CgRefundClass.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  1. <?php
  2. namespace bizHd\cg\classes;
  3. use biz\shop\classes\ShopCapitalClass;
  4. use biz\shop\classes\ShopExtClass;
  5. use bizHd\ghs\classes\GhsClass;
  6. use bizHd\purchase\classes\PurchaseClass;
  7. use bizHd\purchase\classes\PurchaseItemClass;
  8. use bizHd\shop\classes\MainClass;
  9. use bizGhs\stock\classes\StockRecordClass;
  10. use bizHd\shop\classes\ShopClass;
  11. use bizHd\wx\classes\WxOpenClass;
  12. use common\components\dict;
  13. use common\components\noticeUtil;
  14. use common\components\orderSn;
  15. use common\components\util;
  16. use Yii;
  17. use bizGhs\base\classes\BaseClass;
  18. use bizGhs\order\traits\OrderTrait;
  19. use bizGhs\product\classes\ProductClass;
  20. use common\components\lakala\Lakala;
  21. class CgRefundClass extends BaseClass
  22. {
  23. use OrderTrait;
  24. public static $baseFile = '\bizHd\cg\models\CgRefund';
  25. const STATUS_UN_COMPLETE = 0;//待审核
  26. const STATUS_COMPLETE = 1;//已通过
  27. const STATUS_REJECT = 2;//已驳回
  28. const STATUS_CANCEL = 3;//已取消
  29. const REFUND_TYPE_MONEY_GOOD = 1; //退款退货
  30. const REFUND_TYPE_MONEY = 2; // 仅退款
  31. public static function onlyRefundMoney($ghsShop, $cg)
  32. {
  33. $refundOrderSn = orderSn::getCgRefundSn();
  34. $refundPrice = $cg->actPrice ?? 0;
  35. $orderSn = $cg->orderSn ?? '';
  36. $refundFee = bcmul($refundPrice, 100);
  37. $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
  38. $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
  39. $params = [
  40. 'appid' => 'OP00002119',
  41. 'serial_no' => '018b08cfddbd',
  42. 'merchant_no' => $ghsShop->lklSjNo,
  43. 'term_no' => $ghsShop->lklScanTermNo,
  44. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  45. 'lklCertificatePath' => $lklCertificatePath,
  46. ];
  47. $laResource = new Lakala($params);
  48. $refundReason = '';
  49. //退款用拉卡拉原单号比较稳定,用自己内部的单号,好像会出现找不到订单号的情况
  50. $thirdNo = $cg->thirdNo ?? '';
  51. $thisOrderSn = '';
  52. //竟然会出现thirdNo为空的情况
  53. if (!empty($thirdNo)) {
  54. $thisOrderSn = $orderSn;
  55. }
  56. $backParams = [
  57. 'refundSn' => $refundOrderSn,
  58. 'thirdNo' => $thirdNo,
  59. 'orderSn' => $thisOrderSn,
  60. 'refundAmount' => $refundFee,
  61. 'refundReason' => $refundReason,
  62. ];
  63. $response = $laResource->refund($backParams);
  64. if (!isset($response['code']) || $response['code'] != 'BBS00000') {
  65. $errMsg = $response['msg'] ?? '';
  66. noticeUtil::push("钱退回失败 {$orderSn} {$errMsg}", '15280215347');
  67. return ['status' => 0, 'msg' => $errMsg];
  68. } else {
  69. $ghsShopId = $ghsShop->id;
  70. ShopExtClass::orderCancelBackMoneyReport($ghsShopId);
  71. $sjName = $ghsShop->merchantName;
  72. $shopName = $ghsShop->shopName;
  73. $name = $shopName == '首店' ? $sjName : $sjName . '-' . $shopName;
  74. noticeUtil::push("钱已经原路退回 success {$orderSn} {$name}", '15280215347');
  75. return ['status' => 1, 'msg' => '退款成功'];
  76. }
  77. }
  78. //审核通过 ssh 20230811
  79. public static function passRefund($cgRefund, $cg)
  80. {
  81. if ($cgRefund->status == 1) {
  82. util::fail('已通过');
  83. }
  84. if ($cgRefund->status == 2) {
  85. util::fail('已驳回');
  86. }
  87. if ($cgRefund->status == 3) {
  88. util::fail('已取消');
  89. }
  90. $refundType = $cgRefund->refundType ?? 1;
  91. $refundSn = $cgRefund->orderSn ?? '';
  92. $cgRefund->status = 1;
  93. $cgRefund->save();
  94. $orderSn = $cg->orderSn ?? '';
  95. $mainId = $cg->mainId ?? 0;
  96. $shopId = $cg->shopId ?? 0;
  97. $sjId = $cg->sjId ?? 0;
  98. $ghsName = $cg->ghsName ?? '';
  99. $payWay = $cg->payWay;
  100. $onlinePay = $cg->onlinePay ?? 1;
  101. $cg->refund = PurchaseClass::REFUND_YES;
  102. $cg->save();
  103. $transaction_id = $cg->thirdNo ?? '';
  104. $refundOrderSn = orderSn::getCgRefundSn();
  105. $refundPrice = $cgRefund->refundPrice ?? 0;
  106. if (is_numeric($refundPrice) == false || $refundPrice < 0) {
  107. util::fail('退款金额有问题');
  108. }
  109. $shop = ShopClass::getLockById($shopId);
  110. if (empty($shop)) {
  111. util::fail('没有找到门店14');
  112. }
  113. $main = MainClass::getLockById($mainId);
  114. if (empty($main)) {
  115. util::fail('没有main信息7');
  116. }
  117. // 处理退货退款前,把库存先补回。(本次哪些花材要退多少,就补回多少)
  118. if ($refundType == CgRefundClass::REFUND_TYPE_MONEY_GOOD) {
  119. $field = 'id, cgItemId, itemNum, xhNum';
  120. $refundItemList = CgRefundItemClass::getAllByCondition(['orderSn' => $refundSn], null, $field, null, true);
  121. if (empty($refundItemList)) {
  122. util::fail('没有找到售后订单的花材哦');
  123. }
  124. $refundList = [];
  125. foreach ($refundItemList as $val) {
  126. $cgItemId = $val->cgItemId;
  127. if (empty($cgItemId)) {
  128. util::fail('旧订单无法售后,请联系管理员哦');
  129. }
  130. $refundList[$cgItemId] = $val;
  131. }
  132. $field = 'id, xhNum, productId';
  133. $cgItemList = PurchaseItemClass::getAllByCondition(['orderSn' => $cg->orderSn], null, $field, null, true);
  134. if (empty($cgItemList)) {
  135. util::fail('采购单花材错误');
  136. }
  137. $itemDatas = [];
  138. foreach ($cgItemList as $cgItem) {
  139. if (isset($refundList[$cgItem->id])) {
  140. $refund = $refundList[$cgItem->id];
  141. $product = ProductClass::getById($cgItem->productId, true);
  142. $itemDatas[$cgItem->productId] = ['product' => $product, 'addNum' => $refund->itemNum]; // 使用 itemNum 合适,还是 xhNum ?
  143. }
  144. }
  145. $cgShop = $shop;//采购门店
  146. $adminId = $cgShop->adminId;
  147. // 补回本次退货的花材数量
  148. PurchaseClass::increaseProductStock($itemDatas, $cgShop, $adminId, $cg->mainId, '系统');
  149. }
  150. if ($refundType == CgRefundClass::REFUND_TYPE_MONEY_GOOD) {
  151. $refundItemList = CgRefundItemClass::getAllByCondition(['orderSn' => $refundSn], null, '*', null, true);
  152. if (empty($refundItemList)) {
  153. util::fail('没有找到售后订单的花材哦');
  154. }
  155. $refundData = [];
  156. foreach ($refundItemList as $key => $val) {
  157. $val->status = 1;
  158. $val->save();
  159. $cgItemId = $val->cgItemId ?? 0;
  160. if (empty($cgItemId)) {
  161. util::fail('旧订单无法售后,请联系管理员哦');
  162. }
  163. $refundData[$cgItemId] = $val;
  164. }
  165. $cgItemList = PurchaseItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*', null, true);
  166. if (empty($cgItemList)) {
  167. util::fail('采购单花材错误');
  168. }
  169. foreach ($cgItemList as $oneKey => $oneItem) {
  170. $oneItemId = $oneItem->id;
  171. $productId = $oneItem->productId ?? 0;
  172. $ptItemId = $oneItem->itemId ?? 0;
  173. $itemName = $oneItem->name ?? '';
  174. $cgItemNum = $oneItem->xhNum ?? 0;
  175. $refundNum = $oneItem->refundNum ?? 0;
  176. $remainNum = bcsub($cgItemNum, $refundNum);
  177. if (isset($refundData[$oneItemId])) {
  178. $refundSingle = $refundData[$oneItemId];
  179. $num = $refundSingle->xhNum ?? 0;
  180. if ($num > $remainNum) {
  181. util::fail("{$itemName} 超过可退数量");
  182. }
  183. $oneItem->refundNum = bcadd($refundNum, $num);
  184. $oneItem->save();
  185. if ($refundSingle->xhUnitType == 1) {
  186. $smallNum = $num;
  187. $bigNum = 0;
  188. } else {
  189. $smallNum = 0;
  190. $bigNum = $num;
  191. }
  192. $itemNum = $refundSingle->itemNum;
  193. if ($bigNum > 0 || $smallNum > 0) {
  194. $stockInfo = ProductClass::decreaseStock($productId, $bigNum, $smallNum);
  195. $oldStock = $stockInfo['oldStock'] ?? 0;
  196. $newStock = $stockInfo['newStock'] ?? 0;
  197. $recordData = [];
  198. $recordData['itemNum'] = $itemNum;
  199. $recordData['sjId'] = $sjId;
  200. $recordData['shopId'] = $shopId;
  201. $recordData['mainId'] = $mainId;
  202. $recordData['orderSn'] = $orderSn;
  203. $recordData['itemId'] = $ptItemId;
  204. $recordData['oldStock'] = $oldStock; //当时库存
  205. $recordData['productId'] = $productId;
  206. $recordData['newStock'] = $newStock;// 最新库存
  207. $recordData['relateName'] = $ghsName;
  208. $recordData['io'] = 0;
  209. StockRecordClass::hdCgApplyRefundAddRecord($recordData);
  210. $refundSingle->itemStock = $oldStock;
  211. $refundSingle->newStock = $newStock;
  212. $refundSingle->save();
  213. }
  214. }
  215. }
  216. }
  217. //记录总的退款金额
  218. $currentTkPrice = bcadd($cg->tkPrice, $refundPrice, 2);
  219. $cg->tkPrice = $currentTkPrice;
  220. $cg->refund = PurchaseClass::REFUND_YES;
  221. $cg->save();
  222. $ghsId = $cg->ghsId;
  223. $ghs = GhsClass::getLockById($ghsId);
  224. if (empty($ghs)) {
  225. util::fail('没有找到供货商');
  226. }
  227. // 根据 $refundPrice 更新消费金额 expendAmount
  228. $expendAmount = bcsub($ghs->expendAmount, $refundPrice, 2);
  229. $ghs->expendAmount = $expendAmount;
  230. $ghs->save();
  231. if ($onlinePay == dict::getDict('onlinePay', 'yes')) {
  232. if ($payWay == dict::getDict('payWay', 'wxPay') || $payWay == dict::getDict('payWay', 'alipay')) {
  233. $ghsShopId = $ghs->shopId ?? 0;
  234. $ghsShop = ShopClass::getById($ghsShopId, true);
  235. if (empty($ghsShop)) {
  236. util::fail('没有找到供货商的门店');
  237. }
  238. $refundFee = bcmul($refundPrice, 100);
  239. $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
  240. $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
  241. $params = [
  242. 'appid' => 'OP00002119',
  243. 'serial_no' => '018b08cfddbd',
  244. 'merchant_no' => $ghsShop->lklSjNo,
  245. 'term_no' => $ghsShop->lklScanTermNo,
  246. 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
  247. 'lklCertificatePath' => $lklCertificatePath,
  248. ];
  249. $laResource = new Lakala($params);
  250. $refundReason = '';
  251. $aliParams = [
  252. 'refundSn' => $refundOrderSn,
  253. 'orderSn' => $orderSn,
  254. 'refundAmount' => $refundFee,
  255. 'refundReason' => $refundReason,
  256. 'thirdNo' => $transaction_id,//这个参数必传,不然聚合收银合支付宝付款的退款不会成功
  257. ];
  258. $response = $laResource->refund($aliParams);
  259. if (!isset($response['code']) || $response['code'] != 'BBS00000') {
  260. $errMsg = $response['msg'] ?? '';
  261. //$lklSjNo = $ghsShop->lklSjNo ?? '';
  262. //noticeUtil::push('商户号:' . $lklSjNo . '的退款失败了哦,请注意:' . $errMsg . ' 金额:' . $refundFee, '15280215347');
  263. util::fail('退款失败:' . $errMsg);
  264. }
  265. $refundTradeNo = isset($response['resp_data']['trade_no']) ? $response['resp_data']['trade_no'] : '';
  266. $cgRefund->thirdRefundNo = $refundTradeNo;
  267. $cgRefund->save();
  268. $cg->refundPrice = $refundPrice;
  269. $currentActPrice = bcsub($cg->actPrice, $refundPrice, 2);
  270. if ($currentActPrice < 0) {
  271. util::fail('可退款金额不足!!');
  272. }
  273. $cg->actPrice = $currentActPrice;
  274. $currentRealPrice = bcsub($cg->realPrice, $refundPrice, 2);
  275. if ($currentRealPrice < 0) {
  276. util::fail('可退款金额不足,请排查。');
  277. }
  278. $cg->realPrice = $currentRealPrice;
  279. $cg->save();
  280. } else {
  281. util::fail('暂不支持退款');
  282. }
  283. } else {
  284. if ($payWay == dict::getDict('payWay', 'debtPay')) {
  285. $clearId = $cg->clearId ?? 0;
  286. if (!empty($clearId)) {
  287. util::fail('订单已经结帐,无法再发起退款');
  288. }
  289. $cg->refundPrice = $refundPrice;
  290. $currentActPrice = bcsub($cg->actPrice, $refundPrice, 2);
  291. if ($currentActPrice < 0) {
  292. util::fail('可退款金额不足');
  293. }
  294. $cg->actPrice = $currentActPrice;
  295. $currentRealPrice = bcsub($cg->realPrice, $refundPrice, 2);
  296. if ($currentRealPrice < 0) {
  297. util::fail('可退款金额不足,请排查');
  298. }
  299. $cg->realPrice = $currentRealPrice;
  300. $currentRemainDebt = bcsub($cg->remainDebtPrice, $refundPrice, 2);
  301. if ($currentRemainDebt < 0) {
  302. util::fail('可退款金额不足哦');
  303. }
  304. if ($currentRemainDebt == 0) {
  305. $cg->debt = PurchaseClass::DEBT_NO;
  306. }
  307. $cg->remainDebtPrice = $currentRemainDebt;
  308. $cg->save();
  309. //门店应付总款减少
  310. $currentMayPay = bcsub($main->mayPay, $refundPrice, 2);
  311. if ($currentMayPay < 0) {
  312. //noticeUtil::push("应付款有问题! {$main->mayPay} {$refundPrice}", '15280215347');
  313. //util::fail('应付款有问题!');
  314. }
  315. $main->mayPay = $currentMayPay;
  316. $main->save();
  317. //应付供货商款减少
  318. GhsClass::refundDebtAmountReduce($ghs, $cgRefund, $cg);
  319. } elseif ($payWay == dict::getDict('payWay', 'balancePay')) {
  320. util::fail('余额支付暂不支持退款');
  321. //采购单总金额还要减去退款
  322. $cg->refundPrice = $refundPrice;
  323. $currentActPrice = bcsub($cg->actPrice, $refundPrice, 2);
  324. if ($currentActPrice < 0) {
  325. util::fail('退款金额有问题!');
  326. }
  327. $cg->actPrice = $currentActPrice;
  328. $currentRealPrice = bcsub($cg->realPrice, $refundPrice, 2);
  329. if ($currentRealPrice < 0) {
  330. util::fail('退款金额有问题,请排查');
  331. }
  332. $cg->realPrice = $currentRealPrice;
  333. $cg->save();
  334. //门店余额增加
  335. \biz\shop\classes\ShopClass::cgRefundAddBalance($main, $shop, $refundPrice, $cgRefund, $ghs);
  336. } elseif ($payWay == dict::getDict('payWay', 'cash')) {
  337. $cg->refundPrice = $refundPrice;
  338. $currentActPrice = bcsub($cg->actPrice, $refundPrice, 2);
  339. if ($currentActPrice < 0) {
  340. util::fail('可退款金额不足...');
  341. }
  342. $cg->actPrice = $currentActPrice;
  343. $currentRealPrice = bcsub($cg->realPrice, $refundPrice, 2);
  344. if ($currentRealPrice < 0) {
  345. util::fail('可退款金额不足,请确认');
  346. }
  347. $cg->realPrice = $currentRealPrice;
  348. $cg->save();
  349. } else {
  350. //其它线下退款直接完成
  351. $cg->refundPrice = $refundPrice;
  352. $currentActPrice = bcsub($cg->actPrice, $refundPrice, 2);
  353. if ($currentActPrice < 0) {
  354. util::fail('可退款金额不足...');
  355. }
  356. $cg->actPrice = $currentActPrice;
  357. $currentRealPrice = bcsub($cg->realPrice, $refundPrice, 2);
  358. if ($currentRealPrice < 0) {
  359. util::fail('可退款金额不足,请确认');
  360. }
  361. $cg->realPrice = $currentRealPrice;
  362. $cg->save();
  363. }
  364. }
  365. return $cgRefund;
  366. }
  367. //驳回 ssh 20230811
  368. public static function reject($cgRefund, $rejectReason)
  369. {
  370. if ($cgRefund->status == self::STATUS_COMPLETE) {
  371. util::fail('申请已通过');
  372. }
  373. if ($cgRefund->status == self::STATUS_REJECT) {
  374. util::fail('申请已驳回');
  375. }
  376. if ($cgRefund->status == self::STATUS_CANCEL) {
  377. util::fail('申请已取消');
  378. }
  379. $cgRefund->status = self::STATUS_REJECT;
  380. $cgRefund->rejectReason = $rejectReason;
  381. $cgRefund->save();
  382. }
  383. //取消退款 ssh 20230808
  384. public static function cancelRefund($refund)
  385. {
  386. if ($refund->status == self::STATUS_COMPLETE) {
  387. util::fail('申请已通过');
  388. }
  389. if ($refund->status == self::STATUS_REJECT) {
  390. util::fail('申请已驳回');
  391. }
  392. if ($refund->status == self::STATUS_CANCEL) {
  393. util::fail('申请已取消');
  394. }
  395. $refund->status = self::STATUS_CANCEL;
  396. $refund->save();
  397. }
  398. public static function valid($refund, $mainId)
  399. {
  400. if (isset($refund->mainId) == false || $refund->mainId != $mainId) {
  401. util::fail('无法访问,编号5');
  402. }
  403. return true;
  404. }
  405. public static function getRefundList($where)
  406. {
  407. $data = self::getList('*', $where, 'addTime DESC');
  408. $list = isset($data['list']) && !empty($data['list']) ? $data['list'] : [];
  409. if (empty($list)) {
  410. return $data;
  411. }
  412. $data['list'] = $list;
  413. return $data;
  414. }
  415. //2021.1.23 lqh 订单详情
  416. public static function getOrderDetail($orderSn, $shopId)
  417. {
  418. $orderData = self::orderExist(['orderSn' => $orderSn, 'shopId' => $shopId]);
  419. $orderInfo = CgRefundItemClass::getOrderItemDetail($orderSn);
  420. $itemData = [];
  421. if ($orderInfo) {
  422. foreach ($orderInfo as $v) {
  423. $info = json_decode($v['itemInfo'], true);
  424. $tmp = $info;
  425. $tmp['itemCover'] = self::groupImg($info['itemCover']);
  426. unset($v['itemInfo']);
  427. //兼容 旧数据,没有 rank (花材等级 默认给B)
  428. if (!isset($tmp['rank'])) {
  429. $tmp['rank'] = 'B';
  430. }
  431. $tmp = array_merge($tmp, $v);
  432. $itemData[] = $tmp;
  433. }
  434. }
  435. //下面注释放开前,员工id要用shopAdminId
  436. //$orderData = self::groupAdmin($orderData);
  437. $orderData['itemInfo'] = $itemData;
  438. return $orderData;
  439. }
  440. //2021.1.23 lqh 判断定时是否存在
  441. public static function orderExist($where)
  442. {
  443. $orderData = self::getByCondition($where);
  444. if (!$orderData) {
  445. util::fail('订单不存在');
  446. }
  447. return $orderData;
  448. }
  449. // 组装 orderItem lqh 2021.1.25
  450. public static function groupOrderItem($ghsItemInfo, $orderSn, $cgItemList)
  451. {
  452. $productData = self::getProductMapData($ghsItemInfo);
  453. //写入详情表
  454. $batchData = [];
  455. foreach ($ghsItemInfo as $v) {
  456. $tmp = [];
  457. $productId = $v['productId'];
  458. $itemId = $productData[$productId]['itemId'];
  459. $rank = $productData[$productId]['rank'] ?? 'B';// 花材级别
  460. $tmp['orderSn'] = $orderSn;
  461. $tmp['itemId'] = $itemId;
  462. $tmp['productId'] = $v['productId'];
  463. $unitNum = $productData[$productId]['ratio'] ?? 0;
  464. $tmp['itemStock'] = $v['oldStock'];//当时库存
  465. $tmp['newStock'] = $v['newStock'];//当时库存
  466. $tmp['itemNum'] = ProductClass::mergeItemNum($v['bigNum'], $v['smallNum'], $unitNum);// 数量
  467. $tmp['name'] = $productData[$productId]['name'] ?? '';
  468. $tmp['cover'] = $productData[$productId]['cover'] ?? '';
  469. $tmp['itemPrice'] = $cgItemList[$productId]['price'] ?? 0; //当时售卖的价格
  470. $tmp['totalPrice'] = bcmul($tmp['itemPrice'], $tmp['itemNum'], 2);
  471. $tmp['itemCost'] = $productData[$productId]['cost'] ?? 0; //当时成本价
  472. $stockFormat = ProductClass::formatStock($tmp['itemStock'], $unitNum); // 库存总单位数量转大小单位的数量
  473. $itemInfo = [
  474. 'itemName' => $productData[$productId]['name'] ?? '',//花材名称
  475. 'itemCover' => $productData[$productId]['cover'] ?? '',//花材图片
  476. 'bigNum' => $v['bigNum'] ?? 0,//数量(大单位)
  477. 'smallNum' => $v['smallNum'] ?? 0,//数量(小单位)
  478. 'bigNumStock' => $stockFormat['bigNum'],// 当时库存大单位数
  479. 'smallNumStock' => $stockFormat['smallNum'],//当时库存 小单位数
  480. 'itemUnit' => $unitNum ? 2 : 1,//单位数量 2表示有两个单位(e.g 扎和支) 1表是只有一个单位(e.g 扎)
  481. 'ratio' => $unitNum,// 比例
  482. 'rank' => $rank,// 花材级别
  483. 'bigUnit' => $productData[$productId]['bigUnit'],//大单位名称 扎
  484. 'smallUnit' => $productData[$productId]['smallUnit'],//小单位名称 支
  485. ];
  486. $tmp['itemInfo'] = json_encode($itemInfo);
  487. $batchData[] = $tmp;
  488. }
  489. return $batchData;
  490. }
  491. }