Browse Source

Merge branch 'feature/0721-tenant' into develop

Eric 1 year ago
parent
commit
816cdb0ef2

+ 1 - 1
cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/client/SysUserFeignService.java

@@ -66,7 +66,7 @@ public interface SysUserFeignService {
 	@ApiOperation(value = "退出登录")
 	HttpResponseResult<String> logout();
 
-	@GetMapping(value = "exit/{clientId}/{phone}")
+	@GetMapping(value = "exit/{clientId}/{phone}", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
 	@ApiOperation(value = "退出登录")
 	HttpResponseResult<String> logout(@PathVariable("clientId") String clientId, @PathVariable("phone") String phone);
 

+ 31 - 0
cooleshow-auth/auth-api/src/main/java/com/yonge/cooleshow/auth/api/entity/UserPassword.java

@@ -0,0 +1,31 @@
+package com.yonge.cooleshow.auth.api.entity;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+
+@ApiModel("用户账号密码")
+@Data
+public class UserPassword {
+
+
+    @ApiModel("校验密码")
+    @Data
+    public static class CheckPassword {
+
+        @ApiModelProperty("密码")
+        @NotNull(message = "密码不能为空")
+        private String password;
+    }
+
+    @ApiModel("校验验证码")
+    @Data
+    public static class CheckVerityCode {
+
+        @ApiModelProperty("验证码")
+        @NotNull(message = "验证码不能为空")
+        private String code;
+    }
+}

+ 26 - 0
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/web/controller/UserController.java

@@ -6,6 +6,7 @@ import com.yonge.cooleshow.auth.api.dto.UpdatePasswordDto;
 import com.yonge.cooleshow.auth.api.dto.UserSetReq;
 import com.yonge.cooleshow.auth.api.entity.SysRole;
 import com.yonge.cooleshow.auth.api.entity.SysUser;
+import com.yonge.cooleshow.auth.api.entity.UserPassword;
 import com.yonge.cooleshow.auth.api.vo.UserSetVo;
 import com.yonge.cooleshow.auth.core.service.CustomTokenServices;
 import com.yonge.cooleshow.auth.service.SysConfigService;
@@ -40,6 +41,7 @@ import org.springframework.http.MediaType;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.security.authentication.BadCredentialsException;
 import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
+import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
 import javax.validation.Valid;
@@ -672,4 +674,28 @@ public class UserController extends BaseController {
         result.put("customerServicePhone",sysConfigService.findConfigValue("customer_service_phone"));
         return succeed(result);
     }
+
+    @PostMapping("/checkPassword")
+    @ApiOperation(value = "校验密码")
+    public Object checkPassword(@Validated @RequestBody UserPassword.CheckPassword checkPassword){
+        AuthUser authUser = SecurityUtils.getUser();
+        SysUser sysUser = sysUserService.get(authUser.getUserId());
+        BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
+        if(!encoder.matches(checkPassword.getPassword(),sysUser.getPassword())){
+            throw new BizException("原密码错误");
+        }
+        return succeed();
+    }
+
+    @PostMapping("/checkVerityCode")
+    @ApiOperation(value = "校验验证码")
+    public Object checkVerityCode(@Validated @RequestBody UserPassword.CheckVerityCode checkVerityCode) {
+        AuthUser authUser = SecurityUtils.getUser();
+        SysUser sysUser = sysUserService.get(authUser.getUserId());
+        if (!smsCodeService.verifyValidCode(sysUser.getPhone(), checkVerityCode.getCode(),
+                "SMS_VERIFY_CODE_UPDATE_PSW")) {
+            return failed("验证码错误");
+        }
+        return succeed();
+    }
 }

+ 64 - 14
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TenantActivationCodeServiceImpl.java

@@ -416,10 +416,19 @@ public class TenantActivationCodeServiceImpl extends ServiceImpl<TenantActivatio
         List<StudentVo> studentVos = studentDao.selectPage(PageUtil.getPage(studentSearch), studentSearch);
         Map<String, StudentVo> mapStudentByPhone = studentVos.stream().collect(Collectors.toMap(StudentVo::getPhone, Function.identity()));
 
-        Map<Integer,List<String>> errMsgMap = new LinkedHashMap<>();
+//        Map<Integer,List<String>> errMsgMap = new LinkedHashMap<>();
         Map<String, Integer> codeRowMap = new HashMap<>();
 
-        String errTemplate = "第%s行%s";
+
+        String phone_err = "手机号错误或已注册成为其他机构";
+        List<Integer> phone_err_lines = new ArrayList<>();
+        String code_send = "激活码已被发放";
+        List<Integer> code_send_lines = new ArrayList<>();
+        String code_not_exist = "激活码不存在";
+        List<Integer> code_not_exist_lines = new ArrayList<>();
+        String code_repeat = "激活码重复";
+        Map<String,List<Integer>> code_repeat_lines = new LinkedHashMap<>();
+
         int rowIndex = 1;
         // 校验数据格式是否错误 第二行开始取数据
         for (TenantActivationCodeWrapper.ImportTemplate template : importTemplates) {
@@ -430,40 +439,81 @@ public class TenantActivationCodeServiceImpl extends ServiceImpl<TenantActivatio
                 continue;
             }
             int msgRowNo = rowIndex;
-            List<String> errList = errMsgMap.getOrDefault(msgRowNo, new ArrayList<>());
+//            List<String> errList = errMsgMap.getOrDefault(msgRowNo, new ArrayList<>());
             String code = template.getCode();
             if (codeRowMap.containsKey(code)) {
-                errList.add(String.format(errTemplate, msgRowNo, "激活码重复"));
+                List<Integer> lines = code_repeat_lines.getOrDefault(code, new ArrayList<>());
+                Integer repeatLine = codeRowMap.get(code);
+                if (!lines.contains(repeatLine)) {
+                    lines.add(repeatLine);
+                }
+                lines.add(msgRowNo);
             } else {
                 codeRowMap.put(acCode, msgRowNo);
             }
 
             if (!mapByCode.containsKey(code)) {
-                errList.add(String.format(errTemplate, msgRowNo, "激活码不存在"));
+                code_not_exist_lines.add(msgRowNo);
             } else {
                 TenantActivationCode tenantActivationCode = mapByCode.get(code);
                 if (tenantActivationCode.getActivationStatus() || EActivationCode.SEND.equals(tenantActivationCode.getSendStatus())) {
-                    errList.add(String.format(errTemplate, msgRowNo, "激活码已被发放/激活"));
+                    code_send_lines.add(msgRowNo);
                 }
             }
             String phone = template.getPhone();
             if (StringUtils.isNotEmpty(phone)) {
                 if (!Pattern.matches(PHONE_REG, phone.trim()) ||
                         (mapStudentByPhone.containsKey(phone) && !mapStudentByPhone.get(phone).getTenantId().equals(tenantId))) {
-                    errList.add(String.format(errTemplate, msgRowNo, "手机号错误或已注册成为其他机构学员"));
+                    phone_err_lines.add(msgRowNo);
                 }
             }
 
-            errMsgMap.put(msgRowNo, errList);
+//            errMsgMap.put(msgRowNo, errList);
         }
 
