Quellcode durchsuchen

Merge remote-tracking branch 'masetr/develop' into develop

‘linchangsheng’ vor 6 Monaten
Ursprung
Commit
232b4e56a1

+ 3 - 3
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/commonmapper/MaterialMapper.java

@@ -62,7 +62,7 @@ public interface MaterialMapper {
      *
      * @param page
      * @param companyWechatId
-     * @param userId
+     * @param workerId
      * @param orderId
      * @param goodsType
      * @param startTime
@@ -72,7 +72,7 @@ public interface MaterialMapper {
     @InterceptorIgnore(tenantLine = "1", blockAttack = "1", illegalSql = "1")
     IPage<NormRecordVO> normRecordList(IPage page,
                                        @Param("companyWechatId") String companyWechatId,
-                                       @Param("userId") String userId,
+                                       @Param("workerId") String workerId,
                                        @Param("orderId") String orderId,
                                        @Param("goodsType") String goodsType,
                                        @Param("startTime") String startTime,
@@ -81,7 +81,7 @@ public interface MaterialMapper {
     @InterceptorIgnore(tenantLine = "1", blockAttack = "1", illegalSql = "1")
     IPage<PartsRefundVO> partsRefundList(Page<Object> objectPage,
                                          @Param("companyWechatId") String currentCompanyWechatId,
-                                         @Param("userId") String userId,
+                                         @Param("workerId") String workerId,
                                          @Param("type") String type,
                                          @Param("status") String status);
 

+ 10 - 10
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/common/SMSLogic.java

@@ -232,7 +232,7 @@ public class SMSLogic {
         //6位随机数
         if (!active.equals("prd")) {
             //记录发送的code
-            redisUtil.set(Constant.RedisPrefix.SMS + ":" + mobile, "000000", 1 * 60);
+            redisUtil.set(Constant.RedisPrefix.SMS + ":" + mobile, "000000", 60);
         } else {
             Random random = new Random();
             int num = (int) (random.nextDouble() * (1000000 - 100000) + 100000);
@@ -241,15 +241,15 @@ public class SMSLogic {
             map.put("code", code);
             String content = this.send(mobile, TEMPLATE_SMS_CODE, map);
 
-            String beforeDate = DateUtils.formatDate1(new Date());
-            long count = smsRecordService.count(new LambdaQueryWrapper<SmsRecord>()
-                    .eq(SmsRecord::getPhone, mobile)
-                    .ge(SmsRecord::getCreateTime, beforeDate + " 00:00:00")
-                    .le(SmsRecord::getCreateTime, beforeDate + " 23:59:59"));
-            // 一天内超过5次登录,不再发短信
-            if (count > 5) {
-                throw new RemoteServiceException("今天发送短信次数超过5次,今天禁止登录!");
-            }
+//            String beforeDate = DateUtils.formatDate1(new Date());
+//            long count = smsRecordService.count(new LambdaQueryWrapper<SmsRecord>()
+//                    .eq(SmsRecord::getPhone, mobile)
+//                    .ge(SmsRecord::getCreateTime, beforeDate + " 00:00:00")
+//                    .le(SmsRecord::getCreateTime, beforeDate + " 23:59:59"));
+//            // 一天内超过10次登录,不再发短信
+//            if (count > 10) {
+//                throw new RemoteServiceException("今天发送短信次数超过5次,今天禁止登录!");
+//            }
 
             //记录短信内容
             SmsRecord smsRecord = new SmsRecord();

+ 6 - 1
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/material/NormRecordLogic.java

@@ -7,8 +7,11 @@ import com.gree.mall.miniapp.bean.user.CurrentCompanyWechat;
 import com.gree.mall.miniapp.commonmapper.MaterialMapper;
 import com.gree.mall.miniapp.exception.RemoteServiceException;
 import com.gree.mall.miniapp.logic.common.CommonLogic;
+import com.gree.mall.miniapp.plus.entity.User;
+import com.gree.mall.miniapp.plus.service.UserService;
 import com.gree.mall.miniapp.utils.DateUtils;
 import lombok.extern.slf4j.Slf4j;
+import me.chanjar.weixin.cp.bean.WxCpAgent;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
 
@@ -26,6 +29,8 @@ public class NormRecordLogic {
     MaterialMapper materialMapper;
     @Resource
     CommonLogic commonLogic;
+    @Resource
+    UserService userService;
 
     public IPage<NormRecordVO> list(String orderId, String goodsType, String yearMonth, Integer pageNum, Integer pageSize, HttpServletRequest request) {
         String startTime = null;
@@ -37,7 +42,7 @@ public class NormRecordLogic {
         }
         CurrentCompanyWechat wechat = commonLogic.getCurrentCompanyWechat(request);
         IPage<NormRecordVO> page = materialMapper.normRecordList(new Page<>(pageNum, pageSize), wechat.getCurrentCompanyWechatId(),
-                wechat.getUserId(), orderId, goodsType, startTime, endTime);
+                wechat.getUser().getWorkerNumber(), orderId, goodsType, startTime, endTime);
         return page;
     }
 

+ 1 - 1
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/material/PartsRefundLogic.java

@@ -42,7 +42,7 @@ public class PartsRefundLogic {
     public IPage<PartsRefundVO> list(String type, String status, Integer pageNum, Integer pageSize, HttpServletRequest request) {
         CurrentCompanyWechat wechat = commonLogic.getCurrentCompanyWechat(request);
         IPage<PartsRefundVO> page = materialMapper.partsRefundList(new Page<>(pageNum, pageSize), wechat.getCurrentCompanyWechatId(),
-                wechat.getUserId(), type, status);
+                wechat.getUser().getWorkerNumber(), type, status);
         if (CollectionUtil.isNotEmpty(page.getRecords())) {
             // 查出明细
             List<WebsitPartsRetItem> itemList = websitPartsRetItemService.lambdaQuery()

+ 2 - 2
mall-miniapp-service/src/main/resources/mapper/MaterialMapper.xml

@@ -298,7 +298,7 @@
             websit_norm_record a
         WHERE
             a.company_wechat_id = #{companyWechatId}
-            AND a.worker_id = #{userId}
+            AND a.worker_id = #{workerId}
         <if test="orderId!=null and orderId!=''">
             AND a.order_id LIKE CONCAT ('%', #{orderId}, '%')
         </if>
@@ -318,7 +318,7 @@
         websit_parts_ret a
         WHERE
         a.company_wechat_id = #{companyWechatId}
-        AND a.worker_id = #{userId}
+        AND a.worker_id = #{workerId}
         <if test="type!=null and type!=''">
             AND a.type = #{type}
         </if>

+ 6 - 0
mall-server-api/src/main/java/com/gree/mall/manager/constant/Constant.java

@@ -1,5 +1,9 @@
 package com.gree.mall.manager.constant;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
 public class Constant {
 
     //校验的token
@@ -21,6 +25,8 @@ public class Constant {
     // 辅材编号前缀
     public final static String FC = "FC";
 
+    public final static List<String> INIT_INCR_LIST = Arrays.asList("WEBSIT_ID");
+
     public class Ali {
         public final static String ACCESS_KEY_ID = "LTAI4GK1q4mnpCFbonMd1pji";
         public final static String ACCESS_KEY_SECERT = "E5LW0V1H8HBxqjKkExIxaXUgSyex6C";

+ 5 - 1
mall-server-api/src/main/java/com/gree/mall/manager/logic/admin/AdminCompanyWechatLogic.java

@@ -12,6 +12,7 @@ import com.gree.mall.manager.bean.admin.reqDto.AdminUserAddReqBean;
 import com.gree.mall.manager.bean.admin.respDto.AdminCompanyWechatRespPageBean;
 import com.gree.mall.manager.commonmapper.AdminMapper;
 import com.gree.mall.manager.config.wx.WxConfiguration;
+import com.gree.mall.manager.constant.Constant;
 import com.gree.mall.manager.enums.RoleTypeEnum;
 import com.gree.mall.manager.enums.admin.AdminWebsitTypeEnum;
 import com.gree.mall.manager.exception.RemoteServiceException;
@@ -21,6 +22,7 @@ import com.gree.mall.manager.plus.service.AdminCompanyWechatService;
 import com.gree.mall.manager.plus.service.AdminRoleService;
 import com.gree.mall.manager.plus.service.BuyCompanyInfoService;
 import com.gree.mall.manager.plus.service.BuyServiceRecordService;
+import com.gree.mall.manager.utils.CommonUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
@@ -146,9 +148,11 @@ public class AdminCompanyWechatLogic {
         adminWebsit.setParentId("1");
         adminWebsit.setType(AdminWebsitTypeEnum.B.getKey());
         adminWebsit.insert();
+        commonLogic.initIncrKeyValue(adminCompanyWechat.getCompanyWechatId(), adminCompanyWechat.getCompanyName(), Constant.INIT_INCR_LIST);
         //生成网点部门挂在商户目录下
         AdminWebsit adminWebsit2 = new AdminWebsit();
-        adminWebsit2.setWebsitId(IdWorker.getIdStr());
+        String websitId = commonLogic.getIncrKeyValue(adminCompanyWechat.getCompanyWechatId(), "WEBSIT_ID", "A",6);
+        adminWebsit2.setWebsitId(websitId);
         adminWebsit2.setName(adminCompanyWechat.getCompanyName()+"-网点");
         adminWebsit2.setWebsitNumber(adminWebsit.getWebsitId());
         adminWebsit2.setCompanyWechatId(adminCompanyWechat.getCompanyWechatId());

+ 5 - 5
mall-server-api/src/main/java/com/gree/mall/manager/logic/admin/AdminWebsitLogic.java

@@ -174,11 +174,16 @@ public class AdminWebsitLogic {
 //                throw new RemoteServiceException("创建网点数量已达上限3,请联系相关人员");
 //            }
 //        }
+        adminWebsit.setCompanyWechatId(parent.getCompanyWechatId());
+        adminWebsit.setCompanyWechatName(parent.getCompanyWechatName());
 
         if (parent.getType().equals(AdminWebsitTypeEnum.A.getKey())) {
+            adminWebsit.setWebsitId(IdWorker.getIdStr());
             adminWebsit.setType(AdminWebsitTypeEnum.B.getKey());
         } else if (parent.getType().equals(AdminWebsitTypeEnum.B.getKey())) {
             adminWebsit.setType(AdminWebsitTypeEnum.C.getKey());
+            String websitId = commonLogic.getIncrKeyValue(adminWebsit.getCompanyWechatId(), "WEBSIT_ID", "A",6);
+            adminWebsit.setWebsitId(websitId);
         }
 
         if (adminUser.getType() == 2 && adminWebsit.getType().equals(AdminWebsitTypeEnum.C.getKey())) {
@@ -193,11 +198,6 @@ public class AdminWebsitLogic {
             throw new RemoteServiceException("支付配置不能为空");
         }
 
-        adminWebsit.setCompanyWechatId(parent.getCompanyWechatId());
-        adminWebsit.setCompanyWechatName(parent.getCompanyWechatName());
-        if (!adminWebsit.getType().equals(AdminWebsitTypeEnum.C.getKey())) {
-            adminWebsit.setWebsitId(IdWorker.getIdStr());
-        }
         adminWebsit.setWebsitNumber(adminWebsit.getWebsitId());
         adminWebsit.insert();
 

+ 37 - 0
mall-server-api/src/main/java/com/gree/mall/manager/logic/common/CommonLogic.java

@@ -1,5 +1,6 @@
 package com.gree.mall.manager.logic.common;
 
+import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.date.DateUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.TypeReference;
@@ -23,6 +24,8 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
@@ -90,6 +93,8 @@ public class CommonLogic {
 
     @Autowired
     AdminDeptWebsitService adminDeptWebsitService;
+    @Autowired
+    IncrKeyValueService incrKeyValueService;
 
     public Map<String, String> getOSSConfig() throws UnsupportedEncodingException {
         return ossUtil.getConfig();
@@ -583,4 +588,36 @@ public class CommonLogic {
                 return BigDecimal.ZERO;
         }
     }
+
+    @Transactional(propagation = Propagation.REQUIRES_NEW)
+    public String getIncrKeyValue(String companyWechatId, String key, String start, int length) {
+        final IncrKeyValue incrKeyValue = incrKeyValueService.lambdaQuery()
+                .eq(IncrKeyValue::getCompanyWechatId, companyWechatId)
+                .eq(IncrKeyValue::getIncrKey, key)
+                .one();
+        final Integer value = incrKeyValue.getIncrValue();
+        incrKeyValue.setIncrValue(incrKeyValue.getIncrValue() + 1)
+                .updateById();
+        StringBuilder number = new StringBuilder();
+        number.append(start);
+        int ramainLen = length - number.toString().length();
+        //自增 填充位数
+        number.append(String.format("%0" + ramainLen + "d", Integer.parseInt(value.toString())));
+        return number.toString();
+    }
+
+    @Transactional(propagation = Propagation.REQUIRES_NEW)
+    public void initIncrKeyValue(String companyWechatId, String companyWechatName, List<String> keys) {
+        if (CollectionUtil.isNotEmpty(keys)) {
+            List<IncrKeyValue> list = new ArrayList<>();
+            for (String key : keys) {
+                IncrKeyValue incrKeyValue = new IncrKeyValue();
+                incrKeyValue.setCompanyWechatId(companyWechatId)
+                        .setCompanyName(companyWechatName)
+                        .setIncrKey(key);
+                list.add(incrKeyValue);
+            }
+            incrKeyValueService.saveBatch(list);
+        }
+    }
 }

+ 1 - 0
mall-server-api/src/main/java/com/gree/mall/manager/logic/settle/repair/DailyTransferLogic.java

@@ -19,6 +19,7 @@ import com.gree.mall.manager.plus.service.*;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;