Przeglądaj źródła

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

林琦海 5 lat temu
rodzic
commit
7a740a7513

+ 4 - 21
app-ghs/controllers/CustomController.php

@@ -61,27 +61,6 @@ class CustomController extends BaseController
         util::complete();
     }
 
-    //添加新客户 ssh 2021.1.8
-    public function actionAdd()
-    {
-        $post = Yii::$app->request->post();
-        $post['style'] = SjClass::STYLE_RETAIL;
-        $post['from'] = ApplyClass::FROM_GHS;
-        $post['introSjId'] = $this->sjId;
-        $post['introStyle'] = SjClass::STYLE_SUPPLIER;
-        $post['certType'] = ApplyClass::CERT_TYPE_MOBILE;
-        $mobile = $post['mobile'] ?? '';
-        $confirmMobile = $post['confirmMobile'];
-        if (stringUtil::isMobile($mobile) == false) {
-            util::fail(' 请填写正确的手机号');
-        }
-        if ($mobile != $confirmMobile) {
-            util::fail('二次号码填写不一致');
-        }
-        ApplyService::replaceApply($post);
-        util::complete('添加成功,等待审核');
-    }
-
     //欠款客户 ssh 2021.2.4
     public function actionDebtList()
     {
@@ -91,6 +70,10 @@ class CustomController extends BaseController
             $where['name'] = ['like', $get['name']];
         }
         $list = CustomService::getDebtList($where);
+        //共X个客户,合计欠款XXX元
+        $shop = $this->shop;
+        $list['customNum'] = $shop->mayGatheringNum ?? 0;
+        $list['debtAmount'] = $shop->mayGathering ?? 0.00;
         util::success($list);
     }
 

+ 11 - 2
app-pt/controllers/PtYeChangeController.php

@@ -26,8 +26,17 @@ class PtYeChangeController extends BaseController
         if (!empty($tx)) {
             $where['tx'] = $tx;
         }
-        $list = PtYeChangeClass::getChangeList($where);
-        util::success($list);
+        $respond = PtYeChangeClass::getChangeList($where);
+        if (isset($respond['list']) && !empty($respond['list'])) {
+            foreach ($respond['list'] as $key => $val) {
+                if ($tx == dict::getDict('yeTx', 'can')) {
+                    $respond['list'][$key]['balance'] = '-';
+                } else {
+                    $respond['list'][$key]['txBalance'] = '-';
+                }
+            }
+        }
+        util::success($respond);
     }
 
 }

+ 14 - 3
app-pt/controllers/ShopYeChangeController.php

@@ -19,9 +19,20 @@ class ShopYeChangeController extends BaseController
         $tx = $get['tx'] ?? dict::getDict('yeTx', 'canNot');
         $where = [];
         $where['shopId'] = $shopId;
-        $where['tx'] = $tx;
-        $list = ShopYeChangeClass::getChangeList($where);
-        util::success($list);
+        if (!empty($tx)) {
+            $where['tx'] = $tx;
+        }
+        $respond = ShopYeChangeClass::getChangeList($where);
+        if (isset($respond['list']) && !empty($respond['list'])) {
+            foreach ($respond['list'] as $key => $val) {
+                if ($tx == dict::getDict('yeTx', 'can')) {
+                    $respond['list'][$key]['balance'] = '-';
+                } else {
+                    $respond['list'][$key]['txBalance'] = '-';
+                }
+            }
+        }
+        util::success($respond);
     }
 
 }

+ 0 - 8
biz-ghs/custom/services/CustomService.php

@@ -65,14 +65,6 @@ class CustomService extends BaseService
         if (empty($list)) {
             return $data;
         }
-        $i = 0;
-        $debtAmount = 0;
-        foreach ($list as $eky => $val) {
-            $i++;
-            $debtAmount = bcadd($debtAmount, $val['debtAmount']);
-        }
-        $data['customNum'] = $i;
-        $data['debtAmount'] = $debtAmount;
         $data['list'] = CustomClass::groupBaseInfo($list);
         return $data;
     }

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

