Browse Source

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

shizhongqi 4 years ago
parent
commit
1cc09dd26d

+ 18 - 12
app-ghs/controllers/ProductController.php

@@ -47,7 +47,7 @@ class ProductController extends BaseController
 
         $p->times = $num;
         $content = '<TEXT x="360" y="30" font="12" w="2" h="2" r="90">' . $name . '</TEXT>';
-        $content .= '<BC128 x="260" y="30" h="80" s="1" r="90" n="5" w="12">'.$ptItemId.'</BC128>';
+        $content .= '<BC128 x="260" y="30" h="80" s="1" r="90" n="5" w="12">' . $ptItemId . '</BC128>';
         $p->printLabelMsg($content);
         util::complete();
     }
@@ -255,34 +255,40 @@ class ProductController extends BaseController
 
             $productList = ProductClass::getAllByCondition(['id' => ['in', $ids]], null, '*', 'id', true);
             foreach ($arr as $product) {
-                if (isset($product['price']) == false) {
-                    util::fail('没有价格');
+
+                $productId = $product['id'];
+                $productInfo = $productList[$productId] ?? [];
+                if (empty($productInfo)) {
+                    util::fail('没有找到花材');
                 }
+                $productName = $productInfo->name ?? '';
                 if (isset($product['id']) == false) {
                     util::fail('没有花材');
                 }
+                if (isset($product['price']) == false || is_numeric($product['price']) == false || $product['price'] < 0) {
+                    util::fail('请填写' . $productName . '的花店价');
+                }
                 $price = $product['price'];
-                $productId = $product['id'];
-
-                $product = $productList[$productId] ?? [];
-                if (empty($product)) {
-                    util::fail('没有找到花材');
+                if (isset($product['skPrice']) == false || is_numeric($product['skPrice']) == false || $product['skPrice'] < 0) {
+                    util::fail('请填写' . $productName . '的散客价');
                 }
-                if (isset($product->mainId) == false || $product->mainId != $this->mainId) {
+                $skPrice = $product['skPrice'];
+
+                if (isset($productInfo->mainId) == false || $productInfo->mainId != $this->mainId) {
                     util::fail('没有权限访问');
                 }
                 if (empty($price)) {
                     continue;
                 }
-                $ptItemId = $product->itemId;
-                ProductClass::changeSinglePrice($shop, $ptItemId, $price);
+                $ptItemId = $productInfo->itemId;
+                ProductClass::changeSinglePrice($shop, $ptItemId, $price, $skPrice);
                 //在首店修改需要同步到所有直营店
                 if ($default == 1) {
                     foreach ($chainShopList as $chain) {
                         if ($chain->id == $shop->id) {
                             continue;
                         }
-                        ProductClass::changeSinglePrice($chain, $ptItemId, $price);
+                        ProductClass::changeSinglePrice($chain, $ptItemId, $price, $skPrice);
                     }
                 }
             }

+ 8 - 3
app-hd/controllers/WorkController.php

@@ -86,12 +86,13 @@ class WorkController extends BaseController
             }
             $post['catName'] = $cat->categoryName ?? '';
             $main = $this->main;
-            //默认直接完成
-            $post['complete'] = 1;
             $work = WorkClass::createFinish($post, $main);
             $transaction->commit();
 
-            WorkClass::print($work, $this->shop, false);
+            $complete = $post['complete'] ?? 0;
+            if ($complete == 1) {
+                WorkClass::print($work, $this->shop, false);
+            }
 
             util::success($work);
         } catch (\Exception $e) {
@@ -120,6 +121,7 @@ class WorkController extends BaseController
             $main = $this->main;
             WorkClass::goodsCreateFinish($post, $main);
             $transaction->commit();
+
             util::complete();
         } catch (\Exception $e) {
             $transaction->rollBack();
@@ -184,6 +186,9 @@ class WorkController extends BaseController
             }
             WorkClass::finish($work);
             $transaction->commit();
+
+            WorkClass::print($work, $this->shop, false);
+
             util::complete();
         } catch (\Exception $e) {
             $transaction->rollBack();

+ 13 - 20
biz-ghs/product/classes/ProductClass.php

@@ -139,9 +139,12 @@ class ProductClass extends BaseClass
             $smallPrice = bcmul($smallPrice, $smallRatio, 2);
             $list[$k]['smallPrice'] = $smallPrice;
 
-            //自动调价的价格
-            $list[$k]['autoPrice'] = bcadd($v['cost'], $v['addPrice'], 2);
-
+            //这个很重要不能随意乱改
+            $autoPrice = bcadd($v['cost'], $v['addPrice'], 2);
+            $skMore = $v['skMore'] ?? 0;
+            $skAutoPrice = bcadd($autoPrice, $skMore, 2);
+            $list[$k]['autoPrice'] = $autoPrice;
+            $list[$k]['autoSkPrice'] = $skAutoPrice;
         }
         return $list;
     }
