|
|
@@ -5,9 +5,12 @@ namespace SixShop\Lakala\Controller\Admin;
|
|
|
use SixShop\Balpay\Entity\ExtensionBalpayLogEntity;
|
|
|
use SixShop\Balpay\Enum\BalpayLogTypeEnum;
|
|
|
use SixShop\Core\Request;
|
|
|
+use SixShop\Lakala\Config;
|
|
|
use SixShop\Lakala\Entity\ProfitShareOrderEntity;
|
|
|
use SixShop\Lakala\Enum\ProfitShareOrderStatusEnum;
|
|
|
use SixShop\Lakala\Service\LaepIndustryService;
|
|
|
+use SixShop\Lakala\Service\SACSService;
|
|
|
+use think\facade\Db;
|
|
|
use think\Response;
|
|
|
use function SixShop\Core\page_response;
|
|
|
use function SixShop\Core\success_response;
|
|
|
@@ -39,8 +42,9 @@ class ProfitShareOrderController
|
|
|
public function approve(
|
|
|
int $id,
|
|
|
ProfitShareOrderEntity $profitShareOrderEntity,
|
|
|
- ExtensionBalpayLogEntity $extensionBalpayLogEntity,
|
|
|
- LaepIndustryService $laepIndustryService
|
|
|
+ LaepIndustryService $laepIndustryService,
|
|
|
+ SACSService $sacsService,
|
|
|
+ Config $config,
|
|
|
): Response
|
|
|
{
|
|
|
$entity = $profitShareOrderEntity->where(['id' => $id, 'status' => ProfitShareOrderStatusEnum::PENDING])->findOrEmpty();
|
|
|
@@ -59,12 +63,30 @@ class ProfitShareOrderController
|
|
|
default => '商户账户异常'
|
|
|
});
|
|
|
}
|
|
|
+ // 只分给分账接收方
|
|
|
$curBalance = (int)round($balance->curBalance * 100,0);
|
|
|
- if ($curBalance < $entity->total_amt) {
|
|
|
- throw_logic_exception('商户余额不足');
|
|
|
+ if ($curBalance < $entity->separate_value) {
|
|
|
+ throw_logic_exception('分账商户余额不足');
|
|
|
}
|
|
|
- $entity->status = ProfitShareOrderStatusEnum::PROCESSING;
|
|
|
- $entity->save();
|
|
|
+ Db::transaction(function () use ($entity, $sacsService, $config){
|
|
|
+ $response = $sacsService->balanceSeparate([
|
|
|
+ 'merchant_no' => $entity->merchant_no,
|
|
|
+ 'out_separate_no' => $entity->out_separate_no,
|
|
|
+ 'total_amt' => $entity->separate_value,
|
|
|
+ 'lkl_org_no' => $entity->lkl_org_no,
|
|
|
+ 'cal_type' => '0', // 分账计算类型 0- 按照指定金额,1- 按照指定比例
|
|
|
+ 'notify_url' => $config->notify_url,
|
|
|
+ 'recv_datas' => [
|
|
|
+ [
|
|
|
+ 'recv_no' => $entity->recv_no,
|
|
|
+ 'separate_value' => $entity->separate_value,
|
|
|
+ ]
|
|
|
+ ]
|
|
|
+ ]);
|
|
|
+ $entity->separate_no = $response->separate_no;
|
|
|
+ $entity->status = ProfitShareOrderStatusEnum::PROCESSING;
|
|
|
+ $entity->save();
|
|
|
+ });
|
|
|
|
|
|
return success_response($entity);
|
|
|
}
|