|
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
|
|
namespace SixShop\Lakala\Entity;
|
|
namespace SixShop\Lakala\Entity;
|
|
|
|
|
|
|
|
use SixShop\Core\Entity\BaseEntity;
|
|
use SixShop\Core\Entity\BaseEntity;
|
|
|
|
|
+use SixShop\Core\Exception\LogicException;
|
|
|
use SixShop\Lakala\Config;
|
|
use SixShop\Lakala\Config;
|
|
|
use SixShop\Lakala\Enum\ProfitShareOrderStatusEnum;
|
|
use SixShop\Lakala\Enum\ProfitShareOrderStatusEnum;
|
|
|
use SixShop\Lakala\Enum\ReceiverStatusEnum;
|
|
use SixShop\Lakala\Enum\ReceiverStatusEnum;
|
|
@@ -48,13 +49,21 @@ class ProfitShareReceiverEntity extends BaseEntity
|
|
|
|
|
|
|
|
public function getReceiver(array $params):self
|
|
public function getReceiver(array $params):self
|
|
|
{
|
|
{
|
|
|
- $result = $this->where($params)
|
|
|
|
|
|
|
+ $entity = $this->where($params)
|
|
|
->append(['status_text'])
|
|
->append(['status_text'])
|
|
|
->findOrEmpty();
|
|
->findOrEmpty();
|
|
|
- if ($result->isEmpty()) {
|
|
|
|
|
|
|
+ if ($entity->isEmpty()) {
|
|
|
throw_logic_exception('分账接收方申请记录不存在!');
|
|
throw_logic_exception('分账接收方申请记录不存在!');
|
|
|
}
|
|
}
|
|
|
- return $result;
|
|
|
|
|
|
|
+ if ($entity->receiver_no && $entity->status == ReceiverStatusEnum::SUBMITTING) {
|
|
|
|
|
+ $response = LedgerService::queryReceiverDetail($entity->order_no, $entity->receiver_no);
|
|
|
|
|
+ if ($response->rowStatus == 'VALID') {
|
|
|
|
|
+ $entity->status = ReceiverStatusEnum::VERIFIED;
|
|
|
|
|
+ $entity->wallet_id = $response->walletId;
|
|
|
|
|
+ }
|
|
|
|
|
+ $entity->save();
|
|
|
|
|
+ }
|
|
|
|
|
+ return $entity;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function apply(int $id):self
|
|
public function apply(int $id):self
|
|
@@ -77,7 +86,19 @@ class ProfitShareReceiverEntity extends BaseEntity
|
|
|
'acctOpenBankName' => $entity->acct_open_bank_name,
|
|
'acctOpenBankName' => $entity->acct_open_bank_name,
|
|
|
'acctClearBankCode' => $entity->acct_clear_bank_code,
|
|
'acctClearBankCode' => $entity->acct_clear_bank_code,
|
|
|
];
|
|
];
|
|
|
- $response = LedgerService::applyLedgerReceiver($reqData);
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ $response = LedgerService::applyLedgerReceiver($reqData);
|
|
|
|
|
+ } catch (LogicException $e) {
|
|
|
|
|
+ if ($e->getResponse()->getData()['code'] == 103001) {
|
|
|
|
|
+ // 系统异常,请稍后重试
|
|
|
|
|
+ // 创建新的申请记录
|
|
|
|
|
+ $newEntity = $entity->clone()->toArray();
|
|
|
|
|
+ unset($newEntity['id'],$newEntity['order_no']);
|
|
|
|
|
+ $this->save($newEntity);
|
|
|
|
|
+ $entity->delete();
|
|
|
|
|
+ }
|
|
|
|
|
+ throw $e;
|
|
|
|
|
+ }
|
|
|
$entity->org_id = $response->orgId;
|
|
$entity->org_id = $response->orgId;
|
|
|
$entity->org_name = $response->orgName;
|
|
$entity->org_name = $response->orgName;
|
|
|
$entity->receiver_no = $response->receiverNo;
|
|
$entity->receiver_no = $response->receiverNo;
|