@@ -586,30 +589,20 @@ class ProductClass extends BaseClass
     }
 
     //单个修改价格 lqh 2021.1.28
-    public static function changeSinglePrice($shop, $ptItemId, $price)
+    public static function changeSinglePrice($shop, $ptItemId, $price, $skPrice = null)
     {
         $mainId = $shop->mainId ?? 0;
         $productInfo = ProductClass::getByCondition(['itemId' => $ptItemId, 'mainId' => $mainId], true);
         if (empty($productInfo)) {
             return false;
         }
-
         $productInfo->price = $price;
-
-        $addPrice = $productInfo->addPrice ?? 0;
-
-        $skAddPrice = $productInfo->skAddPrice ?? 0;
-        $sk = bcsub($addPrice, $skAddPrice, 2);
-        $productInfo->skPrice = bcsub($price, $sk, 2);
-
-        $hjAddPrice = $productInfo->hjAddPrice ?? 0;
-        $hj = bcsub($addPrice, $hjAddPrice, 2);
-        $productInfo->hjPrice = bcsub($price, $hj, 2);
-
-        $zsAddPrice = $productInfo->zsAddPrice ?? 0;
-        $zs = bcsub($addPrice, $zsAddPrice, 2);
-        $productInfo->zsPrice = bcsub($price, $zs, 2);
-
+        if (empty($skPrice)) {
+            $skMore = $productInfo->skMore ?? 0;
+            $productInfo->skPrice = bcadd($price, $skMore, 2);
+        } else {
+            $productInfo->skPrice = $skPrice;
+        }
         $productInfo->save();
     }
 

+ 5 - 4
biz-hd/work/classes/WorkClass.php

@@ -26,7 +26,7 @@ class WorkClass extends BaseClass
     const STATUS_CANCEL = 2;
 
     //打印工单 ssh 20220601
-    public static function print($work, $shop,$mustPrint=true)
+    public static function print($work, $shop, $mustPrint = true)
     {
         $orderSn = $work->orderSn ?? '';
         if (!empty($orderSn)) {
@@ -40,7 +40,7 @@ class WorkClass extends BaseClass
             $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
             $printLabelSn = $ext->printLabelSn ?? '';
             if (empty($printLabelSn)) {
-                if($mustPrint){
+                if ($mustPrint) {
                     util::fail('请设置标签打印机');
                 }
             } else {
@@ -50,6 +50,9 @@ class WorkClass extends BaseClass
                 if (!empty($workItemList)) {
                     foreach ($workItemList as $item) {
                         $goodsSn = $item->goodsSn ?? '';
+                        if (empty($goodsSn)) {
+                            continue;
+                        }
                         $num = $item->num ?? 1;
                         $name = $item->name ?? '';
                         $content = '<TEXT x="360" y="30" font="12" w="2" h="2" r="90">' . $name . '</TEXT>';
@@ -154,8 +157,6 @@ class WorkClass extends BaseClass
     //锁定制作单 ssh 20220320
     public static function lock($work)
     {
-        $work->stockLock = 1;
-        $work->save();
         WorkItemClass::lock($work);
     }
 

+ 23 - 0
console/controllers/ProductController.php

@@ -5,12 +5,35 @@ namespace console\controllers;
 use biz\item\classes\PtItemClass;
 use biz\product\classes\ProductClass;
 use biz\product\models\Product;
+use bizGhs\item\classes\ItemClass;
+use bizGhs\item\models\Item;
 use yii\console\Controller;
 use Yii;
 
 class ProductController extends Controller
 {
 
+    //修改散客比花店价格贵 ssh 20220609
+    public function actionSkMore()
+    {
+        $query = new \yii\db\Query();
+        $query->from(Item::tableName());
+        $query->where(['>', 'id', 0]);
+        foreach ($query->batch() as $batchItem) {
+            foreach ($batchItem as $item) {
+                $addPrice = $item['addPrice'] ?? 0;
+                $id = $item['id'] ?? 0;
+                $skAddPrice = $item['skAddPrice'] ?? 0;
+                if ($skAddPrice > $addPrice) {
+                    $add = bcsub($skAddPrice, $addPrice, 2);
+                    ItemClass::updateById($id, ['skMore' => $add]);
+                } else {
+                    echo "散客加价小于花店加价 {$id}\n";
+                }
+            }
+        }
+    }
+
     //更新纯彩花艺的价格 ./yii product/update-price ssh 20211020
     public function actionUpdatePrice()
     {