|
|
@@ -3,12 +3,11 @@
|
|
|
namespace bizHd\purchase\classes;
|
|
|
|
|
|
use biz\ghs\classes\GhsClass;
|
|
|
-use biz\shop\classes\ShopClass;
|
|
|
+use biz\ghs\models\Ghs;
|
|
|
+use biz\shop\models\Shop;
|
|
|
use bizGhs\admin\classes\AdminClass;
|
|
|
-use bizGhs\custom\classes\CustomClass;
|
|
|
-use biz\sj\classes\MerchantClass;
|
|
|
+use bizGhs\order\classes\OrderClass;
|
|
|
use common\components\orderSn;
|
|
|
-use common\components\stringUtil;
|
|
|
use common\components\util;
|
|
|
use Yii;
|
|
|
use bizHd\base\classes\BaseClass;
|
|
|
@@ -59,6 +58,7 @@ class PurchaseClass extends BaseClass
|
|
|
$sjId = $ghs['sjId'] ?? 0;
|
|
|
$shopId = $ghs['shopId'];
|
|
|
$getType = $data['getType'];
|
|
|
+ $cgId = $respond['id'] ?? 0;
|
|
|
$orderData = [
|
|
|
'prePrice' => 0.01,
|
|
|
'actPrice' => 0.01,
|
|
|
@@ -67,9 +67,10 @@ class PurchaseClass extends BaseClass
|
|
|
'product' => $productList,
|
|
|
'merchantId' => $sjId,
|
|
|
'sendType' => $getType,
|
|
|
+ 'cgId' => $cgId,
|
|
|
];
|
|
|
|
|
|
- \bizGhs\order\classes\OrderClass::addOrder($orderData, $shopId, true);
|
|
|
+ OrderClass::addOrder($orderData, $shopId, true);
|
|
|
|
|
|
return $respond;
|
|
|
}
|
|
|
@@ -130,14 +131,95 @@ class PurchaseClass extends BaseClass
|
|
|
public static function debt($info)
|
|
|
{
|
|
|
if (isset($info['status']) == false || $info['status'] != self::STATUS_UN_PAY) {
|
|
|
- util::fail('请确认订单状态');
|
|
|
+ util::fail('订单不是待付款状态');
|
|
|
}
|
|
|
+ $id = $info['id'] ?? 0;
|
|
|
+ $data = [
|
|
|
+ 'status' => self::STATUS_UN_SEND,
|
|
|
+ 'debt' => 1,
|
|
|
+ ];
|
|
|
+ self::updateById($id, $data);
|
|
|
+
|
|
|
+ $shopId = $info['shopId'] ?? 0;
|
|
|
+ $shop = Shop::findBySql('select * from ' . Shop::tableName() . ' where id = :id for update', ['id' => $shopId])->one();
|
|
|
+ if (empty($shop)) {
|
|
|
+ util::fail('没有找到门店');
|
|
|
+ }
|
|
|
+ $actPrice = $info['actPrice'];
|
|
|
+ $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('没有找到供货商');
|
|
|
+ }
|
|
|
+ $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();
|
|
|
+
|
|
|
+ $cgId = $info['cgId'] ?? 0;
|
|
|
+ $cg = OrderClass::getById($cgId, true);
|
|
|
+ if (empty($cg)) {
|
|
|
+ util::fail('没有找到对应供货商订单');
|
|
|
+ }
|
|
|
+ $cg->status = OrderClass::ORDER_STATUS_UN_SEND;
|
|
|
+ $cg->save();
|
|
|
+ $shopId = $cg->shopId;
|
|
|
+ $actPrice = $cg->actPrice;
|
|
|
+ $shop = Shop::findBySql('select * from ' . Shop::tableName() . ' where id = :id for update', ['id' => $shopId])->one();
|
|
|
+ $shop->totalIncome = bcadd($shop->totalIncome, $actPrice, 2);
|
|
|
+ $shop->totalOrderNum += 1;
|
|
|
+ $shop->save();
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//余额支付 ssh 2021.1.24
|
|
|
public static function balancePay($info)
|
|
|
{
|
|
|
+ if (isset($info['status']) == false || $info['status'] != self::STATUS_UN_PAY) {
|
|
|
+ util::fail('订单不是待付款状态');
|
|
|
+ }
|
|
|
+ $id = $info['id'] ?? 0;
|
|
|
+ $data = [
|
|
|
+ 'status' => self::STATUS_UN_SEND,
|
|
|
+ ];
|
|
|
+ self::updateById($id, $data);
|
|
|
|
|
|
+ $shopId = $info['shopId'] ?? 0;
|
|
|
+ $shop = Shop::findBySql('select * from ' . Shop::tableName() . ' where id = :id for update', ['id' => $shopId])->one();
|
|
|
+ if (empty($shop)) {
|
|
|
+ util::fail('没有找到门店');
|
|
|
+ }
|
|
|
+ $actPrice = $info['actPrice'];
|
|
|
+ $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('没有找到供货商');
|
|
|
+ }
|
|
|
+ $ghs->expendAmount = bcadd($ghs->expendAmount, $actPrice, 2);
|
|
|
+ $ghs->expendNum += 1;
|
|
|
+ $ghs->save();
|
|
|
+
|
|
|
+ $cgId = $info['cgId'] ?? 0;
|
|
|
+ $cg = OrderClass::getById($cgId, true);
|
|
|
+ if (empty($cg)) {
|
|
|
+ util::fail('没有找到对应供货商订单');
|
|
|
+ }
|
|
|
+ $cg->status = OrderClass::ORDER_STATUS_UN_SEND;
|
|
|
+ $cg->save();
|
|
|
+ $shopId = $cg->shopId;
|
|
|
+ $actPrice = $cg->actPrice;
|
|
|
+ $shop = Shop::findBySql('select * from ' . Shop::tableName() . ' where id = :id for update', ['id' => $shopId])->one();
|
|
|
+ $shop->totalIncome = bcadd($shop->totalIncome, $actPrice, 2);
|
|
|
+ $shop->totalOrderNum += 1;
|
|
|
+ $shop->save();
|
|
|
}
|
|
|
|
|
|
//检查采购单
|