@@ -126,8 +126,11 @@ class OrderClearClass extends BaseClass
         $shop = ShopClass::getLockById($shopId);
         $currentGathering = bcsub($shop->mayGathering, $amount, 2);
         $shop->mayGathering = $currentGathering;
+        if ($custom->debtNum == 0) {
+            $shop->mayGatheringNum -= 1;
+            $shop->save();
+        }
         $shop->save();
-
     }
 
 }

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

@@ -195,20 +195,8 @@ class OrderService extends BaseService
     //欠款记录 ssh 2021.2.4
     public static function getDebtOrderList($where)
     {
-        $list = OrderClass::getAllList(['id', 'orderSn', 'actPrice', 'addTime'], $where, 'addTime DESC');
+        $list = OrderClass::getAllList(['id', 'orderSn', 'realPrice', 'actPrice', 'addTime'], $where, 'addTime DESC');
         $respond['list'] = $list;
-        $respond['num'] = 0;
-        $respond['totalAmount'] = 0.00;
-        if (!empty($list)) {
-            $i = 0;
-            $amount = 0.00;
-            foreach ($list as $key => $val) {
-                $i++;
-                $amount = bcadd($amount, $val['actPrice'], 2);
-            }
-            $respond['num'] = $i;
-            $respond['totalAmount'] = $amount;
-        }
         return $respond;
     }
 
@@ -405,8 +393,16 @@ class OrderService extends BaseService
         if (isset($order->debt) == false) {
             util::fail('订单有问题,没有欠款项');
         }
+
+        $customId = $order->customId;
+        $custom = CustomClass::getLockById($customId);
+        if (empty($custom)) {
+            util::fail('没有找到客户信息');
+        }
+
         /**门店资产变化**/
         $amount = $order->actPrice ?? 0.00;
+        $realPrice = $order->realPrice ?? 0.00;
         $currentShopId = $order->shopId ?? 0;
         $shop = ShopClass::getLockById($currentShopId);
         if (empty($shop)) {
@@ -420,8 +416,12 @@ class OrderService extends BaseService
         $shop->totalIncome = $currentTotalIncome;
         if ($payWay == dict::getDict('payWay', 'debtPay')) {
             //客户欠款支付会增加【应收客户款】
-            $currentGathering = bcadd($shop->mayGathering, $amount, 2);
+            $currentGathering = bcadd($shop->mayGathering, $realPrice, 2);
             $shop->mayGathering = $currentGathering;
+            //客户第一次欠款的增加一个欠款客户
+            if ($custom->debtNum == 0) {
+                $shop->mayGatheringNum += 1;
+            }
         }
         $shop->save();
 
@@ -451,11 +451,16 @@ class OrderService extends BaseService
         ];
         ShopCapitalClass::addCapital($capital);
 
-        //客户采购引起的开单,会增加余额,会增加收入
+        //客户采购,会增加余额,会增加收入
         if ($isPurchase == true) {
             //余额支付和微信支付会增加余额
             if ($payWay == dict::getDict('payWay', 'wxPay') || $payWay == dict::getDict('payWay', 'balancePay')) {
-                ShopClass::customKdAddBalance($shop, $amount, $order, $capitalType);
+                ShopClass::customKdAddBalance($shop, $realPrice, $order, $capitalType);
+            }
+            if (isset($order->discountType) && $order->discountType == dict::getDict('discountType', 'usePtCoupon')) {
+                //客户使用优惠券增加的余额
+                $theCapital = dict::getDict('capitalType', 'usePtCoupon', 'id');
+                ShopClass::customKdUseCouponAddBalance($shop, $order, $theCapital);
             }
         }
 
@@ -477,15 +482,10 @@ class OrderService extends BaseService
         StatYjClass::addYj($order);
 
         /**客户资产变化**/
