Order.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  1. <?php
  2. /**
  3. * @package merchant
  4. *
  5. * @author Qinii
  6. * @day 2020-06-15
  7. *
  8. *
  9. */
  10. namespace app\controller\admin\order;
  11. use crmeb\basic\BaseController;
  12. use app\common\repositories\store\ExcelRepository;
  13. use app\common\repositories\system\merchant\MerchantRepository;
  14. use app\common\repositories\store\order\StoreOrderRepository as repository;
  15. use crmeb\services\SpreadsheetExcelService;
  16. use think\App;
  17. use think\facade\Db;
  18. class Order extends BaseController
  19. {
  20. protected $repository;
  21. public function __construct(App $app, repository $repository)
  22. {
  23. parent::__construct($app);
  24. $this->repository = $repository;
  25. }
  26. public function lst($id)
  27. {
  28. [$page, $limit] = $this->getPage();
  29. $where = $this->request->params(['date','order_sn','order_type','keywords','username']);
  30. $productKeywords = $this->request->param('product_keywords');//商品关键字
  31. $where['reconciliation_type'] = $this->request->param('status', 1);
  32. $where['mer_id'] = $id;
  33. $where['product_keywords'] = $productKeywords;
  34. return app('json')->success($this->repository->adminGetList($where, $page, $limit));
  35. }
  36. public function markForm($id)
  37. {
  38. if (!$this->repository->getWhereCount([$this->repository->getPk() => $id]))
  39. return app('json')->fail('数据不存在');
  40. return app('json')->success(formToData($this->repository->adminMarkForm($id)));
  41. }
  42. public function mark($id)
  43. {
  44. if (!$this->repository->getWhereCount([$this->repository->getPk() => $id]))
  45. return app('json')->fail('数据不存在');
  46. $data = $this->request->params(['admin_mark']);
  47. $this->repository->update($id, $data);
  48. return app('json')->success('备注成功');
  49. }
  50. /**
  51. * TODO
  52. * @return mixed
  53. * @author Qinii
  54. * @day 2020-06-25
  55. */
  56. public function getAllList()
  57. {
  58. [$page, $limit] = $this->getPage();
  59. $where = $this->request->params(['type', 'date', 'mer_id','keywords','status','username','order_sn','order_ids','paid', 'zero_line_uid']);
  60. $pay_type=$this->request->param('pay_type');
  61. if($pay_type==1 || $pay_type==4){
  62. $where['pay_type']=$pay_type;
  63. }
  64. if($pay_type==6){
  65. //一壶茶红积分兑换的
  66. $where['mer_id']=496;
  67. $where['pay_type']=5;
  68. }
  69. // 导出
  70. $is_excel = request()->param('is_excel', 0);
  71. $result = $this->repository->merchantGetList($where, $page, $limit, $is_excel);
  72. if ($is_excel == 1) {
  73. $data = $result['list'];
  74. $arr = [];
  75. foreach ($data as $item) {
  76. $arr[] = [
  77. $item['order_sn'], // 订单编号
  78. $item['order_type'] == 0 ? "普通订单" : "核销订单", // 订单类型
  79. $item['user']['nickname'] ?? '', // 用户昵称
  80. $item['user']['phone'] ?? '', // 用户手机号
  81. $item['real_name'], // 收货人
  82. $item['merchant']['mer_name'] ?? '', // 商户名称
  83. // $item['orderProduct'][0]['cart_info']['product']['image'],
  84. ($item['orderProduct'][0]['cart_info']['product']['store_name'] ?? '') . ' | ' . ($item['orderProduct'][0]['cart_info']['productAttr']['sku'] ?? ''),
  85. $item['orderProduct'][0]['cart_info']['productAttr']['price'] ?? 0.00,
  86. $item['orderProduct'][0]['product_num'] ?? 0,
  87. $item['pay_price'], // 订单金额
  88. $item['paid'] == 0 ? "未支付" : "已支付", // 支付状态
  89. $item['fzone_pay_note'], // 支付方式
  90. $item['fzone_pay_jifen'], // 支付方式
  91. $item['fzone_pay_price'], // 支付方式
  92. $item['fzone_pay_jingdou'], // 支付方式
  93. $item['fzone_pay_vr'], // 支付方式
  94. $item['is_del'] == 0 ? ($item['status'] == 5 ? '待付款' : ($item['status'] == 0 ? '待发货' : ($item['status'] == 1 ? '待收货' : ($item['status'] == 2 ? '待评价' : ($item['status'] == 3 ? '已完成' : ($item['status'] == 4 ? '已申请退款' : ($item['status'] == -1 ? '已退款' : ($item['status'] == 6 ? '已取消' : '')))))))) : '已删除', // 订单状态
  95. $item['create_time'], // 下单时间
  96. ];
  97. }
  98. return app('json')->success($this->getStatisticsExcel([
  99. '订单编号',
  100. '订单类型',
  101. '用户昵称',
  102. '用户手机号',
  103. '收货人',
  104. '商户名称',
  105. '商品图片',
  106. // '商品名称',
  107. '商品单价',
  108. '商品数量',
  109. '订单金额',
  110. '支付状态',
  111. '支付方式',
  112. '支付积分',
  113. '支付现金',
  114. '支付京豆',
  115. '支付VR',
  116. '订单状态',
  117. '下单时间'
  118. ], $arr, '订单明细'));
  119. }
  120. return app('json')->success($result);
  121. }
  122. /**
  123. * 获取统计导出
  124. */
  125. public function getStatisticsExcel($header,$arr,$title)
  126. {
  127. $filename = $title.'_'.date('YmdHis').'_'.rand(10000,99999);
  128. $name = $filename;
  129. $info = '生成时间:' . date('Y-m-d H:i:s',time());
  130. $suffix='xlsx';
  131. $path='extract';
  132. unset($_instance);
  133. $_instance = SpreadsheetExcelService::instance_xin();
  134. $_path =$_instance
  135. ->createOrActive()
  136. ->setExcelHeader($header)
  137. ->setExcelTile($title, $name, $info)
  138. ->setExcelContent($arr)
  139. ->excelSave($filename, $suffix, $path);
  140. $domain = request()->domain();
  141. $data= [
  142. 'name' => $filename.'.'.$suffix,
  143. 'status' => 1,
  144. 'path' => $domain.'/'.$_path
  145. ];
  146. return $data;
  147. }
  148. /**
  149. * TODO 自提订单列表
  150. * @return mixed
  151. * @author Qinii
  152. * @day 2020-08-17
  153. */
  154. public function getTakeList()
  155. {
  156. [$page, $limit] = $this->getPage();
  157. $where = $this->request->params(['date','order_sn','keywords','username']);
  158. $where['take_order'] = 1;
  159. $where['status'] = -1;
  160. $where['verify_date'] = $where['date'];
  161. unset($where['date']);
  162. return app('json')->success($this->repository->merchantGetList($where, $page, $limit));
  163. }
  164. /**
  165. * TODO
  166. * @return mixed
  167. * @author Qinii
  168. * @day 2020-08-17
  169. */
  170. public function chart()
  171. {
  172. $where = $this->request->params(['type', 'date', 'mer_id','keywords','username','order_sn','order_ids','paid']);
  173. return app('json')->success($this->repository->adminOrderNumber(-1, $where));
  174. }
  175. /**
  176. * TODO 自提订单头部统计
  177. * @return mixed
  178. * @author Qinii
  179. * @day 2020-08-17
  180. */
  181. public function takeChart()
  182. {
  183. return app('json')->success($this->repository->adminOrderNumber(1));
  184. }
  185. /**
  186. * TODO 订单类型
  187. * @return mixed
  188. * @author Qinii
  189. * @day 2020-08-15
  190. */
  191. public function orderType()
  192. {
  193. return app('json')->success($this->repository->orderType([]));
  194. }
  195. public function detail($id)
  196. {
  197. $data = $this->repository->getOne($id, null);
  198. if (!$data)
  199. return app('json')->fail('数据不存在');
  200. return app('json')->success($data);
  201. }
  202. /**
  203. * TODO 快递查询
  204. * @param $id
  205. * @return mixed
  206. * @author Qinii
  207. * @day 2020-06-25
  208. */
  209. public function express($id)
  210. {
  211. if (!$this->repository->getWhereCount(['order_id' => $id, 'delivery_type' => 1]))
  212. return app('json')->fail('订单信息或状态错误');
  213. return app('json')->success($this->repository->express($id));
  214. }
  215. public function reList($id)
  216. {
  217. [$page, $limit] = $this->getPage();
  218. $where = ['reconciliation_id' => $id, 'type' => 0];
  219. return app('json')->success($this->repository->reconList($where, $page, $limit));
  220. }
  221. /**
  222. * TODO 导出文件
  223. * @author Qinii
  224. * @day 2020-07-30
  225. */
  226. public function excel()
  227. {
  228. $where = $this->request->params(['type', 'date', 'mer_id','keywords','status','username','order_sn']);
  229. app()->make(ExcelRepository::class)->create($where, $this->request->adminId(), 'order',0);
  230. return app('json')->success('开始导出数据');
  231. }
  232. /**
  233. * 养老金打款凭证 列表
  234. * @return mixed
  235. * @throws \think\db\exception\DataNotFoundException
  236. * @throws \think\db\exception\DbException
  237. * @throws \think\db\exception\ModelNotFoundException
  238. */
  239. public function order_red_list()
  240. {
  241. [$page, $limit] = $this->getPage();
  242. $where = $this->request->params(['status', 'date']);
  243. // $where['mer_id'] = $this->request->merId();
  244. $query = Db::name('enterprise_red_order_voucher')->when(isset($where['date']) && $where['date'] !== '', function ($query) use ($where) {
  245. getModelTime($query, $where['date']);
  246. })->when(isset($where['status']) && $where['status'] !== '', function ($query) use ($where) {
  247. $query->where('status',$where['status']);
  248. });
  249. $data['count'] = $query->count();
  250. $data['list'] = $query->page($page, $limit)->order('id desc')->select();
  251. return app('json')->success('ok', $data);
  252. }
  253. /**
  254. * 养老金提交打款凭证 审核
  255. * @return mixed
  256. * @throws \think\db\exception\DataNotFoundException
  257. * @throws \think\db\exception\DbException
  258. * @throws \think\db\exception\ModelNotFoundException
  259. */
  260. public function order_red_status()
  261. {
  262. $post= $this->request->params(['id', 'status', 'refund_message']);
  263. $voucher=Db::name('enterprise_red_order_voucher')->find($post['id']);
  264. if(!$voucher){
  265. return app('json')->fail('订单信息错误');
  266. }
  267. if($voucher['status']!=0){
  268. return app('json')->fail('请勿重复操作');
  269. }
  270. if($post['status']==2){
  271. $update['status']=2;
  272. $update['refund_message']=$post['refund_message'];
  273. if($post['refund_message']==''){
  274. return app('json')->fail('请输入不通过原因');
  275. }
  276. $is_red_ylj=0;
  277. }else{
  278. $update['status']=1;
  279. $is_red_ylj=2;
  280. }
  281. $update['status_time']=date('Y-m-d H:i:s');
  282. $re=Db::name('enterprise_red_order_voucher')->where('id',$post['id'])->update($update);
  283. Db::name('store_order')->whereIn('order_id',$voucher['order_ids'])->where('is_red_ylj',1)->update(['is_red_ylj'=>$is_red_ylj]);
  284. $where['o.paid'] = 1;
  285. // $where['o.pay_type'] = 5;
  286. $where['u.commission_type'] = 5;
  287. $where['u.gzc'] = 3;
  288. $where['u.status'] = 0;
  289. $bill_id = Db::name('store_order')
  290. ->alias('o')
  291. ->join('user_bill u', 'u.order_sn=o.order_sn')
  292. ->where($where)
  293. ->whereIN('o.pay_type',[0,5])
  294. ->whereIn('o.order_id', $voucher['order_ids'])
  295. ->column('u.bill_id');
  296. Db::name('user_bill')->whereIn('bill_id',$bill_id)->update(['status'=>1,'gzc'=>0]);
  297. if($re){
  298. return app('json')->success('操作成功');
  299. }
  300. return app('json')->fail('操作失败');
  301. }
  302. /**
  303. * 撤回订单,并撤回订单奖励
  304. */
  305. public function killOrderRewards(){
  306. $group_order_id = request()->param('group_order_id');
  307. $order_id = request()->param('order_id');
  308. $uid = request()->param('uid');
  309. $adminId = $this->request->adminId();
  310. if (empty($order_id) || empty($group_order_id) || empty($uid)) {
  311. return app('json')->fail('参数缺失');
  312. }
  313. if (!in_array($adminId, [1,28,29])) {//超级管理员,财务,老总
  314. return app('json')->fail('后台权限不足');
  315. }
  316. $ok = $this->repository->useKillOrderRewards($group_order_id, $order_id, $uid,$adminId);
  317. if (!$ok) {
  318. return app('json')->fail('操作失败');
  319. }
  320. return app('json')->success('操作成功');
  321. // try {
  322. // Db::startTrans();
  323. // //查找是否有推荐人
  324. // $spreadUid = Db::name('user')->where('uid', $uid)->value('spread_uid');
  325. // //取出pv
  326. // $pv = $this->getValue('user_pv_log', [['order_id', '=', $order_id], ['status', '=', 1],], 'pv');
  327. // //取出 vr
  328. // $payVr = $this->getValue('user_sign_vr', [['order_id', '=', $order_id], ['type', '=', 2],], 'number');
  329. // //取出购买赠送积分 / 支出积分
  330. // $score = $this->getValue('user_sign_score', [['order_id', '=', $order_id], ['status', '=', 1], ['source_type', '=', 3], ['uid', '=', $uid], ['pm', '=', 1],], 'reward_socre');
  331. // $payScore = $this->getValue('user_sign_score', [['order_id', '=', $order_id], ['status', '=', 1], ['pm', '=', 2], ['uid', '=', $uid],], 'reward_socre');
  332. // // 贡献值
  333. // $gongXian = $this->getValue('user_sign_gongxian', [['order_id', '=', $order_id], ['status', '=', 1], ['type', '=', 1], ['uid', '=', $uid],], 'number');
  334. // // 养老金
  335. // $yangLaoJin = $this->getValue('user_bill', [['link_id', '=', $order_id], ['status', '=', 1], ['pm', '=', 1], ['uid', '=', $uid],], 'number');
  336. // if($spreadUid){ //如果有推荐人就执行
  337. // $spreadScore = 0;
  338. // $spreadGongXian = 0;
  339. // $spreadYlj = 0;
  340. // $spreadYongJin = 0;
  341. // $spreadScore = $this->getValue('user_sign_score', [['order_id', '=', $order_id], ['uid', '=', $spreadUid], ['status', '=', 1],], 'reward_socre');
  342. // $spreadGongXian = $this->getValue('user_sign_gongxian', [['order_id', '=', $order_id], ['status', '=', 1], ['type', '=', 1], ['uid', '=', $spreadUid],], 'number');
  343. // $spreadYlj = $this->getValue('user_bill', [['link_id', '=', $order_id], ['commission_type', '=', 5], ['uid', '=', $spreadUid],], 'number'); //推荐获得养老金
  344. // $spreadYongJin = $this->getValue('user_bill', [['link_id', '=', $order_id], ['commission_type', '=', 3], ['uid', '=', $spreadUid],], 'number'); //推荐获得佣金
  345. // $spreadUser = Db::name('user')->where('uid', $spreadUid)->find();
  346. // Db::name('backup_user')->insert($spreadUser); //插入备份表
  347. // Db::name('user')->where('uid', $spreadUid) //更新数据
  348. // ->update([
  349. // 'score' => Db::raw("score - {$spreadScore}"),
  350. // 'per_contribute' => Db::raw("per_contribute - {$spreadGongXian}"),
  351. // 'brokerage_price' => Db::raw("brokerage_price - {$spreadYongJin}"),
  352. // 'annuity' => Db::raw("annuity - {$spreadYlj}"),
  353. // ]);
  354. // $userhjm1 =[
  355. // 'uid' => $spreadUid,
  356. // 'order_id' => $order_id,
  357. // 'score' => $spreadScore??0,
  358. // 'per_contribute' => $spreadGongXian??0,
  359. // 'brokerage_price' => $spreadYongJin??0,
  360. // 'user' => 2,
  361. // ];
  362. // Db::name('backup_user_change')->insert($userhjm1); //插入更新数据记录表
  363. // }
  364. // //扫吗消费
  365. // $smSpreadUid = $this->getValue('user_sign_score', [['order_id', '=', $order_id], ['mark','like','%扫码%'], ['status', '=', 1],], 'uid');
  366. // $smSpreadScore = $this->getValue('user_sign_score', [['order_id', '=', $order_id], ['uid','=',$smSpreadUid], ['status', '=', 1],], 'reward_socre');
  367. // //第二推荐
  368. // $spreadYongJinTwoUid = $this->getValue('user_bill', [['link_id', '=', $order_id], ['commission_type', '=', 3], ['uid', 'not in', [$uid, $spreadUid]],], 'uid');
  369. // $spreadYongJinTwo = $this->getValue('user_bill', [['link_id', '=', $order_id], ['commission_type', '=', 3], ['uid', '=', $spreadYongJinTwoUid],], 'number');
  370. // //更新购买用户的user表
  371. // $uscore = $payScore - $score;
  372. // $user = Db::name('user')->where('uid', $uid)->find();
  373. // Db::name('backup_user')->insert($user);
  374. // Db::name('user')->where('uid', $uid)
  375. // ->update([
  376. // 'pv' => Db::raw("pv - {$pv}"),
  377. // 'vr' => Db::raw("vr + {$payVr}"),
  378. // 'score' => Db::raw("score + {$uscore}"),
  379. // 'contribute' => Db::raw("contribute - {$gongXian}"),
  380. // 'annuity' => Db::raw("annuity - {$yangLaoJin}"),
  381. // ]);
  382. // $userhjm =[
  383. // 'uid' => $uid,
  384. // 'order_id' => $order_id,
  385. // 'pv' => $pv??0,
  386. // 'vr' => $payVr??0,
  387. // 'score' => $uscore??0,
  388. // 'contribute' => $gongXian??0,
  389. // 'annuity' => $yangLaoJin??0,
  390. // 'user' => 1,
  391. // ];
  392. // Db::name('backup_user_change')->insert($userhjm);//具体修改插入对应表
  393. // //第二推荐
  394. // if($spreadYongJinTwoUid) {
  395. // $spreadUserTwo = Db::name('user')->where('uid', $spreadYongJinTwoUid)->find();
  396. // Db::name('backup_user')->insert($spreadUserTwo);
  397. // Db::name('user')->where('uid', $spreadYongJinTwoUid)->dec('brokerage_price', $spreadYongJinTwo)->update();
  398. // $userhjm2 =[
  399. // 'uid' => $spreadYongJinTwoUid,
  400. // 'order_id' => $order_id,
  401. // 'brokerage_price' => $spreadYongJinTwo??0,
  402. // 'user' => 3,
  403. // ];
  404. // Db::name('backup_user_change')->insert($userhjm2);
  405. // }//扫码消费
  406. // if($smSpreadUid){
  407. // $smUserTwo = Db::name('user')->where('uid', $smSpreadUid)->find();
  408. // Db::name('backup_user')->insert($smUserTwo);
  409. // Db::name('user')->where('uid', $smSpreadUid)->dec('score', $smSpreadScore)->update();
  410. // $userhjm3 =[
  411. // 'uid' => $smSpreadUid,
  412. // 'order_id' => $order_id,
  413. // 'score' => $smSpreadScore??0,
  414. // 'user' => 4,
  415. // ];
  416. // Db::name('backup_user_change')->insert($userhjm3);
  417. // }
  418. // // 删除订单相关表p;
  419. // $this->backupAndDelete('store_order', ['group_order_id' => $group_order_id]);
  420. // $this->backupAndDelete('store_group_order', ['group_order_id' => $group_order_id]);
  421. // $this->backupAndDelete('user_pv_log', ['order_id' => $order_id]);
  422. // $this->backupAndDelete('user_sign_vr', ['order_id' => $order_id]);
  423. // $this->backupAndDelete('user_sign_score', ['order_id' => $order_id]);
  424. // $this->backupAndDelete('user_sign_gongxian', ['order_id' => $order_id]);
  425. // $this->backupAndDelete('user_bill', ['link_id' => $order_id]);
  426. // $this->backupAndDelete('gzc_logs', ['link_id' => $order_id]);
  427. // Db::commit();
  428. // } catch (\Exception $e) {
  429. // Db::rollback();
  430. // return app('json')->fail('操作失败'. $e->getMessage());
  431. // }
  432. // Db::name("user_order_kill_records")->insert([//记录哪位管理员撤销的订单
  433. // 'operation_id' => $adminId,
  434. // 'uid' => $uid,
  435. // 'order_id' => $order_id,
  436. // 'mark' => '后台管理员撤销订单记录'
  437. // ]);
  438. // return app('json')->success('操作成功');
  439. }
  440. //
  441. // private function backupAndDelete($table, array $where)//备份并删除
  442. // {
  443. // $backupTable = 'backup_' . $table;
  444. // $rows = Db::name($table)->where($where)->select()->toArray();
  445. // if ($rows) {
  446. // Db::name($backupTable)->insertAll($rows);
  447. // Db::name($table)->where($where)->delete();
  448. // }
  449. // }
  450. // private function getValue($table, array $where, string $field, $default = 0)//查找
  451. // {
  452. // $value = Db::name($table)->where($where)->value($field);
  453. // return $value ?? $default;
  454. // }
  455. /**
  456. * 展示撤回订单列表,恢复订单
  457. */
  458. public function killOrderLst() //撤回订单的列表
  459. {
  460. // $query = Db::name('backup_store_order')->paginate(20)->toArray();
  461. // return app('json')->success($query, '获取成功');
  462. $list = $this->repository->getKillOrderList();
  463. return app('json')->success($list, '获取成功');
  464. }
  465. public function easterKillOrder(){ //恢复订单
  466. $group_order_id = request()->param('group_order_id');
  467. $order_id = request()->param('order_id');
  468. if (empty($order_id) || empty($group_order_id)) {
  469. return app('json')->fail('参数缺失');
  470. }
  471. $ok = $this->repository->recoverOrderByAdmin($group_order_id, $order_id);
  472. if (!$ok) {
  473. return app('json')->fail('操作失败');
  474. }
  475. return app('json')->success('操作成功');
  476. // try {
  477. // Db::startTrans();
  478. // // 恢复订单相关表
  479. // $this->easterOrder('store_order', ['group_order_id' => $group_order_id]);
  480. // $this->easterOrder('store_group_order', ['group_order_id' => $group_order_id]);
  481. // // 恢复 pv
  482. // $this->easterOrder('user_pv_log', ['order_id' => $order_id]);
  483. // // 恢复 vr
  484. // $this->easterOrder('user_sign_vr', ['order_id' => $order_id]);
  485. // // 恢复 积分
  486. // $this->easterOrder('user_sign_score', ['order_id' => $order_id]);
  487. // // 恢复 贡献值
  488. // $this->easterOrder('user_sign_gongxian', ['order_id' => $order_id]);
  489. // // 恢复 佣金/养老金等
  490. // $this->easterOrder('user_bill', ['link_id' => $order_id]);
  491. // // 恢复 公证处
  492. // $this->easterOrder('gzc_logs', ['link_id' => $order_id]);
  493. // //恢复用户奖励
  494. // $this->easterUserAward(['order_id' => $order_id]);
  495. // Db::commit();
  496. // } catch (\Exception $e) {
  497. // Db::rollback();
  498. // return app('json')->fail('撤回失败: '.$e->getMessage());
  499. // }
  500. // Db::name("user_order_recover_records")->insert([//记录恢复的订单
  501. // 'operation_id' => $adminId,
  502. // 'order_id' => $order_id,
  503. // 'mark' => '恢复订单记录'
  504. // ]);
  505. // return app('json')->success('撤回成功');
  506. }
  507. // private function easterOrder($table, array $where) //恢复表数据
  508. // {
  509. // $backupTable = 'backup_' . $table;
  510. // $rows = Db::name($backupTable)->where($where)->select()->toArray();
  511. //
  512. // if ($rows) {
  513. // foreach ($rows as &$row) {
  514. // if (isset($row['del_time'])) unset($row['del_time']);
  515. // }
  516. // unset($row);
  517. // Db::name($table)->insertAll($rows);
  518. // Db::name($backupTable)->where($where)->delete();
  519. // }
  520. // }
  521. // private function easterUserAward(array $where){ //恢复奖励
  522. // $row = Db::name('backup_user_change')->where($where)->where('user', 1)->field('pv, vr, score, contribute, annuity,uid')->find();
  523. // $uid = $row['uid'];
  524. // $pv = $row['pv'];
  525. // $vr = $row['vr'];
  526. // $score= $row['score'];
  527. // $contribute = $row['contribute'];
  528. // $annuity = $row['annuity'];
  529. // Db::name('user') //更新订单用户
  530. // ->where('uid', $uid)
  531. // ->update([
  532. // 'pv' => Db::raw("pv + {$pv}"),
  533. // 'vr' => Db::raw("vr - {$vr}"),
  534. // 'score' => Db::raw("score - {$score}"),
  535. // 'contribute' => Db::raw("contribute + {$contribute}"),
  536. // 'annuity' => Db::raw("annuity + {$annuity}"),
  537. // ]);
  538. // $row2 = Db::name('backup_user_change')->where($where)->where('user', 2)->field('brokerage_price, score, per_contribute, annuity,uid')->find();
  539. // if ($row2) {
  540. // $spreadUid = $row2['uid'];
  541. // $spreadScore = $row2['score'];
  542. // $per_contribute = $row2['per_contribute'];
  543. // $spreadAnnuity = $row2['annuity'];
  544. // $spreadYongJin = $row2['brokerage_price'];
  545. // Db::name('user') //更新推荐人
  546. // ->where('uid', $spreadUid)
  547. // ->update([
  548. // 'score' => Db::raw("score + {$spreadScore}"),
  549. // 'contribute' => Db::raw("contribute + {$per_contribute}"),
  550. // 'annuity' => Db::raw("annuity + {$spreadAnnuity}"),
  551. // 'brokerage_price' => Db::raw("brokerage_price + {$spreadYongJin}"),
  552. // 'per_contribute'=> Db::raw("per_contribute + {$per_contribute}"),
  553. // ]);
  554. // }
  555. // $row3 = Db::name('backup_user_change')->where($where)->where('user', 3)->field('brokerage_price,uid')->find();
  556. // if ($row3) {
  557. // $spreadUidTwo = $row3['uid']; //第二推荐人
  558. // $spreadYongJin2 = $row3['brokerage_price'];
  559. // Db::name('user')
  560. // ->where('uid', $spreadUidTwo)
  561. // ->update([
  562. // 'brokerage_price' => Db::raw("brokerage_price + {$spreadYongJin2}"),
  563. // ]);
  564. // }
  565. // $row4 = Db::name('backup_user_change')->where($where)->where('user', 4)->field('score,uid')->find();
  566. // if ($row4) {
  567. // $spreadUidThree = $row4['uid']; //扫码
  568. // $spreadScore3 = $row4['score'];
  569. // Db::name('user')
  570. // ->where('uid', $spreadUidThree)
  571. // ->update([
  572. // 'score' => Db::raw("score + {$spreadScore3}"),
  573. // ]);
  574. // }
  575. // }
  576. }