Procházet zdrojové kódy

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

林琦海 před 5 roky
rodič
revize
c64cb356a4

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

@@ -28,7 +28,7 @@ class BaseController extends PublicController
     {
         //定义平台类型 1花店 2供货商
         Yii::$app->params['ptStyle'] = dict::getDict('ptStyle', 'ghs');
-        //token验证
+        //token验证 
         $adminId = jwt::getLoginId();
         if (getenv('YII_ENV', 'local') != 'production') {
             //$adminId = 18;

+ 2 - 2
app-hd/controllers/BaseController.php

@@ -31,10 +31,10 @@ class BaseController extends PublicController
         //定义平台类型 1花店 2供货商 3商城
         Yii::$app->params['ptStyle'] = dict::getDict('ptStyle', 'hd');
 
-        //token验证
+        //token验证 
         $adminId = jwt::getLoginId();
         if (getenv('YII_ENV', 'local') != 'production') {
-            //$adminId = 18;
+            //$adminId = 253;
         }
         if (empty($adminId)) {
             util::notLogin();

+ 2 - 1
biz-ghs/admin/classes/AdminClass.php

@@ -232,7 +232,8 @@ class AdminClass extends BaseClass
     {
         $wxInfo = self::switchAdminInfo($wxInfo, $source);
         $unionId = isset($wxInfo['unionId']) && !empty($wxInfo['unionId']) ? $wxInfo['unionId'] : '';
-        $admin = \biz\admin\classes\AdminClass::getByCondition(['unionId' => $unionId]);
+        $style = Yii::$app->params['ptStyle'];
+        $admin = \biz\admin\classes\AdminClass::getByCondition(['unionId' => $unionId, 'style' => $style]);
         if (empty($admin)) {
             $admin = self::generateAdmin($wxInfo);
         } else {

+ 3 - 1
biz-ghs/order/classes/OrderClearClass.php

@@ -82,7 +82,6 @@ class OrderClearClass extends BaseClass
         $customShop->mayPay = $currentMayPay;
         $customShop->save();
 
-
         $orderSn = orderSn::getPurchaseClearSn();
         $clearData = [
             'prePrice' => $amount,
@@ -113,6 +112,9 @@ class OrderClearClass extends BaseClass
             util::fail('没有找到供货商');
         }
         $remainAmount = bcsub($ghs->debtAmount, $amount, 2);
+        if ($remainAmount < 0) {
+            util::fail('客户欠款金额有问题!');
+        }
         $num = bcsub($ghs->debtNum, count($list));
         $ghs->debtAmount = $remainAmount;
         $ghs->debtNum = $num;

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

@@ -511,7 +511,7 @@ class OrderService extends BaseService
         }
 
         if ($isPurchase) {
-            WxMessageClass::newOrderNotice($shop, $order);
+            WxMessageClass::newOrderInform($shop, $order);
         }
 
     }

+ 2 - 1
biz-hd/admin/classes/AdminClass.php

@@ -189,7 +189,8 @@ class AdminClass extends BaseClass
             noticeUtil::push("创建用户时没有找到unionId,参数:" . json_encode($wxInfo), '15280215347');
             util::fail('没有找到unionId');
         }
-        $admin = self::getByUnionId($unionId);
+        $ptStyle = Yii::$app->params['ptStyle'];
+        $admin = self::getByCondition(['unionId' => $unionId, 'style' => $ptStyle]);
         if (empty($admin)) {
             $admin = self::generateAdmin($wxInfo);
         } else {

+ 0 - 1
biz-hd/purchase/services/PurchaseService.php

@@ -258,7 +258,6 @@ class PurchaseService extends BaseService
         $shop->save();
 
         //支出流水
-        $payWay = dict::getDict('payWay', 'unknown');
         $capitalType = dict::getDict('capitalType', 'xhPurchase', 'id');
         $sjId = $info->sjId ?? 0;
         $shopId = $info->shopId ?? 0;

+ 3 - 36
biz-mall/admin/classes/AdminClass.php

@@ -140,45 +140,12 @@ class AdminClass extends BaseClass
     public static function replaceAdmin($adminInfo, $source)
     {
         $adminInfo = self::switchAdminInfo($adminInfo, $source);
-        $adminSource = UserClass::$userSourceId;
         $unionId = isset($adminInfo['unionId']) && !empty($adminInfo['unionId']) ? $adminInfo['unionId'] : '';
-        $unionAdmin = [];
-        if (!empty($unionId)) {
-            $unionAdmin = self::getByUnionId($unionId);
-        }
-        switch ($source) {
-            case $adminSource['mini']['name']:
-                $sourceId = $adminSource['mini']['id'];
-                $miniOpenId = $adminInfo['miniOpenId'];
-                $admin = self::getByMiniOpenId($miniOpenId);
-                break;
-            case $adminSource['official']['name']:
-                $sourceId = $adminSource['official']['id'];
-                $openId = isset($adminInfo['openId']) ? $adminInfo['openId'] : '';
-                $admin = [];
-                if (!empty($openId)) {
-                    $admin = self::getByOpenId($openId);
-                }
-                break;
-            default:
-                throw new \Exception('未知来源的用户');
-        }
+        $ptStyle = Yii::$app->params['ptStyle'];
+        $admin = self::getByCondition(['unionId' => $unionId, 'style' => $ptStyle]);
         if (empty($admin)) {
-            if (!empty($unionAdmin)) {
-                //1、在小程序端已经授权用户信息和unionId之后,关注公众号时走这里
-                //2、关注了公众号或者H5已经授权时,并首次访问小程序
-                $admin = self::updateAdmin($unionAdmin, $adminInfo);
-            } else {
-                $adminInfo['sourceType'] = $sourceId;
-                $admin = self::generateAdmin($adminInfo);
-            }
+            $admin = self::generateAdmin($adminInfo);
         } else {
-            if (!empty($unionAdmin)) {
-                if (isset($unionAdmin['id']) && isset($admin['id']) && $admin['id'] != $unionAdmin['id']) {
-                    //合并相同管理员,小程序管理保留,其它删除
-                    $admin = self::mergeAdmin($unionAdmin, $admin);
-                }
-            }
             $admin = self::updateAdmin($admin, $adminInfo);
         }
         return $admin;

+ 8 - 12
biz/wx/classes/WxMessageClass.php

@@ -100,19 +100,15 @@ class WxMessageClass extends BaseClass
     }
 
     //新订单通知 shish 20210529
-    public static function newOrderNotice($shop, $order)
+    public static function newOrderInform($shop, $order)
     {
         $shopId = $shop->id;
         $ptStyle = $shop->ptStyle;
-        $wxBase = [
-            dict::getDict('ptStyle', 'hd') => \bizHd\wx\classes\WxOpenClass::getWxInfo(),
-            dict::getDict('ptStyle', 'ghs') => \bizHd\wx\classes\WxOpenClass::getGhsWxInfo(),
-            dict::getDict('ptStyle', 'mall') => \bizHd\wx\classes\WxOpenClass::getMallWxInfo(),
-        ];
+        $wxBase = WxOpenClass::getWxBase();
         $wx = $wxBase[$ptStyle] ?? [];
         $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
-        $shortTempId = 'OPENTM417875155';//收入提醒
-        $tempId = isset($message[$shortTempId]) ? $message[$shortTempId] : '';
+        $shortTempId = 'OPENTM417875155';//新订单通知
+        $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
         if (empty($tempId)) {
             return false;
         }
@@ -128,16 +124,16 @@ class WxMessageClass extends BaseClass
                 "template_id" => $tempId,
                 "url" => Yii::$app->params['ghsDomain'],
                 "data" => [
-                    "first" => ["value" => "恭喜,您获得一张优惠劵。", "color" => "#173177"],
-                    "keyword1" => ["value" => '查看', "color" => "#173177"],
-                    "keyword2" => ["value" => '优惠劵', "color" => "#173177"],
+                    "first" => ["value" => "您有新的订单,请注意查收", "color" => "#173177"],
+                    "keyword1" => ["value" => $order->orderSn, "color" => "#173177"],
+                    "keyword2" => ["value" => $order->actPrice, "color" => "#173177"],
                     "keyword3" => ["value" => date("Y-m-d H:i"), "color" => "#173177"],
                     "remark" => ["value" => "点击查看详情", "color" => "#173177"]
                 ]
             ];
             $data['miniprogram']['appid'] = $wx['miniAppId'];
             $data['miniprogram']['pagepath'] = 'pagesOrder/detail?id=' . $orderId;
-            wxUtil::sendTaskInform($data, $wx);
+            wxUtil::sendTaskInform($data, $wx, $ptStyle);
         }
     }
 

+ 25 - 1
biz/wx/classes/WxOpenClass.php

@@ -32,7 +32,6 @@ class WxOpenClass extends BaseClass
     //取供货商平台信息 ssh 2021.2.25
     public static function getGhsOpen()
     {
-
         return self::getByCondition(['style' => dict::getDict('ptStyle', 'ghs')]);
     }
 
@@ -47,4 +46,29 @@ class WxOpenClass extends BaseClass
         return self::getByCondition(['style' => dict::getDict('ptStyle', 'mall')]);
     }
 
+    public static function getWxBase()
+    {
+        $wxBase = [
+            dict::getDict('ptStyle', 'hd') => WxOpenClass::getWxInfo(),
+            dict::getDict('ptStyle', 'ghs') => WxOpenClass::getGhsWxInfo(),
+            dict::getDict('ptStyle', 'mall') => self::getMallWxInfo(),
+        ];
+        return $wxBase;
+    }
+
+    public static function getWxInfo()
+    {
+        return \bizHd\wx\classes\WxOpenClass::getWxInfo();
+    }
+
+    public static function getGhsWxInfo()
+    {
+        return \bizHd\wx\classes\WxOpenClass::getGhsWxInfo();
+    }
+
+    public static function getMallWxInfo()
+    {
+        return \bizHd\wx\classes\WxOpenClass::getMallWxInfo();
+    }
+
 }