Преглед изворни кода

Merge branch 'master' of git.huaml.com:zhh/huahuibao

shizhongqi пре 5 година
родитељ
комит
ee0dccb716

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

@@ -23,15 +23,7 @@ class PurchaseOrderController extends BaseController
         $shop = $this->shop;
         $default = $shop->default ?? 0;
         if ($default != 1) {
-            util::fail('首店才能采购');
-        }
-
-        $shopAdmin = $this->shopAdmin;
-        $roleId = $shopAdmin['roleId'] ?? 0;
-        $role = AdminRoleClass::getById($roleId);
-        $roleName = $role['roleName'] ?? '';
-        if ($roleName == '员工') {
-            util::fail('您没有权限操作哦');
+            util::fail('请在首店发起采购');
         }
 
         $ghsItemInfo = $post['itemInfo'] ?? '';

+ 8 - 20
biz-ghs/order/classes/OrderClass.php

@@ -123,7 +123,8 @@ class OrderClass extends BaseClass
         $price = $respond['price'] ?? 0;
         $currentPrice = bcadd($price, $sendCost, 2);
         $data['prePrice'] = $currentPrice;
-
+        //默认生成订单时需要打单
+        $data['needPrint'] = $data['needPrint'] ?? dict::getDict('needPrint', 'need');
         if (isset($data['modifyPrice'])) {
             //商家打折,修改金额
             $modifyPrice = $data['modifyPrice'] ?? 0;
@@ -446,31 +447,18 @@ class OrderClass extends BaseClass
             foreach ($respond['product'] as $current) {
                 //58mm的机器,一行打印16个汉字,32个字母
                 $name = $current['name'] ?? '';
-                $currentNum = stringUtil::getWordNum($name);
-                if ($currentNum >= 5) {
-                    $name = stringUtil::subStringUtf8($name, 4);
-                }
-
-                preg_match_all("/([\x{4e00}-\x{9fa5}]){1}/u", $name, $arrCh);
-                //中文字数
-                $zwNum = count($arrCh[0]);
-                $totalNum = strlen($name);
-                $notZwNum = bcsub($totalNum, $zwNum * 3);
-                $holdNum = bcadd($notZwNum, $zwNum * 2);
-                $blankNum = bcsub(10, $holdNum);
-                if($blankNum > 0){
-                    $name = $name . str_repeat(' ', $blankNum);
-                }
+                $content .= $name . '<BR>';
+                $name = str_repeat(' ', 10);
 
                 $productNum = $current['num'] ?? '';
                 $blankNum = bcsub(12, strlen($productNum));
-                if($blankNum > 0){
+                if ($blankNum > 0) {
                     $productNum = $productNum . str_repeat(' ', $blankNum);
                 }
 
                 $productPrice = $current['price'] ?? '';
                 $blankNum = bcsub(7, strlen($productPrice));
-                if($blankNum>0){
+                if ($blankNum > 0) {
                     $productPrice = $productPrice . str_repeat(' ', $blankNum);
                 }
                 $content .= $name . " " . $productNum . ' ' . $productPrice . '<BR>';
@@ -540,7 +528,7 @@ class OrderClass extends BaseClass
                     $bigTotalPrice = bcmul($bigUnitPrice, $bigNum, 2);
                     $printProduct[] = [
                         'name' => $itemVal['name'] ?? '',
-                        'num' => $bigNum . '扎/' . $bigUnitPrice,
+                        'num' => $bigNum . '扎*' . $bigUnitPrice,
                         'price' => $bigTotalPrice
                     ];
                 }
@@ -548,7 +536,7 @@ class OrderClass extends BaseClass
                     $smallTotalPrice = bcmul($smallUnitPrice, $smallNum, 2);
                     $printProduct[] = [
                         'name' => $itemVal['name'] ?? '',
-                        'num' => $smallNum . '支/' . $smallUnitPrice,
+                        'num' => $smallNum . '支*' . $smallUnitPrice,
                         'price' => $smallTotalPrice
                     ];
                 }

+ 4 - 2
biz-ghs/order/services/OrderService.php

@@ -586,8 +586,10 @@ class OrderService extends BaseService
             }
         }
 
-        //在线打印
-        OrderClass::onlinePrint($order);
+        //订单生成时唤起在线打印
+        if (isset($order->needPrint) && $order->needPrint == dict::getDict('needPrint', 'need')) {
+            OrderClass::onlinePrint($order);
+        }
 
     }
 

+ 6 - 4
biz-ghs/product/classes/ProductClass.php

@@ -302,7 +302,9 @@ class ProductClass extends BaseClass
         if ($checkStock && $newStock < 0) {
             //需要判断库存是否充足
             util::unlock($key);
-            util::fail("库存不足");
+            $currentName = $productData->name ?? '';
+            $currentRemainStock = floatval($productData->stock);
+            util::fail("{$currentName} 只剩{$currentRemainStock}扎,请修改");
         }
         self::updateStockById($productId, $newStock);
         //减库存,加销量 2021.6.21 linqh
@@ -789,12 +791,12 @@ class ProductClass extends BaseClass
     //变成自动改价 2021.4.14
     public static function autoPriceById($productId)
     {
-        $product = self::getById($productId,true);
-        if(empty($product)){
+        $product = self::getById($productId, true);
+        if (empty($product)) {
             return false;
         }
         $price = bcadd($product->cost, $product->addPrice, 2);
-        self::changePrice($product,$price, self::PRICE_LABEL_AUTO);
+        self::changePrice($product, $price, self::PRICE_LABEL_AUTO);
     }
 
     //获取当前门店下所有的product

+ 5 - 0
common/components/dict.php

@@ -8,6 +8,11 @@ class dict
 {
 
     public static $data = [
+        //是否需要打印
+        'needPrint' => [
+            'need' => 1,
+            'noNeed' => 2,
+        ],
 
         //批发店囤货时显示给零售库存的最高值
         'showMaxStock' => 260,

+ 9 - 7
doc/开发规范.md

@@ -32,12 +32,14 @@ UserClass::getAllList()
 
 condition支持查询条件包括
 
-'name'=>'john'
-'id>'=>3
-'id<'=>10
-'id'=>['in',[10,11,12]]
-'age'=>['between',[20,30]]
-'name'=>['like','Jack']
+$condition= [
+    'name'=>'john'
+    'id>'=>3
+    'id<'=>10
+    'id'=>['in',[10,11,12]]
+    'age'=>['between',[20,30]]
+    'name'=>['like','Jack']
+];
 ````
 
 
@@ -63,7 +65,7 @@ condition支持查询条件包括
 ##### 调试方法
 
 Yii自带debug,它对每一次的请求,参数,插入数据库都有记录,很好进行跟踪。
-在域名尾巴增加个debug即可使用,如:https://a.huaml.com/debug
+在域名尾巴增加个debug即可使用,如:http://api.shop.hzghd.com/debug