shish 5 lat temu
rodzic
commit
9f3289f265

+ 69 - 57
app/ghs/controllers/CustomController.php

@@ -13,61 +13,73 @@ use yii\web\Controller;
 
 class CustomController extends BaseController
 {
-	
-	//客户列表 shish 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 = ['merchantId' => $this->sjId];
-		switch ($type) {
-			case 1:
-				//已开店
-				$where['isOpen'] = 1;
-				break;
-			default:
-		}
-		if (!empty($name)) {
-			if (stringUtil::isMobile($name)) {
-				$where['mobile'] = $name;
-			} else {
-				$where['shopName'] = ['like', $name];
-			}
-		}
-		$list = CustomService::getCustomList($where);
-		util::success($list);
-	}
-	
-	//客户详情 shish 2021.1.8
-	public function actionDetail()
-	{
-		$get = Yii::$app->request->get();
-		$customId = $get['id'] ?? 0;
-		$info = CustomService::getCustomInfo($customId);
-		CustomClass::valid($info, $this->sjId);
-		$info['sn'] = 1254358;
-		util::success($info);
-	}
-	
-	//允许月结开关 shish 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();
-	}
-	
-	//添加新客户 shish 2021.1.8
-	public function actionAdd()
-	{
-		$post = Yii::$app->request->post();
-		ApplyService::addCustom($post, $this->sjId);
-		util::complete('已提交审核');
-	}
-	
+
+    //客户列表 shish 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 = ['merchantId' => $this->sjId];
+        switch ($type) {
+            case 1:
+                //已开店
+                $where['isOpen'] = 1;
+                break;
+            default:
+        }
+        if (!empty($name)) {
+            if (stringUtil::isMobile($name)) {
+                $where['mobile'] = $name;
+            } else {
+                $where['shopName'] = ['like', $name];
+            }
+        }
+        $list = CustomService::getCustomList($where);
+        util::success($list);
+    }
+
+    //客户详情 shish 2021.1.8
+    public function actionDetail()
+    {
+        $get = Yii::$app->request->get();
+        $customId = $get['id'] ?? 0;
+        $info = CustomService::getCustomInfo($customId);
+        CustomClass::valid($info, $this->sjId);
+        $info['sn'] = 1254358;
+        util::success($info);
+    }
+
+    //允许月结开关 shish 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();
+    }
+
+    //添加新客户 shish 2021.1.8
+    public function actionAdd()
+    {
+        $post = Yii::$app->request->post();
+        ApplyService::addCustom($post, $this->sjId);
+        util::complete('已提交审核');
+    }
+
+    //欠款客户 shish 2021.2.4
+    public function actionDebtList()
+    {
+        $get = Yii::$app->request->get();
+        $where = ['merchantId' => $this->sjId, 'isDebt' => 1];
+        if (isset($get['name']) && !empty($get['name'])) {
+            $where['name'] = ['like', $get['name']];
+        }
+        $list = CustomService::getDebtList($where);
+        util::success($list);
+    }
+
 }

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

@@ -0,0 +1,18 @@
+<?php
+
+namespace ghs\controllers;
+
+use Yii;
+use common\components\util;
+
+class OrderClearController extends BaseController
+{
+
+    //收款 shish 2021.2.4
+    public function actionClear()
+    {
+        $ids = Yii::$app->request->post('id');
+        util::complete();
+    }
+
+}

+ 19 - 0
app/ghs/controllers/OrderController.php

@@ -6,6 +6,7 @@ use biz\merchant\services\MerchantExtendService;
 use biz\wx\classes\WxOpenClass;
 use bizGhs\admin\classes\AdminClass;
 use bizGhs\custom\classes\CustomClass;
+use bizGhs\custom\services\CustomService;
 use bizGhs\merchant\classes\ShopClass;
 use bizGhs\merchant\services\ShopService;
 use bizGhs\order\classes\OrderClass;
@@ -476,4 +477,22 @@ class OrderController extends BaseController
         util::success($out);
     }
 
+    //客户欠款的订单 shish 2021.2.4
+    public function actionDebtList()
+    {
+        $id = Yii::$app->request->get('id', 0);
+        $info = CustomClass::getCustom($id);
+        CustomClass::valid($info, $this->sjId);
+        $where = ['customId' => $id, 'debt' => 1];
+        $list = OrderService::getDebtOrderList($where);
+        util::success($list);
+    }
+
+    //收款 shish 2021.2.4
+    public function actionClearDebt()
+    {
+        $ids = Yii::$app->request->post('id');
+        util::complete();
+    }
+
 }

+ 59 - 50
biz-ghs/custom/classes/CustomClass.php

@@ -4,59 +4,68 @@ namespace bizGhs\custom\classes;
 
 use bizGhs\merchant\classes\MerchantClass;
 use common\components\business;
