Browse Source

连接id没有生成

李天标 2 years ago
parent
commit
5b7b3a4e9d

+ 99 - 0
src/main/java/com/szwl/controller/IndexController.java

@@ -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";
+    }
 }
 

+ 25 - 4
src/main/java/com/szwl/controller/TAdminController.java

@@ -22,6 +22,7 @@ import com.szwl.model.entity.*;
 import com.szwl.model.param.AddLoginUserParam;
 import com.szwl.model.param.UpdateLoginUserParam;
 import com.szwl.model.param.UpdateSysRoleParam;
+import com.szwl.model.utils.AdminUtils;
 import com.szwl.service.*;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -409,12 +410,27 @@ public class TAdminController {
             admin.setIsAdmined(true);
             admin.setPassword(DigestUtils.md5Hex(admin.getPassword()));
             boolean b = tAdminService.save(admin);
-            //todo 绑定商家角色
-            tMessageCode.setModifyDate(new Date());
+
             tMessageCodeService.saveOrUpdate(tMessageCode);
             if(b){
-                admin.setManagerId(admin.getManager());
-                tAdminService.getById(admin);
+                //todo 绑定商家角色
+                LambdaQueryWrapper<SysRole> query4 = Wrappers.lambdaQuery();
+                query4.eq(SysRole::getAdminId,"1");
+                query4.eq(SysRole::getRoleName,"商家");
+                List<SysRole> list2 = sysRoleService.list(query4);
+                if(list2.size()>0){
+                    SysRole sysRole = list2.get(0);
+                    SysUserRole sysUserRole = new SysUserRole();
+                    sysUserRole.setRoleId(sysRole.getRoleId());
+                    sysUserRole.setId(String.valueOf(admin.getId()));
+                    boolean save = sysUserRoleService.save(sysUserRole);
+                }
+                tMessageCode.setModifyDate(new Date());
+                if(admin.getId()!=null){
+                    String managerId = AdminUtils.encrypt(false, admin.getId());
+                    admin.setManagerId(managerId);
+                    tAdminService.getById(admin);
+                }
             }
             return R.ok(b);
 
@@ -443,6 +459,11 @@ public class TAdminController {
         );
         TAdmin tAdmin = Optional.ofNullable(tAdminService.getOnly(query))
                 .orElseThrow(() -> new BizException(ResponseCodesEnum.L0002));
+        if(StringUtils.isEmpty(tAdmin.getManagerId())){
+            String managerId = AdminUtils.encrypt(false, tAdmin.getId());
+            tAdmin.setManagerId(managerId);
+            tAdminService.getById(tAdmin);
+        }
         UserDetailBO userDetailBO = BeanUtil.copyProperties(tAdmin,UserDetailBO.class);
 
         String token = IdUtil.simpleUUID();

+ 4 - 1
src/main/java/com/szwl/mapper/xml/TAdminMapper.xml

@@ -33,11 +33,14 @@
         <result column="code" property="code" />
         <result column="pay_platform" property="payPlatform" />
         <result column="relation_admin_id" property="relationAdminId" />
+        <result column="agency_id" property="agencyId" />
+        <result column="merchant_id" property="merchantId" />
+        <result column="personage_id" property="personageId" />
     </resultMap>
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
-        id, create_date, modify_date, area_id, email, is_admined, is_enabled, is_locked, locked_date, login_date, login_failure_count, login_ip, trade_merchant_no, name, parent_id, password, notice_id, type, username, phone, is_refund, if_foreign, open, promo_code_open, apply_start_time, apply_end_time, code, pay_platform, relation_admin_id
+        id, create_date, modify_date, area_id, email, is_admined, is_enabled, is_locked, locked_date, login_date, login_failure_count, login_ip, trade_merchant_no, name, parent_id, password, notice_id, type, username, phone, is_refund, if_foreign, open, promo_code_open, apply_start_time, apply_end_time, code, pay_platform, relation_admin_id,agency_id,merchant_id,personage_id
     </sql>
     <select id="queryByXml" resultType="com.szwl.model.entity.TAdmin">
         select * from t_admin a

+ 8 - 0
src/main/java/com/szwl/model/entity/TAdmin.java

@@ -120,4 +120,12 @@ public class TAdmin implements Serializable {
         return managerId;
     }
 
+    @ApiModelProperty(value = "一级分销商家id")
+    private Long agencyId;
+
+    @ApiModelProperty(value = "二级分销商家id")
+    private Long merchantId;
+
+    @ApiModelProperty(value = "三级分销商家id")
+    private Long personageId;
 }