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

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

sorry 5 лет назад
Родитель
Сommit
0ea320c3fe

+ 79 - 79
app-ghs/controllers/CustomController.php

@@ -13,85 +13,85 @@ use Yii;
 
 class CustomController extends BaseController
 {
-	
-	//客户列表 ssh 2021.7.8
-	public function actionList()
-	{
-		$get = Yii::$app->request->get();
-		$type = isset($get['type']) ? $get['type'] : 0;
-		$name = isset($get['name']) ? $get['name'] : '';
-		$where = ['ownSjId' => $this->sjId];
-		switch ($type) {
-			case 1:
-				//已开店
-				$where['isOpen'] = 1;
-				break;
-			default:
-		}
-		if (!empty($name)) {
-			if (stringUtil::isMobile($name)) {
-				$where['mobile'] = $name;
-			} else {
-				$where['name'] = ['like', $name];
-			}
-		}
-		$list = CustomService::getCustomList($where);
-		util::success($list);
-	}
-	
-	//客户详情 ssh 2021.1.8
-	public function actionDetail()
-	{
-		$get = Yii::$app->request->get();
-		$customId = $get['id'] ?? 0;
-		$info = CustomService::getCustomInfo($customId);
-		CustomClass::valid($info, $this->sjId);
-		util::success($info);
-	}
-	
-	//允许月结开关 ssh 2021.1.8
-	public function actionDebt()
-	{
-		$get = Yii::$app->request->get();
-		$debt = isset($get['debt']) ? $get['debt'] : 0;
-		$customId = isset($get['customId']) ? $get['customId'] : 0;
-		$custom = CustomClass::getById($customId);
-		CustomClass::valid($custom, $this->sjId);
-		CustomClass::debt($custom, $debt);
-		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()
-	{
-		$get = Yii::$app->request->get();
-		$where = ['sjId' => $this->sjId, 'isDebt' => 1];
-		if (isset($get['name']) && !empty($get['name'])) {
-			$where['name'] = ['like', $get['name']];
-		}
-		$list = CustomService::getDebtList($where);
-		util::success($list);
-	}
+    //客户列表 ssh 2021.7.8
+    public function actionList()
+    {
+        $get = Yii::$app->request->get();
+        $type = isset($get['type']) ? $get['type'] : 0;
+        $name = isset($get['name']) ? $get['name'] : '';
+        $where = ['ownSjId' => $this->sjId];
+        switch ($type) {
+            case 1:
+                //已开店
+                $where['isOpen'] = 1;
+                break;
+            default:
+        }
+        if (!empty($name)) {
+            if (stringUtil::isMobile($name)) {
+                $where['mobile'] = $name;
+            } else {
+                $where['name'] = ['like', $name];
+            }
+        }
+        $list = CustomService::getCustomList($where);
+        util::success($list);
+    }
+
+    //客户详情 ssh 2021.1.8
+    public function actionDetail()
+    {
+        $get = Yii::$app->request->get();
+        $customId = $get['id'] ?? 0;
+        $info = CustomService::getCustomInfo($customId);
+        CustomClass::valid($info, $this->sjId);
+        util::success($info);
+    }
+
+    //允许月结开关 ssh 2021.1.8
+    public function actionDebt()
+    {
+        $get = Yii::$app->request->get();
+        $debt = isset($get['debt']) ? $get['debt'] : 0;
+        $customId = isset($get['customId']) ? $get['customId'] : 0;
+        $custom = CustomClass::getById($customId);
+        CustomClass::valid($custom, $this->sjId);
+        CustomClass::debt($custom, $debt);
+        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()
+    {
+        $get = Yii::$app->request->get();
+        $where = ['ownSjId' => $this->sjId, 'isDebt' => 1];
+        if (isset($get['name']) && !empty($get['name'])) {
+            $where['name'] = ['like', $get['name']];
+        }
+        $list = CustomService::getDebtList($where);
+        util::success($list);
+    }
 
 }

+ 3 - 0
biz-ghs/custom/classes/CustomClass.php

@@ -18,6 +18,9 @@ class CustomClass extends BaseClass
 
     public static $baseFile = '\bizGhs\custom\models\Custom';
 
+    const IS_DEBT_NO = 0;
+    const IS_DEBT_YES = 1;
+
     //申请开店建立客户关系 ssh 2021.2.28
     //GhsClass::build()也有相似流程
     public static function buildCustom($applyData, $sjId, $shopId)

+ 5 - 0
biz-ghs/order/classes/OrderClass.php

@@ -76,6 +76,11 @@ class OrderClass extends BaseClass
     const CLEAR_DEBT = 1;
     const CLEAR_HAS_GATHERING = 2;
 
+    //没有欠款
+    const DEBT_NO = 0;
+    //欠款
+    const DEBT_YES = 1;
+
     public static $sendTypeMap = [
         self::SEND_TYPE_UNKNOWN => '未确认',
         self::SEND_TYPE_NO => '自取',

+ 23 - 12
biz-hd/purchase/classes/PurchaseClass.php

@@ -9,6 +9,7 @@ use biz\shop\models\Shop;
 use bizGhs\admin\classes\AdminClass;
 use bizGhs\custom\classes\CustomClass;
 use biz\sj\classes\MerchantClass;
+use bizGhs\custom\models\Custom;
 use bizGhs\order\traits\OrderTrait;
 use bizGhs\product\classes\ProductClass;
 use bizGhs\order\classes\OrderClass;
@@ -235,13 +236,6 @@ class PurchaseClass extends BaseClass
                     }
                 }
                 $list[$key]['product'] = $itemData;
-//                $list[$key]['product'] = [
-//                    [
-//                        'cover' => 'https://img.huahb.com/uploads/12358/202101/13/0e713d46064ca89b1fb11095b710f244_small.jpeg',
-//                        'name' => '昆明B级红玫瑰卡罗拉', 'property' => 'B级', 'price' => '8.45', 'bigNum' => 2,
-//                        'smallNum' => 10
-//                    ],
-//                ];
             }
         }
         return $list;
