Trade.php 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use app\common\library\CoinRate;
  5. use app\common\library\Ems;
  6. use app\common\library\Sms;
  7. use app\common\model\Config;
  8. use fast\Random;
  9. use think\Session;
  10. use think\Validate;
  11. /**
  12. * 互助接口
  13. */
  14. class Trade extends Api
  15. {
  16. protected $noNeedLogin = ['*'];
  17. protected $noNeedRight = '*';
  18. public function _initialize()
  19. {
  20. parent::_initialize();
  21. }
  22. function getfunsorder()
  23. {
  24. $map['status']=3;
  25. $user=get_user_data($this->auth->id);
  26. $uids=db('user')->where(['id'=>['like','%,'.$this->auth->id.',%'],'tdeep'=>['elt',$user['tdeep']+2]])->column('id');
  27. if($uids)
  28. {
  29. $map['relevant_userid']=['in',$uids];
  30. }else{
  31. $map['relevant_userid']=0;
  32. }
  33. $p=$this->request->request('p');
  34. if(empty($p))
  35. {
  36. $this->error('缺少参数页码');
  37. }
  38. $pagesize=10;
  39. $total=db('trade')->where($map)->count();
  40. $totalPage=ceil($total/$pagesize);
  41. if($p>$totalPage && $total>0)
  42. {
  43. $this->error('页码有误');
  44. }
  45. $list=db('trade')->where($map)->page($p,$pagesize)->order('id desc')->select();
  46. foreach ($list as &$v)
  47. {
  48. $v['name']=get_table_column('goods',$v['goodsid'],'title');
  49. $v['ctime']=date('Y-m-d H:i',$v['ctime']);
  50. $v['mobile']=get_user_data($v['userid'],'mobile');
  51. }
  52. if(empty($list))
  53. {
  54. $data['list']=[];
  55. }else{
  56. $data['list']=$list;
  57. }
  58. $data['total']=$totalPage;
  59. $this->success('',$data);
  60. }
  61. function match()
  62. {
  63. $goodsid=$this->request->request("goodsid");
  64. $ginfo=db('goods')->where(['id'=>$goodsid])->find();
  65. if($ginfo['istrade'] == 1)
  66. {
  67. $this->error('已结束');
  68. }else{
  69. $user=get_user_data($this->auth->id);
  70. if(empty($user['bank_number']) && empty($user['wxprc']) &&empty($user['alipayprc']) && empty($user['usdt_address']) && empty($user['thb_bank_number']) && empty($user['idr_bank_number']))
  71. {
  72. $this->error('请至少完善一个收款账户信息,在交易');
  73. }
  74. // if($user['isreal'] != 2)
  75. // {
  76. // $this->error('您还未实名~');
  77. // }
  78. $addressCnt=db('user_address')->where(['userid'=>$user['id']])->count();
  79. if($addressCnt == 0)
  80. {
  81. //$this->error('您还未添加地址~');
  82. }
  83. if($ginfo['userid'] == $this->auth->id)
  84. {
  85. $this->error('您不能买自己的商品~');
  86. }
  87. $topbcf=db('bonus_config')->where(['id'=>5])->find();
  88. $studio=db('studio')->where(['title'=>$this->auth->login_studio])->find();
  89. $topcnt=db('trade')->where(['relevant_userid'=>$user['id'],'stuid'=>$studio['id'],'iscancel'=>0,'create_time'=>strtotime('today'),'type'=>0 ])->count();
  90. if($topcnt>=$topbcf['value'])
  91. {
  92. $this->error($topcnt.'您今日此分商家抢单次数已达上限'.$topbcf['value']);
  93. }
  94. $feeconfig=db('bonus_config')->where(['id'=>2])->find();
  95. $fee=$feeconfig['value']*0.01*$ginfo['price1'];
  96. if ($ginfo['istrade'] == 0){
  97. db()->startTrans();
  98. $tradedata=[
  99. 'orderNo'=>date('YmdHi').rand(100,999),
  100. 'userid'=>$ginfo['userid'],
  101. 'goodsid'=>$goodsid,
  102. 'nums'=>$ginfo['price1'],
  103. 'ctime'=>time(),
  104. 'create_time'=>strtotime('today'),
  105. 'status'=>1,
  106. 'relevant_userid'=>$this->auth->id,
  107. 'fee'=>$fee,
  108. 'pre_price'=> $ginfo['pre_price'],
  109. 'remark'=>date('Y-m-d H:i:s'),
  110. 'catid'=>$ginfo['catid'],
  111. 'stuid'=>$ginfo['stuid'],
  112. 'type'=>0,
  113. ];
  114. $tradeid=db('trade')->insertGetId($tradedata);
  115. $res1=db('goods')->where(['id'=>$goodsid])->update(['istrade'=>1]);
  116. if($tradeid && $res1)
  117. {
  118. db()->commit();
  119. $this->success('成功',['id'=>$tradeid]);
  120. }else{
  121. db()->rollback();
  122. $this->error('抢购失败');
  123. }
  124. }else{
  125. $this->error('抢购结束');
  126. }
  127. }
  128. }
  129. function topay()
  130. {
  131. $tradid=$this->request->request("id");
  132. if(empty($tradid))
  133. {
  134. $this->error('网络错误,请重试~');
  135. }
  136. $prc=$this->request->request("prc");
  137. if(empty($prc))
  138. {
  139. $this->error('请上传凭证');
  140. }
  141. $res=db('trade')->where(['id'=>$tradid])->update(['pay_time'=>time(),'status'=>2,'prc'=>$prc]);
  142. if($res)
  143. {
  144. $this->success('支付完成');
  145. }else{
  146. $this->error('支付失败');
  147. }
  148. }
  149. function tocancelappeal()
  150. {
  151. $id=$this->request->request("id");
  152. $trade=db('trade')->where(['id'=>$id,'userid'=>$this->auth->id,'isappeal'=>1,'status'=>-1])->find();
  153. if($trade)
  154. {
  155. $res1=db('trade')->where(['id'=>$id])->update(['isappeal'=>0,'appeal_text'=>'','status'=>2]);
  156. if($res1)
  157. {
  158. $this->success('取消成功');
  159. }else{
  160. $this->error('取消失败');
  161. }
  162. }else{
  163. $this->error('订单不存在,或订单状态已发生改变');
  164. }
  165. }
  166. function tocancel1()
  167. {
  168. $id=$this->request->post("id");
  169. $trade=db('trade')->where(['id'=>$id,'status'=>0])->find();
  170. if(empty($trade))
  171. {
  172. $this->error('订单不存在,或以发生改变');
  173. }else{
  174. $res1=db('trade')->where(['id'=>$id])->update(['status'=>-2,'iscancel'=>1,'confirm_time'=>time()]);
  175. if($res1)
  176. {
  177. $selltrade=db('trade')->where(['goodsid'=>$trade['goodsid'],'status'=>3])->find();
  178. if(empty($selltrade))
  179. {
  180. $res2=db('goods')->where(['id'=>$trade['goodsid']])->update(['istrade'=>0]);
  181. }
  182. $this->success('取消成功');
  183. }else{
  184. $this->error('取消失败');
  185. }
  186. }
  187. }
  188. function tocancel()
  189. {
  190. $id=$this->request->request("id");
  191. $trade=db('trade')->where(['id'=>$id,'status'=>1])->find();
  192. if(empty($trade))
  193. {
  194. $this->error('订单不存在,或以发生改变');
  195. }else{
  196. db()->startTrans();
  197. $res1=db('trade')->where(['id'=>$id])->update(['status'=>-2,'iscancel'=>1,'confirm_time'=>time()]);
  198. $res2=db('goods')->where(['id'=>$trade['goodsid']])->update(['istrade'=>0]);
  199. if($res1 && $res2)
  200. {
  201. db()->commit();
  202. $this->success('取消成功');
  203. }else{
  204. db()->rollback();
  205. $this->error('取消失败');
  206. }
  207. }
  208. }
  209. function toeditorder()
  210. {
  211. $param=$this->request->request();
  212. $trade=db('trade')->where(['id'=>$param['id']])->find();
  213. if(empty($param['buyer']) && $param['status'] == $trade['status'])
  214. {
  215. $this->error('您并未修改订单');
  216. }
  217. db()->startTrans();
  218. if($param['buyer'])
  219. {
  220. $user=db('user')->where(['username|mobile'=>$param['buyer']])->find();
  221. if($user['id'] == $trade['relevant_userid'])
  222. {
  223. unset($param['buyer']);
  224. $res1=1;
  225. $res2=1;
  226. }else{
  227. $res1=db('trade')->where(['id'=>$param['id']])->update(['relevant_userid'=>$user['id']]);
  228. $res2=db('goods')->where(['id'=>$trade['goodsid']])->update(['userid'=>$user['id']]);
  229. }
  230. }
  231. if($param['status'] != $trade['status'])
  232. {
  233. if($param['status'] == 1)
  234. {
  235. $res3=db('trade')->where(['id'=>$param['id']])->update(['status'=>1,'pay_time'=>0,'confirm_time'=>0,'endnums'=>0]);
  236. $res4=1;
  237. }elseif($param['status'] == 2)
  238. {
  239. $res3=db('trade')->where(['id'=>$param['id']])->update(['status'=>2,'pay_time'=>time(),'confirm_time'=>0,'endnums'=>0]);
  240. $res4=1;
  241. }elseif($param['status'] == 3)
  242. {
  243. $bcf=db('bonus_config')->where(['id'=>1])->find();
  244. $endprice=$trade['nums']*$bcf['value']*0.01+$trade['nums'];
  245. $res3=db('trade')->where(['id'=>$param['id']])->update(['status'=>3,'endnums'=>$endprice,'confirm_time'=>time()]);
  246. $res4=db('goods')->where(['id'=>$trade['goodsid']])->update(['userid'=>$trade['relevant_userid'],'price1'=>$endprice]);
  247. }
  248. }else{
  249. $res3=1;
  250. $res4=1;
  251. }
  252. if($res1 && $res2 && $res3 && $res4)
  253. {
  254. db()->commit();
  255. $this->success('修改成功');
  256. }else{
  257. db()->rollback();
  258. $this->error('修改失败');
  259. }
  260. }
  261. function toconfirm()
  262. {
  263. $id=$this->request->request("id");
  264. $tradeinfo=db('trade')->where(['id'=>$id,'status'=>2])->find();
  265. if(empty($tradeinfo))
  266. {
  267. $this->error('订单不存在,或以发生改变');
  268. }else{
  269. $bcf=db('bonus_config')->where(['id'=>1])->find();
  270. $endprice=$tradeinfo['nums']*$bcf['value']*0.01+$tradeinfo['nums'];
  271. db()->startTrans();
  272. $res1=db('trade')->where(['id'=>$id])->update(['confirm_time'=>time(),'endnums'=>$endprice,'pre_price'=> $endprice-$tradeinfo['nums'],'status'=>3]);
  273. $res2=db('goods')->where(['id'=>$tradeinfo['goodsid']])->update(['userid'=>$tradeinfo['relevant_userid'],'update_time'=>time(),'price1'=>$endprice,'pre_price'=> $endprice-$tradeinfo['nums']]);
  274. if($res1 && $res2)
  275. {
  276. db()->commit();
  277. $this->success('操作完成');
  278. }else{
  279. db()->rollback();
  280. $this->error('操作失败');
  281. }
  282. }
  283. }
  284. /*发货*/
  285. function addorder()
  286. {
  287. $id=$this->request->post('id');
  288. if(empty($id))
  289. {
  290. $this->error('缺少参数');
  291. }
  292. $addressinfo=db('user_address')->where(['userid'=>$this->auth->id])->order('isdefault desc')->find();
  293. if(empty($addressinfo))
  294. {
  295. $this->error("地址不存在,请添加地址");
  296. }
  297. $info=db('trade')->where(['id'=>$id])->find();
  298. if($info['issell']>0)
  299. {
  300. $this->error('不可重复操作');
  301. }
  302. $goods=db('goods')->where(['id'=>$info['goodsid']])->find();
  303. db()->startTrans();
  304. $res=db('trade')->where(['id'=>$id])->update(['issell'=>-1,'ext'=>'发货']);
  305. $data=[
  306. 'orderNo'=>date('YmdHis').rand(100,999),
  307. 'orderStatus'=>1,
  308. 'totalMoney'=>$info['nums'],
  309. 'deliverMoney'=>0,
  310. 'userid'=>$this->auth->id,
  311. 'userName'=>$addressinfo['userName'],
  312. 'userPhone'=>$addressinfo['userPhone'],
  313. 'userAddress'=>$addressinfo['area'].$addressinfo['address'],
  314. 'addressId'=>$addressinfo['id'],
  315. 'remark'=>'',
  316. 'createTime'=>date('Y-m-d H:i:s'),
  317. 'needPay'=>$info['nums'],
  318. 'utime'=>time(),
  319. 'type'=>0
  320. ];
  321. $oids=db('order')->insertGetId($data);
  322. $ordGod=[
  323. 'orderid'=>$oids,
  324. 'goodsid'=>$info['goodsid'],
  325. 'nums'=>1,
  326. 'price'=>$info['nums'],
  327. 'attr'=>'',
  328. 'title'=>$goods['title'],
  329. 'image'=>$goods['image'],
  330. ];
  331. $ogids=db('order_goods')->insertGetId($ordGod);
  332. $logid=db('order_log')->insertGetId(['orderid'=>$oids,'title'=>'订单消息','content'=>'您的订单已生成,请耐心等待发货','userid'=>$this->auth->id,'ctime'=>time()]);
  333. if($res && $oids && $ogids && $logid)
  334. {
  335. db()->commit();
  336. $this->success('操作完成');
  337. }else{
  338. db()->rollback();
  339. $this->error('操作失败');
  340. }
  341. }
  342. /*代售*/
  343. function tosell()
  344. {
  345. $id=$this->request->post('id');
  346. if(empty($id))
  347. {
  348. $this->error('缺少参数');
  349. }
  350. $wtprc=$this->request->post('wtprc');
  351. if(empty($wtprc))
  352. {
  353. $this->error('请上传凭证');
  354. }
  355. $user=get_user_data($this->auth->id);
  356. $info=db('trade')->where(['id'=>$id])->find();
  357. if($info['issell']>0)
  358. {
  359. $this->error('不可重复操作');
  360. }
  361. $res=db('trade')->where(['id'=>$id])->update(['issell'=>1,'wtprc'=>$wtprc]);
  362. if($res)
  363. {
  364. $this->success('操作完成,请耐心等待审核');
  365. }else{
  366. $this->error('操作失败');
  367. }
  368. }
  369. function getonsale()
  370. {
  371. $type = $this->request->post('type');
  372. if($type > 0)
  373. {
  374. $map['issell']=$type;
  375. if($type == 2)
  376. {
  377. $map['status']=['egt',3];
  378. }else{
  379. $map['status']=3;
  380. }
  381. }else{
  382. $map['issell']=0;
  383. $map['status']=['in','1,2'];
  384. }
  385. $map['stuid']=get_user_data($this->auth->id,'stuid');
  386. $p = $this->request->post('p');
  387. $data_list = db('trade')->where($map)->page($p, 10)->order("id desc")->select();
  388. foreach ($data_list as &$v) {
  389. $goods=db('goods')->where(['id'=>$v['goodsid']])->find();
  390. $v['goods']=$goods;
  391. $v['ctime1']=date('Y-m-d H:i:s',$v['ctime']);
  392. $v['sendtime1']=$v['sendtime']>0?date('Y-m-d H:i:s',$v['sendtime']):'';
  393. $v['status_desc']=config('tradeStatus')[$v['status']];
  394. $v['selluser']=get_user_info($v['userid'],'nickname','mobile');
  395. $v['buyuser']=get_user_info($v['relevant_userid'],'nickname','mobile');
  396. if($type == 1)
  397. {
  398. $v['desc']='待审核';
  399. }elseif($type == 2)
  400. {
  401. $v['desc']='已审核';
  402. }else{
  403. $v['desc']='交易中';
  404. }
  405. }
  406. if ($data_list) {
  407. $return['data'] = $data_list;
  408. } else {
  409. $return['data'] = null;
  410. }
  411. $count = db('trade' )->where($map)->count();
  412. $return['total'] = ceil($count / 10);
  413. return $return;
  414. }
  415. function getorders()
  416. {
  417. $map['stuid'] = $this->auth->stuid;
  418. $map['status'] = ['in','1,2,3'];
  419. $p = $this->request->post('p');
  420. $data_list = db('trade')->where($map)->page($p, 10)->order("id desc")->select();
  421. foreach ($data_list as &$v) {
  422. $goods=db('goods')->where(['id'=>$v['goodsid']])->find();
  423. $v['goods']=$goods;
  424. $v['ctime1']=date('Y-m-d H:i:s',$v['ctime']);
  425. $v['pay_time1']=$v['pay_time']>0?date('Y-m-d H:i:s',$v['pay_time']):'';
  426. $v['confirm_time1']=$v['confirm_time']>0?date('Y-m-d H:i:s',$v['confirm_time']):'';
  427. $v['status_desc']=config('tradeStatus')[$v['status']];
  428. $v['selluser']=get_user_info($v['userid'],'nickname','mobile');
  429. $v['buyuser']=get_user_info($v['relevant_userid'],'nickname','mobile');
  430. }
  431. if ($data_list) {
  432. $return['data'] = $data_list;
  433. } else {
  434. $return['data'] = null;
  435. }
  436. $count = db('trade' )->where($map)->count();
  437. $return['total'] = ceil($count / 10);
  438. return $return;
  439. }
  440. function gettj()
  441. {
  442. $sid = $this->request->post('sid');
  443. if($sid>0)
  444. {
  445. $map['stuid']=$sid;
  446. }else{
  447. $map['stuid']=0;
  448. }
  449. $time=$this->request->post('starttime');
  450. if(empty($time))
  451. {
  452. $start=strtotime('today')-60*60*24*5;
  453. $map['ctime']=['gt',$start];
  454. }else{
  455. $start=strtotime($time);
  456. $end=$start+60*60*24;
  457. $map['ctime']=[['egt',$start],['lt',$end]];
  458. }
  459. $p = $this->request->post('p');
  460. $data_list = db('trade')->where($map)->page($p, 10)->order("id desc")->select();
  461. foreach ($data_list as &$v) {
  462. $goods=db('goods')->where(['id'=>$v['goodsid']])->find();
  463. $v['goods']=$goods;
  464. $v['ctime1']=date('Y-m-d H:i:s',$v['ctime']);
  465. $v['confirm_time1']=date('Y-m-d H:i:s',$v['confirm_time']);
  466. $v['status_desc']=config('tradeStatus')[$v['status']];
  467. $v['selluser']=get_user_info($v['userid'],'nickname','mobile');
  468. $v['buyuser']=get_user_info($v['relevant_userid'],'nickname','mobile');
  469. $v['stuname']=get_table_column('studio',$v['stuid'],'name');
  470. }
  471. if ($data_list) {
  472. $return['data'] = $data_list;
  473. } else {
  474. $return['data'] = null;
  475. }
  476. $count = db('trade' )->where($map)->count();
  477. $return['total'] = ceil($count / 10);
  478. return $return;
  479. }
  480. /*我的挂卖*/
  481. function gettradeout()
  482. {
  483. $times=strtotime('today')-60*60*24*2;
  484. $userId = $this->auth->id;
  485. $map['ctime']=['gt',$times];
  486. // $map['userid'] = $this->auth->id;
  487. $map['status'] = ['egt',3];
  488. $p = $this->request->post('p');
  489. $data_list = db('trade')->where($map)->where(function($query) use($userId){
  490. $query->where(['userid'=> $userId])->whereOr(function($query) use($userId){
  491. $query->where(['relevant_userid'=> $userId,'on_resale'=>1]);
  492. });
  493. })->page($p, 10)->order("id desc")->select();
  494. //var_dump(db('trade')->getLastSql());
  495. //$speedData = \app\common\model\Trade::getSpeedTotalByUser($userId);
  496. $config = Config::getConfigByGroup('trade');
  497. $releaseRate = isset($config['release_rate'])? floatval($config['release_rate']['value']) : 0;
  498. foreach ($data_list as &$v) {
  499. $goods=db('goods')->where(['id'=>$v['goodsid']])->find();
  500. $v['goods']=$goods;
  501. $v['ctime1']=date('Y-m-d H:i:s',$v['ctime']);
  502. $v['pay_time1']=date('Y-m-d H:i:s',$v['pay_time']);
  503. $v['confirm_time1']=date('Y-m-d H:i:s',$v['confirm_time']);
  504. $v['status_desc']=config('tradeStatus')[$v['status']];
  505. $v['selluser']=get_user_info($v['userid'],'nickname','mobile');
  506. $v['buyuser']=get_user_info($v['relevant_userid'],'nickname','mobile');
  507. $v['release_rate']=$releaseRate;
  508. $v['flag']=0;
  509. if($v['userid']== $this->auth->id)
  510. {
  511. $v['flag']=1;
  512. }elseif($v['relevant_userid']== $this->auth->id)
  513. {
  514. $v['flag']=2;
  515. }
  516. }
  517. if ($data_list) {
  518. $return['data'] = $data_list;
  519. } else {
  520. $return['data'] = null;
  521. }
  522. $count = db('trade' )->where($map)->count();
  523. $return['total'] = ceil($count / 10);
  524. return $return;
  525. }
  526. function tochange()
  527. {
  528. $params=$this->request->post();
  529. if($params['old'] == $params['new'])
  530. {
  531. $this->error('变更商家不可与原商家一致');
  532. }
  533. /*转商家记录不可重复提交*/
  534. $info=db('studio_code')->where(['goodsid'=>$params['goodsid'],'status'=>1])->find();
  535. if($info)
  536. {
  537. $this->error('此商品新店长还未处理,不可重复操作');
  538. }
  539. $params['userid']=$this->auth->id;
  540. $params['hostid']=$params['new'];
  541. $params['ctime']=time();
  542. $params['status']=1;
  543. $ids=db('studio_code')->insertGetId($params);
  544. if($ids)
  545. {
  546. $this->success('已提交审核,请耐心等待');
  547. }else{
  548. $this->error('提交失败,请重新操作');
  549. }
  550. }
  551. function tosethost()
  552. {
  553. $params=$this->request->post();
  554. $studio=db('studio')->where(['id'=>$params['id']])->find();
  555. if($studio['userid'] != $this->auth->id)
  556. {
  557. $this->error('你还不是店长不可设置商家参数');
  558. }
  559. if($params['new_title'])
  560. {
  561. $params['title']=$studio['ident'].$params['new_title'];
  562. }
  563. unset($params['new_title']);
  564. $res=db('studio')->where(['id'=>$params['id']])->update($params);
  565. if($res)
  566. {
  567. if(isset($params['title']) && $params['title']){
  568. \app\common\model\User::where(['id'=> $this->auth->id])->update(['login_studio'=> $params['title']]);
  569. }
  570. $this->success('设置成功');
  571. }else{
  572. $this->error('设置失败');
  573. }
  574. }
  575. function todjgoods()
  576. {
  577. $id=$this->request->post('id');
  578. $status=$this->request->post('status');
  579. $info=db('goods')->where(['id'=>$id])->find();
  580. if(empty($info))
  581. {
  582. $this->error('要操作的信息不存在');
  583. }else{
  584. if($status == 1)
  585. {
  586. $res=db('goods')->where(['id'=>$id,'on_sale'=>-1])->update(['on_sale'=>1]);
  587. }else{
  588. $res=db('goods')->where(['id'=>$id,'on_sale'=>1])->update(['on_sale'=>-1]);
  589. }
  590. if($res)
  591. {
  592. $this->success('操作完成');
  593. }else{
  594. $this->error('操作失败');
  595. }
  596. }
  597. }
  598. function toviewchange()
  599. {
  600. $id=$this->request->post('id');
  601. $status=$params=$this->request->post('status');
  602. $info=db('studio_code')->where(['id'=>$id,'status'=>1])->find();
  603. if(empty($info))
  604. {
  605. $this->error('要操作的信息不存在');
  606. }
  607. if($status == 1)
  608. {
  609. db()->startTrans();
  610. $res1=db('studio_code')->where(['id'=>$id])->update(['status'=>2,'utime'=>time()]);
  611. $res2=db('goods')->where(['id'=>$info['goodsid']])->update(['stuid'=>$info['new']]);
  612. if($res1 && $res2)
  613. {
  614. db('trade')->where(['status'=>['neq',4],'goodsid'=>$info['goodsid']])->update(['stuid'=>$info['new']]);
  615. db()->commit();
  616. $this->success('审核完成');
  617. }else{
  618. db()->rollback();
  619. $this->error('审核失败');
  620. }
  621. }else{
  622. $res=db('studio_code')->where(['id'=>$id])->update(['status'=>-1]);
  623. if($res)
  624. {
  625. $this->success('审核完成');
  626. }else{
  627. $this->error('审核失败');
  628. }
  629. }
  630. }
  631. function getmystdgoods()
  632. {
  633. $type = $this->request->post('type');
  634. if($type)
  635. {
  636. $map['on_sale']=$type;
  637. }
  638. $studio=db('studio')->where(['title'=>$this->auth->login_studio])->find();
  639. $map['stuid']=$studio['id'];
  640. $p = $this->request->post('p');
  641. $data_list = db('goods')->where($map)->page($p, 10)->order("id desc")->select();
  642. foreach ($data_list as &$v)
  643. {
  644. $info=db('studio_code')->where(['goodsid'=>$v['id'],'status'=>1])->find();
  645. if($info)
  646. {
  647. $v['iszc']=1;
  648. }else{
  649. $v['iszc']=0;
  650. }
  651. $v['username']=get_user_data($v['userid'],'mobile');
  652. }
  653. if ($data_list) {
  654. $return['data'] = $data_list;
  655. } else {
  656. $return['data'] = null;
  657. }
  658. $count = db('goods' )->where($map)->count();
  659. $return['total'] = ceil($count / 10);
  660. return $return;
  661. }
  662. function gethostdraw()
  663. {
  664. $map['on_sale']=1;
  665. $map['on_resale']=2;
  666. $map['stuid'] = $this->auth->stuid;
  667. $p = $this->request->post('p');
  668. $data_list = db('goods')->where($map)->page($p, 10)->order("id desc")->select();
  669. foreach ($data_list as &$v)
  670. {
  671. $v['username']=get_user_data($v['userid'],'mobile');
  672. }
  673. if ($data_list) {
  674. $return['data'] = $data_list;
  675. } else {
  676. $return['data'] = null;
  677. }
  678. $count = db('goods' )->where($map)->count();
  679. $return['total'] = ceil($count / 10);
  680. return $return;
  681. }
  682. function getchangedraw()
  683. {
  684. $status=$this->request->post('status');
  685. if($status == 1)
  686. {
  687. $map['status']=1;
  688. $map['hostid'] = $this->auth->stuid;
  689. }elseif($status == 2)
  690. {
  691. $map['new'] = $this->auth->stuid;
  692. }else{
  693. $map['old'] = $this->auth->stuid;
  694. }
  695. $p = $this->request->post('p');
  696. $data_list = db('studio_code')->where($map)->page($p, 10)->order("id desc")->select();
  697. foreach ($data_list as &$v)
  698. {
  699. $v['username']=get_user_data($v['userid'],'mobile');
  700. $v['olds']=get_table_column('studio',$v['old'],'title');
  701. $v['news']=get_table_column('studio',$v['new'],'title');
  702. $v['time1']=date('Y-m-d H:i:s',$v['ctime']);
  703. $v['time2']=$v['utime']>0?date('Y-m-d H:i:s',$v['utime']):'';
  704. }
  705. if ($data_list) {
  706. $return['data'] = $data_list;
  707. } else {
  708. $return['data'] = null;
  709. }
  710. $count = db('studio_code' )->where($map)->count();
  711. $return['total'] = ceil($count / 10);
  712. return $return;
  713. }
  714. function getmydraw()
  715. {
  716. $type = $this->request->post('type');
  717. if($type == 1)
  718. {
  719. $map['istrade']=0;
  720. }elseif($type == 2)
  721. {
  722. $map['istrade']=1;
  723. }
  724. $map['on_sale']=1;
  725. $map['on_resale']=2;
  726. $map['userid'] = $this->auth->id;
  727. $p = $this->request->post('p');
  728. $data_list = db('goods')->where($map)->page($p, 10)->order("id desc")->select();
  729. if ($data_list) {
  730. $return['data'] = $data_list;
  731. } else {
  732. $return['data'] = null;
  733. }
  734. $count = db('goods' )->where($map)->count();
  735. $return['total'] = ceil($count / 10);
  736. return $return;
  737. }
  738. /*交易列表*/
  739. function gettradelist()
  740. {
  741. $times=strtotime('today')-60*60*24*2;
  742. $map['ctime']=['gt',$times];
  743. $map['status']=['not in','0,-2'];
  744. $map['userid|relevant_userid'] = $this->auth->id;
  745. $p = $this->request->post('p');
  746. $data_list = db('trade')->where($map)->page($p, 10)->order("id desc")->select();
  747. foreach ($data_list as &$v) {
  748. $goods=db('goods')->where(['id'=>$v['goodsid']])->find();
  749. $v['goods']=$goods? $goods : ['image'=>''];
  750. $v['ctime1']=date('Y-m-d H:i:s',$v['ctime']);
  751. $v['pay_time1']=date('Y-m-d H:i:s',$v['pay_time']);
  752. $v['confirm_time1']=date('Y-m-d H:i:s',$v['confirm_time']);
  753. $v['selluser']=get_user_info($v['userid'],'nickname','mobile');
  754. $v['buyuser']=get_user_info($v['relevant_userid'],'nickname','mobile');
  755. $v['flag']=0;
  756. if($v['userid']== $this->auth->id)
  757. {
  758. $v['flag']=1;
  759. }elseif($v['relevant_userid']== $this->auth->id)
  760. {
  761. $v['flag']=2;
  762. }
  763. if($v['status'] == 3 && $v['issell'] == 0)
  764. {
  765. $v['status_desc']='待上架';
  766. }elseif($v['status'] == 3 && $v['issell'] == 1){
  767. $v['status_desc']='待茶室长确认';
  768. }elseif($v['status'] == 3 && $v['issell'] == 2){
  769. $v['status_desc']='已上架';
  770. }else{
  771. if($v['status'] == 1 && $v['flag']==1){
  772. $v['status_desc']='等待买方支付';
  773. }else if($v['status'] == 1 && $v['flag']==2){
  774. $v['status_desc']='待付款';
  775. }
  776. else if($v['status'] == 2 && $v['flag']==1){
  777. $v['status_desc']='待收款';
  778. }
  779. else if($v['status'] == 2 && $v['flag']==2){
  780. $v['status_desc']='等待卖方确认';
  781. }else{
  782. $v['status_desc']=config('tradeStatus')[$v['status']];
  783. }
  784. }
  785. }
  786. if ($data_list) {
  787. $return['data'] = $data_list;
  788. } else {
  789. $return['data'] = null;
  790. }
  791. $count = db('trade' )->where($map)->count();
  792. $return['total'] = ceil($count / 10);
  793. return $return;
  794. }
  795. function toselltrade()
  796. {
  797. $id=$this->request->request('id');
  798. $trade=db('trade')->where(['id'=>$id,'status'=>3,'issell'=>1])->find();
  799. if(empty($trade))
  800. {
  801. $this->error('订单不存在,或状态已发生改变');
  802. }
  803. db()->startTrans();
  804. $res1=db('goods')->where(['id'=>$trade['goodsid']])->update(['time1'=>time()]);
  805. $res=db('trade')->where(['id'=>$id,'status'=>3])->update(['issell'=>2,'create_time'=>strtotime('today'),'sendtime'=>time()]);
  806. if($res && $res1)
  807. {
  808. bonusorder($trade['relevant_userid'],$trade['nums']);
  809. addtrade($trade['goodsid']);
  810. db()->commit();
  811. $this->success('审核完成');
  812. }else{
  813. db()->rollback();
  814. $this->error('审核失败');
  815. }
  816. }
  817. function toupdatetrade()
  818. {
  819. $id=$this->request->request('id');
  820. $type=$this->request->request('type');
  821. $isadd=$this->request->request('isadd');
  822. $trade=db('trade')->where(['id'=>$id,'status'=>3,'issell'=>0])->find();
  823. if(empty($trade))
  824. {
  825. $this->error('订单不存在,或状态已发生改变');
  826. }
  827. if($type == 1)
  828. {//代售
  829. db()->startTrans();
  830. $res=db('trade')->where(['id'=>$id,'status'=>3])->update(['issell'=>1]);
  831. $res1=db('goods')->where(['id'=>$trade['goodsid']])->update(['time1'=>time()]);
  832. if($res && $res1)
  833. {
  834. db()->commit();
  835. $this->success('代售完成');
  836. }else{
  837. db()->rollback();
  838. $this->error('代售失败');
  839. }
  840. }else{
  841. $addressinfo=db('user_address')->where(['userid'=>$this->auth->id])->order('isdefault desc')->find();
  842. if(empty($addressinfo))
  843. {
  844. $this->error("地址不存在,请添加地址");
  845. }
  846. if($trade['issell']>0)
  847. {
  848. $this->error('已代售不可重复操作');
  849. }
  850. $goods=db('goods')->where(['id'=>$trade['goodsid']])->find();
  851. db()->startTrans();
  852. $res=db('trade')->where(['id'=>$id])->update(['status'=>4,'issell'=>-1,'sendtime'=>time()]);
  853. $data=[
  854. 'orderNo'=>date('YmdHis').rand(100,999),
  855. 'orderStatus'=>1,
  856. 'totalMoney'=>$trade['nums'],
  857. 'deliverMoney'=>0,
  858. 'userid'=>$this->auth->id,
  859. 'userName'=>$addressinfo['userName'],
  860. 'userPhone'=>$addressinfo['userPhone'],
  861. 'userAddress'=>$addressinfo['area'].$addressinfo['address'],
  862. 'addressId'=>$addressinfo['id'],
  863. 'remark'=>'',
  864. 'createTime'=>date('Y-m-d H:i:s'),
  865. 'needPay'=>0,
  866. 'utime'=>time(),
  867. 'type'=>0,
  868. 'tradeid'=>$id,
  869. ];
  870. $oids=db('order')->insertGetId($data);
  871. $ordGod=[
  872. 'orderid'=>$oids,
  873. 'goodsid'=>$trade['goodsid'],
  874. 'nums'=>1,
  875. 'price'=>$trade['nums'],
  876. 'attr'=>'',
  877. 'title'=>$goods['title'],
  878. 'image'=>$goods['image'],
  879. ];
  880. $ogids=db('order_goods')->insertGetId($ordGod);
  881. $logid=db('order_log')->insertGetId(['orderid'=>$oids,'title'=>'订单消息','content'=>'您的订单已生成,请耐心等待发货','userid'=>$this->auth->id,'ctime'=>time()]);
  882. if($res && $oids && $ogids && $logid)
  883. {
  884. db('goods')->where(['id'=>$goods['id']])->update(['on_sale'=>0]);
  885. db()->commit();
  886. $this->success('发货成功');
  887. }else{
  888. db()->rollback();
  889. $this->error('发货失败');
  890. }
  891. }
  892. }
  893. /*转售给平台 add by wes */
  894. function resaletrade()
  895. {
  896. $id=$this->request->request('id');
  897. $trade=db('trade')->where(['id'=>$id,'status'=>3,'issell'=>2])->find();
  898. if(empty($trade))
  899. {
  900. $this->error('订单商品不存在,或未上架无法转售');
  901. }
  902. if($trade['on_resale'] == 1) {
  903. $this->error('订单商品已转售');
  904. }
  905. $studio=db('studio')->where(['title'=>$this->auth->login_studio])->find();
  906. $startTime = isset($studio['start'])? $studio['start'] : 0;
  907. $endTime = isset($studio['end'])? $studio['end'] : 0;
  908. $startTime = $startTime? strtotime(date('Y-m-d').' '.$startTime) : 0;
  909. $endTime = $endTime? strtotime(date('Y-m-d').' '.$endTime) : 0;
  910. $expired = $startTime > time()? $startTime - time() : 0;
  911. if(time()>= $startTime && time() <= $endTime){
  912. $this->error('抱歉,请在营业时间以外转售');
  913. }
  914. db()->startTrans();
  915. $totalUsdt = CoinRate::transfer($trade['pre_price']);
  916. $res=db('trade')->where(['id'=>$id,'status'=>3])->update(['on_resale'=>1,'status'=>4,'release_total_usdt'=> $totalUsdt]);
  917. $res1=db('goods')->where(['id'=>$trade['goodsid']])->update(['time1'=>time(),'on_resale'=> 1]);
  918. if($res && $res1)
  919. {
  920. db()->commit();
  921. $this->success('转售平台完成');
  922. }else{
  923. db()->rollback();
  924. $this->error('转售平台失败');
  925. }
  926. }
  927. /*申诉*/
  928. function toappeal()
  929. {
  930. $id=$this->request->request('id');
  931. $appeal_text=$this->request->request('appeal_text');
  932. if(empty($appeal_text))
  933. {
  934. $this->error('缺少参数');
  935. }
  936. $res=db('trade')->where(['id'=>$id])->update(['status'=>-1,'isappeal'=>1,'appeal_text'=>$appeal_text]);
  937. if($res)
  938. {
  939. $this->success('申诉提交完成');
  940. }else{
  941. $this->error('申诉失败');
  942. }
  943. }
  944. function toyuyue()
  945. {
  946. $type=$this->request->request('type');
  947. if(empty($type))
  948. {
  949. $this->error('请选择价值范围');
  950. }
  951. $sid=$this->request->request('sid');
  952. if(empty($sid))
  953. {
  954. $this->error('请选择商家');
  955. }else{
  956. $map['stuid']=$sid;
  957. $gmap['stuid']=$sid;
  958. }
  959. $studio=db('studio')->where(['id'=>$sid])->find();
  960. $isappoint=db('studio_user')->where(['sid'=>$studio['id'],'userid'=>$this->auth->id])->find();
  961. if($isappoint)
  962. {
  963. $this->error('预约已关闭');
  964. }
  965. $bcf=db('bonus_config')->where(['id'=>5])->find();
  966. $yuyue_count=db('trade')->where(['stuid'=>$sid,'type'=>1,'status'=>['neq',-2],'relevant_userid'=>$this->auth->id,'appoint_time'=>['gt',strtotime('today')]])->count();
  967. if($yuyue_count >= $bcf['cap'])
  968. {
  969. $this->error('本商家今日预约已达上限');
  970. }
  971. #价格区间
  972. if($type == 5)
  973. {
  974. $map['endnums']=['egt',config('price_range')[$type]];
  975. $gmap['price1']=['egt',config('price_range')[$type]];
  976. }else{
  977. $price_range=explode('-',config('price_range')[$type]);
  978. $map['endnums'][]=['egt',$price_range[0]];
  979. $map['endnums'][]=['lt',$price_range[1]];
  980. $gmap['price1'][]=['egt',$price_range[0]];
  981. $gmap['price1'][]=['lt',$price_range[1]];
  982. }
  983. /*下架的不算*/
  984. $godis =[];
  985. $ggids=db('goods')->where(['on_sale'=>['neq',1]])->column('id');
  986. $ggids2=db('trade')->where(['status'=>0])->column('goodsid');
  987. if($ggids)
  988. {
  989. if($ggids2)
  990. {
  991. $godis=array_merge($ggids,$ggids2);
  992. }else{
  993. $godis=$ggids;
  994. }
  995. $map['goodsid']=['not in',$godis];
  996. $gmap['id']=['not in',$godis];
  997. }else{
  998. if($ggids2)
  999. {
  1000. $map['goodsid']=['not in',$ggids2];
  1001. $gmap['id']=['not in',$godis];
  1002. }
  1003. }
  1004. $map['relevant_userid']=['neq',$this->auth->id];/*不匹配自身订单*/
  1005. $map['status']=3;
  1006. $map['issell']=2;
  1007. $map['isout']=0;
  1008. $info=db('trade')->where($map)->find();
  1009. if(empty($info))
  1010. {
  1011. $gmap['userid']=['neq',$this->auth->id];
  1012. $gmap['on_sale']=1;
  1013. $gmap['on_resale']=2;
  1014. $gmap['istrade']=0;
  1015. $gmap['userid']=['neq',$this->auth->id];
  1016. $goods=db('goods')->where($gmap)->find();
  1017. if(empty($goods))
  1018. {
  1019. $this->error('没有商品可以预约,请更换价格范围');
  1020. }else{
  1021. db()->startTrans();
  1022. $feebcf=db('bonus_config')->where(['id'=>2])->find();
  1023. $tradedata=[
  1024. 'orderNo'=>date('YmdHi').rand(100,999),
  1025. 'userid'=>$goods['userid'],
  1026. 'goodsid'=>$goods['id'],
  1027. 'nums'=>$goods['price1'],
  1028. 'ctime'=>time(),
  1029. 'create_time'=>strtotime('today'),
  1030. 'status'=>0,
  1031. 'relevant_userid'=>$this->auth->id,
  1032. 'fee'=>$goods['price']*$feebcf['value']*0.01,
  1033. 'remark'=>date('Y-m-d H:i:s'),
  1034. 'catid'=>$goods['catid'],
  1035. 'stuid'=>$goods['stuid'],
  1036. 'appoint_time'=>time(),
  1037. 'type'=>1,
  1038. ];
  1039. $tradeid=db('trade')->insertGetId($tradedata);
  1040. $res1=db('goods')->where(['id'=>$goods['id']])->update(['istrade'=>1]);
  1041. if($tradeid && $res1)
  1042. {
  1043. db()->commit();
  1044. $this->success('预约完成');
  1045. }else{
  1046. db()->rollback();
  1047. $this->error('预约失败');
  1048. }
  1049. }
  1050. }else{
  1051. $feebcf=db('bonus_config')->where(['id'=>2])->find();
  1052. $tradedata=[
  1053. 'orderNo'=>date('YmdHi').rand(100,999),
  1054. 'userid'=>$info['relevant_userid'],
  1055. 'goodsid'=>$info['goodsid'],
  1056. 'nums'=>$info['endnums'],
  1057. 'ctime'=>time(),
  1058. 'create_time'=>strtotime('today'),
  1059. 'status'=>0,
  1060. 'relevant_userid'=>$this->auth->id,
  1061. 'fee'=>$info['endnums']*$feebcf['value']*0.01,
  1062. 'remark'=>date('Y-m-d H:i:s'),
  1063. 'catid'=>$info['catid'],
  1064. 'stuid'=>$info['stuid'],
  1065. 'appoint_time'=>time(),
  1066. 'type'=>1,
  1067. ];
  1068. $tradeid=db('trade')->insertGetId($tradedata);
  1069. if($tradeid)
  1070. {
  1071. $this->success('预约完成');
  1072. }else{
  1073. $this->error('预约失败');
  1074. }
  1075. }
  1076. }
  1077. function toownchange()
  1078. {
  1079. $goodsid=$this->request->request('goodsid');
  1080. $goods=db('goods')->where(['id'=>$goodsid])->find();
  1081. if(empty($goods))
  1082. {
  1083. $this->error('要操作的商品不存在');
  1084. }
  1085. $username=$this->request->request('username');
  1086. if(empty($username))
  1087. {
  1088. $this->error('请输入更改会员账户或手机号');
  1089. }
  1090. $user=db('user')->where(['username|mobile'=>$username])->find();
  1091. if($user['id'] == $goods['userid'])
  1092. {
  1093. $this->error('更改的所属人不可与原所属人一致');
  1094. }
  1095. $res=db('goods')->where(['id'=>$goodsid])->update(['userid'=>$user['id']]);
  1096. if($res)
  1097. {
  1098. db('trade')->where(['goodsid'=>$goodsid,'status'=>['in','1,2,3']])->update(['relevant_userid'=>$user['id']]);
  1099. $this->success('更改成功');
  1100. }else{
  1101. $this->error('更改失败');
  1102. }
  1103. }
  1104. // 拆分
  1105. function tosongoods()
  1106. {
  1107. $gid=input('id');
  1108. $goodsinfo=db('goods')->where(['id'=>$gid])->find();
  1109. $tradeinfo=db('trade')->where(['goodsid'=>$goodsinfo['id'],'status'=>['in','1,2,-1']])->find();
  1110. if($tradeinfo)
  1111. {
  1112. $this->error('此商品交易中,不可拆分');
  1113. }
  1114. $tradeinfo1=db('trade')->where(['goodsid'=>$goodsinfo['id'],'status'=>3,'issell'=>0])->find();
  1115. if($tradeinfo)
  1116. {
  1117. $this->error('此商品还未代售,不可拆分');
  1118. }
  1119. // if($goodsinfo['topprice']<=$goodsinfo['price1'])
  1120. // {
  1121. $sum=0;
  1122. $sumpreprice=0;
  1123. for($i=1;$i<=(int)$goodsinfo['son_nums'];$i++)
  1124. {
  1125. if($i < (int)$goodsinfo['son_nums'])
  1126. {
  1127. $price=round(($goodsinfo['price1']/$goodsinfo['son_nums']),0);
  1128. $preprice=round(($goodsinfo['pre_price']/$goodsinfo['son_nums']),0);
  1129. $sum+=$price;
  1130. $sumpreprice+=$preprice;
  1131. }else{
  1132. $price=$goodsinfo['price1']-$sum;
  1133. $preprice=$goodsinfo['pre_price']-$sumpreprice;
  1134. }
  1135. $data=[
  1136. 'catid'=>$goodsinfo['catid'],
  1137. 'title'=>$goodsinfo['title'].$i,
  1138. 'description'=>$goodsinfo['description'].'-'.$i,
  1139. 'content'=>$goodsinfo['content'],
  1140. 'image'=>$goodsinfo['image'],
  1141. 'images'=>$goodsinfo['images'],
  1142. 'on_sale'=>1,
  1143. 'price'=>$price-$preprice,
  1144. 'price1'=>$price,
  1145. 'pre_price'=>$preprice,
  1146. 'topprice'=>$goodsinfo['topprice'],
  1147. 'son_nums'=>$goodsinfo['son_nums'],
  1148. 'utime'=>time(),
  1149. 'isnew'=>1,
  1150. 'istrade'=>0,
  1151. 'stuid'=>$goodsinfo['stuid'],
  1152. 'userid'=>$goodsinfo['userid'],
  1153. ];
  1154. $ids=db('goods')->insertGetId($data);
  1155. }
  1156. db('goods')->where(['id'=>$goodsinfo['id']])->update(['on_sale'=>0,'price1'=>0,'price'=>0]);
  1157. db('trade')->where(['goodsid'=>$goodsinfo['id'],'status'=>3])->update(['isout'=>1]);
  1158. // }
  1159. $this->success('拆分成功');
  1160. }
  1161. }