feat : refund
This commit is contained in:
@@ -18,6 +18,7 @@ use App\Constants\ApiCode;
|
||||
use App\Constants\Common\GoodCode;
|
||||
use App\Constants\Common\OrderCode;
|
||||
use App\Constants\Common\PayCode;
|
||||
use App\Constants\Common\RefundCode;
|
||||
use App\Constants\ConfigCode;
|
||||
use App\Exception\ErrException;
|
||||
use App\Model\Order;
|
||||
@@ -57,6 +58,19 @@ trait OrderTrait
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $type
|
||||
* @param int $userId
|
||||
* @return string
|
||||
*/
|
||||
protected function generateRefundOrderNo(int $type,int $userId): string
|
||||
{
|
||||
return match ($type) {
|
||||
OrderCode::ORDER_TYPE_GOOD => RefundCode::ORDER_TYPE_GOOD_PREFIX . '_' .date("YmdHis") . $userId . mt_rand(10000000, 99999999),
|
||||
OrderCode::ORDER_TYPE_BALANCE => RefundCode::ORDER_TYPE_BALANCE_PREFIX. '_' .date("YmdHis"). $userId. mt_rand(10000000, 99999999),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成购物车数据
|
||||
* @param array $data
|
||||
|
||||
@@ -46,16 +46,18 @@ trait OrderChangeStatusTrait
|
||||
* @param int $orderId
|
||||
* @param int $type
|
||||
* @param float|int $amount amount = 0 全部 amount > 0 部分
|
||||
* @param string $reason
|
||||
* @return void
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
protected function joinRefundQueue(int $orderId, int $type, float|int $amount = 0): void
|
||||
protected function joinRefundQueue(int $orderId, int $type, float|int $amount = 0, string $reason = '系统自动'): void
|
||||
{
|
||||
$message = new RefundOrderProducer([
|
||||
'order_id' => $orderId,
|
||||
'type' => $type,
|
||||
'amount' => $amount,
|
||||
'reason' => $reason
|
||||
]);
|
||||
$producer = ApplicationContext::getContainer()->get(Producer::class);
|
||||
$producer->produce($message);
|
||||
|
||||
Reference in New Issue
Block a user