-        $customId = $order->customId;
-        $custom = CustomClass::getLockById($customId);
-        if (empty($custom)) {
-            util::fail('没有找到客户信息');
-        }
         if ($payWay == dict::getDict('payWay', 'debtPay')) {
-            //欠款支付
+            //欠款金额
             $custom->isDebt = CustomClass::IS_DEBT_YES;
-            $custom->debtAmount = bcadd($custom->debtAmount, $amount, 2);
+            $custom->debtAmount = bcadd($custom->debtAmount, $realPrice, 2);
             $custom->debtNum += 1;
         }
         $custom->buyNum += 1;

+ 2 - 0
biz-hd/order/classes/OrderClass.php

@@ -285,6 +285,8 @@ class OrderClass extends BaseClass
                         OrderSendClass::withoutSend($order);
                     }
                 }
+                //您有新的收入提醒(门店订单)
+                WxMessageClass::gatheringIncomeInform($shop, $order);
             }
         };
         //来自商城的订单通知 linqh 2021.5.19

+ 4 - 0
biz-hd/purchase/classes/PurchaseClearClass.php

@@ -173,6 +173,10 @@ class PurchaseClearClass extends BaseClass
         $custom->debtNum -= count($arr);
         $custom->isDebt = $remain > 0 ? 1 : 0;
         $custom->save();
+        if ($custom->debtNum == 0) {
+            $shop->mayGatheringNum -= 1;
+            $shop->save();
+        }
 
         //客户门店应付供货商款减少
         $customShopId = $custom->shopId;

+ 3 - 4
biz-hd/purchase/services/PurchaseService.php

@@ -239,15 +239,14 @@ class PurchaseService extends BaseService
         if (empty($shop)) {
             util::fail('没有找到门店');
         }
-        $actPrice = $info->actPrice;
         $realPrice = $info->realPrice;
         /**余额支付引起余额减少**/
         if ($payWay == dict::getDict('payWay', 'balancePay')) {
             ShopClass::purchaseReduceBalance($shop, $realPrice, $info);
         }
-        $shop->totalPurchase = bcadd($shop->totalPurchase, $actPrice, 2);
+        $shop->totalPurchase = bcadd($shop->totalPurchase, $realPrice, 2);
         $shop->totalPurchaseOrder += 1;
-        $currentExpend = bcadd($shop->totalExpend, $actPrice, 2);
+        $currentExpend = bcadd($shop->totalExpend, $realPrice, 2);
         $shop->totalExpend = $currentExpend;
         $shop->cgUnPay -= 1;
         $shop->cgUnSend += 1;
@@ -300,7 +299,7 @@ class PurchaseService extends BaseService
             $ghs->debtAmount = bcadd($ghs->debtAmount, $realPrice, 2);
             $ghs->debtNum += 1;
         }
-        $ghs->expendAmount = bcadd($ghs->expendAmount, $actPrice, 2);
+        $ghs->expendAmount = bcadd($ghs->expendAmount, $realPrice, 2);
         $ghs->expendNum += 1;
         $ghs->save();
 

+ 50 - 0
biz/pt/classes/PtAssetClass.php

@@ -60,6 +60,56 @@ class PtAssetClass extends BaseClass
         PtYeChangeClass::addChange($change, true);
     }
 
