feat : refund

This commit is contained in:
2025-03-27 10:58:00 +08:00
parent 7f4d6ca0d0
commit c4bc83f9e2
5 changed files with 16 additions and 12 deletions

View File

@@ -69,6 +69,7 @@ class RefundOrderConsumer extends ConsumerMessage
$service->orderId = (int)$data['order_id'];
$service->reason = $data['reason'];
$service->type = $data['type'];
$service->adminId = $data['admin_id'] ?? 0;
$service->handle();
} catch (Exception $e) {

View File

@@ -40,6 +40,7 @@ class RefundService extends BaseService
$service->orderId = $orderId;
$service->reason = $this->request->input('reason','');
$service->type = RefundCode::FULL_GOOD_REFUND;
$service->adminId = $this->adminId;
$service->handle();
@@ -66,6 +67,7 @@ class RefundService extends BaseService
$service->reason = $this->request->input('reason','');
$service->orderGoodIds = $orderGoodIds;
$service->type = RefundCode::PARTIAL_GOOD_REFUND;
$service->adminId = $this->adminId;
$service->handle();
@@ -104,7 +106,7 @@ class RefundService extends BaseService
if (empty($orderIds)) throw new ErrException('暂无数据');
foreach ($orderIds as $orderId) {
$this->joinRefundQueue($orderId,RefundCode::FULL_GOOD_REFUND,$reason);
$this->joinRefundQueue($orderId,RefundCode::FULL_GOOD_REFUND,$reason,$this->adminId);
}
return $this->return->success();

View File

@@ -127,6 +127,7 @@ abstract class BaseRefundOrderService
if ($orderGoodList->isEmpty()) throw new Exception('该订单没有这些商品信息:'.json_encode(['order_id' => $this->orderId,'order_type' => $this->type,'goods_list' => $this->orderGoodIds]));
$this->orderGoodList = $orderGoodList->toArray();
unset($orderGoodList);
//todo 优惠券信息没有看
foreach ($this->orderGoodList as $orderGood) {
if (!in_array($orderGood['status'],OrderCode::CAN_REFUND_STATUS)) throw new Exception('商品状态不能退款:'.json_encode(['order_info' => $this->orderInfo->toArray(),'order_good' => $orderGood,'goods_list' => $this->orderGoodIds]));

View File

@@ -97,13 +97,13 @@ abstract class WxJsRechargeBaseService implements ThirdPayInterface
{
$this->setConfig();
$this->callbackData = $this->request->all();
// try {
// $this->callbackData = $this->ysdPay->wechat($this->config)->callback($this->request)->toArray()['resource']['ciphertext'];
// }catch (Exception $e) {
// $this->log->debug(__CLASS__.'wxPay回调解密失败'.json_encode($e->getMessage()));
// throw new ErrException('wxPay回调解密失败');
// }
// $this->callbackData = $this->request->all();
try {
$this->callbackData = $this->ysdPay->wechat($this->config)->callback($this->request)->toArray()['resource']['ciphertext'];
}catch (Exception $e) {
$this->log->debug(__CLASS__.'wxPay回调解密失败'.json_encode($e->getMessage()));
throw new ErrException('wxPay回调解密失败');
}
if (empty($this->callbackData)) {
$this->log->debug(__CLASS__.'wxPay获取回调失败'.json_encode($this->request));

View File

@@ -52,16 +52,16 @@ trait OrderChangeStatusTrait
* @param int $orderId
* @param int $type refundCode
* @param string $reason
* @param int $adminId
* @return void
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
protected function joinRefundQueue(int $orderId, int $type, string $reason = '系统自动'): void
protected function joinRefundQueue(int $orderId, int $type, string $reason = '系统自动',int $adminId = 0): void
{
$message = new RefundOrderProducer([
'order_id' => $orderId,
'type' => $type,
'reason' => $reason
'reason' => $reason,
'admin_id' => $adminId
]);
// $producer = ApplicationContext::getContainer()->get(Producer::class);
$this->producer->produce($message);