|
|
@@ -7,6 +7,7 @@ use biz\ghs\models\Ghs;
|
|
|
use biz\shop\models\Shop;
|
|
|
use bizGhs\admin\classes\AdminClass;
|
|
|
use bizGhs\order\classes\OrderClass;
|
|
|
+use common\components\dict;
|
|
|
use common\components\orderSn;
|
|
|
use common\components\util;
|
|
|
use bizHd\base\classes\BaseClass;
|
|
|
@@ -131,95 +132,93 @@ class PurchaseClass extends BaseClass
|
|
|
//订单延期支付 ssh 2021.1.24
|
|
|
public static function debt($info)
|
|
|
{
|
|
|
- if (isset($info['status']) == false || $info['status'] != self::STATUS_UN_PAY) {
|
|
|
- util::fail('订单不是待付款状态');
|
|
|
- }
|
|
|
- $id = $info['id'] ?? 0;
|
|
|
- $data = [
|
|
|
- 'status' => self::STATUS_UN_SEND,
|
|
|
- 'debt' => 1,
|
|
|
- ];
|
|
|
- self::updateById($id, $data);
|
|
|
+ $payWay = dict::getDict('payWay', 'debtPay');
|
|
|
+ self::complete($info, $payWay);
|
|
|
+ }
|
|
|
|
|
|
- $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();
|
|
|
+ //余额支付 ssh 2021.1.24
|
|
|
+ public static function balancePay($info)
|
|
|
+ {
|
|
|
+ $payWay = dict::getDict('payWay', 'balancePay');
|
|
|
+ self::complete($info, $payWay);
|
|
|
+ }
|
|
|
|
|
|
- $ghsOrderId = $info['ghsOrderId'] ?? 0;
|
|
|
- $cg = OrderClass::getById($ghsOrderId, true);
|
|
|
- if (empty($cg)) {
|
|
|
- util::fail('没有找到对应供货商订单');
|
|
|
+ //检查采购单
|
|
|
+ public static function valid($info, $shopId)
|
|
|
+ {
|
|
|
+ if (empty($info)) {
|
|
|
+ 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();
|
|
|
- if (empty($shop)) {
|
|
|
- util::fail('没有找到供货商门店');
|
|
|
+ if (isset($info->shopId) && $info->shopId == $shopId) {
|
|
|
+ return true;
|
|
|
}
|
|
|
- $shop->totalIncome = bcadd($shop->totalIncome, $actPrice, 2);
|
|
|
- $shop->totalOrderNum += 1;
|
|
|
- $shop->save();
|
|
|
+ util::fail('没有权限操作');
|
|
|
+ }
|
|
|
|
|
|
+ //采购订单支付成功后回调处理流程
|
|
|
+ public static function thirdPay($payWay, $orderSn, $totalFee, $attach)
|
|
|
+ {
|
|
|
+ $info = self::getByCondition(['orderSn' => $orderSn], true);
|
|
|
+ if (empty($info)) {
|
|
|
+ util::fail('没有找到订单');
|
|
|
+ }
|
|
|
+ $info->actPirce
|
|
|
+ self::complete($info, $payWay);
|
|
|
}
|
|
|
|
|
|
- //余额支付 ssh 2021.1.24
|
|
|
- public static function balancePay($info)
|
|
|
+ //第三方支付、余额支付和欠款支付后调用的流程 shish 2021.4.27
|
|
|
+ public static function complete($info, $payWay)
|
|
|
{
|
|
|
- if (isset($info['status']) == false || $info['status'] != self::STATUS_UN_PAY) {
|
|
|
+ if (empty($info)) {
|
|
|
+ util::fail('没有找到订单');
|
|
|
+ }
|
|
|
+ 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);
|
|
|
+ $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)) {
|
|
|
util::fail('没有找到门店');
|
|
|
}
|
|
|
- $actPrice = $info['actPrice'];
|
|
|
+ $actPrice = $info->actPrice;
|
|
|
$shop->totalPurchase = bcadd($shop->totalPurchase, $actPrice, 2);
|
|
|
$shop->totalPurchaseOrder += 1;
|
|
|
$shop->save();
|
|
|
- $ghsId = $info['ghsId'] ?? 0;
|
|
|
+ $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;
|
|
|
- $cg = OrderClass::getById($ghsOrderId, true);
|
|
|
- if (empty($cg)) {
|
|
|
+ $ghsOrderId = $info->ghsOrderId ?? 0;
|
|
|
+ $ghsOrder = OrderClass::getById($ghsOrderId, true);
|
|
|
+ if (empty($ghsOrder)) {
|
|
|
util::fail('没有找到对应供货商订单');
|
|
|
}
|
|
|
- $cg->status = OrderClass::ORDER_STATUS_UN_SEND;
|
|
|
- $cg->save();
|
|
|
- $shopId = $cg->shopId;
|
|
|
- $actPrice = $cg->actPrice;
|
|
|
+ $ghsOrder->status = OrderClass::ORDER_STATUS_UN_SEND;
|
|
|
+ $ghsOrder->save();
|
|
|
+ $shopId = $ghsOrder->shopId;
|
|
|
+ $actPrice = $ghsOrder->actPrice;
|
|
|
$shop = Shop::findBySql('select * from ' . Shop::tableName() . ' where id = :id for update', ['id' => $shopId])->one();
|
|
|
if (empty($shop)) {
|
|
|
util::fail('没有找到供货商门店');
|
|
|
@@ -229,22 +228,4 @@ class PurchaseClass extends BaseClass
|
|
|
$shop->save();
|
|
|
}
|
|
|
|
|
|
- //检查采购单
|
|
|
- public static function valid($info, $shopId)
|
|
|
- {
|
|
|
- if (empty($info)) {
|
|
|
- util::fail('没有找到采购单');
|
|
|
- }
|
|
|
- if (isset($info['shopId']) && $info['shopId'] == $shopId) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- util::fail('没有权限操作');
|
|
|
- }
|
|
|
-
|
|
|
- //采购订单支付成功后回调处理流程
|
|
|
- public static function complete($purchase)
|
|
|
- {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
}
|