|
|
@@ -2,24 +2,51 @@
|
|
|
declare(strict_types=1);
|
|
|
namespace SixShop\Lakala\Controller\Admin;
|
|
|
|
|
|
+use SixShop\Balpay\Entity\ExtensionBalpayLogEntity;
|
|
|
+use SixShop\Balpay\Enum\BalpayLogTypeEnum;
|
|
|
use SixShop\Core\Request;
|
|
|
use SixShop\Lakala\Entity\ProfitShareOrderEntity;
|
|
|
+use SixShop\Lakala\Enum\ProfitShareOrderStatusEnum;
|
|
|
use think\Response;
|
|
|
use function SixShop\Core\page_response;
|
|
|
+use function SixShop\Core\success_response;
|
|
|
+use function SixShop\Core\throw_logic_exception;
|
|
|
|
|
|
class ProfitShareOrderController
|
|
|
{
|
|
|
- public function index(Request $request, ProfitShareOrderEntity $entity): Response
|
|
|
+ public function index(Request $request, ProfitShareOrderEntity $profitShareOrderEntity): Response
|
|
|
{
|
|
|
$params = $request->get([
|
|
|
'status/s',
|
|
|
'out_separate_no/s',
|
|
|
]);
|
|
|
return page_response(
|
|
|
- page: $entity->getOrderList($params, $request->pageAndLimit()),
|
|
|
+ page: $profitShareOrderEntity->getOrderList($params, $request->pageAndLimit()),
|
|
|
data: [
|
|
|
- 'stats' => $entity->getStats(),
|
|
|
+ 'stats' => $profitShareOrderEntity->getStats(),
|
|
|
]
|
|
|
);
|
|
|
}
|
|
|
+
|
|
|
+ public function reject(
|
|
|
+ int $id,
|
|
|
+ Request $request,
|
|
|
+ ProfitShareOrderEntity $profitShareOrderEntity,
|
|
|
+ ExtensionBalpayLogEntity $extensionBalpayLogEntity): Response
|
|
|
+ {
|
|
|
+ $reason = $request->put('reason/s');
|
|
|
+ $entity = $profitShareOrderEntity->where(['id' => $id, 'status' => ProfitShareOrderStatusEnum::PENDING])->findOrEmpty();
|
|
|
+ if ($entity->isEmpty()) {
|
|
|
+ throw_logic_exception('订单不存在或状态异常');
|
|
|
+ }
|
|
|
+ $profitShareOrderEntity->transaction(function () use ($entity, $extensionBalpayLogEntity, $id, $reason){
|
|
|
+ $entity->status = ProfitShareOrderStatusEnum::FAIL;
|
|
|
+ $entity->fail_reason = $reason;
|
|
|
+ $entity->save();
|
|
|
+ $amount = bcadd((string)$entity->separate_value, (string)$entity->fee_amt, 2);
|
|
|
+ $amount = bcdiv($amount, '100', 2);
|
|
|
+ $extensionBalpayLogEntity->change($entity->user_id, (float)$amount, BalpayLogTypeEnum::RECHARGE, '分账失败退回', $entity->id);
|
|
|
+ });
|
|
|
+ return success_response($entity);
|
|
|
+ }
|
|
|
}
|