Browse Source

合并主支到ls

shish 1 year ago
parent
commit
ada749ca1e
70 changed files with 1667 additions and 315 deletions
  1. 1 1
      app-ghs/controllers/AuthController.php
  2. 6 5
      app-ghs/controllers/CheckOrderController.php
  3. 18 0
      app-ghs/controllers/ClearController.php
  4. 24 10
      app-ghs/controllers/ConsoleController.php
  5. 61 5
      app-ghs/controllers/CustomController.php
  6. 3 0
      app-ghs/controllers/ExpendController.php
  7. 291 3
      app-ghs/controllers/ItemController.php
  8. 27 6
      app-ghs/controllers/OrderClearController.php
  9. 150 22
      app-ghs/controllers/OrderController.php
  10. 2 5
      app-ghs/controllers/PartController.php
  11. 23 4
      app-ghs/controllers/ProductController.php
  12. 19 1
      app-ghs/controllers/PurchaseClearController.php
  13. 31 12
      app-ghs/controllers/PurchaseOrderController.php
  14. 74 19
      app-ghs/controllers/RefundController.php
  15. 39 8
      app-ghs/controllers/ShopController.php
  16. 27 2
      app-ghs/controllers/ShopExtController.php
  17. 1 1
      app-ghs/controllers/StatController.php
  18. 50 0
      app-ghs/controllers/StockInController.php
  19. 44 10
      app-ghs/controllers/StockOutController.php
  20. 12 7
      app-ghs/controllers/TestController.php
  21. 2 5
      app-ghs/controllers/WastageController.php
  22. 8 13
      app-hd/controllers/CgRefundController.php
  23. 4 0
      app-hd/controllers/ConsoleController.php
  24. 51 0
      app-hd/controllers/ItemController.php
  25. 2 0
      app-hd/controllers/MainController.php
  26. 27 4
      app-hd/controllers/NoticeController.php
  27. 56 6
      app-hd/controllers/OrderController.php
  28. 9 5
      app-hd/controllers/ProductController.php
  29. 1 1
      app-hd/controllers/PurchaseClearController.php
  30. 8 26
      app-hd/controllers/PurchaseController.php
  31. 21 1
      app-hd/controllers/RefundController.php
  32. 1 1
      app-mall/controllers/CategoryController.php
  33. 1 1
      app-mall/controllers/ItemController.php
  34. 1 1
      app-mall/controllers/OrderController.php
  35. 6 0
      app-pt/controllers/WxOpenController.php
  36. 14 3
      app-pt/views/main/app.php
  37. 42 3
      biz-ghs/clear/classes/ClearClass.php
  38. 12 0
      biz-ghs/clear/classes/ClearRefundSnClass.php
  39. 13 0
      biz-ghs/clear/models/ClearRefundSn.php
  40. 102 14
      biz-ghs/item/classes/ItemClass.php
  41. 15 4
      biz-ghs/order/classes/CheckOrderClass.php
  42. 9 6
      biz-ghs/order/classes/OrderClass.php
  43. 2 3
      biz-ghs/order/classes/OrderItemClass.php
  44. 2 2
      biz-ghs/order/classes/PurchaseOrderClass.php
  45. 11 4
      biz-ghs/order/classes/RefundOrderClass.php
  46. 2 2
      biz-ghs/order/services/OrderService.php
  47. 0 10
      biz-ghs/order/services/RefundOrderService.php
  48. 28 8
      biz-ghs/product/classes/ProductClass.php
  49. 27 22
      biz-ghs/product/services/ProductService.php
  50. 31 0
      biz-ghs/shop/classes/ShopAdminClass.php
  51. 53 5
      biz-hd/cg/classes/CgRefundClass.php
  52. 6 0
      biz-hd/cg/services/CgRefundService.php
  53. 11 7
      biz-hd/order/classes/OrderClass.php
  54. 1 2
      biz-hd/order/classes/OrderItemClass.php
  55. 1 1
      biz-hd/purchase/classes/PurchaseClass.php
  56. 9 2
      biz-hd/purchase/classes/PurchaseClearClass.php
  57. 13 5
      biz-hd/purchase/services/PurchaseService.php
  58. 43 0
      biz-hd/refund/classes/HdRefundClass.php
  59. 8 5
      biz-hd/refund/classes/HdRefundItemClass.php
  60. 3 0
      biz/ghs/classes/GhsClass.php
  61. 2 8
      biz/shop/classes/ShopClass.php
  62. 24 0
      biz/shop/classes/ShopExtClass.php
  63. 3 3
      common/components/book.php
  64. 3 3
      common/components/bookJd.php
  65. 3 3
      common/components/dict.php
  66. 17 0
      common/components/miniUtil.php
  67. 15 0
      common/components/orderSn.php
  68. 12 2
      common/components/util.php
  69. 16 0
      common/components/wxUtil.php
  70. 13 3
      console/controllers/CustomController.php

+ 1 - 1
app-ghs/controllers/AuthController.php

@@ -682,7 +682,7 @@ class AuthController extends PublicController
     {
         $version = getenv('GHS_NEW_APK_VERSION') == false ? '100' : getenv('GHS_NEW_APK_VERSION');
         $mustUpdate = getenv('GHS_NEW_APK_VERSION_MUST_UPDATE') == false ? 0 : getenv('GHS_NEW_APK_VERSION_MUST_UPDATE');
-        $updateText = '结账功能优化';
+        $updateText = '开单优化;修复扫码收款问题';
         util::success(['version' => $version, 'mustUpdate' => $mustUpdate, 'updateText' => $updateText]);
     }
 

+ 6 - 5
app-ghs/controllers/CheckOrderController.php

