Orderback.php 48 KB

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