OrderController.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. <?php
  2. namespace hd\controllers;
  3. use biz\sj\services\MerchantAssetService;
  4. use biz\sj\services\MerchantExtendService;
  5. use biz\sj\services\MerchantService;
  6. use bizGhs\product\classes\ProductClass;
  7. use bizHd\custom\classes\CustomClass;
  8. use bizHd\merchant\services\ShopService;
  9. use bizHd\order\classes\OrderClass;
  10. use bizHd\order\classes\OrderSendClass;
  11. use bizHd\order\services\OrderService;
  12. use bizHd\saas\services\RegionService;
  13. use bizHd\user\services\UserService;
  14. use bizGhs\order\classes\OrderItemClass;
  15. use common\components\dict;
  16. use common\components\dateUtil;
  17. use common\services\xhPayToolService;
  18. use Yii;
  19. use common\components\util;
  20. use common\components\stringUtil;
  21. use bizHd\goods\services\GoodsService;
  22. use bizHd\merchant\services\ExpressService;
  23. use bizHd\order\services\OrderGoodsService;
  24. use bizHd\promote\services\CouponService;
  25. use common\components\httpUtil;
  26. class OrderController extends BaseController
  27. {
  28. public $guestAccess = ['order-relate', 'fast-pay', 'create-order', 'list'];
  29. //开单操作 ssh 2019.12.3
  30. public function actionCreateOrder()
  31. {
  32. $post = Yii::$app->request->post();
  33. $post['sjId'] = $this->sjId;
  34. $post['shopId'] = $this->shopId;
  35. $post['payWay'] = $this->isWx == true ? 0 : 1;
  36. $now = time();
  37. //订单30分钟后过期
  38. $expireTime = $now + 1800;
  39. $post['deadline'] = $expireTime;
  40. //商城
  41. $post['fromType'] = 1;
  42. // $payWay = $post['payWay'] ?? dict::getDict('payWay', 'wxPay');
  43. // OrderClass::staffKdPay($payWay, $orderSn);
  44. // util::success(['orderSn' => $orderSn, 'totalPrice' => $currentPrice, 'couponId' => $couponId, 'orderId' => $orderId]);
  45. }
  46. //下单要用到的相关信息 ssh 2019.12.6
  47. public function actionOrderRelate()
  48. {
  49. $regionTree = RegionService::tree();
  50. $shop = $this->shop->attributes;
  51. $freight = MerchantExtendService::getFreight($this->sjExtend);
  52. $mapKey = 'OFWBZ-2NTHP-EHNDD-LKWQY-GANM7-PXBJH';
  53. $out = ['freight' => $freight, 'shop' => $shop, 'region' => $regionTree, 'txMapKey' => $mapKey, 'merchant' => $shop];
  54. util::success($out);
  55. }
  56. //余额支付 ssh 2019.12.6
  57. public function actionBalancePay()
  58. {
  59. $post = Yii::$app->request->post();
  60. $orderSn = isset($post['orderSn']) ? $post['orderSn'] : 0;
  61. $payPassword = isset($post['payPassword']) ? $post['payPassword'] : 0;
  62. $couponId = isset($post['couponId']) ? $post['couponId'] : 0;
  63. //验证优惠券是否还有效
  64. if (!empty($couponId)) {
  65. CouponService::checkBeforeUse($couponId, $order['prePrice'], $order['userId']);
  66. }
  67. $order = OrderService::getByOrderSn($orderSn);
  68. $userId = $this->adminId;
  69. $user = UserService::getUserInfo($userId);
  70. //验证支付密码是否正确
  71. UserService::validPayPassword($payPassword, $user);
  72. //支付前验证订单有效性
  73. OrderService::checkBeforePay($order, $this->adminId);
  74. $capitalType = dict::getDict('capitalType', 'xhOrder', 'id');
  75. $totalFee = $order['prePrice'];
  76. $sourceType = 0;
  77. $discountData = OrderService::getDiscountPrice(['price' => $totalFee, 'sourceType' => $sourceType, 'couponId' => $couponId, 'userId' => $this->adminId]);
  78. $actPrice = $discountData['price'];
  79. $callbackParams = [];
  80. $respond = xhPayToolService::balancePay($callbackParams, $orderSn, $actPrice, $capitalType, $couponId);
  81. $balance = isset($respond['balance']) ? $respond['balance'] : 0;
  82. util::success(['discountAmount' => $discountData['discountAmount'], 'discountType' => $discountData['discountType'], 'balance' => $balance]);
  83. }
  84. //获取商城下单要用的微信支付和小程序支付参数 ssh 2019.21.3
  85. public function actionWxPay()
  86. {
  87. ini_set('date.timezone', 'Asia/Shanghai');
  88. $post = Yii::$app->request->post();
  89. $couponId = isset($post['couponId']) ? $post['couponId'] : 0;
  90. $orderSn = isset($post['orderSn']) ? $post['orderSn'] : 0;
  91. $order = OrderService::getByOrderSn($orderSn);
  92. $orderId = $order['id'];
  93. //验证优惠券是否还有效
  94. if (!empty($couponId)) {
  95. CouponService::checkBeforeUse($couponId, $order['prePrice'], $order['userId']);
  96. }
  97. //支付前验证订单有效性
  98. OrderService::checkBeforePay($order, $this->adminId);
  99. $name = isset($order['orderName']) && !empty($order['orderName']) ? $order['orderName'] : '购买商品';
  100. $totalFee = $order['realPrice'];
  101. //小程序使用miniOpenId
  102. if (httpUtil::isMiniProgram()) {
  103. $openId = $this->user['miniOpenId'];
  104. } else {
  105. $openId = $this->user['openId'];
  106. }
  107. $capitalType = dict::getDict('capitalType', 'xhOrder', 'id');
  108. //流水类型、优惠卷、微信支付(h5还是小程序支付)类型 带到回调
  109. $wxPayType = 0;
  110. if (httpUtil::isMiniProgram()) {
  111. $wxPayType = 1;
  112. }
  113. $attach = "couponId=" . $couponId . "&capitalType=" . $capitalType . '&wxPayType=' . $wxPayType;
  114. //订单30分钟后过期
  115. $now = time();
  116. $expireTime = $now + 1800;
  117. $wx = Yii::getAlias("@vendor/weixin");
  118. require_once($wx . '/lib/WxPay.Api.php');
  119. require_once($wx . '/example/WxPay.JsApiPay.php');
  120. $input = new \WxPayUnifiedOrder();
  121. $input->SetBody($name);
  122. $input->SetOut_trade_no($orderSn);
  123. $input->SetTotal_fee($totalFee * 100);
  124. $input->SetTime_start(date("YmdHis", $now));
  125. $input->SetAttach($attach);//将流水类型、代金劵等传给微信再回传
  126. $input->SetTime_expire(date("YmdHis", $expireTime));
  127. $input->SetNotify_url(Yii::$app->params['hdHost'] . '/notice/wx-callback/');
  128. $input->SetTrade_type("JSAPI");
  129. //花卉宝代为申请的微信支付
  130. $merchantExtend = $this->sjExtend->attributes;
  131. if (isset($merchantExtend['wxPayApply']) && $merchantExtend['wxPayApply'] == 1) {
  132. $input->SetSub_openid($openId);
  133. } else {
  134. $input->SetOpenid($openId);
  135. }
  136. //小程序使用miniAppId
  137. if (httpUtil::isMiniProgram()) {
  138. $merchantExtend['wxAppId'] = $merchantExtend['miniAppId'];
  139. }
  140. $wxOrder = \WxPayApi::unifiedOrder($input, 6, $merchantExtend);
  141. $tools = new \JsApiPay();
  142. $jsApiParameters = $tools->GetJsApiParameters($wxOrder, $merchantExtend);
  143. $newParams = json_decode($jsApiParameters, true);
  144. //已请求微信不能修改价格
  145. $updateData = [];
  146. $updateData['modPrice'] = 0;
  147. if (empty($order['deadline'])) {
  148. $updateData['deadline'] = $expireTime;
  149. }
  150. OrderService::updateById($orderId, $updateData);
  151. util::success($newParams);
  152. }
  153. //快捷付款订单
  154. public function actionFastPay()
  155. {
  156. ini_set('date.timezone', 'Asia/Shanghai');
  157. $post = Yii::$app->request->post();
  158. $payWay = isset($post['payWay']) ? $post['payWay'] : 0;
  159. $shopId = !empty($this->shopId) ? $this->shopId : ShopService::getDefaultShopId($this->sj);
  160. //验证门店是否有效
  161. $shopInfo = ShopService::getById($shopId);
  162. ShopService::valid($shopInfo, $this->sjId);
  163. $post['shopId'] = $shopId;
  164. //默认门店订单
  165. $store = isset($post['store']) ? $post['store'] : 1;
  166. $post['store'] = $store;
  167. //来源 0微信 1支付宝 2小程序 3朋友圈 4美团
  168. $sourceType = $this->isWx ? 0 : 1;
  169. if (httpUtil::isMiniProgram()) {
  170. $sourceType = 2;
  171. }
  172. $sourceType = isset($post['sourceType']) ? $post['sourceType'] : 0;
  173. //兼容旧系统sourceType=3表示朋友圈来源
  174. $fromType = $sourceType == 3 ? 2 : 0;
  175. $fromType = isset($post['fromType']) && !empty($post['fromType']) ? $post['fromType'] : $fromType;
  176. $post['userId'] = $this->adminId;
  177. $custom = $this->custom;
  178. $post['bookName'] = $custom['userName'] ?? '';
  179. $bookMobile = isset($post['bookMobile']) && !empty($post['bookMobile']) && stringUtil::isMobile($post['bookMobile']) ? $post['bookMobile'] : '';
  180. $bookMobile = empty($bookMobile) && isset($custom['mobile']) && !empty($custom['mobile']) ? $custom['mobile'] : $bookMobile;
  181. $post['bookMobile'] = $bookMobile;
  182. $prePrice = round($post['prePrice'], 2);
  183. $couponId = isset($post['couponId']) ? $post['couponId'] : 0;
  184. $discountData = OrderService::getDiscountPrice(['price' => $prePrice, 'sourceType' => $sourceType, 'couponId' => $couponId, 'userId' => $this->adminId]);
  185. $actPrice = $discountData['price'];
  186. $post['discountType'] = $discountData['discountType'];
  187. $post['discountAmount'] = $discountData['discountAmount'];
  188. $post['actPrice'] = $actPrice;
  189. $post['realPrice'] = $actPrice;
  190. $post['payStyle'] = 0;
  191. $post['sjId'] = $this->sjId;
  192. $now = time();
  193. $expireTime = $now + 300;//订单5分钟后过期
  194. $post['createTime'] = date("Y-m-d H:i:s", $now);
  195. $post['deadline'] = $expireTime;
  196. if ($actPrice <= 0) {
  197. util::fail('请填写正确的金额');
  198. }
  199. //微信支付订单提交不能修改价格
  200. $post['modPrice'] = $this->isWx ? 0 : 1;
  201. $post['sourceType'] = $sourceType;
  202. $post['goodsNum'] = 1;
  203. $post['fromType'] = $fromType;
  204. $order = OrderService::addOrder($post);
  205. $orderId = $order['id'];
  206. $orderSn = $order['orderSn'];
  207. $sjId = $this->sjId;
  208. if ($payWay == 0) {
  209. $orderId = $order['id'];
  210. $name = '购买商品';
  211. $totalFee = $actPrice;
  212. $user = UserService::getById($this->adminId);
  213. $openId = isset($user['openId']) ? $user['openId'] : 0;
  214. if (httpUtil::isMiniProgram()) {
  215. //小程序使用miniOpenId
  216. $openId = $user['miniOpenId'];
  217. }
  218. if (empty($openId)) {
  219. util::fail('没有找到客户的openId');
  220. }
  221. $capitalType = dict::getDict('capitalType', 'xhOrder', 'id');
  222. //流水类型、优惠卷、微信支付(h5还是小程序支付)类型 带到回调
  223. $wxPayType = 0;
  224. if (httpUtil::isMiniProgram()) {
  225. $wxPayType = 1;
  226. }
  227. $attach = 'capitalType=' . $capitalType . '&couponId=' . $couponId . '&wxPayType=' . $wxPayType;
  228. $wx = Yii::getAlias("@vendor/weixin");
  229. require_once($wx . '/lib/WxPay.Api.php');
  230. require_once($wx . '/example/WxPay.JsApiPay.php');
  231. $input = new \WxPayUnifiedOrder();
  232. $input->SetBody($name);
  233. $input->SetOut_trade_no($orderSn);
  234. $input->SetTotal_fee($totalFee * 100);
  235. $input->SetTime_start(date("YmdHis", $now));
  236. $input->SetAttach($attach);
  237. //设置订单有效期5分钟
  238. $input->SetTime_expire(date("YmdHis", $expireTime));
  239. $input->SetNotify_url(Yii::$app->params['hdHost'] . '/notice/wx-callback/');
  240. $input->SetTrade_type("JSAPI");
  241. //花卉宝代为申请的微信支付
  242. $merchantExtend = $this->sjExtend->attributes;
  243. if (isset($merchantExtend['wxPayApply']) && $merchantExtend['wxPayApply'] == 1) {
  244. $input->SetSub_openid($openId);
  245. } else {
  246. $input->SetOpenid($openId);
  247. }
  248. //小程序使用miniAppId
  249. if (httpUtil::isMiniProgram()) {
  250. $merchantExtend['wxAppId'] = $merchantExtend['miniAppId'];
  251. }
  252. Yii::info('支付发起使用小程序信息' . json_encode($merchantExtend));
  253. $wxOrder = \WxPayApi::unifiedOrder($input, 6, $merchantExtend);
  254. $tools = new \JsApiPay();
  255. $jsApiParameters = $tools->GetJsApiParameters($wxOrder, $merchantExtend);
  256. $newParams = json_decode($jsApiParameters, true);
  257. $newParams['orderId'] = $orderId;
  258. util::success($newParams);
  259. } elseif ($payWay == 1) {
  260. $extend = MerchantExtendService::getBySjId($sjId);
  261. if (isset($extend['alipayInit']) == false || $extend['alipayInit'] == 0) {
  262. util::fail('支付宝付款即将开通...');
  263. }
  264. $config = [
  265. //应用ID,您的APPID。
  266. 'app_id' => $extend['alipayPId'],
  267. //商户私钥,您的原始格式RSA私钥
  268. 'merchant_private_key' => $extend['alipayKey'],
  269. //异步通知地址
  270. 'notify_url' => Yii::$app->params['hdHost'] . "/notice/ali-callback",
  271. //同步跳转
  272. 'return_url' => "",
  273. //编码格式
  274. 'charset' => "UTF-8",
  275. //签名方式
  276. 'sign_type' => "RSA2",
  277. //支付宝网关
  278. 'gatewayUrl' => "https://openapi.alipay.com/gateway.do",
  279. //支付宝公钥,查看地址:https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。
  280. 'alipay_public_key' => $extend['alipayPublicKey'],
  281. ];
  282. Yii::info(json_encode($config) . ' aplipay config');
  283. $alipayWap = Yii::getAlias("@vendor/alipayWap");
  284. require_once($alipayWap . '/wappay/service/AlipayTradeService.php');
  285. require_once($alipayWap . '/wappay/buildermodel/AlipayTradeWapPayContentBuilder.php');
  286. $totalFee = $order['realPrice'];
  287. $out_trade_no = $orderSn;//商户订单号,商户网站订单系统中唯一订单号,必填
  288. $subject = '购买商品';//订单名称,必填
  289. $total_amount = $totalFee;//付款金额,必填
  290. $body = '';//商品描述,可空
  291. $timeout_express = "1m";//超时时间
  292. $capitalType = dict::getDict('capitalType', 'xhOrder', 'id');
  293. $passBackParams = 'capitalType=' . $capitalType . '&couponId=' . $couponId . '&sjId=' . $sjId;//将流水类型、优惠卷传过去
  294. $passBackParams = urlencode($passBackParams);
  295. $payRequestBuilder = new \AlipayTradeWapPayContentBuilder();
  296. $payRequestBuilder->setBody($body);
  297. $payRequestBuilder->setSubject($subject);
  298. $payRequestBuilder->setOutTradeNo($out_trade_no);
  299. $payRequestBuilder->setTotalAmount($total_amount);
  300. $payRequestBuilder->setTimeExpress($timeout_express);
  301. //在异步通知时将该参数原样返回
  302. $payRequestBuilder->setPassbackParams($passBackParams);
  303. //同步通知
  304. $returnUrl = Yii::$app->params['mallDomain'] . "/#/pages/callback/success?account={$sjId}&shopId={$shopId}&orderSn={$orderSn}&totalPrice={$totalFee}&pageStatus=3&payDiscountPrice=0&payDiscountType=0";
  305. //异步通知
  306. $notifyUrl = Yii::$app->params['mallHost'] . "/notice/ali-callback";
  307. $payResponse = new \AlipayTradeService($config);
  308. $result = $payResponse->wapPay($payRequestBuilder, $returnUrl, $notifyUrl);
  309. //直接将支付宝的html返回给前端
  310. echo $result;
  311. } elseif ($payWay == 2) {
  312. //余额支付,验证支付密码是否正确
  313. $payPassword = isset($post['payPassword']) ? $post['payPassword'] : 0;
  314. $user = UserService::getUserInfo($this->adminId);
  315. UserService::validPayPassword($payPassword, $user);
  316. $capitalType = dict::getDict('capitalType', 'xhOrder', 'id');
  317. $callbackParams = [];
  318. $respond = xhPayToolService::balancePay($callbackParams, $orderSn, $actPrice, $capitalType, $couponId);
  319. $balance = isset($respond['balance']) ? $respond['balance'] : 0;
  320. util::success(['discountAmount' => $discountData['discountAmount'], 'discountType' => $discountData['discountType'], 'orderSn' => $orderSn, 'orderId' => $orderId, 'balance' => $balance]);
  321. } else {
  322. util::fail('无效的支付方式');
  323. }
  324. }
  325. //订单评价
  326. public function actionComment()
  327. {
  328. $post = Yii::$app->request->post();
  329. $id = $post['id'];
  330. $order = OrderService::getById($id);
  331. OrderService::valid($order, $this->shopId);
  332. if ($order['grade'] > 0) {
  333. util::fail('您已经评过了');
  334. }
  335. OrderService::comment($post);
  336. util::complete('提交成功');
  337. }
  338. //订单详情 ssh 2019.12.16
  339. public function actionDetail()
  340. {
  341. $id = Yii::$app->request->get('id', 0);
  342. $orderSn = Yii::$app->request->get('orderSn', '');
  343. $detail = [];
  344. if (!empty($id)) {
  345. $detail = OrderService::getOrderById($id);
  346. }
  347. if (!empty($orderSn)) {
  348. $detail = OrderService::getOrderBySn($orderSn);
  349. }
  350. OrderService::valid($detail, $this->shopId);
  351. //因前端未修改,这里先做一下兼容,好像打印时要调用到
  352. $detail['receiveProvince'] = $detail['province'] ?? '';
  353. $detail['receiveCity'] = $detail['city'] ?? '';
  354. $detail['receiveAddress'] = $detail['address'] ?? '';
  355. $detail['receiveFloor'] = $detail['floor'] ?? '';
  356. util::success($detail);
  357. }
  358. public function actionList()
  359. {
  360. $get = Yii::$app->request->get();
  361. $search = isset($get['search']) ? $get['search'] : '';
  362. $shopId = $this->shopId ?? 0;
  363. if (empty($shopId)) {
  364. //没有登录不显示数据
  365. util::success(['list' => [], 'moreData' => 0, 'shop' => [], 'totalNum' => 0, 'totalPage' => 0]);
  366. }
  367. $where = [];
  368. $where['shopId'] = $shopId;
  369. $status = $get['status'] ?? 0;
  370. if (!empty($status)) {
  371. $where['status'] = $get['status'];
  372. }
  373. if (!empty($search)) {
  374. if (stringUtil::isMobile($search)) {
  375. $where['bookMobile'] = $search;
  376. } else {
  377. $where['orderSn'] = $search;
  378. }
  379. }
  380. $searchTime = $get['searchTime'] ?? '';
  381. if (!empty($searchTime)) {
  382. $startTime = $get['startTime'] ?? '';
  383. $endTime = $get['endTime'] ?? '';
  384. $period = dateUtil::formatTime($searchTime, $startTime, $endTime);
  385. $where['addTime'] = ['between', [$period['startTime'], $period['endTime']]];
  386. }
  387. $list = OrderService::getOrderList($where);
  388. $list['shop'] = $this->shop->attributes ?? [];
  389. util::success($list);
  390. }
  391. //订单归类 ssh 2019.12.17
  392. public function actionClassify()
  393. {
  394. $post = Yii::$app->request->post();
  395. $id = isset($post['id']) ? $post['id'] : 0;
  396. $order = OrderService::getById($id);
  397. OrderService::valid($order, $this->shopId);
  398. $categoryId = isset($post['categoryId']) ? $post['categoryId'] : $post['categoryId'];
  399. $usageId = isset($post['usageId']) ? $post['usageId'] : $post['usageId'];
  400. OrderService::classify($id, $categoryId, $usageId);
  401. util::complete();
  402. }
  403. //更新配送单 ssh 2019.12.17
  404. public function actionUpdateSheet()
  405. {
  406. $post = Yii::$app->request->post();
  407. $id = isset($post['id']) ? $post['id'] : 0;
  408. unset($post['id']);
  409. $order = OrderService::getById($id);
  410. OrderService::valid($order, $this->shopId);
  411. OrderService::updateSheet($order, $post);
  412. util::complete('提交成功');
  413. }
  414. //商家收款与发货 ssh 2019.12.18
  415. public function actionGathering()
  416. {
  417. $post = Yii::$app->request->post();
  418. $price = isset($post['price']) && is_numeric($post['price']) ? $post['price'] : 0;
  419. $payWay = isset($post['payWay']) && is_numeric($post['payWay']) ? $post['payWay'] : 0;
  420. $userId = isset($post['userId']) ? $post['userId'] : 0;
  421. $userInfo = UserService::getById($userId);
  422. if (empty($userInfo) || $userInfo['sjId'] != $this->sjId) {
  423. util::fail('您选择的客户无效');
  424. }
  425. if ($price <= 0) {
  426. util::fail('请输入金额');
  427. }
  428. $post['prePrice'] = $price;
  429. $post['actPrice'] = $price;
  430. $post['payWay'] = $payWay;
  431. $post['sourceType'] = 1;
  432. $post['userId'] = $userId;
  433. $post['goodsNum'] = 1;
  434. $post['orderName'] = '商品';
  435. $shopId = MerchantService::getDefaultShopId($this->sj);
  436. $post['shopId'] = $shopId;
  437. $order = OrderService::addOrder($post);
  438. $id = $order['id'];
  439. $orderSn = $order['orderSn'];
  440. //流水类型列表
  441. $capitalType = dict::getDict('capitalType', 'xhOrder', 'id');
  442. $callbackParams = [];
  443. switch ($payWay) {
  444. case 0:
  445. xhPayToolService::wxPay($callbackParams, $orderSn, $price, $capitalType, 0);
  446. break;
  447. case 1:
  448. xhPayToolService::alipay($callbackParams, $orderSn, $price, $capitalType, 0, []);
  449. break;
  450. case 2:
  451. xhPayToolService::balancePay($callbackParams, $orderSn, $price, $capitalType, 0);
  452. break;
  453. default:
  454. util::fail('无效支付方式');
  455. }
  456. util::success($order);
  457. }
  458. //免发货管理 ssh 2020.1.6
  459. public function actionWithoutSend()
  460. {
  461. $id = Yii::$app->request->get('id');
  462. $order = OrderService::getById($id);
  463. OrderService::valid($order, $this->shopId);
  464. //配送流程变更
  465. $currentFlow = OrderSendClass::withoutSend($order);
  466. util::success(['currentFlow' => $currentFlow]);
  467. }
  468. //修改价格 ssh 2020.1.6
  469. public function actionUpdatePrice()
  470. {
  471. $id = Yii::$app->request->get('id');
  472. $price = Yii::$app->request->get('price', 1);
  473. $order = OrderService::getById($id);
  474. OrderService::valid($order, $this->shopId);
  475. if (isset($order['modPrice']) && $order['modPrice'] == 0) {
  476. util::fail('已发起支付,不能修改价格');
  477. }
  478. OrderService::updateById($id, ['actPrice' => $price]);
  479. util::complete('修改成功');
  480. }
  481. //配送单 ssh 2020.2.29
  482. public function actionGetDeliverDetail()
  483. {
  484. $id = Yii::$app->request->get('id', 0);
  485. $order = OrderService::getById($id);
  486. OrderService::valid($order, $this->shopId);
  487. $reachDate = isset($order['reachDate']) && !empty($order['reachDate']) ? $order['reachDate'] : '';
  488. $reachPeriodId = $order['reachPeriod'];
  489. $reachPeriodArr = [0 => '上午', 1 => '下午', 2 => '晚上'];
  490. $reachPeriod = isset($reachPeriodArr[$reachPeriodId]) ? $reachPeriodArr[$reachPeriodId] : '';
  491. $bookName = isset($order['bookName']) ? $order['bookName'] : '';
  492. $bookMobile = isset($order['bookMobile']) ? $order['bookMobile'] : '';
  493. if (isset($order['anonymity']) && $order['anonymity'] == 1) {
  494. $bookName = '--';
  495. $bookMobile = '--';
  496. }
  497. $data = [
  498. 'reachDate' => $reachDate . ' ' . $reachPeriod,
  499. 'orderSn' => $order['orderSn'],
  500. 'receiveUserName' => $order['receiveUserName'],
  501. 'receiveMobile' => $order['receiveMobile'],
  502. 'fullAddress' => $order['fullAddress'] . "(" . $order['showAddress'] . ")",
  503. 'cardInfo' => $order['cardInfo'],
  504. 'bookMobile' => $bookMobile,
  505. 'bookName' => $bookName,
  506. 'remark' => $order['remark'],
  507. 'sendNum' => $order['sendNum'],
  508. 'telephone' => 18030142050,
  509. 'printTime' => '',
  510. 'img' => '',
  511. ];
  512. util::success($data);
  513. }
  514. //运费计算 linqh 2021.4.12 暂反回固定
  515. public function actionFreight()
  516. {
  517. util::success(['sedCost' => 10]);
  518. }
  519. }