Commit a2290504 by 孙亚楠

d

parent 03bd68df
......@@ -110,7 +110,7 @@ class EordersignlogDao extends Dao{
async PageeordersignlogContract(params){
let sql = [];
sql.push(`SELECT t1.engine_contract_id,t1.engine_contract_name,t1.created_at,t2.live_start,t2.live_end,t2.merchant_name,t1.order_id `);
sql.push(`SELECT t1.engine_contract_id,t1.engine_contract_name,t1.created_at,t2.live_start,t2.live_end,t2.merchant_name,t1.order_id,t2.contract_url `);
sql.push(`FROM e_order_sign_log t1 inner join e_order t2 on t2.id =t1.order_id WHERE 1 = 1 `)
this.setpageEorderContractParams(sql,params);
sql.push("ORDER BY t1.created_at DESC");
......
......@@ -12,7 +12,6 @@ module.exports = function (db, DataTypes) {
product_type: {type: DataTypes.STRING, field: 'product_type', allowNull: true,defaultValue:'', comment:'产品类型'},
product_unit_price:{ type: DataTypes.STRING, field: 'product_unit_price', allowNull: true, defaultValue:'',comment:'产品单价'},
product_desc:{ type: DataTypes.STRING, field: 'product_desc', allowNull: true, defaultValue:'',comment:'产品描述'},
price: { type: DataTypes.BIGINT, field: 'price', allowNull: true, defaultValue:0,comment:'订单价格'},
product_specifications: { type: DataTypes.INTEGER, field: 'product_specifications', allowNull: true, defaultValue:0,comment:'产品规格数量'},
contract_url: {type: DataTypes.STRING, field: 'contract_url', allowNull: true, defaultValue:'',comment:'合同Url' },
live_start: {type: DataTypes.DATE, field: 'live_start', allowNull: true, defaultValue:null, comment:'生效时间' },
......
......@@ -6,6 +6,8 @@ module.exports = function (db, DataTypes) {
return db.define('eorderproduct', {
order_id: {type: DataTypes.STRING, field: 'order_id', allowNull: true, defaultValue:'',comment:'订单号' },
product_id: {type: DataTypes.STRING, field: 'product_id', allowNull: true,defaultValue:'', comment:'产品id'},
price: { type: DataTypes.BIGINT, field: 'price', allowNull: true, defaultValue:0,comment:'订单价格'},
product_name: {type: DataTypes.STRING, field: 'product_name', allowNull: true,defaultValue:'', comment:'产品名称'},
created_at: { type: DataTypes.DATE, field: 'created_at', allowNull: false},
updated_at: { type: DataTypes.DATE, field: 'updated_at', allowNull: false},
deleted_at: { type: DataTypes.DATE, field: 'deleted_at', allowNull: true },
......
......@@ -76,9 +76,9 @@ class EorderService extends ServiceBase {
_orderBeanProperties.product_type = params.product_type ? params.product_type : _orderBean.product_type;
_orderBeanProperties.product_unit_price = params.product_unit_price ? params.product_unit_price : _orderBean.product_unit_price;
_orderBeanProperties.product_desc = params.product_desc ? params.product_desc : _orderBean.product_desc;
if(params.hasOwnProperty('price')){
_orderBeanProperties.price = Number(params.price || _orderBean.price);
}
// if(params.hasOwnProperty('price')){
// _orderBeanProperties.price = Number(params.price || _orderBean.price);
// }
if(params.hasOwnProperty('product_specifications')){
_orderBeanProperties.product_specifications = Number(params.product_specifications || _orderBean.product_specifications);
}
......@@ -104,16 +104,26 @@ class EorderService extends ServiceBase {
throw new Error("更新订单失败");
return system.getResult(null,`系统错误 更新订单商品失败`);
}
if(params.product_ids && params.product_ids.length>0){
let ids = Array.from(new Set(params.product_ids));
if(params.product_arr && params.product_arr.length>0){
// 去重开始
let productItemMap={};
for (let item of params.product_arr) {
productItemMap[item.id]=item
}
//去重结束
let eorderProductProperties = [];
for(let item of ids){
eorderProductProperties.push({order_id:_orderBean.id,product_id:item});
for(let key in productItemMap){
eorderProductProperties.push({
order_id: _orderBean.id,
product_id: productItemMap[key].id,
product_name: productItemMap[key].product_name,
price: productItemMap[key].price
});
}
_orderBeanProperties.eorderProducts=eorderProductProperties;
await this.eorderproductDao.bulkCreate(eorderProductProperties,t);
}else{
await this.eorderproductDao.create({order_id: _orderBean.id, product_id: this.trim(params.product_id)},t);
await this.eorderproductDao.create({order_id: _orderBean.id, product_id: this.trim(params.product_id),price:this.trim(params.product_unit_price)},t);
}
});
return system.getResult(_orderBeanProperties);
......@@ -121,15 +131,25 @@ class EorderService extends ServiceBase {
let orderBean =null;
await this.db.transaction(async t => {
orderBean=await this.dao.create(params,t);
if(params.product_ids && params.product_ids.length>0){
let ids = Array.from(new Set(params.product_ids));
if(params.product_arr && params.product_arr.length>0){
// 去重开始
let productItemMap={};
for (let item of params.product_arr) {
productItemMap[item.id] = item;
}
//去重结束
let eorderProductProperties = [];
for(let item of ids){
eorderProductProperties.push({order_id:orderBean.id,product_id:item});
for(let key in productItemMap){
eorderProductProperties.push({
order_id: orderBean.id,
product_id: productItemMap[key].id,
product_name: productItemMap[key].product_name,
price: productItemMap[key].price
});
}
await this.eorderproductDao.bulkCreate(eorderProductProperties,t);
}else{
await this.eorderproductDao.create({order_id: orderBean.id, product_id: this.trim(params.product_id)},t);
await this.eorderproductDao.create({order_id: orderBean.id, product_id: this.trim(params.product_id),price:this.trim(params.product_unit_price)},t);
}
});
this.handleDate(orderBean.dataValues, ['live_start', 'live_end', 'created_at'], null, null);
......@@ -238,13 +258,14 @@ class EorderService extends ServiceBase {
return system.getResult(null, `参数错误 订单【${params.id}】不存在`);
}
try{
let productIds = await this.eorderproductDao.model.findAll({
let productChildren = await this.eorderproductDao.model.findAll({
where:{
order_id:orderBean.id
},
attributes:['product_id']
attributes:['product_id','product_name','price','order_id']
});
orderBean.productIds = productIds;
orderBean.productChildren = productChildren;
this.handleDate(orderBean, ['created_at','pay_date','audit_date','live_start','live_end'], null, null);
orderBean.product_type_name = orderBean.product_type == '1' ? '单产品' : '组合产品';
orderBean.product_specifications_unit = orderBean.product_type == '1' ? '份' : '元';
......@@ -279,6 +300,7 @@ class EorderService extends ServiceBase {
}
}
/**
* fn:订单查询(分页)
* @param params
......@@ -398,12 +420,5 @@ class EorderService extends ServiceBase {
return system.getResult(null,`系统错误`);
}
}
}
module.exports = EorderService;
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment