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->orderId = (int)$data['order_id'];
$service->reason = $data['reason']; $service->reason = $data['reason'];
$service->type = $data['type']; $service->type = $data['type'];
$service->adminId = $data['admin_id'] ?? 0;
$service->handle(); $service->handle();
} catch (Exception $e) { } catch (Exception $e) {

View File

@@ -40,6 +40,7 @@ class RefundService extends BaseService
$service->orderId = $orderId; $service->orderId = $orderId;
$service->reason = $this->request->input('reason',''); $service->reason = $this->request->input('reason','');
$service->type = RefundCode::FULL_GOOD_REFUND; $service->type = RefundCode::FULL_GOOD_REFUND;
$service->adminId = $this->adminId;
$service->handle(); $service->handle();
@@ -66,6 +67,7 @@ class RefundService extends BaseService
$service->reason = $this->request->input('reason',''); $service->reason = $this->request->input('reason','');
$service->orderGoodIds = $orderGoodIds; $service->orderGoodIds = $orderGoodIds;
$service->type = RefundCode::PARTIAL_GOOD_REFUND; $service->type = RefundCode::PARTIAL_GOOD_REFUND;
$service->adminId = $this->adminId;
$service->handle(); $service->handle();
@@ -104,7 +106,7 @@ class RefundService extends BaseService
if (empty($orderIds)) throw new ErrException('暂无数据'); if (empty($orderIds)) throw new ErrException('暂无数据');
foreach ($orderIds as $orderId) { 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(); 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])); if ($orderGoodList->isEmpty()) throw new Exception('该订单没有这些商品信息:'.json_encode(['order_id' => $this->orderId,'order_type' => $this->type,'goods_list' => $this->orderGoodIds]));
$this->orderGoodList = $orderGoodList->toArray(); $this->orderGoodList = $orderGoodList->toArray();
unset($orderGoodList); unset($orderGoodList);
//todo 优惠券信息没有看
foreach ($this->orderGoodList as $orderGood) { 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])); 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->setConfig();
$this->callbackData = $this->request->all(); // $this->callbackData = $this->request->all();
// try { try {
// $this->callbackData = $this->ysdPay->wechat($this->config)->callback($this->request)->toArray()['resource']['ciphertext']; $this->callbackData = $this->ysdPay->wechat($this->config)->callback($this->request)->toArray()['resource']['ciphertext'];
// }catch (Exception $e) { }catch (Exception $e) {
// $this->log->debug(__CLASS__.'wxPay回调解密失败'.json_encode($e->getMessage())); $this->log->debug(__CLASS__.'wxPay回调解密失败'.json_encode($e->getMessage()));
// throw new ErrException('wxPay回调解密失败'); throw new ErrException('wxPay回调解密失败');
// } }
if (empty($this->callbackData)) { if (empty($this->callbackData)) {
$this->log->debug(__CLASS__.'wxPay获取回调失败'.json_encode($this->request)); $this->log->debug(__CLASS__.'wxPay获取回调失败'.json_encode($this->request));

View File

@@ -52,16 +52,16 @@ trait OrderChangeStatusTrait
* @param int $orderId * @param int $orderId
* @param int $type refundCode * @param int $type refundCode
* @param string $reason * @param string $reason
* @param int $adminId
* @return void * @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([ $message = new RefundOrderProducer([
'order_id' => $orderId, 'order_id' => $orderId,
'type' => $type, 'type' => $type,
'reason' => $reason 'reason' => $reason,
'admin_id' => $adminId
]); ]);
// $producer = ApplicationContext::getContainer()->get(Producer::class); // $producer = ApplicationContext::getContainer()->get(Producer::class);
$this->producer->produce($message); $this->producer->produce($message);