Browse Source

结款记录

shish 5 years ago
parent
commit
327a0e712e

+ 23 - 0
app/shop/controllers/PurchaseClearController.php

@@ -0,0 +1,23 @@
+<?php
+
+namespace shop\controllers;
+
+use biz\purchase\classes\PurchaseClearClass;
+use Yii;
+use common\components\util;
+
+class PurchaseClearController extends BaseController
+{
+
+	//生成结算订单 shish 2021.1.26
+	public function actionCreateOrder()
+	{
+		$post = Yii::$app->request->post();
+		$ids = $post['id'];
+		$data['merchantId'] = $this->merchantId;
+		$data['id'] = $ids;
+		$respond = PurchaseClearClass::addClear($data);
+		util::success($respond);
+	}
+
+}

+ 102 - 90
app/shop/controllers/PurchaseController.php

@@ -11,96 +11,108 @@ use common\components\util;
 
 class PurchaseController extends BaseController
 {
+	
+	//生成采购单 shish 2021.1.17
+	public function actionCreateOrder()
+	{
+		$post = Yii::$app->request->post();
+		$supplierId = $post['supplierId'] ?? 0;
+		//供货商
+		$supplier = SupplierClass::getById($supplierId);
+		if (empty($supplier)) {
+			util::fail('没有找到供货商');
+		}
+		$upShopId = $supplier['upShopId'] ?? 0;
+		$upId = $supplier['upId'] ?? 0;
+		$post['upShopId'] = $upShopId;
+		$post['upId'] = $upId;
+		
+		$post['shopId'] = $this->shopId;
+		$product = $post['product'] ?? '';
+		$productList = json_decode($product, true);
+		//判断product数据是不是同个供货商的
+		ProductClass::valid($productList, $upShopId);
+		$post['product'] = $productList;
+		$respond = PurchaseClass::addPurchase($post);
+		$orderSn = $respond['orderSn'] ?? '';
+		$actPrice = $respond['actPrice'] ?? '';
+		$data = [
+			'orderSn' => $orderSn,
+			'actPrice' => $actPrice,
+			'hasBalancePay' => 1,
+			'hasPayPassword' => 0,
+			'hasDebtPay' => 1,
+		];
+		util::success($data);
+	}
+	
+	//延期支付 shish 2021.1.24
+	public function actionDebtPay()
+	{
+		$get = Yii::$app->request->get();
+		$id = $get['id'] ?? 0;
+		$info = PurchaseClass::getInfo($id);
+		PurchaseClass::valid($info, $this->shopId);
+		PurchaseClass::debt($info);
+		util::complete();
+	}
+	
+	//余额支付 shish 2021.1.24
+	public function actionBalancePay()
+	{
+		$get = Yii::$app->request->get();
+		$id = $get['id'] ?? 0;
+		$password = $get['password'] ?? '';
+		$info = PurchaseClass::getInfo($id);
+		PurchaseClass::valid($info, $this->shopId);
+		purchaseClass::balancePay($info);
+		util::complete();
+	}
+	
+	//采购记录 shish 2021.1.24
+	public function actionList()
+	{
+		$get = Yii::$app->request->get();
+		$where = ['merchantId' => $this->merchantId];
+		$status = $get['status'] ?? 0;
+		if (!empty($status)) {
+			$where['status'] = $status;
+		}
+		$list = PurchaseService::getPurchaseList($where);
+		util::success($list);
+	}
+	
+	//采购详情 shish 2021.01.25
+	public function actionDetail()
+	{
+		$get = Yii::$app->request->get();
+		$id = $get['id'] ?? 0;
+		$info = PurchaseClass::getInfo($id, true, true, true);
+		PurchaseClass::valid($info, $this->shopId);
+		util::success($info);
+	}
+	
+	//可用的支付方式 shish 2021.1.25
+	public function actionPayWay()
+	{
+		$button = [
+			['type' => 'wxPay', 'show' => 1, 'disable' => 1],
+			['type' => 'debtPay', 'show' => 1, 'disable' => 0],
+			['type' => 'balancePay', 'show' => 1, 'disable' => 0],
+		];
+		util::success(['button' => $button]);
+	}
 
-    //生成采购单 shish 2021.1.17
-    public function actionCreateOrder()
-    {
-        $post = Yii::$app->request->post();
-        $supplierId = $post['supplierId'] ?? 0;
-        //供货商
-        $supplier = SupplierClass::getById($supplierId);
-        if (empty($supplier)) {
-            util::fail('没有找到供货商');
-        }
-        $upShopId = $supplier['upShopId'] ?? 0;
-        $upId = $supplier['upId'] ?? 0;
-        $post['upShopId'] = $upShopId;
-        $post['upId'] = $upId;
+	//待结款明细 shish 2021.1.26
+	public function actionDebtList()
+	{
+		$get = Yii::$app->request->get();
+		$where = [
+			'merchantId' => $this->merchantId,
+			'debt' => PurchaseClass::DEBT_YES
+		];
+		$respond = PurchaseService::getDebtList($where);
+		util::success($respond);
+	}
 
-        $post['shopId'] = $this->shopId;
-        $product = $post['product'] ?? '';
-        $productList = json_decode($product, true);
-        //判断product数据是不是同个供货商的
-        ProductClass::valid($productList, $upShopId);
-        $post['product'] = $productList;
-        $respond = PurchaseClass::addPurchase($post);
-        $orderSn = $respond['orderSn'] ?? '';
-        $actPrice = $respond['actPrice'] ?? '';
-        $data = [
-            'orderSn' => $orderSn,
-            'actPrice' => $actPrice,
-            'hasBalancePay' => 1,
-            'hasPayPassword' => 0,
-            'hasDebtPay' => 1,
-        ];
-        util::success($data);
-    }
-
-    //延期支付 shish 2021.1.24
-    public function actionDebtPay()
-    {
-        $get = Yii::$app->request->get();
-        $id = $get['id'] ?? 0;
-        $info = PurchaseClass::getInfo($id);
-        PurchaseClass::valid($info, $this->shopId);
-        PurchaseClass::debt($info);
-        util::complete();
-    }
-
-    //余额支付 shish 2021.1.24
-    public function actionBalancePay()
-    {
-        $get = Yii::$app->request->get();
-        $id = $get['id'] ?? 0;
-        $password = $get['password'] ?? '';
-        $info = PurchaseClass::getInfo($id);
-        PurchaseClass::valid($info, $this->shopId);
-        purchaseClass::balancePay($info);
-        util::complete();
-    }
-
-    //采购记录 shish 2021.1.24
-    public function actionList()
-    {
-        $get = Yii::$app->request->get();
-        $where = ['merchantId' => $this->merchantId];
-        $status = $get['status'] ?? 0;
-        if (!empty($status)) {
-            $where['status'] = $status;
-        }
-        $list = PurchaseService::getPurchaseList($where);
-        util::success($list);
-    }
-
-    //采购详情 shish 2021.01.25
-    public function actionDetail()
-    {
-        $get = Yii::$app->request->get();
-        $id = $get['id'] ?? 0;
-        $info = PurchaseClass::getInfo($id, true, true, true);
-        PurchaseClass::valid($info, $this->shopId);
-        util::success($info);
-    }
-
-    //可用的支付方式 shish 2021.1.25
-    public function actionPayWay()
-    {
-        $button = [
-            ['type' => 'wxPay', 'show' => 1, 'disable' => 1],
-            ['type' => 'debtPay', 'show' => 1, 'disable' => 0],
-            ['type' => 'balancePay', 'show' => 1, 'disable' => 0],
-        ];
-        util::success(['button' => $button]);
-    }
-    
 }