+    //客户使用优惠券增加余额 shish 20210601
+    public static function customKdUseCouponAddBalance($shop, $order, $capitalType, $tx)
+    {
+        $amount = $order->discountAmount;
+        $ptStyle = $shop->ptStyle;
+        if ($ptStyle == dict::getDict('ptStyle', 'hd')) {
+            $asset = self::getHdBalance();
+        } elseif ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
+            $asset = self::getGhsBalance();
+        } else {
+            util::fail('没有找到平台');
+        }
+        $currentAmount = bcadd($asset->amount, $amount, 2);
+        $asset->amount = $currentAmount;
+        $asset->save();
+
+        if ($ptStyle == dict::getDict('ptStyle', 'hd')) {
+            $txAsset = self::getHdTxBalance();
+        } elseif ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
+            $txAsset = self::getGhsTxBalance();
+        } else {
+            util::fail('没有找到平台');
+        }
+        $currentTxBalance = $txAsset->amount;
+
+        $currentTxBalance = bcadd($currentTxBalance, $amount, 2);
+        $txAsset->amount = $currentTxBalance;
+        $txAsset->save();
+
+        $id = $order->id;
+        $event = "【{$shop->merchantName} {$shop->shopName}】的客户下单(使用平台优惠券{$amount}元) 订单号:{$order->orderSn}";
+        $change = [
+            'relateId' => $id,
+            'capitalType' => $capitalType,
+            'amount' => $amount,
+            'balance' => $currentAmount,
+            'txBalance' => $currentTxBalance,
+            'io' => 1,
+            'payWay' => $order->payWay,
+            'event' => $event,
+            'sjId' => $order->sjId,
+            'shopId' => $order->shopId,
+            'tx' => $tx,
+            'ptStyle' => $ptStyle,
+            'shopName' => $shop->shopName,
+            'sjName' => $shop->merchantName,
+        ];
+        PtYeChangeClass::addChange($change, true);
+    }
+
     //平台余额增加 shish 20210519
     public static function rechargeAddBalance($shop, $amount, $order, $capitalType, $tx)
     {

+ 1 - 1
biz/pt/classes/PtYeChangeClass.php

@@ -19,7 +19,7 @@ class PtYeChangeClass extends BaseClass
 
     public static function getChangeList($where)
     {
-        $data = self::getList('*', $where, 'addTime DESC');
+        $data = self::getList('*', $where, 'addTime DESC,id DESC');
         return $data;
     }
 

+ 37 - 0
biz/shop/classes/ShopClass.php

@@ -179,6 +179,43 @@ class ShopClass extends BaseClass
         return $gatheringCode;
     }
 