+use common\components\util;
 use Yii;
 use biz\base\classes\BaseClass;
 
 class CustomClass extends BaseClass
 {
-	
-	public static $baseFile = '\bizGhs\custom\models\Custom';
-	
-	public static function getCustomByIds($ids)
-	{
-		$list = self::getByIds($ids, null, 'id');
-		return self::groupBaseInfo($list);
-	}
-	
-	//整合头像等信息 shish 2021.1.8
-	public static function groupBaseInfo($list)
-	{
-		if (empty($list)) {
-			return $list;
-		}
-		//获取客户信息
-		$downIdList = array_unique(array_filter(array_column($list, 'downId')));
-		$retailInfo = MerchantClass::getByIds($downIdList, null, 'id');
-		foreach ($list as $key => $val) {
-			$downId = $val['downId'];
-			$currentInfo = isset($retailInfo[$downId]) ? $retailInfo[$downId] : [];
-			//组合头像
-			$currentInfo = business::formatMerchantLogo($currentInfo);
-			$list[$key]['smallAvatar'] = isset($currentInfo['smallLogoUrl']) ? $currentInfo['smallLogoUrl'] : '';
-			$list[$key]['avatar'] = isset($currentInfo['logoUrl']) ? $currentInfo['logoUrl'] : '';
-			$list[$key]['visitTime'] = '06-11 12:50';
-			$list[$key]['level'] = 0;
-		}
-		return $list;
-	}
-	
-	//欠款权限开关 shish 2021.1.8
-	public static function debt($custom, $debt)
-	{
-		$id = isset($custom['id']) ? $custom['id'] : 0;
-		self::updateById($id, ['debt' => $debt]);
-		return true;
-	}
-	
-	//权限判断 shish 2021.1.8
-	public static function valid($custom, $merchantId)
-	{
-		if (empty($custom)) {
-			util::fail('没有找到客户');
-		}
-		if ($custom['merchantId'] != $merchantId) {
-			util::fail('您没有权限操作此客户');
-		}
-	}
-	
+
+    public static $baseFile = '\bizGhs\custom\models\Custom';
+
+    //获取客户信息 shish 2021.2.4
+    public static function getCustom($id)
+    {
+        $info = self::getById($id);
+        $respond = self::groupBaseInfo([$info]);
+        return current($respond);
+    }
+
+    public static function getCustomByIds($ids)
+    {
+        $list = self::getByIds($ids, null, 'id');
+        return self::groupBaseInfo($list);
+    }
+
+    //整合头像等信息 shish 2021.1.8
+    public static function groupBaseInfo($list)
+    {
+        if (empty($list)) {
+            return $list;
+        }
+        //获取客户信息
+        $downIdList = array_unique(array_filter(array_column($list, 'downId')));
+        $retailInfo = MerchantClass::getByIds($downIdList, null, 'id');
+        foreach ($list as $key => $val) {
+            $downId = $val['downId'];
+            $currentInfo = isset($retailInfo[$downId]) ? $retailInfo[$downId] : [];
+            //组合头像
+            $currentInfo = business::formatMerchantLogo($currentInfo);
+            $list[$key]['smallAvatar'] = isset($currentInfo['smallLogoUrl']) ? $currentInfo['smallLogoUrl'] : '';
+            $list[$key]['avatar'] = isset($currentInfo['logoUrl']) ? $currentInfo['logoUrl'] : '';
+            $list[$key]['visitTime'] = '06-11 12:50';
+            $list[$key]['level'] = 0;
+        }
+        return $list;
+    }
+
+    //欠款权限开关 shish 2021.1.8
+    public static function debt($custom, $debt)
+    {
+        $id = isset($custom['id']) ? $custom['id'] : 0;
+        self::updateById($id, ['debt' => $debt]);
+        return true;
+    }
+
+    //权限判断 shish 2021.1.8
+    public static function valid($custom, $merchantId)
+    {
+        if (empty($custom)) {
+            util::fail('没有找到客户');
+        }
+        if ($custom['merchantId'] != $merchantId) {
+            util::fail('您没有权限操作此客户');
+        }
+    }
+
 }

+ 49 - 39
biz-ghs/custom/services/CustomService.php

