|
|
@@ -3,6 +3,8 @@ declare(strict_types=1);
|
|
|
|
|
|
namespace SixShop\Lakala\Entity;
|
|
|
|
|
|
+use SixShop\Balpay\Entity\ExtensionBalpayLogEntity;
|
|
|
+use SixShop\Balpay\Enum\BalpayLogTypeEnum;
|
|
|
use SixShop\Core\Entity\BaseEntity;
|
|
|
use SixShop\Lakala\Enum\ProfitShareOrderCMDTypeEnum;
|
|
|
use SixShop\Lakala\Enum\ProfitShareOrderStatusEnum;
|
|
|
@@ -115,7 +117,7 @@ class ProfitShareOrderEntity extends BaseEntity
|
|
|
|
|
|
public function queryProfitShareOrderResult(int $id): self
|
|
|
{
|
|
|
- $entity = $this->findOrEmpty($id);
|
|
|
+ $entity = $this->lock(true)->find($id);
|
|
|
if ($entity->isEmpty()) {
|
|
|
throw_logic_exception('分账订单不存在');
|
|
|
}
|
|
|
@@ -131,7 +133,11 @@ class ProfitShareOrderEntity extends BaseEntity
|
|
|
default => throw_logic_exception('分账状态异常')
|
|
|
};
|
|
|
$resData->acc_result_desc && $entity->fail_reason = $resData->acc_result_desc;
|
|
|
- $entity->save();
|
|
|
+ if ($entity->status == ProfitShareOrderStatusEnum::FAIL) {
|
|
|
+ $amount = bcadd((string)$entity->separate_value, (string)$entity->fee_amt, 2);
|
|
|
+ $amount = bcdiv($amount, '100', 2);
|
|
|
+ app()->make(ExtensionBalpayLogEntity::class)->change($entity->user_id, (float)$amount, BalpayLogTypeEnum::RECHARGE, '分账失败退回', $entity->id);
|
|
|
+ }
|
|
|
}
|
|
|
return $entity;
|
|
|
}
|