Orderback.php 47 KB

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