+ 7 - 0
biz/purchase/classes/PurchaseClass.php

@@ -23,6 +23,13 @@ class PurchaseClass extends BaseClass
     const STATUS_SENDING = 3;
     const STATUS_COMPLETE = 4;
 
+    //未知
+    const DEBT_UNKNOWN = 0;
+    //欠款
+	const DEBT_YES = 1;
+	//没有欠款
+	const DEBT_NO = 2;
+
     //添加采购 shish 2021.1.18
     public static function addPurchase($data)
     {

+ 25 - 0
biz/purchase/classes/PurchaseClearClass.php

@@ -0,0 +1,25 @@
+<?php
+
+namespace biz\purchase\classes;
+
+use biz\merchant\classes\ShopClass;
+use biz\order\classes\OrderClass;
+use bizGhs\admin\classes\AdminClass;
+use bizGhs\merchant\classes\SupplierClass;
+use common\components\orderSn;
+use common\components\stringUtil;
+use common\components\util;
+use Yii;
+use biz\base\classes\BaseClass;
+
+class PurchaseClearClass extends BaseClass
+{
+	
+	public static $baseFile = '\biz\purchase\models\PurchaseClear';
+	
+	public static function addClear($data)
+	{
+		return ['orderSn' => 'PC_CS154836', 'actPrice' => 0.01];
+	}
+	
+}

+ 14 - 0
biz/purchase/classes/PurchaseClearSnClass.php

@@ -0,0 +1,14 @@
+<?php
+
+namespace biz\purchase\classes;
+
+use common\components\stringUtil;
+use Yii;
+use biz\base\classes\BaseClass;
+
+class PurchaseClearSnClass extends BaseClass
+{
+	
+	public static $baseFile = '\biz\purchase\models\PurchaseClearSn';
+	
+}

+ 15 - 0
biz/purchase/models/PurchaseClear.php

@@ -0,0 +1,15 @@
+<?php
+
+namespace biz\purchase\models;
+
+use biz\base\models\Base;
+
+class PurchaseClear extends Base
+{
+	
+	public static function tableName()
+	{
+		return 'xhPurchaseClear';
+	}
+	
+}

+ 15 - 0
biz/purchase/models/PurchaseClearSn.php

@@ -0,0 +1,15 @@
+<?php
+
+namespace biz\purchase\models;
+
+use biz\base\models\Base;
+
+class PurchaseClearSn extends Base
+{
+	
+	public static function tableName()
+	{
+		return 'xhPurchaseClearSn';
+	}
+	
+}

+ 16 - 0
biz/purchase/services/PurchaseClearService.php

@@ -0,0 +1,16 @@
+<?php
+
+namespace biz\purchase\services;
+
+use biz\base\services\BaseService;
+use biz\purchase\classes\PurchaseClass;
+use bizGhs\admin\classes\AdminClass;
+use bizGhs\merchant\classes\SupplierClass;
+use Yii;
+
+class PurchaseClearService extends BaseService
+{
+
+	public static $baseFile = '\biz\purchase\classes\PurchaseClearClass';
+
+}

+ 48 - 40
biz/purchase/services/PurchaseService.php

@@ -10,44 +10,52 @@ use Yii;
 
 class PurchaseService extends BaseService
 {
-
-    public static $baseFile = '\biz\purchase\classes\PurchaseClass';
-
-    //采购记录 shish 2021.1.24
-    public static function getPurchaseList($where)
-    {
-        $data = PurchaseClass::getList('*', $where, 'addTime DESC');
-        $data['list'] = self::groupInfo($data['list']);
-        $data['allNum'] = 0;
-        $data['unPayNum'] = 0;
-        $data['unSendNum'] = 0;
-        $data['sendingNum'] = 0;
-        $data['finishNum'] = 0;
-        $data['debtNum'] = 0;
-        return $data;
-    }
-
-    //组合信息 shish 2021.1.25
-    public static function groupInfo($list)
-    {
-        if (empty($list)) {
-            return $list;
-        }
-
-        $supplierIds = array_unique(array_filter(array_column($list, 'supplierId')));
-        $supplierInfo = SupplierClass::getSupplierByIds($supplierIds);
-
-        $adminIds = array_unique(array_filter(array_column($list, 'adminId')));
-        $adminInfo = AdminClass::getAdminByIds($adminIds);
-
-        foreach ($list as $key => $val) {
-            $supplierId = $val['supplierId'];
-            $list[$key]['supplierName'] = $supplierInfo[$supplierId]['name'] ?? '';
-            $list[$key]['supplierAvatar'] = $supplierInfo[$supplierId]['logoUrl'] ?? Yii::$app->params['imgHost'] . '/hhb_small.png';
-            $adminId = $val['adminId'] ?? 0;
-            $list[$key]['adminName'] = $adminInfo[$adminId]['adminName'] ?? '';
-        }
-        return $list;
-    }
-
+	
+	public static $baseFile = '\biz\purchase\classes\PurchaseClass';
+	
+	//采购记录 shish 2021.1.24
+	public static function getPurchaseList($where)
+	{
+		$data = PurchaseClass::getList('*', $where, 'addTime DESC');
+		$data['list'] = self::groupInfo($data['list']);
+		$data['allNum'] = 0;
+		$data['unPayNum'] = 0;
+		$data['unSendNum'] = 0;
+		$data['sendingNum'] = 0;
+		$data['finishNum'] = 0;
+		$data['debtNum'] = 0;
+		return $data;
+	}
+	
+	//组合信息 shish 2021.1.25
+	public static function groupInfo($list)
+	{
+		if (empty($list)) {
+			return $list;
+		}
+		
+		$supplierIds = array_unique(array_filter(array_column($list, 'supplierId')));
+		$supplierInfo = SupplierClass::getSupplierByIds($supplierIds);
+		
+		$adminIds = array_unique(array_filter(array_column($list, 'adminId')));
+		$adminInfo = AdminClass::getAdminByIds($adminIds);
+		
+		foreach ($list as $key => $val) {
+			$supplierId = $val['supplierId'];
+			$list[$key]['supplierName'] = $supplierInfo[$supplierId]['name'] ?? '';
+			$list[$key]['supplierAvatar'] = $supplierInfo[$supplierId]['logoUrl'] ?? Yii::$app->params['imgHost'] . '/hhb_small.png';
+			$adminId = $val['adminId'] ?? 0;
+			$list[$key]['adminName'] = $adminInfo[$adminId]['adminName'] ?? '';
+		}
+		return $list;
+	}
+	
+	//所有的欠款采购单 shish 2021.1.26
+	public static function getDebtList($where)
+	{
+		$list = PurchaseClass::getAllList('*', $where, 'addTime DESC');
+		$count = PurchaseClass::getCount($where);
+		return ['list' => $list, 'debtNum' => $count];
+	}
+	
 }

+ 49 - 33
common/components/orderSn.php

@@ -2,6 +2,7 @@
 
 namespace common\components;
 
+use biz\purchase\classes\PurchaseClearSnClass;
 use bizGhs\check\classes\CheckSnClass;
 use bizGhs\order\classes\OrderSnClass;
 use bizGhs\order\classes\PurchaseSnClass;
@@ -11,7 +12,7 @@ use yii\imagine\Image;
 //订单号生成 shish 2021.1.19
 class orderSn
 {
-
+	
 	//供货商订单号生成 shish 2021.1.19
 	public static function getGhsOrderSn()
 	{
@@ -26,7 +27,7 @@ class orderSn
 		}
 		return $prefix . $id;
 	}
-
+	
 	//零售商订单号生成 shish 2021.1.19
 	public static function getOrderSn()
 	{
@@ -41,7 +42,7 @@ class orderSn
 		}
 		return $prefix . $id;
 	}
