Placeorder.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  1. <?php
  2. namespace app\admin\controller\store;
  3. use app\admin\controller\AuthController;
  4. use app\admin\model\order\StoreOrder as StoreOrderModel;
  5. use app\admin\model\order\StoreOrderStatus;
  6. use app\admin\model\system\ShippingTemplates;
  7. use app\admin\model\system\SystemStore;
  8. use app\models\store\StoreBargainUser;
  9. use app\models\store\StoreBargainUserHelp;
  10. use app\models\store\StoreCart;
  11. use app\models\store\StoreCouponUser;
  12. use app\models\store\StoreOrder;
  13. use app\models\store\StorePink;
  14. use app\models\system\CardInfo;
  15. use app\models\system\SystemStoreMember;
  16. use app\models\system\SystemStoreStock;
  17. use app\models\user\User;
  18. use app\models\user\UserAddress;
  19. use app\models\user\UserLevel;
  20. use app\Request;
  21. use crmeb\repositories\OrderRepository;
  22. use think\facade\Route as Url;
  23. use crmeb\services\{FormBuilder, UtilService as Util, JsonService as Json, UtilService};
  24. use app\admin\model\store\StoreProductAttrValue;
  25. /**
  26. *
  27. * Class Placeorder
  28. * @package app\admin\controller\store
  29. */
  30. class Placeorder extends AuthController
  31. {
  32. /**
  33. * 购物车 列表
  34. * @param Request $request
  35. * @return mixed
  36. */
  37. public function lst()
  38. {
  39. return app('json')->successful(StoreCart::getUserProductCartList($this->request->get('uid')));
  40. }
  41. /**
  42. * 下单
  43. * @return string
  44. * @throws \think\db\exception\DataNotFoundException
  45. * @throws \think\db\exception\DbException
  46. * @throws \think\db\exception\ModelNotFoundException
  47. */
  48. public function index()
  49. {
  50. $store = [];
  51. if ($this->adminInfo['type'] == 0) {
  52. $store = SystemStore::where('is_del', 0)->where('is_show', 1)->field('id,name')->select()->toArray();
  53. } else {
  54. $store = SystemStore::where('id', $this->adminInfo['store_id'])->field('id,name')->select();
  55. }
  56. $this->assign('store', $store);
  57. $this->assign('type', $this->adminInfo['type']);
  58. return $this->fetch();
  59. }
  60. /**
  61. * 获取会员卡
  62. * @param $card_no
  63. */
  64. public function getCardNo($card_no)
  65. {
  66. if ($card_no == '') return app('json')->fail('会员码不能为空');
  67. if (intval($card_no) == 1) {
  68. $info['user'] = User::where('uid', $card_no)->field("uid,real_name,addres , phone, '' as nickname, now_money,integral")->find();
  69. $info['uid'] = $info['user']['uid'];
  70. return app('json')->successful($info);
  71. }
  72. if (strlen($card_no) == 15) {
  73. $info = CardInfo::where(['type' => 1, 'card_number' => $card_no])->find();
  74. if (!$info) return app('json')->fail('充值卡号不存在');
  75. if ($info['use_uid'] == 0) return app('json')->fail('充值卡未激活');
  76. $info['user'] = User::where('uid', $info['use_uid'])->field('uid,real_name,addres,phone,nickname,now_money,integral')->find();
  77. $info['uid'] = $info['user']['uid'];
  78. return app('json')->successful($info);
  79. }
  80. if (strlen($card_no) == 8 || strlen($card_no) == 11) {
  81. if (!User::where('SN|phone', $card_no)->find()) return app('json')->fail('会员码不存在');
  82. $info['user'] = User::where('SN|phone', $card_no)->field('uid,real_name,addres,phone,nickname,now_money,integral')->find();
  83. $info['uid'] = $info['user']['uid'];
  84. } else {
  85. if (!SystemStoreMember::be(['card_no' => $card_no])) return app('json')->fail('会员码不存在');
  86. $info = SystemStoreMember::where('card_no', $card_no)->find()->toArray();
  87. $info['user'] = User::where('uid', $info['uid'])->field('real_name,addres,phone,nickname,now_money,integral')->find();
  88. }
  89. return app('json')->successful($info);
  90. }
  91. /**
  92. * 获取条形码商品
  93. * @param string $bar_code
  94. * @return array|void
  95. * @throws \think\db\exception\DataNotFoundException
  96. * @throws \think\db\exception\DbException
  97. * @throws \think\db\exception\ModelNotFoundException
  98. */
  99. public function getBarCode($bar_code = '')
  100. {
  101. if ($bar_code == '') return $this->failed('条形码不存在');
  102. $info = SystemStoreStock::alias('a')->join("StoreProduct b", "a.product_id=b.id", "left")->where('a.bar_code', $bar_code)->field('a.price,a.unique,a.in_stock,a.is_consumer,a.product_id,b.store_name,b.image')->find();
  103. if ($info) {
  104. $info = $info->toArray();
  105. $info['suk'] = StoreProductAttrValue::where('unique', $info['unique'])->value('suk');
  106. } else {
  107. $info = StoreProductAttrValue::alias('a')->join("StoreProduct b", "a.product_id=b.id", "left")->where('a.bar_code', $bar_code)->where('a.type', 0)->field('a.price,a.unique,0 as in_stock,b.is_consumer,a.product_id,b.store_name,b.image')->find();
  108. if ($info) {
  109. $info = $info->toArray();
  110. } else {
  111. $info = [];
  112. }
  113. }
  114. return app('json')->successful($info);
  115. }
  116. /**
  117. * 增加购物车
  118. * @param $data
  119. * @return mixed
  120. * @throws \think\db\exception\DataNotFoundException
  121. * @throws \think\db\exception\ModelNotFoundException
  122. */
  123. public function add_cart()
  124. {
  125. list($productId, $cartNum, $uniqueId, $combinationId, $secKillId, $bargainId, $new, $uid) = UtilService::postMore([
  126. ['productId', 0],//普通产品编号
  127. ['cartNum', 1], //购物车数量
  128. ['uniqueId', ''],//属性唯一值
  129. ['combinationId', 0],//拼团产品编号
  130. ['secKillId', 0],//秒杀产品编号
  131. ['bargainId', 0],//砍价产品编号
  132. ['new', 1], // 1 加入购物车直接购买 0 加入购物车
  133. ['uid', 0],//用户编号
  134. ], $this->request, true);
  135. $request = $this->request;
  136. if (!$productId || !is_numeric($productId)) return app('json')->fail('参数错误');
  137. if ($bargainId && StoreBargainUserHelp::getSurplusPrice($bargainId, $uid)) return app('json')->fail('请先砍价');
  138. $res = StoreCart::setCart($uid, $productId, $cartNum, $uniqueId, 'product', $new, $combinationId, $secKillId, $bargainId);
  139. if (!$res) return app('json')->fail(StoreCart::getErrorInfo());
  140. else return app('json')->successful('ok', ['cartId' => $res->id]);
  141. }
  142. /**
  143. * 清空购物车
  144. * @return mixed
  145. * @throws \Exception
  146. */
  147. public function clear_cart()
  148. {
  149. list($uid) = UtilService::postMore([
  150. ['uid', 0],//用户编号
  151. ], $this->request, true);
  152. $is_pay = 0;
  153. StoreCart::where(compact('uid', 'is_pay'))->delete();
  154. return app('json')->successful('清空完成!');
  155. }
  156. /**
  157. * 购物车 删除产品
  158. * @param Request $request
  159. * @return mixed
  160. */
  161. public function del(Request $request)
  162. {
  163. list($ids, $uid) = UtilService::postMore([
  164. ['ids', []],//购物车编号
  165. ['uid', 0],
  166. ], $request, true);
  167. if (!count($ids))
  168. return app('json')->fail('参数错误!');
  169. if (StoreCart::removeUserCart($uid, $ids))
  170. return app('json')->successful();
  171. return app('json')->fail('清除失败!');
  172. }
  173. /**
  174. * 购物车 修改产品数量
  175. * @param Request $request
  176. * @return mixed
  177. * @throws \think\Exception
  178. * @throws \think\db\exception\DataNotFoundException
  179. * @throws \think\db\exception\ModelNotFoundException
  180. * @throws \think\exception\DbException
  181. */
  182. public function num(Request $request)
  183. {
  184. list($id, $number, $uid) = UtilService::postMore([
  185. ['id', 0],//购物车编号
  186. ['number', 0],//购物车编号
  187. ['uid', 0],
  188. ], $request, true);
  189. if (!$id || !$number || !is_numeric($id) || !is_numeric($number)) return app('json')->fail('参数错误!');
  190. $res = StoreCart::changeUserCartNum($id, $number, $uid);
  191. if ($res) return app('json')->successful();
  192. else return app('json')->fail(StoreCart::getErrorInfo('修改失败'));
  193. }
  194. /**
  195. * 订单确认
  196. * @return mixed
  197. * @throws \Psr\SimpleCache\InvalidArgumentException
  198. * @throws \think\db\exception\DataNotFoundException
  199. * @throws \think\db\exception\DbException
  200. * @throws \think\db\exception\ModelNotFoundException
  201. */
  202. public function confirm()
  203. {
  204. $request = $this->request;
  205. $temp = ShippingTemplates::get(1);
  206. if (!$temp) return app('json')->fail('默认模板未配置,无法下单');
  207. list($cartId) = UtilService::postMore(['cartId'], $request, true);
  208. if (!is_string($cartId) || !$cartId) return app('json')->fail('请提交购买的商品');
  209. $uid = input('uid', 0);
  210. $cartGroup = StoreCart::getUserProductCartList($uid, $cartId, 1);
  211. if (count($cartGroup['invalid'])) return app('json')->fail($cartGroup['invalid'][0]['productInfo']['store_name'] . '已失效!');
  212. if (!$cartGroup['valid']) return app('json')->fail('请提交购买的商品');
  213. $cartInfo = $cartGroup['valid'];
  214. $addr = UserAddress::where('uid', $uid)->where('is_default', 1)->find();
  215. $priceGroup = StoreOrder::getOrderPriceGroup($cartInfo, $addr);
  216. if ($priceGroup === false) {
  217. return app('json')->fail(StoreOrder::getErrorInfo('运费模板不存在'));
  218. }
  219. $other = [
  220. 'offlinePostage' => sys_config('offline_postage'),
  221. 'integralRatio' => sys_config('integral_ratio')
  222. ];
  223. $usableCoupons = StoreCouponUser::getUsableCouponList($uid, $cartGroup, $priceGroup['totalPrice']);
  224. $usableCoupon = isset($usableCoupons[0]) ? $usableCoupons[0] : null;
  225. $cartIdA = explode(',', $cartId);
  226. $seckill_id = 0;
  227. $combination_id = 0;
  228. $bargain_id = 0;
  229. if (count($cartIdA) == 1) {
  230. $seckill_id = StoreCart::where('id', $cartId)->value('seckill_id');
  231. $combination_id = StoreCart::where('id', $cartId)->value('combination_id');
  232. $bargain_id = StoreCart::where('id', $cartId)->value('bargain_id');
  233. }
  234. $data['deduction'] = $seckill_id || $combination_id || $bargain_id;
  235. $data['usableCoupon'] = $usableCoupon;
  236. $data['addressInfo'] = UserAddress::getUserDefaultAddress($uid);
  237. $data['seckill_id'] = $seckill_id;
  238. $data['combination_id'] = $combination_id;
  239. $data['bargain_id'] = $bargain_id;
  240. $data['cartInfo'] = $cartInfo;
  241. $data['priceGroup'] = $priceGroup;
  242. $data['orderKey'] = StoreOrder::cacheOrderInfo($uid, $cartInfo, $priceGroup, $other);
  243. $data['offlinePostage'] = $other['offlinePostage'];
  244. $vipId = UserLevel::getUserLevel($uid);
  245. $user = User::find($uid);
  246. if (isset($user['pwd'])) unset($user['pwd']);
  247. $user['vip'] = $vipId !== false ? true : false;
  248. if ($user['vip']) {
  249. $user['vip_id'] = $vipId;
  250. $user['discount'] = UserLevel::getUserLevelInfo($vipId, 'discount');
  251. }
  252. $data['userInfo'] = $user;
  253. $data['integralRatio'] = $other['integralRatio'];
  254. $data['offline_pay_status'] = (int)sys_config('offline_pay_status') ?? (int)2;
  255. $data['store_self_mention'] = (int)sys_config('store_self_mention') ?? 0;//门店自提是否开启
  256. $data['system_store'] = ($res = \app\models\system\SystemStore::getStoreDispose()) ? $res : [];//门店信息
  257. return app('json')->successful($data);
  258. }
  259. /**
  260. * 计算订单金额
  261. * @param Request $request
  262. * @param $key
  263. * @return mixed
  264. * @throws \think\Exception
  265. * @throws \think\db\exception\DataNotFoundException
  266. * @throws \think\db\exception\ModelNotFoundException
  267. * @throws \think\exception\DbException
  268. */
  269. public function computedOrder($key)
  270. {
  271. $request = $this->request;
  272. $uid = input('uid', 0);
  273. if (!$key) return app('json')->fail('参数错误!');
  274. if (StoreOrder::be(['order_id|unique' => $key, 'uid' => $uid, 'is_del' => 0]))
  275. return app('json')->status('extend_order', '订单已生成', ['orderId' => $key, 'key' => $key]);
  276. list($addressId, $couponId, $payType, $useIntegral, $mark, $combinationId, $pinkId, $seckill_id, $formId, $bargainId, $shipping_type) = UtilService::postMore([
  277. 'addressId', 'couponId', ['payType', 'yue'], ['useIntegral', 0], 'mark', ['combinationId', 0], ['pinkId', 0], ['seckill_id', 0], ['formId', ''], ['bargainId', ''],
  278. ['shipping_type', 1],
  279. ], $request, true);
  280. $payType = strtolower($payType);
  281. if ($bargainId) {
  282. $bargainUserTableId = StoreBargainUser::getBargainUserTableId($bargainId, $uid);//TODO 获取用户参与砍价表编号
  283. if (!$bargainUserTableId)
  284. return app('json')->fail('砍价失败');
  285. $status = StoreBargainUser::getBargainUserStatusEnd($bargainUserTableId);
  286. if ($status == 3)
  287. return app('json')->fail('砍价已支付');
  288. StoreBargainUser::setBargainUserStatus($bargainId, $uid); //修改砍价状态
  289. }
  290. if ($pinkId) {
  291. $cache_pink = Cache::get(md5('store_pink_' . $pinkId));
  292. if ($cache_pink && bcsub($cache_pink['people'], $cache_pink['now_people'], 0) <= 0) {
  293. return app('json')->status('ORDER_EXIST', '订单生成失败,该团人员已满', ['orderId' => StoreOrder::getStoreIdPink($pinkId, $uid)]);
  294. }
  295. if (StorePink::getIsPinkUid($pinkId, $uid))
  296. return app('json')->status('ORDER_EXIST', '订单生成失败,你已经在该团内不能再参加了', ['orderId' => StoreOrder::getStoreIdPink($pinkId, $uid)]);
  297. if (StoreOrder::getIsOrderPink($pinkId, $uid))
  298. return app('json')->status('ORDER_EXIST', '订单生成失败,你已经参加该团了,请先支付订单', ['orderId' => StoreOrder::getStoreIdPink($pinkId, $uid)]);
  299. }
  300. $priceGroup = StoreOrder::cacheKeyCreateOrder($uid, $key, $addressId, $payType, (int)$useIntegral, $couponId, $mark, $combinationId, $pinkId, $seckill_id, $bargainId, true, 0, $shipping_type);
  301. if ($priceGroup)
  302. return app('json')->status('NONE', 'ok', $priceGroup);
  303. else
  304. return app('json')->fail(StoreOrder::getErrorInfo('计算失败'));
  305. }
  306. /**
  307. * 订单创建
  308. * @param Request $request
  309. * @param $key
  310. * @return mixed
  311. * @throws \think\Exception
  312. * @throws \think\db\exception\DataNotFoundException
  313. * @throws \think\db\exception\ModelNotFoundException
  314. * @throws \think\exception\DbException
  315. */
  316. public function create($key)
  317. {
  318. $request = $this->request;
  319. $uid = input('uid', 0);
  320. if (!$key) return app('json')->fail('参数错误!');
  321. if (StoreOrder::be(['order_id|unique' => $key, 'uid' => $uid, 'is_del' => 0]))
  322. return app('json')->status('extend_order', '订单已生成', ['orderId' => $key, 'key' => $key]);
  323. list($addressId, $couponId, $payType, $useIntegral, $mark, $combinationId, $pinkId, $seckill_id, $formId, $bargainId, $from, $shipping_type, $real_name, $phone, $storeId, $auth_code) = UtilService::postMore([
  324. 'addressId', 'couponId', 'payType', ['useIntegral', 0], 'mark', ['combinationId', 0], ['pinkId', 0], ['seckill_id', 0], ['formId', ''], ['bargainId', ''], ['from', 'weixin'],
  325. ['shipping_type', 1], ['real_name', '散户'], ['phone', '18700010001'], ['store_id', 0], ['auth_code', ''],
  326. ], $request, true);
  327. if (empty($real_name)) $real_name = '散户';
  328. if (empty($phone)) $phone = '18700010001';
  329. $payType = strtolower($payType);
  330. if ($bargainId) {
  331. $bargainUserTableId = StoreBargainUser::getBargainUserTableId($bargainId, $uid);//TODO 获取用户参与砍价表编号
  332. if (!$bargainUserTableId)
  333. return app('json')->fail('砍价失败');
  334. $status = StoreBargainUser::getBargainUserStatusEnd($bargainUserTableId);
  335. if ($status == 3)
  336. return app('json')->fail('砍价已支付');
  337. StoreBargainUser::setBargainUserStatus($bargainId, $uid); //修改砍价状态
  338. }
  339. if ($pinkId) {
  340. $cache_pink = Cache::get(md5('store_pink_' . $pinkId));
  341. if ($cache_pink && bcsub($cache_pink['people'], $cache_pink['now_people'], 0) <= 0) {
  342. return app('json')->status('ORDER_EXIST', '订单生成失败,该团人员已满', ['orderId' => StoreOrder::getStoreIdPink($pinkId, $uid)]);
  343. }
  344. if (StorePink::getIsPinkUid($pinkId, $uid))
  345. return app('json')->status('ORDER_EXIST', '订单生成失败,你已经在该团内不能再参加了', ['orderId' => StoreOrder::getStoreIdPink($pinkId, $uid)]);
  346. if (StoreOrder::getIsOrderPink($pinkId, $uid))
  347. return app('json')->status('ORDER_EXIST', '订单生成失败,你已经参加该团了,请先支付订单', ['orderId' => StoreOrder::getStoreIdPink($pinkId, $uid)]);
  348. }
  349. $isChannel = 1;
  350. if ($from == 'weixin')
  351. $isChannel = 0;
  352. elseif ($from == 'weixinh5')
  353. $isChannel = 2;
  354. $order = StoreOrder::cacheKeyCreateOrder($uid, $key, $addressId, $payType, (int)$useIntegral, $couponId, $mark, $combinationId, $pinkId, $seckill_id, $bargainId, false, $isChannel, $shipping_type, $real_name, $phone, $storeId);
  355. if ($order === false) return app('json')->fail(StoreOrder::getErrorInfo('订单生成失败'));
  356. $orderId = $order['order_id'];
  357. $info = compact('orderId', 'key');
  358. if ($orderId) {
  359. event('OrderCreated', [$order]); //订单创建成功事件
  360. // event('ShortMssageSend', [$orderId, 'AdminPlaceAnOrder']);//发送管理员通知
  361. switch ($payType) {
  362. case "weixin":
  363. $orderInfo = StoreOrder::where('order_id', $orderId)->find();
  364. if (!$orderInfo || !isset($orderInfo['paid'])) return app('json')->fail('支付订单不存在!');
  365. $orderInfo = $orderInfo->toArray();
  366. if ($orderInfo['paid']) return app('json')->fail('支付已支付!');
  367. //支付金额为0
  368. if (bcsub((float)$orderInfo['pay_price'], 0, 2) <= 0) {
  369. //创建订单jspay支付
  370. $payPriceStatus = StoreOrder::jsPayPrice($orderId, $uid, $formId);
  371. if ($payPriceStatus)//0元支付成功
  372. return app('json')->status('success', '微信支付成功', $info);
  373. else
  374. return app('json')->status('pay_error', StoreOrder::getErrorInfo());
  375. } else {
  376. try {
  377. $jsConfig = OrderRepository::barcodePay($orderId, $auth_code); //创建订单jspay
  378. } catch (\Exception $e) {
  379. return app('json')->status('pay_error', $e->getMessage(), $info);
  380. }
  381. $info['jsConfig'] = $jsConfig;
  382. if ($from == 'weixinh5') {
  383. return app('json')->status('wechat_h5_pay', '订单创建成功', $info);
  384. } else {
  385. return app('json')->status('wechat_pay', '订单创建成功', $info);
  386. }
  387. }
  388. break;
  389. case 'yue':
  390. if (StoreOrder::yuePay($orderId, $uid, $formId)) {
  391. $orderInfo = StoreOrder::where('order_id', $orderId)->find();
  392. $this->verify($orderInfo['id']);
  393. return app('json')->status('success', '余额支付成功', $info);
  394. } else {
  395. $errorinfo = StoreOrder::getErrorInfo();
  396. if (is_array($errorinfo))
  397. return app('json')->status($errorinfo['status'], $errorinfo['msg'], $info);
  398. else
  399. return app('json')->status('pay_error', $errorinfo);
  400. }
  401. break;
  402. case 'offline':
  403. $orderInfo = StoreOrder::where('order_id', $orderId)->find();
  404. $this->offline($orderInfo['id']);
  405. $this->verify($orderInfo['id']);
  406. return app('json')->status('success', '订单创建成功', $info);
  407. break;
  408. case 'jialie':
  409. $orderInfo = StoreOrder::where('order_id', $orderId)->find();
  410. if (!$orderInfo || !isset($orderInfo['paid'])) return app('json')->fail('支付订单不存在!');
  411. $orderInfo = $orderInfo->toArray();
  412. if ($orderInfo['paid']) return app('json')->fail('支付已支付!');
  413. $rs = OrderRepository::jialiePay($orderId, $auth_code); //支付结果
  414. if ($rs['ret_code'] == "00" && $rs['status'] == "2") {
  415. $this->verify($orderInfo['id']);
  416. StoreOrder::paySuccess($orderId, 'jialie');
  417. } elseif ($rs['ret_code'] == "00" && $rs['status'] == 1) {
  418. StoreOrder::edit(['jialie_do' => 1], $orderInfo['id']);
  419. } else {
  420. return app('json')->fail($rs['ret_msg']);
  421. }
  422. return app('json')->status('success', '订单创建成功', $info);
  423. break;
  424. }
  425. } else return app('json')->fail(StoreOrder::getErrorInfo('订单生成失败!'));
  426. }
  427. public function verify($id)
  428. {
  429. StoreOrderModel::beginTrans();
  430. $orderInfo = StoreOrderModel::where('id', $id)->find();
  431. if ($orderInfo->combination_id && $orderInfo->pink_id) {
  432. $res = \app\admin\model\ump\StorePink::where('id', $orderInfo->pink_id)->where('status', '<>', 2)->count();
  433. if ($res) return Json::fail('拼团订单暂未成功无法核销!');
  434. }
  435. $orderInfo->status = 2;
  436. if ($orderInfo->save()) {
  437. OrderRepository::storeProductOrderTakeDeliveryAdmin($orderInfo);
  438. StoreOrderStatus::setStatus($orderInfo->id, 'take_delivery', '已核销');
  439. StoreOrderModel::commitTrans();
  440. return true;
  441. } else {
  442. StoreOrderModel::rollbackTrans();
  443. return false;
  444. }
  445. }
  446. /**
  447. * 立即支付
  448. * @param $id
  449. */
  450. public function offline($id)
  451. {
  452. $res = StoreOrderModel::updateOffline($id);
  453. if ($res) {
  454. event('StoreProductOrderOffline', [$id]);
  455. StoreOrderStatus::setStatus($id, 'offline', '线下付款');
  456. return true;
  457. } else {
  458. return false;
  459. }
  460. }
  461. }