ソースを参照

组合开单 收款人 小票打印

shish 4 年 前
コミット
70838cb31b

+ 13 - 2
app-hd/controllers/OrderController.php

@@ -309,6 +309,7 @@ class OrderController extends BaseController
         $post['deadline'] = $expireTime;
         $post['staffId'] = $this->shopAdminId ?? 0;
         $post['staffName'] = $this->shopAdmin->name ?? '';
+        $groupId = isset($post['groupId']) && !empty($post['groupId']) ? $post['groupId'] : 0;
         //商城
         $post['fromType'] = 1;
         //客户
@@ -325,13 +326,13 @@ class OrderController extends BaseController
         $hasPay = $post['hasPay'] ?? dict::getDict('hasPay', 'unPay');
 
         $productJson = $post['product'] ?? '';
-        if (empty($productJson)) {
+        if (empty($productJson) && empty($groupId)) {
             if (isset($post['lsGoodsPrice']) == false || $post['lsGoodsPrice'] <= 0) {
                 util::fail('请选择商品');
             }
         }
         $productList = json_decode($productJson, true);
-        if (empty($productList)) {
+        if (empty($productList) && empty($groupId)) {
             if (isset($post['lsGoodsPrice']) == false || $post['lsGoodsPrice'] <= 0) {
                 util::fail('请选择商品');
             }
@@ -343,6 +344,16 @@ class OrderController extends BaseController
             $post['deadline'] = date("Y-m-d H:i:s", strtotime('+360 day'));
             $return = OrderService::createFinishOrder($post, $custom, $hasPay);
             $transaction->commit();
+
+            //订单生成时唤起在线打印
+            $id = $return->id ?? 0;
+            $order = OrderClass::getById($id, true);
+            if (!empty($order) && $order->needPrint == dict::getDict('needPrint', 'need') && $order->payStatus == 1) {
+                OrderClass::onlinePrint($order);
+                $order->printNum += 1;
+                $order->save();
+            }
+
             util::success($return);
         } catch (\Exception $e) {
             $transaction->rollBack();

+ 8 - 0
app-hd/controllers/ShopAdminController.php

@@ -245,4 +245,12 @@ class ShopAdminController extends BaseController
         \biz\shop\classes\ShopAdminClass::deleteShopAdmin($relation, $this->shopAdminId, $this->shopId);
         util::complete();
     }
+
+    //获取所有在职员工 ssh 20220507
+    public function actionGetAllStaff()
+    {
+        $list = \bizHd\admin\classes\ShopAdminClass::getAllByCondition(['mainId' => $this->mainId, 'delStatus' => 0, 'status' => 1, 'isPt' => 0,], null, 'id,name', null, true);
+        util::success(['list' => $list]);
+    }
+
 }

+ 197 - 0
biz-hd/order/classes/OrderClass.php

@@ -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;
+    }
+
 }

+ 1 - 0
biz-hd/order/services/OrderService.php

@@ -50,6 +50,7 @@ class OrderService extends BaseService
             if (empty($group)) {
                 util::fail('没有找到商品组合');
             }
