Просмотр исходного кода

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

shizhongqi 1 месяц назад
Родитель
Сommit
2e94320a6e

+ 8 - 3
.env.example

@@ -70,10 +70,15 @@ LIANKENET_TIMEOUT=10
 # 可选:指定 USB 口与驱动名,不填则自动取设备第一台打印机
 LIANKENET_DEVICE_PORT=
 LIANKENET_PRINTER_MODEL=
-# 纸张代码,A4=9,小票机请按打印机参数配置
+# 默认纸张类型与链科 dmPaperSize(接口 paperSize 可覆盖)
+LIANKENET_PAPER_TYPE=a4
 LIANKENET_PAPER_SIZE=9
-# A4 配送单可单独指定纸张代码,不填则沿用 LIANKENET_PAPER_SIZE
-LIANKENET_A4_PAPER_SIZE=9
+# 配送单:a4 / a5 / b5 / letter
+LIANKENET_DELIVERY_SLIP_PAPER_TYPE=a4
+LIANKENET_DELIVERY_SLIP_PAPER_SIZE=
+# 节日贺卡:a4 / a5 / card_10x15 / card_13x18
+LIANKENET_GREETING_CARD_PAPER_TYPE=a4
+LIANKENET_GREETING_CARD_PAPER_SIZE=
 # 配送单页脚客服电话,不填则用门店电话
 LIANKENET_SERVICE_PHONE=
 LIANKENET_COPIES=1

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

@@ -29,7 +29,7 @@ class ApplyController extends BaseController
     {
         $get = Yii::$app->request->get();
         $mobile = $get['mobile'] ?? '';
-        if (stringUtil::isMobile($mobile) == false) {
+        if (!stringUtil::isMobile($mobile)) {
             util::fail('请输入正确手机号');
         }
         $rand = rand(11111, 99999);

+ 120 - 0
app-ghs/controllers/GhsNoticeController.php

@@ -0,0 +1,120 @@
+<?php
+
+namespace ghs\controllers;
+
+use bizGhs\shop\classes\GhsNoticeClass;
+use common\components\util;
+use Yii;
+
+/**
+ * 批发端通知公告
+ */
+class GhsNoticeController extends BaseController
+{
+    /**
+     * 管理端公告列表
+     */
+    public function actionList()
+    {
+        $get = Yii::$app->request->get();
+        $list = GhsNoticeClass::searchList([
+            'mainId' => $this->mainId,
+            'title' => $get['title'] ?? '',
+            'isDel' => 0,
+            'order' => 'id DESC',
+        ]);
+        util::success($list);
+    }
+
+    /**
+     * 客户端公告列表(仅显示中的公告)
+     */
+    public function actionShowList()
+    {
+        $get = Yii::$app->request->get();
+        $list = GhsNoticeClass::searchList([
+            'mainId' => $this->mainId,
+            'title' => $get['title'] ?? '',
+            'position' => $get['position'] ?? '',
+            'isDel' => 0,
+            'status' => 1,
+            'order' => 'sort DESC, id DESC',
+        ]);
+        util::success($list);
+    }
+
+    /**
+     * 新增公告
+     */
+    public function actionAdd()
+    {
+        $post = Yii::$app->request->post();
+        $post['mainId'] = $this->mainId;
+        $post['staffId'] = intval($this->shopAdminId);
+        $id = GhsNoticeClass::addNotice($post);
+        $info = GhsNoticeClass::getDetail($id);
+        util::success($info);
+    }
+
+    /**
+     * 更新公告
+     */
+    public function actionUpdate()
+    {
+        $post = Yii::$app->request->post();
+        $id = intval($post['id'] ?? 0);
+        if ($id <= 0) {
+            util::fail('公告id不对');
+        }
+        $info = GhsNoticeClass::getById($id);
+        GhsNoticeClass::valid($info, $this->mainId);
+        $post['staffId'] = intval($this->shopAdminId);
+        GhsNoticeClass::updateNotice($id, $post);
+        util::complete('修改成功');
+    }
+
+    /**
+     * 公告详情
+     */
+    public function actionDetail()
+    {
+        $id = intval(Yii::$app->request->get('id', 0));
+        if ($id <= 0) {
+            util::fail('公告id不对');
+        }
+        $info = GhsNoticeClass::getById($id);
+        GhsNoticeClass::valid($info, $this->mainId);
+        util::success(GhsNoticeClass::getDetail($id));
+    }
+
+    /**
+     * 软删除公告
+     */
+    public function actionDelete()
+    {
+        $id = intval(Yii::$app->request->post('id', Yii::$app->request->get('id', 0)));
+        if ($id <= 0) {
+            util::fail('公告id不对');
+        }
+        $info = GhsNoticeClass::getById($id);
+        GhsNoticeClass::valid($info, $this->mainId);
+        GhsNoticeClass::deleteNotice($id, intval($this->shopAdminId));
+        util::complete('删除成功');
+    }
+
+    /**
+     * 上下架公告
+     */
+    public function actionUpdateStatus()
+    {
+        $id = intval(Yii::$app->request->post('id', Yii::$app->request->get('id', 0)));
+        $status = intval(Yii::$app->request->post('status', Yii::$app->request->get('status', 0)));
+        if ($id <= 0) {
+            util::fail('公告id不对');
+        }
+        $info = GhsNoticeClass::getById($id);
+        GhsNoticeClass::valid($info, $this->mainId);
+        GhsNoticeClass::updateStatus($id, $status, intval($this->shopAdminId));
+        util::complete('操作成功');
+    }
+}

+ 0 - 3
app-hd/controllers/ApplyController.php

@@ -70,9 +70,6 @@ class ApplyController extends BaseController
         $ptStyle = Yii::$app->params['ptStyle'];
         $cacheKey = 'register_mobile_code_' . $ptStyle . '_' . $mobile;
         Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 600, $rand]);