-
+	
 	//供货商采购单号 shish 2021.1.19
 	public static function getGhsPurchaseSn()
 	{
@@ -56,7 +57,7 @@ class orderSn
 		}
 		return $prefix . $id;
 	}
-
+	
 	//供货商盘点单号 shish 2021.1.19
 	public static function getGhsCheckSn()
 	{
@@ -71,7 +72,7 @@ class orderSn
 		}
 		return $prefix . $id;
 	}
-
+	
 	//零售商采购单号 shish 2021.1.19
 	public static function getPurchaseSn()
 	{
@@ -87,33 +88,48 @@ class orderSn
 		return $prefix . $id;
 	}
 
-	//供货商入库订单号 linqh 2021.1.23
-    public static function getGhsStockInSn()
-    {
-        $prefix = 'RK_CS';
-        if (getenv('YII_ENV', 'local') == 'production') {
-            $prefix = 'RK';
-        }
-        $respond = \bizGhs\order\classes\StockInSnClass::add(['id' => null]);
-        $id = $respond['id'] ?? 0;
-        if (empty($id)) {
-            util::fail('入库单号没有生成');
-        }
-        return $prefix . $id;
-    }
+	//零售商采购单号 shish 2021.1.19
+	public static function getPurchaseClearSn()
+	{
+		$prefix = 'PC_CS';
+		if (getenv('YII_ENV', 'local') == 'production') {
+			$prefix = 'PC';
+		}
+		$respond = PurchaseClearSnClass::add(['id' => null]);
+		$id = $respond['id'] ?? 0;
+		if (empty($id)) {
+			util::fail('单号没有生成');
+		}
+		return $prefix . $id;
+	}
 
