StoreOrderController.php 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891
  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('orderId', '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. $jsConfig = OrderRepository::appPay($order);
  218. } else if ($from == 'sb') {
  219. $data = [
  220. 'version' => '10',
  221. 'mer_no' => '6888804045113',
  222. 'mer_key' => 'Ids+y1lR4thuaHGxXaCwCLbkdFXTjze96Tua3U88ZHsvaHvYxNi7HiMBOnabYUckONdHUdUR/0g=',
  223. 'mer_order_no' => $order['order_id'].'-'.time(),
  224. 'create_time' => date('YmdHis',time()),
  225. 'order_amt' => $order['pay_price'],
  226. 'notify_url' => SystemConfigService::get('site_url').'/api/sdNotify',
  227. 'return_url' => '',
  228. 'create_ip' => str_replace('.','_', $_SERVER['REMOTE_ADDR']),
  229. 'store_id' => '000000',
  230. 'pay_extra' => json_encode(['wx_app_id' => 'wxc45bba547e921b9f', 'gh_ori_id' => 'gh_0d97f2db5dad', 'path_url' => 'pages/zf/index?', 'miniProgramType'=> '0']),
  231. 'accsplit_flag' => 'NO',
  232. 'sign_type' => 'MD5',
  233. ];
  234. $data['sign'] = sing($data, 'FQ7AZy8uve6bp7yed0MK2HqZ+qlwE798t0L0HZm0Xv7oBE8zyyB5QcTIc2iJcGXdmcDy+d3mf/N0m2NjLxy8qsME+l5b4jCqLOcCP6oEE2mYiitZIKIfvpsHc7nNZKB3yc5tMRDMqKxixuz+UKFTiw==');
  235. $data['expire_time'] = date('YmdHis',time()+1800);
  236. $data['goods_name'] = StoreOrder::getProductTitle($order['cart_id']);
  237. $data['product_code'] = '02010005';
  238. $data['clear_cycle'] = 0;
  239. $data['jump_scheme'] = 'sandcash://scpay';
  240. $data['meta_option'] = json_encode([
  241. ['sc' => '','s' => 'Android', 'n' => '', 'id' => ''],
  242. ['sc' => '','s' => 'IOS', 'n' => '', 'id' => ''],
  243. ]);
  244. return app('json')->status('weixin', '订单创建成功',['order' => $data, 'orderId' => $order['order_id']]);
  245. }else {
  246. $jsConfig = OrderRepository::wxPay($orderId);
  247. }
  248. } catch (\Exception $e) {
  249. return app('json')->status('pay_error', $e->getMessage(), $info);
  250. }
  251. $info['jsConfig'] = $jsConfig;
  252. if ($from == 'weixinh5') {
  253. return app('json')->status('wechat_h5_pay', '订单创建成功', $info);
  254. } else {
  255. return app('json')->status('wechat_pay', '订单创建成功', $info);
  256. }
  257. }
  258. break;
  259. case 'yue':
  260. if (StoreOrder::yuePay($orderId, $request->uid(), $formId))
  261. return app('json')->status('success', '余额支付成功', $info);
  262. else {
  263. $errorinfo = StoreOrder::getErrorInfo();
  264. if (is_array($errorinfo))
  265. return app('json')->status($errorinfo['status'], $errorinfo['msg'], $info);
  266. else
  267. return app('json')->status('pay_error', $errorinfo);
  268. }
  269. break;
  270. case 'offline':
  271. return app('json')->status('success', '订单创建成功', $info);
  272. break;
  273. case "ali":
  274. $orderInfo = StoreOrder::where('order_id', $orderId)->find();
  275. if (!$orderInfo || !isset($orderInfo['paid'])) return app('json')->fail('支付订单不存在!');
  276. $orderInfo = $orderInfo->toArray();
  277. if ($orderInfo['paid']) return app('json')->fail('支付已支付!');
  278. //支付金额为0
  279. if (bcsub((float)$orderInfo['pay_price'], 0, 2) <= 0) {
  280. //创建订单jspay支付
  281. $payPriceStatus = StoreOrder::jsPayPrice($orderId, $request->uid());
  282. if ($payPriceStatus)//0元支付成功
  283. return app('json')->status('success', '支付成功');
  284. else
  285. return app('json')->status('pay_error', StoreOrder::getErrorInfo());
  286. } else {
  287. try {
  288. $jsConfig = OrderRepository::aliPay($orderId); //创建订单jspay
  289. } catch (\Exception $e) {
  290. return app('json')->status('pay_error', $e->getMessage());
  291. }
  292. $info['jsConfig'] = $jsConfig;
  293. return app('json')->status('ali_pay', '订单创建成功', $info);
  294. }
  295. break;
  296. case "ailpay":
  297. $data = [
  298. 'version' => '10',
  299. 'mer_no' => '6888804045113',
  300. 'mer_key' => 'Ids+y1lR4thuaHGxXaCwCLbkdFXTjze96Tua3U88ZHsvaHvYxNi7HiMBOnabYUckONdHUdUR/0g=',
  301. 'mer_order_no' => $order['order_id'].'-'.time(),
  302. 'create_time' => date('YmdHis',time()),
  303. 'order_amt' => $order['pay_price'],
  304. 'notify_url' => SystemConfigService::get('site_url').'/api/sdNotify',
  305. 'return_url' => '',
  306. 'create_ip' => str_replace('.','_', $_SERVER['REMOTE_ADDR']),
  307. 'store_id' => '000000',
  308. 'pay_extra' => json_encode(['mer_app_id' => '', 'openid' => '', 'buyer_id' => '', 'wx_app_id' => '', 'gh_ori_id' => '', 'path_url'=> '', 'miniProgramType' => '']),
  309. 'accsplit_flag' => 'NO',
  310. 'sign_type' => 'MD5',
  311. ];
  312. $data['sign'] = sing($data, 'FQ7AZy8uve6bp7yed0MK2HqZ+qlwE798t0L0HZm0Xv7oBE8zyyB5QcTIc2iJcGXdmcDy+d3mf/N0m2NjLxy8qsME+l5b4jCqLOcCP6oEE2mYiitZIKIfvpsHc7nNZKB3yc5tMRDMqKxixuz+UKFTiw==');
  313. $data['expire_time'] = date('YmdHis',time()+1800);
  314. $data['goods_name'] = StoreOrder::getProductTitle($order['cart_id']);
  315. $data['product_code'] = '02020004';
  316. $data['clear_cycle'] = '0';
  317. $data['jump_scheme'] = 'sandcash://scpay';
  318. $data['meta_option'] = json_encode([
  319. ['sc' => 'wzsc','s' => 'Android', 'n' => '测试', 'id' => 'com.tencent.tmgp.sgame'],
  320. ['sc' => 'wzsc','s' => 'IOS', 'n' => '测试', 'id' => 'com.tencent.tmgp.sgame'],
  321. ]);
  322. return app('json')->status('ailpay', '订单创建成功',['order' => $data, 'orderId' => $order['order_id']]);
  323. case "ylpay":
  324. $data = [
  325. 'version' => '10',
  326. 'mer_no' => '6888804045113',
  327. 'mer_key' => 'Ids+y1lR4thuaHGxXaCwCLbkdFXTjze96Tua3U88ZHsvaHvYxNi7HiMBOnabYUckONdHUdUR/0g=',
  328. 'mer_order_no' => $order['order_id'].'-'.time(),
  329. 'create_time' => date('YmdHis',time()),
  330. 'order_amt' => $order['pay_price'],
  331. 'notify_url' => SystemConfigService::get('site_url').'/api/sdNotify',
  332. 'return_url' => '',
  333. 'create_ip' => str_replace('.','_', $_SERVER['REMOTE_ADDR']),
  334. 'store_id' => '000000',
  335. 'pay_extra' => '',
  336. 'accsplit_flag' => 'NO',
  337. 'sign_type' => 'MD5',
  338. ];
  339. $data['sign'] = sing($data, 'FQ7AZy8uve6bp7yed0MK2HqZ+qlwE798t0L0HZm0Xv7oBE8zyyB5QcTIc2iJcGXdmcDy+d3mf/N0m2NjLxy8qsME+l5b4jCqLOcCP6oEE2mYiitZIKIfvpsHc7nNZKB3yc5tMRDMqKxixuz+UKFTiw==');
  340. $data['expire_time'] = date('YmdHis',time()+1800);
  341. $data['goods_name'] = StoreOrder::getProductTitle($order['cart_id']);
  342. $data['product_code'] = '02030001';
  343. $data['clear_cycle'] = 0;
  344. $data['jump_scheme'] = 'sandcash://scpay';
  345. $data['meta_option'] = json_encode([
  346. ['sc' => '','s' => 'Android', 'n' => '', 'id' => ''],
  347. ['sc' => '','s' => 'IOS', 'n' => '', 'id' => ''],
  348. ]);
  349. return app('json')->status('ylpay', '订单创建成功',['order' => $data, 'orderId' => $order['order_id']]);
  350. }
  351. } else return app('json')->fail(StoreOrder::getErrorInfo('订单生成失败!'));
  352. }
  353. /**
  354. * 订单 再次下单
  355. * @param Request $request
  356. * @return mixed
  357. */
  358. public function again(Request $request)
  359. {
  360. list($uni) = UtilService::postMore([
  361. ['uni', ''],
  362. ], $request, true);
  363. if (!$uni) return app('json')->fail('参数错误!');
  364. $order = StoreOrder::getUserOrderDetail($request->uid(), $uni);
  365. if (!$order) return app('json')->fail('订单不存在!');
  366. $order = StoreOrder::tidyOrder($order, true);
  367. $res = [];
  368. foreach ($order['cartInfo'] as $v) {
  369. if ($v['combination_id']) return app('json')->fail('拼团产品不能再来一单,请在拼团产品内自行下单!');
  370. else if ($v['bargain_id']) return app('json')->fail('砍价产品不能再来一单,请在砍价产品内自行下单!');
  371. else if ($v['seckill_id']) return app('json')->ail('秒杀产品不能再来一单,请在秒杀产品内自行下单!');
  372. else $res[] = StoreCart::setCart($request->uid(), $v['product_id'], $v['cart_num'], isset($v['productInfo']['attrInfo']['unique']) ? $v['productInfo']['attrInfo']['unique'] : '', 'product', 0, 0);
  373. }
  374. $cateId = [];
  375. foreach ($res as $v) {
  376. if (!$v) return app('json')->fail('再来一单失败,请重新下单!');
  377. $cateId[] = $v['id'];
  378. }
  379. event('OrderCreateAgain', implode(',', $cateId));
  380. return app('json')->successful('ok', ['cateId' => implode(',', $cateId)]);
  381. }
  382. /**
  383. * 订单支付
  384. * @param Request $request
  385. * @return mixed
  386. */
  387. public function pay(Request $request)
  388. {
  389. list($uni, $paytype, $from) = UtilService::postMore([
  390. ['uni', ''],
  391. ['paytype', 'weixin'],
  392. ['from', 'weixin']
  393. ], $request, true);
  394. if (!$uni) return app('json')->fail('参数错误!');
  395. $order = StoreOrder::getUserOrderDetail($request->uid(), $uni);
  396. if (!$order)
  397. return app('json')->fail('订单不存在!');
  398. if ($order['paid'])
  399. return app('json')->fail('该订单已支付!');
  400. if ($order['pink_id']) if (StorePink::isPinkStatus($order['pink_id']))
  401. return app('json')->fail('该订单已失效!');
  402. if ($from == 'weixin') {//0
  403. if (in_array($order->is_channel, [1, 2]))
  404. $order['order_id'] = mt_rand(100, 999) . '_' . $order['order_id'];
  405. }
  406. if ($from == 'weixinh5') {//2
  407. if (in_array($order->is_channel, [0, 1]))
  408. $order['order_id'] = mt_rand(100, 999) . '_' . $order['order_id'];
  409. }
  410. if ($from == 'routine') {//1
  411. if (in_array($order->is_channel, [0, 2]))
  412. $order['order_id'] = mt_rand(100, 999) . '_' . $order['order_id'];
  413. }
  414. $order['pay_type'] = $paytype; //重新支付选择支付方式
  415. switch ($order['pay_type']) {
  416. case 'weixin':
  417. try {
  418. if ($from == 'routine') {
  419. $jsConfig = OrderRepository::jsPay($order); //订单列表发起支付
  420. } else if ($from == 'weixinh5') {
  421. $jsConfig = OrderRepository::h5Pay($order);
  422. } else if ($from == 'app') {
  423. $jsConfig = OrderRepository::appPay($order);
  424. } else if ($from == 'sb') {
  425. $data = [
  426. 'version' => '10',
  427. 'mer_no' => '6888804045113',
  428. 'mer_key' => 'Ids+y1lR4thuaHGxXaCwCLbkdFXTjze96Tua3U88ZHsvaHvYxNi7HiMBOnabYUckONdHUdUR/0g=',
  429. 'mer_order_no' => $order['order_id'].'-'.time(),
  430. 'create_time' => date('YmdHis',time()),
  431. 'order_amt' => $order['pay_price'],
  432. 'notify_url' => SystemConfigService::get('site_url').'/api/sdNotify',
  433. 'return_url' => '',
  434. 'create_ip' => str_replace('.','_', $_SERVER['REMOTE_ADDR']),
  435. 'store_id' => '000000',
  436. 'pay_extra' => json_encode(['wx_app_id' => 'wxc45bba547e921b9f', 'gh_ori_id' => 'gh_0d97f2db5dad', 'path_url' => 'pages/zf/index?', 'miniProgramType'=> '0']),
  437. 'accsplit_flag' => 'NO',
  438. 'sign_type' => 'MD5',
  439. ];
  440. $data['sign'] = sing($data, 'FQ7AZy8uve6bp7yed0MK2HqZ+qlwE798t0L0HZm0Xv7oBE8zyyB5QcTIc2iJcGXdmcDy+d3mf/N0m2NjLxy8qsME+l5b4jCqLOcCP6oEE2mYiitZIKIfvpsHc7nNZKB3yc5tMRDMqKxixuz+UKFTiw==');
  441. $data['expire_time'] = date('YmdHis',time()+1800);
  442. $data['goods_name'] = StoreOrder::getProductTitle($order['cart_id']);
  443. $data['product_code'] = '02010005';
  444. $data['clear_cycle'] = 0;
  445. $data['jump_scheme'] = 'sandcash://scpay';
  446. $data['meta_option'] = json_encode([
  447. ['sc' => '','s' => 'Android', 'n' => '', 'id' => ''],
  448. ['sc' => '','s' => 'IOS', 'n' => '', 'id' => ''],
  449. ]);
  450. return app('json')->status('weixin', '订单创建成功',['order' => $data, 'orderId' => $order['order_id']]);
  451. }else {
  452. $jsConfig = OrderRepository::wxPay($order);
  453. }
  454. } catch (\Exception $e) {
  455. return app('json')->fail($e->getMessage());
  456. }
  457. if ($from == 'weixinh5') {
  458. return app('json')->status('wechat_h5_pay', ['jsConfig' => $jsConfig, 'order_id' => $order['order_id']]);
  459. } else {
  460. return app('json')->status('wechat_pay', ['jsConfig' => $jsConfig, 'order_id' => $order['order_id']]);
  461. }
  462. break;
  463. case 'yue':
  464. if (StoreOrder::yuePay($order['order_id'], $request->uid()))
  465. return app('json')->status('success', '余额支付成功');
  466. else {
  467. $error = StoreOrder::getErrorInfo();
  468. return app('json')->fail(is_array($error) && isset($error['msg']) ? $error['msg'] : $error);
  469. }
  470. break;
  471. case 'app':
  472. $res = StoreOrder::appPay($order, $request->uid());
  473. break;
  474. case 'offline':
  475. StoreOrder::createOrderTemplate($order);
  476. if (StoreOrder::setOrderTypePayOffline($order['order_id']))
  477. return app('json')->status('success', '订单创建成功');
  478. else
  479. return app('json')->status('success', '支付失败');
  480. break;
  481. case "ali":
  482. $orderInfo = StoreOrder::where('order_id', $order['order_id'])->find();
  483. if (!$orderInfo || !isset($orderInfo['paid'])) return app('json')->fail('支付订单不存在!');
  484. $orderInfo = $orderInfo->toArray();
  485. if ($orderInfo['paid']) return app('json')->fail('支付已支付!');
  486. //支付金额为0
  487. if (bcsub((float)$orderInfo['pay_price'], 0, 2) <= 0) {
  488. //创建订单jspay支付
  489. $payPriceStatus = StoreOrder::jsPayPrice($order['order_id'], $request->uid());
  490. if ($payPriceStatus)//0元支付成功
  491. return app('json')->status('success', '支付成功');
  492. else
  493. return app('json')->status('pay_error', StoreOrder::getErrorInfo());
  494. } else {
  495. try {
  496. $jsConfig = OrderRepository::aliPay($order['order_id']); //创建订单jspay
  497. } catch (\Exception $e) {
  498. return app('json')->status('pay_error', $e->getMessage());
  499. }
  500. $info['jsConfig'] = $jsConfig;
  501. return app('json')->status('ali_pay', '订单创建成功', $info);
  502. }
  503. break;
  504. case "ailpay":
  505. $data = [
  506. 'version' => '10',
  507. 'mer_no' => '6888804045113',
  508. 'mer_key' => 'Ids+y1lR4thuaHGxXaCwCLbkdFXTjze96Tua3U88ZHsvaHvYxNi7HiMBOnabYUckONdHUdUR/0g=',
  509. 'mer_order_no' => $order['order_id'].'-'.time(),
  510. 'create_time' => date('YmdHis',time()),
  511. 'order_amt' => $order['pay_price'],
  512. 'notify_url' => SystemConfigService::get('site_url').'/api/sdNotify',
  513. 'return_url' => '',
  514. 'create_ip' => str_replace('.','_', $_SERVER['REMOTE_ADDR']),
  515. 'store_id' => '000000',
  516. 'pay_extra' => '',
  517. 'accsplit_flag' => 'NO',
  518. 'sign_type' => 'MD5',
  519. ];
  520. $data['sign'] = sing($data, 'FQ7AZy8uve6bp7yed0MK2HqZ+qlwE798t0L0HZm0Xv7oBE8zyyB5QcTIc2iJcGXdmcDy+d3mf/N0m2NjLxy8qsME+l5b4jCqLOcCP6oEE2mYiitZIKIfvpsHc7nNZKB3yc5tMRDMqKxixuz+UKFTiw==');
  521. $data['expire_time'] = date('YmdHis',time()+1800);
  522. $data['goods_name'] = StoreOrder::getProductTitle($order['cart_id']);
  523. $data['product_code'] = '02020004';
  524. $data['clear_cycle'] = 0;
  525. $data['jump_scheme'] = 'sandcash://scpay';
  526. $data['meta_option'] = json_encode([
  527. ['sc' => '','s' => 'Android', 'n' => '', 'id' => ''],
  528. ['sc' => '','s' => 'IOS', 'n' => '', 'id' => ''],
  529. ]);
  530. return app('json')->status('ailpay', '订单创建成功',['order' => $data, 'orderId' => $order['order_id']]);
  531. case "ylpay":
  532. $data = [
  533. 'version' => '10',
  534. 'mer_no' => '6888804045113',
  535. 'mer_key' => 'Ids+y1lR4thuaHGxXaCwCLbkdFXTjze96Tua3U88ZHsvaHvYxNi7HiMBOnabYUckONdHUdUR/0g=',
  536. 'mer_order_no' => $order['order_id'].'-'.time(),
  537. 'create_time' => date('YmdHis',time()),
  538. 'order_amt' => $order['pay_price'],
  539. 'notify_url' => SystemConfigService::get('site_url').'/api/sdNotify',
  540. 'return_url' => '',
  541. 'create_ip' => str_replace('.','_', $_SERVER['REMOTE_ADDR']),
  542. 'store_id' => '000000',
  543. 'pay_extra' => '',
  544. 'accsplit_flag' => 'NO',
  545. 'sign_type' => 'MD5',
  546. ];
  547. $data['sign'] = sing($data, 'FQ7AZy8uve6bp7yed0MK2HqZ+qlwE798t0L0HZm0Xv7oBE8zyyB5QcTIc2iJcGXdmcDy+d3mf/N0m2NjLxy8qsME+l5b4jCqLOcCP6oEE2mYiitZIKIfvpsHc7nNZKB3yc5tMRDMqKxixuz+UKFTiw==');
  548. $data['expire_time'] = date('YmdHis',time()+1800);
  549. $data['goods_name'] = StoreOrder::getProductTitle($order['cart_id']);
  550. $data['product_code'] = '02030001';
  551. $data['clear_cycle'] = 0;
  552. $data['jump_scheme'] = 'sandcash://scpay';
  553. $data['meta_option'] = json_encode([
  554. ['sc' => '','s' => 'Android', 'n' => '', 'id' => ''],
  555. ['sc' => '','s' => 'IOS', 'n' => '', 'id' => ''],
  556. ]);
  557. return app('json')->status('ylpay', '订单创建成功',['order' => $data, 'orderId' => $order['order_id']]);
  558. }
  559. return app('json')->fail('支付方式错误');
  560. }
  561. /**
  562. * 订单列表
  563. * @param Request $request
  564. * @return mixed
  565. */
  566. public function lst(Request $request)
  567. {
  568. list($type, $page, $limit, $search) = UtilService::getMore([
  569. ['type', ''],
  570. ['page', 0],
  571. ['limit', ''],
  572. ['search', ''],
  573. ], $request, true);
  574. return app('json')->successful(StoreOrder::getUserOrderSearchList($request->uid(), $type, $page, $limit, $search));
  575. }
  576. /**
  577. * 订单详情
  578. * @param Request $request
  579. * @param $uni
  580. * @return mixed
  581. */
  582. public function detail(Request $request, $uni)
  583. {
  584. if (!strlen(trim($uni))) return app('json')->fail('参数错误');
  585. $order = StoreOrder::getUserOrderDetail($request->uid(), $uni);
  586. if (!$order) return app('json')->fail('订单不存在');
  587. $order = $order->toArray();
  588. //是否开启门店自提
  589. $store_self_mention = sys_config('store_self_mention');
  590. //关闭门店自提后 订单隐藏门店信息
  591. if ($store_self_mention == 0) $order['shipping_type'] = 1;
  592. if ($order['verify_code']) {
  593. $verify_code = $order['verify_code'];
  594. $verify[] = substr($verify_code, 0, 4);
  595. $verify[] = substr($verify_code, 4, 4);
  596. $verify[] = substr($verify_code, 8);
  597. $order['_verify_code'] = implode(' ', $verify);
  598. }
  599. $order['add_time_y'] = date('Y-m-d', $order['add_time']);
  600. $order['add_time_h'] = date('H:i:s', $order['add_time']);
  601. $order['system_store'] = SystemStore::getStoreDispose($order['store_id']);
  602. if ($order['shipping_type'] === 2 && $order['verify_code']) {
  603. $name = $order['verify_code'] . '.jpg';
  604. $imageInfo = SystemAttachment::getInfo($name, 'name');
  605. $siteUrl = sys_config('site_url');
  606. if (!$imageInfo) {
  607. $imageInfo = UtilService::getQRCodePath($order['verify_code'], $name);
  608. if (is_array($imageInfo)) {
  609. SystemAttachment::attachmentAdd($imageInfo['name'], $imageInfo['size'], $imageInfo['type'], $imageInfo['dir'], $imageInfo['thumb_path'], 1, $imageInfo['image_type'], $imageInfo['time'], 2);
  610. $url = $imageInfo['dir'];
  611. } else
  612. $url = '';
  613. } else $url = $imageInfo['att_dir'];
  614. if (isset($imageInfo['image_type']) && $imageInfo['image_type'] == 1) $url = $siteUrl . $url;
  615. $order['code'] = $url;
  616. }
  617. $order['mapKey'] = sys_config('tengxun_map_key');
  618. return app('json')->successful('ok', StoreOrder::tidyOrder($order, true, true));
  619. }
  620. /**
  621. * 订单删除
  622. * @param Request $request
  623. * @return mixed
  624. */
  625. public function del(Request $request)
  626. {
  627. list($uni) = UtilService::postMore([
  628. ['uni', ''],
  629. ], $request, true);
  630. if (!$uni) return app('json')->fail('参数错误!');
  631. $res = StoreOrder::removeOrder($uni, $request->uid());
  632. if ($res)
  633. return app('json')->successful();
  634. else
  635. return app('json')->fail(StoreOrder::getErrorInfo());
  636. }
  637. /**
  638. * 订单收货
  639. * @param Request $request
  640. * @return mixed
  641. */
  642. public function take(Request $request)
  643. {
  644. list($uni) = UtilService::postMore([
  645. ['uni', ''],
  646. ], $request, true);
  647. if (!$uni) return app('json')->fail('参数错误!');
  648. $res = StoreOrder::takeOrder($uni, $request->uid());
  649. if ($res) {
  650. $order_info = StoreOrder::where('order_id', $uni)->find();
  651. $gain_integral = intval($order_info['gain_integral']);
  652. $gain_coupon = StoreCouponIssue::alias('a')
  653. ->join('store_coupon b', 'a.cid = b.id')
  654. ->where('a.status', 1)
  655. ->where('a.is_full_give', 1)
  656. ->where('a.is_del', 0)
  657. ->where('a.full_reduction', '<=', $order_info['total_price'])
  658. ->sum('b.coupon_price');
  659. return app('json')->successful(['gain_integral' => $gain_integral, 'gain_coupon' => $gain_coupon]);
  660. } else
  661. return app('json')->fail(StoreOrder::getErrorInfo());
  662. }
  663. /**
  664. * 订单 查看物流
  665. * @param Request $request
  666. * @param $uni
  667. * @return mixed
  668. */
  669. public function express(Request $request, $uni)
  670. {
  671. if (!$uni || !($order = StoreOrder::getUserOrderDetail($request->uid(), $uni))) return app('json')->fail('查询订单不存在!');
  672. if ($order['delivery_type'] != 'express' || !$order['delivery_id']) return app('json')->fail('该订单不存在快递单号!');
  673. $cacheName = $uni . $order['delivery_id'];
  674. $result = CacheService::get($cacheName, null);
  675. if ($result === NULL) {
  676. $result = ExpressService::query($order['delivery_id']);
  677. if (is_array($result) &&
  678. isset($result['result']) &&
  679. isset($result['result']['deliverystatus']) &&
  680. $result['result']['deliverystatus'] >= 3)
  681. $cacheTime = 0;
  682. else
  683. $cacheTime = 1800;
  684. CacheService::set($cacheName, $result, $cacheTime);
  685. }
  686. $orderInfo = [];
  687. $cartInfo = StoreOrderCartInfo::where('oid', $order['id'])->column('cart_info', 'unique') ?? [];
  688. $info = [];
  689. $cartNew = [];
  690. foreach ($cartInfo as $k => $cart) {
  691. $cart = json_decode($cart, true);
  692. $cartNew['cart_num'] = $cart['cart_num'];
  693. $cartNew['truePrice'] = $cart['truePrice'];
  694. $cartNew['productInfo']['image'] = $cart['productInfo']['image'];
  695. $cartNew['productInfo']['store_name'] = $cart['productInfo']['store_name'];
  696. $cartNew['productInfo']['unit_name'] = $cart['productInfo']['unit_name'] ?? '';
  697. array_push($info, $cartNew);
  698. unset($cart);
  699. }
  700. $orderInfo['delivery_id'] = $order['delivery_id'];
  701. $orderInfo['delivery_name'] = $order['delivery_name'];
  702. $orderInfo['delivery_type'] = $order['delivery_type'];
  703. $orderInfo['cartInfo'] = $info;
  704. return app('json')->successful(['order' => $orderInfo, 'express' => $result ? $result : []]);
  705. }
  706. /**
  707. * 订单评价
  708. * @param Request $request
  709. * @return mixed
  710. * @throws \think\db\exception\DataNotFoundException
  711. * @throws \think\db\exception\ModelNotFoundException
  712. * @throws \think\exception\DbException
  713. */
  714. public function comment(Request $request)
  715. {
  716. $group = UtilService::postMore([
  717. ['unique', ''], ['comment', ''], ['pics', ''], ['product_score', 5], ['service_score', 5]
  718. ], $request);
  719. $unique = $group['unique'];
  720. unset($group['unique']);
  721. if (!$unique) return app('json')->fail('参数错误!');
  722. $cartInfo = StoreOrderCartInfo::where('unique', $unique)->find();
  723. $uid = $request->uid();
  724. $user_info = User::get($uid);
  725. $group['nickname'] = $user_info['nickname'];
  726. $group['avatar'] = $user_info['avatar'];
  727. if (!$cartInfo) return app('json')->fail('评价产品不存在!');
  728. $orderUid = StoreOrder::getOrderInfo($cartInfo['oid'], 'uid')['uid'];
  729. if ($uid != $orderUid) return app('json')->fail('评价产品不存在!');
  730. if (StoreProductReply::be(['oid' => $cartInfo['oid'], 'unique' => $unique]))
  731. return app('json')->fail('该产品已评价!');
  732. $group['comment'] = htmlspecialchars(trim($group['comment']));
  733. if ($group['product_score'] < 1) return app('json')->fail('请为产品评分');
  734. else if ($group['service_score'] < 1) return app('json')->fail('请为商家服务评分');
  735. if ($cartInfo['cart_info']['combination_id']) $productId = $cartInfo['cart_info']['product_id'];
  736. else if ($cartInfo['cart_info']['seckill_id']) $productId = $cartInfo['cart_info']['product_id'];
  737. else if ($cartInfo['cart_info']['bargain_id']) $productId = $cartInfo['cart_info']['product_id'];
  738. else $productId = $cartInfo['product_id'];
  739. if ($group['pics']) $group['pics'] = json_encode(is_array($group['pics']) ? $group['pics'] : explode(',', $group['pics']));
  740. $group = array_merge($group, [
  741. 'uid' => $uid,
  742. 'oid' => $cartInfo['oid'],
  743. 'unique' => $unique,
  744. 'product_id' => $productId,
  745. 'add_time' => time(),
  746. 'reply_type' => 'product'
  747. ]);
  748. StoreProductReply::beginTrans();
  749. $res = StoreProductReply::reply($group, 'product');
  750. if (!$res) {
  751. StoreProductReply::rollbackTrans();
  752. return app('json')->fail('评价失败!');
  753. }
  754. try {
  755. StoreOrder::checkOrderOver($cartInfo['oid']);
  756. } catch (\Exception $e) {
  757. StoreProductReply::rollbackTrans();
  758. return app('json')->fail($e->getMessage());
  759. }
  760. StoreProductReply::commitTrans();
  761. event('UserCommented', $res);
  762. event('AdminNewPush');
  763. return app('json')->successful();
  764. }
  765. /**
  766. * 订单统计数据
  767. * @param Request $request
  768. * @return mixed
  769. */
  770. public function data(Request $request)
  771. {
  772. return app('json')->successful(StoreOrder::getOrderData($request->uid()));
  773. }
  774. /**
  775. * 订单退款理由
  776. * @return mixed
  777. */
  778. public function refund_reason()
  779. {
  780. $reason = sys_config('stor_reason') ?: [];//退款理由
  781. $reason = str_replace("\r\n", "\n", $reason);//防止不兼容
  782. $reason = explode("\n", $reason);
  783. return app('json')->successful($reason);
  784. }
  785. /**
  786. * 订单退款审核
  787. * @param Request $request
  788. * @return mixed
  789. */
  790. public function refund_verify(Request $request)
  791. {
  792. $data = UtilService::postMore([
  793. ['text', ''],
  794. ['refund_reason_wap_img', ''],
  795. ['refund_reason_wap_explain', ''],
  796. ['uni', '']
  797. ], $request);
  798. $uni = $data['uni'];
  799. unset($data['uni']);
  800. if ($data['refund_reason_wap_img']) $data['refund_reason_wap_img'] = explode(',', $data['refund_reason_wap_img']);
  801. if (!$uni || $data['text'] == '') return app('json')->fail('参数错误!');
  802. $res = StoreOrder::orderApplyRefund($uni, $request->uid(), $data['text'], $data['refund_reason_wap_explain'], $data['refund_reason_wap_img']);
  803. if ($res)
  804. return app('json')->successful('提交申请成功');
  805. else
  806. return app('json')->fail(StoreOrder::getErrorInfo());
  807. }
  808. /**
  809. * 订单取消 未支付的订单回退积分,回退优惠券,回退库存
  810. * @param Request $request
  811. * @return mixed
  812. * @throws \think\db\exception\DataNotFoundException
  813. * @throws \think\db\exception\ModelNotFoundException
  814. * @throws \think\exception\DbException
  815. */
  816. public function cancel(Request $request)
  817. {
  818. list($id) = UtilService::postMore([['id', 0]], $request, true);
  819. if (!$id) return app('json')->fail('参数错误');
  820. if (StoreOrder::cancelOrder($id, $request->uid()))
  821. return app('json')->successful('取消订单成功');
  822. return app('json')->fail(StoreOrder::getErrorInfo('取消订单失败'));
  823. }
  824. /**
  825. * 订单产品信息
  826. * @param Request $request
  827. * @return mixed
  828. * @throws \think\db\exception\DataNotFoundException
  829. * @throws \think\db\exception\ModelNotFoundException
  830. * @throws \think\exception\DbException
  831. */
  832. public function product(Request $request)
  833. {
  834. list($unique) = UtilService::postMore([['unique', '']], $request, true);
  835. if (!$unique || !StoreOrderCartInfo::be(['unique' => $unique]) || !($cartInfo = StoreOrderCartInfo::where('unique', $unique)->find())) return app('json')->fail('评价产品不存在!');
  836. $cartInfo = $cartInfo->toArray();
  837. $cartProduct = [];
  838. $cartProduct['cart_num'] = $cartInfo['cart_info']['cart_num'];
  839. $cartProduct['productInfo']['image'] = isset($cartInfo['cart_info']['productInfo']['image']) ? $cartInfo['cart_info']['productInfo']['image'] : '';
  840. $cartProduct['productInfo']['price'] = isset($cartInfo['cart_info']['productInfo']['price']) ? $cartInfo['cart_info']['productInfo']['price'] : 0;
  841. $cartProduct['productInfo']['store_name'] = isset($cartInfo['cart_info']['productInfo']['store_name']) ? $cartInfo['cart_info']['productInfo']['store_name'] : '';
  842. if (isset($cartInfo['cart_info']['productInfo']['attrInfo'])) {
  843. $cartProduct['productInfo']['attrInfo']['product_id'] = isset($cartInfo['cart_info']['productInfo']['attrInfo']['product_id']) ? $cartInfo['cart_info']['productInfo']['attrInfo']['product_id'] : '';
  844. $cartProduct['productInfo']['attrInfo']['suk'] = isset($cartInfo['cart_info']['productInfo']['attrInfo']['suk']) ? $cartInfo['cart_info']['productInfo']['attrInfo']['suk'] : '';
  845. $cartProduct['productInfo']['attrInfo']['price'] = isset($cartInfo['cart_info']['productInfo']['attrInfo']['price']) ? $cartInfo['cart_info']['productInfo']['attrInfo']['price'] : '';
  846. $cartProduct['productInfo']['attrInfo']['image'] = isset($cartInfo['cart_info']['productInfo']['attrInfo']['image']) ? $cartInfo['cart_info']['productInfo']['attrInfo']['image'] : '';
  847. }
  848. $cartProduct['product_id'] = isset($cartInfo['cart_info']['product_id']) ? $cartInfo['cart_info']['product_id'] : 0;
  849. $cartProduct['combination_id'] = isset($cartInfo['cart_info']['combination_id']) ? $cartInfo['cart_info']['combination_id'] : 0;
  850. $cartProduct['seckill_id'] = isset($cartInfo['cart_info']['seckill_id']) ? $cartInfo['cart_info']['seckill_id'] : 0;
  851. $cartProduct['bargain_id'] = isset($cartInfo['cart_info']['bargain_id']) ? $cartInfo['cart_info']['bargain_id'] : 0;
  852. $cartProduct['order_id'] = StoreOrder::where('id', $cartInfo['oid'])->value('order_id');
  853. return app('json')->successful($cartProduct);
  854. }
  855. /**
  856. * 首页获取未支付订单
  857. */
  858. public function get_noPay(Request $request)
  859. {
  860. return app('json')->successful(StoreOrder::getUserOrderSearchList($request->uid(), 0, 0, 0, ''));
  861. }
  862. }