|
@@ -5,6 +5,7 @@ namespace SixShop\Lakala\Entity;
|
|
|
|
|
|
|
|
use SixShop\Core\Entity\BaseEntity;
|
|
use SixShop\Core\Entity\BaseEntity;
|
|
|
use SixShop\Core\Exception\LogicException;
|
|
use SixShop\Core\Exception\LogicException;
|
|
|
|
|
+use SixShop\Lakala\Enum\ReceiverActionEnum;
|
|
|
use SixShop\Lakala\Enum\UploadFileTypeEnum;
|
|
use SixShop\Lakala\Enum\UploadFileTypeEnum;
|
|
|
use SixShop\Lakala\Facade\Config;
|
|
use SixShop\Lakala\Facade\Config;
|
|
|
use SixShop\Lakala\Enum\ProfitShareOrderStatusEnum;
|
|
use SixShop\Lakala\Enum\ProfitShareOrderStatusEnum;
|
|
@@ -31,6 +32,8 @@ class ProfitShareReceiverEntity extends BaseEntity
|
|
|
}
|
|
}
|
|
|
$entity->data($data);
|
|
$entity->data($data);
|
|
|
Db::transaction(function () use ($entity) {
|
|
Db::transaction(function () use ($entity) {
|
|
|
|
|
+ $entity->action = ReceiverActionEnum::ADD;
|
|
|
|
|
+ $entity->status = ReceiverStatusEnum::PENDING;
|
|
|
$entity->save();
|
|
$entity->save();
|
|
|
$result = MMSService::cardBin($entity->order_no, $entity->acct_no, $entity->org_code);
|
|
$result = MMSService::cardBin($entity->order_no, $entity->acct_no, $entity->org_code);
|
|
|
$entity->acct_open_bank_code = $result->bankCode;
|
|
$entity->acct_open_bank_code = $result->bankCode;
|
|
@@ -45,6 +48,7 @@ class ProfitShareReceiverEntity extends BaseEntity
|
|
|
{
|
|
{
|
|
|
return $this->withSearch(['order_no', 'status', 'user_id'], $params)
|
|
return $this->withSearch(['order_no', 'status', 'user_id'], $params)
|
|
|
->append(['action_text','status_text'])
|
|
->append(['action_text','status_text'])
|
|
|
|
|
+ ->order('id', 'desc')
|
|
|
->paginate($pageAndLimit);
|
|
->paginate($pageAndLimit);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -87,8 +91,8 @@ class ProfitShareReceiverEntity extends BaseEntity
|
|
|
public function apply(int $id): self
|
|
public function apply(int $id): self
|
|
|
{
|
|
{
|
|
|
$entity = $this->getReceiver(['id' => $id]);
|
|
$entity = $this->getReceiver(['id' => $id]);
|
|
|
- if ($entity->status != ReceiverStatusEnum::PENDING) {
|
|
|
|
|
- throw_logic_exception('待审核状态才可以申请!');
|
|
|
|
|
|
|
+ if ($entity->status != ReceiverStatusEnum::PENDING || $entity->action != ReceiverActionEnum::ADD) {
|
|
|
|
|
+ throw_logic_exception('待审核状态新增记录才可以申请!');
|
|
|
}
|
|
}
|
|
|
$reqData = [
|
|
$reqData = [
|
|
|
'orderNo' => $entity->order_no,
|
|
'orderNo' => $entity->order_no,
|
|
@@ -165,4 +169,28 @@ class ProfitShareReceiverEntity extends BaseEntity
|
|
|
$entity->save();
|
|
$entity->save();
|
|
|
return $entity;
|
|
return $entity;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ public function updateReceiver(array $params, array $data):self
|
|
|
|
|
+ {
|
|
|
|
|
+ /* @var self $entity */
|
|
|
|
|
+ $entity = $this->where($params)->findOrEmpty();
|
|
|
|
|
+ if ($entity->isEmpty()) {
|
|
|
|
|
+ throw_logic_exception('分账接收方申请记录不存在!');
|
|
|
|
|
+ }
|
|
|
|
|
+ $saveData = $entity->toArray();
|
|
|
|
|
+ unset($saveData['id'], $saveData['order_no'], $saveData['create_time']);
|
|
|
|
|
+ $saveData = array_merge($saveData, $data);
|
|
|
|
|
+ $this->data($saveData);
|
|
|
|
|
+ Db::transaction(function () use ($entity) {
|
|
|
|
|
+ $this->action = ReceiverActionEnum::UPDATE;
|
|
|
|
|
+ $this->status = ReceiverStatusEnum::PENDING;
|
|
|
|
|
+ $this->save();
|
|
|
|
|
+ $result = MMSService::cardBin($this->order_no, $this->acct_no, $this->org_code);
|
|
|
|
|
+ $this->acct_open_bank_code = $result->bankCode;
|
|
|
|
|
+ $this->acct_clear_bank_code = $result->clearingBankCode;
|
|
|
|
|
+ $this->fail_reason = '';
|
|
|
|
|
+ $this->save();
|
|
|
|
|
+ });
|
|
|
|
|
+ return $this;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|