+    //客户使用优惠券增加余额 shish 20210601
+    public static function customKdUseCouponAddBalance($shop, $order, $capitalType)
+    {
+        //门店余额增加
+        $amount = $order->discountAmount;
+        $currentBalance = bcadd($shop->balance, $amount, 2);
+        $shop->balance = $currentBalance;
+        $shop->totalRecharge = bcadd($shop->totalRecharge, $amount, 2);
+        //可提现余额同步增加
+        $currentTx = bcadd($shop->txBalance, $amount, 2);
+        $shop->txBalance = $currentTx;
+        $shop->save();
+
+        //增加余额变动记录
+        $id = $order->id;
+        $event = "客户下单(使用平台优惠券{$amount}元)";
+        $tx = dict::getDict('yeTx', 'can');
+        $change = [
+            'relateId' => $id,
+            'capitalType' => $capitalType,
+            'amount' => $amount,
+            'balance' => $currentBalance,
+            'txBalance' => $currentTx,
+            'io' => 1,
+            'payWay' => $order->payWay,
+            'event' => $event,
+            'sjId' => $order->sjId,
+            'shopId' => $order->shopId,
+            'tx' => $tx,
+            'ptStyle' => $shop->ptStyle,
+        ];
+        ShopYeChangeClass::addChange($change, true);
+
+        //平台余额增加
+        PtAssetClass::customKdUseCouponAddBalance($shop, $order, $capitalType, $tx);
+    }
+
     //客户下单引起的余额增加 shish 20210520
     public static function customKdAddBalance($shop, $amount, $order, $capitalType)
     {

+ 3 - 3
biz/shop/classes/ShopCouponClass.php

@@ -21,21 +21,21 @@ class ShopCouponClass extends BaseClass
         [
             'name' => '优惠券',
             'amount' => '5',
-            'miniCost' => '100',
+            'miniCost' => '50',
             'beginTime' => "+6 days",
             'endTime' => "+7 days",
         ],
         [
             'name' => '优惠券',
             'amount' => '10',
-            'miniCost' => '100',
+            'miniCost' => '50',
             'beginTime' => "+3 days",
             'endTime' => "+7 days",
         ],
         [
             'name' => '优惠券',
             'amount' => '15',
-            'miniCost' => '100',
+            'miniCost' => '50',
             'beginTime' => "+0 days",
             'endTime' => "+7 days",
         ]

+ 1 - 1
biz/shop/classes/ShopYeChangeClass.php

@@ -16,7 +16,7 @@ class ShopYeChangeClass extends BaseClass
 
     public static function getChangeList($where)
     {
-        $data = self::getList('*', $where, 'addTime DESC');
+        $data = self::getList('*', $where, 'addTime DESC,id DESC');
         return $data;
     }
 

+ 42 - 0
biz/wx/classes/WxMessageClass.php

@@ -85,6 +85,7 @@ class WxMessageClass extends BaseClass
             $wx = $wxBase[$ptStyle] ?? [];
             foreach ($message as $shortId => $title) {
                 $wxReturn = wxUtil::tMessageCreate($wx, $shortId, $ptStyle);
+                echo json_encode($wxReturn) . "\n";
                 if (isset($wxReturn['errcode']) && $wxReturn['errcode'] == 0) {
                     $templateId = $wxReturn['template_id'];
                     $data = [
@@ -317,6 +318,47 @@ class WxMessageClass extends BaseClass
         }
     }
 
+    //收款码收入通知 shish 20210531
+    public static function gatheringIncomeInform($shop, $order)
+    {
+        $shopId = $shop->id;
+        $ptStyle = $shop->ptStyle;
+        $wxBase = WxOpenClass::getWxBase();
+        $wx = $wxBase[$ptStyle] ?? [];
+        $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
+        $shortTempId = 'OPENTM207422813';//收入提醒
+        $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
+        if (empty($tempId)) {
+            return false;
+        }
+        $actPrice = $order->actPrice;
+        $orderId = $order->id;
+        $adminList = ShopAdminClass::getRemainAdmin($shopId);
+        foreach ($adminList as $admin) {
+            if (isset($admin['subscribe']) == false || $admin['subscribe'] == 0) {
+                continue;
+            }
+            $openId = isset($admin['openId']) ? $admin['openId'] : '';
+            $data = [
+                "touser" => $openId,
+                "template_id" => $tempId,
+                "url" => Yii::$app->params['ghsDomain'],
+                "data" => [
+                    "first" => ["value" => "您有新的收入。", "color" => "#173177"],
+                    "keyword1" => ["value" => $actPrice, "color" => "#173177"],
+                    "keyword2" => ["value" => '二维码收款', "color" => "#173177"],
+                    "keyword3" => ["value" => date("Y-m-d H:i"), "color" => "#173177"],
+                    "remark" => ["value" => "点击查看详情", "color" => "#173177"]
+                ]
+            ];
+            $data['miniprogram']['appid'] = $wx['miniAppId'];
+            $data['miniprogram']['pagepath'] = 'admin/order/detail?id=' . $orderId;
+
+            wxUtil::sendTaskInform($data, $wx, $ptStyle);
+        }
+    }
+
+
     //提现成功通知 shish 20210531
     public static function cashInform($shop, $cash)
     {

+ 2 - 0
common/components/dict.php

@@ -140,6 +140,7 @@ class dict
             'ghsCheckOut' => ['id' => 26, 'name' => 'ghsCheckOut'],
             //供货商入库
             'ghsCheckIn' => ['id' => 27, 'name' => 'ghsCheckIn'],
+            'usePtCoupon' => ['id' => 30, 'name' => 'usePtCoupon'],
         ],
         "capitalTypeList" => [//流水类型的对应链接,后台收支明细查看时跳转的链接
             0 => ['link' => '/capital/order-detail', 'name' => '网店', 'orderLink' => '/order/detail', 'id' => 0,],
@@ -155,6 +156,7 @@ class dict
             12 => ['link' => '/capital/purchase-detail', 'name' => '培训报名', 'orderLink' => '', 'id' => 12,],
             20 => ['link' => '', 'name' => '采购结算', 'orderLink' => '', 'id' => 20,],
             25 => ['link' => '', 'name' => '采购', 'orderLink' => '', 'id' => 25,],
+            30 => ['link' => '', 'name' => '使用平台优惠券', 'orderLink' => '', 'id' => 30,],
         ],
 
         //用户来源