|
@@ -11,15 +11,14 @@ import com.hboxs.control.api.BaseController;
|
|
|
import com.hboxs.entity.Admin;
|
|
|
import com.hboxs.entity.Equipment;
|
|
|
import com.hboxs.entity.EquipmentApply;
|
|
|
-import com.hboxs.service.AdminService;
|
|
|
-import com.hboxs.service.EquipmentApplyService;
|
|
|
-import com.hboxs.service.EquipmentService;
|
|
|
-import com.hboxs.service.ProductService;
|
|
|
+import com.hboxs.entity.Proportion;
|
|
|
+import com.hboxs.service.*;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
@@ -39,6 +38,9 @@ public class IndexController extends BaseController {
|
|
|
@Resource(name = "equipmentApplyServiceImpl")
|
|
|
private EquipmentApplyService equipmentApplyService;
|
|
|
|
|
|
+ @Resource(name = "proportionServiceImpl")
|
|
|
+ private ProportionService proportionService;
|
|
|
+
|
|
|
/**
|
|
|
* 心跳
|
|
|
*
|
|
@@ -168,6 +170,8 @@ public class IndexController extends BaseController {
|
|
|
@RequestMapping(value = "/updateProduct", method = RequestMethod.POST)
|
|
|
@ResponseBody
|
|
|
public JsonMessage updateProduct(@RequestBody List<ProductVo> productVos) {
|
|
|
+ Double f=0.00;
|
|
|
+ int num=0;
|
|
|
for (ProductVo product : productVos) {
|
|
|
String clientId = product.getClientId();
|
|
|
Equipment equipment = equipmentService.findByClientId(clientId);
|
|
@@ -175,7 +179,33 @@ public class IndexController extends BaseController {
|
|
|
if (id == null) {
|
|
|
return JsonMessage.error("调价失败");
|
|
|
}
|
|
|
- productService.updateByClientID(id, product.getRmbPrice(), product.getCodePrice(), product.getProductName(), product.getSellStatus());
|
|
|
+ //设置最低价格
|
|
|
+ //获取商家id
|
|
|
+ Long adminId = equipment.getAdminId();
|
|
|
+ //根据id获取分销比例
|
|
|
+ Proportion proportion = proportionService.getUniqueness(adminId);
|
|
|
+ //平台分销比例
|
|
|
+ BigDecimal adminProportion = proportion.getAdminProportion();
|
|
|
+ Double pricePro = adminProportion.doubleValue()/100;
|
|
|
+ //平台最低收入
|
|
|
+ Double minProportion = 0.005;
|
|
|
+ //获取重新设定的价格
|
|
|
+ Double rmbPrice = product.getRmbPrice().doubleValue();
|
|
|
+ //价格和平台分销比例要大于0
|
|
|
+ if(pricePro>0&&rmbPrice>0){
|
|
|
+ //重新设定价格后平台收入和平台最低收入比较
|
|
|
+ if(rmbPrice*pricePro<minProportion){
|
|
|
+ num++;
|
|
|
+ //保留3位小数点
|
|
|
+ BigDecimal b = new BigDecimal(minProportion/pricePro);
|
|
|
+ f = b.setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ productService.updateByClientID(id, product.getRmbPrice(), product.getCodePrice(), product.getProductName(), product.getSellStatus());
|
|
|
+ }
|
|
|
+ if(f>0){
|
|
|
+ return JsonMessage.error("最低价格应为"+f+"元,或者设为0元。有"+num+"处价格设置不合理!!!");
|
|
|
}
|
|
|
return JsonMessage.success("调价成功");
|
|
|
|