@@ -15,7 +15,7 @@ class CheckOrderController extends BaseController
     public function actionBookDelStock()
     {
         $staff = $this->shopAdmin;
-        if(isset($staff->identity) && $staff->identity == 2){
+        if (isset($staff->identity) && $staff->identity == 2) {
             util::fail('不能操作');
         }
 
@@ -52,7 +52,7 @@ class CheckOrderController extends BaseController
     public function actionBookAddStock()
     {
         $staff = $this->shopAdmin;
-        if(isset($staff->identity) && $staff->identity == 2){
+        if (isset($staff->identity) && $staff->identity == 2) {
             util::fail('不能操作');
         }
 
@@ -93,7 +93,7 @@ class CheckOrderController extends BaseController
     public function actionLoan()
     {
         $staff = $this->shopAdmin;
-        if(isset($staff->identity) && $staff->identity == 2){
+        if (isset($staff->identity) && $staff->identity == 2) {
             util::fail('不能操作');
         }
 
@@ -217,6 +217,7 @@ class CheckOrderController extends BaseController
         if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
             util::fail('超管才能盘点');
         }
+
         $post = Yii::$app->request->post();
         $post['sjId'] = $this->sjId;
         $post['shopId'] = $this->shopId;
@@ -348,9 +349,9 @@ class CheckOrderController extends BaseController
 
         $mainId = $this->mainId;
         if (getenv('YII_ENV') == 'production') {
-            //源花汇小周可以清花材
+            //源花汇小周、小吴、小吕可以清花材
             if ($mainId == 10536) {
-                if (in_array($this->adminId, [11648])) {
+                if (in_array($this->adminId, [11648, 11961, 11976])) {
                     $could = true;
                 }
             }

+ 18 - 0
app-ghs/controllers/ClearController.php

@@ -16,6 +16,24 @@ use Yii;
 class ClearController extends BaseController
 {
 
+    //结账单取消了,钱给原路退回 ssh 20250501
+    public function actionRefundMoney()
+    {
+        $id = Yii::$app->request->get('id', '');
+        $info = ClearClass::getById($id, true);
+        if ($info->ghsShopId != $this->shopId) {
+            util::fail('不是你的结账单');
+        }
+        if ($info->status != 3) {
+            util::fail('结账单没有取消,不能退钱');
+        }
+        $shop = $this->shop;
+        $respond = ClearClass::refundMoney($shop, $info);
+        $status = $respond['status'];
+        $msg = $respond['msg'];
+        util::success(['status' => $status], $msg);
+    }
+
     //获取客户待结订单明细 ssh 20220926
     public function actionGetUnClear()
     {

+ 24 - 10
app-ghs/controllers/ConsoleController.php

@@ -140,7 +140,7 @@ class ConsoleController extends BaseController
                 $sale = bcadd($sale, $item['amount'], 2);
             }
         }
-        util::success(['income'=>$sale]);
+        util::success(['income' => $sale]);
     }
 
     //今日概况 ssh 20220723
@@ -151,18 +151,24 @@ class ConsoleController extends BaseController
 
         $notice = [];
         $shop = $this->shop;
-        $deadline = $shop->deadline;
-        $currentTime = time();
-        $deadTime = strtotime($deadline);
-        if($currentTime>$deadTime){
-            $notice[] = ['title' => '系统已到期,即将停用,请及时续费', 'action' => '查看', 'page' => '/admin/notice/fee'];
+        if (!empty($shop)) {
+            //到期前10天提醒
+            $deadline = $shop->deadline;
+            $currentTime = time();
+            $currentTime = $currentTime + 864000;
+            $deadTime = strtotime($deadline);
+            if ($currentTime > $deadTime) {
+                if (time() > $deadTime) {
+                    $notice[] = ['title' => '系统已到期', 'action' => '查看', 'page' => '/admin/shop/renew'];
+                } else {
+                    $notice[] = ['title' => '系统即将到期,请及时续费', 'action' => '查看', 'page' => '/admin/shop/renew'];
+                }
+            }
         }
 
-        $mainId = $this->mainId;
-        if(!in_array($mainId,[23390,23884,45354,40624,10975])){
-            //$notice[] = ['title' => '明天起续年费需涨600元,请提前安排', 'action' => '如何续', 'page' => '/admin/notice/fee'];
-        }
+        //$notice[] = ['title' => '收银机开始支持【挂单】和重复扫码', 'action' => '查看', 'page' => '/admin/notice/warning'];
 
+        $mainId = $this->mainId;
         $respond = StatSaleClass::profile($mainId);
         $incomeList = $respond['income'] ?? [];
         $todaySale = 0;
@@ -230,15 +236,23 @@ class ConsoleController extends BaseController
                 ["name" => "损耗", "img" => "ghs/home/kcyjs.png", "url" => "/admin/breakage/list"],
                 ["name" => "预订明细", "img" => "ghs/home/yggl.png", "url" => "/admin/book/itemCustom"],
                 ["name" => "新增预订", "img" => "ghs/home/yggl.png", "url" => "/admin/custom/selectCustom?style=1&book=1&getAll=1"],
+                ["name" => "拆散", "img" => "ghs/home/kcyjs.png", "url" => "/admin/part/list"],
             ];
         }
 
         //查看财务的权限
         $lookMoney = ShopAdminClass::lookMoneyPower($this->shopAdmin, $this->shop);
 
+        $warning = '';
+        $warningUrl = '';
+        //$warning = '开小单位(支)会减库存';
+        //$warningUrl = '/admin/notice/warning';
+
         util::success([
             'asset' => $this->main,
             'notice' => $notice,
+            'warning' => $warning,
+            'warningUrl' => $warningUrl,
             'todayData' => [
                 'income' => $todaySale,
                 'order' => $orderNum,

+ 61 - 5
app-ghs/controllers/CustomController.php

@@ -26,6 +26,29 @@ use Yii;
 class CustomController extends BaseController
 {
 
+    //客户设置相关 ssh 20250310
+    public function actionSetChange()
+    {
+
+        $staff = $this->shopAdmin;
+        if ($staff->founder != 2 && $staff->mobile != 15280215347) {
+            util::fail('老板才能修改');
+        }
+
+        $post = Yii::$app->request->post();
+        $shopId = $this->shopId;
+        ShopClass::updateById($shopId, $post);
+
+        $showStock = $post['showStock'] ?? 0;
+        $arr = ['showStock' => $showStock];
+        //如果新客需要审核,老的全部要打开为已经审核通过了
+        $arr['passStatus'] = 1;
+        CustomClass::updateByCondition(['ownShopId' => $shopId], $arr);
+        GhsClass::updateByCondition(['shopId' => $shopId], $arr);
+
+        util::complete('修改成功');
+    }
+
     //获取收款码 ssh 20240530
     public function actionGetGatheringCode()
     {
@@ -87,6 +110,12 @@ class CustomController extends BaseController
                     util::fail('不能充值销单哈');
                 }
             }
+            //恋善好多花控制销账权限
+            if (in_array($this->shopId, [55238, 56609, 56611])) {
+                if (!in_array($this->adminId, [43856, 54620])) {
+                    util::fail('暂无权限销单,请联系老板或财务');
+                }
+            }
             //天天鲜花 陈江店
             if (in_array($this->shopId, [763, 1405, 795])) {
                 if (!in_array($this->adminId, [2094, 5959])) {
@@ -107,22 +136,34 @@ class CustomController extends BaseController
             }
             //源花汇
             if (in_array($this->shopId, [10649])) {
-                if (!in_array($this->adminId, [11641, 11648])) {
+                if (!in_array($this->adminId, [11641, 11648, 4])) {
                     util::fail('请闵总或小周操作');
                 }
             }
             //昱成
             if (in_array($this->shopId, [8596])) {
-                if (!in_array($this->adminId, [9303,9601])) {
+                if (!in_array($this->adminId, [9303, 9601])) {
                     util::fail('只能叶荷操作');
                 }
             }
-            //花大苪
+            //花大苪,多处请搜索关键词 hdb_clear_control
             if (in_array($this->shopId, [8249])) {
                 if (!in_array($this->adminId, [9303])) {
                     util::fail('只能叶荷和财务操作');
                 }
             }
+            //中山淘花里,销账权限控制,多处请搜索 thl_clear_control
+            if (in_array($this->shopId, [17118])) {
+                if (!in_array($this->adminId, [55494, 55445, 17908, 55459, 55707, 55709])) {
+                    util::fail('你不能销单哈。。');
+                }
+            }
+            //小齐鲜花总店和出车,多处请搜索关键词 xq_clear_control
+            if (in_array($this->shopId, [41467, 42946])) {
+                if (!in_array($this->adminId, [40144])) {
+                    util::fail('您不能充值销单哦。');
+                }
+            }
         } else {
             if (in_array($this->shopId, [36523])) {
                 if ($this->adminId != 919) {
@@ -294,6 +335,21 @@ class CustomController extends BaseController
         util::complete('已修改');
     }
 
+    //修改短名 ssh 2025312
+    public function actionModifyShortName()
+    {
+        $get = Yii::$app->request->get();
+        $id = $get['id'] ?? 0;
+        $shortName = $get['shortName'] ?? 0;
+        $custom = CustomClass::getById($id, true);
+        if (empty($custom) || $custom->ownMainId != $this->mainId) {
+            util::fail('修改失败');
+        }
+        $custom->shortName = $shortName;
+        $custom->save();
+        util::complete('修改成功');
+    }
+
     //修改物流信息 ssh 20230105
     public function actionChangeWl()
     {
@@ -646,9 +702,9 @@ class CustomController extends BaseController
                 } else {
                     $shop = $this->shop;
                     //如果花大苪,搜索数字还是优先搜索客户名称,因为客户名称经常会编号
-                    if($shop->id == 8249){
+                    if ($shop->id == 8249) {
                         $where['name'] = ['like', $name];
-                    }else{
+                    } else {
                         $where['mobile'] = ['like', $name];
                     }
                 }

+ 3 - 0
app-ghs/controllers/ExpendController.php

@@ -248,6 +248,9 @@ class ExpendController extends BaseController
             }
         }
 
+        //避免重复提交
+        util::checkRepeatCommit($this->adminId, 10);
+
         $post = Yii::$app->request->post();
         $type = $post['type'] ?? -1;
         $amount = $post['amount'] ?? 0;

+ 291 - 3
app-ghs/controllers/ItemController.php

@@ -3,7 +3,8 @@
 namespace ghs\controllers;
 
 use biz\item\classes\PtItemClass;
-use biz\product\models\Product;
+use biz\item\classes\UnitClass;
+use biz\shop\classes\ShopExtClass;
 use bizGhs\book\classes\BookItemClass;
 use bizGhs\custom\classes\CustomClass;
 use bizGhs\item\classes\ItemClass;
@@ -21,6 +22,293 @@ use Yii;
 class ItemController extends BaseController
 {
 
+    //取消花材的限购,重新开始计算
+    public function actionClearLimitBuy()
+    {
+        $get = Yii::$app->request->get();
+        $id = $get['id'] ?? '';
+        $item = ItemClass::getById($id, true);
+        if (empty($item)) {
+            util::fail('没有找到花材');
+        }
+        if ($item->mainId != $this->mainId) {
+            util::fail('不是你的花材');
+        }
+        ProductClass::cancelLimitBuy($id);
+        util::complete('清除成功');
+    }
+
+    public function actionModifyWeight()
+    {
+        $shop = $this->shop;
+        if ($shop->default == 0) {
+            util::fail('请在总店(首店)修改');
+        }
+
+        $get = Yii::$app->request->get();
+        $id = $get['id'] ?? '';
+        $weight = $get['weight'] ?? 1;
+        if ($weight <= 0) {
+            util::fail('重量不能小于0');
+        }
+        $item = ItemClass::getById($id, true);
+        if (empty($item)) {
+            util::fail('没有找到花材');
+        }
+        if ($item->mainId != $this->mainId) {
+            util::fail('不是你的花材');
+        }
+        $adminId = $this->adminId;
+        $ptItemId = $item->itemId ?? 0;
+        $respond = ShopAdminClass::changeWeightRight($adminId, $ptItemId);
+        $hasRightChange = $respond['hasRightChange'];
+        if ($hasRightChange == 0) {
+            util::fail('不能修改');
+        }
+        $ptItem = PtItemClass::getById($ptItemId, true);
+        if (empty($ptItem)) {
+            util::fail('花材信息缺失');
+        }
+        $connection = Yii::$app->db;
+        $transaction = $connection->beginTransaction();
+        try {
+            $ptItem->weight = $weight;
+            $ptItem->save();
+            ItemClass::updateByCondition(['itemId' => $ptItemId], ['weight' => $weight]);
+            $transaction->commit();
+            util::complete('修改成功');
+        } catch (\Exception $e) {
+            $transaction->rollBack();
+            Yii::info("修改失败原因:" . $e->getMessage());
+            util::fail('修改失败');
+        }
+    }
+
+    public function actionModifyRatio()
+    {
+        $shop = $this->shop;
+        if ($shop->default == 0) {
+            util::fail('请在总店(首店)修改');
+        }
+
+        $get = Yii::$app->request->get();
+        $id = $get['id'] ?? '';
+        $ratio = $get['ratio'] ?? 20;
+        if ($ratio < 1) {
+            util::fail('单位比不能小于1');
+        }
+        $item = ItemClass::getById($id, true);
+        if (empty($item)) {
+            util::fail('没有找到花材');
+        }
+        if ($item->mainId != $this->mainId) {
+            util::fail('不是你的花材');
+        }
+        $adminId = $this->adminId;
+        $ptItemId = $item->itemId ?? 0;
+        $respond = ShopAdminClass::changeWeightRight($adminId, $ptItemId);
+        $hasRightChange = $respond['hasRightChange'];
+        if ($hasRightChange == 0) {
+            util::fail('不能修改');
+        }
+        $ptItem = PtItemClass::getById($ptItemId, true);
+        if (empty($ptItem)) {
+            util::fail('花材信息缺失');
+        }
+        $connection = Yii::$app->db;
+        $transaction = $connection->beginTransaction();
+        try {
+            $ptItem->ratio = $ratio;
+            $ptItem->save();
+            ItemClass::updateByCondition(['itemId' => $ptItemId], ['ratio' => $ratio]);
+            $transaction->commit();
+            util::complete('修改成功');
+        } catch (\Exception $e) {
+            $transaction->rollBack();
+            Yii::info("修改失败原因:" . $e->getMessage());
+            util::fail('修改失败');
+        }
+    }
+
+    public function actionModifyUnit()
+    {
+        $shop = $this->shop;
+        if ($shop->default == 0) {
+            util::fail('请在总店(首店)修改');
+        }
+
+        $get = Yii::$app->request->get();
+        $id = $get['id'] ?? '';
+        $unitId = $get['unitId'] ?? 1;
+        $unit = UnitClass::getById($unitId, true);
+        $type = $get['type'] ?? 'big';
+        if (empty($unit)) {
+            util::fail('没有找到单位');
+        }
+        $unitName = $unit->name;
+        $item = ItemClass::getById($id, true);
+        if (empty($item)) {
+            util::fail('没有找到花材');
+        }
+        if ($item->mainId != $this->mainId) {
+            util::fail('不是你的花材');
+        }
+        $adminId = $this->adminId;
+        $ptItemId = $item->itemId ?? 0;
+        $respond = ShopAdminClass::changeWeightRight($adminId, $ptItemId);
+        $hasRightChange = $respond['hasRightChange'];
+        if ($hasRightChange == 0) {
+            util::fail('不能修改');
+        }
+        $ptItem = PtItemClass::getById($ptItemId, true);
+        if (empty($ptItem)) {
+            util::fail('花材信息缺失');
+        }
+        $connection = Yii::$app->db;
+        $transaction = $connection->beginTransaction();
+        try {
+            if ($type == 'big') {
+                $ptItem->bigUnit = $unitName;
+                $ptItem->bigUnitId = $unitId;
+                $ptItem->save();
+                ItemClass::updateByCondition(['itemId' => $ptItemId], ['bigUnit' => $unitName, 'bigUnitId' => $unitId]);
+            } else {
+                $ptItem->smallUnit = $unitName;
+                $ptItem->smallUnitId = $unitId;
+                $ptItem->save();
+                ItemClass::updateByCondition(['itemId' => $ptItemId], ['smallUnit' => $unitName, 'smallUnitId' => $unitId]);
+            }
+            $transaction->commit();
+            util::complete('修改成功');
+        } catch (\Exception $e) {
+            $transaction->rollBack();
+            Yii::info("修改失败原因:" . $e->getMessage());
+            util::fail('修改失败');
+        }
+    }
+
+    //挪到处理区 ssh 20250418
+    public function actionMoveToLosing()
+    {
+        //避免重复提交
+        util::checkRepeatCommit($this->adminId, 4);
+
+        $get = Yii::$app->request->get();
+        $id = $get['id'] ?? '';
+        $num = $get['num'] ?? 0;
+        $item = ItemClass::getById($id, true);
+        if (empty($item)) {
+            util::fail('没有找到花材');
+        }
+        if ($item->mainId != $this->mainId) {
+            util::fail('不是你的花材');
+        }
+        if ($num <= 0) {
+            util::fail('请输入数量');
+        }
+        $remark = '挪到处理区';
+        $staff = $this->shopAdmin;
+        $staffName = $staff->name ?? '';
+        $staffId = $staff->id;
+        $adminId = $this->adminId;
+        $params = [
+            'staffId' => $staffId,
+            'staffName' => $staffName,
+            'adminId' => $adminId,
+            'remark' => $remark,
+        ];
+        $connection = Yii::$app->db;
+        $transaction = $connection->beginTransaction();
+        try {
+            $shop = $this->shop;
+            ItemClass::moveLose($item, $num, $shop, $params);
+            $transaction->commit();
+            util::complete('挪动成功');
+        } catch (\Exception $e) {
+            $transaction->rollBack();
+            Yii::info("挪动失败原因:" . $e->getMessage());
+            util::fail('挪动失败');
+        }
+    }
+
+    //设为处理区用的花材 ssh 20250418
+    public function actionSetLosing()
+    {
+        $get = Yii::$app->request->get();
+        $id = $get['id'] ?? '';
+        $item = ItemClass::getById($id, true);
+        if (empty($item)) {
+            util::fail('没有找到花材');
+        }
+        if ($item->mainId != $this->mainId) {
+            util::fail('不是你的花材');
+        }
+
+        $shopAdmin = $this->shopAdmin;
+        if ($shopAdmin->founder == 1) {
+            util::fail('请用超管手机操作');
+        }
+
+        $shopId = $this->shopId;
+        $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
+        if (empty($ext)) {
+            util::fail('设置失败,没有找到门店信息');
+        }
+        $ext->losingItem = $id;
+        $ext->save();
+        util::complete('设置成功');
+    }
+
+    //增加和减少半扎 ssh 20250417
+    public function actionChangeHalf()
+    {
+        util::fail('此功能已停用');
+
+        $post = Yii::$app->request->post();
+        $productId = $post['productId'] ?? '';
+        $add = $post['add'] ?? 0;
+        $remark = $post['remark'] ?? '';
+        $product = ProductClass::getLockById($productId);
+        if (empty($product)) {
+            util::fail('没有找到花材');
+        }
+        if ($product->mainId != $this->mainId) {
+            util::fail('不是你的花材');
+        }
+        if ($product->ratioType == 1) {
+            util::fail('若干扎的花材不能减半份');
+        }
+
+        //避免重复提交
+        util::checkRepeatCommit($this->adminId, 4);
+
+        $connection = Yii::$app->db;
+        $transaction = $connection->beginTransaction();
+        try {
+            $shop = $this->shop;
+            $staff = $this->shopAdmin;
+            $staffName = $staff->name ?? '';
+            $staffId = $staff->id;
+            $adminId = $this->adminId;
+            $params = [
+                'staffId' => $staffId,
+                'staffName' => $staffName,
+                'adminId' => $adminId,
+                'remark' => $remark,
+            ];
+            ItemClass::modifyHalf($shop, $product, $params, $add);
+            $product = ProductClass::getLockById($productId);
+            $stock = $product->stock;
+            $stock = floatval($stock);
+            $transaction->commit();
+            util::success(['stock' => $stock]);
+        } catch (\Exception $e) {
+            $transaction->rollBack();
+            Yii::info("加减半份失败原因:" . $e->getMessage());
+            util::fail('加减半份失败');
+        }
+    }
+
     //修改一个花材的采购人 ssh 20240719
     public function actionModifyCgStaff()
     {
@@ -91,10 +379,10 @@ class ItemController extends BaseController
             $where['status'] = 1;
         } elseif ($requestType == 'itemList') {
             $where['delStatus'] = 0;
-            if($lookStock == 1){
+            if ($lookStock == 1) {
                 $where['stock>'] = 0;
             }
-            if($lookStock == 2){
+            if ($lookStock == 2) {
                 $where['stock'] = 0;
             }
             unset($where['status']);

+ 27 - 6
app-ghs/controllers/OrderClearController.php

@@ -115,7 +115,7 @@ class OrderClearController extends BaseController
         $get = Yii::$app->request->get();
         $id = $get['id'] ?? 0;
         $payWay = $get['payWay'] ?? dict::getDict('payWay', 'wxPay');
-        $payRemark = $get['payRemark']??'';
+        $payRemark = $get['payRemark'] ?? '';
         $clear = OrderClearClass::getById($id, true);
         if (empty($clear)) {
             util::fail('没有找到结账单');
@@ -126,10 +126,13 @@ class OrderClearController extends BaseController
         if ($ghs->shopId != $this->shopId) {
             util::fail('没有获得授权');
         }
+        if ($ghs->balance > 0) {
+            util::mistake('客户有余额,不能通过订单销账,请走充值。有疑问请联系技术员', false, 'none', 3000);
+        }
 
         $staff = $this->shopAdmin;
-        if (isset($staff->finance) == false || $staff->finance == 0) {
-            util::fail('不能销单...');
+        if (!isset($staff->finance) || $staff->finance == 0) {
+            util::fail('没有财务权限,不能销单哦');
         }
 
         //避免网络延迟,造成重复操作
@@ -154,12 +157,30 @@ class OrderClearController extends BaseController
                     util::fail('不能销单。。。');
                 }
             }
-            //花大苪 洋桔梗,只有叶荷姐才能销账
+            //花大苪 洋桔梗,只有叶荷姐才能销账,多处请搜索关键词hdb_clear_control
             if (in_array($this->shopId, [16070])) {
                 if (!in_array($this->adminId, [9303, 4])) {
                     util::fail('不能销单。');
                 }
             }
+            //中山淘花里,销账权限控制,多处请搜索 thl_clear_control
+            if (in_array($this->shopId, [17118])) {
+                if (!in_array($this->adminId, [55494, 55445, 17908, 55459, 55707, 55709])) {
+                    util::fail('你不能销单那。。');
+                }
+            }
+            //小齐鲜花总店和出车,多处请搜索关键词 xq_clear_control
+            if (in_array($this->shopId, [41467, 42946])) {
+                if (!in_array($this->adminId, [40144])) {
+                    util::fail('不能销单。');
+                }
+            }
+            //恋善好多花控制销账权限
+            if (in_array($this->shopId, [55238, 56609, 56611])) {
+                if (!in_array($this->adminId, [43856, 54620])) {
+                    util::fail('暂无权限,请联系老板或财务');
+                }
+            }
             //天天鲜花 陈江店
             if (in_array($this->shopId, [763, 1405, 795])) {
                 if (!in_array($this->adminId, [2094, 5959])) {
@@ -180,13 +201,13 @@ class OrderClearController extends BaseController
             }
             //源花汇
             if (in_array($this->shopId, [10649])) {
-                if (!in_array($this->adminId, [11641, 11648])) {
+                if (!in_array($this->adminId, [11641, 11648, 4])) {
                     util::fail('请闵总或小周操作');
                 }
             }
             //昱成
             if (in_array($this->shopId, [8596])) {
-                if (!in_array($this->adminId, [9303,9601])) {
+                if (!in_array($this->adminId, [9303, 9601])) {
                     util::fail('只能叶荷和财务操作');
                 }
             }

+ 150 - 22
app-ghs/controllers/OrderController.php

@@ -9,6 +9,7 @@ use bizGhs\ghs\classes\GhsClass;
 use bizGhs\order\classes\OrderItemClass;
 use bizGhs\order\classes\RefundOrderClass;
 use bizHd\purchase\classes\PurchaseClass;
+use bizHd\purchase\classes\PurchaseItemClass;
 use bizHd\purchase\services\PurchaseService;
 use bizHd\wx\classes\WxOpenClass;
 use bizGhs\custom\classes\CustomClass;
@@ -23,8 +24,10 @@ use common\components\dirUtil;
 use common\components\freight;
 use common\components\httpUtil;
 use common\components\noticeUtil;
+use common\components\orderSn;
 use common\components\oss;
 use common\components\payUtil;
+use common\components\printUtil;
 use common\components\qrCodeUtil;
 use common\components\stringUtil;
 use Yii;
@@ -654,35 +657,75 @@ class OrderController extends BaseController
         $get = Yii::$app->request->get();
         $id = isset($get['id']) ? $get['id'] : 0;
         $order = OrderClass::getById($id, true);
-        if (isset($order->status) == false || $order->status != 1) {
-            util::fail('不是待付款订单');
+        if (empty($order)) {
+            $msg = '没有找到订单';
+            util::success(['returnStatus' => 'FAILURE'], $msg);
+        }
+        if ($order->status != 1) {
+            $msg = '不是待付款订单';
+            util::success(['returnStatus' => 'FAILURE'], $msg);
         }
         OrderClass::valid($order, $this->shopId);
         $cgId = $order->purchaseId ?? 0;
         $cg = PurchaseClass::getById($cgId, true);
         $orderSn = $cg->orderSn ?? '';
         if (empty($orderSn)) {
-            util::fail('没有找到采购单');
+            $msg = '没有找到采购单';
+            util::success(['returnStatus' => 'FAILURE'], $msg);
         }
+
+
+        $codePayErrorKey = 'code_pay_error_' . $id;
+        $hasFailPay = Yii::$app->redis->executeCommand('GET', [$codePayErrorKey]);
+        //前面有付失败过,要重新生成单号
+        if (!empty($hasFailPay)) {
+            $oldOrderSn = $orderSn;
+            $orderSn = orderSn::getPurchaseSn();
+            $cg->orderSn = $orderSn;
+            $cg->save();
+            noticeUtil::push("重新扫码,成功更换单号 {$oldOrderSn} {$orderSn}", '15280215347');
+            PurchaseItemClass::updateByCondition(['orderSn' => $oldOrderSn], ['orderSn' => $orderSn]);
+        }
+
+
+        $shop = $this->shop;
+        $sj = $shop->merchantName;
+        $shopName = $shop->shopName;
+        $name = $shopName == '首店' ? $sj : $sj . '-' . $shopName;
+
         //付款码
         $authCode = (string)$get['authCode'] ?? '';
+        $authCode = trim($authCode);
         if (empty($authCode)) {
-            util::fail('支付失败');
+            $msg = '没有扫到付款码';
+            $remind = $msg . "(付款码:{$authCode})" . '(' . $name . ')';
+            noticeUtil::push($remind . ' 编号001', '15280215347');
+            util::success(['returnStatus' => 'FAILURE'], $msg);
+        }
+        //微信文档说明 https://pay.weixin.qq.com/doc/v2/merchant/4011936234
+        $wxPattern = '/^(10|11|12|13|14|15)\d{16}$/';
+        //支付宝文档说明 https://opendocs.alipay.com/open/194/106039/
+        $aliPattern = '/^(25|26|27|28|29|30)\d{14,22}$/';
+        if (!preg_match($wxPattern, $authCode) && !preg_match($aliPattern, $authCode)) {
+            $msg = '付款码有问题';
+            $remind = $msg . "(付款码:{$authCode})" . '(' . $name . ')';
+            noticeUtil::push($remind . ' 编号002', '15280215347');
+            util::success(['returnStatus' => 'FAILURE'], $msg);
         }
 
         $deadline = $cg->deadline;
         $current = date("Y-m-d H:i:s");
         if ((strtotime($deadline) + 20) < strtotime($current)) {
-            util::fail('订单已经失效');
+            $msg = '订单已经失效';
+            util::success(['returnStatus' => 'FAILURE'], $msg);
         }
         $totalFee = $cg->actPrice ?? 0;
 
         $connection = Yii::$app->db;
         $transaction = $connection->beginTransaction();
         try {
-            $subject = '购买花材';
+            $subject = '购买花材 '.$orderSn;
             $capitalType = dict::getDict('capitalType', 'xhPurchase', 'id');
-            $shop = $this->shop;
             $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
             $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
             $params = [
@@ -768,8 +811,19 @@ class OrderController extends BaseController
                 }
                 util::success(['returnStatus' => 'SUCCESS']);
             } else {
+
+                //标记有没付成功的次数,原因有可能是余额不足等
+                Yii::$app->redis->executeCommand('SETEX', [$codePayErrorKey, 1200, 'hasFail']);
+
                 $msg = $response['msg'] ?? '';
-                util::success(['returnStatus' => 'FAILURE'], $msg);
+                $retCode = $response['code'] ?? '';
+                if ($retCode == 'BBS10000' || $retCode == 'BBS11105') {
+                    $shopId = $order->shopId;
+                    ShopExtClass::remindInputPassword($shopId);
+                }
+                $fullMsg = $msg . "(付款码:{$authCode})" . '(' . $name . ')';
+                noticeUtil::push($fullMsg . ' ' . $retCode . ' 编号007', '15280215347');
+                util::success(['returnStatus' => 'FAILURE', 'returnCode' => $retCode], $msg);
             }
         } catch (\Exception $e) {
             $transaction->rollBack();
@@ -976,7 +1030,7 @@ class OrderController extends BaseController
         Yii::$app->redis->executeCommand('SETEX', [$createOrderCacheKey, 5, 'has']);
 
         CustomClass::valid($custom, $this->shopId);
-        if (isset($custom['mainId']) && !empty($custom['mainId']) && $custom['mainId'] == $custom['ownMainId']) {
+        if (!empty($custom['mainId']) && $custom['mainId'] == $custom['ownMainId']) {
             util::fail('不能给自己开单');
         }
         $post['ghsId'] = $custom['ghsId'] ?? 0;
@@ -994,10 +1048,24 @@ class OrderController extends BaseController
         $post['showAddress'] = $custom['showAddress'] ?? '';
         $post['long'] = $custom['long'] ?? '';
         $post['lat'] = $custom['lat'] ?? '';
-        if (isset($post['getStaffId']) == true && !empty($post['getStaffId'])) {
-            $getStaffName = $post['getStaffName'] ?? '';
-            $shopAdminId = $post['getStaffId'];
-            $shopAdminName = $getStaffName;
+        if (!empty($post['getStaffId'])) {
+            if (getenv('YII_ENV') == 'production') {
+                $tbMainId = 44171;
+            } else {
+                $tbMainId = 644;
+            }
+            if ($this->mainId == $tbMainId) {
+                //平潭花天下,就算选了收款人,也不要给改变开单人,临时解决方案 ssh 2250314
+                if (!empty($post['shopAdminId'])) {
+                    $getStaffName = $post['shopAdminName'] ?? '';
+                    $shopAdminId = $post['shopAdminId'];
+                    $shopAdminName = $getStaffName;
+                }
+            } else {
+                $getStaffName = $post['getStaffName'] ?? '';
+                $shopAdminId = $post['getStaffId'];
+                $shopAdminName = $getStaffName;
+            }
         } else {
             if (getenv('YII_ENV') == 'production') {
                 //鹏诚需要选择开单人
@@ -1014,7 +1082,7 @@ class OrderController extends BaseController
         if (getenv('YII_ENV') == 'production') {
             //小向花卉开单售后控制
             if ($this->mainId == 23390) {
-                if (!in_array($this->adminId, [24043, 24585, 24586, 24654, 24115, 23960, 28456, 31105, 28456, 31105])) {
+                if (!in_array($this->adminId, [24043, 24585, 24586, 24654, 24115, 23960, 28456, 31105, 28456, 31105, 52528, 25011])) {
                     util::fail('你不能开单哦');
                 }
             }
@@ -1038,6 +1106,15 @@ class OrderController extends BaseController
         $transType = $post['transType'] ?? 0;
 
         $shop = $this->shop;
+
+        //到期超过5天不支持开单
+        $deadline = $shop->deadline;
+        $deadTime = strtotime($deadline);
+        $myCurrentTime = time() + 432000;
+        if ($myCurrentTime > $deadTime) {
+            util::fail('系统已到期,请续费');
+        }
+
         if (isset($shop->pfLevel) && $shop->pfLevel == 1) {
             //昆明发往全国
             $sendCost = isset($post['sendCost']) && $post['sendCost'] > 0 ? $post['sendCost'] : 0;
@@ -1077,15 +1154,15 @@ class OrderController extends BaseController
         }
 
         if (getenv('YII_ENV') == 'production') {
-            if($this->mainId == 1082){
+            if ($this->mainId == 1082) {
                 //泉城鲜花批发的出车,只能开收现金方式,多处要修改,关键词qc_cash
-                if($hasPay != 0){
+                if ($hasPay != 0) {
                     util::fail('只能使用扫码付款,编号193');
                 }
             }
-        }else{
-            if($this->mainId == 644){
-                if($hasPay != 0){
+        } else {
+            if ($this->mainId == 644) {
+                if ($hasPay != 0) {
                     //util::fail('只能使用扫码付款,编号190');
                 }
             }
@@ -1465,11 +1542,11 @@ class OrderController extends BaseController
         Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 4, 'has']);
 
         if (getenv('YII_ENV') == 'production') {
-            if($this->mainId == 1082){
+            if ($this->mainId == 1082) {
                 //泉城鲜花批发的出车,只能开收现金方式,多处要修改,关键词qc_cash
                 util::fail('只能使用扫码付款,编号293');
             }
-        }else{
+        } else {
 
         }
 
@@ -2304,7 +2381,7 @@ class OrderController extends BaseController
         //超管或者约定的人可以修改日期
         if (getenv('YII_ENV') == 'production') {
             if (in_array($mainId, [23390])) {
-                if (!in_array($this->adminId, [24586, 23960])) {
+                if (!in_array($this->adminId, [24586, 23960, 24043])) {
                     util::fail('你不能修改哦');
                 }
             }
@@ -2854,4 +2931,55 @@ class OrderController extends BaseController
         }
     }
 
+    //打印发物流用和标签 ssh 20250312
+    public function actionPrintWlLabel()
+    {
+        $get = Yii::$app->request->get();
+        $id = $get['id'] ?? 0;
+        $order = OrderClass::getById($id, true);
+        if (empty($order)) {
+            util::fail('没有找到订单');
+        }
+        $customId = $order->customId ?? 0;
+        $custom = CustomClass::getById($customId, true);
+        if (empty($custom)) {
+            util::fail('没有找到客户');
+        }
+        $shortName = $custom->shortName ?? '';
+        if (empty($shortName)) {
+            util::fail('客户的短名没有设置');
+        }
+        $shortName = stringUtil::subStringUtf8($shortName, 5);
+        $customMobile = $order->customMobile ?? '';
+        if (empty($customMobile)) {
+            util::fail('客户手机号无效');
+        }
+        $shortMobile = substr($customMobile, -4);
+        $remark = $order->remark ?? '';
+        $shortRemark = stringUtil::subStringUtf8($remark, 8);
+
+        $shop = $this->shop;
+        $shopName = $shop->shopName ?? '';
+        $sjName = $shop->merchantName;
+        $currentName = $shopName == '首店' ? $sjName : $sjName . ' ' . $shopName;
+        $telephone = $shop->telephone ?? '';
+
+        $ext = $this->shopExt;
+        $wlLabelSn = $ext->wlLabelSn ?? '';
+        if (empty($wlLabelSn)) {
+            util::fail('请绑定物流标签机');
+        }
+        $p = new printUtil($wlLabelSn);
+        $p->times = 2;
+        $content = '<TEXT x="420" y="130" font="12" w="4" h="4" r="90">' . $shortName . '</TEXT>';
+        $content .= '<TEXT x="395" y="10" font="12" w="2" h="2" r="90">地址</TEXT>';
+        $content .= '<TEXT x="290" y="130" font="12" w="4" h="4" r="90">' . $shortMobile . '</TEXT>';
+        $content .= '<TEXT x="265" y="10" font="12" w="2" h="2" r="90">代码</TEXT>';
+        $content .= '<TEXT x="170" y="130" font="12" w="4" h="4" r="90">' . $shortRemark . '</TEXT>';
+        $content .= '<TEXT x="150" y="10" font="12" w="2" h="2" r="90">物流</TEXT>';
+        $content .= '<TEXT x="45" y="70" font="12" w="2" h="2" r="90">' . $currentName . ' ' . $telephone . '</TEXT>';
+        $p->printLabelMsg($content);
+        util::complete('打印成功');
+    }
+
 }

+ 2 - 5
app-ghs/controllers/PartController.php

@@ -86,10 +86,7 @@ class PartController extends BaseController
         foreach ($productList as $v) {
             $bigNum = $v['bigNum'] ?? 0;
             $smallNum = $v['smallNum'] ?? 0;
-            if ($smallNum > 0) {
-                util::fail('只能拆散整扎');
-            }
-            if ($bigNum <= 0) {
+            if ($bigNum <= 0 && $smallNum <= 0) {
                 util::fail('数量不能为0');
             }
             $property = $v['property'] ?? 1;
@@ -105,7 +102,7 @@ class PartController extends BaseController
             $post['ptStyle'] = dict::getDict('ptStyle', 'ghs');
             $return = PartClass::addOrder($post);
             $transaction->commit();
-            util::success($return,'拆散成功');
+            util::success($return, '拆散成功');
         } catch (\Exception $e) {
             $transaction->rollBack();
             Yii::info("拆散失败原因:" . $e->getMessage());

+ 23 - 4
app-ghs/controllers/ProductController.php

@@ -186,6 +186,8 @@ class ProductController extends BaseController
                 $content .= '<BC128 x="30" y="115" h="75" s="1" r="0" n="3" w="10">' . $ptItemId . '</BC128>';
                 if (in_array($mainId, [52, 1459])) {
                     $content .= '<TEXT x="30" y="250" font="12" w="2" h="2" r="0">惠雅鲜花</TEXT>';
+                } elseif ($mainId == 16948) {
+                    $content .= '<TEXT x="30" y="250" font="12" w="2" h="2" r="0">淘花里鲜花</TEXT>';
                 } else {
                     $content .= '<TEXT x="30" y="250" font="12" w="1" h="1" r="0">' . $unit . '</TEXT>';
                 }
@@ -288,7 +290,7 @@ class ProductController extends BaseController
         $itemInfoData = [];
         if ($requestType == 'hasStockList') {
             //有库存的花材列表
-            $field = 'id,py,cover,name,classId,itemId,price,skPrice,hjPrice,stock,cost,addPrice,hjAddPrice,skMore';
+            $field = 'id,py,cover,name,classId,itemId,price,skPrice,hjPrice,stock,onStock,cost,addPrice,hjAddPrice,skMore';
             $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
             if (!empty($itemInfoData)) {
                 foreach ($itemInfoData as $key => $val) {
@@ -600,7 +602,10 @@ class ProductController extends BaseController
         $join = $shop->join ?? 0;
         $default = $shop->default ?? 0;
         if ($join == 0 && $default == 0) {
-            util::fail('直营分店不能改价');
+            //除了小蔡鲜花的蔡总、郑总,其他人直营分店不能改价格,多处要同步修改,关键词d_price_change
+            if (!in_array($this->adminId, [35725, 23659])) {
+                util::fail('直营店不能改价');
+            }
         }
 
         $shopAdmin = $this->shopAdmin;
@@ -727,7 +732,7 @@ class ProductController extends BaseController
 
             $mainId = $shop->mainId ?? 0;
             if (!empty($mainId)) {
-                //提醒零售收银台界面要刷新
+                //提醒零售收银台界面要刷新,多处要修改,关键词 modify_price_remind_cashier
                 $staffList = ShopAdminClass::getAllByCondition(['mainId' => $mainId], null, '*', null, true);
                 if (!empty($staffList)) {
                     foreach ($staffList as $staff) {
@@ -846,7 +851,7 @@ class ProductController extends BaseController
             }
 
             if (!empty($mainId)) {
-                //提醒零售收银台界面要刷新
+                //提醒零售收银台界面要刷新,多处要修改,关键词 modify_price_remind_cashier
                 $staffList = ShopAdminClass::getAllByCondition(['mainId' => $mainId], null, '*', null, true);
                 if (!empty($staffList)) {
                     foreach ($staffList as $staff) {
@@ -1072,6 +1077,12 @@ class ProductController extends BaseController
             }
         }
 
+        $deadline = $shop->deadline;
+        $deadTime = strtotime($deadline);
+        if (time() > $deadTime) {
+            util::fail('系统已到期');
+        }
+
         $post = Yii::$app->request->post();
         $discountPrice = $post['discountPrice'] ?? 0;
         if ($discountPrice > 0) {
@@ -1244,6 +1255,14 @@ class ProductController extends BaseController
                 }
             }
         }
+
+        //判断这个花材能否被修改单位比和重量,同步参考ShopController actionMyShop方法,关键词has_right_shop_list
+        //判断当前登录的人,在自己有财务权限的main里面,是否包括了这个花材所属的平台id,在这个平台id下所有花材的main
+        $adminId = $this->adminId;
+        $hasRightRespond = ShopAdminClass::changeWeightRight($adminId, $ptItemId);
+        $respond['hasRightChange'] = $hasRightRespond['hasRightChange'];
+        $respond['hasRightChangeReason'] = $hasRightRespond['reason'];
+
         $respond['cpInfo'] = $cpInfo;
         util::success($respond);
     }

+ 19 - 1
app-ghs/controllers/PurchaseClearController.php

@@ -41,12 +41,30 @@ class PurchaseClearController extends BaseController
                     util::fail('不能操作哈');
                 }
             }
-            //花大苪 洋桔梗,只有叶荷姐才能销账
+            //花大苪 洋桔梗,只有叶荷姐才能销账,多处请搜索关键词hdb_clear_control
             if (in_array($this->shopId, [16070])) {
                 if (!in_array($this->adminId, [9303, 4])) {
                     util::fail('暂无权限');
                 }
             }
+            //中山淘花里,销账权限控制,多处请搜索 thl_clear_control
+            if (in_array($this->shopId, [17118])) {
+                if (!in_array($this->adminId, [55494, 55445, 17908, 55459, 55707, 55709])) {
+                    util::fail('你不能销单!');
+                }
+            }
+            //小齐鲜花总店和出车,多处请搜索关键词 xq_clear_control
+            if (in_array($this->shopId, [41467, 42946])) {
+                if (!in_array($this->adminId, [40144])) {
+                    util::fail('不能操作哈。。');
+                }
+            }
+            //恋善好多花控制销账权限
+            if (in_array($this->shopId, [55238,56609,56611])) {
+                if (!in_array($this->adminId, [43856, 54620])) {
+                    util::fail('暂无权限,请联系老板或财务');
+                }
+            }
         } else {
             if (in_array($this->shopId, [36523])) {
 //                if (!in_array($this->adminId, [919])) {

+ 31 - 12
app-ghs/controllers/PurchaseOrderController.php

@@ -227,6 +227,8 @@ class PurchaseOrderController extends BaseController
                 $content .= '<BC128 x="30" y="100" h="70" s="1" r="0" n="4" w="11">' . $ptItemId . '</BC128>';
                 if (in_array($mainId, [52, 1459])) {
                     $content .= '<TEXT x="30" y="250" font="12" w="2" h="2" r="0">惠雅鲜花</TEXT>';
+                } elseif ($mainId == 16948) {
+                    $content .= '<TEXT x="30" y="250" font="12" w="2" h="2" r="0">淘花里鲜花</TEXT>';
                 } else {
                     $content .= '<TEXT x="30" y="250" font="12" w="2" h="2" r="0">' . $unit . '</TEXT>';
                 }
@@ -291,6 +293,8 @@ class PurchaseOrderController extends BaseController
             $content .= '<BC128 x="30" y="100" h="70" s="1" r="0" n="4" w="11">' . $ptItemId . '</BC128>';
             if (in_array($mainId, [52, 1459])) {
                 $content .= '<TEXT x="30" y="250" font="12" w="2" h="2" r="0">惠雅鲜花</TEXT>';
+            } elseif ($mainId == 16948) {
+                $content .= '<TEXT x="30" y="250" font="12" w="2" h="2" r="0">淘花里鲜花</TEXT>';
             } else {
                 $content .= '<TEXT x="30" y="250" font="12" w="2" h="2" r="0">' . $unit . '</TEXT>';
             }
@@ -500,6 +504,7 @@ class PurchaseOrderController extends BaseController
                 }
             }
 
+
             //判断花材里的信息
             foreach ($ghsItemInfo as $v) {
                 $bigNum = $v['bigNum'] ?? 0;
@@ -516,6 +521,13 @@ class PurchaseOrderController extends BaseController
                     util::fail('花材数量不能为0');
                 }
 
+                //城市批发店限制不能让其录小单位,太多人录错,昆明批发不知道有没人录,暂时不限制。 ssh 20250308
+                if ($shop->pfLevel == 0) {
+                    if ($smallNum > 0) {
+                        util::fail('不能录小单位:' . $name);
+                    }
+                }
+
                 if ($globalCgMyCharge == 1) {
                     if (isset($needCgList[$productId]) == false) {
                         util::fail($name . ' 不需要采购');
@@ -700,24 +712,33 @@ class PurchaseOrderController extends BaseController
             }
         }
 
+        $adminId = $this->adminId;
+        $mainId = $this->mainId;
+
         //采购限制访问,有多处要同步修改,关键词cg_limit_access
         if (getenv('YII_ENV') == 'production') {
             //纯彩花艺
             if ($this->mainId == 10) {
-                if (in_array($this->adminId, [37, 988, 14346]) == false) {
-                    util::fail('没有数据哦1');
+                if (!in_array($this->adminId, [37, 988, 14346])) {
+                    util::fail('没有数据哦,编号1792');
                 }
             }
             //天天鲜花十堰店
             if ($this->mainId == 7184) {
-                if (in_array($this->adminId, [8340, 8345, 9433]) == false) {
-                    util::fail('没有数据哦2');
+                if (!in_array($this->adminId, [8340, 8345, 9433])) {
+                    util::fail('没有数据哦,编号1592');
                 }
             }
             //小向花卉采购控制
             if ($this->mainId == 23390) {
                 if (!in_array($this->adminId, [24586, 24115, 24759, 26390, 23960, 25011, 25004, 24655, 28521, 4])) {
-                    util::fail('没有数据哦3');
+                    util::fail('没有数据哦,编号2292');
+                }
+            }
+            //中山淘花里采购控制,多处要修改,搜索关键词 thl_cg_control
+            if ($mainId == 16948) {
+                if (!in_array($adminId, [55494, 55445, 17908, 55459, 55707, 4, 55709])) {
+                    util::fail('暂时不能查看哦,编号6811');
                 }
             }
         }
@@ -788,16 +809,14 @@ class PurchaseOrderController extends BaseController
             if ($mainId == 8164) {
                 if (!isset($staff->finance) || $staff->finance == 0) {
                     if ($hasOver) {
-                        util::fail('超过3天,无法查看');
+                        util::fail('超过3天,暂时无法查看');
                     }
                 }
             }
-        } else {
-            if ($mainId == 644) {
-                if (!isset($staff->finance) || $staff->finance == 0) {
-                    if ($hasOver) {
-                        util::fail('超过3天,无法查看');
-                    }
+            //中山淘花里采购控制,多处要修改,搜索关键词 thl_cg_control
+            if ($mainId == 16948) {
+                if (!in_array($adminId, [55494, 55445, 17908, 55459, 55707, 4, 55709])) {
+                    util::fail('暂时不能查看哦,编号6892');
                 }
             }
         }

+ 74 - 19
app-ghs/controllers/RefundController.php

@@ -9,6 +9,7 @@ use bizGhs\shop\classes\ShopClass;
 use bizHd\cg\classes\CgRefundClass;
 use bizHd\cg\classes\CgRefundItemClass;
 use bizHd\notice\classes\NoticeClass;
+use bizHd\purchase\classes\PurchaseClass;
 use bizHd\purchase\classes\PurchaseClearClass;
 use common\components\dateUtil;
 use common\components\imgUtil;
@@ -24,6 +25,30 @@ use bizGhs\order\classes\StockWastageOrderClass;
 class RefundController extends BaseController
 {
 
+    //取消的订单退钱,特殊情况的操作:商家取消订单时,客户同时付款成功了,造成的流程冲突,需要退钱 ssh 20250429
+    public function actionRefundMoney()
+    {
+        $get = Yii::$app->request->get();
+        $id = $get['id'] ?? '';
+        $order = OrderClass::getById($id, true);
+        if (empty($order)) {
+            util::fail('没有找到订单');
+        }
+        if ($order->mainId != $this->mainId) {
+            util::fail('不是你的订单');
+        }
+        $shop = $this->shop;
+        $purchaseId = $order->purchaseId ?? 0;
+        $cg = PurchaseClass::getById($purchaseId, true);
+        if (empty($cg)) {
+            util::fail('没有找到订单');
+        }
+        $respond = CgRefundClass::onlyRefundMoney($shop, $cg);
+        $status = $respond['status'];
+        $msg = $respond['msg'];
+        util::success(['status' => $status], $msg);
+    }
+
     //修改金额 ssh 20240412
     public function actionModifyAmount()
     {
@@ -95,18 +120,30 @@ class RefundController extends BaseController
             util::fail('无法操作');
         }
 
+        //多处要同步修改ghs_refund ssh 20250331
         if (getenv('YII_ENV') == 'production') {
             //小向花卉开单售后控制
             if ($this->mainId == 23390) {
                 if (!in_array($this->adminId, [24043, 24585, 24586, 24654, 24115, 23960])) {
-                    util::fail('你不能售后哦。。');
+                    util::fail('你不能售后哦');
+                }
+                //小向花卉售后必须备注
+                $remark = $post['remark'] ?? '';
+                if (empty($remark)) {
+                    util::fail('请填写备注007');
                 }
             }
-        } else {
-            if ($this->mainId == 644) {
-//                if (!in_array($this->adminId, [919])) {
-//                    util::fail('你不能售后哈');
-//                }
+            //国恋只有指定人有退款权限
+            if ($this->mainId == 7704) {
+                if (in_array($this->shopAdminId, [133727, 133545]) == false) {
+                    util::fail('无法操作。。');
+                }
+            }
+            //小齐出车指定人可以售后
+            if ($this->mainId == 42680) {
+                if (!in_array($this->adminId, [40144])) {
+                    util::fail('你不能售后哦。。');
+                }
             }
         }
 
@@ -177,18 +214,30 @@ class RefundController extends BaseController
             util::fail('无法操作');
         }
 
+        //多处要同步修改ghs_refund ssh 20250331
         if (getenv('YII_ENV') == 'production') {
             //小向花卉开单售后控制
             if ($this->mainId == 23390) {
                 if (!in_array($this->adminId, [24043, 24585, 24586, 24654, 24115, 23960])) {
                     util::fail('你不能售后哦。。');
                 }
+                //小向花卉售后必须备注
+                $remark = $post['remark'] ?? '';
+                if (empty($remark)) {
+                    util::fail('请填写备注007');
+                }
             }
-        } else {
-            if ($this->mainId == 644) {
-//                if (!in_array($this->adminId, [919])) {
-//                    util::fail('你不能售后哈');
-//                }
+            //国恋只有指定人有退款权限
+            if ($this->mainId == 7704) {
+                if (in_array($this->shopAdminId, [133727, 133545]) == false) {
+                    util::fail('无法操作。。');
+                }
+            }
+            //小齐出车指定人可以售后
+            if ($this->mainId == 42680) {
+                if (!in_array($this->adminId, [40144])) {
+                    util::fail('你不能售后哦。。。');
+                }
             }
         }
 
@@ -483,18 +532,12 @@ class RefundController extends BaseController
             util::fail('超管才能操作退款');
         }
 
-        //国恋只有指定人有退款权限
-        if ($this->mainId == 7704) {
-            if (in_array($this->shopAdminId, [133727, 133545]) == false) {
-                util::fail('无法操作。。');
-            }
-        }
-
+        //多处要同步修改ghs_refund ssh 20250331
         if (getenv('YII_ENV') == 'production') {
             //小向花卉开单售后控制
             if ($this->mainId == 23390) {
                 if (!in_array($this->adminId, [24043, 24585, 24586, 24654, 24115, 23960])) {
-                    util::fail('你不能售后。。');
+                    util::fail('你不能售后哈。。');
                 }
                 //小向花卉售后必须备注
                 $remark = $post['remark'] ?? '';
@@ -502,6 +545,18 @@ class RefundController extends BaseController
                     util::fail('请填写备注007');
                 }
             }
+            //国恋只有指定人有退款权限
+            if ($this->mainId == 7704) {
+                if (in_array($this->shopAdminId, [133727, 133545]) == false) {
+                    util::fail('无法操作。。');
+                }
+            }
+            //小齐出车指定人可以售后
+            if ($this->mainId == 42680) {
+                if (!in_array($this->adminId, [40144])) {
+                    util::fail('你不能售后哦。。');
+                }
+            }
         }
 
         $id = isset($post['id']) ? $post['id'] : 0;

+ 39 - 8
app-ghs/controllers/ShopController.php

@@ -7,6 +7,7 @@ use biz\shop\classes\ShopAdminClass;
 use biz\sj\services\MerchantExtendService;
 use bizGhs\admin\classes\AdminClass;
 use bizGhs\custom\classes\CustomClass;
+use bizGhs\ghs\classes\GhsClass;
 use bizGhs\merchant\classes\ShopClass;
 use bizGhs\merchant\services\ShopService;
 use bizHd\saas\services\RegionService;
@@ -47,7 +48,7 @@ class ShopController extends BaseController
             $sjId = $this->sjId ?? 0;
             $shopList = ShopClass::getAllByCondition(['sjId' => $sjId, 'ptStyle' => 2], null, 'id,shopName,merchantName,sjId,mainId,ptStyle', 'id');
         }
-        $adminId = $this->adminId ?? 0;
+        $adminId = $this->adminId;
         $staffList = ShopAdminClass::getAllByCondition(['adminId' => $adminId], null, '*', null, true);
         $mainIdList = [];
         if (!empty($staffList)) {
@@ -66,7 +67,7 @@ class ShopController extends BaseController
             if (!empty($addShopList)) {
                 foreach ($addShopList as $addShop) {
                     $addShopId = $addShop['id'] ?? 0;
-                    if (isset($shopList[$addShopId]) == false) {
+                    if (!isset($shopList[$addShopId])) {
                         $shopList[$addShopId] = $addShop;
                     }
                 }
@@ -140,16 +141,18 @@ class ShopController extends BaseController
         $id = $post['id'] ?? 0;
         $shop = ShopService::getById($id);
         if (empty($shop)) {
-            util::fail('没有找到门店65');
+            util::fail('没有找到门店,编号657701');
         }
         $staff = $this->shopAdmin;
         if (isset($staff->finance) == false || $staff->finance == 0) {
-            if ($this->adminId != 4) {
+            //花掌柜的小石,源花汇的小吕和小吴,没有财务权限也要能修改门店
+            if (!in_array($this->adminId, [4, 11961, 11976])) {
                 util::fail('没有修改门店权限');
             }
         }
         if (isset($staff->super) == false || $staff->super == 0) {
-            if ($this->adminId != 4) {
+            //花掌柜的小石,源花汇的小吕和小吴,没有改库存改价格权限也要能修改门店
+            if (!in_array($this->adminId, [4, 11961, 11976])) {
                 util::fail('没有修改门店权限哦');
             }
         }
@@ -327,6 +330,24 @@ class ShopController extends BaseController
     //切换门店 lqh 2021.1.31
     public function actionToggleShop()
     {
+
+        $mainId = $this->mainId;
+        $adminId = $this->adminId;
+        if (getenv('YII_ENV') == 'production') {
+            //安海恋善指定人不能切换门店
+            if (in_array($mainId, [44759, 56314, 56315, 56452])) {
+                if (in_array($adminId, [54630, 54723])) {
+                    util::fail('不能切换门店,原因是容易误操作或收银机登录使用');
+                }
+            }
+        } else {
+            if (in_array($mainId, [644])) {
+                if (in_array($adminId, [919])) {
+                    //util::fail('不能切换门店,原因是容易误操作或收银机登录使用');
+                }
+            }
+        }
+
         $shopAdmin = $this->shopAdmin;
         $switchShop = ShopAdminClass::hasSwitchShopRight($shopAdmin);
         if ($switchShop == 0) {
@@ -392,7 +413,13 @@ class ShopController extends BaseController
     public function actionGetPtGhsShop()
     {
         $hasSale = Yii::$app->request->get('hasSale', 0);
-        $shopList = ShopClass::getAllByCondition(['ptStyle' => 2, 'live' => 1], 'id asc', '*');
+        $name = Yii::$app->request->get('name', '');
+        $arr = ['ptStyle' => 2, 'live' => 1];
+        if (!empty($name)) {
+            $arr['merchantName'] = ['like', $name];
+            $hasSale = 0;
+        }
+        $shopList = ShopClass::getAllByCondition($arr, 'id asc', '*');
         $totalSale = 0;
         $totalShopNum = 0;
         $totalBalance = 0;
@@ -401,8 +428,12 @@ class ShopController extends BaseController
                 $mainId = $shop['mainId'] ?? 0;
                 $main = MainClass::getById($mainId, true);
                 $balance = $main->balance ?? 0;
-                $respond = StatSaleClass::profile($mainId);
-                $incomeList = $respond['income'] ?? [];
+                if (!empty($name) || $hasSale == 0) {
+                    $incomeList = [];
+                } else {
+                    $respond = StatSaleClass::profile($mainId);
+                    $incomeList = $respond['income'] ?? [];
+                }
                 $todaySale = 0;
                 if (!empty($incomeList)) {
                     foreach ($incomeList as $item) {

+ 27 - 2
app-ghs/controllers/ShopExtController.php

@@ -122,6 +122,10 @@ class ShopExtController extends BaseController
         $printKey = $get['printKey'] ?? '';
         $printLabelSn = $get['printLabelSn'] ?? '';
         $printLabelKey = $get['printLabelKey'] ?? '';
+
+        $wlLabelSn = $get['wlLabelSn'] ?? '';
+        $wlLabelKey = $get['wlLabelKey'] ?? '';
+
         $shop = $this->shop;
         $default = $shop->default ?? 0;
         $shopName = $shop->shopName ?? '';
@@ -150,9 +154,9 @@ class ShopExtController extends BaseController
                 $ext->printLabelSn = $printLabelSn;
                 $ext->printLabelKey = $printLabelKey;
                 $ext->save();
-                //将打印纸张设置为50X70
+                //将打印纸张设置为50X40
                 $labelPrint->times = 1;
-                $content = '<SIZE>50,70</SIZE>';
+                $content = '<SIZE>50,40</SIZE>';
                 $labelPrint->printLabelMsg($content);
             } else {
                 $hasFail = 1;
@@ -162,6 +166,27 @@ class ShopExtController extends BaseController
             $ext->printLabelKey = '';
             $ext->save();
         }
+
+        if (!empty($wlLabelSn) && !empty($wlLabelKey)) {
+            $labelPrint = new printUtil($wlLabelSn);
+            $return = $labelPrint->addPrint($wlLabelKey, $name);
+            if ($return) {
+                $ext->wlLabelSn = $wlLabelSn;
+                $ext->wlLabelKey = $wlLabelKey;
+                $ext->save();
+                //将打印纸张设置为60X100
+                $labelPrint->times = 1;
+                $content = '<SIZE>60,100</SIZE>';
+                $labelPrint->printLabelMsg($content);
+            } else {
+                $hasFail = 1;
+            }
+        } else {
+            $ext->wlLabelSn = '';
+            $ext->wlLabelKey = '';
+            $ext->save();
+        }
+
         if ($hasFail == 1) {
             util::success(['hasFail' => 1], '出现添加失败的情况');
         }

+ 1 - 1
app-ghs/controllers/StatController.php

@@ -77,7 +77,7 @@ class StatController extends BaseController
         if (getenv('YII_ENV') == 'production') {
             //小向花卉
             if ($this->mainId == 23390) {
-                if (in_array($this->adminId, [28456,31105])) {
+                if (in_array($this->adminId, [28456,31105,52528])) {
                     $hasPower = 1;
                 }
             }

+ 50 - 0
app-ghs/controllers/StockInController.php

@@ -4,6 +4,8 @@ namespace ghs\controllers;
 
 use bizGhs\order\classes\StockInOrderClass;
 use bizGhs\order\classes\StockInOrderItemClass;
+use bizGhs\product\classes\ProductClass;
+use bizGhs\shop\classes\ShopClass;
 use bizGhs\stock\classes\StockInDayClass;
 use common\components\dateUtil;
 use common\components\util;
@@ -98,6 +100,54 @@ class StockInController extends BaseController
         util::success($orderData);
     }
 
+    //获取完成入库信息和入库花材的实时库存 ssh 20250317
+    public function actionGetFullInfo()
+    {
+        $orderSn = Yii::$app->request->get('orderSn', '');
+        $in = StockInOrderClass::getByCondition(['orderSn' => $orderSn]);
+        if (empty($in)) {
+            util::fail('没有找到入库记录');
+        }
+        if ($in['inMainId'] != $this->mainId) {
+            util::fail('不是你的入库记录');
+        }
+        $outShopId = $in['outShopId'];
+        $outShop = ShopClass::getById($outShopId, true);
+        $outShopName = $outShop->shopName ?? '';
+        $in['outShopName'] = $outShopName;
+        $list = StockInOrderItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*', null, null);
+        $productInfo = [];
+        if (!empty($list)) {
+            $productIds = array_column($list, 'productId');
+            $productInfo = ProductClass::getAllByCondition(['id' => ['in', $productIds]], null, '*', 'id');
+        }
+        foreach ($list as $key => $item) {
+            $productId = $item['productId'];
+            $current = $productInfo[$productId] ?? [];
+            $currentStock = $current['stock'] ?? 0;
+            $currentStock = floatval($currentStock);
+            $list[$key]['currentStock'] = $currentStock;
+            $itemNum = $item['itemNum'] ?? 0;
+            $itemNum = floatval($itemNum);
+            $list[$key]['itemNum'] = $itemNum;
+            $itemInfo = $item['itemInfo'];
+            $itemExt = json_decode($itemInfo, true);
+            $itemName = $itemExt['itemName'] ?? '';
+            $list[$key]['itemName'] = $itemName;
+            //前端使用,勿删
+            if ($currentStock >= $itemNum) {
+                $actPutNum = $itemNum;
+            } else {
+                $actPutNum = $currentStock;
+            }
+            $list[$key]['actPutNum'] = $actPutNum;
+            $changeNum = $actPutNum - $itemNum;
+            $list[$key]['changeNum'] = $changeNum;
+        }
+        $respond = ['info' => $in, 'list' => $list];
+        util::success($respond);
+    }
+
     //确认入库 lqh 2021.1.24
     public function actionConfirmOrder()
     {

+ 44 - 10
app-ghs/controllers/StockOutController.php

@@ -17,16 +17,12 @@ class StockOutController extends BaseController
     //入库单一键出库 ssh 20231207
     public function actionOneKeyStockOut()
     {
-        $get = Yii::$app->request->get();
-        $inShopId = $get['inShopId'] ?? 0;
-        if ($inShopId == $this->shopId) {
-            util::fail('出库和入库门店一样');
-        }
-        $inShop = ShopClass::getById($inShopId, true);
-        if (empty($inShop)) {
-            util::fail('没有找到入库门店');
+        if (Yii::$app->request->isGet) {
+            $post = Yii::$app->request->get();
+        } elseif (Yii::$app->request->isPost) {
+            $post = Yii::$app->request->post();
         }
-        $orderSn = $get['orderSn'] ?? '';
+        $orderSn = $post['orderSn'] ?? '';
         $in = StockInOrderClass::getByCondition(['orderSn' => $orderSn], true);
         if (empty($in)) {
             util::fail('没有找到入库单');
@@ -34,6 +30,30 @@ class StockOutController extends BaseController
         if ($in->inMainId != $this->mainId) {
             util::fail('不是你的入库单');
         }
+
+        $inShopId = $post['inShopId'] ?? 0;
+        if ($inShopId == $this->shopId) {
+            util::fail('出库和入库门店一样');
+        }
+        $inShop = ShopClass::getById($inShopId, true);
+        if (empty($inShop)) {
+            util::fail('没有找到入库门店');
+        }
+
+        $changeList = $post['changeList'] ?? [];
+        $changeData = [];
+        if (!empty($changeList)) {
+            $changeFormatData = json_decode($changeList, true);
+            if (!empty($changeFormatData)) {
+                foreach ($changeFormatData as $k => $v) {
+                    $productId = $v['productId'];
+                    $actPutNum = $v['actPutNum'] ?? 0;
+                    $itemName = $v['itemName'] ?? '';
+                    $changeData[$productId] = ['actPutNum' => $actPutNum, 'itemName' => $itemName];
+                }
+            }
+        }
+
         $inItemList = StockInOrderItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*');
         if (empty($inItemList)) {
             util::fail('没有找到入库单的花材');
@@ -42,6 +62,16 @@ class StockOutController extends BaseController
         foreach ($inItemList as $key => $info) {
             $productId = $info['productId'] ?? 0;
             $itemNum = $info['itemNum'] ? floatval($info['itemNum']) : 0;
+            if (!empty($changeData)) {
+                if (isset($changeData[$productId])) {
+                    $changeResult = $changeData[$productId];
+                    $itemNum = $changeResult['actPutNum'];
+                    $itemName = $changeResult['itemName'];
+                    if (!is_numeric($itemNum)) {
+                        util::fail('请填写【' . $itemName . '】回调数值');
+                    }
+                }
+            }
             $itemInfo[] = ['productId' => $productId, 'bigNum' => $itemNum, 'smallNum' => 0];
         }
         $arr = [
@@ -62,8 +92,11 @@ class StockOutController extends BaseController
         $transaction = $connection->beginTransaction();
         try {
             StockOutOrderClass::addOrder($arr);
+            //回调次数+1
+            $in->callbackTime += 1;
+            $in->save();
             $transaction->commit();
-            util::complete('出库成功');
+            util::complete('操作成功');
         } catch (\Exception $exception) {
             $transaction->rollBack();
             util::fail('操作失败');
@@ -246,6 +279,7 @@ class StockOutController extends BaseController
             foreach ($ghsItemInfo as $v) {
                 $bigNum = $v['bigNum'] ?? 0;
                 $smallNum = $v['smallNum'] ?? 0;
+                $name = $v['name'] ?? '';
                 if ($bigNum <= 0 && $smallNum <= 0) {
                     util::fail('花材数量不能为0');
                 }

+ 12 - 7
app-ghs/controllers/TestController.php

@@ -345,6 +345,7 @@ class TestController extends BaseController
             //['name' => '宜宾花房里', 'merchantNo' => '82267105399041L', 'wx' => [702588640, 702570297], 'zfb' => '2088060798606945'],
             //['name' => '普莲花艺', 'merchantNo' => '8223990539902H8', 'wx' => [709291364, 709278546], 'zfb' => '2088160744835387'],
             //['name' => '凯里壹号鲜花工厂', 'merchantNo' => '82271305992000N', 'wx' => [735074420, 735074312], 'zfb' => '2088660471452939'],
+
             //['name' => '淮北花语集鲜花批发', 'merchantNo' => '82236605992000K', 'wx' => [747493528, 747494351], 'zfb' => '2088960295011854'],
             //['name' => '中山淘花里鲜花', 'merchantNo' => '82260305992004F', 'wx' => [750281744, 750282146], 'zfb' => '2088960768726142'],
             ['name' => '济南花中花', 'merchantNo' => '8224510599200DW', 'wx' => [750727543, 750727855], 'zfb' => '2088960829581057'],
@@ -352,6 +353,8 @@ class TestController extends BaseController
             ['name' => '广州天天鲜花', 'merchantNo' => '82258505992003V', 'wx' => [756889316, 756889307], 'zfb' => '2088070803130745'],
             //['name' => '平潭花天下', 'merchantNo' => '8223910599200DU', 'wx' => [742408710, 742408308], 'zfb' => '2088860472568840'],
             //['name' => '福清辉煌鲜花批发', 'merchantNo' => '8223910599200EA', 'wx' => [745744183, 745743573], 'zfb' => '2088860913726576'],
+            //['name' => '日照月下鲜花批发', 'merchantNo' => '82247705992002D', 'wx' => [759404451, 759404055], 'zfb' => '2088170264295192'],
+            ['name' => '陆丰幸运花坊', 'merchantNo' => '82259705992001N', 'wx' => [762636401,762635754 ], 'zfb' => '2088170810827880'],
             //['name' => '阜阳芳棠鲜花批发', 'merchantNo' => '82237205992002Q', 'wx' => [733203298, 733203681], 'zfb' => '2088660084283241'],
             //['name' => '厦门拾花蒲鲜花批发', 'merchantNo' => '8223930599200BH', 'wx' => [732030422, 732025011], 'zfb' => '2088560833972467'],
             //['name' => '肇庆兄弟花业鲜花批发', 'merchantNo' => '8225880599200AN', 'wx' => [731684756, 731684322], 'zfb' => '2088560782624772'],
@@ -702,7 +705,7 @@ class TestController extends BaseController
     //零售订单查询 ssh 20231031
     public function actionLsTradeQuery()
     {
-        $shopId = 520;
+
         $shop = ShopClass::getById($shopId, true);
         if (empty($shop)) {
             util::stop('没有找到门店21');
@@ -719,7 +722,7 @@ class TestController extends BaseController
         ];
         $laResource = new Lakala($params);
         $queryParams = [
-            'orderSn' => 'KD26555366',
+
             //'tradeNo' => '20231029110113130266215259252887',
         ];
         $response = $laResource->query($queryParams, 0);
@@ -831,10 +834,11 @@ class TestController extends BaseController
     //交易查询 ssh 20231021
     public function actionTradeQuery()
     {
-        $shopId = 14248;
+
         $shop = ShopClass::getById($shopId, true);
         if (empty($shop)) {
-            util::stop('没有找到门店23');
+
+            util::stop('没有找到门店,编号677230');
         }
         $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
         $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
@@ -848,10 +852,11 @@ class TestController extends BaseController
         ];
         $laResource = new Lakala($params);
         $queryParams = [
-            //'orderSn' => 'CG27765772',
-            'tradeNo' => '66221061685504',
+,
+            'orderSn' => 'CG28416364',
+            //'tradeNo' => '66221061685504',
         ];
-        $response = $laResource->query($queryParams, 1);
+        $response = $laResource->query($queryParams, 0);
         echo "<pre>";
         print_r($response);
         util::stop();

+ 2 - 5
app-ghs/controllers/WastageController.php

@@ -59,12 +59,9 @@ class WastageController extends BaseController
         foreach ($productList as $v) {
             $bigNum = $v['bigNum'] ?? 0;
             $smallNum = $v['smallNum'] ?? 0;
-            if ($bigNum <= 0) {
+            if ($bigNum <= 0 && $smallNum <= 0) {
                 util::fail('花材数量不能为0');
             }
-            if($smallNum > 0){
-                util::fail('小单位不能报损');
-            }
         }
         $connection = Yii::$app->db;
         $transaction = $connection->beginTransaction();
@@ -72,7 +69,7 @@ class WastageController extends BaseController
             //判断花材有效性
             ProductClass::valid($productList, $this->mainId);
             $post['product'] = $productList;
-            $return = StockWastageOrderClass::addOrder($post,$this->shop,true);
+            $return = StockWastageOrderClass::addOrder($post, $this->shop, true);
             $transaction->commit();
             util::success($return);
         } catch (\Exception $e) {

+ 8 - 13
app-hd/controllers/CgRefundController.php

@@ -89,19 +89,14 @@ class CgRefundController extends BaseController
         $payTime = $cg->payTime;
         $currentTime = strtotime($payTime);
         $now = time();
-        //限制12小时内可以主动申请售后
-        $changeTime = 43200;
-        if ($ghsShop->pfLevel && $ghsShop->pfLevel == 1) {
-            //昆明批发商售后时间调整为3天
-            $changeTime = bcmul(3, 86400);
-        }
-        if($ghsShopId == 26578){
-            //九江云朵48小时内可以自主售后
-            $changeTime = bcmul(2, 86400);
-        }
-        $newTime = bcadd($currentTime, $changeTime);
-        if ($now > $newTime) {
-            util::fail('超时订单,请联系门店售后');
+        $saleHour = $ghsShop->saleHour;
+        $saleHour = ceil($saleHour);
+        if ($saleHour > 0) {
+            $changeTime = $saleHour * 3600;
+            $newTime = bcadd($currentTime, $changeTime);
+            if ($now > $newTime) {
+                util::fail('超时订单,请联系门店售后');
+            }
         }
 
         $connection = Yii::$app->db;

+ 4 - 0
app-hd/controllers/ConsoleController.php

@@ -100,9 +100,13 @@ class ConsoleController extends BaseController
         //查看财务的权限
         $lookMoney = \bizGhs\shop\classes\ShopAdminClass::lookMoneyPower($this->shopAdmin, $this->shop);
 
+        $warning = '';
+        //$warning = '明天凌晨2:00~3:00,系统升级,暂停使用';
+
         util::success([
             'asset' => $this->main,
             'notice' => $notice,
+            'warning'=> $warning,
             'todayData' => ['visit' => $visitCustom, 'income' => $todaySale, 'order' => $orderNum, 'wastage' => $wastage, 'bouquet' => $hsNum],
             'incomeStat' => [],
             'menu' => $menu,

+ 51 - 0
app-hd/controllers/ItemController.php

@@ -7,6 +7,7 @@ use biz\item\classes\PtItemClass;
 
 use bizGhs\item\classes\ItemClass;
 use bizGhs\item\services\ItemService;
+use bizHd\product\classes\ProductClass;
 use common\components\dict;
 use common\components\util;
 use Yii;
@@ -14,6 +15,56 @@ use Yii;
 class ItemController extends BaseController
 {
 
+    //增加和减少半扎 ssh 20250417
+    public function actionChangeHalf()
+    {
+        util::fail('此功能已停用');
+
+        $post = Yii::$app->request->post();
+        $productId = $post['productId'] ?? '';
+        $add = $post['add'] ?? 0;
+        $remark = $post['remark'] ?? '';
+        $product = ProductClass::getLockById($productId);
+        if (empty($product)) {
+            util::fail('没有找到花材');
+        }
+        if ($product->mainId != $this->mainId) {
+            util::fail('不是你的花材');
+        }
+        if ($product->ratioType == 1) {
+            util::fail('若干扎的花材不能减半份');
+        }
+
+        //避免重复提交
+        util::checkRepeatCommit($this->adminId, 4);
+
+        $connection = Yii::$app->db;
+        $transaction = $connection->beginTransaction();
+        try {
+            $shop = $this->shop;
+            $staff = $this->shopAdmin;
+            $staffName = $staff->name ?? '';
+            $staffId = $staff->id;
+            $adminId = $this->adminId;
+            $params = [
+                'staffId' => $staffId,
+                'staffName' => $staffName,
+                'adminId' => $adminId,
+                'remark' => $remark,
+            ];
+            ItemClass::modifyHalf($shop, $product, $params, $add);
+            $product = ProductClass::getLockById($productId);
+            $stock = $product->stock;
+            $stock = floatval($stock);
+            $transaction->commit();
+            util::success(['stock' => $stock]);
+        } catch (\Exception $e) {
+            $transaction->rollBack();
+            Yii::info("加减半份失败原因:" . $e->getMessage());
+            util::fail('加减半份失败');
+        }
+    }
+
     //检测是否要刷新
     public function actionCheckRefresh()
     {

+ 2 - 0
app-hd/controllers/MainController.php

@@ -45,6 +45,8 @@ class MainController extends BaseController
         $scene = 'a=' . $this->shopAdminId . '&s=' . $this->shopId;
         $goodsImgUrl = miniUtil::generateUnlimitedMiniCode($merchant, $goodsPage, $scene, $ptStyle);
 
+        //miniUtil::generateShortLink($merchant, $ptStyle,'pages/home/recent','花美林');
+
         $flowerPage = 'pages/item/item';
         $flowerImgUrl = miniUtil::generateUnlimitedMiniCode($merchant, $flowerPage, $scene, $ptStyle);
 

+ 27 - 4
app-hd/controllers/NoticeController.php

@@ -147,7 +147,7 @@ class NoticeController extends PublicController
                     if (isset($cg->book) && $cg->book == 0) {
                         $ghsShopId = $order->shopId ?? 0;
                         if (getenv('YII_ENV') == 'production') {
-                            $specialList = [10649, 8042, 16454, 21319, 33668, 43274];
+                            $specialList = [10649, 8042, 16454, 21319, 33668];
                         } else {
                             $specialList = [36523];
                         }
@@ -222,7 +222,11 @@ class NoticeController extends PublicController
                                     $needTwoPrint = [644];
                                 }
                                 if (in_array($order->mainId, $needTwoPrint)) {
-                                    OrderClass::onlinePrint($order);
+                                    if ($order->mainId == 7538) {
+                                        OrderClass::onlinePrint($order, 0);
+                                    } else {
+                                        OrderClass::onlinePrint($order);
+                                    }
                                     $order->printNum += 1;
                                     $order->save();
                                 }
@@ -372,7 +376,7 @@ class NoticeController extends PublicController
                     if (isset($cg->book) && $cg->book == 0) {
                         $ghsShopId = $order->shopId ?? 0;
                         if (getenv('YII_ENV') == 'production') {
-                            $specialList = [10649, 8042, 16454, 21319, 33668, 43274];
+                            $specialList = [10649, 8042, 16454, 21319, 33668];
                         } else {
                             $specialList = [36523];
                         }
@@ -453,7 +457,11 @@ class NoticeController extends PublicController
                                     $needTwoPrint = [644];
                                 }
                                 if (in_array($order->mainId, $needTwoPrint)) {
-                                    OrderClass::onlinePrint($order);
+                                    if ($order->mainId == 7538) {
+                                        OrderClass::onlinePrint($order, 0);
+                                    } else {
+                                        OrderClass::onlinePrint($order);
+                                    }
                                     if (isset($ext->printSn) && !empty($ext->printSn)) {
                                         $order->printNum += 1;
                                         $order->save();
@@ -485,6 +493,21 @@ class NoticeController extends PublicController
                     }
                 }
             }
+
+            //散客下单买花,回调通知后,播报声音提示,这个方法本来不能写在这边要写在app-mall里的
+            if ($capitalType == dict::getDict('capitalType', 'xhOrder', 'id')) {
+                $cacheKey = 'hd_shop_order_pay_' . $orderSn;
+                $has = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
+                if (empty($has)) {
+                    Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 300, 'has']);
+                    $newOrder = \bizHd\order\classes\OrderClass::getByCondition(['orderSn' => $orderSn], true);
+                    if ($newOrder->onlinePay == 2) {
+                        //语音播报
+                        ShopExtClass::hdGatheringReport($newOrder);
+                    }
+                }
+            }
+
         } catch (\Exception $e) {
             $transaction->rollBack();
             Yii::error("失败原因:" . $e->getMessage());

+ 56 - 6
app-hd/controllers/OrderController.php

@@ -10,6 +10,7 @@ use bizHd\custom\classes\HdClass;
 use bizHd\goods\classes\GoodsClass;
 use bizHd\merchant\services\ShopService;
 use bizHd\order\classes\OrderClass;
+use bizHd\order\classes\OrderItemClass;
 use bizHd\order\classes\OrderSendClass;
 use bizHd\order\services\OrderService;
 use bizHd\product\classes\ProductClass;
@@ -21,6 +22,8 @@ use bizHd\work\classes\WorkClass;
 use bizHd\wx\classes\WxOpenClass;
 use common\components\dict;
 use common\components\dateUtil;
+use common\components\noticeUtil;
+use common\components\orderSn;
 use common\components\payUtil;
 use common\services\xhPayToolService;
 use Yii;
@@ -268,15 +271,53 @@ class OrderController extends BaseController
         header("Content-type: text/html; charset=utf-8");
         $get = Yii::$app->request->get();
         $id = isset($get['id']) ? $get['id'] : 0;
+        $version = $get['version'] ?? 0;
         $order = OrderClass::getById($id, true);
         OrderClass::valid($order, $this->mainId);
+
+        $shop = $this->shop;
+        $sj = $shop->merchantName;
+        $shopName = $shop->shopName;
+        $name = $shopName == '首店' ? $sj : $sj . '-' . $shopName;
+
         $authCode = (string)$get['authCode'] ?? '';
-        if (empty($authCode)) {
-            util::fail('没有获取到支付码');
-        }
+        if ($version > 0) {
+            if (empty($authCode)) {
+                $msg = '没有扫到付款码';
+                $remind = $msg . "(零售端付款码:{$authCode})" . '(' . $name . ')';
+                noticeUtil::push($remind . ' 编号005', '15280215347');
+                util::success(['returnStatus' => 'FAILURE'], $msg);
+            }
+            //微信文档说明 https://pay.weixin.qq.com/doc/v2/merchant/4011936234
+            $wxPattern = '/^(10|11|12|13|14|15)\d{16}$/';
+            //支付宝文档说明 https://opendocs.alipay.com/open/194/106039/
+            $aliPattern = '/^(25|26|27|28|29|30)\d{14,22}$/';
+            if (!preg_match($wxPattern, $authCode) && !preg_match($aliPattern, $authCode)) {
+                $msg = '付款码有问题';
+                $remind = $msg . "(零售端付款码:{$authCode})" . '(' . $name . ')';
+                noticeUtil::push($remind . ' 编号009', '15280215347');
+                util::success(['returnStatus' => 'FAILURE'], $msg);
+            }
 
+        } else {
+            if (empty($authCode)) {
+                util::fail('没有获取到支付码');
+            }
+        }
         $orderSn = $order->orderSn ?? '';
-        $subject = '购买花材';
+
+        $lsCodePayErrorKey = 'ls_code_pay_error_' . $id;
+        $hasFailPay = Yii::$app->redis->executeCommand('GET', [$lsCodePayErrorKey]);
+        //前面有付失败过,要重新生成单号
+        if (!empty($hasFailPay)) {
+            $oldOrderSn = $order->orderSn;
+            $orderSn = orderSn::getOrderSn();
+            $order->orderSn = $orderSn;
+            $order->save();
+            OrderItemClass::updateByCondition(['orderSn' => $oldOrderSn], ['orderSn' => $orderSn]);
+        }
+
+        $subject = '购买花材 ' . $orderSn;
         $totalFee = $order->mainPay ?? 0;
         $capitalType = dict::getDict('capitalType', 'xhOrder', 'id');
 
@@ -284,7 +325,6 @@ class OrderController extends BaseController
         $transaction = $connection->beginTransaction();
         try {
 
-            $shop = $this->shop;
             $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
             $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
             $params = [
@@ -342,8 +382,18 @@ class OrderController extends BaseController
 
                 util::success(['returnStatus' => 'SUCCESS']);
             } else {
+                //标记有没付成功的次数,原因有可能是余额不足等
+                Yii::$app->redis->executeCommand('SETEX', [$lsCodePayErrorKey, 1200, 'hasFail']);
+
                 $msg = $response['msg'] ?? '';
-                util::success(['returnStatus' => 'FAILURE'], $msg);
+                $retCode = $response['code'] ?? '';
+                $fullMsg = $msg . "(零售端付款码:{$authCode})" . '(' . $name . ')';
+                if ($retCode == 'BBS10000' || $retCode == 'BBS11105') {
+                    $shopId = $order->shopId;
+                    ShopExtClass::remindInputPassword($shopId);
+                }
+                noticeUtil::push($fullMsg . ' ' . $retCode . ' 编号008', '15280215347');
+                util::success(['returnStatus' => 'FAILURE', 'returnCode' => $retCode], $msg);
             }
 
         } catch (\Exception $e) {

+ 9 - 5
app-hd/controllers/ProductController.php

@@ -339,7 +339,7 @@ class ProductController extends BaseController
 
             $mainId = $shop->mainId ?? 0;
             if (!empty($mainId)) {
-                //提醒零售收银台界面要刷新
+                //提醒零售收银台界面要刷新,多处要修改,关键词 modify_price_remind_cashier
                 $staffList = ShopAdminClass::getAllByCondition(['mainId' => $mainId], null, '*', null, true);
                 if (!empty($staffList)) {
                     foreach ($staffList as $staff) {
@@ -441,11 +441,11 @@ class ProductController extends BaseController
             //根据分类组装分类下的花材信息
             $shop = ShopClass::getById($shopId, true);
             $mainId = $shop->mainId ?? 0;
-            $open = $shop->open??1;
+            $open = $shop->open ?? 1;
 
-            if($open == 0){
+            if ($open == 0) {
                 //九江云朵、丽子鲜花休店不让看花材
-                if(in_array($mainId,[26374,1496])){
+                if (in_array($mainId, [26374, 1496])) {
                     util::fail('已休店');
                 }
             }
@@ -467,7 +467,11 @@ class ProductController extends BaseController
             $myProduct = ProductClass::getAllByCondition(['mainId' => $this->mainId, 'delStatus' => 0], null, 'id,stock,onStock,stockWarning,itemId', 'itemId');
             if (!empty($itemInfoData)) {
                 $myShop = $this->shop;
-                $myDisplay = isset($myShop->pfShopId) && $myShop->pfShopId > 0 ? 1 : 0;
+                $myDisplay = 0;
+                if (isset($myShop->pfShopId) && $myShop->pfShopId > 0) {
+                    $myDisplay = 1;
+                }
+
                 foreach ($itemInfoData as $key => $val) {
                     $ptItemId = $val['itemId'] ?? 0;
                     $myStock = $myProduct[$ptItemId]['stock'] ?? 0;

+ 1 - 1
app-hd/controllers/PurchaseClearController.php

@@ -117,7 +117,6 @@ class PurchaseClearController extends BaseController
             $order->save();
             util::fail('订单已经失效,请重新发起结算');
         }
-        $name = '采购单结算';
         $totalFee = $order->actPrice;
         $openId = '';
         if (isset($post['currentMiniOpenId']) && !empty($post['currentMiniOpenId'])) {
@@ -197,6 +196,7 @@ class PurchaseClearController extends BaseController
         ];
         $laResource = new Lakala($params);
         $notifyUrl = Yii::$app->params['hdHost'] . "/notice/pay-callback";
+        $name = '采购单结算 '.$orderSn;
         $wxParams = [
             'orderSn' => $orderSn,
             'amount' => $totalFee,

+ 8 - 26
app-hd/controllers/PurchaseController.php

@@ -34,7 +34,7 @@ use common\components\qrCodeUtil;
 class PurchaseController extends BaseController
 {
 
-    public $guestAccess = ['detail', 'ali-pay', 'get-ali-pay-code'];
+    public $guestAccess = ['detail', 'ali-pay', 'get-ali-pay-code', 'wx-pay'];
 
     //获取支付宝付款码 ssh 20240713
     public function actionGetAliPayCode()
@@ -580,10 +580,9 @@ class PurchaseController extends BaseController
                             util::fail('满500元支持免费配送');
                         }
                     }
-
-                    //花悠星 国恋 勇记 易宝暂时不支持免费配送
-                    if ($ghsShopId == 7687 || $ghsShopId == 7831 || $ghsShopId == 7778 || $ghsShopId == 12003) {
-                        util::fail('暂不支持送货上门,请选其它方式');
+                    //花悠星 国恋 勇记 万丽 陆丰暂时不支持免费配送
+                    if ($ghsShopId == 7687 || $ghsShopId == 7831 || $ghsShopId == 7778 || $ghsShopId == 12003 || $ghsShopId == 38128) {
+                        util::fail('暂不支持送货上门,请选其它配送方式');
                     }
                 }
             }
@@ -693,7 +692,7 @@ class PurchaseController extends BaseController
                 if (isset($cg->book) && $cg->book == 0) {
                     $ghsShopId = $ghs['shopId'] ?? 0;
                     if (getenv('YII_ENV') == 'production') {
-                        $specialList = [10649, 8042, 16454, 21319, 33668, 43274];
+                        $specialList = [10649, 8042, 16454, 21319, 33668];
                     } else {
                         $specialList = [36523];
                     }
@@ -880,6 +879,7 @@ class PurchaseController extends BaseController
         $ghsShopId = $ghsInfo->shopId ?? 0;
         $ghsShopInfo = ShopClass::getById($ghsShopId, true);
         $info['ghsMobile'] = $ghsShopInfo->telephone ?? '';
+        $info['ghsMobile2'] = $ghsShopInfo->telephone2 ?? '';
         $info['hasRenew'] = 1;
         util::success($info);
     }
@@ -978,26 +978,17 @@ class PurchaseController extends BaseController
             }
 
             $newOrderSn = orderSn::getPurchaseSn();
-            $newGhsOrderSn = orderSn::getGhsOrderSn();
             $orderSn = $newOrderSn;
             $order->orderSn = $newOrderSn;
             $order->save();
             PurchaseItemClass::updateByCondition(['orderSn' => $oldOrderSn], ['orderSn' => $newOrderSn]);
-            $saleId = $order->saleId ?? 0;
-            $sale = OrderClass::getById($saleId, true);
-            if (!empty($sale)) {
-                $oldSaleOrderSn = $sale->orderSn ?? '';
-                $sale->orderSn = $newGhsOrderSn;
-                $sale->save();
-                OrderItemClass::updateByCondition(['orderSn' => $oldSaleOrderSn], ['orderSn' => $newGhsOrderSn]);
-            }
         }
         $order->changePrice = 2;
         $order->save();
 
         $ghsShopName = $ghsShop->shopName ?? '';
         //要带上哪个店的,这样才知道客户下的单是哪个店的,客户很多有多家店
-        $name = $ghsShopName." 花材 " . $orderSn;
+        $name = $ghsShopName . " 花材 " . $orderSn;
         $totalFee = $order->realPrice;
         $purchaseCapital = dict::getDict('capitalType', 'xhPurchase', 'id');
         $ghsId = $order->ghsId ?? 0;
@@ -1115,19 +1106,10 @@ class PurchaseController extends BaseController
             }
 
             $newOrderSn = orderSn::getPurchaseSn();
-            $newGhsOrderSn = orderSn::getGhsOrderSn();
             $orderSn = $newOrderSn;
             $order->orderSn = $newOrderSn;
             $order->save();
             PurchaseItemClass::updateByCondition(['orderSn' => $oldOrderSn], ['orderSn' => $newOrderSn]);
-            $saleId = $order->saleId ?? 0;
-            $sale = OrderClass::getById($saleId, true);
-            if (!empty($sale)) {
-                $oldSaleOrderSn = $sale->orderSn ?? '';
-                $sale->orderSn = $newGhsOrderSn;
-                $sale->save();
-                OrderItemClass::updateByCondition(['orderSn' => $oldSaleOrderSn], ['orderSn' => $newGhsOrderSn]);
-            }
         }
 
         $id = $order->id;
@@ -1136,7 +1118,7 @@ class PurchaseController extends BaseController
 
         $ghsShopName = $ghsShop->shopName ?? '';
         //要带上哪个店的,这样才知道客户下的单是哪个店的,客户很多有多家店
-        $name = $ghsShopName." 花材 " . $orderSn;
+        $name = $ghsShopName . " 花材 " . $orderSn;
         $totalFee = $order->realPrice;
         $openId = '';
         if (isset($post['currentMiniOpenId']) && !empty($post['currentMiniOpenId'])) {

+ 21 - 1
app-hd/controllers/RefundController.php

@@ -17,6 +17,25 @@ use common\components\util;
 class RefundController extends BaseController
 {
 
+    //取消的订单退钱,特殊情况的操作:商家取消订单时,客户同时付款成功了,造成的流程冲突,需要退钱 ssh 20250429
+    public function actionRefundAmount()
+    {
+        $get = Yii::$app->request->get();
+        $id = $get['id'] ?? '';
+        $order = OrderClass::getById($id, true);
+        if (empty($order)) {
+            util::fail('没有找到订单');
+        }
+        if ($order->mainId != $this->mainId) {
+            util::fail('不是你的订单');
+        }
+        $shop = $this->shop;
+        $respond = HdRefundClass::onlyRefundAmount($shop, $order);
+        $status = $respond['status'];
+        $msg = $respond['msg'];
+        util::success(['status' => $status], $msg);
+    }
+
     //列表
     public function actionList()
     {
@@ -176,7 +195,8 @@ class RefundController extends BaseController
             $orderItem = OrderItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*', null, true);
             if (!empty($orderItem)) {
                 foreach ($orderItem as $singe) {
-                    $productData[] = ['productId' => $singe->itemId, 'num' => $singe->num, 'unitPrice' => $singe->unitPrice, 'property' => 1,];
+                    $unitType = $singe->unitType;
+                    $productData[] = ['productId' => $singe->itemId, 'num' => $singe->num, 'unitPrice' => $singe->unitPrice, 'property' => 1, 'unitType' => $unitType];
                 }
             }
             $post['product'] = $productData;

+ 1 - 1
app-mall/controllers/CategoryController.php

@@ -20,7 +20,7 @@ class CategoryController extends BaseController
         //普莲花艺、叶上花、丰行、小武鲜花不能在花卉宝下单,多处要同步修改,关键词ls_mall_not_open
         $mainId = $this->mainId;
         if (getenv('YII_ENV') == 'production') {
-            if (in_array($mainId, [40057, 4750, 7779, 42940, 26374])) {
+            if (in_array($mainId, [40057, 7779, 42940, 26374])) {
                 util::fail('暂无商品哦,编号16339942');
             }
         } else {

+ 1 - 1
app-mall/controllers/ItemController.php

@@ -118,7 +118,7 @@ class ItemController extends BaseController
         //普莲花艺、叶上花、丰行、小武鲜花不能在花卉宝下单,多处要同步修改,关键词ls_mall_not_open
         $mainId = $this->mainId;
         if (getenv('YII_ENV') == 'production') {
-            if (in_array($mainId, [40057, 4750, 7779, 42940, 26374])) {
+            if (in_array($mainId, [40057, 7779, 42940, 26374])) {
                 util::fail('暂时无法访问');
             }
         } else {

+ 1 - 1
app-mall/controllers/OrderController.php

@@ -63,7 +63,7 @@ class OrderController extends BaseController
         //普莲花艺、叶上花、丰行、小武鲜花不能在花卉宝下单,多处要同步修改,关键词ls_mall_not_open
         $mainId = $this->mainId;
         if (getenv('YII_ENV') == 'production') {
-            if (in_array($mainId, [40057, 4750, 7779, 42940, 26374])) {
+            if (in_array($mainId, [40057, 7779, 42940, 26374])) {
                 util::fail('暂时无法访问');
             }
         } else {

+ 6 - 0
app-pt/controllers/WxOpenController.php

@@ -464,6 +464,12 @@ class WxOpenController extends PublicController
             }
             wxUtil::applySetOrderPathInfo($merchant, $open);
         }
+
+        //查询小程序用户隐私保护指引
+        if ($actId == 19) {
+            wxUtil::privacySettingSelect($merchant, $isOpen);
+        }
+
     }
 
     public function actionResult()

+ 14 - 3
app-pt/views/main/app.php

@@ -21,7 +21,7 @@ if ($xhbApi == 'wixhb.com') {
 <body>
 <div style="text-align:center;margin-top:100px;">
     <a style="margin:0 auto;display:inline-block;border:none;padding:8px 15px;border-radius:16px;color:white;background-color:#3385FF;text-decoration:none"
-       href="https://img.<?php echo $xhbApi; ?>/apk/ghs/1226.apk">销花宝APP</a>
+       href="https://img.<?php echo $xhbApi; ?>/apk/ghs/1230.apk">销花宝APP</a>
 </div>
 
 <div style="text-align:center;margin-top:30px;">
@@ -31,12 +31,23 @@ if ($xhbApi == 'wixhb.com') {
 <div style="text-align:center;margin-top:30px;">
     <a style="margin:0 auto;display:inline-block;border:none;padding:8px 15px;border-radius:16px;color:white;background-color:#3385FF;text-decoration:none"
 
-       href="https://img.wixhb.com/apk/hd/pad170.apk">花掌柜收银</a>
+       href="https://img.wixhb.com/apk/hd/pad171.apk">花掌柜收银</a>
 </div>
 <div style="text-align:center;margin-top:30px;">
     <a style="margin:0 auto;display:inline-block;border:none;padding:8px 15px;border-radius:16px;color:white;background-color:#3385FF;text-decoration:none"
 
-       href="https://img.wixhb.com/apk/ghs/pad134.apk">销花宝收银</a>
+       href="https://img.wixhb.com/apk/ghs/pad135.apk">销花宝收银</a>
+</div>
+<div style="width:100%;text-align:center;margin-top:20px;">-----------------------------------------------------------------</div>
+<div style="text-align:center;margin-top:30px;">
+    <a style="margin:0 auto;display:inline-block;border:none;padding:8px 15px;border-radius:16px;color:white;background-color:#3385FF;text-decoration:none"
+
+       href="https://img.wixhb.com/apk/hd/pad176.apk">花掌柜收银(最新版)</a>
+</div>
+<div style="text-align:center;margin-top:30px;">
+    <a style="margin:0 auto;display:inline-block;border:none;padding:8px 15px;border-radius:16px;color:white;background-color:#3385FF;text-decoration:none"
+
+       href="https://img.wixhb.com/apk/ghs/pad140.apk">销花宝收银(最新版)</a>
 </div>
 </body>
 </html>

+ 42 - 3
biz-ghs/clear/classes/ClearClass.php

@@ -15,9 +15,11 @@ use bizGhs\shop\classes\ShopMoneyClass;
 use bizHd\purchase\classes\PurchaseClass;
 use bizHd\purchase\classes\PurchaseClearClass;
 use common\components\dict;
+use common\components\noticeUtil;
 use common\components\orderSn;
 use common\components\util;
 use Yii;
+use common\components\lakala\Lakala;
 
 class ClearClass extends BaseClass
 {
@@ -28,6 +30,43 @@ class ClearClass extends BaseClass
     const STATUS_HAS_PAY = 2;
     const STATUS_EXPIRE = 3;
 
+    public static function refundMoney($shop, $clear)
+    {
+        $refundOrderSn = orderSn::getClearRefundSn();
+        $refundPrice = $clear->actPrice ?? 0;
+        $orderSn = $clear->orderSn ?? '';
+        $refundFee = bcmul($refundPrice, 100);
+        $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
+        $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
+        $params = [
+            'appid' => 'OP00002119',
+            'serial_no' => '018b08cfddbd',
+            'merchant_no' => $shop->lklSjNo,
+            'term_no' => $shop->lklScanTermNo,
+            'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
+            'lklCertificatePath' => $lklCertificatePath,
+        ];
+        $laResource = new Lakala($params);
+        $refundReason = '';
+        $aliParams = [
+            'refundSn' => $refundOrderSn,
+            'orderSn' => $orderSn,
+            'refundAmount' => $refundFee,
+            'refundReason' => $refundReason,
+        ];
+        $response = $laResource->refund($aliParams);
+        if (!isset($response['code']) || $response['code'] != 'BBS00000') {
+            $errMsg = $response['msg'] ?? '';
+            return ['status' => 0, 'msg' => $errMsg];
+        } else {
+            $sjName = $shop->merchantName;
+            $shopName = $shop->shopName;
+            $name = $shopName == '首店' ? $sjName : $sjName . '-' . $shopName;
+            noticeUtil::push("取消的结账单,客户的钱已原路退回 success {$orderSn} {$name}", '15280215347');
+            return ['status' => 1, 'msg' => '退款成功'];
+        }
+    }
+
     public static function addOrder($data)
     {
         $orderSn = orderSn::getPurchaseClearSn();
@@ -152,11 +191,11 @@ class ClearClass extends BaseClass
             'ptStyle' => 2,
             'capitalType' => $capitalType,
             'amount' => $order->prePrice,
-            'staffId'=>$order->customShopAdminId,
-            'staffName'=>$order->customShopAdminName,
+            'staffId' => $order->customShopAdminId,
+            'staffName' => $order->customShopAdminName,
             'balance' => $ghs->debtAmount,
             'io' => 0,
-            'event' => '采购单结账 ' .$order->orderSn ,
+            'event' => '采购单结账 ' . $order->orderSn,
             'sjId' => $order->sjId,
             'shopId' => $order->shopId,
         ];

+ 12 - 0
biz-ghs/clear/classes/ClearRefundSnClass.php

@@ -0,0 +1,12 @@
+<?php
+
+namespace bizGhs\clear\classes;
+
+use bizGhs\base\classes\BaseClass;
+
+class ClearRefundSnClass extends BaseClass
+{
+
+    public static $baseFile = '\bizGhs\clear\models\ClearRefundSn';
+
+}

+ 13 - 0
biz-ghs/clear/models/ClearRefundSn.php

@@ -0,0 +1,13 @@
+<?php
+namespace bizGhs\clear\models;
+use bizGhs\base\models\Base;
+
+class ClearRefundSn extends Base
+{
+
+    public static function tableName()
+    {
+        return 'xhClearRefundSn';
+    }
+
+}

+ 102 - 14
biz-ghs/item/classes/ItemClass.php

@@ -5,10 +5,13 @@ namespace bizGhs\item\classes;
 use biz\item\classes\PtItemCatClass;
 use biz\item\classes\PtItemCatRelateClass;
 use biz\item\classes\PtItemClass;
+use biz\shop\classes\ShopExtClass;
 use bizGhs\base\classes\BaseClass;
 use bizGhs\book\classes\BookItemClass;
+use bizGhs\order\classes\CheckOrderClass;
 use bizGhs\product\classes\ProductClass;
 use common\components\imgUtil;
+use common\components\util;
 use common\services\xhItemService;
 
 class ItemClass extends BaseClass
@@ -16,6 +19,91 @@ class ItemClass extends BaseClass
 
     public static $baseFile = '\bizGhs\item\models\Item';
 
+    public static function moveLose($outItem, $num, $shop, $params)
+    {
+        $sjId = $shop->sjId;
+        $mainId = $shop->mainId;
+        $adminId = $params['adminId'] ?? 0;
+        $staffName = $params['staffName'] ?? '';
+        $remark = $params['remark'] ?? '';
+        $shopId = $shop->id;
+        $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
+        $getItemId = $ext->losingItem ?? 0;
+        if (empty($getItemId)) {
+            util::fail('没有设置处理区花材');
+        }
+        $getItem = ItemClass::getById($getItemId, true);
+        if (empty($getItem)) {
+            util::fail('没有设置处理区花材哈');
+        }
+
+        //出口
+        $outStock = bcsub($outItem->stock, $num, 2);
+        if ($outStock < 0) {
+            util::fail('剩余' . $outItem->stock . '可挪动');
+        }
+        $outRatio = $outItem->ratio ?? 0;
+        $formNum = ProductClass::formatStock($outStock, $outRatio);
+        $ghsItemInfo = [['productId' => $outItem->id, 'bigNum' => $formNum['bigNum'], 'smallNum' => $formNum['smallNum']]];
+        $pdData = [];
+        $pdData['itemInfo'] = $ghsItemInfo;
+        $pdData['sjId'] = $sjId;
+        $pdData['shopId'] = $shopId;
+        $pdData['adminId'] = $adminId;
+        $pdData['mainId'] = $mainId;
+        $pdData['staffName'] = $staffName;
+        $pdData['remark'] = $remark;
+        CheckOrderClass::opOrder($pdData, false, false);
+
+        //进口
+        $inRatio = $getItem->ratio ?? 0;
+        $inStock = bcadd($getItem->stock, $num, 2);
+        $format = ProductClass::formatStock($inStock, $inRatio);
+        $ghsItemInfo = [['productId' => $getItem->id, 'bigNum' => $format['bigNum'], 'smallNum' => $format['smallNum']]];
+        $pdData = [];
+        $pdData['itemInfo'] = $ghsItemInfo;
+        $pdData['sjId'] = $sjId;
+        $pdData['shopId'] = $shopId;
+        $pdData['adminId'] = $adminId;
+        $pdData['mainId'] = $mainId;
+        $pdData['staffName'] = $staffName;
+        $pdData['remark'] = $remark;
+        CheckOrderClass::opOrder($pdData, false, false);
+    }
+
+    //增加和减少半扎 ssh 20250417
+    public static function modifyHalf($shop, $product, $params, $add)
+    {
+        $stock = $product->stock;
+        if ($add == 0) {
+            $newStock = bcsub($stock, 0.5, 2);
+        } else {
+            $newStock = bcadd($stock, 0.5, 2);
+        }
+        if ($newStock < 0) {
+            util::fail('库存不足');
+        }
+        $mainId = $shop->mainId;
+        $shopId = $shop->id;
+        $sjId = $shop->sjId;
+        $adminId = $params['adminId'] ?? 0;
+        $staffName = $params['staffName'] ?? '';
+        $remark = $params['remark'] ?? '';
+        $ratio = $product->ratio ?? 0;
+        $formNum = ProductClass::formatStock($newStock, $ratio);
+        $ghsItemInfo = [['productId' => $product->id, 'bigNum' => $formNum['bigNum'], 'smallNum' => $formNum['smallNum']]];
+        $pdData = [];
+        $pdData['itemInfo'] = $ghsItemInfo;
+        $pdData['sjId'] = $sjId;
+        $pdData['shopId'] = $shopId;
+        $pdData['adminId'] = $adminId;
+        $pdData['mainId'] = $mainId;
+        $pdData['staffName'] = $staffName;
+        $pdData['remark'] = $remark;
+        CheckOrderClass::opOrder($pdData, false, false);
+    }
+
+
     public static function getLoanList($where, $shop)
     {
         $bookSn = $shop->bookSn ?? 0;
@@ -25,11 +113,11 @@ class ItemClass extends BaseClass
             if (!empty($booList)) {
                 foreach ($booList as $book) {
                     $onNum = $book->onNum ?? 0;
-                    $bookNum = $book->bookNum??0;
-                    $roadNum = $book->roadNum??0;
+                    $bookNum = $book->bookNum ?? 0;
+                    $roadNum = $book->roadNum ?? 0;
                     $itemId = $book->itemId ?? 0;
-                    $needCgNum = $book->needCgNum??0;
-                    $bookData[$itemId] = ['onNum'=>$onNum,'bookNum'=>$bookNum,'roadNum'=>$roadNum,'needCgNum'=>$needCgNum];
+                    $needCgNum = $book->needCgNum ?? 0;
+                    $bookData[$itemId] = ['onNum' => $onNum, 'bookNum' => $bookNum, 'roadNum' => $roadNum, 'needCgNum' => $needCgNum];
                 }
             }
         }
@@ -52,19 +140,19 @@ class ItemClass extends BaseClass
                 $stock = $val['stock'] ?? 0;
                 $couldLoan = 0;
                 if (isset($bookData[$productId])) {
-                    $bookNum = $bookData[$productId] && $bookData[$productId]['bookNum']?$bookData[$productId]['bookNum']:0;
-                    if($bookNum>0){
-                        $roadNum = $bookData[$productId] && $bookData[$productId]['roadNum']?$bookData[$productId]['roadNum']:0;
-                        $needCgNum = $bookData[$productId] && $bookData[$productId]['needCgNum']?$bookData[$productId]['needCgNum']:0;
-                        $unReachNum = bcadd($roadNum,$needCgNum,2);
-                        $useStock = bcsub($bookNum,$unReachNum,2);
-                        if($stock>$useStock){
-                            $couldLoan = bcsub($stock,$useStock,2);
+                    $bookNum = $bookData[$productId] && $bookData[$productId]['bookNum'] ? $bookData[$productId]['bookNum'] : 0;
+                    if ($bookNum > 0) {
+                        $roadNum = $bookData[$productId] && $bookData[$productId]['roadNum'] ? $bookData[$productId]['roadNum'] : 0;
+                        $needCgNum = $bookData[$productId] && $bookData[$productId]['needCgNum'] ? $bookData[$productId]['needCgNum'] : 0;
+                        $unReachNum = bcadd($roadNum, $needCgNum, 2);
+                        $useStock = bcsub($bookNum, $unReachNum, 2);
+                        if ($stock > $useStock) {
+                            $couldLoan = bcsub($stock, $useStock, 2);
                         }
-                    }else{
+                    } else {
                         $couldLoan = $stock;
                     }
-                }else{
+                } else {
                     $couldLoan = $stock;
                 }
                 $data['list'][$key]['stock'] = $couldLoan;

+ 15 - 4
biz-ghs/order/classes/CheckOrderClass.php

@@ -13,6 +13,7 @@ use bizGhs\shop\classes\MainClass;
 use bizGhs\stock\classes\StockInDayClass;
 use bizGhs\stock\classes\StockRecordClass;
 use common\components\orderSn;
+use common\components\stringUtil;
 use common\components\util;
 use Yii;
 use bizGhs\base\classes\BaseClass;
@@ -21,6 +22,7 @@ use bizGhs\order\traits\OrderTrait;
 class CheckOrderClass extends BaseClass
 {
     use OrderTrait;
+
     public static $baseFile = '\bizGhs\order\models\CheckOrder';
     const STATUS_DRAFT = 1; //草稿
     const STATUS_COMPLETE = 2; //完成
@@ -272,14 +274,22 @@ class CheckOrderClass extends BaseClass
         $adminId = $data['adminId'] ?? 0;
         $pdType = $data['pdType'] ?? '';
         $mainId = $data['mainId'] ?? 0;
+        $remark = $data['remark'] ?? '';
+        if (!empty($remark)) {
+            $remark = stringUtil::subStringUtf8($remark, 100, '...');
+        }
 
-        //限制花大苪文员修改库存
-        if (in_array($mainId, [8164])) {
-            if (in_array($adminId, [10771, 26263, 4])) {
-                util::fail('不能修改库存数量哦');
+        //控制修改库存的权限,在这里控制 ssh 20250313
+        if (getenv('YII_ENV') == 'production') {
+            //花大苪只有三个人可以修改库存
+            if ($mainId == 8164) {
+                if (!in_array($adminId, [9273, 9303, 47576])) {
+                    util::fail('不能修改库存哦');
+                }
             }
         }
 
+
         if ($draft) {
             //保存草稿
             $data['status'] = self::STATUS_DRAFT;
@@ -354,6 +364,7 @@ class CheckOrderClass extends BaseClass
                     $record['oldStock'] = $productData['stock'];
                     $record['newStock'] = $v['itemNum'];
                     $record['targetId'] = $order->id ?? 0;
+                    $record['remark'] = $remark;
                     StockRecordClass::addCheckOrderRecord($record);
 
                     $amount = $v['amount'] ?? 0;

+ 9 - 6
biz-ghs/order/classes/OrderClass.php

@@ -1713,6 +1713,7 @@ class OrderClass extends BaseClass
         $sjId = $shop->sjId ?? 0;
         $fontSizeType = $shop->fontSize ?? 0;
         $telephone = $shop->telephone ?? '';
+        $telephone2 = $shop->telephone2 ?? '';
         $sj = SjClass::getById($sjId, true);
         $sjName = $sj->name ?? '';
         $shopName = $shop->shopName ?? '';
@@ -1837,13 +1838,12 @@ class OrderClass extends BaseClass
         $bigNum = $showItem['itemStat']['bigNum'] ?? 0;
         $smallNun = $showItem['itemStat']['smallNun'] ?? 0;
         $content .= '********************************<BR>';
-        $content .= "<CB>共{$kindNum}种";
-        $content .= " 数量:";
+        $content .= "<CB>共{$kindNum}种 ";
         if ($bigNum > 0) {
-            $content .= "{$bigNum}";
+            $content .= "{$bigNum}";
         }
         if ($smallNun > 0) {
-            $content .= "{$smallNun}";
+            $content .= "{$smallNun}";
         }
         $content .= "</CB>";
         $content .= '********************************<BR><BR>';
@@ -1885,6 +1885,9 @@ class OrderClass extends BaseClass
         if (!empty($telephone)) {
             $content .= '联系电话:' . $telephone . '<BR>';
         }
+        if (!empty($telephone2)) {
+            $content .= '联系电话2:' . $telephone2 . '<BR>';
+        }
         $content .= '订单日期:' . date("Y-m-d H:i", strtotime($getInfo['addTime'])) . '<BR>';
         $content .= '订单编号:' . $respond['orderSn'] . '<BR>';
         if (isset($orderInfo['shopAdminId']) && !empty($orderInfo['shopAdminId'])) {
@@ -1896,8 +1899,8 @@ class OrderClass extends BaseClass
         $content .= "<BR>";
 
         if (getenv('YII_ENV') == 'production') {
-            //丽子鲜花、花样年华、镜中花卉、满天星、世纪花、盛丰都不显示扫码买花
-            if (!in_array($orderInfo->shopId, [1527, 1585, 1596, 16454, 33668, 38492, 36596, 35389, 38322, 43274, 40312, 44556, 42946])) {
+            //丽子鲜花、花样年华、镜中花卉、满天星、世纪花、盛丰、福清辉煌、美阁都不显示扫码买花
+            if (!in_array($orderInfo->shopId, [1527, 1585, 1596, 16454, 33668, 38492, 36596, 35389, 38322, 43274, 40312, 44556, 42946, 51758, 8391])) {
                 //勇记、国恋、花悠星零售开单不需要打印扫码买花
                 if ($customId != 12145 || $customId != 12487 || $customId != 12281) {
                     $content .= "<BR>";

+ 2 - 3
biz-ghs/order/classes/OrderItemClass.php

@@ -393,8 +393,7 @@ class OrderItemClass extends BaseClass
             }
 
             if ($stockMayChange == true) {
-                //小单位花材开单暂时不扣库存
-                if (intval($itemNum) > 0) {
+                if ($itemNum > 0) {
                     $checkStock = true;
                     //如果是虚拟客户,说明自己也是虚拟批发店,虚拟批发店不用考虑库存
                     if ($live == 0) {
@@ -406,7 +405,7 @@ class OrderItemClass extends BaseClass
                     $recordData['shopId'] = $post['shopId'] ?? 0;
                     $recordData['mainId'] = $post['mainId'] ?? 0;
                     $recordData['itemId'] = $val['itemId'] ?? 0;
-                    $recordData['itemNum'] = intval($itemNum);
+                    $recordData['itemNum'] = $itemNum;
                     $recordData['oldStock'] = $stockInfo['oldStock'];
                     $recordData['newStock'] = $stockInfo['newStock'];
                     $recordData['productId'] = $productId;

+ 2 - 2
biz-ghs/order/classes/PurchaseOrderClass.php

@@ -473,7 +473,7 @@ class PurchaseOrderClass extends BaseClass
                 }
                 if ($orderInfo->fistWcPrintNum == 3) {
                     $printSn = $ext['wcPrintSn3'] ?? '';
-                    noticeUtil::push("使用第3台机器打印 {$printSn}", '15280215347');
+                    //noticeUtil::push("使用第3台机器打印 {$printSn}", '15280215347');
                 }
             }
         } else {
@@ -484,7 +484,7 @@ class PurchaseOrderClass extends BaseClass
                 }
                 if ($order == 3) {
                     $printSn = $ext['wcPrintSn3'] ?? '';
-                    noticeUtil::push("使用第3台机器打印 {$printSn}", '15280215347');
+                    //noticeUtil::push("使用第3台机器打印 {$printSn}", '15280215347');
                 }
             }
         }

+ 11 - 4
biz-ghs/order/classes/RefundOrderClass.php

@@ -25,6 +25,7 @@ use bizGhs\base\classes\BaseClass;
 class RefundOrderClass extends BaseClass
 {
     use OrderTrait;
+
     public static $baseFile = '\bizGhs\order\models\RefundOrder';
 
     const STATUS_UN_COMPLETE = 0; //待审核
@@ -165,11 +166,17 @@ class RefundOrderClass extends BaseClass
                     $oneItem->refundNum = bcadd($refundNum, $num);
                     $oneItem->save();
 
-                    $smallNum = 0;
-                    $bigNum = $num;
+                    if ($refundSingle->xhUnitType == 1) {
+                        $smallNum = $num;
+                        $bigNum = 0;
+                    } else {
+                        $smallNum = 0;
+                        $bigNum = $num;
+                    }
+                    $itemNum = $refundSingle->itemNum;
 
                     //大单位退款才变库存,小单位不变化库存!!
-                    if ($bigNum > 0) {
+                    if ($bigNum > 0 || $smallNum > 0) {
                         //退货加库存
                         $stockInfo = ProductClass::addStock($productId, $bigNum, $smallNum);
                         $oldStock = $stockInfo['oldStock'] ?? 0;
@@ -177,7 +184,7 @@ class RefundOrderClass extends BaseClass
                         //库存变动记录
                         $recordData = [];
                         $recordData['relateName'] = $customName;
-                        $recordData['itemNum'] = $bigNum;
+                        $recordData['itemNum'] = $itemNum;
                         $recordData['sjId'] = $sjId;
                         $recordData['shopId'] = $shopId;
                         $recordData['mainId'] = $mainId;

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

@@ -135,7 +135,7 @@ class OrderService extends BaseService
         if (!empty($cg) && !empty($order)) {
             $ghsShopId = $order->shopId ?? 0;
             if (getenv('YII_ENV') == 'production') {
-                $specialList = [10649, 8042, 16454, 21319, 33668, 43274];
+                $specialList = [10649, 8042, 16454, 21319, 33668];
             } else {
                 $specialList = [36523];
             }
@@ -318,7 +318,7 @@ class OrderService extends BaseService
             if (isset($returnOrder->book) && $returnOrder->book == 0) {
                 $ghsShopId = $ghs['shopId'] ?? 0;
                 if (getenv('YII_ENV') == 'production') {
-                    $specialList = [10649, 8042, 16454, 21319, 33668, 43274];
+                    $specialList = [10649, 8042, 16454, 21319, 33668];
                 } else {
                     $specialList = [36523];
                 }

+ 0 - 10
biz-ghs/order/services/RefundOrderService.php

@@ -96,16 +96,6 @@ class RefundOrderService extends BaseService
             }
         }
 
-        $orderSn = $refund->orderSn;
-        $refundItemList = RefundOrderItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*', null, true);
-        if (!empty($refundItemList)) {
-            foreach ($refundItemList as $refundInfo) {
-                if ($refundInfo->xhUnitType == 1) {
-                    util::fail($refundInfo->name . ' 是小单位,只能使用【只退款】方式');
-                }
-            }
-        }
-
         $relateOrderSn = $refund->relateOrderSn ?? '';
         if (empty($relateOrderSn)) {
             util::fail('没有订单信息');

+ 28 - 8
biz-ghs/product/classes/ProductClass.php

@@ -850,7 +850,7 @@ class ProductClass extends BaseClass
     public static function addStock($productId, $itemNumBundle, $itemNumPiece)
     {
         //小单位库存不再考虑 ssh 20230303
-        $itemNumPiece = 0;
+        //$itemNumPiece = 0;
 
         $key = self::LOCK_STOCK . '_' . $productId;
         $lock = util::lock($key);
@@ -880,7 +880,6 @@ class ProductClass extends BaseClass
     //加路上库存
     public static function addOnStockByItemNum($productId, $itemNum)
     {
-        //小单位库存不再考虑 ssh 20230303
         $key = self::LOCK_ON_STOCK . '_' . $productId;
         $lock = util::lock($key);
         if (!$lock) {
@@ -933,7 +932,7 @@ class ProductClass extends BaseClass
     {
 
         //小单位库存不再考虑 ssh 20230303
-        $itemNumPiece = 0;
+        //$itemNumPiece = 0;
 
         $key = self::LOCK_STOCK . '_' . $productId;
         $lock = util::lock($key);
@@ -1523,9 +1522,12 @@ class ProductClass extends BaseClass
         }
         $cost = $data['cost'] ?? 0;
         $price = $data['price'] ?? 0;
+        $price = floatval($price);
         $skPrice = $data['skPrice'] ?? 0;
+        $skPrice = floatval($skPrice);
         $hjPrice = $data['hjPrice'] ?? 0;
-        if (is_numeric($price) == false || $price <= 0) {
+        $hjPrice = floatval($hjPrice);
+        if (!is_numeric($price) || $price <= 0) {
             util::fail('请填写价格');
         }
         if ($hjPrice > $price) {
@@ -1545,7 +1547,12 @@ class ProductClass extends BaseClass
         }
         if (floatval($price) != floatval($product->price) || floatval($skPrice) != floatval($product->skPrice) || floatval($hjPrice) != floatval($product->hjPrice)) {
             if ($shop->default == 0 && $shop->join == 0) {
-                util::fail('直营分店不能改价');
+
+                //除了小蔡鲜花的蔡总、郑总,其他人直营分店不能改价格,多处要同步修改,关键词d_price_change
+                if (!in_array($adminId, [35725, 23659])) {
+                    util::fail('直营店不能改价哦');
+                }
+
             }
         }
         if (isset($data['limitBuy']) && is_numeric($data['limitBuy'])) {
@@ -1646,12 +1653,25 @@ class ProductClass extends BaseClass
         $staffName = $data['staffName'] ?? '';
         $changeParams = ['staffId' => $staffId, 'staffName' => $staffName];
 
-        if ($price != $product->price || $skPrice != $product->skPrice || $hjPrice != $product->hjPrice) {
-            //批发价有变化
+        if ($price != floatval($product->price) || $skPrice != floatval($product->skPrice) || $hjPrice != floatval($product->hjPrice)) {
+
             self::changeSinglePrice($shop, $ptItemId, $price, $skPrice, $hjPrice, $changeParams);
             unset($upData['price']);
             unset($upData['skPrice']);
             unset($upData['hjPrice']);
+
+            if (!empty($mainId)) {
+                //提醒零售收银台界面要刷新,多处要修改,关键词 modify_price_remind_cashier
+                $staffList = ShopAdminClass::getAllByCondition(['mainId' => $mainId], null, '*', null, true);
+                if (!empty($staffList)) {
+                    foreach ($staffList as $staff) {
+                        $staffId = $staff->id ?? 0;
+                        Yii::$app->redis->executeCommand('SET', ['cashier_' . $mainId . '_' . $staffId . '_may_refresh', 'yes']);
+                        Yii::$app->redis->executeCommand('SET', ['ghs_cashier_' . $mainId . '_' . $staffId . '_may_refresh', 'yes']);
+                    }
+                }
+            }
+
         }
 
         if ($cost != $product->cost) {
@@ -1975,7 +1995,7 @@ class ProductClass extends BaseClass
     //补className
     public static function groupClassName($mainId, $data)
     {
-        $classNameMap = ItemClassClass::getAllByCondition(['mainId'=>$mainId],null,'id,name','id');
+        $classNameMap = ItemClassClass::getAllByCondition(['mainId' => $mainId], null, 'id,name', 'id');
         foreach ($data as $k => $v) {
             $classId = $v['classId'];
             $className = isset($classNameMap[$classId]) && isset($classNameMap[$classId]['name']) ? $classNameMap[$classId]['name'] : '';

+ 27 - 22
biz-ghs/product/services/ProductService.php

@@ -243,7 +243,7 @@ class ProductService extends BaseService
         return $data;
     }
 
-    //生成价格表 ssh 20210922
+    //下载所有花材的库存 ssh 20250328
     public static function generateItemTable($sjId, $level, $mainId = 0)
     {
         $status = 1;
@@ -253,20 +253,15 @@ class ProductService extends BaseService
         //中央ID
         $classIds = ItemClassClass::getGhsItemClassAll($mainId);
 
-        $all = Yii::$app->request->get('all', 0);
-
         $where['mainId'] = $mainId;
-        $allName = $all == 0 ? '' : 'all';
-        if ($all == 0) {
-            $where['status'] = $status;
-        }
+        $where['status'] = $status;
         $where['delStatus'] = 0;
 
         $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], "*");
         $itemInfoData = ProductClass::groupProductInfo($itemInfoData, $level);
-
         $respond = self::assembleData($classIds, $itemInfoData, true);
         $data = $respond['classItem'] ?? [];
+
         $formatData = [];
 
         foreach ($data as $key => $class) {
@@ -275,14 +270,15 @@ class ProductService extends BaseService
                 continue;
             }
             $name = $class['className'] ?? '';
-            $formatData[] = ['name' => $name, 'price' => ''];
+            $formatData[] = ['name' => $name, 'price' => '', 'type' => 'className'];
             if (isset($class['child']) && !empty($class['child'])) {
                 foreach ($class['child'] as $cKey => $child) {
                     $cName = $child['name'] ?? '';
-                    $price = $child['price'] ?? '';
+                    $stock = $child['stock'] ?? '';
                     $formatData[] = [
                         'name' => $cName,
-                        'price' => $price,
+                        'price' => $stock,
+                        'type' => 'item',
                     ];
                 }
             }
@@ -307,9 +303,6 @@ class ProductService extends BaseService
         //$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader(date('n月j日') . " " . $levelName . "客户");
         //$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader(date('n月j日') . " 编号 " . $level);
         $topLevelName = $levelName;
-        if ($level == CustomClass::LEVEL_SK) {
-            $topLevelName = '';
-        }
         $objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader(date('n月j日') . " " . $topLevelName);
 
         $objPHPExcel->getActiveSheet()->getPageMargins()->setTop(0.7);
@@ -321,8 +314,7 @@ class ProductService extends BaseService
 
         $i = 1;
         $letter = [1 => ['A', 'B'], 2 => ['C', 'D'], 3 => ['E', 'F'], 4 => ['G', 'H'], 5 => ['I', 'J'], 6 => ['K', 'L'], 7 => ['M', 'N'],
-            8 => ['O', 'P'], 9 => ['Q', 'R'], 10 => ['S', 'T'], 11 => ['U', 'V'], 12 => ['w', 'x'], 13 => ['y', 'z'],
-            14 => ['AA', 'AB'], 15 => ['AC', 'AD'], 16 => ['AE', 'AF'], 17 => ['AG', 'AH'], 18 => ['AI', 'AJ']];
+            8 => ['O', 'P'], 9 => ['Q', 'R'], 10 => ['S', 'T'], 11 => ['U', 'V']];
         $lastCell = '';
         //最大行
         $max = 50;
@@ -349,8 +341,20 @@ class ProductService extends BaseService
                 $objPHPExcel->getActiveSheet()->getStyle($before . $x)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
                 //垂直居中
                 $objPHPExcel->getActiveSheet()->getStyle($before . $x)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
+            } else if (isset($product['type']) && $product['type'] == 'reach') {
+                $objPHPExcel->getActiveSheet()->setCellValue($before . $x, $product['name'])->setCellValue($after . $x, $product['price']);
+                //字体大小 加粗
+                $objPHPExcel->getActiveSheet()->getStyle($before . $x)->getFont()->setSize(9)->setBold(true);
+                //红色
+                $objPHPExcel->getActiveSheet()->getStyle($before . $x)->getFont()->getColor()->setARGB(\PHPExcel_Style_Color::COLOR_RED);
+                //垂直居中
+                $objPHPExcel->getActiveSheet()->getStyle($before . $x)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
+                //字体大小 加粗
+                $objPHPExcel->getActiveSheet()->getStyle($after . $x)->getFont()->setSize(11)->setBold(true);
+                //红色
+                $objPHPExcel->getActiveSheet()->getStyle($after . $x)->getFont()->getColor()->setARGB(\PHPExcel_Style_Color::COLOR_RED);
             } else {
-                $objPHPExcel->getActiveSheet()->setCellValue($before . $x, $product['name'])->setCellValue($after . $x, '');
+                $objPHPExcel->getActiveSheet()->setCellValue($before . $x, $product['name'])->setCellValue($after . $x, $product['price']);
                 //字体大小
                 $objPHPExcel->getActiveSheet()->getStyle($before . $x)->getFont()->setSize(9);
                 //垂直居中
@@ -371,9 +375,9 @@ class ProductService extends BaseService
         if (file_exists($dir) == false) {
             mkdir($dir, 0777, true);
         }
-        $date = date("m-d");
+        $date = date("H");
 
-        $file = $date . '-hua' . $allName . '.xls';
+        $file = $date . '_stock.xls';
         $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
 
         if (file_exists($dir . '/' . $file)) {
@@ -415,6 +419,7 @@ class ProductService extends BaseService
             if (isset($class['child']) && !empty($class['child'])) {
                 foreach ($class['child'] as $cKey => $child) {
                     $cName = $child['name'] ?? '';
+                    $cName = trim($cName);
                     $price = $child['price'] ?? '';
                     $formatData[] = [
                         'name' => $cName,
@@ -488,7 +493,7 @@ class ProductService extends BaseService
 
             if (isset($product['price']) == false || empty($product['price'])) {
                 //没有价格的合并单元格
-                $objPHPExcel->getActiveSheet()->mergeCells("{$before}{$x}:{$after}{$x}")->setCellValue($before . $x, $product['name']);
+                $objPHPExcel->getActiveSheet()->mergeCells("{$before}{$x}:{$after}{$x}")->setCellValue($before . $x, trim($product['name']));
                 //加粗
                 $objPHPExcel->getActiveSheet()->getStyle($before . $x)->getFont()->setSize(9)->setBold(true);
                 $objPHPExcel->getActiveSheet()->getStyle($before . $x)->getFont()->setName('微软雅黑');
@@ -497,7 +502,7 @@ class ProductService extends BaseService
                 //垂直居中
                 $objPHPExcel->getActiveSheet()->getStyle($before . $x)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
             } else if (isset($product['type']) && $product['type'] == 'reach') {
-                $objPHPExcel->getActiveSheet()->setCellValue($before . $x, $product['name'])->setCellValue($after . $x, $product['price']);
+                $objPHPExcel->getActiveSheet()->setCellValue($before . $x, trim($product['name']))->setCellValue($after . $x, $product['price']);
                 //字体大小 加粗
                 $objPHPExcel->getActiveSheet()->getStyle($before . $x)->getFont()->setSize(9)->setBold(true);
                 //红色
@@ -509,7 +514,7 @@ class ProductService extends BaseService
                 //红色
                 $objPHPExcel->getActiveSheet()->getStyle($after . $x)->getFont()->getColor()->setARGB(\PHPExcel_Style_Color::COLOR_RED);
             } else {
-                $objPHPExcel->getActiveSheet()->setCellValue($before . $x, $product['name'])->setCellValue($after . $x, $product['price']);
+                $objPHPExcel->getActiveSheet()->setCellValue($before . $x, trim($product['name']))->setCellValue($after . $x, $product['price']);
                 //字体大小
                 $objPHPExcel->getActiveSheet()->getStyle($before . $x)->getFont()->setSize(9);
                 //垂直居中

+ 31 - 0
biz-ghs/shop/classes/ShopAdminClass.php

@@ -5,6 +5,7 @@ namespace bizGhs\shop\classes;
 
 use biz\admin\classes\AdminClass;
 use bizGhs\admin\classes\AdminRoleClass;
+use bizGhs\product\classes\ProductClass;
 use common\components\dict;
 use common\components\sms;
 use common\components\util;
@@ -16,6 +17,36 @@ class ShopAdminClass extends BaseClass
 
     public static $baseFile = '\bizGhs\shop\models\ShopAdmin';
 
+
+    public static function changeWeightRight($adminId, $ptItemId)
+    {
+        //判断这个花材能否被修改单位比和重量,同步参考ShopController actionMyShop方法,关键词has_right_shop_list
+        //判断当前登录的人,在自己有财务权限的main里面,是否包括了这个花材所属的平台id,在这个平台id下所有花材的main
+        $staffList = ShopAdminClass::getAllByCondition(['adminId' => $adminId], null, '*', null, true);
+        $hasMainList = [];
+        $mayList = [];
+        if (!empty($staffList)) {
+            foreach ($staffList as $staff) {
+                $mayList[] = $staff->mainId;
+                if ($staff->super == 1) {
+                    $hasMainList[] = $staff->mainId;
+                }
+            }
+        }
+        $sameList = ProductClass::getAllByCondition(['itemId' => $ptItemId], null, 'id,itemId,mainId');
+        $sameMainList = array_column($sameList, 'mainId');
+        $hasNot = array_diff($sameMainList, $hasMainList);
+        $hasRightChange = empty($hasNot) ? 1 : 0;
+
+        $mayHasNot = array_diff($sameMainList, $mayList);
+        $reason = '别的批发店也在用此花材,不能修改';
+        if (empty($mayHasNot)) {
+            $reason = '你在某个店没有改库存改价,不能修改';
+        }
+
+        return ['hasRightChange' => $hasRightChange, 'reason' => $reason];
+    }
+
     const GENERATE_ADMIN_DATA = 'generate_ghs_admin_data_';//创建管理员需要的数据
 
     //查看财务权限 ssh 20230620

+ 53 - 5
biz-hd/cg/classes/CgRefundClass.php

@@ -3,6 +3,7 @@
 namespace bizHd\cg\classes;
 
 use biz\shop\classes\ShopCapitalClass;
+use biz\shop\classes\ShopExtClass;
 use bizHd\ghs\classes\GhsClass;
 use bizHd\purchase\classes\PurchaseClass;
 use bizHd\purchase\classes\PurchaseItemClass;
@@ -35,6 +36,46 @@ class CgRefundClass extends BaseClass
     const REFUND_TYPE_MONEY_GOOD = 1; //退款退货
     const REFUND_TYPE_MONEY = 2; // 仅退款
 
+    public static function onlyRefundMoney($ghsShop, $cg)
+    {
+        $refundOrderSn = orderSn::getCgRefundSn();
+        $refundPrice = $cg->actPrice ?? 0;
+        $orderSn = $cg->orderSn ?? '';
+        $refundFee = bcmul($refundPrice, 100);
+        $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
+        $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
+        $params = [
+            'appid' => 'OP00002119',
+            'serial_no' => '018b08cfddbd',
+            'merchant_no' => $ghsShop->lklSjNo,
+            'term_no' => $ghsShop->lklScanTermNo,
+            'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
+            'lklCertificatePath' => $lklCertificatePath,
+        ];
+        $laResource = new Lakala($params);
+        $refundReason = '';
+        $aliParams = [
+            'refundSn' => $refundOrderSn,
+            'orderSn' => $orderSn,
+            'refundAmount' => $refundFee,
+            'refundReason' => $refundReason,
+        ];
+        $response = $laResource->refund($aliParams);
+        if (!isset($response['code']) || $response['code'] != 'BBS00000') {
+            $errMsg = $response['msg'] ?? '';
+            return ['status' => 0, 'msg' => $errMsg];
+        } else {
+            $ghsShopId = $ghsShop->id;
+            ShopExtClass::orderCancelBackMoneyReport($ghsShopId);
+            $sjName = $ghsShop->merchantName;
+            $shopName = $ghsShop->shopName;
+            $name = $shopName == '首店' ? $sjName : $sjName . '-' . $shopName;
+            noticeUtil::push("订单取消,客户还付款成功,钱已经原路退回 success {$orderSn} {$name}", '15280215347');
+            return ['status' => 1, 'msg' => '退款成功'];
+        }
+    }
+
+
     //审核通过 ssh 20230811
     public static function passRefund($cgRefund, $cg)
     {
@@ -115,16 +156,23 @@ class CgRefundClass extends BaseClass
                     }
                     $oneItem->refundNum = bcadd($refundNum, $num);
                     $oneItem->save();
-                    //大单位退款才变库存,小单位不变化库存!!
-                    $smallNum = 0;
-                    $bigNum = $num;
-                    if ($bigNum > 0) {
+
+                    if ($refundSingle->xhUnitType == 1) {
+                        $smallNum = $num;
+                        $bigNum = 0;
+                    } else {
+                        $smallNum = 0;
+                        $bigNum = $num;
+                    }
+                    $itemNum = $refundSingle->itemNum;
+
+                    if ($bigNum > 0 || $smallNum > 0) {
                         $stockInfo = ProductClass::decreaseStock($productId, $bigNum, $smallNum);
                         $oldStock = $stockInfo['oldStock'] ?? 0;
                         $newStock = $stockInfo['newStock'] ?? 0;
 
                         $recordData = [];
-                        $recordData['itemNum'] = $bigNum;
+                        $recordData['itemNum'] = $itemNum;
                         $recordData['sjId'] = $sjId;
                         $recordData['shopId'] = $shopId;
                         $recordData['mainId'] = $mainId;

+ 6 - 0
biz-hd/cg/services/CgRefundService.php

@@ -212,6 +212,11 @@ class CgRefundService extends BaseService
                 $currentPrice = bcmul($num,$unitPrice,2);
                 $originPrice = bcadd($originPrice,$currentPrice,2);
 
+                $itemNum = $num;
+                if ($unitType == dict::getDict('unitType', 'small')) {
+                    $itemNum = bcdiv($num, $ratio, 2);
+                }
+
                 $refundData = [];
                 $refundData['orderSn'] = $refundOrderSn;
                 $refundData['itemId'] = $ptItemId;
@@ -224,6 +229,7 @@ class CgRefundService extends BaseService
                 $refundData['shopId'] = $shopId;
                 $refundData['sjId'] = $sjId;
                 $refundData['xhNum'] = $num;
+                $refundData['itemNum'] = $itemNum;
                 $refundData['xhUnitName'] = $unitName;
                 $refundData['xhUnitType'] = $unitType;
                 $refundData['xhUnitPrice'] = $unitPrice;

+ 11 - 7
biz-hd/order/classes/OrderClass.php

@@ -20,6 +20,7 @@ use bizGhs\stock\classes\StockRecordClass;
 use bizGhs\ws\services\WsService;
 use bizHd\custom\classes\CustomClass;
 use bizHd\merchant\classes\SjClass;
+use bizHd\refund\classes\HdRefundClass;
 use bizHd\shop\classes\MainClass;
 use bizHd\shop\classes\ShopMoneyChangeClass;
 use bizHd\stat\classes\StatIncomeClass;
@@ -260,11 +261,16 @@ class OrderClass extends BaseClass
         }
         $orderSn = $order->orderSn ?? '';
         if ($order->status == self::ORDER_STATUS_CANCEL) {
-            noticeUtil::push('特别注意,零售订单:' . $orderSn . ',付款成功但订单是取消状态', '15280215347');
-            util::fail('订单已取消');
+            $shopId = $order->shopId;
+            $shop = ShopClass::getById($shopId, true);
+            if (!empty($shop)) {
+                HdRefundClass::onlyRefundAmount($shop, $order);
+            }
+            noticeUtil::push('注意,散客订单:' . $orderSn . ',付款成功但订单已取消,关键词 cancel_get_money', '15280215347');
+            util::stop("SUCCESS");
         }
         if ($order->payStatus == 1) {
-            noticeUtil::push('特别注意,零售订单:' . $orderSn . ',已经付过款了,无需重复请求和操作', '15280215347');
+            noticeUtil::push('注意散客订单:' . $orderSn . ',已经付过款了,无需重复请求和操作', '15280215347');
             util::fail('订单已经付过款了');
         }
 
@@ -447,18 +453,17 @@ class OrderClass extends BaseClass
         $itemList = OrderItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*', null, true);
         if (!empty($itemList)) {
             foreach ($itemList as $item) {
-
                 $ptItemId = $item->ptItemId ?? 0;
                 $sjId = $item->sjId ?? 0;
                 $shopId = $item->shopId ?? 0;
                 $mainId = $item->mainId ?? 0;
                 $ratio = $item->ratio ?? 20;
                 $unitType = $item->unitType ?? 0;
-                $bigNum = 0;
-                $smallNum = 0;
                 if ($unitType == 0) {
                     $bigNum = $item->num;
+                    $smallNum = 0;
                 } else {
+                    $bigNum = 0;
                     $smallNum = $item->num;
                 }
                 $itemId = $item->itemId ?? 0;
@@ -475,7 +480,6 @@ class OrderClass extends BaseClass
                 $recordData['orderSn'] = $orderSn;
                 $recordData['relateName'] = '系统';
                 StockRecordClass::addSellStockOrderCancelRecord($recordData);
-
             }
         }
         $shopId = $order->shopId ?? 0;

+ 1 - 2
biz-hd/order/classes/OrderItemClass.php

@@ -39,8 +39,7 @@ class OrderItemClass extends BaseClass
 
         //库存减少
         $itemNum = ProductClass::mergeItemNum($bigNum, $smallNum, $ratio);
-        //开单时如果是小单位暂时不扣库存
-        if (intval($itemNum) > 0) {
+        if ($itemNum > 0) {
             $stockInfo = ProductClass::decreaseStock($itemId, $bigNum, $smallNum, true);
             $recordData = [];
             $recordData['sjId'] = $sjId;

+ 1 - 1
biz-hd/purchase/classes/PurchaseClass.php

@@ -205,7 +205,7 @@ class PurchaseClass extends BaseClass
         $purchaseItem = PurchaseItemClass::getAllByCondition(['orderSn' => $orderSn], null, "*");
         foreach ($purchaseItem as $v) {
             //小单位库存不考虑入库 ssh 202310
-            $itemNum = intval($v['itemNum']);
+            $itemNum = $v['itemNum'];
             if ($itemNum > 0) {
                 $productId = $v['productId'];
                 $stockInfo = ProductClass::addStockByItemNum($v['productId'], $itemNum);

+ 9 - 2
biz-hd/purchase/classes/PurchaseClearClass.php

@@ -6,6 +6,7 @@ use biz\ghs\classes\GhsClass;
 use biz\shop\classes\ShopClass;
 use biz\shop\classes\ShopYeChangeClass;
 use biz\wx\classes\WxMessageClass;
+use bizGhs\clear\classes\ClearClass;
 use bizGhs\custom\classes\CustomClass;
 use bizGhs\order\classes\OrderClass;
 use bizHd\base\classes\BaseClass;
@@ -132,9 +133,15 @@ class PurchaseClearClass extends BaseClass
             if ($order->onlinePay == dict::getDict('onlinePay', 'yes')) {
                 $ghsName = $order->ghsName ?? '';
                 $customName = $order->customName ?? '';
-                $id = $order->id ?? 0;
                 $orderSn = $order->orderSn ?? '';
-                noticeUtil::push("重要提醒:有花店客户线上结账,但结账单却取消了 供货商:{$ghsName} 客户:{$customName} 订单编号:{$orderSn}", '15280215347');
+                noticeUtil::push("花店线上付款结账,但结账单是取消状态。供货商:{$ghsName},客户:{$customName},订单编号:{$orderSn}", '15280215347');
+                $ghsShopId = $order->ghsShopId;
+                $shop = ShopClass::getById($ghsShopId, true);
+                if (!empty($shop)) {
+                    //原路退回给客户
+                    ClearClass::refundMoney($shop, $order);
+                }
+                util::stop("SUCCESS");
             }
         }
         if (isset($order->status) == false || $order->status != self::STATUS_AWAIT_PAY) {

+ 13 - 5
biz-hd/purchase/services/PurchaseService.php

@@ -20,6 +20,7 @@ use bizGhs\stock\classes\StockRecordClass;
 use bizGhs\ws\services\WsService;
 use bizHd\admin\classes\ShopAdminClass;
 use bizHd\base\services\BaseService;
+use bizHd\cg\classes\CgRefundClass;
 use bizHd\purchase\classes\PurchaseClass;
 use bizHd\purchase\classes\PurchaseItemClass;
 use bizHd\shop\classes\MainClass;
@@ -280,7 +281,7 @@ class PurchaseService extends BaseService
     {
         $info = self::getByCondition(['orderSn' => $orderSn], true);
         if (empty($info)) {
-            noticeUtil::push('花店采购,付款成功,支付回调,单号:' . $orderSn . ',没有找到订单 '.$attach, '15280215347');
+            noticeUtil::push('花店采购,付款成功,支付回调,单号:' . $orderSn . ',没有找到订单 ' . $attach, '15280215347');
             $msg = "没有找到订单 orderSn:{$orderSn}";
             Yii::info($msg);
             util::fail($msg);
@@ -331,13 +332,20 @@ class PurchaseService extends BaseService
             util::fail('没有找到订单状态');
         }
         if ($info->status == PurchaseClass::STATUS_CANCEL) {
-            noticeUtil::push('重点注意,采购单:' . $orderSn . ',客户付钱了但订单取消状态', '15280215347');
-            sms::send('15280215347,' . $orderSn, '重点注意,采购单:{$var},客户付钱了但订单取消状态');
-            util::fail('订单已取消');
+            noticeUtil::push('注意花店采购单:' . $orderSn . ',客户付款了但订单已取消,关键词 cancel_get_money', '15280215347');
+            $saleId = $info->saleId;
+            $sale = OrderClass::getById($saleId, true);
+            if (!empty($sale)) {
+                $ghsShopId = $sale->shopId;
+                $ghsShop = ShopClass::getById($ghsShopId, true);
+                if (!empty($ghsShop)) {
+                    CgRefundClass::onlyRefundMoney($ghsShop, $info);
+                }
+            }
+            util::stop("SUCCESS");
         }
 
         if (isset($info->payStatus) && $info->payStatus == 1) {
-            //noticeUtil::push('重点注意,采购单:' . $orderSn . ',已经付过款了,重复请求', '15280215347');
             util::fail('订单已经付过款了');
         }
 

+ 43 - 0
biz-hd/refund/classes/HdRefundClass.php

@@ -2,8 +2,12 @@
 
 namespace bizHd\refund\classes;
 
+use biz\shop\classes\ShopExtClass;
+use common\components\noticeUtil;
+use common\components\orderSn;
 use Yii;
 use bizHd\base\classes\BaseClass;
+use common\components\lakala\Lakala;
 
 class HdRefundClass extends BaseClass
 {
@@ -16,6 +20,45 @@ class HdRefundClass extends BaseClass
     const STATUS_UN_COMPLETE = 0; //退款处理中
     const STATUS_COMPLETE = 1; //已完成
 
+    public static function onlyRefundAmount($shop, $order)
+    {
+        $refundSn = orderSn::getHdRefundSn();
+        $xsOrderSn = $order->orderSn ?? '';
+        $refundPrice = $order->actPrice ?? 0;
+        $refundFee = bcmul($refundPrice, 100);
+        $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
+        $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
+        $params = [
+            'appid' => 'OP00002119',
+            'serial_no' => '018b08cfddbd',
+            'merchant_no' => $shop->lklSjNo,
+            'term_no' => $shop->lklScanTermNo,
+            'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
+            'lklCertificatePath' => $lklCertificatePath,
+        ];
+        $laResource = new Lakala($params);
+        $refundReason = '';
+        $aliParams = [
+            'refundSn' => $refundSn,
+            'orderSn' => $xsOrderSn,
+            'refundAmount' => $refundFee,
+            'refundReason' => $refundReason,
+        ];
+        $response = $laResource->refund($aliParams);
+        if (!isset($response['code']) || $response['code'] != 'BBS00000') {
+            $errMsg = $response['msg'] ?? '';
+            return ['status' => 0, 'msg' => $errMsg];
+        } else {
+            $shopId = $shop->id;
+            ShopExtClass::orderCancelBackMoneyReport($shopId);
+            $sjName = $shop->merchantName;
+            $shopName = $shop->shopName;
+            $name = $shopName == '首店' ? $sjName : $sjName . '-' . $shopName;
+            noticeUtil::push("零售订单取消,客户还付款成功,钱已经原路退回 success {$xsOrderSn} {$name}", '15280215347');
+            return ['status' => 1, 'msg' => '退款成功'];
+        }
+    }
+
     // 订单列表
     public static function getOrderList($where)
     {

+ 8 - 5
biz-hd/refund/classes/HdRefundItemClass.php

@@ -24,16 +24,20 @@ class HdRefundItemClass extends BaseClass
         $itemId = $data['itemId'] ?? 0;
         $num = $data['num'] ?? 0;
         $unitType = $data['unitType'] ?? 0;
-        $bigNum = $unitType == 0 ? $num : 0;
-        $smallNum = $unitType == 1 ? $num : 0;
         $ratio = $data['ratio'] ?? 0;
         $ptItemId = $data['ptItemId'] ?? 0;
         $mainId = $data['mainId'] ?? 0;
         $shopId = $data['shopId'] ?? 0;
         $sjId = $data['sjId'] ?? 0;
         $shopAdminName = $post['shopAdminName'] ?? '';
-
-        if ($bigNum > 0) {
+        if ($unitType == 1) {
+            $bigNum = 0;
+            $smallNum = $num;
+        } else {
+            $bigNum = $num;
+            $smallNum = 0;
+        }
+        if ($bigNum > 0 || $smallNum > 0) {
             $stockInfo = ProductClass::addStock($itemId, $bigNum, $smallNum);
             $recordData = [];
             $recordData['sjId'] = $sjId;
@@ -48,7 +52,6 @@ class HdRefundItemClass extends BaseClass
             $recordData['relateName'] = $shopAdminName;
             StockRecordClass::hdRefundAddRecord($recordData);
         }
-
         return self::add($data);
     }
 

+ 3 - 0
biz/ghs/classes/GhsClass.php

@@ -252,6 +252,9 @@ class GhsClass extends BaseClass
             $telephone = $currentShop['telephone'] ?? '';
             $list[$key]['telephone'] = $telephone;
 
+            $telephone2 = $currentShop['telephone2'] ?? '';
+            $list[$key]['telephone2'] = $telephone2;
+
             $balance = $val['balance']??0;
             $debtAmount = $val['debtAmount'] ?? 0;
             $remainDebtAmount = bcsub($debtAmount, $balance, 2);

+ 2 - 8
biz/shop/classes/ShopClass.php

@@ -152,8 +152,6 @@ class ShopClass extends BaseClass
         $sjName = $shop['merchantName'] ?? '';
         //默认门店只显示商家名称即可
         $name = $default == 1 && $shopName == '首店' ? $sjName : $sjName . ' ' . $shopName;
-        $needCheck = isset($data['needCheck']) ? $data['needCheck'] : 0;
-        $passStatus = $needCheck == 1 ? 0 : 1;
         $shopUpdate = [
             'name' => $name,
             'mobile' => $data['mobile'] ?? '',
@@ -165,14 +163,10 @@ class ShopClass extends BaseClass
             'fullAddress' => $data['fullAddress'] ?? '',
             'showAddress' => $data['showAddress'] ?? '',
             'lat' => $data['lat'] ?? '',
-            'long' => $data['long'] ?? '',
-            'passStatus' => $passStatus,
+            'long' => $data['long'] ?? ''
         ];
         $where = ['sjId' => $sjId, 'shopId' => $id];
-        if ($ptStyle == dict::getDict('ptStyle', 'hd')) {
-            //不能更新 ssh 20240821
-            CustomClass::updateByCondition($where, ['passStatus' => $passStatus]);
-        } elseif ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
+        if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
             GhsClass::updateByCondition($where, $shopUpdate);
         }
         return $respond;

+ 24 - 0
biz/shop/classes/ShopExtClass.php

@@ -334,6 +334,30 @@ class ShopExtClass extends BaseClass
         }
     }
 
+    //订单取消,钱原路退回,提醒客户
+    public static function orderCancelBackMoneyReport($shopId)
+    {
+        $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true);
+        if (!empty($shopExt->lbSn)) {
+            $sound = "订单已取消,付款已原路退回,请稍等几秒重新付款";
+            $url = "https://speaker.17laimai.cn/notify.php?id={$shopExt->lbSn}&token=HK1626595800&version={$shopExt->lbVersion}&message=" . $sound;
+            $curl = new curl\Curl();
+            $curl->get($url);
+        }
+    }
+
+    //提醒输入密码 ssh 20250501
+    public static function remindInputPassword($shopId)
+    {
+        $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true);
+        if (!empty($shopExt->lbSn)) {
+            $sound = "请输入密码";
+            $url = "https://speaker.17laimai.cn/notify.php?id={$shopExt->lbSn}&token=HK1626595800&version={$shopExt->lbVersion}&message=" . $sound;
+            $curl = new curl\Curl();
+            $curl->get($url);
+        }
+    }
+
     //清除所有小菊
     public static function clearXjALl($shopId)
     {

+ 3 - 3
common/components/book.php

@@ -13,15 +13,15 @@ class book
             ['title' => '注册和下载APP', 'id' => 'register'],
             ['title' => '添加修改花材和分类(必看)', 'id' => 'flowerManage'],
             ['title' => '批量修改库存', 'id' => 'batchModifyStock'],
-            ['title' => '设置新订单通知', 'id' => 'setNewNotice'],
+            ['title' => '设置新订单新客户通知', 'id' => 'setNewNotice'],
         ]],
         ['class' => '销售', 'icon' => '/book/kd.png', 'list' => [
             ['title' => '引导客户下单和给客户开单', 'id' => 'order'],
             ['title' => '用小票机打印小票', 'id' => 'print'],
             ['title' => '订单售后,退货退款和补单', 'id' => 'afterSale'],
             ['title' => '客户自助申请售后', 'id' => 'afterSaleService'],
-            ['title' => '自动记账和快速结账', 'id' => 'chargeUp'],
-            ['title' => '根据客户付款金额结账', 'id' => 'quickIn'],
+            ['title' => '自动挂账和快速销账', 'id' => 'chargeUp'],
+            ['title' => '客户微信转过来的钱怎么销账', 'id' => 'quickIn'],
             ['title' => '花材做特价', 'id' => 'tj'],
             ['title' => '节前做预售', 'id' => 'preSell'],
             ['title' => '限购活动', 'id' => 'limitBuy'],

+ 3 - 3
common/components/bookJd.php

@@ -12,15 +12,15 @@ class bookJd
             ['title' => '注册和下载APP', 'id' => 'register'],
             ['title' => '添加修改花材和分类(必看)', 'id' => 'flowerManage'],
             ['title' => '批量修改库存', 'id' => 'batchModifyStock'],
-            ['title' => '设置新订单通知', 'id' => 'setNewNotice'],
+            ['title' => '设置新订单新客户通知', 'id' => 'setNewNotice'],
         ]],
         ['class' => '销售', 'icon' => '/book/kd.png', 'list' => [
             ['title' => '引导客户下单和给客户开单', 'id' => 'order'],
             ['title' => '用小票机打印小票', 'id' => 'print'],
             ['title' => '订单售后,退货退款和补单', 'id' => 'afterSale'],
             ['title' => '客户自助申请售后', 'id' => 'afterSaleService'],
-            ['title' => '自动记账和快速结账', 'id' => 'chargeUp'],
-            ['title' => '根据客户付款金额结账', 'id' => 'quickIn'],
+            ['title' => '自动挂账和快速销账', 'id' => 'chargeUp'],
+            ['title' => '客户微信转过来的钱怎么销账', 'id' => 'quickIn'],
             ['title' => '花材做特价', 'id' => 'tj'],
             ['title' => '节前做预售', 'id' => 'preSell'],
             ['title' => '限购活动', 'id' => 'limitBuy'],

+ 3 - 3
common/components/dict.php

@@ -11,9 +11,8 @@ class dict
         //允许看商家列表的人员
         'couldLookAllShop' => [
             4,//石头
-            51,//琦海
             7335,//骆总
-            12747,//曾总
+            1960,//少奇
         ],
         'getPayType' => 1,
         'appVersion' => 2,
@@ -523,7 +522,7 @@ class dict
             'qt' => 5,//其它
         ],
         'expendTypeMap' => [
-            0 => '店租', 1 => '水电', 2 => '物业', 3 => '伙食', 4 => '房租', 5 => '其它', 6 => '物品', 7 => '办公用品', 8 => '运费', 9 => '工资'
+            0 => '店租', 1 => '水电', 2 => '物业', 3 => '伙食', 4 => '房租', 5 => '其它', 6 => '物品', 7 => '办公用品', 8 => '运费', 9 => '工资', 10 => '线下售后'
         ],
         'expendTypeList' => [
             ['id' => 9, 'name' => '工资'],
@@ -534,6 +533,7 @@ class dict
             ['id' => 1, 'name' => '水电'],
             ['id' => 2, 'name' => '物业'],
             ['id' => 3, 'name' => '伙食'],
+            ['id' => 10, 'name' => '线下售后'],
             ['id' => 4, 'name' => '房租'],
             ['id' => 5, 'name' => '其它'],
         ],

+ 17 - 0
common/components/miniUtil.php

@@ -1560,6 +1560,23 @@ class miniUtil
         return $behind . $fileName;
     }
 
+    public static function generateShortLink($merchant, $ptStyle = 0, $pageUrl, $pageTitle)
+    {
+        $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
+        $url = "https://api.weixin.qq.com/wxa/genwxashortlink?access_token={$accessToken}";
+        $curl = new curl\Curl();
+        $data = [
+            "page_url" => $pageUrl,
+            "page_title" => $pageTitle,
+            'is_permanent' => false,
+        ];
+        $result = $curl->setOption(CURLOPT_POSTFIELDS, Json::encode($data))->post($url);
+        $result = Json::decode($result);
+        echo "<pre>";
+        print_r($result);
+        die;
+    }
+
     //小程序码生成,永久有效,数量暂无限制 ssh 2020.4.17
     public static function generateUnlimitedMiniCode($merchant, $page, $scene = '', $ptStyle = 0)
     {

+ 15 - 0
common/components/orderSn.php

@@ -5,6 +5,7 @@ namespace common\components;
 use biz\shop\classes\ShopClass;
 use biz\sj\classes\CashSnClass;
 use bizGhs\book\classes\BookSnClass;
+use bizGhs\clear\classes\ClearRefundSnClass;
 use bizGhs\custom\classes\CustomRechargeSnClass;
 use bizGhs\ghs\classes\GhsRechargeSnClass;
 use bizGhs\live\classes\LiveOrderSnClass;
@@ -378,6 +379,20 @@ class orderSn
         return $prefix . $id;
     }
 
+    public static function getClearRefundSn()
+    {
+        $prefix = 'RDS_CS';
+        if (getenv('YII_ENV', 'local') == 'production') {
+            $prefix = 'RDS';
+        }
+        $respond = ClearRefundSnClass::add(['id' => null]);
+        $id = $respond['id'] ?? 0;
+        if (empty($id)) {
+            util::fail('结账退款单号没有生成');
+        }
+        return $prefix . $id;
+    }
+
     //制作单 ssh 20220319
     public static function getWorkSn()
     {

+ 12 - 2
common/components/util.php

@@ -38,7 +38,6 @@ class util
 
     /**
      * 生成缩略图
-     * @author yangzhiguo0903@163.com
      * @param string     源图绝对完整地址{带文件名及后缀名}
      * @param string     目标图绝对完整地址{带文件名及后缀名}
      * @param int        缩略图宽{0:此时目标高度不能为0,目标宽度为源图宽*(目标高度/源图高)}
@@ -46,6 +45,7 @@ class util
      * @param int        是否裁切{宽,高必须非0}
      * @param int /float  缩放{0:不缩放, 0<this<1:缩放到相应比例(此时宽高限制和裁切均失效)}
      * @return boolean
+     * @author yangzhiguo0903@163.com
      */
     public static function img2thumb($src_img, $dst_img, $width = 75, $height = 75, $cut = 0, $proportion = 0)
     {
@@ -285,6 +285,16 @@ class util
         self::encode(['code' => 0, 'msg' => $msg, 'data' => []]);
     }
 
+    public static function mistake($msg = '操作失败', $mask = false, $icon = 'none', $duration = 1500)
+    {
+        $report = isset(Yii::$app->params['errorReport']) ? Yii::$app->params['errorReport'] : 0;
+        if ($report == 1) {
+            throw new \Exception($msg);
+            return fale;
+        }
+        self::encode(['code' => 0, 'msg' => $msg, 'data' => [], 'mask' => $mask, 'icon' => $icon, 'duration' => $duration]);
+    }
+
     //错误输出,带自定义code
     public static function error($code, $msg)
     {
@@ -318,7 +328,7 @@ class util
     /**
      * [getLock 时间锁]
      * @param  [type]  $key    [string]
-     * @param  integer $expire [time]
+     * @param integer $expire [time]
      * @return [type]          [bool]
      */
     public static function getLock($key, $expire = 10)

+ 16 - 0
common/components/wxUtil.php

@@ -1650,6 +1650,10 @@ class wxUtil
                     "privacy_key" => "BlueTooth",
                     "privacy_text" => "门店管理时,方便通过蓝牙打印条形码"
                 ],
+                [
+                    "privacy_key" => "Clipboard",
+                    "privacy_text" => "管理订单时,方便复制订单号"
+                ],
             ],
             "privacy_ver" => 2,
         ];
@@ -1660,6 +1664,18 @@ class wxUtil
         echo '隐私设置OK';
     }
 
+    public static function privacySettingSelect($merchant, $isOpen = 0)
+    {
+        $accessToken = self::getMiniProgramAccessToken($merchant, $isOpen);
+        $url = "https://api.weixin.qq.com/cgi-bin/component/getprivacysetting?access_token={$accessToken}";
+        $curl = new curl\Curl();
+        $data = ['privacy_ver' => 1];
+        $result = $curl->setOption(CURLOPT_POSTFIELDS, Json::encode($data))->post($url);
+        $respond = Json::decode($result);
+        echo "<pre>";
+        print_r($respond);
+    }
+
     //收款小程序码
     public static function generateGatheringMiniCode($merchant, $shopId, $isOpen = 0)
     {

+ 13 - 3
console/controllers/CustomController.php

@@ -196,8 +196,19 @@ class CustomController extends Controller
                 Yii::$app->params['ptStyle'] = 2;
                 ApplyService::pass($id, '批发商手动添加');
                 $transaction->commit();
-                //只要手动添加的都标记为花店,任何情况都不会标记为散客
-                CustomClass::updateByCondition(['mobile' => $mobile], ['isHd' => 1]);
+
+                //只要手动添加的都标记为花店,任何情况都不会标记为散客,任何情况都是审核通过的状态
+                $customList = CustomClass::getAllByCondition(['mobile' => $mobile], null, '*', null, true);
+                if (!empty($customList)) {
+                    foreach ($customList as $custom) {
+                        $custom->isHd = 1;
+                        $custom->passStatus = 1;
+                        $custom->save();
+                        $ghsId = $custom->ghsId;
+                        GhsClass::updateById($ghsId, ['passStatus' => 1]);
+                    }
+                }
+
                 //noticeUtil::push("花店 {$shopName} 手机号 {$mobile} 由批发商添加成功");
             } catch (\Exception $exception) {
                 $transaction->rollBack();
@@ -359,5 +370,4 @@ class CustomController extends Controller
 
         }
     }
-
 }