Commit 9d113880 by 任晓松

价格修改

parent 582b0453
......@@ -56,6 +56,9 @@ class OpProductAPI extends APIBase {
case "getProductRecommend":
opResult = await this.productSve.getProductRecommend(pobj.actionBody,pobj.appInfo);
break;
case "updateProductPrice":
opResult = await this.productSve.updateProductPrice(pobj.actionBody,pobj.appInfo);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
......
......@@ -279,5 +279,32 @@ class ProductService extends ServiceBase {
}
return system.getResult(rtn);
}
/**
* 更改产品销售价格
* @param actionBody
* @returns {Promise<void>}
*/
async updateProductPrice(actionBody,appInfo){
// let productPrice = await this.findOne({pay_code:actionBody.payCode});
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 whereParams = {
payCode:actionBody.payCode,
uapp_id:appInfo.uapp_id
}
let productPrice = await this.customQuery(sql,whereParams);
if(!productPrice || productPrice.length == 0){
return system.getResultFail(-1,'暂无产品')
}
let price = productPrice[0].supply_price;
if(actionBody.price < price){
return system.getResultFail(-1,'修改的价格不能低于供货价!')
}
let updateFields = {
price : actionBody.price
}
this.updateByWhere(updateFields, { where: { id: productPrice[0].id } });
return system.getResultSuccess()
}
}
module.exports = ProductService;
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