PurchaseController.php 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115
  1. <?php
  2. namespace hd\controllers;
  3. use biz\admin\classes\AdminClass;
  4. use biz\ghs\classes\GhsClass;
  5. use biz\notice\classes\NoticeClass;
  6. use biz\shop\classes\ShopClass;
  7. use biz\shop\classes\ShopExpressClass;
  8. use bizGhs\custom\classes\CustomClass;
  9. use bizGhs\express\services\DadaExpressServices;
  10. use bizGhs\order\classes\OrderClass;
  11. use bizGhs\order\classes\OrderItemClass;
  12. use bizHd\purchase\classes\PurchaseClass;
  13. use bizHd\purchase\classes\PurchaseItemClass;
  14. use bizHd\purchase\services\PurchaseService;
  15. use bizGhs\product\classes\ProductClass;
  16. use bizHd\wx\classes\WxOpenClass;
  17. use common\components\dateUtil;
  18. use common\components\dict;
  19. use common\components\freight;
  20. use common\components\httpUtil;
  21. use common\components\imgUtil;
  22. use common\components\noticeUtil;
  23. use common\components\orderSn;
  24. use Yii;
  25. use common\components\util;
  26. use biz\wx\classes\WxMessageClass;
  27. use bizGhs\order\services\OrderService;
  28. use common\components\lakala\Lakala;
  29. class PurchaseController extends BaseController
  30. {
  31. public $guestAccess = ['detail'];
  32. //确认收货 ssh 20231119
  33. public function actionConfirmTake()
  34. {
  35. $get = Yii::$app->request->get();
  36. $id = $get['id'] ?? 0;
  37. $info = PurchaseClass::getById($id, true);
  38. if (empty($info)) {
  39. util::fail('没有找到采购单');
  40. }
  41. if (isset($info->mainId) == false || $info->mainId != $this->mainId) {
  42. util::fail('无法访问');
  43. }
  44. PurchaseClass::confirmTake($info);
  45. util::complete('确认成功');
  46. }
  47. public function actionGetFullInfo()
  48. {
  49. $get = Yii::$app->request->get();
  50. $id = $get['id'] ?? 0;
  51. $info = PurchaseClass::getById($id);
  52. if (empty($info)) {
  53. util::fail('没有找到采购单');
  54. }
  55. if (isset($info['mainId']) == false || $info['mainId'] != $this->mainId) {
  56. util::fail('无法访问');
  57. }
  58. $orderSn = $info['orderSn'] ?? '';
  59. $list = PurchaseItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*');
  60. if (!empty($list)) {
  61. foreach ($list as $key => $item) {
  62. $shortCover = $item['cover'] ?? '';
  63. $cover = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_130,w_130";
  64. $bigCover = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_700,w_700";
  65. $list[$key]['cover'] = $cover;
  66. $list[$key]['bigCover'] = $bigCover;
  67. $list[$key]['shortCover'] = $shortCover;
  68. }
  69. }
  70. $info['product'] = $list;
  71. util::success($info);
  72. }
  73. //虚拟供货商的采购 ssh 20230308
  74. public function actionAddVirtualCg()
  75. {
  76. $post = Yii::$app->request->post();
  77. $ghsId = $post['ghsId'] ?? 0;
  78. $payMode = $post['payMode'] ?? 0;
  79. $payWay = $post['payWay'] ?? 0;
  80. $ghsInfo = GhsClass::getById($ghsId);
  81. if (empty($ghsInfo)) {
  82. util::fail('没有找到供货商');
  83. }
  84. if (isset($ghsInfo['mainId']) && !empty($ghsInfo['mainId']) && $ghsInfo['mainId'] == $ghsInfo['ownMainId']) {
  85. util::fail('不能向自己的店买花');
  86. }
  87. $connection = Yii::$app->db;
  88. $transaction = $connection->beginTransaction();
  89. try {
  90. $post['book'] = $post['book'] ?? 0;
  91. $post['sjId'] = $this->sjId;
  92. $post['shopId'] = $this->shopId;
  93. $post['shopAdminId'] = $this->shopAdminId;
  94. $post['ghsId'] = $ghsId;
  95. $post['ghsName'] = $ghsInfo['name'] ?? '';
  96. $post['ghsMobile'] = $ghsInfo['mobile'] ?? '';
  97. $post['ghsAvatar'] = $ghsInfo['avatar'] ?? '';
  98. $post['ghsFullAddress'] = $ghsInfo['fullAddress'] ?? '';
  99. $customId = $ghsInfo['customId'] ?? 0;
  100. $post['customId'] = $customId;
  101. $shopAdmin = $this->shopAdmin ?? null;
  102. $name = $shopAdmin->name ?? '';
  103. $post['shopAdminName'] = $name;
  104. $post['mainId'] = $this->mainId;
  105. $product = $post['product'] ?? '';
  106. $productList = json_decode($product, true);
  107. //判断product数据是不是同个供货商的
  108. $ids = array_unique(array_filter(array_column($productList, 'productId')));
  109. $productInfoList = ProductClass::getByIds($ids, null, 'id');
  110. if (!empty($productInfoList)) {
  111. foreach ($productInfoList as $currentInfo) {
  112. if (isset($currentInfo['mainId']) == false || $currentInfo['mainId'] != $this->mainId) {
  113. util::fail('只能选择同一家的商品哦');
  114. }
  115. }
  116. if (count($productInfoList) != count($ids)) {
  117. util::fail('存在无效商品');
  118. }
  119. } else {
  120. util::fail('花材不存在');
  121. }
  122. //供货商预订单最低公斤数要求和每公斤服务费
  123. $ghsInfo['kiloFee'] = 0;
  124. $ghsInfo['miniKilo'] = 0;
  125. $post['product'] = $productList;
  126. $packCost = 0;
  127. $post['packCost'] = $packCost;
  128. $post['sendCost'] = isset($post['sendCost']) && $post['sendCost'] > 0 ? $post['sendCost'] : 0;
  129. $respond = PurchaseService::createPurchase($post, $ghsInfo);
  130. if ($payMode == 0) {
  131. //欠款
  132. PurchaseService::debt($respond);
  133. } else {
  134. //线下支付
  135. PurchaseService::payAfter($respond, $payWay);
  136. $saleId = $respond->saleId ?? 0;
  137. $order = OrderClass::getById($saleId, true);
  138. if (empty($order)) {
  139. util::fail('没有找到订单');
  140. }
  141. OrderService::payAfter($order, $payWay, true);
  142. }
  143. $transaction->commit();
  144. util::success($respond);
  145. } catch (Exception $e) {
  146. $transaction->rollBack();
  147. util::fail();
  148. }
  149. }
  150. //生成采购单 ssh 2021.1.17
  151. public function actionCreateOrder()
  152. {
  153. $post = Yii::$app->request->post();
  154. //多颜色数据整理
  155. $colorItem = $post['xj'] ?? [];
  156. $newXj = [];
  157. if (!empty($colorItem)) {
  158. $colorData = json_decode($colorItem, true);
  159. if (!empty($colorData) && is_array($colorData)) {
  160. foreach ($colorData as $colorInfo) {
  161. $ptItemId = $colorInfo['ptItemId'] ?? 0;
  162. $colorList = $colorInfo['list'] ?? [];
  163. if (!empty($colorList)) {
  164. foreach ($colorList as $colorItemKey => $colorItem) {
  165. $newXj[$ptItemId][] = $colorItem;
  166. }
  167. }
  168. }
  169. }
  170. }
  171. $post['xj'] = $newXj;
  172. $ghsId = $post['ghsId'] ?? 0;
  173. //供货商
  174. $ghsInfo = GhsClass::getById($ghsId);
  175. if (empty($ghsInfo)) {
  176. util::fail('没有找到供货商');
  177. }
  178. $ghsShopId = $ghsInfo['shopId'] ?? 0;
  179. if (isset($ghsInfo['mainId']) && !empty($ghsInfo['mainId']) && $ghsInfo['mainId'] == $ghsInfo['ownMainId']) {
  180. util::fail('不能跟自己的店买花');
  181. }
  182. $connection = Yii::$app->db;//事务处理
  183. $transaction = $connection->beginTransaction();
  184. try {
  185. $post['book'] = $post['book'] ?? 0;
  186. $post['sjId'] = $this->sjId;
  187. $post['shopId'] = $this->shopId;
  188. $post['shopAdminId'] = $this->shopAdminId;
  189. $post['ghsId'] = $ghsId;
  190. $post['ghsName'] = $ghsInfo['name'] ?? '';
  191. $post['ghsMobile'] = $ghsInfo['mobile'] ?? '';
  192. $post['ghsAvatar'] = $ghsInfo['avatar'] ?? '';
  193. $post['ghsFullAddress'] = $ghsInfo['fullAddress'] ?? '';
  194. $customId = $ghsInfo['customId'] ?? 0;
  195. $post['customId'] = $customId;
  196. $shopAdmin = $this->shopAdmin ?? null;
  197. $name = $shopAdmin->name ?? '';
  198. $post['shopAdminName'] = $name;
  199. $post['mainId'] = $this->mainId;
  200. $product = $post['product'] ?? '';
  201. $productList = json_decode($product, true);
  202. //判断product数据是不是同个供货商的
  203. $ghsShopInfo = ShopClass::getById($ghsShopId, true);
  204. $ghsMainId = $ghsShopInfo->mainId ?? 0;
  205. $isOpen = ShopClass::isOpen($ghsShopInfo);
  206. $book = $post['book'] ?? 0;
  207. if ($isOpen == 0 && $book == 0) {
  208. util::fail('本店已休息,请选择其它门店');
  209. }
  210. if (isset($post['transType']) && $post['transType'] == 4) {
  211. if (isset($ghsShopInfo->pfLevel) && $ghsShopInfo->pfLevel == 1) {
  212. $notSameCity = PurchaseClass::notSameCity($this->shop, $ghsShopInfo);
  213. if ($notSameCity == false) {
  214. util::fail('距离太远,不能选择同城配送');
  215. }
  216. }
  217. }
  218. if ($book == 1) {
  219. $sendTimeWant = isset($post['sendTimeWant']) && !empty($post['sendTimeWant']) ? $post['sendTimeWant'] : date("Y-m-d");
  220. $future = date("Y-m-d", strtotime('+2 day'));
  221. if (strtotime($sendTimeWant) < strtotime($future)) {
  222. //util::fail('请选择时间');
  223. }
  224. $nowTime = strtotime(date("Y-m-d"));
  225. if (strtotime($sendTimeWant) < $nowTime) {
  226. util::fail('不能选择过去时间');
  227. }
  228. }
  229. $ids = array_unique(array_filter(array_column($productList, 'productId')));
  230. $productInfoList = ProductClass::getByIds($ids, null, 'id');
  231. if (!empty($productInfoList)) {
  232. $presellData = [];
  233. $nowTime = strtotime(date("Y-m-d"));
  234. foreach ($productInfoList as $currentInfo) {
  235. if (isset($currentInfo['mainId']) == false || $currentInfo['mainId'] != $ghsMainId) {
  236. util::fail('只能选择同一家的商品哦');
  237. }
  238. $currentName = $currentInfo['name'] ?? '';
  239. $presell = $currentInfo['presell'] ?? 0;
  240. $presellData[] = $presell;
  241. if ($presell == 1) {
  242. if ($book == 1) {
  243. util::fail('预订时不能选择预售花材');
  244. } else {
  245. if (isset($post['sendTimeWant']) == false || empty($post['sendTimeWant'])) {
  246. util::fail('请选择配送日期');
  247. }
  248. $sendTimeWant = $post['sendTimeWant'];
  249. if (strtotime($sendTimeWant) < $nowTime) {
  250. util::fail('不能选择过去时间');
  251. }
  252. $hasDateStr = $currentInfo['presellDate'] ?? [];
  253. $hasDate = explode(',', trim($hasDateStr));
  254. if (empty($hasDate)) {
  255. util::fail('预售日期有问题,请提醒门店');
  256. }
  257. if (in_array(strtotime($sendTimeWant), $hasDate) == false) {
  258. util::fail("有预售花材在{$sendTimeWant}没到货");
  259. }
  260. $post['presell'] = 1;
  261. }
  262. }
  263. }
  264. if (count($productInfoList) != count($ids)) {
  265. util::fail('存在无效商品');
  266. }
  267. $presellData = array_unique($presellData);
  268. if (count($presellData) > 1) {
  269. util::fail('预售和非预售花材不能一起下单');
  270. }
  271. } else {
  272. util::fail('花材不存在');
  273. }
  274. //供货商预订单最低公斤数要求和每公斤服务费
  275. $ghsInfo['kiloFee'] = $ghsShopInfo->kiloFee ?? 0;
  276. $ghsInfo['miniKilo'] = $ghsShopInfo->miniKilo ?? 0;
  277. $post['product'] = $productList;
  278. $sendType = $post['sendType'] ?? 0;
  279. $transType = $post['transType'] ?? 0;
  280. if (isset($ghsShopInfo->pfLevel) && $ghsShopInfo->pfLevel == 1) {
  281. //昆明发货包装费和运费的计算
  282. $totalWeight = 0;
  283. $totalItemNum = 0;
  284. foreach ($productList as $itemData) {
  285. $bigNum = $itemData['bigNum'] ?? 0;
  286. $thisWeight = $itemData['weight'] ?? 0;
  287. $currentWeight = bcmul($thisWeight, $bigNum, 2);
  288. $totalWeight = bcadd($currentWeight, $totalWeight, 2);
  289. $totalItemNum = bcadd($totalItemNum, $bigNum, 2);
  290. }
  291. $totalItemNum = floatval($totalItemNum);
  292. $kmPackCost = dict::getDict('kmPackCost');
  293. $packCost = 0;
  294. if (!empty($kmPackCost)) {
  295. foreach ($kmPackCost as $itemPack) {
  296. $kiloNum = $itemPack['num'] ?? 0;
  297. if ($kiloNum >= $totalWeight) {
  298. $packCost = $itemPack['amount'] ?? 0;
  299. break;
  300. }
  301. }
  302. }
  303. //同城配送和到店自取免打包费
  304. if ($transType == 4 || $transType == 5) {
  305. $packCost = 0;
  306. }
  307. //如果已经算过一次打包费和运费了,则不再费了
  308. $needAdd = \bizHd\shop\classes\ShopClass::needAddPackCost($ghsShopInfo, $customId);
  309. if ($needAdd == false) {
  310. $packCost = 0;
  311. }
  312. $post['packCost'] = $packCost;
  313. $transCost = dict::getDict('transCost');
  314. $sendCost = 0;
  315. if (!empty($transCost)) {
  316. foreach ($transCost as $trans) {
  317. $sign = $trans['sign'] ?? 0;
  318. if ($sign == $transType) {
  319. if ($sign == 2) {
  320. //冷链物流
  321. $llOption = $trans['option'] ?? [];
  322. if (!empty($llOption)) {
  323. $largeInfo = end($llOption);
  324. $largeNum = $largeInfo['num'] ?? 0;
  325. $largeAmount = $largeInfo['amount'] ?? 0;
  326. $bs = intval($totalItemNum / $largeNum);
  327. if ($bs > 0) {
  328. $addSendCost = bcmul($bs, $largeAmount, 2);
  329. $sendCost = bcadd($sendCost, $addSendCost, 2);
  330. $subNum = bcmul($bs, $largeNum, 2);
  331. $subNum = floatval($subNum);
  332. $totalItemNum = bcsub($totalItemNum, $subNum, 2);
  333. $totalItemNum = floatval($totalItemNum);
  334. }
  335. foreach ($llOption as $miniItem) {
  336. if ($miniItem['num'] >= $totalItemNum) {
  337. $sendCost = bcadd($sendCost, $miniItem['amount'], 2);
  338. break;
  339. }
  340. }
  341. }
  342. } else {
  343. //其它物流
  344. $perKiloCost = $trans['perKiloCost'] ?? 0;
  345. $sendCost = bcmul($perKiloCost, $totalWeight, 3);
  346. $sendCost = round($sendCost, 2);
  347. }
  348. }
  349. }
  350. }
  351. //如果已经算过一次打包费和运费了,则不再费了
  352. $needAdd = \bizHd\shop\classes\ShopClass::needAddPackCost($ghsShopInfo, $customId);
  353. if ($needAdd == false) {
  354. $sendCost = 0;
  355. }
  356. $post['sendCost'] = $sendCost;
  357. //标记为昆明到地方订单
  358. $post['localOrder'] = 1;
  359. } else {
  360. //同城发货包装费和运费的计算
  361. $sendCost = 0;
  362. if ($sendType == dict::getDict('sendType', 'thirdSend')) {
  363. $weight = 0;
  364. foreach ($productList as $itemData) {
  365. $bigNum = $itemData['bigNum'] ?? 0;
  366. $thisWeight = $itemData['weight'] ?? 0;
  367. $currentWeight = bcmul($thisWeight, $bigNum, 2);
  368. $weight = bcadd($currentWeight, $weight, 2);
  369. }
  370. $result = PurchaseClass::getDistanceFee($this->shop, $ghsShopInfo, $weight);
  371. $sendCost = $result['fee'] ?? 0;
  372. }
  373. $post['sendCost'] = $sendCost;
  374. //出车、发快递、发物流可以算包装费
  375. $packCost = 0;
  376. $itemTotalAmount = $post['itemTotalAmount'] ?? 0;
  377. unset($post['itemTotalAmount']);
  378. if ($sendType == dict::getDict('sendType', 'express')) {
  379. $needAdd = \bizHd\shop\classes\ShopClass::needAddPackCost($ghsShopInfo, $customId, $itemTotalAmount);
  380. if ($needAdd) {
  381. $packCost = $ghsShopInfo->packCost ?? 0;
  382. }
  383. }
  384. $post['packCost'] = $packCost;
  385. }
  386. $respond = PurchaseService::createPurchase($post, $ghsInfo);
  387. if ($sendType == 0) {
  388. if (getenv('YII_ENV') == 'production') {
  389. //杭州斗南鲜花批发部,满500,10公里内免费配送,满1000,20公里免费配送
  390. if ($ghsShopId == 4608) {
  391. if ($respond->actPrice < 500) {
  392. $transaction->rollBack();
  393. util::fail('满500元支持免费配送');
  394. }
  395. }
  396. //叶上花,满500元市区免费配送
  397. if ($ghsShopId == 4804) {
  398. if ($respond->actPrice < 500) {
  399. $transaction->rollBack();
  400. util::fail('满500元支持免费配送');
  401. }
  402. }
  403. //花悠星 国恋 勇记 易宝暂时不支持免费配送
  404. if ($ghsShopId == 7687 || $ghsShopId == 7831 || $ghsShopId == 7778 || $ghsShopId == 12003) {
  405. util::fail('暂不支持送货上门,请选其它方式');
  406. }
  407. }
  408. }
  409. if ($sendType == 2) {
  410. if (in_array($ghsShopId, [520, 1489, 13628, 3, 7855, 7687])) {
  411. util::fail('暂时不能使用跑腿');
  412. }
  413. }
  414. $transaction->commit();
  415. util::success($respond);
  416. } catch (Exception $e) {
  417. $transaction->rollBack();
  418. util::fail();
  419. }
  420. }
  421. //赊账 ssh 2021.1.24
  422. public function actionDebtPay()
  423. {
  424. $get = Yii::$app->request->get();
  425. $orderSn = $get['orderSn'] ?? 0;
  426. $info = PurchaseClass::getByCondition(['orderSn' => $orderSn], true);
  427. PurchaseService::valid($info, $this->shopId);
  428. if ($info->status == 5) {
  429. util::fail('订单已取消');
  430. }
  431. if ($info->status != 1) {
  432. util::fail('订单不是待付款状态');
  433. }
  434. if ($info->book == 1) {
  435. util::fail('预售不能记欠款');
  436. }
  437. $ghsId = $info->ghsId;
  438. $ghs = GhsClass::getGhsInfo($ghsId);
  439. $customId = $ghs['customId'] ?? 0;
  440. $custom = CustomClass::getCustom($customId);
  441. if (empty($custom)) {
  442. util::fail('没有找到客户');
  443. }
  444. if (isset($custom['debt']) == false || $custom['debt'] == CustomClass::IS_DEBT_NO) {
  445. util::fail('请先申请赊账权限');
  446. }
  447. $connection = Yii::$app->db;//事务处理
  448. $transaction = $connection->beginTransaction();
  449. try {
  450. //延期支付
  451. PurchaseService::debt($info);
  452. $transaction->commit();
  453. if (isset($info->localOrder) && $info->localOrder == 1) {
  454. if ($info->transType != 5 && $info->transType != 4) {
  455. //昆明发货,客户算了一次打包费和运费,第二次就不再算了
  456. $current = date("Y_m_d");
  457. $key = 'ghs_custom_today_has_get_pack_cost_' . $current . '_' . $customId;
  458. Yii::$app->redis->executeCommand('SETEX', [$key, 86400, '1']);
  459. }
  460. } else {
  461. if (isset($info->sendType) && $info->sendType == 4) {
  462. //标记当天已收一次包装费,岭南批发市场用的功能
  463. $current = date("Y_m_d");
  464. $key = 'ghs_custom_today_has_get_pack_cost_' . $current . '_' . $customId;
  465. Yii::$app->redis->executeCommand('SETEX', [$key, 86400, '1']);
  466. }
  467. }
  468. //不是预订单,并且采购人没有开批发店,供货商不是源花汇和小明鲜花,则订单直接完成掉,有三个地方要修改,请搜索关键词zjFinish
  469. $cg = PurchaseClass::getByCondition(['orderSn' => $orderSn], true);
  470. if (!empty($cg)) {
  471. if (isset($cg->book) && $cg->book == 0) {
  472. $ghsShopId = $ghs['shopId'] ?? 0;
  473. if (getenv('YII_ENV') == 'production') {
  474. $specialList = [3, 10649, 8042];
  475. } else {
  476. $specialList = [36523];
  477. }
  478. if (!in_array($ghsShopId, $specialList)) {
  479. $cgShopId = $cg->shopId ?? 0;
  480. $cgShop = ShopClass::getById($cgShopId, true);
  481. if (!empty($cgShop)) {
  482. if (isset($cgShop->pfShopId) && $cgShop->pfShopId == 0) {
  483. PurchaseClass::confirmTake($cg);
  484. }
  485. }
  486. }
  487. }
  488. }
  489. //app新订单通知
  490. $saleId = $info->saleId ?? 0;
  491. $order = OrderClass::getById($saleId, true);
  492. if (!empty($order)) {
  493. $shopId = $order->shopId ?? 0;
  494. $shop = ShopClass::getById($shopId, true);
  495. if (!empty($shop)) {
  496. //微信通知供货商
  497. //WxMessageClass::ghsHasNewOrderInform($shop, $order);
  498. $noticeText = json_encode(['orderId' => $saleId]);
  499. $noticeKey = "hdCgNoticeGhs";
  500. Yii::$app->redis->executeCommand('LPUSH', [$noticeKey, $noticeText]);
  501. }
  502. //订单生成时唤起在线打印
  503. if (isset($order->needPrint) && $order->needPrint == dict::getDict('needPrint', 'need')) {
  504. //有几个地方要同步去修改
  505. if (getenv('YII_ENV') == 'production') {
  506. //源花汇不自动打开小票
  507. $mallOrderNoPrint = [10536];
  508. } else {
  509. $mallOrderNoPrint = [];
  510. }
  511. if (in_array($order->mainId, $mallOrderNoPrint)) {
  512. } else {
  513. OrderClass::onlinePrint($order);
  514. $order->printNum += 1;
  515. $order->save();
  516. }
  517. }
  518. }
  519. } catch (Exception $e) {
  520. $transaction->rollBack();
  521. util::fail('支付失败');
  522. }
  523. util::success($info->attributes);
  524. }
  525. //余额支付 ssh 2021.1.24
  526. public function actionBalancePay()
  527. {
  528. $shopAdmin = $this->shopAdmin;
  529. if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
  530. util::fail('超管才能操作');
  531. }
  532. $get = Yii::$app->request->get();
  533. $orderSn = $get['orderSn'] ?? 0;
  534. $password = $get['password'] ?? '';
  535. // 重新获取,不加密的用户数据
  536. $admin = AdminClass::getById($this->adminId, true);
  537. if (password_verify($password, $admin->payPassword) == false) {
  538. util::fail('密码错误');
  539. }
  540. $info = PurchaseClass::getByCondition(['orderSn' => $orderSn], true);
  541. if (empty($info)) {
  542. util::fail('没有找到采购单');
  543. }
  544. if ($info->status == 5) {
  545. util::fail('订单已取消');
  546. }
  547. if ($info->status != 1) {
  548. util::fail('订单不是待付款状态');
  549. }
  550. PurchaseService::valid($info, $this->shopId);
  551. $connection = Yii::$app->db;//事务处理
  552. $transaction = $connection->beginTransaction();
  553. try {
  554. //余额支付
  555. purchaseService::balancePay($info);
  556. $transaction->commit();
  557. } catch (Exception $e) {
  558. $transaction->rollBack();
  559. util::fail('支付失败');
  560. }
  561. util::success($info->attributes);
  562. }
  563. //采购记录 ssh 2021.1.24
  564. public function actionList()
  565. {
  566. $get = Yii::$app->request->get();
  567. $where = ['shopId' => $this->shopId];
  568. $status = $get['status'] ?? 0;
  569. if (!empty($status)) {
  570. $where['status'] = $status;
  571. }
  572. $respond = PurchaseService::getPurchaseList($where);
  573. $respond['shop'] = $this->shop->attributes;
  574. util::success($respond);
  575. }
  576. //采购详情 ssh 2021.01.25
  577. public function actionDetail()
  578. {
  579. $get = Yii::$app->request->get();
  580. $id = $get['id'] ?? 0;
  581. $info = PurchaseService::getInfo($id, true, true);
  582. if (isset($info['mainId']) == false || $info['mainId'] != $this->mainId) {
  583. //不能注释,分享付款功能要用,客户没有登录也能付款
  584. //util::fail('无法访问');
  585. }
  586. $customId = $info['customId'] ?? 0;
  587. $custom = CustomClass::getById($customId);
  588. $customName = $custom['name'] ?? '';
  589. $customMobile = $custom['mobile'] ?? '';
  590. $info['customName'] = $customName;
  591. $info['customMobile'] = $customMobile;
  592. $hasDebtPay = $custom['debt'] ?? 0;
  593. $book = $info['book'] ?? 0;
  594. $presell = $info['presell'] ?? 0;
  595. //预售不能记欠款
  596. if ($book == 1) {
  597. $hasDebtPay = 0;
  598. }
  599. if ($presell == 1) {
  600. $hasDebtPay = 0;
  601. }
  602. $shop = $this->shop;
  603. $info['pfShopId'] = $shop->pfShopId ?? 0;
  604. $info['hasDebtPay'] = $hasDebtPay;
  605. $info['balance'] = $shop->balance ?? 0;
  606. $getPayType = dict::getDict('getPayType');
  607. $info['getPayType'] = $getPayType;
  608. //获取售后条件
  609. $ghsId = $info['ghsId'] ?? 0;
  610. $ghsInfo = GhsClass::getById($ghsId, true);
  611. if (empty($ghsInfo)) {
  612. util::fail('没有找到供货商');
  613. }
  614. $info['afterSale'] = $ghsInfo->afterSale ?? 1;
  615. util::success($info);
  616. }
  617. //可用的支付方式 ssh 2021.1.25
  618. public function actionPayWay()
  619. {
  620. $button = [
  621. ['type' => 'wxPay', 'show' => 1, 'disable' => 1],
  622. ['type' => 'debtPay', 'show' => 1, 'disable' => 0],
  623. ['type' => 'balancePay', 'show' => 1, 'disable' => 0],
  624. ];
  625. util::success(['button' => $button]);
  626. }
  627. //待结款明细 ssh 2021.1.26
  628. public function actionDebtList()
  629. {
  630. $get = Yii::$app->request->get();
  631. $id = $get['id'] ?? 0;
  632. $info = GhsClass::getGhsInfo($id);
  633. GhsClass::valid($info, $this->shopId);
  634. $where = ['ghsId' => $id, 'debt' => PurchaseClass::DEBT_YES];
  635. $searchTime = $get['searchTime'] ?? '';
  636. if (!empty($searchTime)) {
  637. $startTime = $get['startTime'] ?? '';
  638. $endTime = $get['endTime'] ?? '';
  639. $period = dateUtil::formatTime($searchTime, $startTime, $endTime);
  640. $where['addTime'] = ['between', [$period['startTime'], $period['endTime']]];
  641. }
  642. $respond = PurchaseService::getDebtList($where);
  643. util::success($respond);
  644. }
  645. //微信支付 ssh 2021.4.11
  646. public function actionAlipay()
  647. {
  648. ini_set('date.timezone', 'Asia/Shanghai');
  649. $post = Yii::$app->request->post();
  650. $couponId = $post['couponId'] ?? 0;
  651. $orderSn = isset($post['orderSn']) ? $post['orderSn'] : 0;
  652. $order = PurchaseClass::getByCondition(['orderSn' => $orderSn], true);
  653. if (empty($order)) {
  654. util::fail('订单号无效');
  655. }
  656. if ($order->status == 5) {
  657. util::fail('订单已取消');
  658. }
  659. if ($order->status != 1) {
  660. util::fail('订单不是待付款状态');
  661. }
  662. $deadline = $order->deadline;
  663. $current = time();
  664. if (($current + 50) > strtotime($deadline)) {
  665. util::fail('订单已失效,请重新下单');
  666. }
  667. //已经唤起过微信支付了,根据拉卡拉的规则,需要生成新的订单号
  668. if ($order->changePrice == 2) {
  669. $oldOrderSn = $orderSn;
  670. $newOrderSn = orderSn::getPurchaseSn();
  671. $newGhsOrderSn = orderSn::getGhsOrderSn();
  672. $orderSn = $newOrderSn;
  673. $order->orderSn = $newOrderSn;
  674. $order->save();
  675. PurchaseItemClass::updateByCondition(['orderSn' => $oldOrderSn], ['orderSn' => $newOrderSn]);
  676. $saleId = $order->saleId ?? 0;
  677. $sale = OrderClass::getById($saleId, true);
  678. if (!empty($sale)) {
  679. $oldSaleOrderSn = $sale->orderSn ?? '';
  680. $sale->orderSn = $newGhsOrderSn;
  681. $sale->save();
  682. OrderItemClass::updateByCondition(['orderSn' => $oldSaleOrderSn], ['orderSn' => $newGhsOrderSn]);
  683. }
  684. }
  685. $id = $order->id;
  686. $order->changePrice = 2;
  687. $order->save();
  688. $name = $orderSn;
  689. $totalFee = $order->realPrice;
  690. //强制使用小程序的miniOpenId
  691. $openId = isset($this->admin) && !empty($this->admin) ? $this->admin->miniOpenId : '';
  692. if (empty($openId)) {
  693. $currentShopId = $order->shopId ?? 0;
  694. $currentShop = ShopClass::getById($currentShopId, true);
  695. $currentShopName = $currentShop->merchantName . ' ' . $currentShop->shopName;
  696. $currentMobile = $currentShop->mobile ?? '';
  697. noticeUtil::push("花店采购时,发现没有openId,请跟进是否采购成功。{$currentShopName} {$currentMobile}", '15280215347');
  698. util::success(['hasError' => 1, 'hasNoMiniOpenId' => 1]);
  699. }
  700. $purchaseCapital = dict::getDict('capitalType', 'xhPurchase', 'id');
  701. //花卉宝代为申请的微信支付
  702. $merchantExtend = WxOpenClass::getWxInfo();
  703. $ghsId = $order->ghsId ?? 0;
  704. $ghs = GhsClass::getById($ghsId, true);
  705. if (empty($ghs)) {
  706. util::fail('没有供货商信息');
  707. }
  708. $ghsShopId = $ghs->shopId ?? 0;
  709. $ghsShop = ShopClass::getById($ghsShopId, true);
  710. if (empty($ghsShop)) {
  711. util::fail('没有供货商门店信息');
  712. }
  713. $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
  714. $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
  715. $params = [
  716. 'appid' => 'OP00002119',
  717. 'serial_no' => '018b08cfddbd',
  718. 'merchant_no' => $ghsShop->lklSjNo,
  719. 'term_no' => $ghsShop->lklScanTermNo,
  720. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  721. 'lklCertificatePath' => $lklCertificatePath,
  722. ];
  723. $laResource = new Lakala($params);
  724. $notifyUrl = Yii::$app->params['hdHost'] . "/notice/pay-callback";
  725. $wxParams = [
  726. 'orderSn' => $orderSn,
  727. 'amount' => $totalFee,
  728. 'capitalType' => $purchaseCapital,
  729. 'notifyUrl' => $notifyUrl,
  730. 'wxAppId' => $merchantExtend['miniAppId'],
  731. 'openId' => $openId,
  732. 'subject' => $name,
  733. 'couponId' => $couponId,
  734. ];
  735. $response = $laResource->cashierPay($wxParams);
  736. if (isset($response['code']) == false || $response['code'] != '000000') {
  737. $errMsg = $response['msg'] ?? '';
  738. noticeUtil::push('编号AA90:' . $errMsg, '15280215347');
  739. util::fail('发起支付失败');
  740. }
  741. $counter_url = $response['resp_data']['counter_url'] ? $response['resp_data']['counter_url'] : '';
  742. $new = [
  743. 'counter_url' => $counter_url,
  744. ];
  745. util::success($new);
  746. }
  747. //微信支付 ssh 2021.4.11
  748. public function actionWxPay()
  749. {
  750. ini_set('date.timezone', 'Asia/Shanghai');
  751. $post = Yii::$app->request->post();
  752. $couponId = $post['couponId'] ?? 0;
  753. $orderSn = isset($post['orderSn']) ? $post['orderSn'] : 0;
  754. $order = PurchaseClass::getByCondition(['orderSn' => $orderSn], true);
  755. if (empty($order)) {
  756. util::fail('订单号无效');
  757. }
  758. if ($order->status == 5) {
  759. util::fail('订单已取消');
  760. }
  761. if ($order->status != 1) {
  762. util::fail('订单不是待付款状态');
  763. }
  764. $deadline = $order->deadline;
  765. $current = time();
  766. if (($current + 50) > strtotime($deadline)) {
  767. util::fail('订单已失效,请重新下单');
  768. }
  769. $ghsId = $order->ghsId ?? 0;
  770. $ghs = GhsClass::getById($ghsId, true);
  771. if (empty($ghs)) {
  772. util::fail('没有供货商信息');
  773. }
  774. $ghsShopId = $ghs->shopId ?? 0;
  775. $ghsShop = ShopClass::getById($ghsShopId, true);
  776. if (empty($ghsShop)) {
  777. util::fail('没有供货商门店信息');
  778. }
  779. if (isset($ghsShop->lklSjNo) && empty($ghsShop->lklSjNo)) {
  780. util::fail('商家支付功能冻结');
  781. }
  782. //已经唤起过微信支付了,根据拉卡拉的规则,需要生成新的订单号
  783. if ($order->changePrice == 2) {
  784. $oldOrderSn = $orderSn;
  785. //老单号需要关单,否则有付款成功的风险,老单号关闭成功了,才能生成新单号
  786. $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
  787. $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
  788. $params = [
  789. 'appid' => 'OP00002119',
  790. 'serial_no' => '018b08cfddbd',
  791. 'merchant_no' => $ghsShop->lklSjNo,
  792. 'term_no' => $ghsShop->lklScanTermNo,
  793. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  794. 'lklCertificatePath' => $lklCertificatePath,
  795. ];
  796. $laResource = new Lakala($params);
  797. $closeParams = [
  798. 'orderSn' => $oldOrderSn,
  799. ];
  800. $response = $laResource->close($closeParams);
  801. if (isset($response['code']) == false || $response['code'] != 'BBS00000') {
  802. $msg = $response['msg'] ?? '';
  803. noticeUtil::push('重点注意,花店买花更换单号没有成功,单号:' . $oldOrderSn . ',关单没有成功,' . $msg, '15280215347');
  804. util::fail('出错了,请重新下一单');
  805. }
  806. $newOrderSn = orderSn::getPurchaseSn();
  807. $newGhsOrderSn = orderSn::getGhsOrderSn();
  808. $orderSn = $newOrderSn;
  809. $order->orderSn = $newOrderSn;
  810. $order->save();
  811. PurchaseItemClass::updateByCondition(['orderSn' => $oldOrderSn], ['orderSn' => $newOrderSn]);
  812. $saleId = $order->saleId ?? 0;
  813. $sale = OrderClass::getById($saleId, true);
  814. if (!empty($sale)) {
  815. $oldSaleOrderSn = $sale->orderSn ?? '';
  816. $sale->orderSn = $newGhsOrderSn;
  817. $sale->save();
  818. OrderItemClass::updateByCondition(['orderSn' => $oldSaleOrderSn], ['orderSn' => $newGhsOrderSn]);
  819. }
  820. }
  821. $id = $order->id;
  822. $order->changePrice = 2;
  823. $order->save();
  824. $name = $orderSn;
  825. $totalFee = $order->realPrice;
  826. $openId = '';
  827. if (isset($post['currentMiniOpenId']) && !empty($post['currentMiniOpenId'])) {
  828. $openId = $post['currentMiniOpenId'];
  829. //noticeUtil::push('花店采购下单时,通过前端获取了openId:' . $openId, '15280215347');
  830. }
  831. if (empty($openId)) {
  832. if (isset($this->admin) && !empty($this->admin)) {
  833. if (isset($this->admin->miniOpenId) && !empty($this->admin->miniOpenId)) {
  834. $openId = $this->admin->miniOpenId;
  835. noticeUtil::push('花店采购下单时,通过数据库获取了openId:' . $openId, '15280215347');
  836. }
  837. }
  838. }
  839. if (empty($openId)) {
  840. $currentShopId = $order->shopId ?? 0;
  841. $currentShop = ShopClass::getById($currentShopId, true);
  842. $currentShopName = $currentShop->merchantName . ' ' . $currentShop->shopName;
  843. $currentMobile = $currentShop->mobile ?? '';
  844. noticeUtil::push("花店采购时,发现没有openId,请跟进是否采购成功。{$currentShopName} {$currentMobile}", '15280215347');
  845. util::success(['hasError' => 1, 'hasNoMiniOpenId' => 1]);
  846. }
  847. $purchaseCapital = dict::getDict('capitalType', 'xhPurchase', 'id');
  848. //花卉宝代为申请的微信支付
  849. $merchantExtend = WxOpenClass::getWxInfo();
  850. $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
  851. $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
  852. $params = [
  853. 'appid' => 'OP00002119',
  854. 'serial_no' => '018b08cfddbd',
  855. 'merchant_no' => $ghsShop->lklSjNo,
  856. 'term_no' => $ghsShop->lklScanTermNo,
  857. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  858. 'lklCertificatePath' => $lklCertificatePath,
  859. ];
  860. $laResource = new Lakala($params);
  861. $notifyUrl = Yii::$app->params['hdHost'] . "/notice/pay-callback";
  862. $wxParams = [
  863. 'orderSn' => $orderSn,
  864. 'amount' => $totalFee,
  865. 'capitalType' => $purchaseCapital,
  866. 'notifyUrl' => $notifyUrl,
  867. 'wxAppId' => $merchantExtend['miniAppId'],
  868. 'openId' => $openId,
  869. 'subject' => $name,
  870. 'couponId' => $couponId,
  871. ];
  872. $response = $laResource->driveWxPay($wxParams);
  873. if (isset($response['code']) == false || $response['code'] != 'BBS00000') {
  874. $errMsg = $response['msg'] ?? '';
  875. noticeUtil::push('编号99891:' . $errMsg, '15280215347');
  876. util::fail('支付失败');
  877. }
  878. $newParams = isset($response['resp_data']['acc_resp_fields']) ? $response['resp_data']['acc_resp_fields'] : [];
  879. $appId = $newParams['app_id'] ?? '';
  880. $nonceStr = $newParams['nonce_str'] ?? '';
  881. $paySign = $newParams['pay_sign'] ?? '';
  882. $package = $newParams['package'] ?? '';
  883. $signType = $newParams['sign_type'] ?? '';
  884. $timeStamp = $newParams['time_stamp'] ?? '';
  885. $new = [
  886. 'id' => $id,
  887. 'appId' => $appId,
  888. 'nonceStr' => $nonceStr,
  889. 'paySign' => $paySign,
  890. 'package' => $package,
  891. 'signType' => $signType,
  892. 'timeStamp' => $timeStamp,
  893. 'orderSn' => $orderSn,
  894. ];
  895. util::success($new);
  896. }
  897. //计算运费 ssh 20221003
  898. public function actionFreight()
  899. {
  900. $get = Yii::$app->request->get();
  901. $shop = $this->shop;
  902. $shopLat = isset($shop->lat) ? $shop->lat : '';
  903. $shopLong = isset($shop->long) ? $shop->long : '';
  904. if (empty($shopLat) || empty($shopLong)) {
  905. util::success(['distance' => 0, 'showDistance' => 0, 'fee' => 0]);
  906. }
  907. $ghsId = $get['ghsId'] ?? 0;
  908. $ghs = GhsClass::getById($ghsId, true);
  909. if (empty($ghs)) {
  910. util::success(['distance' => 0, 'showDistance' => 0, 'fee' => 0]);
  911. }
  912. $ghsShopId = $ghs->shopId ?? 0;
  913. $ghsShop = ShopClass::getById($ghsShopId, true);
  914. if (empty($ghsShop)) {
  915. util::success(['distance' => 0, 'showDistance' => 0, 'fee' => 0]);
  916. }
  917. $ghsShopLat = isset($ghsShop->lat) ? $ghsShop->lat : '';
  918. $ghsShopLong = isset($ghsShop->long) ? $ghsShop->long : '';
  919. if (empty($ghsShopLat) || empty($ghsShopLong)) {
  920. util::success(['distance' => 0, 'showDistance' => 0, 'fee' => 0]);
  921. }
  922. $weight = $get['weight'] ?? 0;
  923. if (empty($weight)) {
  924. util::success(['distance' => 0, 'showDistance' => 0, 'fee' => 0]);
  925. }
  926. $respond = PurchaseClass::getDistanceFee($this->shop, $ghsShop, $weight);
  927. util::success($respond);
  928. }
  929. //运费计算 lqh 2021.4.12 暂时返回固定值
  930. public function actionFreight2()
  931. {
  932. //lqh 2021.6.25 运费固定返回0
  933. util::success(['sedCost' => 0]);
  934. $post = Yii::$app->request->post();
  935. $ghsId = $post['ghsId'] ?? 0;
  936. //供货商
  937. $ghsInfo = GhsClass::getById($ghsId);
  938. if (empty($ghsInfo)) {
  939. util::fail('没有找到供货商');
  940. }
  941. //花材信息
  942. $productJson = $post['product'] ?? '';
  943. // $productJson = '[{"productId":31993,"bigNum":1,"smallNum":0}]';
  944. if (empty($productJson)) {
  945. util::fail('请选择花材');
  946. }
  947. $productList = json_decode($productJson, true);
  948. if (empty($productList)) {
  949. util::fail('请选择花材');
  950. }
  951. $productList = PurchaseClass::mergeItemInfo($productList);
  952. $weight = 0;
  953. $price = 0;
  954. $productData = ProductClass::getProductMapData($productList);
  955. $bigNum = 0;
  956. foreach ($productList as $key => $val) {
  957. $productId = $val['productId'];
  958. $w = ProductClass::getWeight($val['productId'], $val['bigNum'], $val['smallNum']);
  959. $bigNum += $val['bigNum'];
  960. $weight = bcadd($w, $weight, 2);
  961. $ratio = $productData[$productId]['ratio'] ?? 0;
  962. //大小数量合并多少扎
  963. $itemNum = ProductClass::mergeItemNum($val['bigNum'], $val['smallNum'], $ratio);
  964. //售卖价格
  965. $itemPrice = $productData[$productId]['price'] ?? 0;
  966. //合计价格
  967. $price = bcadd($price, bcmul($itemNum, $itemPrice, 2), 2);
  968. }
  969. $ghsShopId = $ghsInfo['shopId'] ?? 0;
  970. $ghsSjId = $ghsInfo['sjId'] ?? 0;
  971. $sendTime = $post['sendTime'] ?? '';
  972. if (!empty($sendTime)) {
  973. //配送时间不为空
  974. // 预约发单时间(预约时间unix时间戳(10位),精确到分;整分钟为间隔,并且需要至少提前5分钟预约
  975. $sendTimeInt = strtotime($sendTime);
  976. $now = time();
  977. $diff = $sendTimeInt - $now;
  978. //因服务器写入时间,改为至少提前6分钟
  979. if ($diff <= 360) {
  980. util::fail('配送时间至少提前6分钟');
  981. }
  982. $sendTime = date('Y-m-d H:i', strtotime($sendTime));
  983. } else {
  984. $sendTime = date('Y-m-d H:i', strtotime("+30 minute"));
  985. }
  986. //找供货商的客户信息,用里面的配送相关地址信息
  987. $customId = $ghsInfo['customId'] ?? 0;
  988. $customInfo = CustomClass::getById($customId);
  989. if (empty($customInfo)) {
  990. util::fail('没有找到客户');
  991. }
  992. //判断商家是否开启达达,若未开启,则使用自定义运费计算
  993. $shopNo = ShopExpressClass::getShopNo($ghsSjId, $ghsShopId);
  994. if (!$shopNo) {
  995. //使用自定义运费
  996. //util::fail('供货商暂未开通配送');
  997. $cost = freight::getCost($ghsInfo['lat'], $ghsInfo['long'], $customInfo['lat'], $customInfo['long'], $weight);
  998. util::success(['sedCost' => $cost]);
  999. }
  1000. //组装订单信息
  1001. $info = [];
  1002. //发送放的商家信息,即供货商的相关信息
  1003. $info['sjId'] = $ghsSjId;
  1004. $info['shopId'] = $ghsShopId;
  1005. $info['actPrice'] = $price;//价格
  1006. $info['weight'] = $weight;
  1007. $info['orderSn'] = \common\components\orderSn::getGhsOrderSn();
  1008. $info['bigNum'] = $bigNum;
  1009. //配送地址,当前零售端的门店地址
  1010. $info['customName'] = $customInfo['name'] ?? '';
  1011. $info['customMobile'] = $customInfo['mobile'] ?? '';
  1012. $info['province'] = $customInfo['province'] ?? '';
  1013. $info['city'] = $customInfo['city'] ?? '';;
  1014. $info['address'] = $customInfo['address'] ?? '';;
  1015. $info['floor'] = $customInfo['floor'] ?? '';;
  1016. $info['fullAddress'] = $customInfo['fullAddress'] ?? '';;
  1017. $info['lat'] = $customInfo['lat'] ?? '';;
  1018. $info['long'] = $customInfo['long'] ?? '';;
  1019. $info['sendTime'] = $sendTime;
  1020. $res = DadaExpressServices::queryDeliverFee($info);
  1021. util::success(['sedCost' => $res['fee']]);
  1022. }
  1023. }