-
-        noticeUtil::push("注册验证码:{$rand},{$mobile} 申请注册", '15280215347');
-
         util::complete();
     }
 

+ 61 - 1
app-hd/controllers/GhsController.php

@@ -8,6 +8,7 @@ use bizGhs\custom\classes\AccountMoneyClass;
 use bizGhs\custom\classes\CustomClass;
 use bizGhs\custom\classes\CustomLevelClass;
 use bizGhs\merchant\classes\WlClass;
+use bizGhs\shop\classes\GhsNoticeClass;
 use bizHd\purchase\classes\PurchaseClass;
 use bizHd\shop\classes\ShopExtClass;
 use bizGhs\stat\classes\StatVisitClass;
@@ -23,7 +24,7 @@ use Yii;
 class GhsController extends BaseController
 {
 
-    public $guestAccess = ['info', 'get-ghs-data', 'detail'];
+    public $guestAccess = ['info', 'get-ghs-data', 'detail', 'common-info', 'ghs-notice-detail'];
 
     //提示花店有多个供货商
     public function actionRemindMoreGhs()
@@ -496,4 +497,63 @@ class GhsController extends BaseController
         util::complete();
     }
 
+    public function actionCommonInfo()
+    {
+        $mainId = $this->resolveGhsMainId();
+        // 通用接口返回全部有效公告,前端按 positions 字段筛选展示位置
+        $ghsNoticeList = GhsNoticeClass::getClientNoticeList($mainId);
+        util::success(['ghsNoticeList' => $ghsNoticeList]);
+    }
+
+    /**
+     * 批发商公告详情(零售端采购页查看)
+     */
+    public function actionGhsNoticeDetail()
+    {
+        $id = intval(Yii::$app->request->get('id', 0));
+        if ($id <= 0) {
+            util::fail('公告id不对');
+        }
+        util::success(GhsNoticeClass::getClientDetail($id));
+    }
+
+    /**
+     * 根据批发商 ghsId 或 shopId 解析 mainId(列表接口用,勿与公告 id 混用)
+     */
+    protected function resolveGhsMainId(): int
+    {
+        $get = Yii::$app->request->get();
+        $ghsId = intval($get['ghsId'] ?? 0);
+        $shopId = intval($get['shopId'] ?? 0);
+        $ghsShopId = 0;
+
+        if ($ghsId > 0) {
+            $ghs = GhsClass::getById($ghsId);
+            if (empty($ghs)) {
+                util::fail('没有找到批发商');
+            }
+            if (!empty($this->shopId)) {
+                GhsClass::valid($ghs, $this->shopId);
+            }
+            $ghsShopId = intval($ghs['shopId'] ?? 0);
+        } elseif ($shopId > 0) {
+            $ghsShop = ShopClass::getById($shopId, true);
+            if (empty($ghsShop) || $ghsShop->ptStyle != dict::getDict('ptStyle', 'ghs')) {
+                util::fail('没有找到批发店');
+            }
+            $ghsShopId = $shopId;
+        } else {
+            util::fail('参数不对');
+        }
+
+        $ghsShop = ShopClass::getById($ghsShopId, true);
+        if (empty($ghsShop)) {
+            util::fail('没有找到批发商');
+        }
+        $mainId = intval($ghsShop->mainId ?? 0);
+        if ($mainId <= 0) {
+            util::fail('批发商信息不完整');
+        }
+        return $mainId;
+    }
 }

+ 174 - 202
app-hd/controllers/PurchaseController.php

@@ -11,7 +11,6 @@ use bizGhs\custom\classes\AccountMoneyClass;
 use bizGhs\custom\classes\CustomClass;
 use bizGhs\express\classes\GhsDeliveryOrderClass;
 use bizGhs\order\classes\OrderClass;
-use bizGhs\order\classes\ShMethodClass;
 use bizHd\cg\classes\CgMergeSnClass;
 use bizHd\purchase\classes\PurchaseClass;
 use bizHd\purchase\classes\PurchaseItemClass;
@@ -521,9 +520,6 @@ class PurchaseController extends BaseController
 
             $post['product'] = $productList;
 
