OrderClass.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  1. <?php
  2. namespace bizHd\order\classes;
  3. use biz\goods\classes\GoodsClass;
  4. use biz\goods\models\Goods;
  5. use biz\shop\classes\ShopAdminClass;
  6. use biz\shop\classes\ShopCapitalClass;
  7. use biz\shop\classes\ShopClass;
  8. use biz\shop\classes\ShopExtClass;
  9. use biz\shop\models\Shop;
  10. use biz\stat\classes\StatKdClass;
  11. use biz\stat\classes\StatOrderCountClass;
  12. use biz\stat\classes\StatSaleClass;
  13. use biz\stock\classes\GoodsStockRecordClass;
  14. use biz\wx\classes\WxMessageClass;
  15. use bizGhs\product\classes\ProductClass;
  16. use bizGhs\stat\classes\StatYjClass;
  17. use bizGhs\stock\classes\StockRecordClass;
  18. use bizGhs\ws\services\WsService;
  19. use bizHd\custom\classes\CustomClass;
  20. use bizHd\merchant\classes\SjClass;
  21. use bizHd\shop\classes\MainClass;
  22. use bizHd\stat\classes\StatIncomeClass;
  23. use bizHd\stat\classes\StatOrderClass;
  24. use bizHd\user\classes\UserClass;
  25. use bizHd\work\classes\WorkClass;
  26. use common\components\dict;
  27. use common\components\miniUtil;
  28. use common\components\orderSn;
  29. use common\components\printUtil;
  30. use common\components\util;
  31. use Yii;
  32. use bizHd\base\classes\BaseClass;
  33. class OrderClass extends BaseClass
  34. {
  35. public static $baseFile = '\bizHd\order\models\Order';
  36. //已取消
  37. const ORDER_STATUS_CANCEL = 5;
  38. //完成
  39. const ORDER_STATUS_COMPLETE = 4;
  40. //配送中
  41. const ORDER_STATUS_SENDING = 3;
  42. //待配送
  43. const ORDER_STATUS_UN_SEND = 2;
  44. //待付款
  45. const ORDER_STATUS_UN_PAY = 1;
  46. //订单总流程数
  47. const ORDER_TOTAL_FLOW = 4;
  48. //未确认配送方式
  49. const SEND_TYPE_UNKNOWN = 0;
  50. //自取
  51. const SEND_TYPE_NO = 1;
  52. //自己送
  53. const SEND_TYPE_MYSELF = 2;
  54. //快递送
  55. const SEND_TYPE_THIRD = 3;
  56. //正常订单
  57. const REFUND_NO = 0;
  58. //已退款订单
  59. const REFUND_YES = 1;
  60. //送达时间段
  61. public static $reachPeriod = [0 => '上午', 1 => '下午', 2 => '晚上'];
  62. //优惠金额
  63. public static $randDiscount = [
  64. 50 => [1, 3],
  65. 100 => [5, 9],
  66. 300 => [10, 15],
  67. 500 => [16, 18],
  68. 1000 => [18, 30],
  69. 20000 => [90, 100],
  70. ];
  71. public static function valid($order, $mainId)
  72. {
  73. if (isset($order->mainId) == false || $order->mainId != $mainId) {
  74. util::fail('没有权限访问的订单');
  75. }
  76. return true;
  77. }
  78. //添加订单 ssh 2019.12.5
  79. public static function addOrder($data)
  80. {
  81. $data['orderSn'] = $data['orderSn'] ?? orderSn::getOrderSn();
  82. $data['payStatus'] = $data['payStatus'] ?? 0;
  83. $shopId = $data['shopId'] ?? 0;
  84. //累计订单增加
  85. $shop = ShopClass::getLockById($shopId);
  86. if (empty($shop)) {
  87. util::fail('没有找到门店信息');
  88. }
  89. $mainId = $shop->mainId ?? 0;
  90. $main = MainClass::getLockById($mainId);
  91. if (empty($main)) {
  92. util::fail('没有找到main信息');
  93. }
  94. $main->unPayOrder += 1;
  95. $main->totalOrder += 1;
  96. $main->save();
  97. $address = $data['address'] ?? '';
  98. $floor = $data['floor'] ?? '';
  99. $data['fullAddress'] = $address . $floor;
  100. $data['reachDate'] = isset($data['reachDate']) && !empty($data['reachDate']) ? $data['reachDate'] : '0000-00-00';
  101. //将花店每月的总订单数作为编号
  102. $riseNum = StatOrderCountClass::addOrder($shop, $main);
  103. $data['sendNum'] = date("d") . $riseNum;
  104. $data['totalFlow'] = OrderClass::ORDER_TOTAL_FLOW;
  105. $return = self::add($data, true);
  106. return $return;
  107. }
  108. public static function getByOrderSn($orderSn)
  109. {
  110. return self::getByCondition(['orderSn' => $orderSn]);
  111. }
  112. //评价 ssh 2019.12.16
  113. public static function comment($data)
  114. {
  115. $id = $data['id'];
  116. unset($data['id']);
  117. return self::updateById($id, $data);
  118. }
  119. public static function getFullInfo($id)
  120. {
  121. $order = self::getById($id);
  122. if (empty($order)) {
  123. return [];
  124. }
  125. $sn = $order['orderSn'] ?? '';
  126. $order['goodsInfoList'] = OrderGoodsClass::getListBySn($sn);
  127. $order['itemInfoList'] = OrderItemClass::getListBySn($sn);
  128. return $order;
  129. }
  130. //订单
  131. public static function getOrderById($id)
  132. {
  133. $order = self::getById($id);
  134. if (empty($order)) {
  135. return [];
  136. }
  137. $sn = $order['orderSn'] ?? '';
  138. $order['goodsInfoList'] = OrderGoodsClass::getListBySn($sn);
  139. return $order;
  140. }
  141. //根据订单查询 ssh 2020.1.4
  142. public static function getOrderBySn($orderSn)
  143. {
  144. $order = self::getByCondition(['orderSn' => $orderSn]);
  145. if (empty($order)) {
  146. return [];
  147. }
  148. $id = $order['id'];
  149. $order['goodsInfoList'] = OrderGoodsClass::getGoodsListById($id);
  150. return $order;
  151. }
  152. //返回随机优惠金额 ssh 2019.9.12
  153. public static function getRandDiscount($amount)
  154. {
  155. if ($amount <= 0) {
  156. return 0;
  157. }
  158. $randDiscount = self::$randDiscount;
  159. krsort($randDiscount);
  160. $rand = 0;
  161. foreach ($randDiscount as $currentAmount => $val) {
  162. if ($amount >= $currentAmount) {
  163. $rand = rand($val[0], $val[1]);
  164. break;
  165. }
  166. }
  167. return $rand / 10;
  168. }
  169. //第三方支付后回调处理流程 ssh 2021.4.30
  170. public static function thirdPay($payWay, $orderSn, $totalFee, $attach, $transactionId)
  171. {
  172. $order = self::getByCondition(['orderSn' => $orderSn], true);
  173. if (empty($order)) {
  174. $msg = "没有找到零售订单 orderSn:{$orderSn}";
  175. Yii::info($msg);
  176. util::fail($msg);
  177. }
  178. if ($order->realPrice != $totalFee) {
  179. $msg = "零售订单金额与回调通知金额不一致 orderSn:{$orderSn} {$order->realPrice} {$totalFee}";
  180. Yii::info($msg);
  181. util::fail($msg);
  182. }
  183. $id = $order->id;
  184. $order = self::getLockById($id);
  185. $date = date("Y-m-d H:i:s");
  186. $order->payTime = $date;
  187. $order->thirdNo = $transactionId;
  188. $order->onlinePay = dict::getDict('onlinePay', 'yes');
  189. $order->save();
  190. self::payAfter($order, $payWay);
  191. }
  192. //订单完成 ssh 2021.4.20
  193. public static function payAfter($order, $payWay)
  194. {
  195. if (empty($order)) {
  196. util::fail('没有找到订单');
  197. }
  198. if (isset($order->status) == false || $order->status != self::ORDER_STATUS_UN_PAY) {
  199. util::fail('订单不是待付款状态');
  200. }
  201. $orderId = $order->id ?? 0;
  202. $order->status = self::ORDER_STATUS_COMPLETE;
  203. $order->payWay = $payWay;
  204. $order->payStatus = 1;
  205. $order->stockChange = 1;
  206. $order->save();
  207. \bizMall\order\classes\OrderGoodsClass::stockChange($order);
  208. $realPrice = $order->realPrice ?? 0;
  209. $shopId = $order->shopId;
  210. $shop = ShopClass::getLockById($shopId);
  211. if (empty($shop)) {
  212. util::fail('没有找到门店');
  213. }
  214. $mainId = $shop->mainId ?? 0;
  215. $main = MainClass::getLockById($mainId);
  216. if (empty($main)) {
  217. util::fail('没有main信息');
  218. }
  219. $main->unSendOrder += 1;
  220. $main->unPayOrder -= 1;
  221. $currentTotalIncome = bcadd($main->totalIncome, $realPrice, 2);
  222. $main->totalIncome = $currentTotalIncome;
  223. $main->save();
  224. $capitalType = dict::getDict('capitalType', 'xhOrder', 'id');
  225. $shopAdminId = $order->shopAdminId ?? 0;
  226. $shopAdminName = $order->shopAdminName ?? '';
  227. $sjId = $order->sjId;
  228. $fromType = $order->fromType ?? 1;
  229. $event = !empty($shopAdminId) ? '员工开单' : '客户下单';
  230. $capital = [
  231. 'capitalType' => $capitalType,
  232. 'relateId' => $orderId,
  233. 'io' => 1,
  234. 'totalIncome' => $currentTotalIncome,
  235. 'payWay' => $payWay,
  236. 'event' => $event,
  237. 'sjId' => $sjId,
  238. 'shopId' => $shopId,
  239. 'shopAdminId' => $shopAdminId,
  240. 'shopAdminName' => $shopAdminName,
  241. 'amount' => $realPrice,
  242. 'fromType' => $fromType,
  243. 'mainId' => $mainId,
  244. ];
  245. ShopCapitalClass::addCapital($capital);
  246. //每天和每月收入增加
  247. StatIncomeClass::updateOrInsert($main, $shop, $realPrice);
  248. //今日订单+1
  249. StatOrderClass::updateOrInsert($main, $shop);
  250. //销售收入增加
  251. StatSaleClass::replace($main, $shop, $realPrice);
  252. //各渠道收入金额统计
  253. StatKdClass::replace($shop, $realPrice, $payWay);
  254. //客户在线支付下单增加商家可提现余额
  255. if (isset($order->onlinePay) && $order->onlinePay == dict::getDict('onlinePay', 'yes')) {
  256. $amount = $order->actPrice;
  257. ShopClass::customKdAddBalance($main, $shop, $amount, $order, $capitalType);
  258. }
  259. }
  260. //转化出送到时间 ssh 2020.3.15
  261. public static function getReachTime($order)
  262. {
  263. $reachTime = '';
  264. if (isset($order['reachDate']) && !empty($order['reachDate'])) {
  265. $prev = date("n-j", strtotime($order['reachDate']));
  266. $periodData = self::$reachPeriod;
  267. $periodKey = $order['reachPeriod'];
  268. $period = isset($periodData[$periodKey]) ? $periodData[$periodKey] : '上午';
  269. $reachTime = $prev . ' ' . $period;
  270. }
  271. return $reachTime;
  272. }
  273. //支付成功获取unionId ssh 2020.5.12
  274. public static function payToUpdateUnionId($merchant, $merchantExtend, $orderSn, $user)
  275. {
  276. $mcId = $merchantExtend['wxPayMerchantId'];
  277. $miniOpenId = isset($user['miniOpenId']) ? $user['miniOpenId'] : '';
  278. $unionId = isset($user['unionId']) ? $user['unionId'] : '';
  279. $userId = $user['id'];
  280. if (empty($unionId)) {
  281. $unionId = miniUtil::getPaidUnionId($merchant, $miniOpenId, $mcId, (string)$orderSn, 0);
  282. if (!empty($unionId)) {
  283. $findUser = UserClass::getByUnionId($unionId);
  284. if (empty($findUser)) {
  285. UserClass::updateByCondition(['id' => $userId], ['unionId' => $unionId]);
  286. } else {
  287. UserClass::mergeUser($findUser, $user);
  288. }
  289. }
  290. }
  291. }
  292. //订单取消 ssh 20220516
  293. public static function setExpire($order)
  294. {
  295. $now = time();
  296. if ($order->deadline > $now) {
  297. return false;
  298. }
  299. if ($order->status != 1) {
  300. return false;
  301. }
  302. $order->status = 5;
  303. $order->save();
  304. //暂时只考虑花材库存的回滚。商品只有下单成功了才会占用库存。
  305. $orderSn = $order->orderSn ?? '';
  306. $itemList = OrderItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*', null, true);
  307. if (!empty($itemList)) {
  308. foreach ($itemList as $item) {
  309. $ptItemId = $item->ptItemId ?? 0;
  310. $sjId = $item->sjId ?? 0;
  311. $shopId = $item->shopId ?? 0;
  312. $mainId = $item->mainId ?? 0;
  313. $ratio = $item->ratio ?? 20;
  314. $unitType = $item->unitType ?? 0;
  315. $bigNum = 0;
  316. $smallNum = 0;
  317. if ($unitType == 0) {
  318. $bigNum = $item->num;
  319. } else {
  320. $smallNum = $item->num;
  321. }
  322. $itemId = $item->itemId ?? 0;
  323. $stockInfo = ProductClass::addStock($itemId, $bigNum, $smallNum);
  324. $recordData = [];
  325. $recordData['sjId'] = $sjId;
  326. $recordData['shopId'] = $shopId;
  327. $recordData['mainId'] = $mainId;
  328. $recordData['itemId'] = $ptItemId;
  329. $recordData['itemNum'] = ProductClass::mergeItemNum($bigNum, $smallNum, $ratio);
  330. $recordData['oldStock'] = $stockInfo['oldStock'];
  331. $recordData['newStock'] = $stockInfo['newStock'];
  332. $recordData['productId'] = $itemId;
  333. $recordData['orderSn'] = $orderSn;
  334. $recordData['relateName'] = '系统';
  335. StockRecordClass::addSellStockOrderCancelRecord($recordData);
  336. }
  337. }
  338. }
  339. // 扣库存
  340. protected static function decGoodsStock($orderGoods)
  341. {
  342. foreach ($orderGoods as $goods) {
  343. GoodsClass::counters([
  344. 'stock' => -$goods['num']
  345. ], [
  346. 'and',
  347. ['id' => $goods['goodsId']],
  348. ['<>', 'stock', Goods::FULL_STOCK]
  349. ]);
  350. }
  351. }
  352. // 更新商品销量
  353. protected static function updateGoodsActualSold($orderGoods)
  354. {
  355. foreach ($orderGoods as $goods) {
  356. GoodsClass::counters([
  357. 'actualSold' => $goods['num']
  358. ], [
  359. 'id' => $goods['goodsId']
  360. ]);
  361. }
  362. }
  363. //云打印 ssh 20210709
  364. public static function onlinePrint($order)
  365. {
  366. if (empty($order)) {
  367. return false;
  368. }
  369. if ($order->needPrint != dict::getDict('needPrint', 'need')) {
  370. return false;
  371. }
  372. if ($order->payStatus != 1) {
  373. return false;
  374. }
  375. $shopId = $order->shopId ?? 0;
  376. $ext = ShopExtClass::getByCondition(['shopId' => $shopId]);
  377. $printSn = $ext['printSn'] ?? '';
  378. if (empty($printSn)) {
  379. return false;
  380. }
  381. $order->printNum += 1;
  382. $order->save();
  383. $customId = $order->customId ?? 0;
  384. $custom = CustomClass::getById($customId);
  385. $debtAmount = $custom['debtAmount'] ?? 0;
  386. $fromType = $order->fromType ?? dict::getDict('fromType', 'shop');
  387. $fromTypeMap = dict::getDict('fromTypeMap');
  388. $fromTypeName = $fromTypeMap[$fromType] ?? '门店';
  389. $respond = self::getPrintData($order, $debtAmount);
  390. $content = '<B>' . $respond['sendNum'] . ' ' . $fromTypeName . '</B><BR>';
  391. $content .= '--------------------------------<BR>';
  392. if (isset($order->receiveMobile) && !empty($order->receiveMobile)) {
  393. $readPeriod = $order->reachPeriod ?? 0;
  394. $reachPeriodName = dict::getDict('reachPeriodName');
  395. $period = $reachPeriodName[$readPeriod] ?? '上午';
  396. $content .= '<B>' . $order->receiveUserName . '</B><BR>';
  397. $content .= '<B>' . $order->receiveMobile . '</B><BR><BR>';
  398. $content .= '<B>' . $order->reachDate . ' ' . $period . '</B><BR><BR>';
  399. $content .= '<B>' . $order->fullAddress . '(' . $order->showAddress . ')' . '</B><BR><BR>';
  400. if ($order->needCard == 1) {
  401. $content .= '<B>需要贺卡</B><BR>';
  402. }
  403. if (!empty($order->cardInfo)) {
  404. $content .= '贺卡内容:' . $order->cardInfo . '<BR><BR>';
  405. }
  406. if ($order->anonymity == 1) {
  407. $content .= '<B>匿名派送!!!</B><BR><BR>';
  408. } else {
  409. $content .= '订花人电话:' . $order->bookMobile . '<BR><BR>';
  410. }
  411. }
  412. if (isset($respond['remark']) && !empty($respond['remark'])) {
  413. $content .= '<BR>';
  414. $content .= '备注:<BR>';
  415. $content .= '<B>' . $respond['remark'] . '</B><BR>';
  416. }
  417. $content .= '<BR>';
  418. $content .= '花材 数量/单价 金额 <BR>';
  419. $content .= '--------------------------------<BR>';
  420. if (isset($respond['product']) && !empty($respond['product'])) {
  421. foreach ($respond['product'] as $current) {
  422. $content = self::printGroup($current, $content);
  423. }
  424. $content .= '--------------------------------<BR>';
  425. }
  426. if (isset($respond['refund']) && !empty($respond['refund'])) {
  427. $content .= '<B>已退款:</B><BR>';
  428. foreach ($respond['refund'] as $current) {
  429. //58mm的机器,一行打印16个汉字,32个字母
  430. $name = $current['name'] ?? '';
  431. $content .= $name . '<BR>';
  432. $name = str_repeat(' ', 10);
  433. $productNum = $current['num'] ?? '';
  434. $blankNum = bcsub(12, strlen($productNum));
  435. if ($blankNum > 0) {
  436. $productNum = $productNum . str_repeat(' ', $blankNum);
  437. }
  438. $productPrice = $current['price'] ?? '';
  439. $blankNum = bcsub(7, strlen($productPrice));
  440. if ($blankNum > 0) {
  441. $productPrice = $productPrice . str_repeat(' ', $blankNum);
  442. }
  443. $content .= $name . " " . $productNum . ' ' . $productPrice . '<BR>';
  444. }
  445. $content .= '--------------------------------<BR>';
  446. }
  447. if (isset($respond['sendCost']) && $respond['sendCost'] > 0) {
  448. $content .= ' 运费:' . floatval($respond['sendCost']) . '<BR>';
  449. }
  450. $content .= '订单金额:' . floatval($respond['orderPrice']) . '<BR>';
  451. if (isset($respond['discountAmount']) && !empty($respond['discountAmount']) && $respond['discountAmount'] > 0) {
  452. $content .= '优惠扣除:-' . floatval($respond['discountAmount']) . '<BR>';
  453. }
  454. if (isset($respond['refundPrice']) && $respond['refundPrice'] > 0) {
  455. $content .= '退款金额:' . floatval($respond['refundPrice']) . '<BR>';
  456. }
  457. $content .= '应付金额:' . floatval($respond['orderPrice']) . '<BR>';
  458. if (isset($respond['debt']) && $respond['debt'] == 1) {
  459. $content .= '实付金额:0<BR>';
  460. } else {
  461. $content .= '实付金额:' . floatval($respond['realPrice']) . '<BR>';
  462. }
  463. if ($debtAmount > 0) {
  464. $content .= '累计欠款:' . floatval($debtAmount) . '<BR>';
  465. }
  466. $shop = ShopClass::getById($shopId, true);
  467. $sjId = $shop->sjId ?? 0;
  468. $sj = SjClass::getById($sjId, true);
  469. $sjName = $sj->name ?? '';
  470. $currentName = $sjName;
  471. if (isset($shop->default) == false || $shop->default != 1) {
  472. $shopName = $shop->shopName ?? '';
  473. if (!empty($shopName)) {
  474. $currentName = $currentName . ' ' . $shopName;
  475. }
  476. }
  477. $content .= '--------------------------------<BR>';
  478. $content .= '订单日期:' . $order->addTime . '<BR>';
  479. $content .= '订单编号:' . $respond['orderSn'] . '<BR>';
  480. $content .= '门店名称:' . $currentName . '<BR>';
  481. $content .= "<BR>";
  482. $p = new printUtil($printSn);
  483. $orderSn = $order->orderSn ?? '';
  484. $workList = WorkClass::getAllByCondition(['orderSn' => $orderSn], null, '*', null, true);
  485. if (!empty($workList)) {
  486. $content .= "<BR>";
  487. $content .= '--------------------------------<BR>';
  488. foreach ($workList as $work) {
  489. $goodsSn = $work->goodsSn ?? '';
  490. $sn = $work->sn ?? '';
  491. $content .= '<B>制作单编号:' . $sn . '<B>';
  492. // 1-523 有-特殊符号,使用飞鹅自带的函数处理
  493. $content .= $p->bar_code($goodsSn);
  494. $content .= "<BR>";
  495. }
  496. }
  497. $p->printMsg($content);
  498. }
  499. //打印数据 ssh 20210702
  500. public static function getPrintData($order, $debtAmount)
  501. {
  502. $orderSn = $order->orderSn ?? '';
  503. $printProduct = [];
  504. $orderItemList = OrderItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*');
  505. if (!empty($orderItemList)) {
  506. foreach ($orderItemList as $itemKey => $itemVal) {
  507. $unitName = $itemVal['unitName'] ?? '';
  508. $unitPrice = $itemVal['unitPrice'] ? floatval($itemVal['unitPrice']) : 0;
  509. $printProduct[] = [
  510. 'name' => $itemVal['name'] ?? '',
  511. 'num' => $itemVal['num'] . $unitName . '*' . $unitPrice,
  512. 'price' => floatval($itemVal['price']),
  513. ];
  514. }
  515. }
  516. $orderGoodsList = OrderGoodsClass::getAllByCondition(['orderSn' => $orderSn], null, '*');
  517. if (!empty($orderGoodsList)) {
  518. foreach ($orderGoodsList as $itemKey => $itemVal) {
  519. $unitName = $itemVal['unitName'] ?? '份';
  520. $unitPrice = $itemVal['unitPrice'] ? floatval($itemVal['unitPrice']) : 0;
  521. $printProduct[] = [
  522. 'name' => $itemVal['name'] ?? '',
  523. 'num' => $itemVal['num'] . $unitName . '*' . $unitPrice,
  524. 'price' => floatval($itemVal['price']),
  525. ];
  526. }
  527. }
  528. $sendNum = $order['sendNum'] ?? '';
  529. //退款记录
  530. $refundList = [];
  531. $printData = [
  532. 'address' => '',
  533. 'sendCost' => $order->sendCost ?? '0.00',
  534. 'prePrice' => $order->prePrice ?? '0.00',
  535. 'orderPrice' => $order->orderPrice ?? '0',
  536. 'discountAmount' => $order->discountAmount ?? '0.00',
  537. 'realPrice' => $order->realPrice ?? '0.00',
  538. 'refundPrice' => $order->refundPrice ?? '0.00',
  539. 'debt' => $order->debt ?? 0,
  540. 'orderSn' => $order->orderSn ?? '',
  541. 'date' => $order->addTime ?? '',
  542. 'remark' => $order->remark ?? '',
  543. 'custom' => [
  544. 'customName' => $order->customName ?? '',
  545. 'customMobile' => $order->customMobile ?? '',
  546. 'fullAddress' => $order->fullAddress ?? '',
  547. ],
  548. 'product' => $printProduct,
  549. 'refund' => $refundList,
  550. 'sendNum' => $sendNum,
  551. 'debtAmount' => $debtAmount,
  552. ];
  553. return $printData;
  554. }
  555. public static function printGroup($current, $content)
  556. {
  557. //58mm的机器,一行打印16个汉字,32个字母
  558. $name = $current['name'] ?? '';
  559. $content .= $name . '<BR>';
  560. $name = str_repeat(' ', 10);
  561. $productNum = $current['num'] ?? '';
  562. $blankNum = bcsub(12, strlen($productNum));
  563. if ($blankNum > 0) {
  564. $productNum = $productNum . str_repeat(' ', $blankNum);
  565. }
  566. $productPrice = $current['price'] ?? '';
  567. $blankNum = bcsub(7, strlen($productPrice));
  568. if ($blankNum > 0) {
  569. $productPrice = $productPrice . str_repeat(' ', $blankNum);
  570. }
  571. $content .= $name . " " . $productNum . ' ' . $productPrice . '<BR>';
  572. return $content;
  573. }
  574. }