Orderback.php 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\model\ActionLog;
  4. use app\admin\model\DataGroup as DataGroupModel;
  5. use app\admin\model\GoodLog;
  6. use app\admin\model\GoodStockInfo;use app\admin\model\ProcessOrder;
  7. use think\App;
  8. use think\Exception;
  9. use think\facade\Db;
  10. use think\facade\Validate;
  11. //退货单
  12. class Orderback extends Base
  13. {
  14. public function __construct(App $app)
  15. {
  16. parent::__construct($app);
  17. }
  18. public function list()
  19. {
  20. $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) : "1";
  21. $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) : "10";
  22. $where = [['a.is_del', "=", 0]];
  23. $thNo = isset($this->post['thNo']) && $this->post['thNo'] != "" ? trim($this->post['thNo']) : "";
  24. if ($thNo != "") {
  25. $where[] = ['a.thNo', "like", "%{$thNo}%"];
  26. }
  27. $status = isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) : "";
  28. if ($status !== "") {
  29. // $where['status'] = $status;
  30. $where[] = ['a.status', "=", $status];
  31. }
  32. $post_code = isset($this->post['post_code']) && $this->post['post_code'] != "" ? trim($this->post['post_code']) : "";
  33. if ($post_code != "") {
  34. $where[] = ['a.post_code', "like", "%{$post_code}%"];
  35. }
  36. $post_compay = isset($this->post['post_compay']) && $this->post['post_compay'] != "" ? trim($this->post['post_compay']) : "";
  37. if ($post_compay != "") {
  38. $where[] = ['a.post_company', "=", $post_compay];
  39. }
  40. $customer_code = isset($this->post['customer_code']) && $this->post['customer_code'] != "" ? trim($this->post['customer_code']) : "";
  41. if ($customer_code != "") {
  42. $where[] = ['a.customer_code', "like", "%{$customer_code}%"];
  43. }
  44. $relaComNo = isset($this->post['relaComNo']) && $this->post['relaComNo'] != "" ? trim($this->post['relaComNo']) : "";
  45. if ($relaComNo != "") $where[] = ['b.supplierNo', '=', $relaComNo];
  46. $order_code = isset($this->post['order_code']) && $this->post['order_code'] != "" ? trim($this->post['order_code']) : "";
  47. if ($order_code != "") {
  48. $where[] = ['a.orderCode', "like", "%{$order_code}%"];
  49. }
  50. $out_code = isset($this->post['out_code']) && $this->post['out_code'] != "" ? trim($this->post['out_code']) : "";
  51. if ($out_code != "") {
  52. $where[] = ['a.outCode', "like", "%{$out_code}%"];
  53. }
  54. $return_code = isset($this->post['return_code']) && $this->post['return_code'] != "" ? trim($this->post['return_code']) : "";
  55. if ($return_code != "") {
  56. $where[] = ['a.returnCode', "like", "%{$return_code}%"];
  57. }
  58. $start = isset($this->post['start']) && $this->post['start'] != '' ? $this->post['start'] : "";
  59. if ($start !== "") {
  60. $where[] = ['a.addtime', ">=", $start];
  61. }
  62. $end = isset($this->post['end']) && $this->post['end'] != '' ? $this->post['end'] : "";
  63. if ($end !== "") {
  64. $where[] = ['a.addtime', "<=", $end];
  65. }
  66. $order_source = $order_source = isset($this->post['order_source']) && $this->post['order_source'] != "" ? trim($this->post['order_source']) : "";
  67. if ($order_source !== "") {
  68. $where[] = ['b.order_source', "=", $order_source];
  69. }
  70. $supplierNo = $this->post['supplierNo'] ?? '';
  71. if ($supplierNo !== '') {
  72. $spuCode = Db::name('good_basic')
  73. ->where(['is_del' => 0, 'supplierNo' => $supplierNo])
  74. ->column('spuCode');
  75. $where[] = ['b.good_code', 'in', $spuCode];
  76. }
  77. $condition = [];
  78. // $role=$this->checkRole();
  79. // if(!empty($role['write']) && $this->uid!=""){
  80. // // $where[]=["a.apply_id","in",$role['write']];
  81. // $condition .="cgderid = {$this->uid} or apply_id in (".implode(',',$role['write']).")";
  82. // }
  83. // $hand = resign_hand_user($this->uid);
  84. // $role = $this->checkDataShare();
  85. // if (!empty($role[DataGroupModel::$type_全部])) $condition .= "cgderid in {$hand} or apply_id in (" . implode(',',
  86. // $role[DataGroupModel::$type_全部]) . ")";
  87. //只有level2的账号过滤数据权限
  88. if ($this->level == 2) {
  89. $role = $this->checkDataShare();
  90. $hand = resign_hand_user($this->uid, 0);
  91. if (!empty($role[DataGroupModel::$type_全部])) {
  92. $arr = array_unique(array_merge($hand, $role[DataGroupModel::$type_全部]));
  93. $condition[] = ['a.apply_id', 'in', $arr];
  94. $condition[] = ['a.cgderid', 'in', $hand];
  95. }
  96. }
  97. //供应商账号不允许看到库存品数据
  98. if ($this->level == 3) $where[] = ['b.is_stock', '<>', 1];
  99. // if(!empty($role['platform']) ){
  100. // $where[]=["platform_id","in",$role['platform']];
  101. // }
  102. $count = Db::name("order_back")
  103. ->alias('a')
  104. ->leftJoin('sale b', 'b.orderCode=a.orderCode AND b.is_del=0')
  105. ->where($where)
  106. ->where(function ($query) use ($condition) {
  107. $query->whereOr($condition);
  108. })
  109. ->count('a.id');
  110. $total = ceil($count / $size);
  111. $page = $page >= $total ? $total : $page;
  112. $list = Db::name("order_back")
  113. ->alias('a')
  114. ->leftJoin('sale b', 'b.orderCode=a.orderCode AND b.is_del=0')
  115. ->where($where)
  116. ->where(function ($query) use ($condition) {
  117. $query->whereOr($condition);
  118. })
  119. ->field('a.*,b.order_source,b.supplierNo')
  120. ->page($page, $size)
  121. ->order("a.addtime desc")
  122. ->select()
  123. ->toArray();
  124. $data = [];
  125. $all_wsm = Db::name("warehouse_info")
  126. ->alias("a")
  127. ->where(["a.wsm_code" => array_column($list, 'return_wsm')])
  128. ->column("a.name,a.supplierNo", 'a.wsm_code');//b.name,b.code
  129. $userCommon = new \app\admin\common\User();
  130. $names = $userCommon->handle('getCodeAndName', ['code' => array_unique(array_merge(array_column($all_wsm, 'supplierNo'), array_column($list, 'customer_code'), array_column($list, 'supplierNo')))]);
  131. foreach ($list as $value) {
  132. $value['wsm_name'] = "";
  133. $value['wsm_supplier'] = '';
  134. $value['wsm_supplierNo'] = '';
  135. if ($value['return_wsm'] != "") {
  136. // $wsmcode = Db::name("warehouse_info")
  137. // ->alias("a")
  138. //// ->leftJoin("supplier b","a.supplierNo=b.code")
  139. // ->where(["a.wsm_code"=>$value['return_wsm']])
  140. // ->field("a.name as wsm_name,a.supplierNo")//b.name,b.code
  141. // ->find();
  142. $value['wsm_name'] = $all_wsm[$value['return_wsm']]['name'] ?? '';//isset($wsmcode['wsm_name']) ? $wsmcode['wsm_name']:"";
  143. $value['wsm_supplier'] = $names['data'][$all_wsm[$value['return_wsm']]['supplierNo']] ?? '';//isset($wsmcode['name']) ? $wsmcode['name']:"";
  144. $value['wsm_supplierNo'] = $all_wsm[$value['return_wsm']]['supplierNo'];//isset($wsmcode['code']) ? $wsmcode['code']:"";
  145. }
  146. $value['customer_name'] = '';
  147. if ($value['customer_code'] != '') {
  148. // $customer = Db::name("customer_info")->where(['companyNo'=>$value['customer_code']])->find();
  149. $value['customer_name'] = $names['data'][$value['customer_code']] ?? '';//isset($customer['companyName'])?$customer['companyName']:'';
  150. }
  151. $inorder = Db::name("order_backinfo")->where(['thNo' => $value['thNo'], "is_del" => 0])->select();
  152. $value['child'] = empty($inorder) ? [] : $inorder;
  153. $value['supplierName'] = $names['data'][$value['supplierNo']] ?? '';//isset($customer['companyName'])?$customer['companyName']:'';
  154. //是否具有编辑权限
  155. // $value['is_allow_update'] = 0;
  156. // if (in_array($this->roleid, [1, 33]) || in_array($value['apply_id'], $role[DataGroupModel::$type_可编辑])) $value['is_allow_update'] = 1;
  157. $data[] = $value;
  158. }
  159. return app_show(0, "获取成功", ["list" => $data, "count" => $count]);
  160. }
  161. /**
  162. * @return \think\response\Json|void
  163. * @throws \think\db\exception\DataNotFoundException
  164. * @throws \think\db\exception\DbException
  165. * @throws \think\db\exception\ModelNotFoundException
  166. */
  167. public function info(){
  168. $thNo = isset($this->post['thNo']) && $this->post['thNo']!="" ? trim($this->post['thNo']):"";
  169. if($thNo==""){
  170. return error_show(1004,"参数thNo不能为空");
  171. }
  172. $info =Db::name("order_back")->where(['thNo'=>$thNo])->find();
  173. if(empty($info)){
  174. return error_show(1004,"未找到数据");
  175. }
  176. $orderinfo = Db::name("sale")->where(["orderCode"=>$info["orderCode"]])->find();
  177. $info['origin_price']=$orderinfo['origin_price'];
  178. $info['sale_price']=$orderinfo['sale_price'];
  179. $info['order_type']=$orderinfo['order_type'];
  180. $info['order_source']=$orderinfo['order_source'];
  181. $info['total_price']=$orderinfo['total_price'];
  182. $info['companyNo']=$orderinfo['supplierNo'];
  183. // $info['company'] = Db::name('business')
  184. // ->where(['companyNo' => $orderinfo['supplierNo'], 'is_del' => 0])
  185. // ->value('company','');
  186. $info['addr_cn']=GetAddr($info['addr_code']);
  187. if($orderinfo['order_type']==3){
  188. $goon = Db::name("good_zixun")->where(["spuCode"=>$orderinfo['good_code'],"is_del"=>0])->find();
  189. $is_stock=0;
  190. }else {
  191. $goon = Db::name('good_platform')->alias('a')->join('good b', 'b.spuCode=a.spuCode', 'left')
  192. ->where(['a.skuCode' => $orderinfo['skuCode']])->find();
  193. $is_stock=$goon['is_stock'];
  194. }
  195. if (empty($goon)) {
  196. return error_show(1003, "未找到商品数据");
  197. }
  198. $info['out_wsm_name']="";
  199. $info['out_wsm_supplier']='';
  200. $info['out_wsm_supplierNo']='';
  201. if($is_stock==1){
  202. $out =Db::name("order_out")->where(['outCode'=>$info['outCode']])->find();
  203. if($out==false){
  204. return error_show(1003, "未找到出库单数据");
  205. }
  206. if($out['wsm_code']!=''){
  207. // $wsmcode = Db::name("warehouse_info")
  208. // ->alias("a")
  209. //// ->leftJoin("supplier b","a.supplierNo=b.code")
  210. // ->where(["a.wsm_code"=>$out['wsm_code']])
  211. // ->field("a.name as wsm_name")
  212. // ->find();
  213. // $info['out_wsm_name'] =isset($wsmcode['wsm_name']) ? $wsmcode['wsm_name']:"";
  214. // $info['out_wsm_supplier'] =isset($wsmcode['name']) ? $wsmcode['name']:"";
  215. // $info['out_wsm_supplierNo'] =isset($wsmcode['code']) ? $wsmcode['code']:"";
  216. }
  217. }
  218. $retutninfo = Db::name("order_return")->where(['returnCode'=>$info['returnCode']])->find();
  219. $info['apply_id'] = $retutninfo['apply_id'];
  220. $info['apply_name'] = $retutninfo['apply_name'];
  221. $info['return_tag'] = $retutninfo['return_tag'];
  222. $int = isset($goon['cat_id']) && $goon['cat_id'] != 0 ? made($goon['cat_id']) : [];
  223. $info['wsm_name']="";
  224. $info['wsm_supplier']='';
  225. $info['wsm_supplierNo']='';
  226. if($info['return_wsm']!=""){
  227. // $wsmcode = Db::name("warehouse_info")
  228. // ->alias("a")
  229. //// ->leftJoin("supplier b","a.supplierNo=b.code")
  230. // ->where(["a.wsm_code"=>$info['return_wsm']])
  231. // ->field("a.name as wsm_name")
  232. // ->find();
  233. // $info['wsm_name'] =isset($wsmcode['wsm_name']) ? $wsmcode['wsm_name']:"";
  234. // $info['wsm_supplier'] =isset($wsmcode['name']) ? $wsmcode['name']:"";
  235. // $info['wsm_supplierNo'] =isset($wsmcode['code']) ? $wsmcode['code']:"";
  236. }
  237. $inorder= Db::name("order_backinfo")->alias("a")->leftJoin("result_info b","a.error_code=b.result_code")
  238. ->where(['a.thNo'=>$info['thNo'],"a.is_del"=>0])->field("a.*,b.result as error_msg")->select();
  239. $info['child']=empty($inorder)? [] : $inorder;
  240. $info['can']=$int;
  241. //补充仓库名称
  242. $warehouse = Db::name('warehouse_info')
  243. ->alias('wi')
  244. ->where(['wi.is_del' => 0, 'wi.status' => 1])
  245. ->whereIn('wi.wsm_code', [$info['can_sell_wsm'], $info['defective_wsm'], $out['wsm_code']??'', $info['return_wsm']])
  246. // ->leftJoin('supplier s', 's.code=wi.supplierNo AND s.is_del=0')
  247. ->column('wi.name,wi.supplierNo', 'wi.wsm_code');
  248. $userCommon = new \app\admin\common\User();
  249. $names = $userCommon->handle('getCodeAndName', ['code' => array_unique(array_merge(array_column($warehouse, 'supplierNo'), [$orderinfo['supplierNo']]))]);
  250. $info['company'] = $names['data'][$orderinfo['supplierNo']] ?? '';
  251. $info['can_sell_wsm_name'] = isset($warehouse[$info['can_sell_wsm']]['name']) ? $warehouse[$info['can_sell_wsm']]['name'] : '';
  252. $info['can_sell_wsm_supplierNo'] = isset($warehouse[$info['can_sell_wsm']]['supplierNo']) ? $warehouse[$info['can_sell_wsm']]['supplierNo'] : '';
  253. $info['can_sell_wsm_supplier'] = isset($warehouse[$info['can_sell_wsm']]['supplierNo']) ? $names['data'][$warehouse[$info['can_sell_wsm']]['supplierNo']]??'' : '';
  254. $info['defective_wsm_name'] = isset($warehouse[$info['defective_wsm']]['name']) ? $warehouse[$info['defective_wsm']]['name'] : '';
  255. $info['defective_wsm_supplierNo'] = isset($warehouse[$info['defective_wsm']]['supplierNo']) ? $warehouse[$info['defective_wsm']]['supplierNo'] : '';
  256. $info['defective_wsm_supplier'] = isset($warehouse[$info['defective_wsm']]['supplierNo'])?$names['data'][$warehouse[$info['defective_wsm']]['supplierNo']]??'' : '';
  257. if (isset($out) && $out['wsm_code'] != '') {
  258. $info['out_wsm_name'] = $warehouse[$info['out_wsm_name']]['name'] ?? '';
  259. $info['out_wsm_supplier'] = $names['data'][$warehouse[$info['out_wsm_name']]['supplierNo']] ?? '';
  260. $info['out_wsm_supplierNo'] = $warehouse[$info['out_wsm_name']]['supplierNo'] ?? '';
  261. }
  262. if ($info['return_wsm'] != '') {
  263. $info['wsm_name'] = $warehouse[$info['wsm_name']]['name'] ?? '';
  264. $info['wsm_supplier'] = $names['data'][$warehouse[$info['wsm_name']]['supplierNo']] ?? '';
  265. $info['wsm_supplierNo'] = $warehouse[$info['wsm_name']]['supplierNo'] ?? '';
  266. }
  267. return app_show(0, "获取成功", $info);
  268. }
  269. /**
  270. * @return \think\response\Json|void
  271. * @throws \think\db\exception\DataNotFoundException
  272. * @throws \think\db\exception\DbException
  273. * @throws \think\db\exception\ModelNotFoundException
  274. */
  275. public function check(){
  276. $thNo = isset($this->post['thNo']) && $this->post['thNo']!="" ? trim($this->post['thNo']):"";
  277. if($thNo==""){
  278. return error_show(1004,"参数thNo不能为空");
  279. }
  280. $info =Db::name("order_back")->where(['thNo'=>$thNo])->find();
  281. if(empty($info)){
  282. return error_show(1004,"未找到数据");
  283. }
  284. $normal = isset($this->post['normal']) && $this->post['normal']!=="" ? intval($this->post['normal']):"";
  285. if($normal===""){
  286. return error_show(1004,"参数normal不能为空");
  287. }
  288. $errorlist = isset($this->post['errorlist']) && $this->post['errorlist']!=="" ? $this->post['errorlist']:[];
  289. if($info['status']== 2){
  290. return error_show(1002,"退货单已验货");
  291. }
  292. $receive=$normal+array_sum(array_column($errorlist,'error_num'));
  293. $remark = isset($this->post['remark']) && $this->post['remark']!=="" ? trim($this->post['remark']):"";
  294. $info['received_num'] = $receive;
  295. $info['normal_num'] = $normal;
  296. $info['remark'] = $remark;
  297. $str = $info['status'];
  298. $info['status'] =empty($errorlist)?3: 2;
  299. $info['updatetime'] = date("Y-m-d H:i:s");
  300. Db::startTrans();
  301. try{
  302. $up=Db::name("order_back")->save($info);
  303. if($up){
  304. $stn = ["order_code"=>$info['thNo'],"status"=>$str,"action_remark"=>'',"action_type"=>"edit"];
  305. ActionLog::logAdd(['id' => $this->uid, 'nickname' => $this->uname],$stn,"CKTHD",$info['status'],$info);
  306. if($info['status'] == 2) $roleid = [10, 31, 41];//特殊处理,写入到10采购负责人、31库管人员、41库管-张凯旋这三个角色下的所有人
  307. else $roleid = [31,41];//特殊处理,写入到31库管人员、41库管-张凯旋这三个角色下的所有人
  308. $handle_user_list = Db::name('user_role')
  309. ->where('is_del', 0)
  310. ->whereIn('roleid', $roleid)
  311. ->column('uid');
  312. $process = ["order_code" => $info['thNo'], "order_id" => $info['id'], "order_status" => $info['status'], 'order_type' => "CKTHD", "before_status" => $str, 'handle_user_list' => implode(',', $handle_user_list)];
  313. ProcessOrder::AddProcess(['id' => $this->uid, 'nickname' => $this->uname], $process);
  314. if(empty($errorlist)){
  315. Db::commit();
  316. return app_show(0,'更新成功');
  317. }
  318. foreach($errorlist as $value){
  319. $data=[];
  320. isset($value['id'])&&$value['id']!=''?$data['id']=$value['id']:"";
  321. $data['thNo']=$thNo;
  322. $data['error_num']=$value['error_num'];
  323. $data['error_code']=$value['error_code'];
  324. $data['error_remark']=$value['error_remark'];
  325. $data['is_del']=isset($value['is_del'])?$value['is_del']:0;
  326. isset($value['id'])&&$value['id']!=''? "" : $data['addtime']=date("Y-m-d H:i:s");
  327. $data['updatetime']=date("Y-m-d H:i:s");
  328. $in = Db::name("order_backinfo")->save($data);
  329. if(!$in){
  330. Db::rollback();
  331. return error_show(1005,'更新失败');
  332. }
  333. }
  334. Db::commit();
  335. return app_show(0,'更新成功');
  336. }
  337. Db::rollback();
  338. return error_show(1005,'更新失败');
  339. }catch (\Exception $e){
  340. Db::rollback();
  341. return error_show(1004,$e->getMessage());
  342. }
  343. }
  344. public function CheckExam(){
  345. $thNo = isset($this->post['thNo']) && $this->post['thNo']!="" ? trim($this->post['thNo']):"";
  346. if($thNo==""){
  347. return error_show(1004,"参数thNo不能为空");
  348. }
  349. $info =Db::name("order_back")->where(['thNo'=>$thNo])->find();
  350. if(empty($info)){
  351. return error_show(1004,"未找到数据");
  352. }
  353. $errorlist = isset($this->post['errorlist']) && $this->post['errorlist']!=="" ? $this->post['errorlist']:[];
  354. Db::startTrans();
  355. try{
  356. $temp=$info['status'];
  357. $info['status'] =3;
  358. $info['updatetime'] = date("Y-m-d H:i:s");
  359. $up=Db::name("order_back")->save($info);
  360. if($up){
  361. $stn = ["order_code"=>$thNo,"status"=>$temp,"action_remark"=>'',"action_type"=>"edit"];
  362. ActionLog::logAdd(['id' => $this->uid, 'nickname' => $this->uname], $stn, "CKTHD", $info['status'], $stn);
  363. //特殊处理,写入到31库管人员、41库管-张凯旋这三个角色下的所有人
  364. $handle_user_list = Db::name('user_role')
  365. ->where('is_del', 0)
  366. ->whereIn('roleid', [31, 41])
  367. ->column('uid');
  368. $process = ["order_code" => $info['thNo'], "order_id" => $info['id'], "order_status" => 3, "order_type" => "CKTHD", "before_status" => $temp, 'handle_user_list' => implode(',', $handle_user_list)];
  369. ProcessOrder::AddProcess(['id' => $this->uid, 'nickname' => $this->uname], $process);
  370. if(empty($errorlist)){
  371. $up =Db::name("order_backinfo")->where(["thNo"=>$thNo,"is_del"=>0])->save(["status"=>1,
  372. "updatetime"=>date("Y-m-d H:i:s")]);
  373. if($up){
  374. Db::commit();
  375. return app_show(0,'更新成功');
  376. }else{
  377. Db::rollback();
  378. return error_show(1005,'异常记录数据更新失败');
  379. }
  380. }else{
  381. foreach($errorlist as $value){
  382. $temp=Db::name("order_backinfo")->where(['id'=>$value["id"],"is_del"=>0,"thNo"=>$thNo])->find();
  383. if(empty($temp)){
  384. Db::rollback();
  385. return error_show(1005,'异常记录数据未找到');
  386. }
  387. $temp['status']=$value['status'];
  388. $temp['exam_remark']=$value['remark'];
  389. $temp['updatetime']=date("Y-m-d H:i:s");
  390. $com = Db::name("order_backinfo")->save($temp);
  391. if($com==false){
  392. Db::rollback();
  393. return error_show(1005,'异常记录数据更新失败');
  394. }
  395. }
  396. Db::commit();
  397. return app_show(0,'更新成功');
  398. }
  399. }
  400. Db::rollback();
  401. return error_show(1005,'更新失败');
  402. }catch (\Exception $e){
  403. Db::rollback();
  404. return error_show(1004,$e->getMessage());
  405. }
  406. }
  407. public function Exam(){
  408. $thNo = isset($this->post['thNo']) && $this->post['thNo']!="" ? trim($this->post['thNo']):"";
  409. if($thNo==""){
  410. return error_show(1004,"参数thNo不能为空");
  411. }
  412. $info =Db::name("order_back")->where(['thNo'=>$thNo])->find();
  413. if(empty($info)){
  414. return error_show(1004,"未找到数据");
  415. }
  416. $status = isset($this->post['status']) && $this->post['status']!=="" ? intval($this->post['status']):"";
  417. if($status===""){
  418. return error_show(1004,"参数status不能为空");
  419. }
  420. $return_wsm=isset($this->post["return_wsm"])&&$this->post["return_wsm"]!=""?trim($this->post["return_wsm"]):"";
  421. $normal_num=isset($this->post["normal_num"])&&$this->post["normal_num"]!=""?intval($this->post["normal_num"])
  422. :"";
  423. // $defective_wsm=isset($this->post["defective_wsm"])&&$this->post["defective_wsm"]!=""?trim($this->post["defective_wsm"]):"";
  424. // $defective_num=isset($this->post["defective_num"])&&$this->post["defective_num"]!==""?intval($this->post["defective_num"]):"";
  425. // $loss_num=isset($this->post["loss_num"])&&$this->post["loss_num"]!=""?intval($this->post["loss_num"]):"";
  426. if($status==4){
  427. // if($defective_num===""){
  428. // return error_show(1004,"参数defective_num不能为空");
  429. // }
  430. // if($loss_num===""){
  431. // return error_show(1004,"参数loss_num不能为空");
  432. // }
  433. if($normal_num===""){
  434. return error_show(1004,"参数normal_num不能为空");
  435. }
  436. // if($defective_wsm===""){
  437. // return error_show(1004,"参数defective_wsm不能为空");
  438. // }
  439. if($return_wsm===""){
  440. return error_show(1004,"参数return_wsm不能为空");
  441. }
  442. $info['return_wsm']=$return_wsm;
  443. $info['normal_num']=$normal_num;
  444. // $info['loss_num']=$loss_num;//order_back表里没有这三个字段,不知道是干嘛的
  445. // $info['defective_wsm']=$defective_wsm;
  446. // $info['defective_num']=$defective_num;
  447. }
  448. $remark= isset($this->post['remark']) && $this->post['remark']!="" ? trim($this->post['remark']):"";
  449. Db::startTrans();
  450. try{
  451. $var = $info['status'];
  452. $info['status'] =$status;
  453. $info['remark'] =$remark;
  454. $info['updatetime'] = date("Y-m-d H:i:s");
  455. $up=Db::name("order_back")->save($info);
  456. if($up){
  457. $stn = ["order_code"=>$thNo,"status"=>$var,"action_remark"=>'',"action_type"=>"edit"];
  458. ActionLog::logAdd(['id'=>$this->uid,'nickname'=>$this->uname],$stn,"CKTHD",$info['status'],$this->post);
  459. if (in_array($status, [2, 3])) {
  460. if ($status == 2) $roleid = [10, 31, 41];//特殊处理,写入到10采购负责人、31库管人员、41库管-张凯旋这三个角色下的所有人
  461. else $roleid = [31, 41];//特殊处理,写入到、31库管人员、41库管-张凯旋这三个角色下的所有人
  462. $handle_user_list = Db::name('user_role')
  463. ->where('is_del', 0)
  464. ->whereIn('roleid', $roleid)
  465. ->column('uid');
  466. $process = ["order_code" => $info['thNo'], "order_id" => $info['id'], "order_status" => $status, "order_type" => "CKTHD", "before_status" => $var, 'handle_user_list' => implode(',', $handle_user_list)];
  467. } else $process = ["order_code" => $info['thNo'], "order_id" => $info['id'], "order_status" => $status, "order_type" => "CKTHD", "before_status" => $var];
  468. ProcessOrder::AddProcess(['id' => $this->uid, 'nickname' => $this->uname], $process);
  469. Db::commit();
  470. return app_show(0,'更新成功');
  471. }
  472. Db::rollback();
  473. return error_show(1005,'更新失败');
  474. }catch (\Exception $e){
  475. Db::rollback();
  476. return error_show(1004,$e->getMessage());
  477. }
  478. }
  479. //新写一个退货接口
  480. public function ExamNew()
  481. {
  482. $param = $this->request->only(['thNo', 'status', 'status_remark', 'can_sell_wsm' => '', 'can_sell_num' => 0, 'defective_wsm' => '', 'defective_num' => 0, 'loss_num' => 0], 'post', 'trim');
  483. $val = Validate::rule(['thNo|退货编码' => 'require', 'status|状态' => 'require|number|in:4,2,1', 'status_remark|备注' => 'checkRemark:']);
  484. $val->extend('checkRemark', function ($val, $rule, $data) {
  485. return $data['status'] == 4 ? true : (empty($val) ? '请填写备注' : true);
  486. });
  487. if (!$val->check($param)) return error_show(1004, $val->getError());
  488. Db::startTrans();
  489. try {
  490. $info = Db::name("order_back")
  491. ->field('id,order_type,status,outCode,good_code,return_num,orderCode,returnCode,apply_id,apply_name')
  492. ->where(['thNo' => $param['thNo'], 'is_del' => 0])
  493. ->find();
  494. if (empty($info)) throw new Exception('未找到数据');
  495. $sale= Db::name('sale')->where(['orderCode'=>$info['orderCode'],"is_del"=>0])->find();
  496. if($sale==false){
  497. Db::rollback();
  498. return error_show(1004,"未找到销售单数据");
  499. }
  500. $spuCode= $info['good_code'];
  501. if($sale['order_type']!=1){
  502. if($sale['order_type']==3){
  503. $goon = Db::name("good_zixun")->where(["spuCode"=>$sale['good_code'],"is_del"=>0])->find();
  504. $isZx=1;
  505. }else {
  506. $goon = Db::name('good_basic')->where(['spuCode' => $sale['good_code']])->find();
  507. $isZx=2;
  508. }
  509. $spuCode = $this->CheckGoodZx($goon,$isZx,$param['thNo']);
  510. }
  511. $out =Db::name("order_out")->where(['outCode'=>$info['outCode']])->find();
  512. if($out==false){
  513. Db::rollback();
  514. return error_show(1004,"未找到发货单数据");
  515. }
  516. $returninfo =Db::name("order_return")->where(['returnCode'=>$info['returnCode']])->find();
  517. if($returninfo==false){
  518. Db::rollback();
  519. return error_show(1004,"未找到售后单数据");
  520. }
  521. $sabebn =Db::name("sale_info")->where([["orderCode",'=',$info['orderCode']],["num",">",0]])->select()->toArray();
  522. if($param['can_sell_num']!=0&& $param['can_sell_wsm']!=''){
  523. // if($sale['is_stock']==1){ //库存品退回原仓库 备库单释放数量 采购单
  524. // $param['can_sell_wsm'] = $out['wsm_code'];
  525. // }
  526. $stock = Db::name("good_stock")->where(["spuCode"=>$spuCode,'wsm_code'=>$param['can_sell_wsm']])
  527. ->find();
  528. if(empty($stock)) {
  529. $stock=[
  530. "spuCode"=>$spuCode,
  531. "wsm_code"=>$param['can_sell_wsm'],
  532. "usable_stock"=>0,
  533. "wait_out_stock"=>0,
  534. "wait_in_stock"=>0,
  535. "total_stock"=>0,
  536. "addtime"=>date("Y-m-d H:i:s"),
  537. "updatetime"=>date("Y-m-d H:i:s"),
  538. ];
  539. }
  540. $stock['usable_stock']+=$param['can_sell_num'];
  541. $stock['updatetime']=date("Y-m-d H:i:s");
  542. $st_up = Db::name("good_stock")->save($stock);
  543. if($st_up==false){
  544. return error_show(1005,'可售商品入库失败');
  545. }
  546. $stockid = isset($stock['id']) ? $stock['id'] : Db::name("good_stock")->getLastInsID();
  547. if(!empty($sabebn)){
  548. $total_num =$param['can_sell_num'];
  549. foreach ($sabebn as $ve){
  550. $tempnum=0;
  551. if ($total_num==0) break;
  552. if($total_num>=$ve['num']){
  553. $tempnum = $ve['num'];
  554. $total_num-=$ve['num'];
  555. $ve['th_num']+=$ve['num'];
  556. $ve['num']=0;
  557. }else{
  558. $tempnum = $total_num;
  559. $ve['num']-=$total_num;
  560. $ve['th_num']+=$total_num;
  561. $total_num=0;
  562. }
  563. $bnin=GoodStockInfo::ReturnAdd($stockid,$ve['bnCode'],$tempnum,$ve['stockid']);
  564. if($bnin==false){
  565. Db::rollback();
  566. return error_show(1005, '可售商品Bn库存数入库失败');
  567. }
  568. $up=Db::name("sale_info")->save($ve);
  569. if($up==false){
  570. Db::rollback();
  571. return error_show(1005, '可售商品Bn库存数入库失败');
  572. }
  573. $bnin=GoodStockInfo::ReturnBn($info['returnCode'],$ve['id'],$tempnum);
  574. if($bnin==false){
  575. Db::rollback();
  576. return error_show(1005, '可售商品Bn库存数入库失败');
  577. }
  578. }
  579. }else{
  580. if($sale['order_type']==1){
  581. $ordernum = Db::name("order_num")->where(['orderCode' =>$info['orderCode']])->find();
  582. if ($ordernum == false) {
  583. Db::rollback();
  584. return error_show(1005, '未找到关联采购单');
  585. }
  586. $cgd = Db::name("purchease_order")->where(["cgdNo" => $ordernum['cgdNo'], "is_del" => 0])->find();
  587. if ($cgd == false) {
  588. Db::rollback();
  589. return error_show(1005, '未找到采购单数据');
  590. }
  591. $bn =makeNo("BN");
  592. $yp=GoodStockInfo::AddBn($stockid,$bn,$param['can_sell_num'],$cgd['good_price']);
  593. if($yp==false){
  594. Db::rollback();
  595. return error_show(1005, '商品批次退货入库失败');
  596. }
  597. }
  598. }
  599. $good_data=['good_log_code'=>$param['thNo'],"stock_id"=> $stockid,"type"=>1,'stock'=>$param['can_sell_num'],"stock_name"=>"usable_stock"];
  600. GoodLog::LogAdd($this->post['token'],$good_data,'RKTHD');
  601. }
  602. if($param['defective_num']!=0&& $param['defective_wsm']!=''){
  603. $defective = Db::name("good_stock")->where(["spuCode"=>$spuCode,'wsm_code'=>$param['defective_wsm']])->find();
  604. if(empty($defective)) {
  605. $defective=[
  606. "spuCode"=>$spuCode,
  607. "wsm_code"=>$param['defective_wsm'],
  608. "usable_stock"=>0,
  609. "wait_out_stock"=>0,
  610. "wait_in_stock"=>0,
  611. "total_stock"=>0,
  612. "addtime"=>date("Y-m-d H:i:s"),
  613. "updatetime"=>date("Y-m-d H:i:s"),
  614. ];
  615. $order = ["order_code"=>$spuCode,"status"=>1,"action_remark"=>'', "action_type"=>"create"];
  616. }else{
  617. $order = ["order_code"=>$spuCode,"status"=>1,"action_remark"=>'', "action_type"=>"edit"];
  618. }
  619. $defective['usable_stock']+=$param['defective_num'];
  620. $defective['updatetime'] = date("Y-m-d H:i:s");
  621. $upd= Db::name("good_stock")->save($defective);
  622. if($upd==false){
  623. Db::rollback();
  624. return error_show(1005,'次品商品入库失败');
  625. }
  626. $stockid = isset($defective['id']) ? $defective['id'] : Db::name("good_stock")->getLastInsID();
  627. $sabebn =Db::name("sale_info")->where(["orderCode"=>$info['orderCode']])->select()->toArray();
  628. if(!empty($sabebn)){
  629. $total_num =$param['defective_num'];
  630. foreach ($sabebn as $ve){
  631. $tempnum=0;
  632. if ($total_num==0) break;
  633. if($total_num>=$ve['num']){
  634. $tempnum = $ve['num'];
  635. $total_num-=$ve['num'];
  636. $ve['th_num']+=$ve['num'];
  637. $ve['num']=0;
  638. }else{
  639. $tempnum = $total_num;
  640. $ve['num']-=$total_num;
  641. $ve['th_num']+=$total_num;
  642. $total_num=0;
  643. }
  644. $bnin=GoodStockInfo::ReturnAdd($stockid,$ve['bnCode'],$tempnum,$ve['stockid']);
  645. if($bnin==false){
  646. Db::rollback();
  647. return error_show(1005, '可售商品Bn库存数入库失败');
  648. }
  649. $up=Db::name("sale_info")->save($ve);
  650. if($up==false){
  651. Db::rollback();
  652. return error_show(1005, '可售商品Bn库存数入库失败');
  653. }
  654. $bnin=GoodStockInfo::ReturnBn($info['returnCode'],$ve['id'],$tempnum);
  655. if($bnin==false){
  656. Db::rollback();
  657. return error_show(1005, '可售商品Bn库存数入库失败');
  658. }
  659. }
  660. }else{
  661. if($sale['order_type']==1){
  662. $ordernum = Db::name("order_num")->where(['orderCode' =>$info['orderCode']])->find();
  663. if ($ordernum == false) {
  664. Db::rollback();
  665. return error_show(1005, '未找到关联采购单');
  666. }
  667. $cgd = Db::name("purchease_order")->where(["cgdNo" => $ordernum['cgdNo'], "is_del" => 0])->find();
  668. if ($cgd == false) {
  669. Db::rollback();
  670. return error_show(1005, '未找到采购单数据');
  671. }
  672. $bn =makeNo("BN");
  673. $yp=GoodStockInfo::AddBn($stockid,$bn,$param['defective_num'],$cgd['good_price']);
  674. if($yp==false){
  675. Db::rollback();
  676. return error_show(1005, '商品批次退货入库失败');
  677. }
  678. }
  679. }
  680. $good_data=['good_log_code'=>$param['thNo'],"stock_id"=>isset($defective['id'])? $defective['id']:Db::name("good_stock")->getLastInsID(),"type"=>1,'stock'=>$param['defective_num'],"stock_name"=>"usable_stock"];
  681. GoodLog::LogAdd($this->post['token'],$good_data,'RKTHD');
  682. }
  683. $update_data = ['status' => $param['status'], 'updatetime' => date('Y-m-d H:i:s')];
  684. //status==4通过,其他值表示驳回
  685. if ($param['status'] != 4) $update_data['status_remark'] = $param['status_remark'];
  686. else {
  687. $update_data['can_sell_wsm'] = $param['can_sell_wsm'];
  688. $update_data['can_sell_num'] = $param['can_sell_num'];
  689. $update_data['defective_wsm'] = $param['defective_wsm'];
  690. $update_data['defective_num'] = $param['defective_num'];
  691. $update_data['loss_num'] = $param['loss_num'];
  692. if($sale['is_stock']==1){
  693. $sale['th_num']+= $info['return_num'];
  694. if($sale['th_num']==$sale['send_num']&& $sale['wsend_num']==0){
  695. $sale['status']=3;
  696. }
  697. $sale['th_fee']+= round($info['return_num']*$sale['sale_price'],2);
  698. $sale['updatetime']= date("Y-m-d H:i:s");
  699. $uap=Db::name("sale")->save($sale);
  700. if($uap==false){
  701. Db::rollback();
  702. return error_show(1005,'销售单订单更新失败');
  703. }
  704. // $ordernum =Db::name("order_num")->where(['orderCode'=>$info['orderCode']])->find();
  705. // if($ordernum==false){
  706. // Db::rollback();
  707. // return error_show(1005,'未找到关联采购单');
  708. // }
  709. // $ordernum['send_num']-=$info['return_num'];
  710. // $orderup =Db::name("order_num")->save($ordernum);
  711. // if($orderup==false){
  712. // Db::rollback();
  713. // return error_show(1005,'关联数据更新失败');
  714. // }
  715. // $cgd =Db::name("purchease_order")->where(["cgdNo"=>$ordernum['cgdNo'],"is_del"=>0])->find();
  716. // if($cgd==false){
  717. // Db::rollback();
  718. // return error_show(1005,'未找到采购单数据');
  719. // }
  720. // $cgd['th_fee']+= round($cgd['good_price']*$param['can_sell_num'],2);
  721. // $cgd['th_num']+= $param['can_sell_num'];
  722. // if($cgd['th_num']==$cgd['send_num']&& $cgd['wsend_num']==0){
  723. // $cgd['status']=4;
  724. // }
  725. // $cgd['updatetime']= date("Y-m-d H:i:s");
  726. // $cgdup =Db::name("purchease_order")->save($cgd);
  727. // if($cgdup==false){
  728. // Db::rollback();
  729. // return error_show(1005,'采购单数据更新失败');
  730. // }
  731. // if($cgd['bkcode']!=""){
  732. // $bk=Db::name("purchease_order")->where(["bkcode"=>$cgd['bkcode'],"order_type"=>1,"order_source"=>0,"is_del"=>0])->find();
  733. // if($bk==false){
  734. // Db::rollback();
  735. // return error_show(1005,'未找到备库单数据');
  736. // }
  737. // $orderbk = Db::name("order_bk")->where(['cgdNo'=>$bk['cgdNo'],"is_del"=>0])->find();
  738. // if($orderbk==false){
  739. // Db::rollback();
  740. // return error_show(1005,'备库单未完全入库');
  741. // }
  742. // $merge_num = Db::name("purchease_order")->where(["bkcode"=>$bk['bkcode'],"order_type"=>1,"is_del"=>0])->where("order_source","<>",0)->field("sum(send_num)-sum(th_num) as num")->find();
  743. //
  744. // $orderbk['balance_num']=$orderbk['total_num']-$merge_num['num'];
  745. // $orderbk['merge_num']=$merge_num['num'];
  746. // $orderbk['updatetime']=date("Y-m-d H:i:s");
  747. // $orderbkup=Db::name("order_bk")->save($orderbk);
  748. // if($orderbkup==false){
  749. // Db::rollback();
  750. // return error_show(1005,'备库单库存数据释放失败');
  751. // }
  752. // }
  753. }else{
  754. if($returninfo['return_tag']==1){
  755. $sale['th_num']+= $info['return_num'];
  756. if($sale['th_num']==$sale['send_num']&& $sale['wsend_num']==0){
  757. $sale['status']=3;
  758. }
  759. $sale['th_fee']+= round($info['return_num']*$sale['sale_price'],2);
  760. $sale['updatetime']= date("Y-m-d H:i:s");
  761. $uap=Db::name("sale")->save($sale);
  762. if($uap==false){
  763. Db::rollback();
  764. return error_show(1005,'销售单订单更新失败');
  765. }
  766. $ordernum =Db::name("order_num")->where(['orderCode'=>$info['orderCode']])->find();
  767. if($ordernum==false){
  768. Db::rollback();
  769. return error_show(1005,'未找到关联采购单');
  770. }
  771. $ordernum['send_num']-=$info['return_num'];
  772. $orderup =Db::name("order_num")->save($ordernum);
  773. if($orderup==false){
  774. Db::rollback();
  775. return error_show(1005,'关联数据更新失败');
  776. }
  777. $cgd =Db::name("purchease_order")->where(["cgdNo"=>$ordernum['cgdNo'],"is_del"=>0])->find();
  778. if($cgd==false){
  779. Db::rollback();
  780. return error_show(1005,'未找到采购单数据');
  781. }
  782. $cgd['th_num']+= $info['return_num'];
  783. if($cgd['th_num']==$cgd['send_num']&& $cgd['wsend_num']==0){
  784. $cgd['status']=4;
  785. }
  786. $cgd['th_fee']+= round($info['return_num']*$cgd['good_price'],2);
  787. $cgd['updatetime']= date("Y-m-d H:i:s");
  788. $cgdup =Db::name("purchease_order")->save($cgd);
  789. if($cgdup==false){
  790. Db::rollback();
  791. return error_show(1005,'采购单数据更新失败');
  792. }
  793. }else{
  794. $sale['th_num']+= $info['return_num'];
  795. if($sale['th_num']==$sale['send_num']&& $sale['wsend_num']==0){
  796. $sale['status']=3;
  797. }
  798. $sale['th_fee']+= round($info['return_num']*$sale['sale_price'],2);
  799. $sale['updatetime']= date("Y-m-d H:i:s");
  800. $uap=Db::name("sale")->save($sale);
  801. if($uap==false){
  802. Db::rollback();
  803. return error_show(1005,'销售单订单更新失败');
  804. }
  805. // $ordernum =Db::name("order_num")->where(['orderCode'=>$info['orderCode']])->find();
  806. // if($ordernum==false){
  807. // Db::rollback();
  808. // return error_show(1005,'未找到关联采购单');
  809. // }
  810. // $ordernum['send_num']-=$info['return_num'];
  811. // $orderup =Db::name("order_num")->save($ordernum);
  812. // if($orderup==false){
  813. // Db::rollback();
  814. // return error_show(1005,'关联数据更新失败');
  815. // }
  816. // $cgd =Db::name("purchease_order")->where(["cgdNo"=>$ordernum['cgdNo'],"is_del"=>0])->find();
  817. // if($cgd==false){
  818. // Db::rollback();
  819. // return error_show(1005,'未找到采购单数据');
  820. // }
  821. // $cgd['th_fee']+= round($cgd['good_price']*$param['can_sell_num'],2);
  822. // $cgd['th_num']+= $param['can_sell_num'];
  823. // if($cgd['th_num']==$cgd['send_num']&& $cgd['wsend_num']==0){
  824. // $cgd['status']=4;
  825. // }
  826. // $cgd['updatetime']= date("Y-m-d H:i:s");
  827. // $cgdup =Db::name("purchease_order")->save($cgd);
  828. // if($cgdup==false){
  829. // Db::rollback();
  830. // return error_show(1005,'采购单数据更新失败');
  831. // }
  832. }
  833. }
  834. }
  835. $res = Db::name("order_back")
  836. ->where(['id' => $info['id']])
  837. ->update($update_data);
  838. if ($res) {
  839. $data=[
  840. "orderCode"=>$info['orderCode'],
  841. "th_type"=>3,
  842. "th_num"=>$info['return_num'],
  843. "th_fee"=>round($info['return_num']*$sale['sale_price'],2),
  844. "thCode"=>$info['returnCode'],
  845. "apply_id"=>$info['apply_id'],
  846. "apply_name"=>$info['apply_name'],
  847. "spuCode"=>$sale['good_code'],
  848. "good_name"=>$sale['good_name'],
  849. "cat_id"=>$sale['cat_id'],
  850. "addtime"=>date("Y-m-d H:i:s"),
  851. "status"=>1,
  852. "is_del"=>0
  853. ];
  854. $inse=Db::name("th_data")->insert($data);
  855. if($inse==false){
  856. Db::rollback();
  857. return error_show(1004,"退货单更新失败");
  858. }
  859. if($info['return_num']>=$out['send_num']){
  860. $out['status']=4;
  861. $out['updatetime']=date("Y-m-d H:i:s");
  862. $upout =Db::name("order_out")->save($out);
  863. if($upout==false){
  864. Db::rollback();
  865. return error_show(1005,'出库单数据更新失败');
  866. }
  867. }
  868. $stn = ["order_code" => $param['thNo'], "status" => $info['status'], "action_remark" => '', "action_type" => "edit"];
  869. ActionLog::logAdd(['id'=>$this->uid,'nickname'=>$this->uname], $stn, "CKTHD", $param['status'], $stn);
  870. if (in_array($param['status'], [1,2, 3])) {
  871. if ($param['status'] == 2) $roleid = [10, 31, 41];//特殊处理,写入到10采购负责人、31库管人员、41库管-张凯旋这三个角色下的所有人
  872. else $roleid = [31, 41];//特殊处理,写入到、31库管人员、41库管-张凯旋这三个角色下的所有人
  873. $handle_user_list = Db::name('user_role')
  874. ->where('is_del', 0)
  875. ->whereIn('roleid', $roleid)
  876. ->column('uid');
  877. //如果是退货商品验收(节点1),把供应商负责人也加进去
  878. if ($param['status'] == 1) $handle_user_list[] = $sale['cgderid'];
  879. $process = ["order_code" => $param['thNo'], "order_id" => $info['id'], "order_status" => $param['status'], "order_type" => "CKTHD", "before_status" => $info['status'], 'handle_user_list' => implode(',', $handle_user_list)];
  880. } else $process = ["order_code" => $param['thNo'], "order_id" => $info['id'], "order_status" => $param['status'], "order_type" => "CKTHD", "before_status" => $info['status']];
  881. ProcessOrder::AddProcess(['id' => $this->uid, 'nickname' => $this->uname], $process);
  882. Db::commit();
  883. return app_show(0, '操作成功');
  884. } else throw new Exception('操作失败');
  885. } catch (Exception $exception) {
  886. Db::rollback();
  887. return error_show(1005, $exception->getMessage());
  888. }
  889. }
  890. }