订单列表增加手机号搜索 #20
|
|
@ -68,6 +68,10 @@ export class QueryOrderDTO {
|
||||||
@Rule(RuleType.string().allow(''))
|
@Rule(RuleType.string().allow(''))
|
||||||
customer_email: string;
|
customer_email: string;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
@Rule(RuleType.string().allow(''))
|
||||||
|
billing_phone: string;
|
||||||
|
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
@Rule(RuleType.string().allow(null))
|
@Rule(RuleType.string().allow(null))
|
||||||
keyword: string;
|
keyword: string;
|
||||||
|
|
|
||||||
|
|
@ -209,6 +209,7 @@ export class OrderService {
|
||||||
el => el.key === '_wc_order_attribution_utm_source'
|
el => el.key === '_wc_order_attribution_utm_source'
|
||||||
)?.value || '';
|
)?.value || '';
|
||||||
order.customer_email = order?.billing?.email || order?.shipping?.email;
|
order.customer_email = order?.billing?.email || order?.shipping?.email;
|
||||||
|
order.billing_phone = order?.billing?.phone || order?.shipping?.phone;
|
||||||
const entity = plainToClass(Order, order);
|
const entity = plainToClass(Order, order);
|
||||||
const existingOrder = await this.orderModel.findOne({
|
const existingOrder = await this.orderModel.findOne({
|
||||||
where: { externalOrderId: order.externalOrderId, siteId: siteId },
|
where: { externalOrderId: order.externalOrderId, siteId: siteId },
|
||||||
|
|
@ -550,6 +551,7 @@ export class OrderService {
|
||||||
pageSize,
|
pageSize,
|
||||||
customer_email,
|
customer_email,
|
||||||
payment_method,
|
payment_method,
|
||||||
|
billing_phone,
|
||||||
}, userId = undefined) {
|
}, userId = undefined) {
|
||||||
const parameters: any[] = [];
|
const parameters: any[] = [];
|
||||||
|
|
||||||
|
|
@ -563,6 +565,7 @@ export class OrderService {
|
||||||
o.total as total,
|
o.total as total,
|
||||||
o.date_created as date_created,
|
o.date_created as date_created,
|
||||||
o.customer_email as customer_email,
|
o.customer_email as customer_email,
|
||||||
|
o.billing_phone as billing_phone,
|
||||||
o.transaction_id as transaction_id,
|
o.transaction_id as transaction_id,
|
||||||
o.orderStatus as orderStatus,
|
o.orderStatus as orderStatus,
|
||||||
o.customer_ip_address as customer_ip_address,
|
o.customer_ip_address as customer_ip_address,
|
||||||
|
|
@ -670,6 +673,12 @@ export class OrderService {
|
||||||
parameters.push(`%${customer_email}%`);
|
parameters.push(`%${customer_email}%`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (billing_phone) {
|
||||||
|
sqlQuery += ` AND o.billing_phone LIKE ?`;
|
||||||
|
totalQuery += ` AND o.billing_phone LIKE ?`;
|
||||||
|
parameters.push(`%${billing_phone}%`);
|
||||||
|
}
|
||||||
|
|
||||||
// 关键字搜索
|
// 关键字搜索
|
||||||
if (keyword) {
|
if (keyword) {
|
||||||
sqlQuery += `
|
sqlQuery += `
|
||||||
|
|
@ -714,6 +723,7 @@ export class OrderService {
|
||||||
endDate,
|
endDate,
|
||||||
keyword,
|
keyword,
|
||||||
customer_email,
|
customer_email,
|
||||||
|
billing_phone,
|
||||||
}) {
|
}) {
|
||||||
const query = this.orderModel
|
const query = this.orderModel
|
||||||
.createQueryBuilder('order')
|
.createQueryBuilder('order')
|
||||||
|
|
@ -1228,8 +1238,9 @@ export class OrderService {
|
||||||
await this.orderModel.save(order);
|
await this.orderModel.save(order);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async createOrder(data: Record<string, any>) {
|
async createOrder(data: Record<string, any>) {
|
||||||
const { sales, total, billing, customer_email } = data;
|
const { sales, total, billing, customer_email,billing_phone } = data;
|
||||||
const dataSource = this.dataSourceManager.getDataSource('default');
|
const dataSource = this.dataSourceManager.getDataSource('default');
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
return dataSource.transaction(async manager => {
|
return dataSource.transaction(async manager => {
|
||||||
|
|
@ -1248,6 +1259,7 @@ export class OrderService {
|
||||||
date_paid: now,
|
date_paid: now,
|
||||||
total,
|
total,
|
||||||
customer_email,
|
customer_email,
|
||||||
|
billing_phone,
|
||||||
billing,
|
billing,
|
||||||
shipping: billing,
|
shipping: billing,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue