Order.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693
  1. <?php
  2. declare (strict_types=1);
  3. namespace app\system\controller;
  4. use app\BaseController;
  5. use app\model\api\MemberDetail;
  6. //use app\model\api\Express;
  7. use app\model\api\Order as OrderModel;
  8. use app\model\api\ShowTemplateOrder as ShowTemplateOrderModel;
  9. use app\model\api\OrderInfo;
  10. use app\model\api\OrderMono;
  11. use app\Request;
  12. use library\services\UtilService;
  13. use library\utils\Region;
  14. use think\db\exception\DbException;
  15. use think\Exception;
  16. use think\facade\Db;
  17. use function GuzzleHttp\Psr7\str;
  18. // +----------------------------------------------------------------------
  19. // | [ WE CAN DO IT MORE SIMPLE ]
  20. // +----------------------------------------------------------------------
  21. // | Copyright (c) 2018-2020 rights reserved.
  22. // +----------------------------------------------------------------------
  23. // |
  24. // +----------------------------------------------------------------------
  25. // | Date: 2020-09-06 21:53
  26. // +----------------------------------------------------------------------
  27. class Order extends BaseController
  28. {
  29. /**
  30. * 获取订单数据
  31. * @param Request $request
  32. * @return mixed
  33. * @throws DbException
  34. */
  35. public function list(Request $request)
  36. {
  37. $pageSize = 50;
  38. $post = UtilService::getMore(
  39. [
  40. ['page', 1],
  41. ['uid',0],
  42. ['uip',''],
  43. ['order_id', ''],
  44. ['status',''],
  45. ['type',''],
  46. ['shop_id',''],
  47. ['is_ip_buy',''],
  48. ['mobile',''],
  49. ['name',''],
  50. ['tel',''],
  51. ['time',[]],
  52. ], $request
  53. );
  54. $where = [];
  55. if(!empty($post['uid'])){
  56. $where[]=["o.uid","=",$post['uid']];
  57. }else if(!empty($post['uip'])){
  58. $m = Db::name("user")->where("uip",$post['uip'])->find();
  59. if(!empty($m)) {
  60. $where[]=["o.uid","=",$m['uid']];
  61. }
  62. }else if(!empty($post['mobile'])){
  63. $m = Db::name("user")->where("mobile",$post['mobile'])->find();
  64. if(!empty($m)) {
  65. $where[]=["o.uid","=",$m['uid']];
  66. }
  67. }
  68. if(!empty($post['order_id'])){
  69. $where[]=["o.order_id","=",$post['order_id']];
  70. }
  71. if(in_array((string)$post['status'],["0","1","2","3","-1"])){
  72. $where[]=["o.status","=",(int)$post['status']];
  73. }
  74. if($post['is_ip_buy']!="" && in_array((string)$post['is_ip_buy'],["0","1"])){
  75. $where[]=["o.is_ip_buy","=",(int)$post['is_ip_buy']];
  76. }
  77. if($post['type']!="" && in_array((string)$post['type'],["shop","send"])){
  78. $where[]=["o.type","=",$post['type']];
  79. }
  80. if(!empty($post['name'])){
  81. $where[]=["o.name","=",$post['name']];
  82. }
  83. if(!empty($post['tel'])){
  84. $where[]=["o.tel","=",$post['tel']];
  85. }
  86. if(!empty($post['shop_id'])){
  87. $where[]=["o.shop_id","=",$post['shop_id']];
  88. }
  89. //创建时间
  90. $startTime="";
  91. $endTime="";
  92. if(!empty($post['time'][0]) && !empty($post['time'][1])) {
  93. $startTime = strtotime($post['time'][0]);
  94. $endTime = strtotime($post['time'][1]);
  95. $where[]=["o.time","between","{$startTime},{$endTime}"];
  96. }
  97. $order = new OrderModel;
  98. $data = $order
  99. ->alias("o")
  100. ->field("o.*,u1.mobile,u1.uip,u1.nickname")
  101. ->leftJoin("user u1","u1.uid = o.uid")
  102. ->where($where)
  103. ->page((int)$post["page"], $pageSize)
  104. ->order("o.id","desc")
  105. ->select()
  106. ->toArray();
  107. $pageCount = $order->alias("o")->where($where)->count();
  108. $result = UtilService::getParam([
  109. "id",
  110. "order_id",
  111. "uid",
  112. "uip",
  113. "mobile",
  114. "nickname",
  115. "total_money",
  116. "all_money",
  117. "pay_money",
  118. "postage",
  119. "name",
  120. "tel",
  121. "address",
  122. "coupon_money",
  123. "is_ip_buy",
  124. "status",
  125. "score",
  126. "give_score",
  127. "mono",
  128. "express_num",
  129. "type",
  130. "shop_id",
  131. "content",
  132. ['time', 'time', 'date("Y-m-d H:i:s",$1)'],
  133. ['pay_time', 'pay_time', function ($item) {
  134. return empty($item) ? "-" : date('Y-m-d H:i:s', $item);
  135. }],
  136. ['fa_time', 'fa_time', function ($item) {
  137. return empty($item) ? "-" : date('Y-m-d H:i:s', $item);
  138. }],
  139. ['ok_time', 'ok_time', function ($item) {
  140. return empty($item) ? "-" : date('Y-m-d H:i:s', $item);
  141. }],
  142. ], $data);
  143. return app('json')->success([
  144. 'list' => $result,
  145. 'pageCount' => $pageCount,
  146. 'pageSize' => $pageSize,
  147. 'page' => $post['page'],
  148. ]);
  149. }
  150. /**
  151. * 搜索统计
  152. */
  153. public function total(Request $request)
  154. {
  155. $post = UtilService::getMore(
  156. [
  157. ['uid',0],
  158. ['uip',''],
  159. ['mobile',''],
  160. ['tel',''],
  161. ['name',''],
  162. ['type',''],
  163. ['shop_id',''],
  164. ['order_id', ''],
  165. ['status',''],
  166. ['is_ip_buy',''],
  167. ['time',[]],
  168. ], $request
  169. );
  170. $order = new OrderModel;
  171. $totalWhere = [];
  172. if(!empty($post['uid'])){
  173. $totalWhere[]=["uid","=",$post['uid']];
  174. }else if(!empty($post['uip'])){
  175. $m = Db::name("user")->where("uip",$post['uip'])->find();
  176. if(!empty($m)) {
  177. $totalWhere[]=["uid","=",$m['uid']];
  178. }
  179. }else if(!empty($post['mobile'])){
  180. $m = Db::name("user")->where("mobile",$post['mobile'])->find();
  181. if(!empty($m)) {
  182. $totalWhere[]=["uid","=",$m['uid']];
  183. }
  184. }
  185. if(!empty($post['order_id'])){
  186. $totalWhere[]=["order_id","=",$post['order_id']];
  187. }
  188. if($post['is_ip_buy']!="" && in_array((string)$post['is_ip_buy'],["0","1"])){
  189. $totalWhere[]=["is_ip_buy","=",(int)$post['is_ip_buy']];
  190. }
  191. if($post['type']!="" && in_array((string)$post['type'],["shop","send"])){
  192. $totalWhere[]=["type","=",$post['type']];
  193. }
  194. if(in_array((string)$post['status'],["0","1","2","3","-1"])){
  195. $totalWhere[]=["status","=",$post['status']];
  196. }
  197. if(!empty($post['name'])){
  198. $totalWhere[]=["name","=",$post['name']];
  199. }
  200. if(!empty($post['tel'])){
  201. $totalWhere[]=["tel","=",$post['tel']];
  202. }
  203. if(!empty($post['shop_id'])){
  204. $totalWhere[]=["shop_id","=",$post['shop_id']];
  205. }
  206. //创建时间
  207. $startTime="";
  208. $endTime="";
  209. if(!empty($post['time'][0]) && !empty($post['time'][1])) {
  210. $startTime = strtotime($post['time'][0]);
  211. $endTime = strtotime($post['time'][1]);
  212. $totalWhere[]=["time","between","{$startTime},{$endTime}"];
  213. }
  214. foreach($totalWhere as $k=>$v){
  215. if($v[0]=="status"){
  216. array_splice($totalWhere,$k,1);
  217. }
  218. }
  219. //全部
  220. $orderCount = $order->where($totalWhere)->count();
  221. //待支付
  222. $waitPayWhere = $totalWhere;
  223. $waitPayWhere[] = ["status","=","0"];
  224. $waitPayCount = $order->where($waitPayWhere)->count();
  225. //待发货
  226. $waitSendWhere = $totalWhere;
  227. $waitSendWhere[] = ["status","=",1];
  228. $waitSendCount = $order->where($waitSendWhere)->count();
  229. //待收货
  230. $waitAcceptWhere = $totalWhere;
  231. $waitAcceptWhere[] = ["status","=",2];
  232. $waitAcceptCount = $order->where($waitAcceptWhere)->count();
  233. //已完成
  234. $okWhere = $totalWhere;
  235. $okWhere[] = ["status","=",3];
  236. $okCount = $order->where($okWhere)->count();
  237. //已取消
  238. $closeWhere = $totalWhere;
  239. $closeWhere[] = ["status","=",-1];
  240. $closeCount = $order->where($closeWhere)->count();
  241. return app('json')->success([
  242. 'orderCount' => $orderCount,
  243. 'waitPayCount'=> $waitPayCount,
  244. 'waitSendCount' => $waitSendCount,
  245. 'waitAcceptCount'=>$waitAcceptCount,
  246. 'okCount'=>$okCount,
  247. 'closeCount' => $closeCount,
  248. ]);
  249. }
  250. /**
  251. * 订单详情
  252. * @param Request $request
  253. */
  254. public function info(Request $request)
  255. {
  256. [$id] = UtilService::getMore([
  257. ['id', '', 'empty', '参数错误'],
  258. ], $request, true);
  259. $oData = (new OrderModel)
  260. ->alias("o")
  261. ->field("o.*,u1.mobile,u1.uip,u1.nickname")
  262. ->leftJoin("user u1","u1.uid = o.uid")
  263. ->where("o.id",$id)
  264. ->find();
  265. if (empty($oData)) {
  266. return app('json')->fail('找不到订单号');
  267. }
  268. //主订单数据
  269. $data = [];
  270. $data['id'] = $oData['id'];
  271. $data['order_id'] = $oData['order_id'];
  272. $data['uid'] = $oData['uid'];
  273. $data['mobile'] = $oData['mobile'];
  274. $data['nickname'] = $oData['nickname'];
  275. $data['total_money'] = $oData['total_money'];
  276. $data['all_money'] = $oData['all_money'];
  277. $data['pay_money'] = $oData['pay_money'];
  278. $data['postage'] = $oData['postage'];
  279. $data['name'] = $oData['name'];
  280. $data['tel'] = $oData['tel'];
  281. $data['address'] = $oData['address'];
  282. $data['coupon_money'] = $oData['coupon_money'];
  283. $data['is_ip_buy'] = $oData['is_ip_buy'];
  284. $data['status'] = $oData['status'];
  285. $data['score'] = $oData['score'];
  286. $data['give_score'] = $oData['give_score'];
  287. $data['mono'] = $oData['mono'];
  288. $data['express_num'] = $oData['express_num'];
  289. $data['content'] = $oData['content'];
  290. $data['time'] = date('Y-m-d H:i:s', $oData['time']);
  291. $data['pay_time'] = empty($oData['pay_time'])?"-":date('Y-m-d H:i:s', $oData['pay_time']);
  292. $data['fa_time'] = empty($oData['fa_time'])?"-":date('Y-m-d H:i:s', $oData['fa_time']);
  293. $data['ok_time'] = empty($oData['ok_time'])?"-":date('Y-m-d H:i:s', $oData['ok_time']);
  294. //订单详情
  295. $info = (new OrderInfo)->where("o_id", $oData['id'])->select()->toArray();
  296. $infoData = [];
  297. foreach ($info as $v) {
  298. $d = [];
  299. $d['id'] = $v['id'];
  300. $d['p_id'] = $v['p_id'];
  301. $d['title'] = $v['title'];
  302. $d['img'] = $v['img'];
  303. $d['count'] = $v['count'];
  304. $d['price'] = $v['price'];
  305. $d['money'] = $v['money'];
  306. $d['is_ip_buy'] = $v['is_ip_buy'];
  307. $d['give_score'] = $v['give_score'];
  308. $infoData[] = $d;
  309. }
  310. $data['info'] = $infoData;
  311. return app('json')->success($data);
  312. }
  313. /**
  314. * 订单备注记录
  315. * @param Request $request
  316. * @return mixed
  317. */
  318. public function log(Request $request){
  319. $pageSize = 20;
  320. $post = UtilService::getMore([
  321. ['page', 1],
  322. ['o_id', '','empty','参数错误']
  323. ], $request);
  324. $where=[];
  325. $where['m.o_id'] = $post['o_id'];
  326. $where['m.code'] = "shop";
  327. $pageCount = (new OrderMono)->alias("m")->where($where)->count();
  328. $data = (new OrderMono)
  329. ->alias("m")
  330. ->where($where)
  331. ->order("id","desc")
  332. ->page((int)$post["page"], $pageSize)
  333. ->select()
  334. ->toArray();
  335. $data = empty($data)?[]:$data;
  336. foreach($data as $k=>$v){
  337. $data[$k]["time"] = date("Y-m-d H:i:s",$v["time"]);
  338. }
  339. return app('json')->success([
  340. 'list' => $data,
  341. 'pageCount' => $pageCount,
  342. 'pageSize' => $pageSize,
  343. 'page' => $post['page'],
  344. ]);
  345. }
  346. /**
  347. * 进行发货
  348. * @global type $_A
  349. * @param Request $request
  350. */
  351. public function fahuo(Request $request) {
  352. $post = UtilService::getMore([
  353. ['id','','empty','参数错误'],
  354. ['express_num',''],
  355. ['remark',''],
  356. ],$request);
  357. $oData = (new OrderModel)->where("id",$post["id"])->where("status",1)->find();
  358. if (empty($oData)) {
  359. return app('json')->fail('当前订单不可发货');
  360. }
  361. if($oData["type"]=='send' && empty($post["express_num"])){
  362. return app('json')->fail('请输入物流单号');
  363. }
  364. $r = (new OrderModel)->where("id",$post["id"])->update([
  365. "status"=>2,
  366. "express_num"=>$post["express_num"],
  367. "fa_time"=>time(),
  368. ]);
  369. if(!$r){
  370. return app('json')->fail('操作失败');
  371. }
  372. $saveData=[];
  373. $saveData[]=[
  374. "o_id"=>$oData["id"],
  375. "order_id"=>$oData["order_id"],
  376. "mono"=>$oData["type"]=='send'?"确定发货, 物流单号:" . $post["express_num"]:"门店确定清点完毕",
  377. "time"=>time(),
  378. "admin_id"=>$request->adminInfo['id'],
  379. "admin_name"=>$request->adminInfo['name'],
  380. "type"=>1,
  381. "code"=>"shop",
  382. ];
  383. if(!empty($post["remark"])){
  384. $saveData[]=[
  385. "o_id"=>$oData["id"],
  386. "order_id"=>$oData["order_id"],
  387. "mono"=>$post["remark"],
  388. "time"=>time(),
  389. "admin_id"=>$request->adminInfo['id'],
  390. "admin_name"=>$request->adminInfo['name'],
  391. "type"=>1,
  392. "code"=>"shop",
  393. ];
  394. }
  395. (new OrderMono)->insertAll($saveData);
  396. return app('json')->success('操作成功');
  397. }
  398. /**
  399. * 订单备注提交
  400. * @param Request $request
  401. * @return mixed
  402. */
  403. public function mono(Request $request) {
  404. $post = UtilService::getMore([
  405. ['remark','','empty','请输入备注内容'],
  406. ['id','','empty','参数错误']
  407. ],$request);
  408. $oData = (new OrderModel)->where("id",$post["id"])->find();
  409. if (empty($oData)) {
  410. return app('json')->fail('订单不存在');
  411. }
  412. (new OrderMono)->insert([
  413. "o_id"=>$oData["id"],
  414. "order_id"=>$oData["order_id"],
  415. "mono"=>$post["remark"],
  416. "time"=>time(),
  417. "admin_id"=>$request->adminInfo['id'],
  418. "admin_name"=>$request->adminInfo['name'],
  419. "type"=>1,
  420. "code"=>"shop",
  421. ]);
  422. return app('json')->success('处理成功');
  423. }
  424. /**
  425. * 获取活动订单数据
  426. * @param Request $request
  427. * @return mixed
  428. * @throws DbException
  429. */
  430. public function showTemplateList(Request $request)
  431. {
  432. $pageSize = 50;
  433. $post = UtilService::getMore(
  434. [
  435. ['page', 1],
  436. ['uid',0],
  437. ['show_template_id',''],
  438. ['uip',''],
  439. ['order_id', ''],
  440. ['status',''],
  441. ['mobile',''],
  442. ['time',[]],
  443. ], $request
  444. );
  445. $where = [];
  446. if(!empty($post['uid'])){
  447. $where[]=["o.uid","=",$post['uid']];
  448. }else if(!empty($post['mobile'])){
  449. $m = Db::name("user")->where("mobile",$post['mobile'])->find();
  450. if(!empty($m)) {
  451. $where[]=["o.uid","=",$m['uid']];
  452. }
  453. }
  454. if(!empty($post['show_template_id'])){
  455. $where[]=["o.show_template_id","=",$post['show_template_id']];
  456. }
  457. if(!empty($post['order_id'])){
  458. $where[]=["o.order_id","=",$post['order_id']];
  459. }
  460. if(in_array((string)$post['status'],["0","1","-1"])){
  461. $where[]=["o.status","=",(int)$post['status']];
  462. }
  463. //创建时间
  464. $startTime="";
  465. $endTime="";
  466. if(!empty($post['time'][0]) && !empty($post['time'][1])) {
  467. $startTime = strtotime($post['time'][0]);
  468. $endTime = strtotime($post['time'][1]);
  469. $where[]=["o.time","between","{$startTime},{$endTime}"];
  470. }
  471. $order = new ShowTemplateOrderModel;
  472. $data = $order
  473. ->alias("o")
  474. ->field("o.*,u1.mobile,u1.nickname,a.title as show_template_title,a.imgs as show_template_imgs")
  475. ->leftJoin("user u1","u1.uid = o.uid")
  476. ->leftJoin("show_template a","a.id = o.show_template_id")
  477. ->where($where)
  478. ->page((int)$post["page"], $pageSize)
  479. ->order("o.id","desc")
  480. ->select()
  481. ->toArray();
  482. $pageCount = $order->alias("o")->where($where)->count();
  483. $result = UtilService::getParam([
  484. "id",
  485. "order_id",
  486. "uid",
  487. "mobile",
  488. "nickname",
  489. "total_money",
  490. "all_money",
  491. "pay_money",
  492. "status",
  493. "show_template_id",
  494. "show_template_title",
  495. ['show_template_imgs', 'show_template_imgs', function ($item) {
  496. return empty($item) ? [] : explode(",", $item);
  497. }],
  498. ['time', 'time', 'date("Y-m-d H:i:s",$1)'],
  499. ['pay_time', 'pay_time', function ($item) {
  500. return empty($item) ? "-" : date('Y-m-d H:i:s', $item);
  501. }],
  502. ], $data);
  503. return app('json')->success([
  504. 'list' => $result,
  505. 'pageCount' => $pageCount,
  506. 'pageSize' => $pageSize,
  507. 'page' => $post['page'],
  508. ]);
  509. }
  510. /**
  511. * 搜索统计
  512. */
  513. public function showTemplateTotal(Request $request)
  514. {
  515. $post = UtilService::getMore(
  516. [
  517. ['uid',0],
  518. ['mobile',''],
  519. ['order_id', ''],
  520. ['status',''],
  521. ['show_template_id',''],
  522. ['time',[]],
  523. ], $request
  524. );
  525. $order = new ShowTemplateOrderModel;
  526. $totalWhere = [];
  527. if(!empty($post['uid'])){
  528. $totalWhere[]=["uid","=",$post['uid']];
  529. }else if(!empty($post['mobile'])){
  530. $m = Db::name("user")->where("mobile",$post['mobile'])->find();
  531. if(!empty($m)) {
  532. $totalWhere[]=["uid","=",$m['uid']];
  533. }
  534. }
  535. if(!empty($post['show_template_id'])){
  536. $totalWhere[]=["show_template_id","=",$post['show_template_id']];
  537. }
  538. if(!empty($post['order_id'])){
  539. $totalWhere[]=["order_id","=",$post['order_id']];
  540. }
  541. if(in_array((string)$post['status'],["0","1","-1"])){
  542. $totalWhere[]=["status","=",$post['status']];
  543. }
  544. //创建时间
  545. $startTime="";
  546. $endTime="";
  547. if(!empty($post['time'][0]) && !empty($post['time'][1])) {
  548. $startTime = strtotime($post['time'][0]);
  549. $endTime = strtotime($post['time'][1]);
  550. $totalWhere[]=["time","between","{$startTime},{$endTime}"];
  551. }
  552. foreach($totalWhere as $k=>$v){
  553. if($v[0]=="status"){
  554. array_splice($totalWhere,$k,1);
  555. }
  556. }
  557. //全部
  558. $orderCount = $order->where($totalWhere)->count();
  559. //待支付
  560. $waitPayWhere = $totalWhere;
  561. $waitPayWhere[] = ["status","=","0"];
  562. $waitPayCount = $order->where($waitPayWhere)->count();
  563. //待发货
  564. $waitSendWhere = $totalWhere;
  565. $waitSendWhere[] = ["status","=",1];
  566. $waitSendCount = $order->where($waitSendWhere)->count();
  567. //已取消
  568. $closeWhere = $totalWhere;
  569. $closeWhere[] = ["status","=",-1];
  570. $closeCount = $order->where($closeWhere)->count();
  571. return app('json')->success([
  572. 'orderCount' => $orderCount,
  573. 'waitPayCount'=> $waitPayCount,
  574. 'waitSendCount' => $waitSendCount,
  575. 'closeCount' => $closeCount,
  576. ]);
  577. }
  578. /**
  579. * 活动订单详情
  580. * @param Request $request
  581. */
  582. public function showTemplateInfo(Request $request)
  583. {
  584. [$id] = UtilService::getMore([
  585. ['id', '', 'empty', '参数错误'],
  586. ], $request, true);
  587. $oData = (new ShowTemplateOrderModel)
  588. ->alias("o")
  589. ->field("o.*,u1.mobile,u1.nickname,a.title as show_template_title,a.imgs as show_template_imgs")
  590. ->leftJoin("user u1","u1.uid = o.uid")
  591. ->leftJoin("show_template a","a.id = o.show_template_id")
  592. ->where("o.id",$id)
  593. ->find();
  594. if (empty($oData)) {
  595. return app('json')->fail('找不到订单号');
  596. }
  597. //主订单数据
  598. $data = [];
  599. $data['id'] = $oData['id'];
  600. $data['order_id'] = $oData['order_id'];
  601. $data['uid'] = $oData['uid'];
  602. $data['mobile'] = $oData['mobile'];
  603. $data['nickname'] = $oData['nickname'];
  604. $data['total_money'] = $oData['total_money'];
  605. $data['all_money'] = $oData['all_money'];
  606. $data['pay_money'] = $oData['pay_money'];
  607. $data['status'] = $oData['status'];
  608. $data['show_template_id'] = $oData['show_template_id'];
  609. $data['show_template_title'] = $oData['show_template_title'];
  610. $data['show_template_imgs'] = empty($oData['show_template_imgs'])?[]: explode(",", $oData['show_template_imgs']);
  611. $data['status'] = $oData['status'];
  612. $data['time'] = date('Y-m-d H:i:s', $oData['time']);
  613. $data['pay_time'] = empty($oData['pay_time'])?"-":date('Y-m-d H:i:s', $oData['pay_time']);
  614. //订单详情
  615. $data['info'] = empty($oData["data"]) ? [] : unserialize($oData["data"]);
  616. return app('json')->success($data);
  617. }
  618. /**
  619. * 订单备注记录
  620. * @param Request $request
  621. * @return mixed
  622. */
  623. public function showTemplateLog(Request $request){
  624. $pageSize = 20;
  625. $post = UtilService::getMore([
  626. ['page', 1],
  627. ['o_id', '','empty','参数错误']
  628. ], $request);
  629. $where=[];
  630. $where['m.o_id'] = $post['o_id'];
  631. $where['m.code'] = "show_template";
  632. $pageCount = (new OrderMono)->alias("m")->where($where)->count();
  633. $data = (new OrderMono)
  634. ->alias("m")
  635. ->where($where)
  636. ->order("id","desc")
  637. ->page((int)$post["page"], $pageSize)
  638. ->select()
  639. ->toArray();
  640. $data = empty($data)?[]:$data;
  641. foreach($data as $k=>$v){
  642. $data[$k]["time"] = date("Y-m-d H:i:s",$v["time"]);
  643. }
  644. return app('json')->success([
  645. 'list' => $data,
  646. 'pageCount' => $pageCount,
  647. 'pageSize' => $pageSize,
  648. 'page' => $post['page'],
  649. ]);
  650. }
  651. /**
  652. * 报名订单备注提交
  653. * @param Request $request
  654. * @return mixed
  655. */
  656. public function showTemplateMono(Request $request) {
  657. $post = UtilService::getMore([
  658. ['remark','','empty','请输入备注内容'],
  659. ['id','','empty','参数错误']
  660. ],$request);
  661. $oData = (new ShowTemplateOrderModel)->where("id",$post["id"])->find();
  662. if (empty($oData)) {
  663. return app('json')->fail('订单不存在');
  664. }
  665. (new OrderMono)->insert([
  666. "o_id"=>$oData["id"],
  667. "order_id"=>$oData["order_id"],
  668. "mono"=>$post["remark"],
  669. "time"=>time(),
  670. "admin_id"=>$request->adminInfo['id'],
  671. "admin_name"=>$request->adminInfo['name'],
  672. "type"=>1,
  673. "code"=>"show_template",
  674. ]);
  675. return app('json')->success('处理成功');
  676. }
  677. }