|
|
@@ -7,11 +7,14 @@ use biz\goods\models\Goods;
|
|
|
use biz\shop\classes\ShopAdminClass;
|
|
|
use biz\shop\classes\ShopCapitalClass;
|
|
|
use biz\shop\classes\ShopClass;
|
|
|
+use biz\shop\classes\ShopExtClass;
|
|
|
use biz\shop\models\Shop;
|
|
|
use biz\stat\classes\StatOrderCountClass;
|
|
|
use biz\wx\classes\WxMessageClass;
|
|
|
use bizGhs\stat\classes\StatYjClass;
|
|
|
use bizGhs\ws\services\WsService;
|
|
|
+use bizHd\custom\classes\CustomClass;
|
|
|
+use bizHd\merchant\classes\SjClass;
|
|
|
use bizHd\shop\classes\MainClass;
|
|
|
use bizHd\stat\classes\StatIncomeClass;
|
|
|
use bizHd\stat\classes\StatOrderClass;
|
|
|
@@ -19,6 +22,7 @@ use bizHd\user\classes\UserClass;
|
|
|
use common\components\dict;
|
|
|
use common\components\miniUtil;
|
|
|
use common\components\orderSn;
|
|
|
+use common\components\printUtil;
|
|
|
use common\components\util;
|
|
|
use Yii;
|
|
|
use bizHd\base\classes\BaseClass;
|
|
|
@@ -207,6 +211,7 @@ class OrderClass extends BaseClass
|
|
|
$orderId = $order->id ?? 0;
|
|
|
$order->status = self::ORDER_STATUS_COMPLETE;
|
|
|
$order->payWay = $payWay;
|
|
|
+ $order->payStatus = 1;
|
|
|
$order->save();
|
|
|
|
|
|
$realPrice = $order->realPrice ?? 0;
|
|
|
@@ -337,4 +342,196 @@ class OrderClass extends BaseClass
|
|
|
]);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ //云打印 ssh 20210709
|
|
|
+ public static function onlinePrint($order)
|
|
|
+ {
|
|
|
+ $customId = $order->customId ?? 0;
|
|
|
+ $custom = CustomClass::getById($customId);
|
|
|
+ $debtAmount = $custom['debtAmount'] ?? 0;
|
|
|
+
|
|
|
+ $respond = self::getPrintData($order, $debtAmount);
|
|
|
+ $content = '<B>' . $respond['sendNum'] . '</B><BR>';
|
|
|
+ $content .= '--------------------------------<BR>';
|
|
|
+ $content .= '<B>' . $respond['custom']['fullAddress'] . '</B><BR>';
|
|
|
+ $content .= '<B>' . $respond['custom']['customName'] . '</B><BR>';
|
|
|
+ $content .= '<B>' . $respond['custom']['customMobile'] . '</B><BR>';
|
|
|
+
|
|
|
+ $payDate = date("Y-m-d", strtotime($order->payTime));
|
|
|
+ $sendTimeWant = $order->sendTimeWant ?? '';
|
|
|
+ if (!empty($sendTimeWant) && $payDate != $sendTimeWant) {
|
|
|
+ $content .= '<BR>';
|
|
|
+ $content .= '送货时间:<BR>';
|
|
|
+ $content .= '<B>' . $sendTimeWant . '</B><BR>';
|
|
|
+ }
|
|
|
+ if (isset($respond['remark']) && !empty($respond['remark'])) {
|
|
|
+ $content .= '<BR>';
|
|
|
+ $content .= '备注:<BR>';
|
|
|
+ $content .= '<B>' . $respond['remark'] . '</B><BR>';
|
|
|
+ }
|
|
|
+
|
|
|
+ $content .= '<BR>';
|
|
|
+ $content .= '花材 数量/单价 金额 <BR>';
|
|
|
+ $content .= '--------------------------------<BR>';
|
|
|
+
|
|
|
+ if (isset($respond['product']) && !empty($respond['product'])) {
|
|
|
+ foreach ($respond['product'] as $current) {
|
|
|
+
|
|
|
+ $content = self::printGroup($current, $content);
|
|
|
+
|
|
|
+ }
|
|
|
+ $content .= '--------------------------------<BR>';
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isset($respond['refund']) && !empty($respond['refund'])) {
|
|
|
+ $content .= '<B>已退款:</B><BR>';
|
|
|
+ foreach ($respond['refund'] as $current) {
|
|
|
+ //58mm的机器,一行打印16个汉字,32个字母
|
|
|
+ $name = $current['name'] ?? '';
|
|
|
+ $content .= $name . '<BR>';
|
|
|
+ $name = str_repeat(' ', 10);
|
|
|
+
|
|
|
+ $productNum = $current['num'] ?? '';
|
|
|
+ $blankNum = bcsub(12, strlen($productNum));
|
|
|
+ if ($blankNum > 0) {
|
|
|
+ $productNum = $productNum . str_repeat(' ', $blankNum);
|
|
|
+ }
|
|
|
+
|
|
|
+ $productPrice = $current['price'] ?? '';
|
|
|
+ $blankNum = bcsub(7, strlen($productPrice));
|
|
|
+ if ($blankNum > 0) {
|
|
|
+ $productPrice = $productPrice . str_repeat(' ', $blankNum);
|
|
|
+ }
|
|
|
+ $content .= $name . " " . $productNum . ' ' . $productPrice . '<BR>';
|
|
|
+ }
|
|
|
+ $content .= '--------------------------------<BR>';
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isset($respond['sendCost']) && $respond['sendCost'] > 0) {
|
|
|
+ $content .= ' 运费:' . $respond['sendCost'] . '<BR>';
|
|
|
+ }
|
|
|
+ $content .= '订单金额:' . $respond['prePrice'] . '<BR>';
|
|
|
+ if (isset($respond['discountAmount']) && !empty($respond['discountAmount']) && $respond['discountAmount'] > 0) {
|
|
|
+ $content .= '优惠扣除:' . $respond['discountAmount'] . '<BR>';
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isset($respond['refundPrice']) && $respond['refundPrice'] > 0) {
|
|
|
+ $content .= '退款金额:' . $respond['refundPrice'] . '<BR>';
|
|
|
+ }
|
|
|
+
|
|
|
+ $content .= '应付金额:' . $respond['realPrice'] . '<BR>';
|
|
|
+ if (isset($respond['debt']) && $respond['debt'] == 1) {
|
|
|
+ $content .= '实付金额:0.00<BR>';
|
|
|
+ } else {
|
|
|
+ $content .= '实付金额:' . $respond['realPrice'] . '<BR>';
|
|
|
+ }
|
|
|
+ if ($debtAmount > 0) {
|
|
|
+ $content .= '累计欠款:' . $debtAmount . '<BR>';
|
|
|
+ }
|
|
|
+
|
|
|
+ $shopId = $order->shopId ?? 0;
|
|
|
+ $shop = ShopClass::getById($shopId, true);
|
|
|
+ $sjId = $shop->sjId ?? 0;
|
|
|
+ $sj = SjClass::getById($sjId, true);
|
|
|
+ $sjName = $sj->name ?? '';
|
|
|
+ $currentName = $sjName;
|
|
|
+ if (isset($shop->default) == false || $shop->default != 1) {
|
|
|
+ $shopName = $shop->shopName ?? '';
|
|
|
+ if (!empty($shopName)) {
|
|
|
+ $currentName = $currentName . ' ' . $shopName;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $content .= '--------------------------------<BR>';
|
|
|
+ $content .= '订单日期:' . $order->addTime . '<BR>';
|
|
|
+ $content .= '订单编号:' . $respond['orderSn'] . '<BR>';
|
|
|
+ $content .= '门店名称:' . $currentName . '<BR>';
|
|
|
+ $content .= "<BR>";
|
|
|
+
|
|
|
+ $ext = ShopExtClass::getByCondition(['shopId' => $shopId]);
|
|
|
+ $printSn = $ext['printSn'] ?? '';
|
|
|
+ if (!empty($printSn)) {
|
|
|
+ $p = new printUtil($printSn);
|
|
|
+ $p->printMsg($content);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //打印数据 ssh 20210702
|
|
|
+ public static function getPrintData($order, $debtAmount)
|
|
|
+ {
|
|
|
+
|
|
|
+ $orderSn = $order->orderSn ?? '';
|
|
|
+
|
|
|
+ $printProduct = [];
|
|
|
+ $orderItemList = OrderItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*');
|
|
|
+ if (!empty($orderItemList)) {
|
|
|
+ foreach ($orderItemList as $itemKey => $itemVal) {
|
|
|
+ $printProduct[] = [
|
|
|
+ 'name' => $itemVal['name'] ?? '',
|
|
|
+ 'num' => $itemVal['num'] . $itemVal['unitName'],
|
|
|
+ 'price' => floatval($itemVal['price']),
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $orderGoodsList = OrderGoodsClass::getAllByCondition(['orderSn' => $orderSn], null, '*');
|
|
|
+ if (!empty($orderGoodsList)) {
|
|
|
+ foreach ($orderGoodsList as $itemKey => $itemVal) {
|
|
|
+ $printProduct[] = [
|
|
|
+ 'name' => $itemVal['name'] ?? '',
|
|
|
+ 'num' => $itemVal['num'] . $itemVal['unitName'],
|
|
|
+ 'price' => floatval($itemVal['price']),
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $sendNum = $order['sendNum'] ?? '';
|
|
|
+ //退款记录
|
|
|
+ $refundList = [];
|
|
|
+ $printData = [
|
|
|
+ 'address' => '',
|
|
|
+ 'sendCost' => $order->sendCost ?? '0.00',
|
|
|
+ 'prePrice' => $order->prePrice ?? '0.00',
|
|
|
+ 'discountAmount' => $order->discountAmount ?? '0.00',
|
|
|
+ 'realPrice' => $order->realPrice ?? '0.00',
|
|
|
+ 'refundPrice' => $order->refundPrice ?? '0.00',
|
|
|
+ 'debt' => $order->debt ?? 0,
|
|
|
+ 'orderSn' => $order->orderSn ?? '',
|
|
|
+ 'date' => $order->addTime ?? '',
|
|
|
+ 'remark' => $order->remark ?? '',
|
|
|
+ 'custom' => [
|
|
|
+ 'customName' => $order->customName ?? '',
|
|
|
+ 'customMobile' => $order->customMobile ?? '',
|
|
|
+ 'fullAddress' => $order->fullAddress ?? '',
|
|
|
+ ],
|
|
|
+ 'product' => $printProduct,
|
|
|
+ 'refund' => $refundList,
|
|
|
+ 'sendNum' => $sendNum,
|
|
|
+ 'debtAmount' => $debtAmount,
|
|
|
+ ];
|
|
|
+ return $printData;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static function printGroup($current, $content)
|
|
|
+ {
|
|
|
+ //58mm的机器,一行打印16个汉字,32个字母
|
|
|
+ $name = $current['name'] ?? '';
|
|
|
+ $content .= $name . '<BR>';
|
|
|
+ $name = str_repeat(' ', 10);
|
|
|
+
|
|
|
+ $productNum = $current['num'] ?? '';
|
|
|
+ $blankNum = bcsub(12, strlen($productNum));
|
|
|
+ if ($blankNum > 0) {
|
|
|
+ $productNum = $productNum . str_repeat(' ', $blankNum);
|
|
|
+ }
|
|
|
+
|
|
|
+ $productPrice = $current['price'] ?? '';
|
|
|
+ $blankNum = bcsub(7, strlen($productPrice));
|
|
|
+ if ($blankNum > 0) {
|
|
|
+ $productPrice = $productPrice . str_repeat(' ', $blankNum);
|
|
|
+ }
|
|
|
+ $content .= $name . " " . $productNum . ' ' . $productPrice . '<BR>';
|
|
|
+ return $content;
|
|
|
+ }
|
|
|
+
|
|
|
}
|