-    //供货商出库订单号 linqh 2021.1.23
-    public static function getGhsStockOutSn()
-    {
-        $prefix = 'CK_CS';
-        if (getenv('YII_ENV', 'local') == 'production') {
-            $prefix = 'CK';
-        }
-        $respond = \bizGhs\order\classes\StockOutSnClass::add(['id' => null]);
-        $id = $respond['id'] ?? 0;
-        if (empty($id)) {
-            util::fail('出库单号没有生成');
-        }
-        return $prefix . $id;
-    }
+	//供货商入库订单号 linqh 2021.1.23
+	public static function getGhsStockInSn()
+	{
+		$prefix = 'RK_CS';
+		if (getenv('YII_ENV', 'local') == 'production') {
+			$prefix = 'RK';
+		}
+		$respond = \bizGhs\order\classes\StockInSnClass::add(['id' => null]);
+		$id = $respond['id'] ?? 0;
+		if (empty($id)) {
+			util::fail('入库单号没有生成');
+		}
+		return $prefix . $id;
+	}
+	
+	//供货商出库订单号 linqh 2021.1.23
+	public static function getGhsStockOutSn()
+	{
+		$prefix = 'CK_CS';
+		if (getenv('YII_ENV', 'local') == 'production') {
+			$prefix = 'CK';
+		}
+		$respond = \bizGhs\order\classes\StockOutSnClass::add(['id' => null]);
+		$id = $respond['id'] ?? 0;
+		if (empty($id)) {
+			util::fail('出库单号没有生成');
+		}
+		return $prefix . $id;
+	}
 }

