OrderController.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. <?php
  2. namespace ghs\controllers;
  3. use biz\sj\services\MerchantExtendService;
  4. use bizGhs\express\services\DadaExpressServices;
  5. use bizHd\wx\classes\WxOpenClass;
  6. use bizGhs\admin\classes\AdminClass;
  7. use bizGhs\custom\classes\CustomClass;
  8. use bizGhs\merchant\services\ShopService;
  9. use bizGhs\order\classes\OrderClass;
  10. use bizGhs\order\services\OrderService;
  11. use bizHd\saas\services\RegionService;
  12. use bizGhs\product\classes\ProductClass;
  13. use common\components\dict;
  14. use common\components\dateUtil;
  15. use common\components\httpUtil;
  16. use common\services\xhPayToolService;
  17. use Yii;
  18. use common\components\util;
  19. use common\components\stringUtil;
  20. class OrderController extends BaseController
  21. {
  22. public $guestAccess = ['create-order', 'order-relate', 'fast-pay'];
  23. //订单列表 ssh 2021.1.20
  24. public function actionList()
  25. {
  26. $get = Yii::$app->request->get();
  27. $status = $get['status'] ?? 0;
  28. if (!empty($status)) {
  29. $where['status'] = $status;
  30. }
  31. $where['merchantId'] = $this->sjId;
  32. if (isset($get['shopId'])) {
  33. $shopId = $get['shopId'] ?? 0;
  34. if (!empty($shopId)) {
  35. $where['shopId'] = $this->shopId;
  36. }
  37. } else {
  38. $where['shopId'] = $this->shopId;
  39. }
  40. $searchTime = $get['searchTime'] ?? '';
  41. if (!empty($searchTime)) {
  42. $startTime = $get['startTime'] ?? '';
  43. $endTime = $get['endTime'] ?? '';
  44. $period = dateUtil::formatTime($searchTime, $startTime, $endTime);
  45. $where['addTime'] = ['between', [$period['startTime'], $period['endTime']]];
  46. }
  47. $name = $get['name'] ?? '';
  48. if (!empty($name)) {
  49. if (preg_match("/^[a-zA-Z\s]+$/", $name)) {
  50. $where['customNamePy'] = ['like', $name];
  51. } else {
  52. $where['customName'] = ['like', $name];
  53. }
  54. }
  55. $respond = OrderClass::getOrderList($where);
  56. $shop = $this->shop;
  57. $respond['allNum'] = $shop['totalOrder'] ?? 0;
  58. $respond['unPayNum'] = $shop['unPayOrder'] ?? 0;
  59. $respond['unSendNum'] = $shop['unSendOrder'] ?? 0;
  60. $respond['sendingNum'] = $shop['sendingOrder'] ?? 0;
  61. $respond['finishNum'] = $shop['finishOrder'] ?? 0;
  62. util::success($respond);
  63. }
  64. //商城下单操作 ssh 2021.1.14
  65. public function actionCreateOrder()
  66. {
  67. $post = Yii::$app->request->post();
  68. $shopId = $this->shopId;
  69. $customId = $post['customId'] ?? 0;
  70. $post['customId'] = $customId;
  71. //开单必须选客户
  72. if (empty($customId)) {
  73. util::fail('请选择客户');
  74. }
  75. $custom = CustomClass::getCustom($customId);
  76. if (empty($custom)) {
  77. util::fail('请选客户哦');
  78. }
  79. CustomClass::valid($custom, $this->shopId);
  80. $post['ghsId'] = $custom['ghsId'] ?? 0;
  81. $post['customMobile'] = $custom['mobile'] ?? '';
  82. $customName = $custom['name'] ?? '';
  83. $post['customName'] = $customName;
  84. $post['customNamePy'] = $custom['py'] ?? '';
  85. $post['customAvatar'] = $custom['shortSmallAvatar'] ?? '';
  86. $post['shopAdminId'] = $this->shopAdminId;
  87. $shopAdmin = $this->shopAdmin;
  88. $post['shopAdminName'] = $shopAdmin['name'] ?? '';
  89. $post['merchantId'] = $this->sjId;
  90. $post['shopId'] = $shopId;
  91. $post['payWay'] = $this->isWx == true ? 0 : 1;
  92. $post['merchantId'] = $this->sjId;
  93. $post['fromType'] = 1;
  94. $post['expressId'] = $post['expressId'] ?? 0;
  95. $post['clearType'] = $post['clearType'] ?? OrderClass::CLEAR_DEBT;
  96. $productJson = $post['product'] ?? '';
  97. if (empty($productJson)) {
  98. util::fail('请选择花材');
  99. }
  100. $productList = json_decode($productJson, true);
  101. if (empty($productList)) {
  102. util::fail('请选择花材');
  103. }
  104. $connection = Yii::$app->db;//事务处理
  105. $transaction = $connection->beginTransaction();
  106. try {
  107. //判断花材有效性
  108. ProductClass::valid($productList, $this->shopId);
  109. $post['product'] = $productList;
  110. $return = OrderService::createOrder($post, $custom);
  111. $transaction->commit();
  112. util::success($return);
  113. } catch (\Exception $e) {
  114. $transaction->rollBack();
  115. Yii::info("下单失败原因:" . $e->getMessage());
  116. util::fail('下单失败');
  117. }
  118. }
  119. //延期支付 ssh 2021.1.19
  120. public function actionDebt()
  121. {
  122. $get = Yii::$app->request->get();
  123. $id = $get['id'] ?? 0;
  124. $info = OrderClass::getOrderInfo($id);
  125. OrderClass::valid($info, $this->shopId);
  126. OrderClass::debt($info, $this->shop);
  127. util::complete();
  128. }
  129. //获取商城下单要用的微信支付和小程序支付参数 ssh 2019.21.3
  130. public function actionWxPay()
  131. {
  132. ini_set('date.timezone', 'Asia/Shanghai');
  133. $post = Yii::$app->request->post();
  134. $couponId = $post['couponId'] ?? 0;
  135. $orderSn = isset($post['orderSn']) ? $post['orderSn'] : 0;
  136. $order = OrderClass::getByOrderSn($orderSn);
  137. if (empty($order)) {
  138. util::fail('订单号无效');
  139. }
  140. $id = $order['id'];
  141. //支付前验证订单有效性
  142. if (isset($order['adminId']) == false || $order['adminId'] != $this->adminId) {
  143. util::fail('没有权限操作');
  144. }
  145. $name = $order['orderName'] ?? '购买商品';
  146. $totalFee = $order['actPrice'];
  147. //强制使用小程序的miniOpenId
  148. $openId = $this->admin['miniOpenId'];
  149. $capitalType = dict::getDict('capitalType', 'xhGhsOrder', 'id');
  150. //流水类型、优惠卷、微信支付(h5还是小程序支付)类型 带到回调
  151. $wxPayType = 0;
  152. if (httpUtil::isMiniProgram()) {
  153. $wxPayType = 1;
  154. }
  155. $attach = "couponId=" . $couponId . "&capitalType=" . $capitalType . '&wxPayType=' . $wxPayType;
  156. //订单30分钟后过期
  157. $now = time();
  158. $expireTime = $now + 1800;
  159. $wx = Yii::getAlias("@vendor/weixin");
  160. require_once($wx . '/lib/WxPay.Api.php');
  161. require_once($wx . '/example/WxPay.JsApiPay.php');
  162. $input = new \WxPayUnifiedOrder();
  163. $input->SetBody($name);
  164. $input->SetOut_trade_no($orderSn);
  165. $input->SetTotal_fee($totalFee * 100);
  166. $input->SetTime_start(date("YmdHis", $now));
  167. $input->SetAttach($attach);//将流水类型、代金劵等传给微信再回传
  168. $input->SetTime_expire(date("YmdHis", $expireTime));
  169. $input->SetNotify_url(Yii::$app->params['ghsHost'] . '/notice/wx-callback/');
  170. $input->SetTrade_type("JSAPI");
  171. //花卉宝代为申请的微信支付
  172. //$merchantExtend = $this->sjExtend;
  173. $merchantExtend = WxOpenClass::getGhsWxInfo();
  174. if (isset($merchantExtend['wxPayApply']) && $merchantExtend['wxPayApply'] == 1) {
  175. $input->SetSub_openid($openId);
  176. } else {
  177. $input->SetOpenid($openId);
  178. }
  179. //强制使用小程序的miniAppId
  180. $merchantExtend['wxAppId'] = $merchantExtend['miniAppId'];
  181. $wxOrder = \WxPayApi::unifiedOrder($input, 6, $merchantExtend);
  182. $tools = new \JsApiPay();
  183. $jsApiParameters = $tools->GetJsApiParameters($wxOrder, $merchantExtend);
  184. $newParams = json_decode($jsApiParameters, true);
  185. //微信不能修改价格
  186. $current = date("Y-m-d H:i:s");
  187. $updateData = ['deadline' => $current, 'modPrice' => 0];
  188. OrderClass::updateById($id, $updateData);
  189. util::success($newParams);
  190. }
  191. //获取订单详情 ssh 2021.1.21
  192. public function actionDetail()
  193. {
  194. $get = Yii::$app->request->get();
  195. $id = $get['id'] ?? 0;
  196. $info = OrderClass::getOrderInfo($id, true, true, true, false);
  197. OrderClass::valid($info, $this->shopId);
  198. util::success($info);
  199. }
  200. //自取和免发货流程处理 ssh 2021.1.22
  201. public function actionWithoutSend()
  202. {
  203. $get = Yii::$app->request->get();
  204. $id = $get['id'] ?? 0;
  205. $info = OrderClass::getOrderInfo($id);
  206. OrderClass::valid($info, $this->shopId);
  207. OrderClass::withoutSend($info);
  208. util::complete();
  209. }
  210. //本店送 ssh 2021.1.24
  211. public function actionSelfSend()
  212. {
  213. $get = Yii::$app->request->get();
  214. $id = isset($get['id']) ? $get['id'] : 0;
  215. $info = OrderClass::getOrderInfo($id);
  216. OrderClass::valid($info, $this->shopId);
  217. $connection = Yii::$app->db;
  218. $transaction = $connection->beginTransaction();
  219. try {
  220. OrderClass::selfSend($info);
  221. $transaction->commit();
  222. } catch (\Exception $exception) {
  223. $transaction->rollBack();
  224. Yii::info("本店送操作报错:" . $exception->getMessage());
  225. util::fail('操作失败');
  226. }
  227. util::complete();
  228. }
  229. //运费计算 ssh 2021.1.24
  230. public function actionFreight()
  231. {
  232. //2021.3.28 接入达达
  233. $get = Yii::$app->request->get();
  234. $post = Yii::$app->request->post();
  235. if (empty($get)) {
  236. $get = $post;
  237. }
  238. $orderId = $get['id'] ?? 0; //订单ID
  239. $customId = $get['customId'] ?? 0;
  240. if (!empty($customId)) {
  241. util::success(['sedCost' => 27]);
  242. }
  243. if (empty($orderId)) {
  244. util::success(['sedCost' => 10]);
  245. }
  246. $province = $get['province'] ?? '';
  247. $city = $get['city'] ?? '';
  248. $address = $get['address'] ?? '';
  249. $floor = $get['floor'] ?? '';
  250. $customName = $get['customName'] ?? '';
  251. $customMobile = $get['customMobile'] ?? '';
  252. $fullAddress = $province . $city . $address . $floor;
  253. $sendTime = $get['sendTime'] ?? '';
  254. $lat = $get['lat'] ?? '';
  255. $lng = $get['long'] ?? '';
  256. if (empty($lat) || empty($lng) || empty($fullAddress)) {
  257. util::fail('请选择配送地址');
  258. }
  259. if (!empty($sendTime)) {
  260. //配送时间不为空
  261. // 预约发单时间(预约时间unix时间戳(10位),精确到分;整分钟为间隔,并且需要至少提前5分钟预约
  262. $sendTimeInt = strtotime($sendTime);
  263. $now = time();
  264. $diff = $sendTimeInt - $now;
  265. //因服务器写入时间,改为至少提前6分钟
  266. if ($diff <= 360) {
  267. util::fail('配送时间至少提前6分钟');
  268. }
  269. }
  270. //更新订单表
  271. $info = OrderClass::getOrderInfo($orderId);
  272. OrderClass::valid($info, $this->shopId);
  273. $expressAddInfo = [
  274. 'customName' => $customName,
  275. 'customMobile' => $customMobile,
  276. 'province' => $province,
  277. 'city' => $city,
  278. 'address' => $address,
  279. 'floor' => $floor,
  280. 'lat' => $lat,
  281. 'long' => $lng,
  282. 'sendTime' => date('Y-m-d H:i', strtotime($sendTime)),
  283. ];
  284. OrderClass::updateCustomExpressInfo($orderId, $expressAddInfo);
  285. //计算运费
  286. $info['province'] = $province;
  287. $info['city'] = $city;
  288. $info['address'] = $address;
  289. $info['floor'] = $floor;
  290. $info['fullAddress'] = $fullAddress;
  291. $info['lat'] = $lat;
  292. $info['long'] = $lng;
  293. $info['sendTime'] = $expressAddInfo['sendTime'];
  294. $res = DadaExpressServices::queryDeliverFee($info);
  295. util::success(['sedCost' => $res['fee']]);
  296. }
  297. //发快递和第三方配送 ssh 2021.1.24
  298. public function actionThirdSend()
  299. {
  300. $get = Yii::$app->request->get();
  301. $id = isset($get['id']) ? $get['id'] : 0;
  302. $info = OrderClass::getOrderInfo($id);
  303. OrderClass::valid($info, $this->shopId);
  304. $connection = Yii::$app->db;
  305. $transaction = $connection->beginTransaction();
  306. try {
  307. $respond = OrderClass::thirdSend($info, $get);
  308. $transaction->commit();
  309. util::success($respond);
  310. } catch (\Exception $exception) {
  311. $transaction->rollBack();
  312. Yii::info("发快递操作报错:" . $exception->getMessage());
  313. util::fail('操作失败' . $exception->getMessage());
  314. }
  315. }
  316. //确认送达 ssh 2021.1.24
  317. public function actionReach()
  318. {
  319. $get = Yii::$app->request->get();
  320. $id = isset($get['id']) ? $get['id'] : 0;
  321. $info = OrderClass::getOrderInfo($id);
  322. OrderClass::valid($info, $this->shopId);
  323. $connection = Yii::$app->db;
  324. $transaction = $connection->beginTransaction();
  325. try {
  326. OrderClass::reach($info);
  327. $transaction->commit();
  328. } catch (\Exception $exception) {
  329. $transaction->rollBack();
  330. Yii::info("送达操作报错:" . $exception->getMessage());
  331. util::fail('操作失败');
  332. }
  333. util::complete();
  334. }
  335. //快捷付款订单
  336. public function actionFastPay()
  337. {
  338. ini_set('date.timezone', 'Asia/Shanghai');
  339. $post = Yii::$app->request->post();
  340. $payWay = isset($post['payWay']) ? $post['payWay'] : 0;
  341. $post['shopId'] = 2;
  342. //默认门店订单
  343. $store = isset($post['store']) ? $post['store'] : 1;
  344. $post['store'] = $store;
  345. $fromType = $post['fromType'] ?? 1;
  346. $post['userId'] = $this->adminId;
  347. $admin = $this->admin;
  348. $post['bookName'] = isset($admin['name']) ? $admin['name'] : '';
  349. $bookMobile = isset($post['bookMobile']) && !empty($post['bookMobile']) && stringUtil::isMobile($post['bookMobile']) ? $post['bookMobile'] : '';
  350. $bookMobile = empty($bookMobile) && isset($admin['mobile']) && !empty($admin['mobile']) ? $admin['mobile'] : $bookMobile;
  351. $post['bookMobile'] = $bookMobile;
  352. $prePrice = round($post['prePrice'], 2);
  353. $couponId = isset($post['couponId']) ? $post['couponId'] : 0;
  354. $sourceType = 0;
  355. $discountData = OrderService::getDiscountPrice(['price' => $prePrice, 'sourceType' => $sourceType, 'couponId' => $couponId, 'userId' => $this->adminId]);
  356. $actPrice = $discountData['price'];
  357. $post['discountType'] = $discountData['discountType'];
  358. $post['discountAmount'] = $discountData['discountAmount'];
  359. $post['actPrice'] = $actPrice;
  360. $post['payStyle'] = 0;
  361. $post['merchantId'] = $this->sjId;
  362. $now = time();
  363. //订单5分钟后过期
  364. $expireTime = $now + 300;
  365. $post['createTime'] = date("Y-m-d H:i:s", $now);
  366. $post['deadline'] = $expireTime;
  367. if ($actPrice <= 0) {
  368. util::fail('请填写正确的金额');
  369. }
  370. //微信支付订单提交不能修改价格
  371. $post['modPrice'] = $this->isWx ? 0 : 1;
  372. $post['sourceType'] = $sourceType;
  373. $post['goodsNum'] = 1;
  374. $post['fromType'] = $fromType;
  375. $post['product'] = [];
  376. $order = OrderClass::addOrder($post);
  377. $id = $order['id'];
  378. $orderSn = $order['orderSn'];
  379. $merchantId = $this->sjId;
  380. if ($payWay == 0) {
  381. $id = $order['id'];
  382. $name = '购买商品';
  383. $totalFee = $actPrice;
  384. $admin = AdminClass::getAdminById($this->adminId);
  385. //小程序使用miniOpenId
  386. $openId = $admin['miniOpenId'];
  387. $capitalType = dict::getDict('capitalType', 'xhGhsOrder', 'id');
  388. //流水类型、优惠卷、微信支付(h5还是小程序支付)类型 带到回调
  389. $wxPayType = 0;
  390. if (httpUtil::isMiniProgram()) {
  391. $wxPayType = 1;
  392. }
  393. $attach = 'capitalType=' . $capitalType . '&couponId=' . $couponId . '&wxPayType=' . $wxPayType;
  394. $wx = Yii::getAlias("@vendor/weixin");
  395. require_once($wx . '/lib/WxPay.Api.php');
  396. require_once($wx . '/example/WxPay.JsApiPay.php');
  397. $input = new \WxPayUnifiedOrder();
  398. $input->SetBody($name);
  399. $input->SetOut_trade_no($orderSn);
  400. $input->SetTotal_fee($totalFee * 100);
  401. $input->SetTime_start(date("YmdHis", $now));
  402. $input->SetAttach($attach);
  403. //设置订单有效期5分钟
  404. $input->SetTime_expire(date("YmdHis", $expireTime));
  405. $input->SetNotify_url(Yii::$app->params['ghsHost'] . '/notice/wx-callback/');
  406. $input->SetTrade_type("JSAPI");
  407. //花卉宝代为申请的微信支付
  408. //$merchantExtend = $this->sjExtend;
  409. $merchantExtend = WxOpenClass::getGhsWxInfo();
  410. if (isset($merchantExtend['wxPayApply']) && $merchantExtend['wxPayApply'] == 1) {
  411. $input->SetSub_openid($openId);
  412. } else {
  413. $input->SetOpenid($openId);
  414. }
  415. //小程序使用miniAppId
  416. if (httpUtil::isMiniProgram()) {
  417. $merchantExtend['wxAppId'] = $merchantExtend['miniAppId'];
  418. }
  419. //强制使用小程序的appId
  420. $merchantExtend['wxAppId'] = $merchantExtend['miniAppId'];
  421. Yii::info('支付发起使用小程序信息' . json_encode($merchantExtend));
  422. $wxOrder = \WxPayApi::unifiedOrder($input, 6, $merchantExtend);
  423. $tools = new \JsApiPay();
  424. $jsApiParameters = $tools->GetJsApiParameters($wxOrder, $merchantExtend);
  425. $newParams = json_decode($jsApiParameters, true);
  426. $newParams['orderId'] = $id;
  427. util::success($newParams);
  428. } elseif ($payWay == 1) {
  429. $extend = MerchantExtendService::getByMerchantId($merchantId);
  430. if (isset($extend['alipayInit']) == false || $extend['alipayInit'] == 0) {
  431. util::fail('支付宝付款即将开通...');
  432. }
  433. $config = [
  434. //应用ID,您的APPID。
  435. 'app_id' => $extend['alipayPId'],
  436. //商户私钥,您的原始格式RSA私钥
  437. 'merchant_private_key' => $extend['alipayKey'],
  438. //异步通知地址
  439. 'notify_url' => Yii::$app->params['ghsHost'] . "/notice/ali-callback",
  440. //同步跳转
  441. 'return_url' => "",
  442. //编码格式
  443. 'charset' => "UTF-8",
  444. //签名方式
  445. 'sign_type' => "RSA2",
  446. //支付宝网关
  447. 'gatewayUrl' => "https://openapi.alipay.com/gateway.do",
  448. //支付宝公钥,查看地址:https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。
  449. 'alipay_public_key' => $extend['alipayPublicKey'],
  450. ];
  451. Yii::info(json_encode($config) . ' aplipay config');
  452. $alipayWap = Yii::getAlias("@vendor/alipayWap");
  453. require_once($alipayWap . '/wappay/service/AlipayTradeService.php');
  454. require_once($alipayWap . '/wappay/buildermodel/AlipayTradeWapPayContentBuilder.php');
  455. $totalFee = $order['actPrice'];
  456. $out_trade_no = $orderSn;//商户订单号,商户网站订单系统中唯一订单号,必填
  457. $subject = '购买商品';//订单名称,必填
  458. $total_amount = $totalFee;//付款金额,必填
  459. $body = '';//商品描述,可空
  460. $timeout_express = "1m";//超时时间
  461. $capitalType = dict::getDict('capitalType', 'xhGhsOrder', 'id');
  462. $passBackParams = 'capitalType=' . $capitalType . '&couponId=' . $couponId . '&merchantId=' . $merchantId;//将流水类型、优惠卷传过去
  463. $passBackParams = urlencode($passBackParams);
  464. $payRequestBuilder = new \AlipayTradeWapPayContentBuilder();
  465. $payRequestBuilder->setBody($body);
  466. $payRequestBuilder->setSubject($subject);
  467. $payRequestBuilder->setOutTradeNo($out_trade_no);
  468. $payRequestBuilder->setTotalAmount($total_amount);
  469. $payRequestBuilder->setTimeExpress($timeout_express);
  470. //在异步通知时将该参数原样返回
  471. $payRequestBuilder->setPassbackParams($passBackParams);
  472. //同步通知
  473. $returnUrl = Yii::$app->params['mallDomain'] . "/#/pages/callback/success?account={$merchantId}&shopId={$shopId}&orderSn={$orderSn}&totalPrice={$totalFee}&pageStatus=3&payDiscountPrice=0&payDiscountType=0";
  474. //异步通知
  475. $notifyUrl = Yii::$app->params['ghsHost'] . "/notice/ali-callback";
  476. $payResponse = new \AlipayTradeService($config);
  477. $result = $payResponse->wapPay($payRequestBuilder, $returnUrl, $notifyUrl);
  478. //直接将支付宝的html返回给前端
  479. echo $result;
  480. } elseif ($payWay == 2) {
  481. $capitalType = dict::getDict('capitalType', 'xhGhsOrder', 'id');
  482. $callbackParams = [];
  483. $respond = xhPayToolService::balancePay($callbackParams, $orderSn, $actPrice, $capitalType, $couponId);
  484. $balance = isset($respond['balance']) ? $respond['balance'] : 0;
  485. util::success(['discountAmount' => $discountData['discountAmount'], 'discountType' => $discountData['discountType'], 'orderSn' => $orderSn, 'orderId' => $id, 'balance' => $balance]);
  486. } else {
  487. util::fail('无效的支付方式');
  488. }
  489. }
  490. //下单要用到的相关信息 ssh 2019.12.6
  491. public function actionOrderRelate()
  492. {
  493. $regionTree = RegionService::tree();
  494. $shop = ShopService::getDefaultShop($this->sj);
  495. $freight = ['first' => 5, 'add' => 2];
  496. $mapKey = 'OFWBZ-2NTHP-EHNDD-LKWQY-GANM7-PXBJH';
  497. $out = ['freight' => $freight, 'shop' => $shop, 'region' => $regionTree, 'txMapKey' => $mapKey, 'merchant' => $this->sj];
  498. util::success($out);
  499. }
  500. //客户欠款的订单 ssh 2021.2.4
  501. public function actionDebtList()
  502. {
  503. $id = Yii::$app->request->get('id', 0);
  504. $info = CustomClass::getCustom($id);
  505. CustomClass::valid($info, $this->shopId);
  506. $where = ['customId' => $id, 'debt' => 1];
  507. $respond = OrderService::getDebtOrderList($where);
  508. $respond['customInfo'] = $info;
  509. util::success($respond);
  510. }
  511. }