Commit d9ef027d by guojuxing

修改超级管理员,添加发送短信业务逻辑

parent 8f31b0c1
......@@ -7,6 +7,9 @@ import java.util.List;
import java.util.Map;
import com.gic.auth.constant.UserConstants;
import com.gic.enterprise.error.ErrorCode;
import com.gic.enterprise.utils.AutoCreatePasswordUtils;
import com.gic.enterprise.utils.UserDetailUtils;
import com.gic.finance.constant.EnterprisePlatformTypeEnum;
import com.gic.marketing.process.api.service.sms.SmsSendApiService;
import com.gic.open.api.dto.market.MarketUserDTO;
......@@ -112,7 +115,7 @@ public class EnterpriseController {
if (result.isSuccess() && UserConstants.CREATE_AUTO == userDTO.getPasswordType().intValue()) {
//发送短信,通知自动生成密码
if (StringUtils.isBlank(userDTO.getPhoneAreaCode())) {
userDTO.setPhoneAreaCode("86");
userDTO.setPhoneAreaCode("+86");
}
String[] smsArr = new String[] { enterpriseDTO.getEnterpriseName(), userDTO.getPhoneNumber(), password };
ServiceResponse<Void> smsSendResult = smsSendApiService.sendPlatformSms("GICpassword001",
......@@ -192,7 +195,33 @@ public class EnterpriseController {
@RequestMapping("/edit-user")
public RestResponse editUser(UserDTO userDTO) {
return ResultControllerUtils.commonResult(userApiService.editAdmin(userDTO));
//自动密码
boolean isAutoPassword = userDTO.getPasswordType() == UserConstants.CREATE_AUTO;
if (isAutoPassword) {
String password = UserPasswordUtil.createPasswordAuto();
//密码加密
userDTO.setPassword(UserPasswordUtil.getEncryptPassword(password));
}
if (userDTO.getPasswordType() != null && userDTO.getPasswordType().intValue() != UserConstants.CREATE_AUTO) {
//如果是自定义密码
if (StringUtils.isBlank(userDTO.getPassword())) {
return RestResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "密码为空,操作有误");
}
userDTO.setPassword(AutoCreatePasswordUtils.encryptPassword(userDTO.getPassword()));
}
ServiceResponse<Void> result = userApiService.editAdmin(userDTO);
//自动创建密码,需要发送短信
if (result.isSuccess() && isAutoPassword) {
String[] smsArr = new String[] { UserDetailUtils.getUserDetail().getEnterpriseInfo().getEnterpriseName(),
userDTO.getPhoneNumber(), userDTO.getPassword() };
ServiceResponse<Void> smsSendResult = smsSendApiService.sendPlatformSms("GICpassword001",
UserDetailUtils.getUserDetail().getEnterpriseId(), userDTO.getPhoneAreaCode(),
userDTO.getPhoneNumber(), smsArr);
if (!smsSendResult.isSuccess()) {
LOGGER.warn(smsSendResult.getMessage());
}
}
return ResultControllerUtils.commonResult(result);
}
@RequestMapping("/get-enterprise")
......@@ -435,7 +464,8 @@ public class EnterpriseController {
@RequestMapping("/list-coupon")
public RestResponse listCoupon(BigDecimal price, Long isvId, Long enterpriseId, Long serveId, Long skuId) {
return ResultControllerUtils.commonResult(
couponApiService.listEnterpriseCouponByServeId(price, isvId, enterpriseId, serveId, skuId), CouponLogVO.class);
couponApiService.listEnterpriseCouponByServeId(price, isvId, enterpriseId, serveId, skuId),
CouponLogVO.class);
}
@RequestMapping("/order-detail")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment