|
@@ -7,6 +7,7 @@ use SixShop\Balpay\Enum\BalpayLogTypeEnum;
|
|
|
use SixShop\Core\Request;
|
|
use SixShop\Core\Request;
|
|
|
use SixShop\Lakala\Entity\ProfitShareOrderEntity;
|
|
use SixShop\Lakala\Entity\ProfitShareOrderEntity;
|
|
|
use SixShop\Lakala\Enum\ProfitShareOrderStatusEnum;
|
|
use SixShop\Lakala\Enum\ProfitShareOrderStatusEnum;
|
|
|
|
|
+use SixShop\Lakala\Service\LaepIndustryService;
|
|
|
use think\Response;
|
|
use think\Response;
|
|
|
use function SixShop\Core\page_response;
|
|
use function SixShop\Core\page_response;
|
|
|
use function SixShop\Core\success_response;
|
|
use function SixShop\Core\success_response;
|
|
@@ -31,12 +32,30 @@ class ProfitShareOrderController
|
|
|
public function approve(
|
|
public function approve(
|
|
|
int $id,
|
|
int $id,
|
|
|
ProfitShareOrderEntity $profitShareOrderEntity,
|
|
ProfitShareOrderEntity $profitShareOrderEntity,
|
|
|
- ExtensionBalpayLogEntity $extensionBalpayLogEntity): Response
|
|
|
|
|
|
|
+ ExtensionBalpayLogEntity $extensionBalpayLogEntity,
|
|
|
|
|
+ LaepIndustryService $laepIndustryService
|
|
|
|
|
+ ): Response
|
|
|
{
|
|
{
|
|
|
$entity = $profitShareOrderEntity->where(['id' => $id, 'status' => ProfitShareOrderStatusEnum::PENDING])->findOrEmpty();
|
|
$entity = $profitShareOrderEntity->where(['id' => $id, 'status' => ProfitShareOrderStatusEnum::PENDING])->findOrEmpty();
|
|
|
if ($entity->isEmpty()) {
|
|
if ($entity->isEmpty()) {
|
|
|
throw_logic_exception('订单不存在或状态异常');
|
|
throw_logic_exception('订单不存在或状态异常');
|
|
|
}
|
|
}
|
|
|
|
|
+ $balance = $laepIndustryService->ewalletBalanceQuery([
|
|
|
|
|
+ 'merchantNo' => $entity->merchant_no,
|
|
|
|
|
+ 'payType' => '03',
|
|
|
|
|
+ ]);
|
|
|
|
|
+ if ($balance->acctSt != 'NORMAL') {
|
|
|
|
|
+ throw_logic_exception(match ($balance->acctSt){
|
|
|
|
|
+ 'CLOSE' => '商户已经销户',
|
|
|
|
|
+ 'FREEZE' => '商户账户被冻结',
|
|
|
|
|
+ 'STOPPAY' => '商户账户被停付',
|
|
|
|
|
+ default => '商户账户异常'
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ $curBalance = (int)round($balance->curBalance * 100,0);
|
|
|
|
|
+ if ($curBalance < $entity->total_amt) {
|
|
|
|
|
+ throw_logic_exception('商户余额不足');
|
|
|
|
|
+ }
|
|
|
$entity->status = ProfitShareOrderStatusEnum::PROCESSING;
|
|
$entity->status = ProfitShareOrderStatusEnum::PROCESSING;
|
|
|
$entity->save();
|
|
$entity->save();
|
|
|
|
|
|