|
@@ -26,6 +26,8 @@ import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.*;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.text.DateFormat;
|
|
|
+import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
@@ -45,6 +47,8 @@ public class IndexController { ;
|
|
|
@Autowired
|
|
|
TProductService productService;
|
|
|
@Autowired
|
|
|
+ TProportionService proportionService;
|
|
|
+ @Autowired
|
|
|
TEquipmentDescService equipmentDescService;
|
|
|
@Autowired
|
|
|
EsTEquipmentService esTEquipmentService;
|
|
@@ -1480,5 +1484,100 @@ public class IndexController { ;
|
|
|
// return JsonMessage.success("success");
|
|
|
return "success";
|
|
|
}
|
|
|
+ //验证优惠码
|
|
|
+ @RequestMapping(value = "/updateProportion.htm", method = RequestMethod.GET, produces = "text/html;charset=utf-8")
|
|
|
+ @ResponseBody
|
|
|
+ public String updateProportion(String clientId) {
|
|
|
+ LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
|
|
|
+ query.eq(TEquipment::getClientId,clientId);
|
|
|
+ List<TEquipment> list = equipmentService.list(query);
|
|
|
+ TEquipment equipment = list.get(0);
|
|
|
+ if(equipment!=null&&equipment.getId()!=null){
|
|
|
+ TAdmin admin = adminService.getById(equipment.getAdminId());
|
|
|
+ String name = admin.getName();
|
|
|
+ if(StringUtils.isNotEmpty(name)&&name.substring(name.length()-1).equals("x")){
|
|
|
+ //查询机器是否已经有设置分销
|
|
|
+ LambdaQueryWrapper<TProportion> query1 = Wrappers.lambdaQuery();
|
|
|
+ query1.eq(TProportion::getClientId,equipment.getClientId());
|
|
|
+ query1.eq(TProportion::getEquipmentId,equipment.getId());
|
|
|
+ List<TProportion> list1 = proportionService.list(query1);
|
|
|
+ if(list1.size()>0){
|
|
|
+ //已有
|
|
|
+ }else {
|
|
|
+ //没有,需要创建
|
|
|
+ //1,判断是否新机器
|
|
|
+ Date createDate = equipment.getCreateDate();
|
|
|
+ long time = createDate.getTime();
|
|
|
+ DateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ String day= "2022-09-21 23:59:59";
|
|
|
+ try {
|
|
|
+ Date parse = simpleDateFormat.parse(day);
|
|
|
+ if(time>parse.getTime()){
|
|
|
+ return "新机器,不能已此方式生成分销!";
|
|
|
+ }
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ //先找到原账户的分销
|
|
|
+ LambdaQueryWrapper<TProportion> query2 = Wrappers.lambdaQuery();
|
|
|
+ query2.eq(TProportion::getAdminId,admin.getId());
|
|
|
+ List<TProportion> list2 = proportionService.list(query2);
|
|
|
+ if(list2.size()>0){
|
|
|
+ TProportion adminProportion = list2.get(0);
|
|
|
+ TProportion equipmentProportion = new TProportion();
|
|
|
+ equipmentProportion.setCreateDate(new Date());
|
|
|
+ equipmentProportion.setModifyDate(new Date());
|
|
|
+ equipmentProportion.setAdminId(admin.getId());
|
|
|
+ equipmentProportion.setClientId(equipment.getClientId());
|
|
|
+ equipmentProportion.setEquipmentId(equipment.getId());
|
|
|
+ equipmentProportion.setAdminProportion(adminProportion.getAdminProportion());
|
|
|
+ Integer type = adminProportion.getType();
|
|
|
+ switch (type) {
|
|
|
+ case 1:
|
|
|
+ equipmentProportion.setProportion(adminProportion.getAgencyProportion());
|
|
|
+ equipmentProportion.setAgencyProportion(new BigDecimal("0.00"));
|
|
|
+ equipmentProportion.setMerchantProportion(new BigDecimal("0.00"));
|
|
|
+ equipmentProportion.setPersonageProportion(new BigDecimal("0.00"));
|
|
|
+ equipmentProportion.setType(0);
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ equipmentProportion.setProportion(adminProportion.getMerchantProportion());
|
|
|
+ equipmentProportion.setAgencyProportion(adminProportion.getAgencyProportion());
|
|
|
+ if(adminProportion.getAgencyProportion().compareTo(new BigDecimal("0.00"))!=0){
|
|
|
+ equipmentProportion.setAgencyId(admin.getAgencyId());
|
|
|
+ TAdmin byId = adminService.getById(admin.getAgencyId());
|
|
|
+ equipmentProportion.setAgencyName(byId.getUsername());
|
|
|
+ }
|
|
|
+ equipmentProportion.setMerchantProportion(new BigDecimal("0.00"));
|
|
|
+ equipmentProportion.setPersonageProportion(new BigDecimal("0.00"));
|
|
|
+ equipmentProportion.setType(1);
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ equipmentProportion.setProportion(adminProportion.getPersonageProportion());
|
|
|
+ equipmentProportion.setAgencyProportion(adminProportion.getAgencyProportion());
|
|
|
+ if(adminProportion.getAgencyProportion().compareTo(new BigDecimal("0.00"))!=0){
|
|
|
+ equipmentProportion.setAgencyId(admin.getAgencyId());
|
|
|
+ TAdmin byId = adminService.getById(admin.getAgencyId());
|
|
|
+ equipmentProportion.setAgencyName(byId.getUsername());
|
|
|
+ }
|
|
|
+ equipmentProportion.setMerchantProportion(adminProportion.getMerchantProportion());
|
|
|
+ if(adminProportion.getMerchantProportion().compareTo(new BigDecimal("0.00"))!=0){
|
|
|
+ equipmentProportion.setMerchantId(admin.getMerchantId());
|
|
|
+ TAdmin byId = adminService.getById(admin.getMerchantId());
|
|
|
+ equipmentProportion.setMerchantName(byId.getUsername());
|
|
|
+ }
|
|
|
+ equipmentProportion.setPersonageProportion(new BigDecimal("0.00"));
|
|
|
+ equipmentProportion.setType(2);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ boolean save = proportionService.save(equipmentProportion);
|
|
|
+ }else {
|
|
|
+ return "原账户没有设置分销!";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return "success";
|
|
|
+ }
|
|
|
}
|
|
|
|