-            // xhShMethod 门店下单前保留花材合计,供后续 packCost 计算(pfLevel==0 分支会 unset itemTotalAmount)
-            $shMethodItemAmount = $post['itemTotalAmount'] ?? 0;
-
             $sendType = $post['sendType'] ?? 0;
             $transType = $post['transType'] ?? 0;
             if ($sendType == dict::getDict('sendType', 'thirdSend')) {
@@ -631,236 +627,218 @@ class PurchaseController extends BaseController
                 //标记为昆明到地方订单
                 $post['localOrder'] = 1;
             } else {
-
-                // xhShMethod 门店:下单前按配置写入不满最低消费时的附加包装费/运费,关键词sh_method_area
-                if (in_array($ghsShopId, [36523])) {
-                    $shMethodBigNum = 0;
-                    foreach ($productList as $itemData) {
-                        $shMethodBigNum += floatval($itemData['bigNum'] ?? 0);
-                    }
-                    $additionalCosts = ShMethodClass::calcFee(
-                        $ghsShopId,
-                        $ghsMainId,
-                        $sendType,
-                        $shMethodItemAmount,
-                        $shMethodBigNum,
-                        $customId,
-                        $ghsInfo
-                    );
-
-                    // 如果产生了附加运费,与前面可能产生的 sendCost 进行累加或覆盖
-                    if ($additionalCosts['sendCost'] > 0) {
-                        $post['sendCost'] = bcadd($post['sendCost'] ?? 0, $additionalCosts['sendCost'], 2);
-                    }
-
-                    // 如果产生了附加包装费,覆盖前面赋值的 packCost
-                    if ($additionalCosts['packCost'] > 0) {
-                        $post['packCost'] = $additionalCosts['packCost'];
+                //同城发货包装费和运费的计算
+                $sendCost = 0;
+                $sendDistance = 0;
+                //特别注意,这边取供货商的shop信息
+                $mapSet = ShopClass::hasIntraCity($ghsShopInfo);
+                $openIntraCity = $mapSet['openIntraCity'] ?? 0;
+                if ($sendType == dict::getDict('sendType', 'thirdSend')) {
+                    if ($openIntraCity == 2) {
+                        util::fail('不能使用跑腿');
                     }
-                }else{
+                    if ($openIntraCity == 1) {
+                        // 生成随机订单号,不要跟原来的混起来,跑腿-销售单-
+                        $prefix = 'PT-XSD-' . $this->mainId . '-';
+                        $orderSn = $prefix . round(microtime(true) * 1000);
 
-                    //同城发货包装费和运费的计算
-                    $sendCost = 0;
-                    $sendDistance = 0;
-                    //特别注意,这边取供货商的shop信息
-                    $mapSet = ShopClass::hasIntraCity($ghsShopInfo);
-                    $openIntraCity = $mapSet['openIntraCity'] ?? 0;
-                    if ($sendType == dict::getDict('sendType', 'thirdSend')) {
-                        if ($openIntraCity == 2) {
-                            util::fail('不能使用跑腿');
-                        }
-                        if ($openIntraCity == 1) {
-                            // 生成随机订单号,不要跟原来的混起来,跑腿-销售单-
-                            $prefix = 'PT-XSD-' . $this->mainId . '-';
-                            $orderSn = $prefix . round(microtime(true) * 1000);
-
-                            // 使用 DeliveryQuoteUtil 获取配送报价
-                            try {
-
-                                if (empty($post['deliveryPlatform'])) {
-                                    util::fail('请选择跑腿');
-                                }
+                        // 使用 DeliveryQuoteUtil 获取配送报价
+                        try {
 
-                                $quoteResult = DeliveryQuoteUtil::getDeliveryQuote([
-                                    'productList' => $productList,
-                                    'deliveryPlatform' => $post['deliveryPlatform'],
-                                    'deliveryBracketContent' => $post['deliveryBracketContent'], // 平台多报价识别id
-                                    'ghsInfo' => $ghsInfo,
-                                    'custom' => $custom,
-                                    'order' => [
-                                        'orderSn' => $orderSn,
-                                        'goodsType' => 1, //商品类型:0花束 1花材
-                                        'itemTotalAmount' => $post['itemTotalAmount'] ?? 0,
-                                        'remark' => $post['remark'] ?? '',
-                                    ],
-                                    'mainId' => $this->mainId,
-                                    'productCount' => $productCount,
-                                ]);
-
-                                $sendCost = $quoteResult['sendCost'];
-                                $sendDistance = $quoteResult['sendDistance'];
-                            } catch (\Exception $e) {
-                                util::fail($e->getMessage());
+                            if (empty($post['deliveryPlatform'])) {
+                                util::fail('请选择跑腿');
                             }
+
+                            $quoteResult = DeliveryQuoteUtil::getDeliveryQuote([
+                                'productList' => $productList,
+                                'deliveryPlatform' => $post['deliveryPlatform'],
+                                'deliveryBracketContent' => $post['deliveryBracketContent'], // 平台多报价识别id
+                                'ghsInfo' => $ghsInfo,
+                                'custom' => $custom,
+                                'order' => [
+                                    'orderSn' => $orderSn,
+                                    'goodsType' => 1, //商品类型:0花束 1花材
+                                    'itemTotalAmount' => $post['itemTotalAmount'] ?? 0,
+                                    'remark' => $post['remark'] ?? '',
+                                ],
+                                'mainId' => $this->mainId,
+                                'productCount' => $productCount,
+                            ]);
+
+                            $sendCost = $quoteResult['sendCost'];
+                            $sendDistance = $quoteResult['sendDistance'];
+                        } catch (\Exception $e) {
+                            util::fail($e->getMessage());
                         }
                     }
+                }
 
-                    $post['sendCost'] = $sendCost;
-                    $post['sendDistance'] = $sendDistance;
+                $post['sendCost'] = $sendCost;
+                $post['sendDistance'] = $sendDistance;
 
-                    //出车、发快递、发物流可以算包装费
-                    $packCost = 0;
-                    if (isset($ghsInfo['mainId']) && $ghsInfo['mainId'] == 14499) {
-                        noticeUtil::push("走的pfLevel=0", '15280215347');
-                    }
-                    $itemTotalAmount = $post['itemTotalAmount'] ?? 0;
-                    unset($post['itemTotalAmount']);
-                    if ($sendType == dict::getDict('sendType', 'express')) {
-                        $needAdd = \bizHd\shop\classes\ShopClass::needAddPackCost($ghsShopInfo, $customId, $itemTotalAmount);
-                        if ($needAdd) {
-                            $packCost = $ghsShopInfo->packCost ?? 0;
-                        }
+                //出车、发快递、发物流可以算包装费
+                $packCost = 0;
+                if (isset($ghsInfo['mainId']) && $ghsInfo['mainId'] == 14499) {
+                    noticeUtil::push("走的pfLevel=0", '15280215347');
+                }
+                $itemTotalAmount = $post['itemTotalAmount'] ?? 0;
+                unset($post['itemTotalAmount']);
+                if ($sendType == dict::getDict('sendType', 'express')) {
+                    $needAdd = \bizHd\shop\classes\ShopClass::needAddPackCost($ghsShopInfo, $customId, $itemTotalAmount);
+                    if ($needAdd) {
+                        $packCost = $ghsShopInfo->packCost ?? 0;
                     }
-                    $post['packCost'] = $packCost;
-
                 }
+                $post['packCost'] = $packCost;
             }
 
-            $respond = PurchaseService::createPurchase($post, $ghsInfo);
+            if (isset($ghsInfo['mainId']) && $ghsInfo['mainId'] == 14499) {
+                noticeUtil::push("包装费:" . $packCost, '15280215347');
+            }
 
-            if (in_array($ghsShopId, [36523])) {
-                // 使用 xhShMethod 配置校验配送限制,替代旧版门店硬编码规则,关键词sh_method_area
-                $shMethodError = ShMethodClass::checkLimit(
-                    $ghsShopId,
-                    $ghsMainId,
-                    $sendType,
-                    $respond->actPrice ?? 0,
-                    $respond->bigNum ?? 0,
-                    $post['packCost'] ?? 0,
-                    $post['sendCost'] ?? 0,
-                    $post['wlName'] ?? '',
-                    $customId,
-                    $ghsInfo
-                );
-                if ($shMethodError !== '') {
-                    $transaction->rollBack();
-                    util::fail($shMethodError);
-                }
-            } else {
+            $respond = PurchaseService::createPurchase($post, $ghsInfo);
 
-                if ($sendType == 0) {
-                    if (getenv('YII_ENV') == 'production') {
-                        //杭州斗南鲜花批发部,满500,10公里内免费配送,满1000,20公里免费配送
-                        if ($ghsShopId == 4608) {
-                            if ($respond->actPrice < 500) {
-                                $transaction->rollBack();
-                                util::fail('满500元支持免费配送');
-                            }
-                        }
-                        //叶上花,满500元市区免费配送
-                        if ($ghsShopId == 4804) {
-                            if ($respond->actPrice < 500) {
-                                $transaction->rollBack();
-                                util::fail('满500元支持免费配送');
-                            }
+            if ($sendType == 0) {
+                if (getenv('YII_ENV') == 'production') {
+                    //杭州斗南鲜花批发部,满500,10公里内免费配送,满1000,20公里免费配送
+                    if ($ghsShopId == 4608) {
+                        if ($respond->actPrice < 500) {
+                            $transaction->rollBack();
+                            util::fail('满500元支持免费配送');
                         }
-                        //花悠星 国恋 勇记 万丽 陆丰暂时不支持免费配送
-                        if ($ghsShopId == 7687 || $ghsShopId == 7831 || $ghsShopId == 7778 || $ghsShopId == 12003 || $ghsShopId == 38128) {
-                            util::fail('暂不支持送货上门,请选其它配送方式!');
+                    }
+                    //叶上花,满500元市区免费配送
+                    if ($ghsShopId == 4804) {
+                        if ($respond->actPrice < 500) {
+                            $transaction->rollBack();
+                            util::fail('满500元支持免费配送');
                         }
+                    }
+                    //花悠星 国恋 勇记 万丽 陆丰暂时不支持免费配送
+                    if ($ghsShopId == 7687 || $ghsShopId == 7831 || $ghsShopId == 7778 || $ghsShopId == 12003 || $ghsShopId == 38128) {
+                        util::fail('暂不支持送货上门,请选其它配送方式!');
+                    }
 
-                        //广州鑫源花卉,选择送货上门必须选必选商品
-                        if ($ghsShopId == 12439) {
-                            $hasMust = array_intersect($ids, [3446945, 3446970, 3446973, 3446979, 3446995, 3447010, 3447023, 3459983, 4333184, 4317745, 1585738]);
-                            if (empty($hasMust)) {
-                                util::fail('请返回选择 必选商品');
-                            }
+                    //广州鑫源花卉,选择送货上门必须选必选商品
+                    if ($ghsShopId == 12439) {
+                        $hasMust = array_intersect($ids, [3446945, 3446970, 3446973, 3446979, 3446995, 3447010, 3447023, 3459983, 4333184, 4317745, 1585738]);
+                        if (empty($hasMust)) {
+                            util::fail('请返回选择 必选商品');
                         }
-
-                        //三明易批花
-                        if ($ghsShopId == 82200) {
-                            if ($respond->actPrice < 100 || $respond->bigNum < 15) {
-                                $hasMust = array_intersect($ids, [4283478]);
-                                if (empty($hasMust)) {
-                                    util::fail('没满100元且15扎,请返回选运费');
-                                }
-                            }
-                            // 按当天计时,把 sendTimeWant 要限制在两天的时间范围之内
-                            $future = date("Y-m-d", strtotime('+2 day'));
-                            if (strtotime($respond->sendTimeWant) > strtotime($future)) {
-                                util::fail('配送日期只能选最近二天');
-                            }
+                    }
+                    if ($ghsShopId == 100883) {
+                        $hasMust = array_intersect($ids, [5017957,5036067,5036089,5036099,5017958,5036063,5017948,5035980,5036073,5036075,5036076,5036117,5036118,5017949,5035979,5035976,5035928,5035930,5036061,5035879]);
+                        if (empty($hasMust)) {
+                            util::fail('请返回选择 必选商品');
                         }
+                    }
 
-                        if ($ghsShopId == 77703) {
-                            //天天鲜花思明店,暂时关闭送货上门
-                            if ($respond->sendType == 0) {
-                                //util::fail('节日暂停送货上门,请选到店自取');
-                            }
-                        }
 
-                        if ($ghsShopId == 86726) {
-                            //藏花林
-                            if ($respond->transType != 4 && $respond->transType != 5) {
-                                util::fail('请选同城配送或到店自取');
+                    //三明易批花
+                    if ($ghsShopId == 82200) {
+                        if ($respond->actPrice < 100 || $respond->bigNum < 15) {
+                            $hasMust = array_intersect($ids, [4283478]);
+                            if (empty($hasMust)) {
+                                util::fail('没满100元且15扎,请返回选运费');
                             }
                         }
-
+                        // 按当天计时,把 sendTimeWant 要限制在两天的时间范围之内
+                        $future = date("Y-m-d", strtotime('+2 day'));
+                        if (strtotime($respond->sendTimeWant) > strtotime($future)) {
+                            util::fail('配送日期只能选最近二天');
+                        }
                     }
 
-                    if (isset($ghsInfo['home'])) {
-                        if ($ghsInfo['home'] == 0) {
-                            util::fail('暂不支持送货上门,请选其它配送方式');
+                    if ($ghsShopId == 77703) {
+                        //天天鲜花思明店,暂时关闭送货上门
+                        if ($respond->sendType == 0) {
+                            //util::fail('节日暂停送货上门,请选到店自取');
                         }
-                        $homeAmount = $ghsInfo['homeAmount'] ? floatval($ghsInfo['homeAmount']) : 0;
-                        $homeNum = $ghsInfo['homeNum'] ? floatval($ghsInfo['homeNum']) : 0;
-                        if ($homeAmount > 0 && $homeAmount > $respond->actPrice) {
-                            util::fail("满{$homeAmount}元 可送货上门");
-                        }
-                        if ($homeNum > 0 && $homeNum > $respond->bigNum) {
-                            util::fail("满{$homeNum}扎 可送货上门");
+                    }
+
+                    if ($ghsShopId == 86726) {
+                        //藏花林
+                        if ($respond->transType != 4 && $respond->transType != 5) {
+                            util::fail('请选同城配送或到店自取');
                         }
                     }
 
+                } else {
+
+                    //好运鲜花批发,选择送货上门必须选必选商品
+//                    if ($ghsShopId == 36523) {
+//                        if ($respond->transType != 4 && $respond->transType != 5) {
+//                            util::fail('请选同城配送或到店自取');
+//                        }
+//                    }
+
+//                    if ($ghsShopId == 36523) {
+//                        if ($respond->actPrice < 50 || $respond->bigNum < 10) {
+//                            $hasMust = array_intersect($ids, [85295]);
+//                            if (empty($hasMust)) {
+//                                util::fail('没满50元且满10扎,请运费必选商品');
+//                            }
+//                        }
+//                        // 按当天计时,把 sendTimeWant 要限制在两天的时间范围之内
+//                        $future = date("Y-m-d", strtotime('+2 day'));
+//                        if (strtotime($respond->sendTimeWant) > strtotime($future)) {
+//                            util::fail('配送日期只能选最近二天');
+//                        }
+//                    }
+
                 }
 
-                if ($sendType == 2) {
-                    //温州易批花,跑腿,不满100,要选10元的补运费商品
-                    if ($ghsShopId == 91115) {
-                        if ($respond->actPrice < 100) {
-                            $transaction->rollBack();
-                            $hasMust = array_intersect($ids, [4449812, 4449811]);
-                            if (empty($hasMust)) {
-                                util::fail('不满100,必选商品 补运费10元');
-                            }
+                if (isset($ghsInfo['home'])) {
+                    if ($ghsInfo['home'] == 0) {
+                        util::fail('暂不支持送货上门,请选其它配送方式');
+                    }
+                    $homeAmount = $ghsInfo['homeAmount'] ? floatval($ghsInfo['homeAmount']) : 0;
+                    $homeNum = $ghsInfo['homeNum'] ? floatval($ghsInfo['homeNum']) : 0;
+                    if ($homeAmount > 0 && $homeAmount > $respond->actPrice) {
+                        util::fail("满{$homeAmount}元 可送货上门");
+                    }
+                    if ($homeNum > 0 && $homeNum > $respond->bigNum) {
+                        util::fail("满{$homeNum}扎 可送货上门");
+                    }
+                }
+
+            }
+
+            if ($sendType == 2) {
+                //温州易批花,跑腿,不满100,要选10元的补运费商品
+                if ($ghsShopId == 91115) {
+                    if ($respond->actPrice < 100) {
+                        $transaction->rollBack();
+                        $hasMust = array_intersect($ids, [4449812, 4449811]);
+                        if (empty($hasMust)) {
+                            util::fail('不满100,必选商品 补运费10元');
                         }
                     }
                 }
-                if ($sendType == 4) {
-                    //温州易批花,快递,不满100,要选10元的补运费商品
-                    if ($ghsShopId == 91115) {
-                        if ($respond->actPrice < 100) {
-                            $transaction->rollBack();
-                            $hasMust = array_intersect($ids, [4449812, 4449811]);
-                            if (empty($hasMust)) {
-                                util::fail('不满100,必选商品 补运费10元');
-                            }
+            }
+            if ($sendType == 4) {
+                //温州易批花,快递,不满100,要选10元的补运费商品
+                if ($ghsShopId == 91115) {
+                    if ($respond->actPrice < 100) {
+                        $transaction->rollBack();
+                        $hasMust = array_intersect($ids, [4449812, 4449811]);
+                        if (empty($hasMust)) {
+                            util::fail('不满100,必选商品 补运费10元');
                         }
                     }
                 }
-                if ($sendType == 3) {
-                    //温州易批花,物流,不满200,要选10元的补运费商品
-                    if ($ghsShopId == 91115) {
-                        if ($respond->actPrice < 200) {
-                            $transaction->rollBack();
-                            $hasMust = array_intersect($ids, [4449812, 4449811]);
-                            if (empty($hasMust)) {
-                                util::fail('不满200,必选商品 补运费10元');
-                            }
+            }
+            if ($sendType == 3) {
+                //温州易批花,物流,不满200,要选10元的补运费商品
+                if ($ghsShopId == 91115) {
+                    if ($respond->actPrice < 200) {
+                        $transaction->rollBack();
+                        $hasMust = array_intersect($ids, [4449812, 4449811]);
+                        if (empty($hasMust)) {
+                            util::fail('不满200,必选商品 补运费10元');
                         }
                     }
                 }
-
             }
 
             $transaction->commit();
@@ -951,18 +929,12 @@ class PurchaseController extends BaseController
                     Yii::$app->redis->executeCommand('SETEX', [$key, 86400, '1']);
                 }
             } else {
-                //标记当天已收一次包装费/运费,岭南批发市场用的功能,只要有成功订单就标记,不再要求金额必须>0
-                $current = date("Y_m_d");
                 if (isset($info->sendType) && $info->sendType == 4) {
+                    //标记当天已收一次包装费,岭南批发市场用的功能
+                    $current = date("Y_m_d");
                     $key = 'ghs_custom_today_has_get_pack_cost_' . $current . '_' . $customId;
                     Yii::$app->redis->executeCommand('SETEX', [$key, 86400, '1']);
                 }
-                noticeUtil::push("运费:" . $info->sendCost . ' sendType:' . $info->sendType, '15280215347');
-                if (isset($info->sendType) && $info->sendType == 0) {
-                    noticeUtil::push("执行到了", '15280215347');
-                    $sendKey = 'ghs_custom_today_has_get_send_cost_' . $current . '_' . $customId;
-                    Yii::$app->redis->executeCommand('SETEX', [$sendKey, 86400, '1']);
-                }
             }
 
             // 复杂分支/关键逻辑:不是预订单,且供货商配置为直接完成流程,则自动确认收货。

+ 288 - 0
biz-ghs/shop/classes/GhsNoticeClass.php

@@ -0,0 +1,288 @@
+<?php
+
+namespace bizGhs\shop\classes;
+
+use bizGhs\base\classes\BaseClass;
+use common\components\util;
+use Yii;
+use yii\db\Expression;
+
+/**
+ * 批发端通知公告业务类
+ */
+class GhsNoticeClass extends BaseClass
+{
+    public static $baseFile = '\bizGhs\shop\models\GhsNotice';
+
+    /** 展示位置:分类菜单 */
+    const POSITION_CATEGORY = 1;
+    /** 展示位置:订单提交 */
+    const POSITION_ORDER = 2;
+
+    /**
+     * 展示位置文案映射
+     */
+    public static function getPositionMap(): array
+    {
+        return [
+            self::POSITION_CATEGORY => '分类菜单',
+            self::POSITION_ORDER => '订单提交',
+        ];
+    }
+
+    /**
+     * 客户端公告列表(不分页)
+     */
+    public static function getClientNoticeList(int $mainId, int $position = 0): array
+    {
+        if ($mainId <= 0) {
+            return [];
+        }
+        $query = self::getModel()::find()
+            ->where(['mainId' => $mainId, 'isDel' => 0, 'status' => 1]);
+        if ($position > 0) {
+            $query->andWhere(new Expression('FIND_IN_SET(:position, [[position]])', [':position' => (string)$position]));
+        }
+        $list = $query->orderBy('sort DESC, id DESC')->asArray()->all();
+        return self::groupBaseInfo($list);
+    }
+
+    /**
+     * 客户端公告详情(仅校验公告本身有效)
+     */
+    public static function getClientDetail(int $id): array
+    {
+        $info = self::getById($id);
+        if (empty($info) || intval($info['isDel']) === 1 || intval($info['status']) !== 1) {
+            util::fail('公告不存在');
+        }
+        return self::getDetail($id);
+    }
+
+    /**
+     * 通用列表查询,供管理端与客户端复用
+     */
+    public static function searchList(array $params): array
+    {
+        $get = Yii::$app->request->get();
+        $page = isset($get['page']) ? max(1, intval($get['page'])) : 1;
+        $pageSize = !empty($get['pageSize']) ? intval($get['pageSize']) : Yii::$app->params['pageSize'];
+
+        $query = self::getModel()::find()->where(['mainId' => intval($params['mainId'])]);
+
+        if (isset($params['isDel'])) {
+            $query->andWhere(['isDel' => intval($params['isDel'])]);
+        }
+        if (isset($params['status'])) {
+            $query->andWhere(['status' => intval($params['status'])]);
+        }
+        if (!empty($params['title'])) {
+            $query->andWhere(['like', 'title', trim($params['title'])]);
+        }
+        if (!empty($params['position'])) {
+            $position = intval($params['position']);
+            $query->andWhere(new Expression('FIND_IN_SET(:position, [[position]])', [':position' => (string)$position]));
+        }
+
+        $order = !empty($params['order']) ? $params['order'] : 'id DESC';
+        $totalNum = (int)$query->count();
+        $totalPage = $pageSize > 0 ? (int)ceil($totalNum / $pageSize) : 0;
+        $list = $query->orderBy($order)
+            ->offset(($page - 1) * $pageSize)
+            ->limit($pageSize)
+            ->asArray()
+            ->all();
+
+        return [
+            'totalNum' => $totalNum,
+            'totalPage' => $totalPage,
+            'moreData' => $page < $totalPage ? 1 : 0,
+            'list' => self::groupBaseInfo($list),
+        ];
+    }
+
+    /**
+     * 组装列表展示字段
+     */
+    public static function groupBaseInfo(array $list): array
+    {
+        $positionMap = self::getPositionMap();
+        foreach ($list as $key => $item) {
+            $positions = self::formatPositionToArr($item['position'] ?? '');
+            $labels = [];
+            foreach ($positions as $pos) {
+                if (isset($positionMap[$pos])) {
+                    $labels[] = $positionMap[$pos];
+                }
+            }
+            $list[$key]['positions'] = $positions;
+            $list[$key]['positionLabels'] = $labels;
+        }
+        return $list;
+    }
+
+    /**
+     * 多选位置转逗号分隔字符串
+     */
+    public static function formatPositionToStr($positions): string
+    {
+        if (is_string($positions)) {
+            $positions = array_filter(array_map('trim', explode(',', $positions)));
+        }
+        if (!is_array($positions)) {
+            return '';
+        }
+        $valid = array_keys(self::getPositionMap());
+        $positions = array_values(array_unique(array_map('intval', $positions)));
+        $positions = array_values(array_intersect($positions, $valid));
+        sort($positions);
+        return implode(',', $positions);
+    }
+
+    /**
+     * 逗号分隔字符串转位置数组
+     */
+    public static function formatPositionToArr(string $position): array
+    {
+        if ($position === '') {
+            return [];
+        }
+        $positions = array_filter(array_map('trim', explode(',', $position)));
+        return array_values(array_map('intval', $positions));
+    }
+
+    /**
+     * 校验公告表单数据
+     */
+    public static function validateNoticeData(array $data): array
+    {
+        $title = trim($data['title'] ?? '');
+        $summary = trim($data['summary'] ?? '');
+        if ($title === '') {
+            util::fail('请输入公告标题');
+        }
+        if (mb_strlen($title) > 20) {
+            util::fail('标题不能超过20个字');
+        }
+        if ($summary === '') {
+            util::fail('请输入公告简介');
+        }
+        if (mb_strlen($summary) > 70) {
+            util::fail('公告简介不能超过70个字');
+        }
+
+        $position = self::formatPositionToStr($data['position'] ?? '');
+        if ($position === '') {
+            util::fail('请选择展示位置');
+        }
+
+        $content = $data['content'] ?? '';
+        if ($content === '' || $content === '[]') {
+            util::fail('请添加公告内容');
+        }
+        if (is_string($content)) {
+            $contentArr = json_decode($content, true);
+            if (!is_array($contentArr) || empty($contentArr)) {
+                util::fail('公告内容格式不正确');
+            }
+        }
+
+        return [
+            'title' => $title,
+            'summary' => $summary,
+            'content' => is_string($content) ? $content : json_encode($content, JSON_UNESCAPED_UNICODE),
+            'position' => $position,
+            'sort' => intval($data['sort'] ?? 0),
+            'status' => intval($data['status'] ?? 0) === 1 ? 1 : 0,
+        ];
+    }
+
+    /**
+     * 新增公告
+     */
+    public static function addNotice(array $data): int
+    {
+        $noticeData = self::validateNoticeData($data);
+        if (!empty($data['mainId'])) {
+            $noticeData['mainId'] = intval($data['mainId']);
+        }
+        if (!empty($data['staffId'])) {
+            $noticeData['staffId'] = intval($data['staffId']);
+        }
+        if ($noticeData['status'] === 1) {
+            $noticeData['publishTime'] = date('Y-m-d H:i:s');
+        }
+        $result = self::add($noticeData);
+        return is_array($result) ? intval($result['id'] ?? 0) : intval($result);
+    }
+
+    /**
+     * 更新公告
+     */
+    public static function updateNotice(int $id, array $data): void
+    {
+        $noticeData = self::validateNoticeData($data);
+        $info = self::getById($id);
+        if (empty($info)) {
+            util::fail('公告不存在');
+        }
+        if (!empty($data['staffId'])) {
+            $noticeData['staffId'] = intval($data['staffId']);
+        }
+        self::updateById($id, $noticeData);
+    }
+
+    /**
+     * 公告详情
+     */
+    public static function getDetail(int $id): array
+    {
+        $info = self::getById($id);
+        if (empty($info)) {
+            util::fail('公告不存在');
+        }
+        $list = self::groupBaseInfo([$info]);
+        return current($list);
+    }
+
+    /**
+     * 软删除公告
+     */
+    public static function deleteNotice(int $id, int $staffId = 0): void
+    {
+        $updateData = ['isDel' => 1];
+        if ($staffId > 0) {
+            $updateData['staffId'] = $staffId;
+        }
+        self::updateById($id, $updateData);
+    }
+
+    /**
+     * 上下架公告
+     */
+    public static function updateStatus(int $id, int $status, int $staffId = 0): void
+    {
+        $status = $status === 1 ? 1 : 0;
+        $updateData = ['status' => $status];
+        if ($status === 1) {
+            $updateData['publishTime'] = date('Y-m-d H:i:s');
+        }
+        if ($staffId > 0) {
+            $updateData['staffId'] = $staffId;
+        }
+        self::updateById($id, $updateData);
+    }
+
+    /**
+     * 校验公告归属权限
+     */
+    public static function valid(array $info, int $mainId): void
+    {
+        if (empty($info) || intval($info['mainId']) !== intval($mainId)) {
+            util::fail('没有权限操作该公告');
+        }
+        if (intval($info['isDel']) === 1) {
+            util::fail('公告已删除');
+        }
+    }
+}

+ 16 - 0
biz-ghs/shop/models/GhsNotice.php

@@ -0,0 +1,16 @@
+<?php
+
+namespace bizGhs\shop\models;
+
+use bizGhs\base\models\Base;
+
+/**
+ * 批发端通知公告
+ */
+class GhsNotice extends Base
+{
+    public static function tableName()
+    {
+        return 'xhGhsNotice';
+    }
+}

+ 0 - 4
biz-hd/shop/classes/ShopNoticeClass.php

@@ -203,10 +203,6 @@ class ShopNoticeClass extends BaseClass
         if (empty($info)) {
             util::fail('公告不存在');
         }
-        // 从隐藏变为显示时更新上架时间
-        if (intval($info['status']) !== 1 && $noticeData['status'] === 1) {
-            $noticeData['publishTime'] = date('Y-m-d H:i:s');
-        }
         if (!empty($data['staffId'])) {
             $noticeData['staffId'] = intval($data['staffId']);
         }