|
@@ -13,6 +13,7 @@ import { MchChannelService } from './mchChannel';
|
|
|
import { RefundService } from './refund';
|
|
|
import { PayService } from './pay';
|
|
|
import { OrderService } from './order';
|
|
|
+import { isNumber } from '@midwayjs/core/dist/util/types';
|
|
|
|
|
|
@Provide()
|
|
|
export class PayRefundService extends BaseService {
|
|
@@ -90,7 +91,11 @@ export class PayRefundService extends BaseService {
|
|
|
if (!order || +order.status !== 1) {
|
|
|
throw new Error('订单不存在或订单状态非支付成功');
|
|
|
}
|
|
|
- return await this.refundService.toRefund(order, order.amount, payload.reason || '');
|
|
|
+ let amount = order.amount;
|
|
|
+ if(isNumber(payload.amount) && +payload.amount < +order.amount) {
|
|
|
+ amount = payload.amount;
|
|
|
+ }
|
|
|
+ return await this.refundService.toRefund(order, amount, payload.reason || '');
|
|
|
} catch (err) {
|
|
|
this.logger.error('退款下单', JSON.stringify(payload), err.message);
|
|
|
throw new CoolCommException(err.message);
|