Commit 550f89a6 by 任晓松

价格修改

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