StoreOrderController.php 45 KB

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