shish 5 лет назад
Родитель
Сommit
99d2eda5fe

+ 1 - 1
app/shop/controllers/PurchaseController.php

@@ -102,5 +102,5 @@ class PurchaseController extends BaseController
         ];
         util::success(['button' => $button]);
     }
-
+    
 }

+ 23 - 10
app/shop/controllers/SupplierController.php

@@ -11,14 +11,27 @@ use Yii;
 
 class SupplierController extends BaseController
 {
-
-    //供货商列表 shish 2021.1.24
-    public function actionList()
-    {
-        $where = [];
-        $where['merchantId'] = $this->merchantId;
-        $respond = SupplierService::getSupplierList($where);
-        util::success($respond);
-    }
-
+	
+	//供货商列表 shish 2021.1.24
+	public function actionList()
+	{
+		$where = [];
+		$where['merchantId'] = $this->merchantId;
+		$respond = SupplierService::getSupplierList($where);
+		util::success($respond);
+	}
+	
+	//待结款供货商列表 shish 2021.1.26
+	public function actionDebtList()
+	{
+		$get = Yii::$app->request->get();
+		$where = ['merchantId' => $this->merchantId];
+		$status = $get['status'] ?? 0;
+		if (!empty($status)) {
+			$where['status'] = $status;
+		}
+		$list = SupplierService::getDebtList($where);
+		util::success($list);
+	}
+	
 }

+ 25 - 10
biz-ghs/merchant/services/SupplierService.php

@@ -3,22 +3,37 @@
 namespace bizGhs\merchant\services;
 
 use bizGhs\base\services\BaseService;
+use bizGhs\merchant\classes\MerchantAssetClass;
 use bizGhs\merchant\classes\SupplierClass;
+use common\components\util;
 use Yii;
 
 class SupplierService extends BaseService
 {
 
-    public static $baseFile = '\bizGhs\merchant\classes\SupplierClass';
+	public static $baseFile = '\bizGhs\merchant\classes\SupplierClass';
 
-    //供货商列表 shish 2021.1.24
-    public static function getSupplierList($where)
-    {
-        $data = SupplierClass::getList('*', $where, 'addTime DESC');
-        $data['list'] = SupplierClass::groupBaseInfo($data['list']);
-        $data['debtAmount'] = 110000;
-        $data['debtNum'] = 12;
-        return $data;
-    }
+	//供货商列表 shish 2021.1.24
+	public static function getSupplierList($where)
+	{
+		$data = SupplierClass::getList('*', $where, 'addTime DESC');
+		$data['list'] = SupplierClass::groupBaseInfo($data['list']);
+		return $data;
+	}
+
+	//待结款列表 shish 2021.126
+	public static function getDebtList($where)
+	{
+		$merchantId = $where['merchantId'] ?? 0;
+		if (empty($merchantId)) {
+			util::fail('没有找到商家');
+		}
+		$data = SupplierClass::getList('*', $where, 'debtAmount DESC');
+		$data['list'] = SupplierClass::groupBaseInfo($data['list']);
+		$asset = MerchantAssetClass::getByMerchantId($merchantId);
+		$data['debtAmount'] = $asset['cgDebtAmount'] ?? 0.00;
+		$data['debtNum'] = $asset['cgDebtNum'] ?? 0;
+		return $data;
+	}
 
 }