+            GroupClass::valid($group, $mainId);
             $product = [];
             $groupGoodsList = GroupGoodsClass::getAllByCondition(['groupId' => $groupId], null, '*');
             if (!empty($groupGoodsList)) {

+ 26 - 26
common/components/dict.php

@@ -125,8 +125,8 @@ class dict
 
         //支付方式
         'payWay' => ['wxPay' => 0, 'alipay' => 1, 'balancePay' => 2, 'debtPay' => 3, 'cash' => 4, 'bankCard' => 5, 'unknown' => 9],
-        'payWayName' => [0 => '微信', 1 => '支付宝', 2 => '余额', 3 => '欠款', 4 => '现金', 5 => '银行卡', 9 => '未知'],
-        'payWayFullName' => [0 => '微信支付', 1 => '支付宝', 2 => '余额支付', 3 => '欠款支付', 4 => '现金', 5 => '银行卡', 9 => '未知'],
+        'payWayName' => [0 => '微信', 1 => '支付宝', 2 => '余额', 3 => '欠款', 4 => '现金', 5 => '银行卡', 9 => '其它'],
+        'payWayFullName' => [0 => '微信支付', 1 => '支付宝', 2 => '余额支付', 3 => '欠款支付', 4 => '现金', 5 => '银行卡', 9 => '其它'],
         //后台支付方式选项
         'htPayWayOption' => [
             ['name' => '微信', 'id' => 0],
@@ -225,30 +225,30 @@ class dict
         ],
         "capitalTypeList" => [//流水类型的对应链接,后台收支明细查看时跳转的链接
             0 => ['link' => '/capital/order-detail', 'name' => '网店', 'orderLink' => '/order/detail', 'id' => 0,],
-            2 => ['link' => '/capital/active-order-detail', 'name' => '活动报名',  'id' => 2,],
-            4 => ['link' => '/capital/recharge-detail', 'name' => '充值',  'id' => 4,],
-            5 => ['link' => '/capital/user-unite', 'name' => '帐号关联',  'id' => 5,],
-            6 => ['link' => '/capital/draw-cash', 'name' => '提现',  'id' => 6,],
-            7 => ['link' => '/capital/apply-order-detail', 'name' => '接入申请',  'id' => 7,],
-            8 => ['link' => '/capital/merge-user', 'name' => '帐号合并',  'id' => 8,],
-            9 => ['link' => '/capital/renew', 'name' => '续费',  'id' => 9,],
-            10 => ['link' => '/capital/order-detail', 'name' => '订单',  'id' => 10,],
-            11 => ['link' => '/capital/purchase-detail', 'name' => '订单',  'id' => 11,],
-            12 => ['link' => '/capital/purchase-detail', 'name' => '培训报名',  'id' => 12,],
-            20 => ['link' => '', 'name' => '采购结算',  'id' => 20,],
-            25 => ['link' => '', 'name' => '采购',  'id' => 25,],
-            30 => ['link' => '', 'name' => '使用平台优惠券',  'id' => 30,],
-            35 => ['link' => '', 'name' => '报损',  'id' => 35,],
-            38 => ['link' => '', 'name' => '采购退款',  'id' => 38,],
-            40 => ['link' => '', 'name' => '销售退款',  'id' => 40,],
-            45 => ['link' => '', 'name' => '盘点',  'id' => 45,],
-            46 => ['link' => '', 'name' => '佣金',  'id' => 46,],
-            48 => ['link' => '', 'name' => '预订单多退少补',  'id' => 48,],
-            50 => ['link' => '', 'name' => '预订单多退少补',  'id' => 50,],
-            51 => ['link' => '', 'name' => '预订单补款',  'id' => 51,],
-            52 => ['link' => '', 'name' => '花店预订补尾款',  'id' => 52,],
-            53 => ['link' => '', 'name' => '采购盆栽等',  'id' => 53,],
-            54 => ['link' => '', 'name' => '退货退款',  'id' => 54,],
+            2 => ['link' => '/capital/active-order-detail', 'name' => '活动报名', 'id' => 2,],
+            4 => ['link' => '/capital/recharge-detail', 'name' => '充值', 'id' => 4,],
+            5 => ['link' => '/capital/user-unite', 'name' => '帐号关联', 'id' => 5,],
+            6 => ['link' => '/capital/draw-cash', 'name' => '提现', 'id' => 6,],
+            7 => ['link' => '/capital/apply-order-detail', 'name' => '接入申请', 'id' => 7,],
+            8 => ['link' => '/capital/merge-user', 'name' => '帐号合并', 'id' => 8,],
+            9 => ['link' => '/capital/renew', 'name' => '续费', 'id' => 9,],
+            10 => ['link' => '/capital/order-detail', 'name' => '订单', 'id' => 10,],
+            11 => ['link' => '/capital/purchase-detail', 'name' => '订单', 'id' => 11,],
+            12 => ['link' => '/capital/purchase-detail', 'name' => '培训报名', 'id' => 12,],
+            20 => ['link' => '', 'name' => '采购结算', 'id' => 20,],
+            25 => ['link' => '', 'name' => '采购', 'id' => 25,],
+            30 => ['link' => '', 'name' => '使用平台优惠券', 'id' => 30,],
+            35 => ['link' => '', 'name' => '报损', 'id' => 35,],
+            38 => ['link' => '', 'name' => '采购退款', 'id' => 38,],
+            40 => ['link' => '', 'name' => '销售退款', 'id' => 40,],
+            45 => ['link' => '', 'name' => '盘点', 'id' => 45,],
+            46 => ['link' => '', 'name' => '佣金', 'id' => 46,],
+            48 => ['link' => '', 'name' => '预订单多退少补', 'id' => 48,],
+            50 => ['link' => '', 'name' => '预订单多退少补', 'id' => 50,],
+            51 => ['link' => '', 'name' => '预订单补款', 'id' => 51,],
+            52 => ['link' => '', 'name' => '花店预订补尾款', 'id' => 52,],
+            53 => ['link' => '', 'name' => '采购盆栽等', 'id' => 53,],
+            54 => ['link' => '', 'name' => '退货退款', 'id' => 54,],
         ],
 
         //用户来源

+ 3 - 1
sql.sql

@@ -1008,4 +1008,6 @@ ALTER TABLE xhGoodsCategory ADD `sn` CHAR(30) NOT NULL DEFAULT '' COMMENT '有
 ALTER TABLE xhWork ADD `goodsSn` CHAR(30) NOT NULL DEFAULT '' COMMENT '有效的商品编号,对应xhGoods sn' AFTER `workSn`;
 ALTER TABLE xhShop ADD defaultCustomId INT NOT NULL DEFAULT 0 COMMENT '门店默认客户,没有选客户时使用' AFTER `skCustomId`;
 ALTER TABLE xhGhsCustom ADD mainId INT NOT NULL DEFAULT 0 COMMENT '' AFTER `shopId`;
-ALTER TABLE xhGhs ADD mainId INT NOT NULL DEFAULT 0 COMMENT '中央id' AFTER `shopId`;
+ALTER TABLE xhGhs ADD mainId INT NOT NULL DEFAULT 0 COMMENT '中央id' AFTER `shopId`;
+ALTER TABLE xhOrder ADD `getStaffId` INT NOT NULL DEFAULT 0 COMMENT '收款人id' AFTER `shopAdminName`;
+ALTER TABLE xhOrder ADD `getStaffName` VARCHAR(30) NOT NULL DEFAULT '' COMMENT '收款人名称' AFTER `getStaffId`;