@@ -9,43 +9,53 @@ use Yii;
 
 class CustomService extends BaseService
 {
-	
-	public static $baseFile = '\bizGhs\custom\classes\CustomClass';
-	
-	public static function getCustomList($where)
-	{
-		$data = CustomClass::getList('*', $where, 'addTime DESC');
-		$data['isOpenNum'] = 10;
-		$data['allNum'] = 80;
-		$list = isset($data['list']) && !empty($data['list']) ? $data['list'] : [];
-		if (empty($list)) {
-			return $data;
-		}
-		$data['list'] = CustomClass::groupBaseInfo($list);
-		return $data;
-	}
-	
-	//获取客户信息,包括商家头像和店长信息 shish 2021.1.8
-	public static function getCustomInfo($customId)
-	{
-		$custom = CustomClass::getById($customId);
-		if (empty($custom)) {
-			return [];
-		}
-		$list = CustomClass::groupBaseInfo([$custom]);
-		$custom = current($list);
-		$downShopId = $custom['downShopId'] ?? 0;
-		$downShop = \biz\merchant\classes\ShopClass::getById($downShopId);
-		$super = \biz\merchant\classes\ShopClass::getSuper($downShopId);
-		$custom['province'] = $downShop['province'] ?? '';
-		$custom['city'] = $downShop['city'] ?? '';
-		$custom['address'] = $downShop['address'] ?? '';
-		$custom['floor'] = $downShop['floor'] ?? '';
-		$custom['lat'] = $downShop['lat'] ?? '';
-		$custom['long'] = $downShop['long'] ?? '';
-		$custom['userName'] = $super['adminName'] ?? '';
-		$custom['mobile'] = $super['mobile'] ?? '';
-		return $custom;
-	}
-	
+
+    public static $baseFile = '\bizGhs\custom\classes\CustomClass';
+
+    public static function getCustomList($where)
+    {
+        $data = CustomClass::getList('*', $where, 'addTime DESC');
+        $data['isOpenNum'] = 10;
+        $data['allNum'] = 80;
+        $list = isset($data['list']) && !empty($data['list']) ? $data['list'] : [];
+        if (empty($list)) {
+            return $data;
+        }
+        $data['list'] = CustomClass::groupBaseInfo($list);
+        return $data;
+    }
+
+
+    //获取客户信息,包括商家头像和店长信息 shish 2021.1.8
+    public static function getCustomInfo($customId)
+    {
+        $custom = CustomClass::getById($customId);
+        if (empty($custom)) {
+            return [];
+        }
+        $list = CustomClass::groupBaseInfo([$custom]);
+        $custom = current($list);
+        $downShopId = $custom['downShopId'] ?? 0;
+        $downShop = \biz\merchant\classes\ShopClass::getById($downShopId);
+        $super = \biz\merchant\classes\ShopClass::getSuper($downShopId);
+        $custom['province'] = $downShop['province'] ?? '';
+        $custom['city'] = $downShop['city'] ?? '';
+        $custom['address'] = $downShop['address'] ?? '';
+        $custom['floor'] = $downShop['floor'] ?? '';
+        $custom['lat'] = $downShop['lat'] ?? '';
+        $custom['long'] = $downShop['long'] ?? '';
+        $custom['userName'] = $super['adminName'] ?? '';
+        $custom['mobile'] = $super['mobile'] ?? '';
+        return $custom;
+    }
+
+    //欠款客户列表 shish 2021.126
+    public static function getDebtList($where)
+    {
+        $data = CustomClass::getList('*', $where, 'debtAmount DESC');
+        $data['customNum'] = 10;
+        $data['debtAmount'] = 29980;
+        return $data;
+    }
+
 }

+ 11 - 0
biz-ghs/order/services/OrderService.php

@@ -61,6 +61,17 @@ class OrderService extends BaseService
         return $data;
     }
 
+    //欠款记录 shish 2021.2.4
+    public static function getDebtOrderList($where)
+    {
+        $list = OrderClass::getAllList(['id', 'orderSn', 'actPrice', 'addTime'], $where, 'addTime DESC');
+        return [
+            'list' => $list,
+            'num' => 59,
+            'totalAmount' => 25915.00
+        ];
+    }
+
     //取客户最近若干条订单 shish 2019.11.30
     public static function getUserOrder($userId, $limit = 10, $order = null, $with = null)
     {

+ 21 - 1
sql.sql

@@ -1079,4 +1079,24 @@ MODIFY COLUMN `itemNum`  decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '花材数
 =========
 == shish 2021-2-2
 
-将供货商和零售店绑定到自己的开放平台下 并且更新 xhWxBase 和 xhWxMiniBase 下的openAppId值
+将供货商和零售店绑定到自己的开放平台下 并且更新 xhWxBase 和 xhWxMiniBase 下的openAppId值
+
+===========
+== shish 20201-2-4
+ALTER TABLE `xhGhsCustom` ADD isDebt TINYINT NOT NULL DEFAULT 0 COMMENT '是否有欠款 0没有 1有' AFTER debt;
+ALTER TABLE xhGhsOrder ADD debt TINYINT NOT NULL DEFAULT 0 COMMENT '0没有欠款 1有欠款' AFTER `refund`;
+CREATE TABLE `xhGhsOrderClear` (
+  `id` INT(11) NOT NULL AUTO_INCREMENT,
+  `prePrice` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '应付款,原价,未修改价格,打折前',
+  `actPrice` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '实际付款,实价,修改后价格,打折后',
+  `orderSn` CHAR(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '订单号',
+  `sjId` INT(11) NOT NULL DEFAULT '0' COMMENT '商家id',
+  `orderIds` TEXT COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'id的json串',
+  `addTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间',
+  `updateTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
+  PRIMARY KEY (`id`)
+) COMMENT='清算订单';
+CREATE TABLE `xhGhsOrderClearSn` (
+  `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
+  PRIMARY KEY (`id`)
+) AUTO_INCREMENT=12358276 COMMENT='清算订单号';