+ 18 - 1
sql.sql

@@ -932,4 +932,21 @@ ALTER TABLE `xhPurchase` ADD adminId INT NOT NULL DEFAULT 0 COMMENT '采购员'
 ALTER TABLE xhPurchase ADD kindNum SMALLINT NOT NULL DEFAULT 0 COMMENT '多少种' AFTER `sendCost`;
 ALTER TABLE xhSupplier ADD debt TINYINT NOT NULL DEFAULT 1 COMMENT '1没有欠款 2有欠款' AFTER `upShopId`;
 ALTER TABLE `xhSupplier` ADD debtNum SMALLINT NOT NULL DEFAULT 0 COMMENT '欠款订单数,欠款笔数' AFTER `debt`;
-ALTER TABLE xhSupplier CHANGE `upName` `name` VARCHAR(30) NOT NULL DEFAULT '' COMMENT '供货商名称';
+ALTER TABLE xhSupplier CHANGE `upName` `name` VARCHAR(30) NOT NULL DEFAULT '' COMMENT '供货商名称';
+ALTER TABLE xhPurchase MODIFY `debt` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '欠款 0未知 1是 2没有';
+DROP TABLE IF EXISTS `xhPurchaseClear`;
+CREATE TABLE IF NOT EXISTS xhPurchaseClear(
+id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+  `prePrice` decimal(9,2) NOT NULL DEFAULT '0.00' COMMENT '应付款,原价,未修改价格,打折前',
+  `actPrice` decimal(9,2) NOT NULL DEFAULT '0.00' COMMENT '实际付款,实价,修改后价格,打折后',
+orderSn CHAR(20) NOT NULL DEFAULT '' COMMENT '订单号',
+merchantId INT NOT NULL DEFAULT 0 COMMENT '商家id',
+purchaseIds TEXT 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 '修改时间'
+)COMMENT='采购单结算';
+CREATE TABLE IF EXISTS `xhPurchaseClearSn`;
+CREATE TABLE IF NOT EXISTS `xhPurchaseClearSn` (
+  `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
+  PRIMARY KEY (`id`)
+) AUTO_INCREMENT=28356251 COMMENT='结算订单号';