Commit 550f89a6 by 任晓松

价格修改

parent 203a3a25
...@@ -291,10 +291,8 @@ class ProductService extends ServiceBase { ...@@ -291,10 +291,8 @@ class ProductService extends ServiceBase {
let failRet = []; let failRet = [];
for(let i =0;i<arr.length;i++){ for(let i =0;i<arr.length;i++){
const item = arr[i]; const item = arr[i];
let msg = ''; let obj = {};
if(!item.price || !item.payCode){ if(!item.payCode || !item.price){
msg = JSON.stringify(item) + " 参数错误!"
failRet.push(msg)
continue; continue;
} }
let sql = "SELECT a.uapp_id,a.item_name,b.id,b.product_id,b.pay_code,b.price,b.supply_price FROM `p_product` a LEFT JOIN `p_product_price` b ON a.id = b.product_id where b.pay_code = :payCode and a.uapp_id = :uapp_id"; let sql = "SELECT a.uapp_id,a.item_name,b.id,b.product_id,b.pay_code,b.price,b.supply_price FROM `p_product` a LEFT JOIN `p_product_price` b ON a.id = b.product_id where b.pay_code = :payCode and a.uapp_id = :uapp_id";
...@@ -304,14 +302,20 @@ class ProductService extends ServiceBase { ...@@ -304,14 +302,20 @@ class ProductService extends ServiceBase {
} }
let productPrice = await this.customQuery(sql,whereParams); let productPrice = await this.customQuery(sql,whereParams);
if(!productPrice || productPrice.length == 0){ if(!productPrice || productPrice.length == 0){
msg = item.payCode + '暂无产品,请核对payCode'; obj ={
failRet.push(msg); payCode:item.payCode,
message:'暂无产品'
}
failRet.push(obj);
continue; continue;
} }
let price = productPrice[0].supply_price; let price = productPrice[0].supply_price;
if(item.price < price){ if(item.price < price){
msg = item.payCode + '修改的价格不能低于供货价!'; obj ={
failRet.push(msg); payCode:item.payCode,
message:'修改的价格不能低于供货价'
}
failRet.push(obj);
continue; continue;
} }
let updateFields = { let updateFields = {
...@@ -319,11 +323,13 @@ class ProductService extends ServiceBase { ...@@ -319,11 +323,13 @@ class ProductService extends ServiceBase {
} }
let ret = await this.productpriceDao.updateByWhere(updateFields, { where: { id: productPrice[0].id } }); let ret = await this.productpriceDao.updateByWhere(updateFields, { where: { id: productPrice[0].id } });
if(ret){ if(ret){
msg = item.payCode + "修改成功"; successRet.push(item.payCode)
successRet.push(msg)
}else{ }else{
msg = item.payCode + "修改失败"; obj ={
failRet.push(msg) payCode:item.payCode,
message:'修改失败'
}
failRet.push(obj);
} }
} }
return system.getResultSuccess({successRet,failRet}) return system.getResultSuccess({successRet,failRet})
......
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