StoreOrderController.php 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992
  1. <?php
  2. namespace app\api\controller\order;
  3. use app\admin\model\system\{
  4. SystemAttachment, ShippingTemplates
  5. };
  6. use app\admin\model\user\User;
  7. use app\models\routine\RoutineFormId;
  8. use crmeb\repositories\OrderRepository;
  9. use app\models\store\{
  10. StoreBargainUser,
  11. StoreCart,
  12. StoreCoupon,
  13. StoreCouponIssue,
  14. StoreCouponUser,
  15. StoreOrder,
  16. StoreOrderBatch,
  17. StoreOrderCartInfo,
  18. StoreOrderStatus,
  19. StorePink,
  20. StoreProductReply,
  21. StoreSeckill
  22. };
  23. use app\models\system\SystemStore;
  24. use app\models\user\UserAddress;
  25. use app\models\user\UserLevel;
  26. use app\Request;
  27. use think\facade\Cache;
  28. use crmeb\services\{
  29. CacheService,
  30. ExpressService,
  31. SystemConfigService,
  32. UtilService
  33. };
  34. /**
  35. * 订单类
  36. * Class StoreOrderController
  37. * @package app\api\controller\order
  38. */
  39. class StoreOrderController
  40. {
  41. /**
  42. * 订单确认
  43. * @param Request $request
  44. * @return mixed
  45. */
  46. public function confirm(Request $request)
  47. {
  48. // TODO: 运费模板只能选择 ID 为 1 的模板?
  49. $temp = ShippingTemplates::get(1);
  50. if (!$temp) return app('json')->fail('默认模板未配置,无法下单');
  51. list($cartId) = UtilService::postMore(['cartId'], $request, true);
  52. if (!is_string($cartId) || !$cartId) return app('json')->fail('请提交购买的商品');
  53. // 查询当前购物车有效的商品
  54. $uid = $request->uid();
  55. $cartGroup = StoreCart::getUserProductCartList($uid, $cartId, 1);
  56. if (count($cartGroup['invalid'])) {
  57. return app('json')->fail($cartGroup['invalid'][0]['productInfo']['store_name'] . '已失效!');
  58. }
  59. if (!$cartGroup['valid']) {
  60. return app('json')->fail('请提交购买的商品');
  61. }
  62. //
  63. $cartInfo = $cartGroup['valid'];
  64. $addr = UserAddress::getUserDefaultAddress($uid); //UserAddress::where('uid', $uid)->where('is_default', 1)->find();
  65. // 获取当前购物车中各项价格
  66. $priceGroup = StoreOrder::getOrderPriceGroup($cartInfo, $addr);
  67. if ($priceGroup === false) {
  68. return app('json')->fail(StoreOrder::getErrorInfo('运费模板不存在'));
  69. }
  70. $other = [
  71. 'offlinePostage' => sys_config('offline_postage'), // 线下支付是否包邮
  72. 'integralRatio' => sys_config('integral_ratio') // 积分抵用比例
  73. ];
  74. $usableCoupons = []; // TIP 屏蔽优惠券 StoreCouponUser::getUsableCouponList($uid, $cartGroup, $priceGroup['totalPrice']);
  75. $usableCoupon = isset($usableCoupons[0]) ? $usableCoupons[0] : null;
  76. // $cartIdA = explode(',', $cartId);
  77. $seckill_id = 0;
  78. $combination_id = 0;
  79. $bargain_id = 0;
  80. // TIP 屏蔽三个活动
  81. // if (count($cartIdA) == 1) {
  82. // $seckill_id = StoreCart::where('id', $cartId)->value('seckill_id');
  83. // $combination_id = StoreCart::where('id', $cartId)->value('combination_id');
  84. // $bargain_id = StoreCart::where('id', $cartId)->value('bargain_id');
  85. // }
  86. $data['deduction'] = $seckill_id || $combination_id || $bargain_id;
  87. $data['usableCoupon'] = $usableCoupon;
  88. $data['addressInfo'] = $addr; //UserAddress::getUserDefaultAddress($uid);
  89. $data['seckill_id'] = $seckill_id;
  90. $data['combination_id'] = $combination_id;
  91. $data['bargain_id'] = $bargain_id;
  92. $data['cartInfo'] = $cartInfo;
  93. $data['priceGroup'] = $priceGroup;
  94. $data['orderKey'] = StoreOrder::cacheOrderInfo($uid, $cartInfo, $priceGroup, $other);
  95. $data['offlinePostage'] = $other['offlinePostage'];
  96. $vipId = UserLevel::getUserLevel($uid);
  97. $user = $request->user();
  98. if (isset($user['pwd'])) unset($user['pwd']);
  99. $user['vip'] = $vipId !== false ? true : false;
  100. if ($user['vip']) {
  101. $user['vip_id'] = $vipId;
  102. $user['discount'] = UserLevel::getUserLevelInfo($vipId, 'discount');
  103. }
  104. $data['userInfo'] = $user;
  105. $data['integralRatio'] = $other['integralRatio'];
  106. $data['offline_pay_status'] = (int)sys_config('offline_pay_status') ?? (int)2; // 线下支付
  107. $data['store_self_mention'] = (int)sys_config('store_self_mention') ?? 0;//门店自提是否开启
  108. $data['system_store'] = []; // TIP: 屏蔽门店信息 ($res = SystemStore::getStoreDispose()) ? $res : [];//门店信息
  109. return app('json')->successful($data);
  110. }
  111. /**
  112. * 计算订单金额
  113. * @param Request $request
  114. * @param $key
  115. * @return mixed
  116. * @throws \think\Exception
  117. * @throws \think\db\exception\DataNotFoundException
  118. * @throws \think\db\exception\ModelNotFoundException
  119. * @throws \think\exception\DbException
  120. */
  121. public function computedOrder(Request $request, $key)
  122. {
  123. // $key 就是 confirm 返回的 orderKey
  124. if (!$key) return app('json')->fail('参数错误!');
  125. // 是否已存在
  126. $uid = $request->uid();
  127. if (StoreOrder::be(['order_id|unique' => $key, 'uid' => $uid, 'is_del' => 0]))
  128. return app('json')->status('extend_order', '订单已生成', ['orderId' => $key, 'key' => $key]);
  129. list($addressId, $couponId, $payType, $useIntegral, $mark,
  130. $combinationId, $pinkId, $seckill_id, $formId, $bargainId, $shipping_type) = UtilService::postMore([
  131. 'addressId',
  132. 'couponId',
  133. ['payType', 'yue'],
  134. ['useIntegral', 0],
  135. 'mark',
  136. ['combinationId', 0],
  137. ['pinkId', 0],
  138. ['seckill_id', 0],
  139. ['formId', ''],
  140. ['bargainId', ''],
  141. ['shipping_type', 1],
  142. ], $request, true);
  143. // weixin / yue
  144. $payType = strtolower($payType);
  145. if ($bargainId) {
  146. $bargainUserTableId = StoreBargainUser::getBargainUserTableId($bargainId, $uid);//TODO 获取用户参与砍价表编号
  147. if (!$bargainUserTableId)
  148. return app('json')->fail('砍价失败');
  149. $status = StoreBargainUser::getBargainUserStatusEnd($bargainUserTableId);
  150. if ($status == 3)
  151. return app('json')->fail('砍价已支付');
  152. StoreBargainUser::setBargainUserStatus($bargainId, $uid); //修改砍价状态
  153. }
  154. if ($pinkId) {
  155. $cache_pink = Cache::get(md5('store_pink_' . $pinkId));
  156. if ($cache_pink && bcsub($cache_pink['people'], $cache_pink['now_people'], 0) <= 0) {
  157. return app('json')->status('ORDER_EXIST', '订单生成失败,该团人员已满', ['orderId' => StoreOrder::getStoreIdPink($pinkId, $request->uid())]);
  158. }
  159. if (StorePink::getIsPinkUid($pinkId, $request->uid()))
  160. return app('json')->status('ORDER_EXIST', '订单生成失败,你已经在该团内不能再参加了', ['orderId' => StoreOrder::getStoreIdPink($pinkId, $request->uid())]);
  161. if (StoreOrder::getIsOrderPink($pinkId, $request->uid()))
  162. return app('json')->status('ORDER_EXIST', '订单生成失败,你已经参加该团了,请先支付订单', ['orderId' => StoreOrder::getStoreIdPink($pinkId, $request->uid())]);
  163. }
  164. $priceGroup = StoreOrder::cacheKeyCreateOrder($request->uid(), $key, $addressId, $payType, (int)$useIntegral,
  165. $couponId, $mark, $combinationId, $pinkId, $seckill_id, $bargainId, true, 0, $shipping_type);
  166. // return app('json')->fail(StoreOrder::getErrorInfo('计算失败'));
  167. if ($priceGroup)
  168. return app('json')->status('NONE', 'ok', $priceGroup);
  169. else
  170. return app('json')->fail(StoreOrder::getErrorInfo('计算失败'));
  171. }
  172. /**
  173. * 订单创建
  174. * @param Request $request
  175. * @param $key
  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 create(Request $request, $key)
  183. {
  184. // 还是那个 $orderKey
  185. if (!$key) return app('json')->fail('参数错误!');
  186. // 订单是否已存在
  187. $uid = $request->uid();
  188. if (StoreOrder::be(['order_id|unique' => $key, 'uid' => $uid, 'is_del' => 0]))
  189. return app('json')->status('extend_order', '订单已生成', ['orderId' => $key, 'key' => $key]);
  190. // 获得参数
  191. list($addressId, $couponId, $payType, $useIntegral, $mark, $combinationId, $pinkId, $seckill_id, $formId, $bargainId, $from, $shipping_type, $real_name, $phone, $storeId) = UtilService::postMore([
  192. 'addressId',
  193. 'couponId',
  194. 'payType',
  195. ['useIntegral', 0],
  196. 'mark',
  197. ['combinationId', 0], ['pinkId', 0], ['seckill_id', 0], ['formId', ''], ['bargainId', ''],
  198. ['from', 'weixin'],
  199. ['shipping_type', 1], ['real_name', ''], ['phone', ''], ['store_id', 0]
  200. ], $request, true);
  201. // weixin / yue
  202. $payType = strtolower($payType);
  203. if ($bargainId) {
  204. $bargainUserTableId = StoreBargainUser::getBargainUserTableId($bargainId, $uid);//TODO 获取用户参与砍价表编号
  205. if (!$bargainUserTableId)
  206. return app('json')->fail('砍价失败');
  207. $status = StoreBargainUser::getBargainUserStatusEnd($bargainUserTableId);
  208. if ($status == 3)
  209. return app('json')->fail('砍价已支付');
  210. StoreBargainUser::setBargainUserStatus($bargainId, $uid); //修改砍价状态
  211. }
  212. if ($pinkId) {
  213. $cache_pink = Cache::get(md5('store_pink_' . $pinkId));
  214. if ($cache_pink && bcsub($cache_pink['people'], $cache_pink['now_people'], 0) <= 0) {
  215. return app('json')->status('ORDER_EXIST', '订单生成失败,该团人员已满', ['orderId' => StoreOrder::getStoreIdPink($pinkId, $request->uid())]);
  216. }
  217. if (StorePink::getIsPinkUid($pinkId, $request->uid()))
  218. return app('json')->status('ORDER_EXIST', '订单生成失败,你已经在该团内不能再参加了', ['orderId' => StoreOrder::getStoreIdPink($pinkId, $request->uid())]);
  219. if (StoreOrder::getIsOrderPink($pinkId, $request->uid()))
  220. return app('json')->status('ORDER_EXIST', '订单生成失败,你已经参加该团了,请先支付订单', ['orderId' => StoreOrder::getStoreIdPink($pinkId, $request->uid())]);
  221. }
  222. $isChannel = 1; // 'routine'
  223. if ($from == 'weixin')
  224. $isChannel = 0;
  225. elseif ($from == 'weixinh5')
  226. $isChannel = 2;
  227. elseif ($from == 'app') {
  228. $isChannel = 3;
  229. }
  230. $order = StoreOrder::cacheKeyCreateOrder($request->uid(), $key, $addressId, $payType, (int)$useIntegral,
  231. $couponId, $mark, $combinationId, $pinkId, $seckill_id, $bargainId, false, $isChannel,
  232. $shipping_type, $real_name, $phone, $storeId);
  233. if ($order === false) {
  234. return app('json')->fail(StoreOrder::getErrorInfo('订单生成失败'));
  235. }
  236. $orderId = $order['order_id'];
  237. $info = compact('orderId', 'key');
  238. if ($orderId) {
  239. event('OrderCreated', [$order]); //订单创建成功事件
  240. // event('ShortMssageSend', [$orderId, 'AdminPlaceAnOrder']);//发送管理员通知
  241. switch ($payType) {
  242. case "weixin":
  243. $orderInfo = StoreOrder::where('order_id', $orderId)->find();
  244. if (!$orderInfo || !isset($orderInfo['paid'])) return app('json')->fail('支付订单不存在!');
  245. $orderInfo = $orderInfo->toArray();
  246. if ($orderInfo['paid']) return app('json')->fail('支付已支付!');
  247. //支付金额为0
  248. if (bcsub((float)$orderInfo['pay_price'], 0, 2) <= 0) {
  249. //创建订单jspay支付
  250. $payPriceStatus = StoreOrder::jsPayPrice($orderId, $uid, $formId);
  251. if ($payPriceStatus)//0元支付成功
  252. return app('json')->status('success', '微信支付成功', $info);
  253. else
  254. return app('json')->status('pay_error', StoreOrder::getErrorInfo());
  255. } else {
  256. try {
  257. if ($from == 'routine') {
  258. $jsConfig = OrderRepository::jsPay($orderId); //创建订单jspay
  259. } else if ($from == 'weixinh5') {
  260. $jsConfig = OrderRepository::h5Pay($orderId);
  261. } else if ($from == 'app') {
  262. $jsConfig = OrderRepository::wxAppPay($orderId);
  263. } else {
  264. $jsConfig = OrderRepository::wxPay($orderId);
  265. }
  266. } catch (\Exception $e) {
  267. return app('json')->status('pay_error', $e->getMessage(), $info);
  268. }
  269. $info['jsConfig'] = $jsConfig;
  270. return app('json')->status($payType . '_' . $from, '订单创建成功', $info);
  271. // if ($from == 'weixinh5') {
  272. // return app('json')->status('wechat_h5_pay', '订单创建成功', $info);
  273. // } elseif ($from == 'app') {
  274. // return app('json')->status('wechat_app_pay', '订单创建成功', $info);
  275. // } else {
  276. // return app('json')->status('wechat_pay', '订单创建成功', $info);
  277. // }
  278. }
  279. break;
  280. case 'yue':
  281. if (StoreOrder::yuePay($orderId, $request->uid(), $formId))
  282. return app('json')->status('success', '余额支付成功', $info);
  283. else {
  284. $errorinfo = StoreOrder::getErrorInfo();
  285. if (is_array($errorinfo))
  286. return app('json')->status($errorinfo['status'], $errorinfo['msg'], $info);
  287. else
  288. return app('json')->status('pay_error', $errorinfo);
  289. }
  290. break;
  291. case 'offline':
  292. return app('json')->status('success', '订单创建成功', $info);
  293. break;
  294. }
  295. } else { // !$orderId
  296. return app('json')->fail(StoreOrder::getErrorInfo('订单生成失败!'));
  297. }
  298. }
  299. /**
  300. * 计算订单金额
  301. * @param Request $request
  302. * @param $key
  303. * @return mixed
  304. * @throws \think\Exception
  305. * @throws \think\db\exception\DataNotFoundException
  306. * @throws \think\db\exception\ModelNotFoundException
  307. * @throws \think\exception\DbException
  308. */
  309. public function computedOrder_v2(Request $request, $key)
  310. {
  311. // $key 就是 confirm 返回的 orderKey
  312. if (!$key) return app('json')->fail('参数错误!');
  313. // 是否已存在
  314. $uid = $request->uid();
  315. if (StoreOrderBatch::be(['unique' => $key, 'uid' => $uid]))
  316. return app('json')->status('extend_order', '订单已生成', ['orderId' => $key, 'key' => $key]);
  317. list($addressId, $couponId, $payType, $useIntegral, $mark,
  318. $combinationId, $pinkId, $seckill_id, $formId, $bargainId, $shipping_type) = UtilService::postMore([
  319. 'addressId',
  320. 'couponId',
  321. ['payType', 'yue'],
  322. ['useIntegral', 0],
  323. 'mark',
  324. ['combinationId', 0],
  325. ['pinkId', 0],
  326. ['seckill_id', 0],
  327. ['formId', ''],
  328. ['bargainId', ''],
  329. ['shipping_type', 1],
  330. ], $request, true);
  331. // weixin / yue
  332. $payType = strtolower($payType);
  333. if ($bargainId) {
  334. $bargainUserTableId = StoreBargainUser::getBargainUserTableId($bargainId, $uid);//TODO 获取用户参与砍价表编号
  335. if (!$bargainUserTableId)
  336. return app('json')->fail('砍价失败');
  337. $status = StoreBargainUser::getBargainUserStatusEnd($bargainUserTableId);
  338. if ($status == 3)
  339. return app('json')->fail('砍价已支付');
  340. StoreBargainUser::setBargainUserStatus($bargainId, $uid); //修改砍价状态
  341. }
  342. if ($pinkId) {
  343. $cache_pink = Cache::get(md5('store_pink_' . $pinkId));
  344. if ($cache_pink && bcsub($cache_pink['people'], $cache_pink['now_people'], 0) <= 0) {
  345. return app('json')->status('ORDER_EXIST', '订单生成失败,该团人员已满', ['orderId' => StoreOrder::getStoreIdPink($pinkId, $request->uid())]);
  346. }
  347. if (StorePink::getIsPinkUid($pinkId, $request->uid()))
  348. return app('json')->status('ORDER_EXIST', '订单生成失败,你已经在该团内不能再参加了', ['orderId' => StoreOrder::getStoreIdPink($pinkId, $request->uid())]);
  349. if (StoreOrder::getIsOrderPink($pinkId, $request->uid()))
  350. return app('json')->status('ORDER_EXIST', '订单生成失败,你已经参加该团了,请先支付订单', ['orderId' => StoreOrder::getStoreIdPink($pinkId, $request->uid())]);
  351. }
  352. $priceGroup = StoreOrderBatch::cacheKeyCreateOrderBatch($request->uid(), $key, $addressId, $payType, (int)$useIntegral,
  353. $couponId, $mark, $combinationId, $pinkId, $seckill_id, $bargainId, true, 0, $shipping_type);
  354. // return app('json')->fail(StoreOrder::getErrorInfo('计算失败'));
  355. if ($priceGroup)
  356. return app('json')->status('NONE', 'ok', $priceGroup);
  357. else
  358. return app('json')->fail(StoreOrder::getErrorInfo('计算失败'));
  359. }
  360. /**
  361. * 订单创建, 支持子订单版本
  362. * @param Request $request
  363. * @param $key
  364. * @return mixed
  365. * @throws \think\Exception
  366. * @throws \think\db\exception\DataNotFoundException
  367. * @throws \think\db\exception\ModelNotFoundException
  368. * @throws \think\exception\DbException
  369. */
  370. public function create_v2(Request $request, $key)
  371. {
  372. // 还是那个 $orderKey
  373. if (!$key) {
  374. return app('json')->fail('参数错误!');
  375. }
  376. // 订单是否已存在
  377. $uid = $request->uid();
  378. if (StoreOrderBatch::be(['unique' => $key, 'uid' => $uid]))
  379. return app('json')->status('extend_order', '订单已生成', ['orderId' => $key, 'key' => $key]);
  380. // 获得参数
  381. list($addressId, $couponId, $payType, $useIntegral, $mark, $combinationId, $pinkId, $seckill_id, $formId, $bargainId, $from, $shipping_type, $real_name, $phone, $storeId) = UtilService::postMore([
  382. 'addressId',
  383. 'couponId',
  384. 'payType',
  385. ['useIntegral', 0],
  386. 'mark',
  387. ['combinationId', 0], ['pinkId', 0], ['seckill_id', 0], ['formId', ''], ['bargainId', ''],
  388. ['from', 'weixin'],
  389. ['shipping_type', 1], ['real_name', ''], ['phone', ''], ['store_id', 0]
  390. ], $request, true);
  391. // weixin / yue
  392. $payType = strtolower($payType);
  393. if ($bargainId) {
  394. $bargainUserTableId = StoreBargainUser::getBargainUserTableId($bargainId, $uid);//TODO 获取用户参与砍价表编号
  395. if (!$bargainUserTableId)
  396. return app('json')->fail('砍价失败');
  397. $status = StoreBargainUser::getBargainUserStatusEnd($bargainUserTableId);
  398. if ($status == 3)
  399. return app('json')->fail('砍价已支付');
  400. StoreBargainUser::setBargainUserStatus($bargainId, $uid); //修改砍价状态
  401. }
  402. if ($pinkId) {
  403. $cache_pink = Cache::get(md5('store_pink_' . $pinkId));
  404. if ($cache_pink && bcsub($cache_pink['people'], $cache_pink['now_people'], 0) <= 0) {
  405. return app('json')->status('ORDER_EXIST', '订单生成失败,该团人员已满', ['orderId' => StoreOrder::getStoreIdPink($pinkId, $request->uid())]);
  406. }
  407. if (StorePink::getIsPinkUid($pinkId, $request->uid()))
  408. return app('json')->status('ORDER_EXIST', '订单生成失败,你已经在该团内不能再参加了', ['orderId' => StoreOrder::getStoreIdPink($pinkId, $request->uid())]);
  409. if (StoreOrder::getIsOrderPink($pinkId, $request->uid()))
  410. return app('json')->status('ORDER_EXIST', '订单生成失败,你已经参加该团了,请先支付订单', ['orderId' => StoreOrder::getStoreIdPink($pinkId, $request->uid())]);
  411. }
  412. $isChannel = 1; // 'routine'
  413. if ($from == 'weixin')
  414. $isChannel = 0;
  415. elseif ($from == 'weixinh5')
  416. $isChannel = 2;
  417. elseif ($from == 'app') {
  418. $isChannel = 3;
  419. }
  420. $porderId = StoreOrderBatch::cacheKeyCreateOrderBatch($request->uid(), $key, $addressId, $payType, (int)$useIntegral,
  421. $couponId, $mark, $combinationId, $pinkId, $seckill_id, $bargainId, false, $isChannel,
  422. $shipping_type, $real_name, $phone, $storeId);
  423. if ($porderId === false) {
  424. return app('json')->fail(StoreOrderBatch::getErrorInfo('订单生成失败'));
  425. }
  426. $orderId = $porderId; // for compact
  427. $info = compact('orderId', 'key');
  428. if ($porderId) {
  429. event('BatchOrderCreated', [$porderId]); //订单创建成功事件
  430. // event('ShortMssageSend', [$orderId, 'AdminPlaceAnOrder']);//发送管理员通知
  431. switch ($payType) {
  432. case "weixin":
  433. $subOrders = StoreOrderBatch::getAllSubOrders($porderId);
  434. if (!$subOrders) return app('json')->fail('支付订单不存在!');
  435. $fieldValues = StoreOrderBatch::sumFields($subOrders, ['paid','pay_price']);
  436. if ($fieldValues['paid']) {
  437. return app('json')->fail('支付已支付!');
  438. }
  439. //支付金额为0
  440. if (bcsub($fieldValues['pay_price'], 0, 2) <= 0) {
  441. //创建订单jspay支付
  442. $payPriceStatus = StoreOrderBatch::jsPayPriceBatch($porderId, $uid, $formId);
  443. if ($payPriceStatus)//0元支付成功
  444. return app('json')->status('success', '微信支付成功', $info);
  445. else
  446. return app('json')->status('pay_error', StoreOrderBatch::getErrorInfo());
  447. } else {
  448. try {
  449. if ($from == 'routine') {
  450. $jsConfig = OrderRepository::jsPayBatch($porderId); //创建订单jspay
  451. } else if ($from == 'weixinh5') {
  452. $jsConfig = OrderRepository::h5PayBatch($porderId);
  453. } elseif ($from == 'app') {
  454. $jsConfig = OrderRepository::wxAppPayBatch($porderId);
  455. } else {
  456. $jsConfig = OrderRepository::wxPayBatch($porderId);
  457. }
  458. } catch (\Exception $e) {
  459. return app('json')->status('pay_error', $e->getMessage(), $info);
  460. }
  461. $info['jsConfig'] = $jsConfig;
  462. return app('json')->status($payType . '_' . $from, '订单创建成功', $info);
  463. // if ($from == 'weixinh5') {
  464. // return app('json')->status('wechat_h5_pay', '订单创建成功', $info);
  465. // } else {
  466. // return app('json')->status('wechat_pay', '订单创建成功', $info);
  467. // }
  468. }
  469. break;
  470. case 'yue':
  471. if (StoreOrderBatch::yuePayBatch($porderId, $request->uid(), $formId))
  472. return app('json')->status('success', '余额支付成功', $info);
  473. else {
  474. $errorinfo = StoreOrderBatch::getErrorInfo();
  475. if (is_array($errorinfo))
  476. return app('json')->status($errorinfo['status'], $errorinfo['msg'], $info);
  477. else
  478. return app('json')->status('pay_error', $errorinfo);
  479. }
  480. break;
  481. case 'offline':
  482. return app('json')->status('success', '订单创建成功', $info);
  483. break;
  484. }
  485. } else { // !$orderId
  486. return app('json')->fail(StoreOrderBatch::getErrorInfo('订单生成失败!'));
  487. }
  488. }
  489. /**
  490. * 订单 再次下单
  491. * @param Request $request
  492. * @return mixed
  493. */
  494. public function again(Request $request)
  495. {
  496. list($uni) = UtilService::postMore([
  497. ['uni', ''],
  498. ], $request, true);
  499. if (!$uni) return app('json')->fail('参数错误!');
  500. $order = StoreOrder::getUserOrderDetail($request->uid(), $uni);
  501. if (!$order) return app('json')->fail('订单不存在!');
  502. $order = StoreOrder::tidyOrder($order, true);
  503. $res = [];
  504. foreach ($order['cartInfo'] as $v) {
  505. if ($v['combination_id']) return app('json')->fail('拼团产品不能再来一单,请在拼团产品内自行下单!');
  506. else if ($v['bargain_id']) return app('json')->fail('砍价产品不能再来一单,请在砍价产品内自行下单!');
  507. else if ($v['seckill_id']) return app('json')->ail('秒杀产品不能再来一单,请在秒杀产品内自行下单!');
  508. else $res[] = StoreCart::setCart($request->uid(), $v['product_id'], $v['cart_num'], isset($v['productInfo']['attrInfo']['unique']) ? $v['productInfo']['attrInfo']['unique'] : '', 'product', 0, 0);
  509. }
  510. $cateId = [];
  511. foreach ($res as $v) {
  512. if (!$v) return app('json')->fail('再来一单失败,请重新下单!');
  513. $cateId[] = $v['id'];
  514. }
  515. event('OrderCreateAgain', implode(',', $cateId));
  516. return app('json')->successful('ok', ['cateId' => implode(',', $cateId)]);
  517. }
  518. /**
  519. * 订单支付
  520. * @param Request $request
  521. * @return mixed
  522. */
  523. public function pay(Request $request)
  524. {
  525. list($uni, $paytype, $from) = UtilService::postMore([
  526. ['uni', ''],
  527. ['paytype', 'weixin'],
  528. ['from', 'weixin']
  529. ], $request, true);
  530. if (!$uni) return app('json')->fail('参数错误!');
  531. $order = StoreOrder::getUserOrderDetail($request->uid(), $uni);
  532. if (!$order)
  533. return app('json')->fail('订单不存在!');
  534. if ($order['paid'])
  535. return app('json')->fail('该订单已支付!');
  536. if ($order['pink_id']) {
  537. $cache_pink = Cache::get(md5('store_pink_' . $order['pink_id']));
  538. if (StorePink::isPinkStatus($order['pink_id']) || ($cache_pink && bcsub($cache_pink['people'], $cache_pink['now_people'], 0) <= 0)) {
  539. return app('json')->fail('该订单已失效!');
  540. }
  541. }
  542. if ($from == 'weixin') {//0
  543. if (in_array($order->is_channel, [1, 2, 3]))
  544. $order['order_id'] = mt_rand(100, 999) . '_' . $order['order_id'];
  545. }
  546. if ($from == 'weixinh5') {//2
  547. if (in_array($order->is_channel, [0, 1, 3]))
  548. $order['order_id'] = mt_rand(100, 999) . '_' . $order['order_id'];
  549. }
  550. if ($from == 'routine') {//1
  551. if (in_array($order->is_channel, [0, 2, 3]))
  552. $order['order_id'] = mt_rand(100, 999) . '_' . $order['order_id'];
  553. }
  554. if ($from == 'app') {
  555. if (in_array($order->is_channel, [0, 1, 2])) {
  556. $order['order_id'] = mt_rand(100, 999) . '_' . $order['order_id'];
  557. }
  558. }
  559. $order['pay_type'] = $paytype; //重新支付选择支付方式
  560. switch ($order['pay_type']) {
  561. case 'weixin':
  562. try {
  563. if ($from == 'routine') {
  564. $jsConfig = OrderRepository::jsPay($order); //订单列表发起支付
  565. } else if ($from == 'weixinh5') {
  566. $jsConfig = OrderRepository::h5Pay($order);
  567. } else if ($from == 'app') {
  568. $jsConfig = OrderRepository::wxAppPay($order);
  569. } else {
  570. $jsConfig = OrderRepository::wxPay($order);
  571. }
  572. } catch (\Exception $e) {
  573. return app('json')->fail($e->getMessage());
  574. }
  575. return app('json')->status($paytype . '_' . $from, ['jsConfig' => $jsConfig, 'order_id' => $order['order_id']]);
  576. // if ($from == 'weixinh5') {
  577. // return app('json')->status('wechat_h5_pay', ['jsConfig' => $jsConfig, 'order_id' => $order['order_id']]);
  578. // } else {
  579. // return app('json')->status('wechat_pay', ['jsConfig' => $jsConfig, 'order_id' => $order['order_id']]);
  580. // }
  581. break;
  582. case 'yue':
  583. if (StoreOrder::yuePay($order['order_id'], $request->uid()))
  584. return app('json')->status('success', '余额支付成功');
  585. else {
  586. $error = StoreOrder::getErrorInfo();
  587. return app('json')->fail(is_array($error) && isset($error['msg']) ? $error['msg'] : $error);
  588. }
  589. break;
  590. case 'offline':
  591. StoreOrder::createOrderTemplate($order);
  592. if (StoreOrder::setOrderTypePayOffline($order['order_id']))
  593. return app('json')->status('success', '订单创建成功');
  594. else
  595. return app('json')->status('success', '支付失败');
  596. break;
  597. case 'alipay':
  598. break;
  599. }
  600. return app('json')->fail('支付方式错误');
  601. }
  602. /**
  603. * 订单列表
  604. * @param Request $request
  605. * @return mixed
  606. */
  607. public function lst(Request $request)
  608. {
  609. list($type, $page, $limit, $search) = UtilService::getMore([
  610. ['type', ''],
  611. ['page', 0],
  612. ['limit', ''],
  613. ['search', ''],
  614. ], $request, true);
  615. return app('json')->successful(StoreOrder::getUserOrderSearchList($request->uid(), $type, $page, $limit, $search));
  616. }
  617. /**
  618. * 订单详情 v2
  619. * 订单支持子订单之后,订单详情协议传过来的 $uni 有可能是子订单的,也有可能是主订单的
  620. */
  621. public function detail_v2(Request $request, $uni)
  622. {
  623. if (!strlen(trim($uni))) return app('json')->fail('参数错误');
  624. $uid = $request->uid();
  625. $first4 = mb_substr($uni, 0, 4);
  626. if ($first4 == 'wxcn') {
  627. $porder = StoreOrderBatch::where('porder_id', $uni)->where('uid', $uid)->find();
  628. if (!$porder) {
  629. return app('json')->fail('订单不存在');
  630. }
  631. $porder = $porder->toArray();
  632. $subOrders = StoreOrderBatch::getAllSubOrders($porder['porder_id']);
  633. if (!$subOrders) {
  634. return app('json')->fail('订单不存在');
  635. }
  636. $order = $this->__get_order_details($uid, $subOrders[0]['order_id']);
  637. if (!$order) {
  638. return app('json')->fail('订单不存在');
  639. }
  640. $order['order_id'] = $porder['porder_id'];
  641. $order['pay_price'] = $porder['total_price'];
  642. return app('json')->successful('ok', $order);
  643. } else {
  644. return $this->detail($request, $uni);
  645. }
  646. }
  647. /**
  648. * 订单详情
  649. * @param Request $request
  650. * @param $uni
  651. * @return mixed
  652. */
  653. public function detail(Request $request, $uni)
  654. {
  655. $order = $this->__get_order_details($request->uid(), $uni);
  656. if (!$order) {
  657. return app('json')->fail('订单不存在');
  658. }
  659. return app('json')->successful('ok', $order);
  660. }
  661. public function __get_order_details($uid, $uni)
  662. {
  663. $order = StoreOrder::getUserOrderDetail($uid, $uni);
  664. if (!$order) {
  665. return false;
  666. }
  667. $order = $order->toArray();
  668. //是否开启门店自提
  669. $store_self_mention = sys_config('store_self_mention');
  670. //关闭门店自提后 订单隐藏门店信息
  671. if ($store_self_mention == 0) $order['shipping_type'] = 1;
  672. if ($order['verify_code']) {
  673. $verify_code = $order['verify_code'];
  674. $verify[] = substr($verify_code, 0, 4);
  675. $verify[] = substr($verify_code, 4, 4);
  676. $verify[] = substr($verify_code, 8);
  677. $order['_verify_code'] = implode(' ', $verify);
  678. }
  679. $order['add_time_y'] = date('Y-m-d', $order['add_time']);
  680. $order['add_time_h'] = date('H:i:s', $order['add_time']);
  681. $order['system_store'] = SystemStore::getStoreDispose($order['store_id']);
  682. if ($order['shipping_type'] === 2 && $order['verify_code']) {
  683. $name = $order['verify_code'] . '.jpg';
  684. $imageInfo = SystemAttachment::getInfo($name, 'name');
  685. $siteUrl = sys_config('site_url');
  686. if (!$imageInfo) {
  687. $imageInfo = UtilService::getQRCodePath($order['verify_code'], $name);
  688. if (is_array($imageInfo)) {
  689. SystemAttachment::attachmentAdd($imageInfo['name'], $imageInfo['size'], $imageInfo['type'], $imageInfo['dir'], $imageInfo['thumb_path'], 1, $imageInfo['image_type'], $imageInfo['time'], 2);
  690. $url = $imageInfo['dir'];
  691. } else
  692. $url = '';
  693. } else $url = $imageInfo['att_dir'];
  694. if (isset($imageInfo['image_type']) && $imageInfo['image_type'] == 1) $url = $siteUrl . $url;
  695. $order['code'] = $url;
  696. }
  697. $order['mapKey'] = sys_config('tengxun_map_key');
  698. return StoreOrder::tidyOrder($order, true, true);
  699. }
  700. /**
  701. * 订单删除
  702. * @param Request $request
  703. * @return mixed
  704. */
  705. public function del(Request $request)
  706. {
  707. list($uni) = UtilService::postMore([
  708. ['uni', ''],
  709. ], $request, true);
  710. if (!$uni) return app('json')->fail('参数错误!');
  711. $res = StoreOrder::removeOrder($uni, $request->uid());
  712. if ($res)
  713. return app('json')->successful();
  714. else
  715. return app('json')->fail(StoreOrder::getErrorInfo());
  716. }
  717. /**
  718. * 订单收货
  719. * @param Request $request
  720. * @return mixed
  721. */
  722. public function take(Request $request)
  723. {
  724. list($uni) = UtilService::postMore([
  725. ['uni', ''],
  726. ], $request, true);
  727. if (!$uni) return app('json')->fail('参数错误!');
  728. $res = StoreOrder::takeOrder($uni, $request->uid());
  729. if ($res) {
  730. $order_info = StoreOrder::where('order_id', $uni)->find();
  731. $gain_integral = intval($order_info['gain_integral']);
  732. $gain_coupon = StoreCouponIssue::alias('a')
  733. ->join('store_coupon b', 'a.cid = b.id')
  734. ->where('a.status', 1)
  735. ->where('a.is_full_give', 1)
  736. ->where('a.is_del', 0)
  737. ->where('a.full_reduction', '<=', $order_info['total_price'])
  738. ->sum('b.coupon_price');
  739. return app('json')->successful(['gain_integral' => $gain_integral, 'gain_coupon' => $gain_coupon]);
  740. } else
  741. return app('json')->fail(StoreOrder::getErrorInfo());
  742. }
  743. /**
  744. * 订单 查看物流
  745. * @param Request $request
  746. * @param $uni
  747. * @return mixed
  748. */
  749. public function express(Request $request, $uni)
  750. {
  751. if (!$uni || !($order = StoreOrder::getUserOrderDetail($request->uid(), $uni))) return app('json')->fail('查询订单不存在!');
  752. if ($order['delivery_type'] != 'express' || !$order['delivery_id']) return app('json')->fail('该订单不存在快递单号!');
  753. $cacheName = $uni . $order['delivery_id'];
  754. $result = CacheService::get($cacheName);
  755. if (!$result) {
  756. try {
  757. $result = ExpressService::query($order['delivery_id'], $order['delivery_name']);
  758. } catch (\Throwable $e) {
  759. $result = [];
  760. }
  761. if (is_array($result) && (isset($result['result']) || isset($result['content']))) {
  762. $cacheTime = 1200;
  763. if(isset($result['content'])){
  764. $result['result'] = $result['content'];
  765. unset($result['content']);
  766. }
  767. }else
  768. $cacheTime = 1800;
  769. CacheService::set($cacheName, $result, $cacheTime);
  770. }
  771. $orderInfo = [];
  772. $cartInfo = StoreOrderCartInfo::where('oid', $order['id'])->column('cart_info', 'unique') ?? [];
  773. $info = [];
  774. $cartNew = [];
  775. foreach ($cartInfo as $k => $cart) {
  776. $cart = json_decode($cart, true);
  777. $cartNew['cart_num'] = $cart['cart_num'];
  778. $cartNew['truePrice'] = $cart['truePrice'];
  779. $cartNew['productInfo']['image'] = $cart['productInfo']['image'];
  780. $cartNew['productInfo']['store_name'] = $cart['productInfo']['store_name'];
  781. $cartNew['productInfo']['unit_name'] = $cart['productInfo']['unit_name'] ?? '';
  782. array_push($info, $cartNew);
  783. unset($cart);
  784. }
  785. $orderInfo['delivery_id'] = $order['delivery_id'];
  786. $orderInfo['delivery_name'] = $order['delivery_name'];
  787. $orderInfo['delivery_type'] = $order['delivery_type'];
  788. $orderInfo['cartInfo'] = $info;
  789. return app('json')->successful(['order' => $orderInfo, 'express' => $result ? $result : []]);
  790. }
  791. /**
  792. * 订单评价
  793. * @param Request $request
  794. * @return mixed
  795. * @throws \think\db\exception\DataNotFoundException
  796. * @throws \think\db\exception\ModelNotFoundException
  797. * @throws \think\exception\DbException
  798. */
  799. public function comment(Request $request)
  800. {
  801. $group = UtilService::postMore([
  802. ['unique', ''], ['comment', ''], ['pics', ''], ['product_score', 5], ['service_score', 5]
  803. ], $request);
  804. $unique = $group['unique'];
  805. unset($group['unique']);
  806. if (!$unique) return app('json')->fail('参数错误!');
  807. $cartInfo = StoreOrderCartInfo::where('unique', $unique)->find();
  808. $uid = $request->uid();
  809. $user_info = User::get($uid);
  810. $group['nickname'] = $user_info['nickname'];
  811. $group['avatar'] = $user_info['avatar'];
  812. if (!$cartInfo) return app('json')->fail('评价产品不存在!');
  813. $orderUid = StoreOrder::getOrderInfo($cartInfo['oid'], 'uid')['uid'];
  814. if ($uid != $orderUid) {
  815. return app('json')->fail('评价产品不存在!');
  816. }
  817. if (StoreProductReply::be(['oid' => $cartInfo['oid'], 'unique' => $unique]))
  818. return app('json')->fail('该产品已评价!');
  819. $group['comment'] = htmlspecialchars(trim($group['comment']));
  820. if ($group['product_score'] < 1) return app('json')->fail('请为产品评分');
  821. else if ($group['service_score'] < 1) return app('json')->fail('请为商家服务评分');
  822. //
  823. $cartInfo['cart_info'] = json_decode($cartInfo['cart_info'], true);
  824. if ($cartInfo['cart_info']['combination_id']) $productId = $cartInfo['cart_info']['product_id'];
  825. else if ($cartInfo['cart_info']['seckill_id']) $productId = $cartInfo['cart_info']['product_id'];
  826. else if ($cartInfo['cart_info']['bargain_id']) $productId = $cartInfo['cart_info']['product_id'];
  827. else $productId = $cartInfo['product_id'];
  828. if ($group['pics']) {
  829. $group['pics'] = json_encode(is_array($group['pics']) ? $group['pics'] : explode(',', $group['pics']));
  830. } else {
  831. $group['pics'] = '';
  832. }
  833. $group = array_merge($group, [
  834. 'uid' => $uid,
  835. 'oid' => $cartInfo['oid'],
  836. 'unique' => $unique,
  837. 'product_id' => $productId,
  838. 'add_time' => time(),
  839. 'reply_type' => 'product'
  840. ]);
  841. StoreProductReply::beginTrans();
  842. $res = StoreProductReply::reply($group, 'product');
  843. if (!$res) {
  844. StoreProductReply::rollbackTrans();
  845. return app('json')->fail('评价失败!');
  846. }
  847. try {
  848. StoreOrder::checkOrderOver($cartInfo['oid']);
  849. } catch (\Exception $e) {
  850. StoreProductReply::rollbackTrans();
  851. return app('json')->fail($e->getMessage());
  852. }
  853. StoreProductReply::commitTrans();
  854. event('UserCommented', $res);
  855. event('AdminNewPush');
  856. return app('json')->successful();
  857. }
  858. /**
  859. * 订单统计数据
  860. * @param Request $request
  861. * @return mixed
  862. */
  863. public function data(Request $request)
  864. {
  865. return app('json')->successful(StoreOrder::getOrderData($request->uid()));
  866. }
  867. /**
  868. * 订单退款理由
  869. * @return mixed
  870. */
  871. public function refund_reason()
  872. {
  873. $reason = sys_config('stor_reason') ?: [];//退款理由
  874. $reason = str_replace("\r\n", "\n", $reason);//防止不兼容
  875. $reason = explode("\n", $reason);
  876. return app('json')->successful($reason);
  877. }
  878. /**
  879. * 订单退款审核
  880. * @param Request $request
  881. * @return mixed
  882. */
  883. public function refund_verify(Request $request)
  884. {
  885. $data = UtilService::postMore([
  886. ['text', ''],
  887. ['refund_reason_wap_img', ''],
  888. ['refund_reason_wap_explain', ''],
  889. ['uni', '']
  890. ], $request);
  891. $uni = $data['uni'];
  892. unset($data['uni']);
  893. if ($data['refund_reason_wap_img']) $data['refund_reason_wap_img'] = explode(',', $data['refund_reason_wap_img']);
  894. if (!$uni || $data['text'] == '') return app('json')->fail('参数错误!');
  895. $res = StoreOrder::orderApplyRefund($uni, $request->uid(), $data['text'], $data['refund_reason_wap_explain'], $data['refund_reason_wap_img']);
  896. if ($res)
  897. return app('json')->successful('提交申请成功');
  898. else
  899. return app('json')->fail(StoreOrder::getErrorInfo());
  900. }
  901. /**
  902. * 订单取消 未支付的订单回退积分,回退优惠券,回退库存
  903. * @param Request $request
  904. * @return mixed
  905. * @throws \think\db\exception\DataNotFoundException
  906. * @throws \think\db\exception\ModelNotFoundException
  907. * @throws \think\exception\DbException
  908. */
  909. public function cancel(Request $request)
  910. {
  911. list($id) = UtilService::postMore([['id', 0]], $request, true);
  912. if (!$id) return app('json')->fail('参数错误');
  913. if (StoreOrder::cancelOrder($id, $request->uid()))
  914. return app('json')->successful('取消订单成功');
  915. return app('json')->fail(StoreOrder::getErrorInfo('取消订单失败'));
  916. }
  917. /**
  918. * 订单产品信息
  919. * @param Request $request
  920. * @return mixed
  921. * @throws \think\db\exception\DataNotFoundException
  922. * @throws \think\db\exception\ModelNotFoundException
  923. * @throws \think\exception\DbException
  924. */
  925. public function product(Request $request)
  926. {
  927. list($unique) = UtilService::postMore([['unique', '']], $request, true);
  928. if (!$unique || !StoreOrderCartInfo::be(['unique' => $unique]) || !($cartInfo = StoreOrderCartInfo::where('unique', $unique)->find())) return app('json')->fail('评价产品不存在!');
  929. $cartInfo = $cartInfo->toArray();
  930. $cartProduct = [];
  931. $cartProduct['cart_num'] = $cartInfo['cart_info']['cart_num'];
  932. $cartProduct['productInfo']['image'] = isset($cartInfo['cart_info']['productInfo']['image']) ? $cartInfo['cart_info']['productInfo']['image'] : '';
  933. $cartProduct['productInfo']['price'] = isset($cartInfo['cart_info']['productInfo']['price']) ? $cartInfo['cart_info']['productInfo']['price'] : 0;
  934. $cartProduct['productInfo']['store_name'] = isset($cartInfo['cart_info']['productInfo']['store_name']) ? $cartInfo['cart_info']['productInfo']['store_name'] : '';
  935. if (isset($cartInfo['cart_info']['productInfo']['attrInfo'])) {
  936. $cartProduct['productInfo']['attrInfo']['product_id'] = isset($cartInfo['cart_info']['productInfo']['attrInfo']['product_id']) ? $cartInfo['cart_info']['productInfo']['attrInfo']['product_id'] : '';
  937. $cartProduct['productInfo']['attrInfo']['suk'] = isset($cartInfo['cart_info']['productInfo']['attrInfo']['suk']) ? $cartInfo['cart_info']['productInfo']['attrInfo']['suk'] : '';
  938. $cartProduct['productInfo']['attrInfo']['price'] = isset($cartInfo['cart_info']['productInfo']['attrInfo']['price']) ? $cartInfo['cart_info']['productInfo']['attrInfo']['price'] : '';
  939. $cartProduct['productInfo']['attrInfo']['image'] = isset($cartInfo['cart_info']['productInfo']['attrInfo']['image']) ? $cartInfo['cart_info']['productInfo']['attrInfo']['image'] : '';
  940. }
  941. $cartProduct['product_id'] = isset($cartInfo['cart_info']['product_id']) ? $cartInfo['cart_info']['product_id'] : 0;
  942. $cartProduct['combination_id'] = isset($cartInfo['cart_info']['combination_id']) ? $cartInfo['cart_info']['combination_id'] : 0;
  943. $cartProduct['seckill_id'] = isset($cartInfo['cart_info']['seckill_id']) ? $cartInfo['cart_info']['seckill_id'] : 0;
  944. $cartProduct['bargain_id'] = isset($cartInfo['cart_info']['bargain_id']) ? $cartInfo['cart_info']['bargain_id'] : 0;
  945. $cartProduct['order_id'] = StoreOrder::where('id', $cartInfo['oid'])->value('order_id');
  946. return app('json')->successful($cartProduct);
  947. }
  948. /**
  949. * 首页获取未支付订单
  950. */
  951. public function get_noPay(Request $request)
  952. {
  953. return app('json')->successful(StoreOrder::getUserOrderSearchList($request->uid(), 0, 0, 0, ''));
  954. }
  955. }