|
@@ -39,8 +39,8 @@ export class OrderService extends BaseService {
|
|
@Inject()
|
|
@Inject()
|
|
utils: Utils;
|
|
utils: Utils;
|
|
|
|
|
|
- async handleNotify(code, payload) {
|
|
|
|
- const data = await this.dispatchService.handleOrderNotify(code, payload);
|
|
|
|
|
|
+ async handleNotify(code, payload, headers) {
|
|
|
|
+ const data = await this.dispatchService.handleOrderNotify(code, payload, headers);
|
|
const order = await this.orderEntity.findOneBy({ orderNo: data.orderNo });
|
|
const order = await this.orderEntity.findOneBy({ orderNo: data.orderNo });
|
|
order.date = data.date;
|
|
order.date = data.date;
|
|
order.traceNo = data.traceNo;
|
|
order.traceNo = data.traceNo;
|
|
@@ -74,19 +74,6 @@ export class OrderService extends BaseService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- async settle(id) {
|
|
|
|
- const order = await this.orderEntity.findOneBy({ id });
|
|
|
|
- if (order && +order.status === 1) {
|
|
|
|
- const channel = await this.channelService.getOne(order.code);
|
|
|
|
- return await this.dispatchService.settle(order, channel);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- async getForm(orderNo: string) {
|
|
|
|
- return await this.orderEntity.findOneBy({ orderNo });
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
async queryByApi(id) {
|
|
async queryByApi(id) {
|
|
const order = await this.orderEntity.findOneBy({ id });
|
|
const order = await this.orderEntity.findOneBy({ id });
|
|
if (!order) {
|
|
if (!order) {
|
|
@@ -147,6 +134,10 @@ export class OrderService extends BaseService {
|
|
return await this.orderEntity.findOneBy({ outOrderNo });
|
|
return await this.orderEntity.findOneBy({ outOrderNo });
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ async findByOrderNo(orderNo: any) {
|
|
|
|
+ return await this.orderEntity.findOneBy({ orderNo: orderNo });
|
|
|
|
+ }
|
|
|
|
+
|
|
async dashboard(query) {
|
|
async dashboard(query) {
|
|
let { mchId = '' } = query;
|
|
let { mchId = '' } = query;
|
|
const { roleIds, userId } = this.ctx.admin;
|
|
const { roleIds, userId } = this.ctx.admin;
|
|
@@ -264,8 +255,6 @@ export class OrderService extends BaseService {
|
|
status = '',
|
|
status = '',
|
|
notifyStatus = '',
|
|
notifyStatus = '',
|
|
createTime = [],
|
|
createTime = [],
|
|
- mainId = '',
|
|
|
|
- settleStatus = '',
|
|
|
|
} = query;
|
|
} = query;
|
|
if (!createTime || createTime.length !== 2) {
|
|
if (!createTime || createTime.length !== 2) {
|
|
return {
|
|
return {
|
|
@@ -314,10 +303,8 @@ export class OrderService extends BaseService {
|
|
: this.setSql(mchId, 'and a.mchId like ?', [`%${mchId}%`])
|
|
: this.setSql(mchId, 'and a.mchId like ?', [`%${mchId}%`])
|
|
}
|
|
}
|
|
${this.setSql(code, 'and a.code = ?', [code])}
|
|
${this.setSql(code, 'and a.code = ?', [code])}
|
|
- ${this.setSql(mainId, 'and a.mainId = ?', [mainId])}
|
|
|
|
${this.setSql(status, 'and a.status = ?', [status])}
|
|
${this.setSql(status, 'and a.status = ?', [status])}
|
|
${this.setSql(notifyStatus, 'and a.notifyStatus = ?', [notifyStatus])}
|
|
${this.setSql(notifyStatus, 'and a.notifyStatus = ?', [notifyStatus])}
|
|
- ${this.setSql(settleStatus, 'and a.settleStatus = ?', [settleStatus])}
|
|
|
|
${this.setSql(
|
|
${this.setSql(
|
|
createTime && createTime.length === 2,
|
|
createTime && createTime.length === 2,
|
|
'and (a.createTime between ? and ?)',
|
|
'and (a.createTime between ? and ?)',
|
|
@@ -337,8 +324,6 @@ export class OrderService extends BaseService {
|
|
status = '',
|
|
status = '',
|
|
notifyStatus = '',
|
|
notifyStatus = '',
|
|
createTime = [],
|
|
createTime = [],
|
|
- mainId = '',
|
|
|
|
- settleStatus = '',
|
|
|
|
} = query;
|
|
} = query;
|
|
if (!createTime || createTime.length !== 2) {
|
|
if (!createTime || createTime.length !== 2) {
|
|
throw new CoolCommException('请选择日期范围');
|
|
throw new CoolCommException('请选择日期范围');
|
|
@@ -355,9 +340,9 @@ export class OrderService extends BaseService {
|
|
mchId = '-1';
|
|
mchId = '-1';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- const sql = `SELECT a.id, a.orderNo, a.outOrderNo, a.traceNo, a.mchId, a.code, a.amount,${
|
|
|
|
|
|
+ const sql = `SELECT a.id, a.orderNo, a.outOrderNo, a.payUrl, a.traceNo, a.mchId, a.code, a.amount,${
|
|
this.utils.isMerchant(roleIds) ? '' : 'a.channelCharge,'
|
|
this.utils.isMerchant(roleIds) ? '' : 'a.channelCharge,'
|
|
- } a.charge, a.status, a.notifyStatus, a.userId, a.userIp, a.mainId, a.settleStatus, a.settleNo, a.date, a.notifyUrl, a.returnUrl, a.remark, a.createTime, a.updateTime FROM dj_order a WHERE 1=1
|
|
|
|
|
|
+ } a.charge, a.status, a.notifyStatus, a.userId, a.userIp, a.date, a.notifyUrl, a.returnUrl, a.remark, a.createTime, a.updateTime FROM dj_order a WHERE 1=1
|
|
${this.setSql(orderNo, 'and a.orderNo like ?', [`%${orderNo}%`])}
|
|
${this.setSql(orderNo, 'and a.orderNo like ?', [`%${orderNo}%`])}
|
|
${this.setSql(outOrderNo, 'and a.outOrderNo like ?', [`%${outOrderNo}%`])}
|
|
${this.setSql(outOrderNo, 'and a.outOrderNo like ?', [`%${outOrderNo}%`])}
|
|
${this.setSql(traceNo, 'and a.traceNo like ?', [`%${traceNo}%`])}
|
|
${this.setSql(traceNo, 'and a.traceNo like ?', [`%${traceNo}%`])}
|
|
@@ -367,10 +352,8 @@ export class OrderService extends BaseService {
|
|
: this.setSql(mchId, 'and a.mchId like ?', [`%${mchId}%`])
|
|
: this.setSql(mchId, 'and a.mchId like ?', [`%${mchId}%`])
|
|
}
|
|
}
|
|
${this.setSql(code, 'and a.code = ?', [code])}
|
|
${this.setSql(code, 'and a.code = ?', [code])}
|
|
- ${this.setSql(mainId, 'and a.mainId = ?', [mainId])}
|
|
|
|
${this.setSql(status, 'and a.status = ?', [status])}
|
|
${this.setSql(status, 'and a.status = ?', [status])}
|
|
${this.setSql(notifyStatus, 'and a.notifyStatus = ?', [notifyStatus])}
|
|
${this.setSql(notifyStatus, 'and a.notifyStatus = ?', [notifyStatus])}
|
|
- ${this.setSql(settleStatus, 'and a.settleStatus = ?', [settleStatus])}
|
|
|
|
${this.setSql(
|
|
${this.setSql(
|
|
createTime && createTime.length === 2,
|
|
createTime && createTime.length === 2,
|
|
'and (a.createTime between ? and ?)',
|
|
'and (a.createTime between ? and ?)',
|
|
@@ -379,4 +362,32 @@ export class OrderService extends BaseService {
|
|
`;
|
|
`;
|
|
return this.sqlRenderPage(sql, query);
|
|
return this.sqlRenderPage(sql, query);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ async getWeeklyAmount(mchId, userId, code) {
|
|
|
|
+ const time = [
|
|
|
|
+ moment().startOf('week').format('YYYY-MM-DD') + ' 00:00:00',
|
|
|
|
+ moment().endOf('week').format('YYYY-MM-DD') + ' 23:59:59',
|
|
|
|
+ ];
|
|
|
|
+ const sql = `SELECT SUM(IF(a.status = 1, a.amount, 0)) as total FROM dj_order a WHERE 1=1
|
|
|
|
+ ${ this.setSql(mchId, 'and a.mchId = ?', [`${mchId}`]) }
|
|
|
|
+ ${ this.setSql(userId, 'and a.userId = ?', [`${userId}`]) }
|
|
|
|
+ ${ this.setSql(code, 'and a.code = ?', [`${code}`]) }
|
|
|
|
+ ${this.setSql(true, 'and (a.createTime between ? and ?)', time)}
|
|
|
|
+ `
|
|
|
|
+ return await this.nativeQuery(sql);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ async getMonthlyAmount(mchId, userId, code) {
|
|
|
|
+ const time = [
|
|
|
|
+ moment().startOf('month').format('YYYY-MM-DD') + ' 00:00:00',
|
|
|
|
+ moment().endOf('month').format('YYYY-MM-DD') + ' 23:59:59',
|
|
|
|
+ ];
|
|
|
|
+ const sql = `SELECT SUM(IF(a.status = 1, a.amount, 0)) as total FROM dj_order a WHERE 1=1
|
|
|
|
+ ${ this.setSql(mchId, 'and a.mchId = ?', [`${mchId}`]) }
|
|
|
|
+ ${ this.setSql(userId, 'and a.userId = ?', [`${userId}`]) }
|
|
|
|
+ ${ this.setSql(code, 'and a.code = ?', [`${code}`]) }
|
|
|
|
+ ${this.setSql(true, 'and (a.createTime between ? and ?)', time)}
|
|
|
|
+ `
|
|
|
|
+ return await this.nativeQuery(sql);
|
|
|
|
+ }
|
|
}
|
|
}
|