Commit 7880bb54 by 孙亚楠

d

parent ebe3ecd8
...@@ -23,7 +23,7 @@ class EorderproductDao extends Dao{ ...@@ -23,7 +23,7 @@ class EorderproductDao extends Dao{
if(params.order_id){ if(params.order_id){
sql.push('and order_id = :order_id'); sql.push('and order_id = :order_id');
} }
if(params.order_ids || params.order_ids.length!=0){ if(params.order_ids && params.order_ids.length!=0){
sql.push('and order_id in (:order_ids)'); sql.push('and order_id in (:order_ids)');
} }
} }
...@@ -40,7 +40,8 @@ class EorderproductDao extends Dao{ ...@@ -40,7 +40,8 @@ class EorderproductDao extends Dao{
let sql = []; let sql = [];
sql.push('DELETE FROM e_order_product WHERE 1 = 1 '); sql.push('DELETE FROM e_order_product WHERE 1 = 1 ');
this.setEorderParams(sql,params); this.setEorderParams(sql,params);
return await this.customQuery(sql.join(" "), params); let res= await this.customUpdate(sql.join(" "), params);
return res;
} }
/** /**
......
...@@ -13,7 +13,7 @@ module.exports = function (db, DataTypes) { ...@@ -13,7 +13,7 @@ module.exports = function (db, DataTypes) {
product_unit_price:{ type: DataTypes.STRING, field: 'product_unit_price', 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:'产品描述'}, product_desc:{ type: DataTypes.STRING, field: 'product_desc', allowNull: true, defaultValue:'',comment:'产品描述'},
price: { type: DataTypes.BIGINT, field: 'price', allowNull: true, defaultValue:0,comment:'订单价格'}, price: { type: DataTypes.BIGINT, field: 'price', allowNull: true, defaultValue:0,comment:'订单价格'},
product_specifications: { type: DataTypes.INTEGER, 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' }, 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:'生效时间' }, live_start: {type: DataTypes.DATE, field: 'live_start', allowNull: true, defaultValue:null, comment:'生效时间' },
live_end: {type: DataTypes.DATE, field: 'live_end', allowNull: true, defaultValue:null, comment:'结束时间' }, live_end: {type: DataTypes.DATE, field: 'live_end', allowNull: true, defaultValue:null, comment:'结束时间' },
......
const system = require("../../../system"); const system = require("../../../system");
const ServiceBase = require("../../sve.base") const ServiceBase = require("../../sve.base")
class EorderSve extends ServiceBase { class EorderService extends ServiceBase {
constructor() { constructor() {
super("eorder", ServiceBase.getDaoName(EorderSve)); super("eorder", ServiceBase.getDaoName(EorderService));
this.eorderproductDao = system.getObject("db.eorder.eorderproductDao"); this.eorderproductDao = system.getObject("db.eorder.eorderproductDao");
this.GROUP_PRODUCT_TYPE = "2"; this.GROUP_PRODUCT_TYPE = "2";
this.SIGNLE_PRODUCT_TYPE = "1"; this.SIGNLE_PRODUCT_TYPE = "1";
...@@ -21,8 +21,8 @@ class EorderSve extends ServiceBase { ...@@ -21,8 +21,8 @@ class EorderSve extends ServiceBase {
if(!params.merchant_id){ if(!params.merchant_id){
return system.getResult(null, `参数错误 商户ID不能为空`); return system.getResult(null, `参数错误 商户ID不能为空`);
} }
if(!params.sign_id){ if(!params.merchant_name){
return system.getResult(null, `参数错误 签署ID不能为空`); return system.getResult(null, `参数错误 商户名称不能为空`);
} }
if((!params.product_ids || params.product_ids.length==0) && !params.product_id ){ if((!params.product_ids || params.product_ids.length==0) && !params.product_id ){
return system.getResult(null, `参数错误 产品ID列表不能为空`); return system.getResult(null, `参数错误 产品ID列表不能为空`);
...@@ -56,12 +56,17 @@ class EorderSve extends ServiceBase { ...@@ -56,12 +56,17 @@ class EorderSve extends ServiceBase {
console.log(`eorderSve->saveEorder->params` + JSON.stringify(params)); console.log(`eorderSve->saveEorder->params` + JSON.stringify(params));
try{ try{
if(params.id){//更新新操作 if(params.id){//更新新操作
let _orderBean = await this.dao.model.findOne(this.trim(params.id)); let _orderBean = await this.dao.model.findOne({
where:{
id:this.trim(params.id)
}
});
if(!_orderBean){ if(!_orderBean){
return system.getResult(null, `订单【${params.id}】不存在`); return system.getResult(null, `订单【${params.id}】不存在`);
} }
let _orderBeanProperties={id:_orderBean.id}; let _orderBeanProperties={id:_orderBean.id};
_orderBeanProperties.merchant_id = params.merchant_id ? params.merchant_id : _orderBean.merchant_id; _orderBeanProperties.merchant_id = params.merchant_id ? params.merchant_id : _orderBean.merchant_id;
_orderBeanProperties.merchant_name = params.merchant_name ? params.merchant_name : _orderBean.merchant_name;
_orderBeanProperties.sign_id = params.sign_id ? params.sign_id : _orderBean.sign_id; _orderBeanProperties.sign_id = params.sign_id ? params.sign_id : _orderBean.sign_id;
_orderBeanProperties.sign_name = params.sign_name ? params.sign_name : _orderBean.sign_name; _orderBeanProperties.sign_name = params.sign_name ? params.sign_name : _orderBean.sign_name;
_orderBeanProperties.product_id = params.product_id ? params.product_id : _orderBean.product_id; _orderBeanProperties.product_id = params.product_id ? params.product_id : _orderBean.product_id;
...@@ -69,10 +74,10 @@ class EorderSve extends ServiceBase { ...@@ -69,10 +74,10 @@ class EorderSve extends ServiceBase {
_orderBeanProperties.product_unit_price = params.product_unit_price ? params.product_unit_price : _orderBean.product_unit_price; _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; _orderBeanProperties.product_desc = params.product_desc ? params.product_desc : _orderBean.product_desc;
if(params.hasOwnProperty('price')){ if(params.hasOwnProperty('price')){
_orderBeanProperties.price = Number(params.price || 0); _orderBeanProperties.price = Number(params.price || _orderBean.price);
} }
if(params.hasOwnProperty('product_specifications')){ if(params.hasOwnProperty('product_specifications')){
_orderBeanProperties.product_specifications = Number(params.product_specifications || 0); _orderBeanProperties.product_specifications = Number(params.product_specifications || _orderBean.product_specifications);
} }
_orderBeanProperties.contract_url = params.contract_url ? params.contract_url : _orderBean.contract_url; _orderBeanProperties.contract_url = params.contract_url ? params.contract_url : _orderBean.contract_url;
...@@ -92,22 +97,23 @@ class EorderSve extends ServiceBase { ...@@ -92,22 +97,23 @@ class EorderSve extends ServiceBase {
await this.dao.update(_orderBeanProperties, t); await this.dao.update(_orderBeanProperties, t);
//首先删除 eorderproduct 表中所用指定order_id的所有记录 //首先删除 eorderproduct 表中所用指定order_id的所有记录
let deleteRows = await this.eorderproductDao.delete({order_id:_orderBean.id}); let deleteRows = await this.eorderproductDao.delete({order_id:_orderBean.id});
if(deleteRows==0){ if(deleteRows.length==0){
throw new Error("更新订单失败"); throw new Error("更新订单失败");
return system.getResult(null,`系统错误 更新订单商品失败`); return system.getResult(null,`系统错误 更新订单商品失败`);
} }
if(params.product_ids || params.product_ids.length>0){ if(params.product_ids && params.product_ids.length>0){
let ids = Array.from(new Set(params.product_ids)); let ids = Array.from(new Set(params.product_ids));
let eorderProductProperties = []; let eorderProductProperties = [];
for(let item of ids){ for(let item of ids){
eorderProductProperties.push({order_id:orderBean.id,product_id:item}); eorderProductProperties.push({order_id:_orderBean.id,product_id:item});
} }
await this.eorderproductDao.model.bulkCreate(eorderProductProperties,t); _orderBeanProperties.eorderProducts=eorderProductProperties;
await this.eorderproductDao.bulkCreate(eorderProductProperties,t);
}else{ }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)},t);
} }
}); });
return system.getResult(orderBean); return system.getResult(_orderBeanProperties);
}else{ //新增操作 }else{ //新增操作
let orderBean =null; let orderBean =null;
await this.db.transaction(async t => { await this.db.transaction(async t => {
...@@ -118,11 +124,12 @@ class EorderSve extends ServiceBase { ...@@ -118,11 +124,12 @@ class EorderSve extends ServiceBase {
for(let item of ids){ for(let item of ids){
eorderProductProperties.push({order_id:orderBean.id,product_id:item}); eorderProductProperties.push({order_id:orderBean.id,product_id:item});
} }
await this.eorderproductDao.model.bulkCreate(eorderProductProperties,t); await this.eorderproductDao.bulkCreate(eorderProductProperties,t);
}else{ }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)},t);
} }
}); });
this.handleDate(orderBean.dataValues, ['live_start', 'live_end', 'created_at'], null, null);
return system.getResult(orderBean); return system.getResult(orderBean);
} }
}catch (e) { }catch (e) {
...@@ -280,4 +287,4 @@ class EorderSve extends ServiceBase { ...@@ -280,4 +287,4 @@ class EorderSve extends ServiceBase {
} }
} }
module.exports = EorderSve; module.exports = EorderService;
\ No newline at end of file \ No newline at end of file
const system = require("../../../system"); const system = require("../../../system");
const ServiceBase = require("../../sve.base") const ServiceBase = require("../../sve.base")
class EorderauthlogSve extends ServiceBase { class EorderauthlogService extends ServiceBase {
constructor() { constructor() {
super("eorderauthlogSve", ServiceBase.getDaoName(EorderauthlogSve)); super("eorder", ServiceBase.getDaoName(EorderauthlogService));
this.eorderDao = system.getObject("db.eorder.eorderDao"); this.eorderDao = system.getObject("db.eorder.eorderDao");
} }
...@@ -78,4 +78,4 @@ class EorderauthlogSve extends ServiceBase { ...@@ -78,4 +78,4 @@ class EorderauthlogSve extends ServiceBase {
} }
} }
module.exports = EorderauthlogSve; module.exports = EorderauthlogService;
\ No newline at end of file \ No newline at end of file
const system = require("../../../system"); const system = require("../../../system");
const ServiceBase = require("../../sve.base") const ServiceBase = require("../../sve.base")
class EorderproductSve extends ServiceBase { class EorderproductService extends ServiceBase {
constructor() { constructor() {
super("eorderproduct", ServiceBase.getDaoName(EorderproductSve)); super("eorder", ServiceBase.getDaoName(EorderproductService));
// this.accounttradeDao = system.getObject("db.account.accounttradeDao"); // this.accounttradeDao = system.getObject("db.account.accounttradeDao");
} }
...@@ -44,4 +44,4 @@ class EorderproductSve extends ServiceBase { ...@@ -44,4 +44,4 @@ class EorderproductSve extends ServiceBase {
} }
} }
module.exports = EorderproductSve; module.exports = EorderproductService;
\ No newline at end of file \ No newline at end of file
const system = require("../../../system"); const system = require("../../../system");
const ServiceBase = require("../../sve.base") const ServiceBase = require("../../sve.base")
class EordersignlogSve extends ServiceBase { class EordersignlogService extends ServiceBase {
constructor() { constructor() {
super("eordersignlog", ServiceBase.getDaoName(EordersignlogSve)); super("eorder", ServiceBase.getDaoName(EordersignlogService));
this.eorderDao = system.getObject("db.eorder.eorderDao"); this.eorderDao = system.getObject("db.eorder.eorderDao");
} }
...@@ -81,4 +81,4 @@ class EordersignlogSve extends ServiceBase { ...@@ -81,4 +81,4 @@ class EordersignlogSve extends ServiceBase {
} }
module.exports = EordersignlogSve; module.exports = EordersignlogService;
\ No newline at end of file \ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
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