-        List<String> errMsg = errMsgMap.values().stream().flatMap(Collection::stream).collect(Collectors.toList());
-        if (!errMsg.isEmpty()) {
-            String errLines = errMsgMap.entrySet().stream().filter(next -> CollectionUtils.isNotEmpty(next.getValue()))
-                    .map(next -> String.valueOf(next.getKey())).collect(Collectors.joining("、"));
-            errMsg.add(0, "第" + errLines + "行存在错误");
-            throw new BizException(String.join(",", errMsg));
+
+        int totalErrSize = phone_err_lines.size() + code_send_lines.size() + code_not_exist_lines.size() + code_repeat_lines.values().size();
+        if (totalErrSize > 0) {
+            StringBuilder errMsg = new StringBuilder("");
+            errMsg.append("导入失败,共").append(totalErrSize).append("条错误信息~");
+            if (!phone_err_lines.isEmpty()) {
+                errMsg.append("\n");
+                String errLines = phone_err_lines.stream().map(String::valueOf).collect(Collectors.joining("、"));
+                errMsg.append("第").append(errLines).append("行错误,").append(phone_err);
+            }
+
+            if (!code_send_lines.isEmpty()) {
+                errMsg.append("\n");
+                String errLines = code_send_lines.stream().map(String::valueOf).collect(Collectors.joining("、"));
+                errMsg.append("第").append(errLines).append("行错误,").append(errLines).append(code_send);
+            }
+
+            if (!code_not_exist_lines.isEmpty()) {
+                errMsg.append("\n");
+                String errLines = code_not_exist_lines.stream().map(String::valueOf).collect(Collectors.joining("、"));
+                errMsg.append("第").append(errLines).append("行错误,").append(code_not_exist);
+            }
+
+            if (!code_repeat_lines.isEmpty()) {
+                errMsg.append("\n");
+                List<String> lineErr = new ArrayList<>();
+                for (List<Integer> value : code_repeat_lines.values()) {
+                    String errLines = value.stream().map(String::valueOf).collect(Collectors.joining("、"));
+                    lineErr.add("第" + errLines + "行");
+                }
+                errMsg.append(String.join(",", lineErr)).append("行错误,").append(code_repeat);
+            }
+            throw new BizException(errMsg.toString());
         }
+
+
+//        List<String> errMsg = errMsgMap.values().stream().flatMap(Collection::stream).collect(Collectors.toList());
+//        if (!errMsg.isEmpty()) {
+//            String errLines = errMsgMap.entrySet().stream().filter(next -> CollectionUtils.isNotEmpty(next.getValue()))
+//                    .map(next -> String.valueOf(next.getKey())).collect(Collectors.joining("、"));
+//            errMsg.add(0, "第" + errLines + "行存在错误");
+//            throw new BizException(String.join(",", errMsg));
+//        }
         List<TenantActivationCode> tenantActivationCodes = importTemplates.stream()
                 .filter(next -> StringUtils.isNotEmpty(next.getCode()) && StringUtils.isNotBlank(next.getPhone()))
                 .map(next -> {

+ 8 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/UserPaymentCoreServiceImpl.java

@@ -501,9 +501,16 @@ public class UserPaymentCoreServiceImpl implements UserPaymentCoreService {
     public UserPaymentOrderWrapper.PaymentConfig executeOrder(UserPaymentOrderWrapper.UserPaymentOrder orderReq) {
 
         // 填充订单基本信息
+        String defaultService = paymentServiceContext.defaultService();
+        if (EPayerType.ORIGINAL.getCode().toLowerCase().equals(defaultService)) {
+            // 原生支付需要传入支付三方渠道
+            if (StringUtils.isEmpty(orderReq.getPaymentType())) {
+                throw new BizException("支付三方渠道不能为空");
+            }
+        }
         orderReq
             .orderNo(IdWorker.getIdStr())
-            .paymentVender(Optional.ofNullable(orderReq.getPaymentType()).orElse(paymentServiceContext.getPaymentService().venderName()))
+            .paymentVender(Optional.ofNullable(orderReq.getPaymentType()).orElse(defaultService))
             .paymentChannel("")
             .status(EPaymentStatus.WAIT_PAY)
             .originalPrice(BigDecimal.ZERO);