@@ -299,15 +293,17 @@ class PurchaseClass extends BaseClass
         if (isset($info->status) == false || $info->status != self::STATUS_UN_PAY) {
             util::fail('订单不是待付款状态');
         }
+
+        //零售采购单状态变化
         $info->payWay = $payWay;
         $info->status = self::STATUS_UN_SEND;
-
-        //欠款支付
         if ($payWay == dict::getDict('payWay', 'debtPay')) {
+            //欠款支付
             $info->debt = 1;
         }
         $info->save();
 
+        //零售门店资产变化
         $shopId = $info['shopId'] ?? 0;
         $shop = Shop::findBySql('select * from ' . Shop::tableName() . ' where id = :id for update', ['id' => $shopId])->one();
         if (empty($shop)) {
@@ -317,29 +313,31 @@ class PurchaseClass extends BaseClass
         $shop->totalPurchase = bcadd($shop->totalPurchase, $actPrice, 2);
         $shop->totalPurchaseOrder += 1;
         $shop->save();
+
+        //零售的供货商资产变化
         $ghsId = $info->ghsId ?? 0;
         $ghs = Ghs::findBySql('select * from ' . Ghs::tableName() . ' where id = :id for update', ['id' => $ghsId])->one();
         if (empty($ghs)) {
             util::fail('没有找到供货商');
         }
-
-        //欠款支付
         if ($payWay == dict::getDict('payWay', 'debtPay')) {
+            //欠款支付
             $ghs->debt = 2;
             $ghs->debtAmount = bcadd($ghs->debtAmount, $actPrice, 2);
             $ghs->debtNum += 1;
         }
-
         $ghs->expendAmount = bcadd($ghs->expendAmount, $actPrice, 2);
         $ghs->expendNum += 1;
         $ghs->save();
 
+        //供货商销售单状态变化
         $ghsOrderId = $info->ghsOrderId ?? 0;
         $ghsOrder = OrderClass::getById($ghsOrderId, true);
         if (empty($ghsOrder)) {
             util::fail('没有找到对应供货商订单');
         }
         $ghsOrder->status = OrderClass::ORDER_STATUS_UN_SEND;
+        $ghsOrder->debt = OrderClass::DEBT_YES;
         $ghsOrder->save();
         $shopId = $ghsOrder->shopId;
         $actPrice = $ghsOrder->actPrice;
@@ -350,6 +348,19 @@ class PurchaseClass extends BaseClass
         $shop->totalIncome = bcadd($shop->totalIncome, $actPrice, 2);
         $shop->totalOrderNum += 1;
         $shop->save();
+
+        //供货商的客户资产变化
+        $customId = $ghsOrder->customId;
+        $custom = Custom::findBySql('select * from ' . Custom::tableName() . ' where id = :id for update', ['id' => $customId])->one();
+        if ($payWay == dict::getDict('payWay', 'debtPay')) {
+            //欠款支付
+            $custom->isDebt = CustomClass::IS_DEBT_YES;
+            $custom->debtAmount = bcadd($custom->debtAmount, $actPrice, 2);
+            $custom->debtNum += 1;
+        }
+        $custom->buyNum += 1;
+        $custom->buyAmount = bcadd($custom->buyAmount, $actPrice, 2);
+        $custom->save();
     }
 
 }

+ 1 - 1
biz/sj/services/MerchantService.php

@@ -145,7 +145,7 @@ class MerchantService extends BaseService
 
         //创建门店
         $shopData = [
-            'shopName' => $sj['name'],
+            'shopName' => '总店',
             'merchantId' => $sjId,
             'openTime' => '8:00 - 23:00',
             'telephone' => $mobile,