StoreOrderController.php 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002
  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, Log};
  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. Log::error("weixin pay error:" . $e->getMessage());
  268. return app('json')->status('pay_error', $e->getMessage(), $info);
  269. }
  270. $info['jsConfig'] = $jsConfig;
  271. $status = 'wechat_pay'; // routine
  272. if ($from == 'weixinh5') {
  273. $status = 'wechat_h5_pay';
  274. } elseif ($from == 'app') {
  275. $status = 'wechat_app_pay';
  276. }
  277. return app('json')->status($status, '订单创建成功', $info);
  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. Log::error("weixin pay error:" . $e->getMessage());
  460. return app('json')->status('pay_error', $e->getMessage(), $info);
  461. }
  462. $info['jsConfig'] = $jsConfig;
  463. $status = 'wechat_pay'; // routine
  464. if ($from == 'weixinh5') {
  465. $status = 'wechat_h5_pay';
  466. } elseif ($from == 'app') {
  467. $status = 'wechat_app_pay';
  468. }
  469. return app('json')->status($status, '订单创建成功', $info);
  470. }
  471. break;
  472. case 'yue':
  473. if (StoreOrderBatch::yuePayBatch($porderId, $request->uid(), $formId))
  474. return app('json')->status('success', '余额支付成功', $info);
  475. else {
  476. $errorinfo = StoreOrderBatch::getErrorInfo();
  477. if (is_array($errorinfo))
  478. return app('json')->status($errorinfo['status'], $errorinfo['msg'], $info);
  479. else
  480. return app('json')->status('pay_error', $errorinfo);
  481. }
  482. break;
  483. case 'offline':
  484. return app('json')->status('success', '订单创建成功', $info);
  485. break;
  486. }
  487. } else { // !$orderId
  488. return app('json')->fail(StoreOrderBatch::getErrorInfo('订单生成失败!'));
  489. }
  490. }
  491. /**
  492. * 订单 再次下单
  493. * @param Request $request
  494. * @return mixed
  495. */
  496. public function again(Request $request)
  497. {
  498. list($uni) = UtilService::postMore([
  499. ['uni', ''],
  500. ], $request, true);
  501. if (!$uni) return app('json')->fail('参数错误!');
  502. $order = StoreOrder::getUserOrderDetail($request->uid(), $uni);
  503. if (!$order) return app('json')->fail('订单不存在!');
  504. $order = StoreOrder::tidyOrder($order, true);
  505. $res = [];
  506. foreach ($order['cartInfo'] as $v) {
  507. if ($v['combination_id']) return app('json')->fail('拼团产品不能再来一单,请在拼团产品内自行下单!');
  508. else if ($v['bargain_id']) return app('json')->fail('砍价产品不能再来一单,请在砍价产品内自行下单!');
  509. else if ($v['seckill_id']) return app('json')->ail('秒杀产品不能再来一单,请在秒杀产品内自行下单!');
  510. else $res[] = StoreCart::setCart($request->uid(), $v['product_id'], $v['cart_num'], isset($v['productInfo']['attrInfo']['unique']) ? $v['productInfo']['attrInfo']['unique'] : '', 'product', 0, 0);
  511. }
  512. $cateId = [];
  513. foreach ($res as $v) {
  514. if (!$v) return app('json')->fail('再来一单失败,请重新下单!');
  515. $cateId[] = $v['id'];
  516. }
  517. event('OrderCreateAgain', implode(',', $cateId));
  518. return app('json')->successful('ok', ['cateId' => implode(',', $cateId)]);
  519. }
  520. /**
  521. * 订单支付
  522. * @param Request $request
  523. * @return mixed
  524. */
  525. public function pay(Request $request)
  526. {
  527. list($uni, $paytype, $from) = UtilService::postMore([
  528. ['uni', ''],
  529. ['paytype', 'weixin'],
  530. ['from', 'weixin']
  531. ], $request, true);
  532. if (!$uni) return app('json')->fail('参数错误!');
  533. $order = StoreOrder::getUserOrderDetail($request->uid(), $uni);
  534. if (!$order)
  535. return app('json')->fail('订单不存在!');
  536. if ($order['paid'])
  537. return app('json')->fail('该订单已支付!');
  538. if ($order['pink_id']) {
  539. $cache_pink = Cache::get(md5('store_pink_' . $order['pink_id']));
  540. if (StorePink::isPinkStatus($order['pink_id']) || ($cache_pink && bcsub($cache_pink['people'], $cache_pink['now_people'], 0) <= 0)) {
  541. return app('json')->fail('该订单已失效!');
  542. }
  543. }
  544. if ($from == 'weixin') {//0
  545. if (in_array($order->is_channel, [1, 2, 3]))
  546. $order['order_id'] = mt_rand(100, 999) . '_' . $order['order_id'];
  547. }
  548. if ($from == 'weixinh5') {//2
  549. if (in_array($order->is_channel, [0, 1, 3]))
  550. $order['order_id'] = mt_rand(100, 999) . '_' . $order['order_id'];
  551. }
  552. if ($from == 'routine') {//1
  553. if (in_array($order->is_channel, [0, 2, 3]))
  554. $order['order_id'] = mt_rand(100, 999) . '_' . $order['order_id'];
  555. }
  556. if ($from == 'app') {
  557. if (in_array($order->is_channel, [0, 1, 2])) {
  558. $order['order_id'] = mt_rand(100, 999) . '_' . $order['order_id'];
  559. }
  560. }
  561. $order['pay_type'] = $paytype; //重新支付选择支付方式
  562. switch ($order['pay_type']) {
  563. case 'weixin':
  564. try {
  565. if ($from == 'routine') {
  566. $jsConfig = OrderRepository::jsPay($order); //订单列表发起支付
  567. } else if ($from == 'weixinh5') {
  568. $jsConfig = OrderRepository::h5Pay($order);
  569. } else if ($from == 'app') {
  570. $jsConfig = OrderRepository::wxAppPay($order);
  571. } else {
  572. $jsConfig = OrderRepository::wxPay($order);
  573. }
  574. } catch (\Exception $e) {
  575. Log::error('weixin pay error:' . $e->getMessage());
  576. return app('json')->fail($e->getMessage());
  577. }
  578. // return app('json')->status($paytype . '_' . $from, ['jsConfig' => $jsConfig, 'order_id' => $order['order_id']]);
  579. $status = 'wechat_pay'; // routine
  580. if ($from == 'weixinh5') {
  581. $status = 'wechat_h5_pay';
  582. } elseif ($from == 'app') {
  583. $status = 'wechat_app_pay';
  584. }
  585. return app('json')->status($status, ['jsConfig' => $jsConfig, 'order_id' => $order['order_id']]);
  586. // if ($from == 'weixinh5') {
  587. // return app('json')->status('wechat_h5_pay', ['jsConfig' => $jsConfig, 'order_id' => $order['order_id']]);
  588. // } else {
  589. // return app('json')->status('wechat_pay', ['jsConfig' => $jsConfig, 'order_id' => $order['order_id']]);
  590. // }
  591. break;
  592. case 'yue':
  593. if (StoreOrder::yuePay($order['order_id'], $request->uid()))
  594. return app('json')->status('success', '余额支付成功');
  595. else {
  596. $error = StoreOrder::getErrorInfo();
  597. return app('json')->fail(is_array($error) && isset($error['msg']) ? $error['msg'] : $error);
  598. }
  599. break;
  600. case 'offline':
  601. StoreOrder::createOrderTemplate($order);
  602. if (StoreOrder::setOrderTypePayOffline($order['order_id']))
  603. return app('json')->status('success', '订单创建成功');
  604. else
  605. return app('json')->status('success', '支付失败');
  606. break;
  607. case 'alipay':
  608. break;
  609. }
  610. return app('json')->fail('支付方式错误');
  611. }
  612. /**
  613. * 订单列表
  614. * @param Request $request
  615. * @return mixed
  616. */
  617. public function lst(Request $request)
  618. {
  619. list($type, $page, $limit, $search) = UtilService::getMore([
  620. ['type', ''],
  621. ['page', 0],
  622. ['limit', ''],
  623. ['search', ''],
  624. ], $request, true);
  625. return app('json')->successful(StoreOrder::getUserOrderSearchList($request->uid(), $type, $page, $limit, $search));
  626. }
  627. /**
  628. * 订单详情 v2
  629. * 订单支持子订单之后,订单详情协议传过来的 $uni 有可能是子订单的,也有可能是主订单的
  630. */
  631. public function detail_v2(Request $request, $uni)
  632. {
  633. if (!strlen(trim($uni))) return app('json')->fail('参数错误');
  634. $uid = $request->uid();
  635. $first4 = mb_substr($uni, 0, 4);
  636. if ($first4 == 'wxcn') {
  637. $porder = StoreOrderBatch::where('porder_id', $uni)->where('uid', $uid)->find();
  638. if (!$porder) {
  639. return app('json')->fail('订单不存在');
  640. }
  641. $porder = $porder->toArray();
  642. $subOrders = StoreOrderBatch::getAllSubOrders($porder['porder_id']);
  643. if (!$subOrders) {
  644. return app('json')->fail('订单不存在');
  645. }
  646. $order = $this->__get_order_details($uid, $subOrders[0]['order_id']);
  647. if (!$order) {
  648. return app('json')->fail('订单不存在');
  649. }
  650. $order['order_id'] = $porder['porder_id'];
  651. $order['pay_price'] = $porder['total_price'];
  652. return app('json')->successful('ok', $order);
  653. } else {
  654. return $this->detail($request, $uni);
  655. }
  656. }
  657. /**
  658. * 订单详情
  659. * @param Request $request
  660. * @param $uni
  661. * @return mixed
  662. */
  663. public function detail(Request $request, $uni)
  664. {
  665. $order = $this->__get_order_details($request->uid(), $uni);
  666. if (!$order) {
  667. return app('json')->fail('订单不存在');
  668. }
  669. return app('json')->successful('ok', $order);
  670. }
  671. public function __get_order_details($uid, $uni)
  672. {
  673. $order = StoreOrder::getUserOrderDetail($uid, $uni);
  674. if (!$order) {
  675. return false;
  676. }
  677. $order = $order->toArray();
  678. //是否开启门店自提
  679. $store_self_mention = sys_config('store_self_mention');
  680. //关闭门店自提后 订单隐藏门店信息
  681. if ($store_self_mention == 0) $order['shipping_type'] = 1;
  682. if ($order['verify_code']) {
  683. $verify_code = $order['verify_code'];
  684. $verify[] = substr($verify_code, 0, 4);
  685. $verify[] = substr($verify_code, 4, 4);
  686. $verify[] = substr($verify_code, 8);
  687. $order['_verify_code'] = implode(' ', $verify);
  688. }
  689. $order['add_time_y'] = date('Y-m-d', $order['add_time']);
  690. $order['add_time_h'] = date('H:i:s', $order['add_time']);
  691. $order['system_store'] = SystemStore::getStoreDispose($order['store_id']);
  692. if ($order['shipping_type'] === 2 && $order['verify_code']) {
  693. $name = $order['verify_code'] . '.jpg';
  694. $imageInfo = SystemAttachment::getInfo($name, 'name');
  695. $siteUrl = sys_config('site_url');
  696. if (!$imageInfo) {
  697. $imageInfo = UtilService::getQRCodePath($order['verify_code'], $name);
  698. if (is_array($imageInfo)) {
  699. SystemAttachment::attachmentAdd($imageInfo['name'], $imageInfo['size'], $imageInfo['type'], $imageInfo['dir'], $imageInfo['thumb_path'], 1, $imageInfo['image_type'], $imageInfo['time'], 2);
  700. $url = $imageInfo['dir'];
  701. } else
  702. $url = '';
  703. } else $url = $imageInfo['att_dir'];
  704. if (isset($imageInfo['image_type']) && $imageInfo['image_type'] == 1) $url = $siteUrl . $url;
  705. $order['code'] = $url;
  706. }
  707. $order['mapKey'] = sys_config('tengxun_map_key');
  708. return StoreOrder::tidyOrder($order, true, true);
  709. }
  710. /**
  711. * 订单删除
  712. * @param Request $request
  713. * @return mixed
  714. */
  715. public function del(Request $request)
  716. {
  717. list($uni) = UtilService::postMore([
  718. ['uni', ''],
  719. ], $request, true);
  720. if (!$uni) return app('json')->fail('参数错误!');
  721. $res = StoreOrder::removeOrder($uni, $request->uid());
  722. if ($res)
  723. return app('json')->successful();
  724. else
  725. return app('json')->fail(StoreOrder::getErrorInfo());
  726. }
  727. /**
  728. * 订单收货
  729. * @param Request $request
  730. * @return mixed
  731. */
  732. public function take(Request $request)
  733. {
  734. list($uni) = UtilService::postMore([
  735. ['uni', ''],
  736. ], $request, true);
  737. if (!$uni) return app('json')->fail('参数错误!');
  738. $res = StoreOrder::takeOrder($uni, $request->uid());
  739. if ($res) {
  740. $order_info = StoreOrder::where('order_id', $uni)->find();
  741. $gain_integral = intval($order_info['gain_integral']);
  742. $gain_coupon = StoreCouponIssue::alias('a')
  743. ->join('store_coupon b', 'a.cid = b.id')
  744. ->where('a.status', 1)
  745. ->where('a.is_full_give', 1)
  746. ->where('a.is_del', 0)
  747. ->where('a.full_reduction', '<=', $order_info['total_price'])
  748. ->sum('b.coupon_price');
  749. return app('json')->successful(['gain_integral' => $gain_integral, 'gain_coupon' => $gain_coupon]);
  750. } else
  751. return app('json')->fail(StoreOrder::getErrorInfo());
  752. }
  753. /**
  754. * 订单 查看物流
  755. * @param Request $request
  756. * @param $uni
  757. * @return mixed
  758. */
  759. public function express(Request $request, $uni)
  760. {
  761. if (!$uni || !($order = StoreOrder::getUserOrderDetail($request->uid(), $uni))) return app('json')->fail('查询订单不存在!');
  762. if ($order['delivery_type'] != 'express' || !$order['delivery_id']) return app('json')->fail('该订单不存在快递单号!');
  763. $cacheName = $uni . $order['delivery_id'];
  764. $result = CacheService::get($cacheName);
  765. if (!$result) {
  766. try {
  767. $result = ExpressService::query($order['delivery_id'], $order['delivery_name']);
  768. } catch (\Throwable $e) {
  769. $result = [];
  770. }
  771. if (is_array($result) && (isset($result['result']) || isset($result['content']))) {
  772. $cacheTime = 1200;
  773. if(isset($result['content'])){
  774. $result['result'] = $result['content'];
  775. unset($result['content']);
  776. }
  777. }else
  778. $cacheTime = 1800;
  779. CacheService::set($cacheName, $result, $cacheTime);
  780. }
  781. $orderInfo = [];
  782. $cartInfo = StoreOrderCartInfo::where('oid', $order['id'])->column('cart_info', 'unique') ?? [];
  783. $info = [];
  784. $cartNew = [];
  785. foreach ($cartInfo as $k => $cart) {
  786. $cart = json_decode($cart, true);
  787. $cartNew['cart_num'] = $cart['cart_num'];
  788. $cartNew['truePrice'] = $cart['truePrice'];
  789. $cartNew['productInfo']['image'] = $cart['productInfo']['image'];
  790. $cartNew['productInfo']['store_name'] = $cart['productInfo']['store_name'];
  791. $cartNew['productInfo']['unit_name'] = $cart['productInfo']['unit_name'] ?? '';
  792. array_push($info, $cartNew);
  793. unset($cart);
  794. }
  795. $orderInfo['delivery_id'] = $order['delivery_id'];
  796. $orderInfo['delivery_name'] = $order['delivery_name'];
  797. $orderInfo['delivery_type'] = $order['delivery_type'];
  798. $orderInfo['cartInfo'] = $info;
  799. return app('json')->successful(['order' => $orderInfo, 'express' => $result ? $result : []]);
  800. }
  801. /**
  802. * 订单评价
  803. * @param Request $request
  804. * @return mixed
  805. * @throws \think\db\exception\DataNotFoundException
  806. * @throws \think\db\exception\ModelNotFoundException
  807. * @throws \think\exception\DbException
  808. */
  809. public function comment(Request $request)
  810. {
  811. $group = UtilService::postMore([
  812. ['unique', ''], ['comment', ''], ['pics', ''], ['product_score', 5], ['service_score', 5]
  813. ], $request);
  814. $unique = $group['unique'];
  815. unset($group['unique']);
  816. if (!$unique) return app('json')->fail('参数错误!');
  817. $cartInfo = StoreOrderCartInfo::where('unique', $unique)->find();
  818. $uid = $request->uid();
  819. $user_info = User::get($uid);
  820. $group['nickname'] = $user_info['nickname'];
  821. $group['avatar'] = $user_info['avatar'];
  822. if (!$cartInfo) return app('json')->fail('评价产品不存在!');
  823. $orderUid = StoreOrder::getOrderInfo($cartInfo['oid'], 'uid')['uid'];
  824. if ($uid != $orderUid) {
  825. return app('json')->fail('评价产品不存在!');
  826. }
  827. if (StoreProductReply::be(['oid' => $cartInfo['oid'], 'unique' => $unique]))
  828. return app('json')->fail('该产品已评价!');
  829. $group['comment'] = htmlspecialchars(trim($group['comment']));
  830. if ($group['product_score'] < 1) return app('json')->fail('请为产品评分');
  831. else if ($group['service_score'] < 1) return app('json')->fail('请为商家服务评分');
  832. //
  833. $cartInfo['cart_info'] = json_decode($cartInfo['cart_info'], true);
  834. if ($cartInfo['cart_info']['combination_id']) $productId = $cartInfo['cart_info']['product_id'];
  835. else if ($cartInfo['cart_info']['seckill_id']) $productId = $cartInfo['cart_info']['product_id'];
  836. else if ($cartInfo['cart_info']['bargain_id']) $productId = $cartInfo['cart_info']['product_id'];
  837. else $productId = $cartInfo['product_id'];
  838. if ($group['pics']) {
  839. $group['pics'] = json_encode(is_array($group['pics']) ? $group['pics'] : explode(',', $group['pics']));
  840. } else {
  841. $group['pics'] = '';
  842. }
  843. $group = array_merge($group, [
  844. 'uid' => $uid,
  845. 'oid' => $cartInfo['oid'],
  846. 'unique' => $unique,
  847. 'product_id' => $productId,
  848. 'add_time' => time(),
  849. 'reply_type' => 'product'
  850. ]);
  851. StoreProductReply::beginTrans();
  852. $res = StoreProductReply::reply($group, 'product');
  853. if (!$res) {
  854. StoreProductReply::rollbackTrans();
  855. return app('json')->fail('评价失败!');
  856. }
  857. try {
  858. StoreOrder::checkOrderOver($cartInfo['oid']);
  859. } catch (\Exception $e) {
  860. StoreProductReply::rollbackTrans();
  861. return app('json')->fail($e->getMessage());
  862. }
  863. StoreProductReply::commitTrans();
  864. event('UserCommented', $res);
  865. event('AdminNewPush');
  866. return app('json')->successful();
  867. }
  868. /**
  869. * 订单统计数据
  870. * @param Request $request
  871. * @return mixed
  872. */
  873. public function data(Request $request)
  874. {
  875. return app('json')->successful(StoreOrder::getOrderData($request->uid()));
  876. }
  877. /**
  878. * 订单退款理由
  879. * @return mixed
  880. */
  881. public function refund_reason()
  882. {
  883. $reason = sys_config('stor_reason') ?: [];//退款理由
  884. $reason = str_replace("\r\n", "\n", $reason);//防止不兼容
  885. $reason = explode("\n", $reason);
  886. return app('json')->successful($reason);
  887. }
  888. /**
  889. * 订单退款审核
  890. * @param Request $request
  891. * @return mixed
  892. */
  893. public function refund_verify(Request $request)
  894. {
  895. $data = UtilService::postMore([
  896. ['text', ''],
  897. ['refund_reason_wap_img', ''],
  898. ['refund_reason_wap_explain', ''],
  899. ['uni', '']
  900. ], $request);
  901. $uni = $data['uni'];
  902. unset($data['uni']);
  903. if ($data['refund_reason_wap_img']) $data['refund_reason_wap_img'] = explode(',', $data['refund_reason_wap_img']);
  904. if (!$uni || $data['text'] == '') return app('json')->fail('参数错误!');
  905. $res = StoreOrder::orderApplyRefund($uni, $request->uid(), $data['text'], $data['refund_reason_wap_explain'], $data['refund_reason_wap_img']);
  906. if ($res)
  907. return app('json')->successful('提交申请成功');
  908. else
  909. return app('json')->fail(StoreOrder::getErrorInfo());
  910. }
  911. /**
  912. * 订单取消 未支付的订单回退积分,回退优惠券,回退库存
  913. * @param Request $request
  914. * @return mixed
  915. * @throws \think\db\exception\DataNotFoundException
  916. * @throws \think\db\exception\ModelNotFoundException
  917. * @throws \think\exception\DbException
  918. */
  919. public function cancel(Request $request)
  920. {
  921. list($id) = UtilService::postMore([['id', 0]], $request, true);
  922. if (!$id) return app('json')->fail('参数错误');
  923. if (StoreOrder::cancelOrder($id, $request->uid()))
  924. return app('json')->successful('取消订单成功');
  925. return app('json')->fail(StoreOrder::getErrorInfo('取消订单失败'));
  926. }
  927. /**
  928. * 订单产品信息
  929. * @param Request $request
  930. * @return mixed
  931. * @throws \think\db\exception\DataNotFoundException
  932. * @throws \think\db\exception\ModelNotFoundException
  933. * @throws \think\exception\DbException
  934. */
  935. public function product(Request $request)
  936. {
  937. list($unique) = UtilService::postMore([['unique', '']], $request, true);
  938. if (!$unique || !StoreOrderCartInfo::be(['unique' => $unique]) || !($cartInfo = StoreOrderCartInfo::where('unique', $unique)->find())) return app('json')->fail('评价产品不存在!');
  939. $cartInfo = $cartInfo->toArray();
  940. $cartProduct = [];
  941. $cartProduct['cart_num'] = $cartInfo['cart_info']['cart_num'];
  942. $cartProduct['productInfo']['image'] = isset($cartInfo['cart_info']['productInfo']['image']) ? $cartInfo['cart_info']['productInfo']['image'] : '';
  943. $cartProduct['productInfo']['price'] = isset($cartInfo['cart_info']['productInfo']['price']) ? $cartInfo['cart_info']['productInfo']['price'] : 0;
  944. $cartProduct['productInfo']['store_name'] = isset($cartInfo['cart_info']['productInfo']['store_name']) ? $cartInfo['cart_info']['productInfo']['store_name'] : '';
  945. if (isset($cartInfo['cart_info']['productInfo']['attrInfo'])) {
  946. $cartProduct['productInfo']['attrInfo']['product_id'] = isset($cartInfo['cart_info']['productInfo']['attrInfo']['product_id']) ? $cartInfo['cart_info']['productInfo']['attrInfo']['product_id'] : '';
  947. $cartProduct['productInfo']['attrInfo']['suk'] = isset($cartInfo['cart_info']['productInfo']['attrInfo']['suk']) ? $cartInfo['cart_info']['productInfo']['attrInfo']['suk'] : '';
  948. $cartProduct['productInfo']['attrInfo']['price'] = isset($cartInfo['cart_info']['productInfo']['attrInfo']['price']) ? $cartInfo['cart_info']['productInfo']['attrInfo']['price'] : '';
  949. $cartProduct['productInfo']['attrInfo']['image'] = isset($cartInfo['cart_info']['productInfo']['attrInfo']['image']) ? $cartInfo['cart_info']['productInfo']['attrInfo']['image'] : '';
  950. }
  951. $cartProduct['product_id'] = isset($cartInfo['cart_info']['product_id']) ? $cartInfo['cart_info']['product_id'] : 0;
  952. $cartProduct['combination_id'] = isset($cartInfo['cart_info']['combination_id']) ? $cartInfo['cart_info']['combination_id'] : 0;
  953. $cartProduct['seckill_id'] = isset($cartInfo['cart_info']['seckill_id']) ? $cartInfo['cart_info']['seckill_id'] : 0;
  954. $cartProduct['bargain_id'] = isset($cartInfo['cart_info']['bargain_id']) ? $cartInfo['cart_info']['bargain_id'] : 0;
  955. $cartProduct['order_id'] = StoreOrder::where('id', $cartInfo['oid'])->value('order_id');
  956. return app('json')->successful($cartProduct);
  957. }
  958. /**
  959. * 首页获取未支付订单
  960. */
  961. public function get_noPay(Request $request)
  962. {
  963. return app('json')->successful(StoreOrder::getUserOrderSearchList($request->uid(), 0, 0, 0, ''));
  964. }
  965. }