After.php 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\model\ActionLog;
  4. use app\admin\model\ProcessOrder;
  5. use think\App;
  6. use think\Exception;
  7. use think\facade\Db;
  8. use think\facade\Validate;
  9. //售后
  10. class After extends \app\BaseController
  11. {
  12. public $post=[];
  13. public function __construct(App $app)
  14. {
  15. parent::__construct($app);
  16. $this->post =$this->request->post();
  17. }
  18. public function create(){
  19. $outCode = isset($this->post['outCode']) &&$this->post['outCode']!=''?trim($this->post['outCode']) :"";
  20. if($outCode==''){
  21. return error_show(1004,"参数outCode 不能为空");
  22. }
  23. $orderout= Db::name("order_out")->where(["outCode"=>$outCode])->find();
  24. if(empty($orderout)){
  25. return error_show(1005,"未找到订单数据");
  26. }
  27. $oder= Db::name("sale")->where(["orderCode"=>$orderout['orderCode'],"is_del"=>0])->find();
  28. if(empty($oder)){
  29. return error_show(1005,"未找到订单数据");
  30. }
  31. $errorCode = isset($this->post['errorCode']) &&$this->post['errorCode']!=''?trim($this->post['errorCode']) :"";
  32. if($outCode==''){
  33. return error_show(1004,"参数errorCode 不能为空");
  34. }
  35. $error =Db::name('result_info')->where(["result_code"=>$errorCode,"is_del"=>0])->find();
  36. if(empty($error)){
  37. return error_show(1005,"未找到退货原因数据");
  38. }
  39. $remark =isset($this->post['remark']) &&$this->post['remark']!=''?trim($this->post['remark']) :"";
  40. $is_receive =isset($this->post['is_receive']) &&$this->post['is_receive']!==''?intval($this->post['is_receive'])
  41. :"";
  42. if($is_receive===""){
  43. return error_show(1004,"参数 is_receive 不能为空");
  44. }
  45. if($is_receive==0){
  46. $num=$orderout['send_num'];
  47. }else{
  48. $num =isset($this->post['num']) &&$this->post['num']!=''?intval($this->post['num']) :"";
  49. if($num==""){
  50. return error_show(1004,"参数 num 不能为空或零");
  51. }
  52. }
  53. $except_code =isset($this->post['except_code']) &&$this->post['except_code']!=''?trim($this->post['except_code']) :"";
  54. $img = isset($this->post['img']) &&$this->post['img']!=''?trim($this->post['img']) :"";
  55. $token = isset($this->post['token'])&&$this->post['token']!='' ? trim($this->post['token']):"";
  56. if($token==''){
  57. return error_show(105,"参数token不能为空");
  58. }
  59. $user =GetUserInfo($token);
  60. if(empty($user)||$user['code']!=0){
  61. return error_show(102,"申请人数据不存在");
  62. }
  63. $rm= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  64. $ri= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  65. $returnCode=makeNo("RS");
  66. Db::startTrans();
  67. try{
  68. $in = [
  69. "returnCode"=>$returnCode,
  70. "outCode"=>$outCode,
  71. "orderCode"=> $oder['orderCode'],
  72. "good_code"=>$oder['good_code'],
  73. "good_name"=>$oder['good_name'],
  74. "customer_code"=>$oder['customer_code'],
  75. "apply_id"=>$rm,
  76. "apply_name"=>$ri,
  77. 'total_num'=>$orderout['send_num'],
  78. "error_code"=>$errorCode,
  79. "error_num"=>$num,
  80. "error_img"=>$img,
  81. "error_msg"=>$error['result'],
  82. "error_remark"=>$remark,
  83. "is_receive"=>$is_receive,
  84. "remark"=>'',
  85. "except_code"=>$except_code,
  86. "order_type"=>$orderout['order_type'],
  87. "status"=>1,
  88. "is_del"=>0,
  89. "addtime"=>date("Y-m-d H:i:s"),
  90. "updatetime"=>date("Y-m-d H:i:s")
  91. ];
  92. $create = Db::name("order_return")->insert($in,true);
  93. $orde = ["order_code"=>$returnCode,"status"=>$in['status'],"action_remark"=>'',"action_type"=>"create"];
  94. ActionLog::logAdd($this->post['token'],$orde,$orderout['order_type']==1?'SHD':"ZXSHD",0,$orde);
  95. if($create>0){
  96. $process=["order_code"=>$returnCode,"order_id"=>$create,"order_status"=>0,"order_type"=>'SHD'];
  97. ProcessOrder::AddProcess($token,$process);
  98. Db::commit();
  99. return app_show(0,"售后申请单新建成功",["returnCode"=>$returnCode]);
  100. }
  101. Db::rollback();
  102. return error_show(1005,"售后申请单新建失败");
  103. }catch (\Exception $e){
  104. Db::rollback();
  105. return error_show(1005,$e->getMessage());
  106. }
  107. }
  108. public function list(){
  109. $page = isset($this->post['page']) && $this->post['page'] !=="" ? intval($this->post['page']):"1";
  110. $size = isset($this->post['size']) && $this->post['size'] !=="" ? intval($this->post['size']):"10";
  111. $where =[['a.is_del',"=",0]];
  112. $bkcode = isset($this->post['returnCode']) && $this->post['returnCode']!="" ? trim($this->post['returnCode']):"";
  113. if($bkcode!=""){
  114. $where[]=['a.returnCode',"like", "%{$bkcode}%"];
  115. }
  116. $out = isset($this->post['outCode']) && $this->post['outCode']!="" ? trim($this->post['outCode']):"";
  117. if($out!=""){
  118. $where[]=['a.outCode',"like", "%{$out}%"];
  119. }
  120. $status = isset($this->post['status']) && $this->post['status']!=="" ? intval($this->post['status']):"";
  121. if($status!==""){
  122. $where[]=['a.status',"=", $status];
  123. }
  124. $order_type = isset($this->post['order_type']) && $this->post['order_type']!=="" ? intval($this->post['order_type']):"";
  125. if($order_type!==""){
  126. $where[]=['a.order_type',"=", $order_type];
  127. }
  128. $orderCode = isset($this->post['orderCode']) && $this->post['orderCode']!="" ? trim($this->post['orderCode'])
  129. :"";
  130. if($orderCode!=""){
  131. $where[]=['a.orderCode',"like", "%{$orderCode}%"];
  132. }
  133. $good_code = isset($this->post['good_code']) && $this->post['good_code']!="" ? trim($this->post['good_code'])
  134. :"";
  135. if($good_code!=""){
  136. $where[]=['a.good_code',"like", "%{$good_code}%"];
  137. }
  138. $good_name = isset($this->post['good_name']) && $this->post['good_name']!="" ? trim($this->post['good_name'])
  139. :"";
  140. if($good_name!=""){
  141. $where[]=['a.good_name',"like", "%{$good_name}%"];
  142. }
  143. $customer_code = isset($this->post['customer_code']) && $this->post['customer_code']!="" ? trim($this->post['customer_code'])
  144. :"";
  145. if($customer_code!=""){
  146. $where[]=['a.customer_code',"like", "%{$customer_code}%"];
  147. }
  148. $except_code = isset($this->post['except_code']) && $this->post['except_code']!="" ? trim($this->post['except_code']):"";
  149. if($except_code!=""){
  150. $where[]=['a.except_code',"=", $except_code];
  151. }
  152. $apply_name = isset($this->post['apply_name']) && $this->post['apply_name']!="" ? trim($this->post['apply_name'])
  153. :"";
  154. if($apply_name!=""){
  155. $where[]=['a.apply_name',"like", "%{$apply_name}%"];
  156. }
  157. $start =isset($this->post['start'])&&$this->post['start']!='' ? $this->post['start']:"";
  158. if($start!==""){
  159. $where[]=['a.addtime',">=", $start];
  160. }
  161. $end =isset($this->post['end'])&&$this->post['end']!='' ? $this->post['end']:"";
  162. if($end!==""){
  163. $where[]=['a.addtime',"<=", $end];
  164. }
  165. $count=Db::name("order_return")->alias("a")->leftJoin("order_returninfo b","a.returnCode=b.returnCode")->where
  166. ($where)->count();
  167. $total = ceil($count/$size);
  168. $page = $total>=$page ? $page :$total;
  169. $list =Db::name("order_return")->alias("a")->leftJoin("order_returninfo b","a.returnCode=b.returnCode")->where($where)
  170. ->field("a.*,b.return_wsm,b.contactor,b.mobile,b.addr,b.addr_code,b.post_code,b.post_company,b.post_fee,b.gys_remark")->page($page,$size)
  171. ->order("addtime desc")->select();
  172. $data=[];
  173. foreach ($list as $value){
  174. $customer = Db::name("customer_info")->where(["companyNo"=>$value['customer_code']])->find();
  175. $value['customer_name'] = isset($customer['companyName']) ?trim($customer['companyName']):'';
  176. $data[]=$value;
  177. }
  178. return app_show(0,"获取成功",['list'=>$data,"count"=>$count]);
  179. }
  180. /**
  181. * @return \think\response\Json|void
  182. * @throws \think\db\exception\DataNotFoundException
  183. * @throws \think\db\exception\DbException
  184. * @throws \think\db\exception\ModelNotFoundException
  185. */
  186. public function info(){
  187. $bkcode = isset($this->post['returnCode']) && $this->post['returnCode']!="" ? trim($this->post['returnCode']):"";
  188. if($bkcode==""){
  189. return error_show(1005,"参数returnCode 不能为空");
  190. }
  191. $info = Db::name("order_return")->alias("a")->leftJoin("order_returninfo b","a.returnCode=b.returnCode")
  192. ->field("a.*,b.return_wsm,b.contactor,b.mobile,b.addr,b.addr_code,b.post_code,b.post_company,b.post_fee,b.gys_remark")
  193. ->where(['a.returnCode'=>$bkcode])->find();
  194. if(empty($info)){
  195. return error_show(1005,"未找到售后数据");
  196. }
  197. $orderinfo = Db::name("sale")->where(["orderCode"=>$info["orderCode"]])->find();
  198. $info['origin_price']=$orderinfo['origin_price'];
  199. $info['order_type']=$orderinfo['order_type'];
  200. $info['sale_price']=$orderinfo['sale_price'];
  201. $info['total_price']=sprintf("%1\$.2f",$orderinfo['sale_price']*$info['error_num']);
  202. if($orderinfo['order_type']==3|| $orderinfo['order_type']==4){
  203. $goon = Db::name("good_zixun")->where(["spuCode"=>$orderinfo['good_code'],"is_del"=>0])->find();
  204. }else {
  205. $goon = Db::name('good_platform')->alias('a')->join('good b', 'b.spuCode=a.spuCode', 'left')
  206. ->where(['a.skuCode' => $orderinfo['skuCode']])->find();
  207. }
  208. if (empty($goon)) {
  209. return error_show(1003, "未找到商品数据");
  210. }
  211. $int = isset($goon['cat_id']) && $goon['cat_id'] != 0 ? made($goon['cat_id']) : [];
  212. list($a,$b,$c)=explode(",",$info['addr_code']);
  213. $addcode =json_encode(["provice_code"=>$a,"city_code"=>$b,"area_code"=>$c]);
  214. $info["addr_cn"]=GetAddr($addcode);
  215. // $info["addr_code"]=json_decode($addcode,true);
  216. $out =Db::name("order_out")->where(["outCode"=>$info['outCode']])->find();
  217. $info['out_num'] = isset($out['send_num'])?$out['send_num']:'';
  218. // $customer = Db::name("customer_info")->where(["companyNo"=>$info['customer_code']])->find();
  219. $wsmcode = Db::name("warehouse_info")
  220. ->alias("a")
  221. ->leftJoin("supplier b","a.supplierNo=b.code")
  222. ->where(["a.wsm_code"=>$info['return_wsm']])
  223. ->field("a.name as wsm_name,b.name,b.code,a.wsm_code,a.contactor_name,a.position,a.mobile,a.addrs_code,a.addr,a.companyNo")
  224. ->find();
  225. $info['wsm_code'] =isset($wsmcode['wsm_code']) ? $wsmcode['wsm_code']:"";
  226. $info['wsm_name'] =isset($wsmcode['wsm_name']) ? $wsmcode['wsm_name']:"";
  227. $info['wsm_supplier'] =isset($wsmcode['name']) ? $wsmcode['name']:"";
  228. $info['wsm_supplierNo'] =isset($wsmcode['code']) ? $wsmcode['code']:"";
  229. $customer = Db::name("business")->field('id,company,companyNo')->where(["companyNo"=>$wsmcode['companyNo']])->find();
  230. $info['customer_name'] = isset($customer['company']) ?trim($customer['company']):'';
  231. $info['customer_code'] = isset($customer['companyNo']) ?trim($customer['companyNo']):'';
  232. $info['can']=$int;
  233. //仓库的联系人、职位、电话、省市区和地址
  234. $info['contactor_name'] = $wsmcode['contactor_name'];//联系人
  235. $info['position'] = $wsmcode['position'];//职位
  236. $info['mobile'] = $wsmcode['mobile'];//电话
  237. $info['addrs_code'] = json_decode($wsmcode['addrs_code'], true);//省市区编码
  238. $info['addr'] = $wsmcode['addr'];//地址
  239. $info['spuCode'] = $orderinfo['good_code'];//地址
  240. $info['skuCode'] = $orderinfo['skuCode'];//地址
  241. return app_show(0,"获取成功",$info);
  242. }
  243. public function status(){
  244. $bkcode = isset($this->post['returnCode']) && $this->post['returnCode']!="" ? trim($this->post['returnCode']):"";
  245. if($bkcode==""){
  246. return error_show(1005,"参数returnCode 不能为空");
  247. }
  248. $info = Db::name("order_return")->where(['returnCode'=>$bkcode])->find();
  249. if(empty($info)){
  250. return error_show(1005,"未找到售后数据");
  251. }
  252. $status = isset($this->post['status']) && $this->post['status']!=="" ? intval($this->post['status'])
  253. :"";
  254. if($status===""){
  255. return error_show(1005,"参数status 不能为空");
  256. }
  257. $orde= Db::name("order_out")->where(["outCode"=>$info['outCode']])->find();
  258. if($orde==false){
  259. return error_show(1005,"未找到出库单数据");
  260. }
  261. $remark = isset($this->post['remark'])&&$this->post['remark']!=''?trim($this->post['remark']):"";
  262. if($remark!=''){
  263. $info['remark'] =$remark;
  264. }
  265. if($status==3 && $info['is_receive']==1){
  266. $post =isset($this->post['is_post'])&&$this->post['is_post']!==""? intval($this->post['is_post']):"";
  267. if($post===""){
  268. return error_show(1005,"参数is_post不能为空");
  269. }
  270. $info['is_post']=$post;
  271. $return_tag =isset($this->post['return_tag'])&&$this->post['return_tag']!==""? intval($this->post['return_tag']):"";
  272. if($return_tag===""){
  273. return error_show(1005,"参数return_tag不能为空");
  274. }
  275. $info['return_tag']=$return_tag;
  276. $is_th =isset($this->post['is_th'])&&$this->post['is_th']!==""? intval($this->post['is_th']):"0";
  277. $info['is_th']=$is_th;
  278. }
  279. // $status = $info['order_status']==1&&$info['order_type']==1 && $status==1?4:$status;
  280. Db::startTrans();
  281. try{
  282. $var=$info['status'];
  283. $info['status']=$status;
  284. $info['updatetime']=date("Y-m-d H:i:s");
  285. $up =Db::name("order_return")->save($info);
  286. if($up){
  287. $order = ["order_code"=>$info['returnCode'],"status"=>$var,"action_remark"=>'',"action_type"=>"edit"];
  288. ActionLog::logAdd($this->post['token'],$order,$info['order_type']==1?'SHD':"ZXSHD", $info['status'],$this->post);
  289. $process=["order_code"=>$info['returnCode'],"order_id"=>$info['id'],"order_status"=>$status,"order_type"=>$info['order_type']==1?'SHD':"ZXSHD"];
  290. ProcessOrder::AddProcess($this->post['token'],$process);
  291. Db::commit();
  292. return app_show(0,"更新成功");
  293. }else{
  294. Db::rollback();
  295. return error_show(1004,"更新失败");
  296. }
  297. }catch (\Exception $e){
  298. Db::rollback();
  299. return error_show(1004,$e->getMessage());
  300. }
  301. }
  302. public function setWsm(){
  303. $bkcode = isset($this->post['returnCode']) && $this->post['returnCode']!="" ? trim($this->post['returnCode']):"";
  304. if($bkcode==""){
  305. return error_show(1005,"参数returnCode 不能为空");
  306. }
  307. $info = Db::name("order_return")->where(['returnCode'=>$bkcode])->find();
  308. if(empty($info)){
  309. return error_show(1005,"未找到售后数据");
  310. }
  311. if($info['status']!=3){
  312. return error_show(1005,"采购主管未审核无法设置退回仓库");
  313. }
  314. $wsm_code = isset($this->post['wsm_code']) && $this->post['wsm_code']!="" ? trim($this->post['wsm_code']) :"";
  315. if($info['return_tag']==2) {
  316. if($wsm_code==""){
  317. return error_show(1005,"参数 wsm_code 不能为空");
  318. }
  319. $warehouse =Db::name("warehouse_info")->where(["wsm_code"=>$wsm_code])->find();
  320. if($warehouse==false){
  321. return error_show(1005,"仓库数据未找到");
  322. }
  323. $wareaddr =Db::name("warehouse_addr")->where(["wsm_code"=>$wsm_code,"is_del"=>0,"status"=>1])->find();
  324. }
  325. $addrcode=isset($this->post['addr_code'])&&$this->post['addr_code']!=""?$this->post['addr_code']:"";
  326. if($addrcode==""){
  327. return error_show(1005,"参数 addr_code 不能为空");
  328. }
  329. $addr=isset($this->post['addr'])&&$this->post['addr']!=""?trim($this->post['addr']):"";
  330. if($addr==""){
  331. return error_show(1005,"参数 addr 不能为空");
  332. }
  333. $mobile=isset($this->post['mobile'])&&$this->post['mobile']!=""?trim($this->post['mobile']):"";
  334. if($mobile==""){
  335. return error_show(1005,"参数 mobile 不能为空");
  336. }
  337. $contactor=isset($this->post['contactor'])&&$this->post['contactor']!=""?trim($this->post['contactor']):"";
  338. if($contactor==""){
  339. return error_show(1005,"参数 contactor 不能为空");
  340. }
  341. $returninfo=[
  342. "returnCode"=>$bkcode,
  343. "return_wsm"=>$wsm_code,
  344. "contactor"=>$contactor,
  345. "mobile"=>$mobile ,
  346. "addr"=>$addr,
  347. "addr_code"=>$addrcode,
  348. "addtime"=>date("Y-m-d H:i:s")
  349. ];
  350. Db::startTrans();
  351. try {
  352. $in=Db::name("order_returninfo")->insert($returninfo);
  353. if($in){
  354. if($info['return_tag']==2 &&$wareaddr==false) {
  355. $addrs =[
  356. "wsm_code"=>$wsm_code,
  357. "wsm_type"=>1,
  358. "wsm_name"=>$contactor,
  359. "wsm_addr"=>$addr,
  360. "addr_code"=>$addrcode,
  361. "wsm_mobile"=>$mobile,
  362. "status"=>'1',
  363. "is_del"=>'0',
  364. "addtime"=>date("Y-m-d H:i:s"),
  365. "updatetime"=>date("Y-m-d H:i:s")
  366. ];
  367. $wareaddr =Db::name("warehouse_addr")->insert($addrs);
  368. if($wareaddr==false){
  369. Db::rollback();
  370. return app_show(1004,"退货仓库地址录入失败");
  371. }
  372. }
  373. $info['status']=4;
  374. $info["updatetime"]=date("Y-m-d H:i:s");
  375. $up =Db::name("order_return")->save($info);
  376. if($up){
  377. Db::commit();
  378. return app_show(0,"退货仓库设置成功");
  379. }
  380. }
  381. Db::rollback();
  382. return error_show(1004,"设置失败");
  383. }catch (\Exception $e){
  384. Db::rollback();
  385. return error_show(1004,$e->getMessage());
  386. }
  387. }
  388. /**
  389. * @return \think\response\Json|void
  390. * @throws \think\db\exception\DataNotFoundException
  391. * @throws \think\db\exception\DbException
  392. * @throws \think\db\exception\ModelNotFoundException
  393. */
  394. public function postfeed(){
  395. $bkcode = isset($this->post['returnCode']) && $this->post['returnCode']!="" ? trim($this->post['returnCode']):"";
  396. if($bkcode==""){
  397. return error_show(1005,"参数returnCode 不能为空");
  398. }
  399. $info = Db::name("order_return")->where(['returnCode'=>$bkcode])->find();
  400. if(empty($info)){
  401. return error_show(1005,"未找到售后数据");
  402. }
  403. $contactor = isset($this->post['contactor']) && $this->post['contactor']!="" ? trim($this->post['contactor']) :"";
  404. $mobile = isset($this->post['mobile']) && $this->post['mobile']!="" ? trim($this->post['mobile']):"";
  405. $addr = isset($this->post['addr']) && $this->post['addr']!="" ? trim($this->post['addr']):"";
  406. $addr_code = isset($this->post['addr_code']) && $this->post['addr_code']!=""&&!empty($this->post['addr_code']) ?
  407. $this->post['addr_code']:"";
  408. $wsm_code = isset($this->post['wsm_code']) && $this->post['wsm_code']!="" ? trim($this->post['wsm_code']):"";
  409. if($wsm_code==""){
  410. return error_show(1005,"参数 wsm_code不能为空");
  411. }
  412. if($info['is_th']==0&&$info['order_type']==1) {
  413. $wsm = Db::name("warehouse_info")->where(["wsm_code" => $wsm_code])->find();
  414. if (empty($wsm)) {
  415. return error_show(1005, "未找到仓库数据");
  416. }
  417. $sm = Db::name("warehouse_addr")->where(["wsm_code" => $wsm_code,"is_del"=>0])->find();
  418. $contactor==""?(isset($sm['wsm_name']) ? $contactor=$sm['wsm_name']:""):"";
  419. $sm['wsm_name'] =isset($sm['wsm_name']) ? $sm['wsm_name']:"";
  420. $mobile==""?(isset($sm['wsm_mobile']) ? $mobile=$sm['wsm_mobile']:""):"";
  421. $sm['wsm_mobile'] =isset($sm['wsm_mobile']) ? $sm['wsm_mobile']:"";
  422. $addr==""?(isset($sm['wsm_addr']) ? $addr=$sm['wsm_addr']:""):"";
  423. $sm['wsm_addr'] =isset($sm['wsm_addr']) ? $sm['wsm_addr']:"";
  424. $addr_code==""?(isset($sm['addr_code']) ? $addr=$sm['addr_code']:""):"";
  425. $sm['addr_code'] =isset($sm['addr_code']) ? $sm['addr_code']:"";
  426. }
  427. $remark = isset($this->post['remark']) && $this->post['remark']!="" ? trim($this->post['remark']):"";
  428. if($info['is_th']==1 && $info['order_type']==1){
  429. if($contactor==''){
  430. return error_show(1005,"参数 contactor 不能为空");
  431. }
  432. if($mobile==''){
  433. return error_show(1005,"参数 mobile 不能为空");
  434. }
  435. if($addr==''){
  436. return error_show(1005,"参数 addr 不能为空");
  437. }
  438. if($addr_code==''){
  439. return error_show(1005,"参数 addr_code 不能为空");
  440. }
  441. if($addr_code!==''&&is_array($addr_code)){
  442. $addrs=[];
  443. $addrs['provice_code'] = $addr_code[0];
  444. $addrs['city_code'] = $addr_code[1];
  445. $addrs['area_code'] = $addr_code[2];
  446. $addr_code = json_encode($addrs);
  447. }
  448. }
  449. Db::startTrans();
  450. try{
  451. $var=$info['status'];
  452. $info['status']=$info['order_type']==1?3:4;
  453. $info['remark']=$remark;
  454. $info['updatetime']=date("Y-m-d H:i:s");
  455. $up =Db::name("order_return")->save($info);
  456. if($up){
  457. // var_dump($contactor);
  458. $returninfo = Db::name("order_returninfo")->where(["returnCode"=>$bkcode])->find();
  459. if(empty($returninfo)){
  460. $returninfo=[
  461. "returnCode"=>$bkcode,
  462. "return_wsm"=>$wsm_code,
  463. "contactor"=>$contactor,
  464. "mobile"=>$mobile ,
  465. "addr"=>$addr,
  466. "addr_code"=>$addr_code,
  467. "addtime"=>date("Y-m-d H:i:s")
  468. ];
  469. }else{
  470. $returninfo['return_wsm'] = $wsm_code;
  471. //if($info['is_th']==1 && $info['order_type']==1) {
  472. $contactor !==""? $returninfo['contactor'] = $contactor:"";
  473. $mobile!==""?$returninfo['mobile'] = $mobile:"";
  474. $addr!==""? $returninfo['addr'] = $addr:"";
  475. $addr_code!==""?$returninfo['addr_code'] = $addr_code:"";
  476. // }
  477. }
  478. // var_dump($contactor);
  479. // var_dump($returninfo);
  480. $in=Db::name("order_returninfo")->save($returninfo);
  481. if($in){
  482. $order = ["order_code"=>$info['returnCode'],"status"=>$var,"action_remark"=>'',"action_type"=>"edit"];
  483. ActionLog::logAdd($this->post['token'],$order,$info['order_type']==1?'SHD':"ZXSHD",$info['status'],$order);
  484. $process=["order_code"=>$info['returnCode'],"order_id"=>$info['id'],"order_status"=>$info['status'],"order_type"=>$info['order_type']==1?'SHD':"ZXSHD"];
  485. ProcessOrder::AddProcess($this->post['token'],$process);
  486. Db::commit();
  487. return app_show(0,"更新成功");
  488. }
  489. }
  490. Db::rollback();
  491. return error_show(1004,"更新失败");
  492. }catch (\Exception $e){
  493. Db::rollback();
  494. return error_show(1004,$e->getMessage());
  495. }
  496. }
  497. /**
  498. * @return \think\response\Json|void
  499. * @throws \think\db\exception\DataNotFoundException
  500. * @throws \think\db\exception\DbException
  501. * @throws \think\db\exception\ModelNotFoundException
  502. */
  503. public function addpost(){
  504. $bkcode = isset($this->post['returnCode']) && $this->post['returnCode']!="" ? trim($this->post['returnCode']):"";
  505. if($bkcode==""){
  506. return error_show(1005,"参数returnCode 不能为空");
  507. }
  508. $info = Db::name("order_return")->where(['returnCode'=>$bkcode])->find();
  509. if(empty($info)){
  510. return error_show(1005,"未找到售后数据");
  511. }
  512. $return_info = Db::name("order_returninfo")->where(['returnCode'=>$bkcode])->find();
  513. if(empty($return_info)){
  514. $return_info=[
  515. "returnCode"=>$bkcode,
  516. "return_wsm"=>'',
  517. "contactor"=>'',
  518. "mobile"=>'',
  519. "addr"=>'',
  520. "addr_code"=>'',
  521. "addtime"=>date("Y-m-d H:i:s"),
  522. "post_company"=>'',
  523. "post_code"=>'',
  524. "post_fee"=>'',
  525. ];
  526. }
  527. $post_own = isset($this->post['own']) &&$this->post['own']!='' ? trim($this->post['own']):"";
  528. if($post_own==''){
  529. return error_show(1005,"参数own不能为空");
  530. }
  531. $info['post_own'] = $post_own;
  532. $post_company = isset($this->post['company'])&&$this->post['company']!='' ? trim($this->post['company']):"";
  533. if($post_company==''){
  534. return error_show(1005,"参数company不能为空");
  535. }
  536. $return_info['post_company'] = $post_company;
  537. $post_code = isset($this->post['post_code'])&&$this->post['post_code']!='' ? trim($this->post['post_code']):"";
  538. if($post_code==''){
  539. return error_show(1005,"参数post_code不能为空");
  540. }
  541. $return_info['post_code'] = $post_code;
  542. $fee= isset($this->post['post_fee'])&&$this->post['post_fee']!=='' ? round($this->post['post_fee'],2):"";
  543. if($fee===''){
  544. return error_show(1005,"参数post_fee不能为空");
  545. }
  546. $return_info['post_fee'] = $fee;
  547. Db::startTrans();
  548. try{
  549. $str=$info['status'];
  550. $info['status']=$info['order_type']==1?4:5;
  551. $info['updatetime']=date("Y-m-d H:i:s");
  552. $up =Db::name("order_return")->save($info);
  553. if($up){
  554. $order = ["order_code"=>$info['orderCode'],"status"=>$str,"action_remark"=>'',"action_type"=>"edit"];
  555. ActionLog::logAdd($this->post['token'],$order,$info['order_type']==1?'SHD':"ZXSHD",$info['status'],$order);
  556. $process=["order_code"=>$info['returnCode'],"order_id"=>$info['id'],"order_status"=>$info['status'],"order_type"=>$info['order_type']==1?'SHD':"ZXSHD"];
  557. ProcessOrder::AddProcess($this->post['token'],$process);
  558. $in=Db::name("order_returninfo")->save($return_info);
  559. if($in){
  560. $data=[
  561. 'thNo'=>makeNo("ST"),
  562. "orderCode"=>$info['orderCode'],
  563. "order_type"=>$info['order_type'],
  564. "outCode"=>$info['outCode'],
  565. "returnCode"=>$info['returnCode'],
  566. "good_code"=>$info['good_code'],
  567. "good_name"=>$info['good_name'],
  568. "return_wsm"=>$return_info['return_wsm'],
  569. "return_num"=>$info['error_num'],
  570. "contactor"=>$return_info['contactor'],
  571. "mobile"=>$return_info['mobile'],
  572. "addr"=>$return_info['addr'],
  573. "addr_code"=>$return_info['addr_code'],
  574. "return_code"=>$info['error_code'],
  575. "return_msg"=>$info['error_msg'],
  576. "post_fee"=>$return_info['post_fee'],
  577. "post_code"=>$return_info['post_code'],
  578. "post_company"=>$return_info['post_company'],
  579. "customer_code"=>$info['customer_code'],
  580. "addtime"=>date("Y-m-d H:i:s"),
  581. "updatetime"=>date("Y-m-d H:i:s")
  582. ];
  583. $back =Db::name("order_back")->insert($data,true);
  584. if($back>0){
  585. $order = ["order_code"=>$data['thNo'],"status"=>0,"action_remark"=>'',"action_type"=>"create"];
  586. ActionLog::logAdd($this->post['token'],$order,$info['order_type']==1?'SHD':"ZXSHD", 0,$data);
  587. $process=["order_code"=>$data['thNo'],"order_id"=>$back,"order_status"=>0,"order_type"=>$info['order_type']==1?'CKTHD':"ZXCKTHD"];
  588. ProcessOrder::AddProcess($this->post['token'],$process);
  589. Db::commit();
  590. return app_show(0,"更新成功");
  591. }
  592. }
  593. }
  594. Db::rollback();
  595. return error_show(1004,"更新失败");
  596. }catch (\Exception $e){
  597. Db::rollback();
  598. return error_show(1004,$e->getMessage());
  599. }
  600. }
  601. /**
  602. * @return \think\response\Json|void
  603. * @throws \think\db\exception\DataNotFoundException
  604. * @throws \think\db\exception\DbException
  605. * @throws \think\db\exception\ModelNotFoundException
  606. */
  607. public function GysFeed(){
  608. $bkcode = isset($this->post['returnCode']) && $this->post['returnCode']!="" ? trim($this->post['returnCode']):"";
  609. if($bkcode==""){
  610. return error_show(1005,"参数returnCode 不能为空");
  611. }
  612. $info = Db::name("order_return")->where(['returnCode'=>$bkcode])->find();
  613. if(empty($info)){
  614. return error_show(1005,"未找到售后数据");
  615. }
  616. $isth = isset($this->post['is_th']) && $this->post['is_th']!="" ? intval($this->post['is_th']):"0";
  617. $contactor = isset($this->post['contactor']) && $this->post['contactor']!="" ? trim($this->post['contactor'])
  618. :"";
  619. $mobile = isset($this->post['mobile']) && $this->post['mobile']!="" ? trim($this->post['mobile']):"";
  620. $addr = isset($this->post['addr']) && $this->post['addr']!="" ? trim($this->post['addr']):"";
  621. $addr_code = isset($this->post['addr_code']) && $this->post['addr_code']!=""&&!empty($this->post['addr_code']) ? $this->post['addr_code']:"";
  622. $remark = isset($this->post['remark']) && $this->post['remark']!="" ? trim($this->post['remark']):"";
  623. if($isth==1){
  624. if($contactor==''){
  625. return error_show(1005,"参数 contactor 不能为空");
  626. }
  627. if($mobile==''){
  628. return error_show(1005,"参数 mobile 不能为空");
  629. }
  630. if($addr==''){
  631. return error_show(1005,"参数 addr 不能为空");
  632. }
  633. // var_dump(isset($this->post['addr_code']) , $this->post['addr_code']!="",!empty($addr_code));
  634. if($addr_code==''){
  635. return error_show(1005,"参数 addr_code 不能为空");
  636. }
  637. if(is_array($addr_code)){
  638. $addrs=[];
  639. $addrs['provice_code'] = $addr_code[0];
  640. $addrs['city_code'] = $addr_code[1];
  641. $addrs['area_code'] = $addr_code[2];
  642. $addr_code = json_encode($addrs);
  643. }
  644. }
  645. $orde= Db::name("order_out")->where(["outCode"=>$info['outCode'],"is_del"=>0])->find();
  646. if(empty($orde)){
  647. return error_show(1005,"未找到出库单数据");
  648. }
  649. Db::startTrans();
  650. try{
  651. $stat=$info['status'];
  652. $info['status']=$info['order_status']==1?5:3;
  653. $info['is_th']=$isth;
  654. $info['updatetime']=date("Y-m-d H:i:s");
  655. $up =Db::name("order_return")->save($info);
  656. if($up){
  657. $returninfo = Db::name("order_returninfo")->where(["returnCode"=>$bkcode])->find();
  658. if(empty($returninfo)){
  659. $returninfo=[
  660. "returnCode"=>$bkcode,
  661. "return_wsm"=>'',
  662. "contactor"=>$contactor,
  663. "mobile"=>$mobile ,
  664. "addr"=>$addr,
  665. "addr_code"=>$addr_code,
  666. "gys_remark"=>$remark,
  667. "addtime"=>date("Y-m-d H:i:s")
  668. ];
  669. }else{
  670. $returninfo['return_wsm'] = '';
  671. $returninfo['contactor'] = $contactor;
  672. $returninfo['mobile'] = $mobile;
  673. $returninfo['addr'] = $addr;
  674. $returninfo['gys_remark'] = $remark;
  675. $returninfo['addr_code'] = $addr_code;
  676. }
  677. $in=Db::name("order_returninfo")->save($returninfo);
  678. if($in){
  679. if( $info['order_status']==1&&$info['order_type']==2){
  680. $orderout= Db::name("order_out")->where($orde)->save(['status'=>3,"updatetime"=>date("Y-m-d H:i:s")]);
  681. $order = ["order_code"=>$orde['outCode'],"status"=>$orde['status'],"action_remark"=>'',"action_type"=>"edit"];
  682. ActionLog::logAdd($this->post['token'],$order,$orde['order_type']==1?'CKD':"ZXCKD", 3,
  683. ['status'=>3,"updatetime"=>date("Y-m-d H:i:s")]);
  684. $process=["order_code"=>$orde['outCode'],"order_id"=>$orde['id'],"order_status"=>3,
  685. "order_type"=>$orde['order_type']==1?'CKD':"ZXCKD"];
  686. ProcessOrder::AddProcess($this->post['token'],$process);
  687. if($orderout){
  688. Db::commit();
  689. return app_show(0,"更新成功");
  690. }else{
  691. Db::rollback();
  692. return error_show(1004,"更新失败");
  693. }
  694. }
  695. $order = ["order_code"=>$info['returnCode'],"status"=>$stat,"action_remark"=>'',"action_type"=>"edit"];
  696. ActionLog::logAdd($this->post['token'],$order,$info['order_type']==1?'CKTHD':"ZXCKTHD",3,$order);
  697. $process=["order_code"=>$info['returnCode'],"order_id"=>$info['id'],"order_status"=>$info['status'],"order_type"=>$info['order_type']==1?'CKTHD':"ZXCKTHD"];
  698. ProcessOrder::AddProcess($this->post['token'],$process);
  699. Db::commit();
  700. return app_show(0,"更新成功");
  701. }
  702. }
  703. Db::rollback();
  704. return error_show(1004,"更新失败");
  705. }catch (\Exception $e){
  706. Db::rollback();
  707. return error_show(1004,$e->getMessage());
  708. }
  709. }
  710. public function GetWsm(){
  711. $bkcode = isset($this->post['returnCode']) && $this->post['returnCode']!="" ? trim($this->post['returnCode']):"";
  712. if($bkcode==""){
  713. return error_show(1005,"参数returnCode 不能为空");
  714. }
  715. $info = Db::name("order_return")->where(['returnCode'=>$bkcode])->find();
  716. if(empty($info)){
  717. return error_show(1005,"未找到售后数据");
  718. }
  719. $list=[];
  720. if($info['is_th']==1){
  721. if($info["order_type"]==1){
  722. $out =Db::name("order_out")->where(["outCode"=>$info['outCode']])->find();
  723. if(empty($out)){
  724. return error_show(1005,"未找到出库单数据");
  725. }
  726. $ware = Db::name("warehouse_info")->alias("a")->leftJoin("warehouse_addr b","a.wsm_code=b.wsm_code and b.status=1 and b.is_del=0")
  727. ->where(["a.status"=>1,"wsm_type"=>1,"a.is_del"=>0,"a.supplierNo"=>$out['wsm_code']])->field("a.wsm_code,a.name,b.wsm_name,b.wsm_mobile,b.wsm_addr,b.addr_code")->find();
  728. if(empty($ware)){
  729. return error_show(1005,"未找到仓库数据");
  730. }
  731. $temp['wsm_code']=isset($ware['wsm_code'])?$ware['wsm_code']:"";
  732. $temp['wsm_name']=isset($ware['name'])?$ware['name']:"";
  733. $temp['contactor'] = isset($ware['wsm_name'])?$ware['wsm_name']:"";
  734. $temp['mobile'] =isset($ware['wsm_mobile'])?$ware['wsm_mobile']:"";
  735. $temp['addr'] =isset($ware['wsm_addr'])?$ware['wsm_addr']:"";
  736. $temp['addr_code'] = isset($ware['addr_code'])?$ware['addr_code']:"";
  737. $temp['addr_cn'] =GetAddr( $ware['addr_code']);
  738. $list[]=$temp;
  739. }else {
  740. $returninfo = Db::name("order_returninfo")->where(["returnCode" => $bkcode])->find();
  741. if (empty($returninfo)) {
  742. return error_show(1005, "未找到供应商仓库数据");
  743. }
  744. $data = [];
  745. $data['wsm_code'] = isset($returninfo['return_wsm']) && $returninfo['return_wsm'] != "" ? $returninfo['return_wsm'] : "-";
  746. $data['wsm_name'] = '供应商仓';
  747. $data['supplier_name'] = '供应商';
  748. $data['contactor'] = $returninfo['contactor'];
  749. $data['mobile'] = $returninfo['mobile'];
  750. $data['addr'] = $returninfo['addr'];
  751. $data['addr_cn'] =GetAddr( $returninfo['addr_code']);
  752. $data['addr_code'] = $returninfo['addr_code'];
  753. $list[] = $data;
  754. }
  755. }
  756. $supplier = Db::name("supplier")->where(["is_platform"=>1,"status"=>1,"is_del"=>0])->column("code,name");
  757. if(empty($supplier)){
  758. return error_show(1005,"未找到供应商仓库数据");
  759. }
  760. foreach ($supplier as $value){
  761. $temp=[];
  762. $ware = Db::name("warehouse_info")->alias("a")->leftJoin("warehouse_addr b","a.wsm_code=b.wsm_code and b.status=1 and b.is_del=0")
  763. ->where(["a.wsm_type"=>1,"a.status"=>1,"a.is_del"=>0,"a.supplierNo"=>$value['code']])->field("a.wsm_code,a.name,b.wsm_name,b.wsm_mobile,b.wsm_addr,b.addr_code")->find();
  764. if(empty($ware)){
  765. continue;
  766. }
  767. $temp['wsm_code']=isset($ware['wsm_code'])?$ware['wsm_code']:"";
  768. $temp['wsm_name']=isset($ware['name'])?$ware['name']:"";
  769. $temp['supplier_name']=$value['name'];
  770. $temp['contactor'] = isset($ware['wsm_name'])?$ware['wsm_name']:"";
  771. $temp['mobile'] =isset($ware['wsm_mobile'])?$ware['wsm_mobile']:"";
  772. $temp['addr'] =isset($ware['wsm_addr'])?$ware['wsm_addr']:"";
  773. $temp['addr_cn'] =GetAddr($ware['addr_code']);
  774. $temp['addr_code'] = isset($ware['addr_code'])?$ware['addr_code']:"";
  775. $list[]=$temp;
  776. }
  777. return app_show(0,"获取成功",$list);
  778. }
  779. public function setdelivery(){
  780. $bkcode = isset($this->post['returnCode']) && $this->post['returnCode']!="" ? trim($this->post['returnCode']):"";
  781. if($bkcode==""){
  782. return error_show(1005,"参数returnCode 不能为空");
  783. }
  784. $info = Db::name("order_return")->where(['returnCode'=>$bkcode])->find();
  785. if(empty($info)){
  786. return error_show(1005,"未找到售后数据");
  787. }
  788. if(($info['is_receive']==0&&$info['status']!=3)||($info['is_receive']==1&&$info['status']!=4) ){
  789. return error_show(1005,"售后单流程状态有误");
  790. }
  791. $out=Db::name("order_out")->where(["outCode"=>$info["outCode"]])->find();
  792. $is_th = isset($this->post['is_th'])&&$this->post['is_th']!=="" ? intval($this->post['is_th']):"";
  793. if($is_th===""){
  794. return error_show(1005,"参数is_th不能为空");
  795. }
  796. $company=isset($this->post['company'])&&$this->post['company']!=""?trim($this->post['company']):"";
  797. $post_code=isset($this->post['post_code'])&&$this->post['post_code']!=""?trim($this->post['post_code']):"";
  798. $post_fee=isset($this->post['post_fee'])&&$this->post['post_fee']!==""?floatval($this->post['post_fee']):"";
  799. if($is_th==1){
  800. if($company==""){
  801. return error_show(1005,"参数company不能为空");
  802. }
  803. if($post_code==""){
  804. return error_show(1005,"参数post_code不能为空");
  805. }
  806. if($post_fee===""){
  807. return error_show(1005,"参数post_fee不能为空");
  808. }
  809. }
  810. Db::startTrans();
  811. try {
  812. $returninfo = Db::name("order_returninfo")->where(["returnCode"=>$bkcode])->find();
  813. if($returninfo==false){
  814. $returninfo=[
  815. "returnCode"=>$bkcode,
  816. "return_wsm"=>"",
  817. "contactor"=>"",
  818. "mobile"=>"",
  819. "addr"=>"",
  820. "addr_code"=>"",
  821. "post_code"=>$post_code,
  822. "post_company"=>$company,
  823. "post_fee"=>$post_fee,
  824. "gys_remark"=>"",
  825. "addtime"=>date("Y-m-d H:i:s")
  826. ];
  827. }else{
  828. $returninfo['post_fee']=$post_fee;
  829. $returninfo['post_company']=$company;
  830. $returninfo['post_code']=$post_code;
  831. }
  832. $up =Db::name("order_returninfo")->save($returninfo);
  833. if($up){
  834. $info['status']=5;
  835. $info['updatetime']=date("y-m-d H:i:s");
  836. $ro =Db::name("order_return")->save($info);
  837. if($ro){
  838. $thNo =makeNo("ST");
  839. $thdata=[
  840. "thNo"=>$thNo,
  841. "orderCode"=>$out["orderCode"],
  842. "outCode"=>$out["outCode"],
  843. "order_type"=>$info["order_type"],
  844. "returnCode"=>$info["returnCode"],
  845. "good_code"=>$info["good_code"],
  846. "good_name"=>$info["good_name"],
  847. "return_wsm"=>$returninfo["return_wsm"],
  848. // "defective_wsm"=>'',
  849. "return_msg"=>$info["error_msg"],
  850. "return_num"=>$info["total_num"],
  851. "normal_num"=>0,
  852. "received_num"=>0,
  853. // "defective_num"=>0,
  854. // "loss_num"=>0,
  855. "contactor"=>$returninfo["contactor"],
  856. "mobile"=>$returninfo["mobile"],
  857. "addr"=>$returninfo["addr"],
  858. "addr_code"=>$returninfo["addr_code"],
  859. "return_code"=>$info["error_code"],
  860. "post_fee"=>$returninfo["post_fee"],
  861. "post_code"=>$returninfo["post_code"],
  862. "post_company"=>$returninfo["post_company"],
  863. "customer_code"=>$info["customer_code"],
  864. "status"=>1,
  865. "addtime"=>date("Y-m-d H:i:s"),
  866. "updatetime"=>date("Y-m-d H:i:s")
  867. ];
  868. $sav= Db::name("order_back")->insert($thdata);
  869. if($sav){
  870. Db::commit();
  871. return app_show(0,"退货单新建成功",["thNo"=>$thNo]);
  872. }
  873. }
  874. }
  875. Db::rollback();
  876. return error_show(1004,'退货失败');
  877. }catch (\Exception $e){
  878. Db::rollback();
  879. return error_show(1004,$e->getMessage());
  880. }
  881. }
  882. //取消售后
  883. public function Cancel()
  884. {
  885. //接收参数
  886. $data = $this->request->only(['token', 'returnCode'], 'post', 'trim');
  887. $val = Validate::rule(['returnCode|售后单编号' => 'require']);
  888. if (!$val->check($data)) return error_show(1005, $val->getError());
  889. Db::startTrans();
  890. try {
  891. $rs = Db::name('order_return')->field('id,status')->where([['returnCode', '=', $data['returnCode']], ['is_del', '=', 0], ['status', '<>', 8]])->find();
  892. if (!$rs) throw new Exception('该售后单记录不存在');
  893. //修改记录
  894. $res = Db::name('order_return')->where(['id' => $rs['id']])->update(['status' => 8, 'updatetime' => date('Y-m-d H:i:s')]);
  895. if (!$res) throw new Exception('该售后单记录修改失败');
  896. //记录日志
  897. ActionLog::logAdd($data['token'], ["order_code" => $data['returnCode'], "status" => 8, "action_remark" => '', "action_type" => "cancel"], 'SHD', 8, $this->post);
  898. ProcessOrder::AddProcess($this->post['token'], ["order_code" => $data['returnCode'], "order_id" => $rs['id'], "order_status" => 8, "order_type" => 'SHD']);
  899. //提交
  900. Db::commit();
  901. return app_show(0, "取消成功");
  902. } catch (\Exception $e) {
  903. Db::rollback();
  904. return error_show(1004, $e->getMessage());
  905. }
  906. }
  907. }