shish 3 лет назад
Родитель
Сommit
a49a889bfe

+ 20 - 1
app-ghs/controllers/PurchaseOrderController.php

@@ -2,20 +2,39 @@
 
 namespace ghs\controllers;
 
-use biz\admin\classes\AdminRoleClass;
 use biz\ghs\classes\GhsClass;
 use bizGhs\order\classes\PurchaseOrderClass;
 use bizGhs\order\classes\PurchaseOrderItemClass;
 use bizGhs\product\classes\ProductClass;
+use common\components\dict;
 use common\components\noticeUtil;
 use common\components\printUtil;
 use common\components\stringUtil;
 use common\components\util;
+use biz\shop\classes\ShopExtClass;
 use Yii;
 
 class PurchaseOrderController extends BaseController
 {
 
+    //打印小票 ssh 20230608
+    public function actionPrintBill()
+    {
+        $get = Yii::$app->request->get();
+        $id = $get['id'] ?? 0;
+        $cg = PurchaseOrderClass::getById($id, true);
+        if (empty($cg)) {
+            util::fail('没有找到采购单');
+        }
+        if ($cg->mainId != $this->mainId) {
+            util::fail('没有权限');
+        }
+        PurchaseOrderClass::printTicket($cg);
+        $cg->printNum += 1;
+        $cg->save();
+        util::complete();
+    }
+
     //打印全部 ssh 20220602
     public function actionPrintAll()
     {

+ 134 - 0
biz-ghs/order/classes/PurchaseOrderClass.php

@@ -6,6 +6,8 @@ use biz\ghs\classes\GhsClass;
 use biz\shop\classes\MainClass;
 use biz\shop\classes\ShopCapitalClass;
 use biz\shop\classes\ShopClass;
+use biz\shop\classes\ShopExtClass;
+use biz\sj\classes\SjClass;
 use biz\stat\classes\StatCgClass;
 use biz\stat\classes\StatCgGhsClass;
 use biz\stat\classes\StatOutClass;
@@ -21,6 +23,7 @@ use common\components\dict;
 use common\components\imgUtil;
 use common\components\noticeUtil;
 use common\components\orderSn;
+use common\components\printUtil;
 use common\components\util;
 use Yii;
 
@@ -56,6 +59,137 @@ class PurchaseOrderClass extends BaseClass
     const IN_TYPE_LATER = 0;
     const IN_TYPE_NOW = 1;
 
+    public static function printGroup($current, $content)
+    {
+        //58mm的机器,一行打印16个汉字,32个字母
+        $productPrice = $current['bigPrice'] ?? '';
+        $name = $current['name'] ?? '';
+        if (floatval($productPrice) == 0.01) {
+            $name = $name . '(送)';
+        }
+        $productNum = $current['itemNum'] ?? '';
+        $count = $current['itemNum'] ?? '';
+        $content .= '<B>' . $name . ' ' . $count . '</B><BR>';
+        $content .= $productNum . '=' . $productPrice . '<BR>';
+        $content .= '--------------------------------<BR>';
+        return $content;
+    }
+
+    //打印小票 ssh 20230608
+    public static function printTicket($orderInfo)
+    {
+        $ghsId = $orderInfo->ghsId ?? 0;
+        $ghsInfo = GhsClass::getById($ghsId, true);
+        $debtAmount = $ghsInfo->debtAmount ? floatval($ghsInfo->debtAmount) : 0;
+
+        $orderSn = $orderInfo->orderSn ?? '';
+        $itemList = PurchaseOrderItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*');
+
+        $content = '';
+        $content .= '--------------------------------<BR>';
+        $content .= '<B>' . $orderInfo->ghsName . '</B><BR><BR>';
+        $content .= '<B>' . $ghsInfo->mobile . '</B><BR>';
+        if (isset($orderInfo->remark) && !empty($orderInfo->remark)) {
+            $content .= '<BR>';
+            $content .= '备注:<BR>';
+            $content .= '<B>' . $orderInfo->remark . '</B><BR>';
+        }
+        $content .= '<BR>';
+        $content .= '花材       数量/单价   金额   <BR>';
+        $content .= '--------------------------------<BR>';
+        $content .= '--------------------------------<BR>';
+        if (isset($itemList) && !empty($itemList)) {
+            foreach ($itemList as $current) {
+                $content = self::printGroup($current, $content);
+            }
+        }
+        $kindNum = $orderInfo->kind ?? 0;
+        $bigNum = $orderInfo->itemNum ? floatval($orderInfo->itemNum) : 0;
+        $content .= '<BR>********************************<BR>';
+        $content .= "<CB>共{$kindNum}种";
+        if ($bigNum > 0) {
+            $content .= ",{$bigNum}扎";
+        }
+        $content .= "</CB>";
+        $content .= '********************************<BR><BR>';
+        if (isset($orderInfo['refund']) && !empty($orderInfo['refund'])) {
+            $content .= '<CB>【已退款】</CB><BR>';
+            foreach ($orderInfo['refund'] as $current) {
+                //58mm的机器,一行打印16个汉字,32个字母
+                $name = $current['name'] ?? '';
+                $count = $current['count'] ?? '';
+                $content .= '<B>' . $name . ' ' . $count . '</B><BR>';
+
+                $productNum = $current['num'] ?? '';
+                $productPrice = $current['price'] ?? '';
+                $content .= $productNum . '=' . $productPrice . '<BR>';
+
+                $content .= '--------------------------------<BR>';
+            }
+            $content .= '--------------------------------<BR>';
+        }
+
+        if (isset($orderInfo['itemPrice']) && $orderInfo['itemPrice'] > 0) {
+            $content .= '商品金额:' . floatval($orderInfo['itemPrice']) . '<BR>';
+        }
+        if (isset($orderInfo['sendCost']) && $orderInfo['sendCost'] > 0) {
+            $content .= '    运费:' . floatval($orderInfo['sendCost']) . '<BR>';
+        }
+        if (isset($orderInfo['packCost']) && $orderInfo['packCost'] > 0) {
+            $content .= '  打包费:' . floatval($orderInfo['packCost']) . '<BR>';
+        }
+        $content .= '合计金额:' . floatval($orderInfo['prePrice']) . '<BR>';
+        if (isset($orderInfo['discountAmount']) && !empty($orderInfo['discountAmount']) && $orderInfo['discountAmount'] > 0) {
+            $content .= '优惠扣除:-' . floatval($orderInfo['discountAmount']) . '<BR>';
+        }
+        if (isset($orderInfo['book']) && $orderInfo['book'] == 1) {
+            $content .= '预付金额:' . floatval($orderInfo['bookPrice']) . '<BR>';
+        }
+        if (isset($orderInfo['tkPrice']) && $orderInfo['tkPrice'] > 0) {
+            $content .= '退款金额:' . floatval($orderInfo['tkPrice']) . '<BR>';
+        }
+        $content .= '<B>订单金额:' . floatval($orderInfo['realPrice']) . '</B><BR>';
+        if (isset($orderInfo['debt']) && $orderInfo['debt'] == 1) {
+            $content .= '实付金额:0<BR>';
+        } else {
+            $content .= '实付金额:' . floatval($orderInfo['realPrice']) . '<BR>';
+        }
+        if ($debtAmount > 0) {
+            $content .= '累计欠款:' . floatval($debtAmount) . '<BR>';
+        }
+        $content .= '--------------------------------<BR>';
+
+        $shopId = $orderInfo['shopId'] ?? 0;
+        $shop = ShopClass::getById($shopId, true);
+        $sjId = $shop->sjId ?? 0;
+        $telephone = $shop->telephone ?? '';
+        $sj = SjClass::getById($sjId, true);
+        $sjName = $sj->name ?? '';
+        $shopName = $shop->shopName ?? '';
+        $currentName = $shopName == '首店' ? $sjName : $sjName . ' ' . $shopName;
+        $getInfo = self::getById($orderInfo['id']);
+        $content .= '订单日期:' . date("Y-m-d H:i", strtotime($getInfo['addTime'])) . '<BR>';
+        $content .= '订单编号:' . $orderInfo['orderSn'] . '<BR>';
+        if (isset($orderInfo['shopAdminId']) && !empty($orderInfo['shopAdminId'])) {
+            $content .= '员工开单:' . $orderInfo['shopAdminName'] . '<BR>';
+        } else {
+            $content .= '客户下单:' . $orderInfo['customShopAdminName'] . '<BR>';
+        }
+        $content .= '门店名称:' . $currentName . '<BR>';
+        if (!empty($telephone)) {
+            $content .= '联系电话:' . $telephone . '<BR>';
+        }
+        $content .= "<BR>";
+        $content .= "<BR>";
+        $ext = ShopExtClass::getByCondition(['shopId' => $shopId]);
+        $printSn = $ext['printSn'] ?? '';
+        if (!empty($printSn)) {
+            $p = new printUtil($printSn);
+            $p->printMsg($content, $shop);
+        }
+    }
+
+
     public static function putIn($cg, $data)
     {
         if ($cg->status == self::PURCHASE_ORDER_STATUS_COMPLETE) {