|
|
@@ -5,7 +5,8 @@ namespace SixShop\Lakala\Entity;
|
|
|
|
|
|
use SixShop\Core\Entity\BaseEntity;
|
|
|
use SixShop\Core\Exception\LogicException;
|
|
|
-use SixShop\Lakala\Config;
|
|
|
+use SixShop\Lakala\Enum\UploadFileTypeEnum;
|
|
|
+use SixShop\Lakala\Facade\Config;
|
|
|
use SixShop\Lakala\Enum\ProfitShareOrderStatusEnum;
|
|
|
use SixShop\Lakala\Enum\ReceiverStatusEnum;
|
|
|
use SixShop\Lakala\Facade\LedgerService;
|
|
|
@@ -70,7 +71,7 @@ class ProfitShareReceiverEntity extends BaseEntity
|
|
|
{
|
|
|
$entity = $this->getReceiver(['id' => $id]);
|
|
|
if ($entity->status != ReceiverStatusEnum::PENDING) {
|
|
|
- throw_logic_exception('请不要重复提交申请!');
|
|
|
+ throw_logic_exception('待审核状态才可以申请!');
|
|
|
}
|
|
|
$reqData = [
|
|
|
'orderNo' => $entity->order_no,
|
|
|
@@ -106,4 +107,37 @@ class ProfitShareReceiverEntity extends BaseEntity
|
|
|
$entity->save();
|
|
|
return $entity;
|
|
|
}
|
|
|
+
|
|
|
+ public function bind(int $id):self
|
|
|
+ {
|
|
|
+ $entity = $this->getReceiver(['id' => $id]);
|
|
|
+ if ($entity->status != ReceiverStatusEnum::VERIFIED) {
|
|
|
+ throw_logic_exception('验证通过状态才可以绑定!');
|
|
|
+ }
|
|
|
+ if (!$entity->entrust_file_path) {
|
|
|
+ if (!$entity->entrust_local_path) {
|
|
|
+ // 添加默认合作协议
|
|
|
+ $defaultReceiverAgreementFile = Config::getConfig('receiver_agreement_file');
|
|
|
+ if (!$defaultReceiverAgreementFile) {
|
|
|
+ throw_logic_exception('请先添加默认合作协议!');
|
|
|
+ }
|
|
|
+ $entity->entrust_local_path = Config::getConfig('receiver_agreement_file')[0];
|
|
|
+ $entity->save();
|
|
|
+ }
|
|
|
+ // 上传协议文件
|
|
|
+ $entrustLocalPath = public_path().$entity->entrust_local_path;
|
|
|
+ $pathInfo = pathinfo($entrustLocalPath);
|
|
|
+ $response = MMSService::uploadFile(
|
|
|
+ orderNo: $entity->order_no,
|
|
|
+ attType: UploadFileTypeEnum::SPLIT_COOPERATION_FILE,
|
|
|
+ attExtName : $pathInfo['extension'],
|
|
|
+ fileContent: file_get_contents($entrustLocalPath),
|
|
|
+ );
|
|
|
+ $entity->entrust_file_name = '合作协议'.$pathInfo['extension'];
|
|
|
+ $entity->entrust_file_path = $response->attFileId;
|
|
|
+ $entity->save();
|
|
|
+ }
|
|
|
+ // todo 绑定申请
|
|
|
+ return $entity;
|
|
|
+ }
|
|
|
}
|