From 48aa92e2b807604819985e26b3be1405d5336e47 Mon Sep 17 00:00:00 2001 From: Jack <46790855@qq.com> Date: Thu, 12 Dec 2024 10:01:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E8=B4=A7=E9=82=AE=E4=BB=B6=E9=82=AE?= =?UTF-8?q?=E4=BB=B6=20bug=20=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/AccountUserBaseService.java | 2 + .../impl/AccountUserBaseServiceImpl.java | 187 ++++++++++++------ mall-common/pom.xml | 42 ++++ .../mall/common/constant/CommonConstant.java | 13 ++ .../mall/common/pojo/dto/EmailDto.java | 44 +++++ .../mall/common/pojo/dto/ErrorTypeEnum.java | 51 +++++ .../suisung/mall/common/pojo/dto/SmsDto.java | 73 +++++++ .../mall/common/service/ThirdService.java | 10 + .../common/service/impl/AliServiceImpl.java | 67 +++++++ .../service/impl/DefaultSmsServiceImpl.java | 50 +++++ .../service/impl/HuaweiServiceimpl.java | 43 ++++ .../service/impl/TencentServiceImpl.java | 61 ++++++ .../mall/common/utils/ContextUtil.java | 2 - .../suisung/mall/common/utils/ThirdUtil.java | 37 ++++ .../suisung/mall/MallGatewayApplication.java | 12 +- .../service/impl/EsProductServiceImpl.java | 5 +- mall-shop/pom.xml | 17 +- .../quartz/job/RsyncNoticeMsgJob.java | 10 +- .../service/ShopMessageTemplateService.java | 12 ++ .../impl/ShopMessageTemplateServiceImpl.java | 153 ++++++++++++-- .../shop/order/listener/MessageListener.java | 1 + .../impl/ShopOrderBaseServiceImpl.java | 97 ++++++--- .../service/ShopProductBaseService.java | 4 + .../impl/ShopProductAnalyticsServiceImpl.java | 11 +- .../impl/ShopProductBaseServiceImpl.java | 42 ++++ .../service/impl/SFExpressApiServiceImpl.java | 5 +- .../admin/ShopStorePrinterController.java | 12 +- .../store/mapper/ShopStoreEmployeeMapper.java | 10 + .../ShopStoreEmployeeRightsGroupService.java | 8 + .../service/ShopStoreEmployeeService.java | 8 + .../store/service/ShopStoreInfoService.java | 8 + ...opStoreEmployeeRightsGroupServiceImpl.java | 13 +- .../impl/ShopStoreEmployeeServiceImpl.java | 37 +++- .../impl/ShopStoreInfoServiceImpl.java | 14 +- .../mapper/store/ShopStoreEmployeeMapper.xml | 15 ++ 35 files changed, 1062 insertions(+), 114 deletions(-) create mode 100644 mall-common/src/main/java/com/suisung/mall/common/pojo/dto/EmailDto.java create mode 100644 mall-common/src/main/java/com/suisung/mall/common/pojo/dto/ErrorTypeEnum.java create mode 100644 mall-common/src/main/java/com/suisung/mall/common/pojo/dto/SmsDto.java create mode 100644 mall-common/src/main/java/com/suisung/mall/common/service/ThirdService.java create mode 100644 mall-common/src/main/java/com/suisung/mall/common/service/impl/AliServiceImpl.java create mode 100644 mall-common/src/main/java/com/suisung/mall/common/service/impl/DefaultSmsServiceImpl.java create mode 100644 mall-common/src/main/java/com/suisung/mall/common/service/impl/HuaweiServiceimpl.java create mode 100644 mall-common/src/main/java/com/suisung/mall/common/service/impl/TencentServiceImpl.java create mode 100644 mall-common/src/main/java/com/suisung/mall/common/utils/ThirdUtil.java diff --git a/mall-account/src/main/java/com/suisung/mall/account/service/AccountUserBaseService.java b/mall-account/src/main/java/com/suisung/mall/account/service/AccountUserBaseService.java index 9cbbe7df..c5a0eb0b 100644 --- a/mall-account/src/main/java/com/suisung/mall/account/service/AccountUserBaseService.java +++ b/mall-account/src/main/java/com/suisung/mall/account/service/AccountUserBaseService.java @@ -141,4 +141,6 @@ public interface AccountUserBaseService extends IBaseService { * @param code */ void callbackGoogle(HttpServletResponse response, String code); + + boolean changePassword(String old_password, String password); } diff --git a/mall-account/src/main/java/com/suisung/mall/account/service/impl/AccountUserBaseServiceImpl.java b/mall-account/src/main/java/com/suisung/mall/account/service/impl/AccountUserBaseServiceImpl.java index 93febc2e..8137b036 100644 --- a/mall-account/src/main/java/com/suisung/mall/account/service/impl/AccountUserBaseServiceImpl.java +++ b/mall-account/src/main/java/com/suisung/mall/account/service/impl/AccountUserBaseServiceImpl.java @@ -48,12 +48,12 @@ import com.suisung.mall.common.modules.distribution.ShopDistributionUser; import com.suisung.mall.common.modules.distribution.ShopDistributionUserCommission; import com.suisung.mall.common.modules.pay.PayUserResource; import com.suisung.mall.common.modules.plantform.ShopPlantformSubsiteUser; +import com.suisung.mall.common.pojo.dto.SmsDto; import com.suisung.mall.common.service.MessageService; import com.suisung.mall.common.utils.*; import com.suisung.mall.common.utils.constbank.RSAUtil; import com.suisung.mall.common.utils.phone.PhoneNumberUtils; import com.suisung.mall.common.utils.pojo.dto.EmailDTO; -import com.suisung.mall.core.web.model.SmsDto; import com.suisung.mall.core.web.service.CloundService; import com.suisung.mall.core.web.service.RedisService; import com.suisung.mall.core.web.service.impl.BaseServiceImpl; @@ -89,75 +89,52 @@ import static com.suisung.mall.common.utils.I18nUtil._; @Service public class AccountUserBaseServiceImpl extends BaseServiceImpl implements AccountUserBaseService { + private final String VERIFY_CODE_KEY = "register:verifyCode:"; @Autowired private AuthService authService; - @Autowired private AdminService adminService; - @Autowired private SnsService snsService; - @Autowired private HttpServletRequest request; - @Autowired private RedisService redisService; - @Autowired private ShopService shopService; - @Autowired private PayService payService; - @Autowired private AccountUserInfoService accountUserInfoService; - @Autowired private AccountUserLoginService accountUserLoginService; - @Autowired private AccountBaseConfigService accountBaseConfigService; - @Autowired private AccountBaseUserLevelService baseUserLevelService; - @Autowired private AccountUserSnsService accountUserSnsService; - @Autowired private AccountUserBindConnectService bindConnectService; - @Autowired private AccountUserTypeService accountUserTypeService; - @Autowired private MessageService messageService; - @Autowired private WeiXinService weiXinService; - @Autowired private AccountUserBindConnectService accountUserBindConnectService; - @Autowired private AccountUserBaseService accountUserBaseService; - @Autowired private AccountUserChannelCodeService accountUserChannelCodeService; - @Autowired private AccountUserChannelService accountUserChannelService; - @Autowired private AccountUserBaseMapper accountUserBaseMapper; - @Autowired private CloundService cloundService; - - private final String VERIFY_CODE_KEY = "register:verifyCode:"; - - private Logger logger = LoggerFactory.getLogger(AccountUserBaseServiceImpl.class); + private final Logger logger = LoggerFactory.getLogger(AccountUserBaseServiceImpl.class); @Override public CommonResult login(Map params) { @@ -345,7 +322,6 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl 60 * 4) { + throw new ApiException(_("验证码获取频率太高,请稍后再试")); + } } String verifyCode = RandomUtil.randomNumbers(4); @@ -2271,20 +2250,60 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl queryWrapper = new QueryWrapper<>(); queryWrapper.eq("config_type", "email"); @@ -2294,7 +2313,7 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl configMap = configs.stream().collect(Collectors.toMap(AccountBaseConfig::getConfig_key, AccountBaseConfig::getConfig_value, (k1, k2) -> k2)); EmailDTO emailDTO = Convert.convert(EmailDTO.class, configMap); emailDTO.setEmail_to_Address(number); - emailDTO.setSubject(String.format(_("%s 注册验证码"), accountBaseConfigService.getConfig("site_name", "lancerdt"))); + emailDTO.setSubject(String.format(_("%s 注册验证码"), accountBaseConfigService.getConfig("site_name", "MallSuite"))); emailDTO.setContent(String.format(_("您的验证码: [%s] 5分钟内有效"), verifyCode)); try { return EmailUtil.send(emailDTO); @@ -2322,19 +2341,61 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl queryWrapper = new QueryWrapper<>(); queryWrapper.eq("config_type", "email"); @@ -2343,7 +2404,7 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl configMap = configs.stream().collect(Collectors.toMap(AccountBaseConfig::getConfig_key, AccountBaseConfig::getConfig_value, (k1, k2) -> k2)); EmailDTO emailDTO = Convert.convert(EmailDTO.class, configMap); emailDTO.setEmail_to_Address(number); - emailDTO.setSubject(String.format(_("%s 用户找回密码 验证码"), accountBaseConfigService.getConfig("site_name", "lancerdt"))); + emailDTO.setSubject(String.format(_("%s 用户找回密码 验证码"), accountBaseConfigService.getConfig("site_name", "MallSuite"))); emailDTO.setContent(String.format(_("您的验证码: [%s] 5分钟内有效"), verifyCode)); try { return EmailUtil.send(emailDTO); @@ -2370,7 +2431,7 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl list = super.gets(ids); UserDto currentUser = getCurrentUser(); - if ((currentUser!=null&¤tUser.getClient_id().equals(AuthConstant.ADMIN_CLIENT_ID)) && ConfigConstant.URL_BASE.equals("https://demo.lancerdt.com")) { + if ((currentUser != null && currentUser.getClient_id().equals(AuthConstant.ADMIN_CLIENT_ID)) && ConfigConstant.URL_BASE.equals("https://demo.mallsuite.cn")) { for (AccountUserBase it : list) { if (ObjectUtil.isNotEmpty(it)) { String userAccount = it.getUser_account(); @@ -2861,4 +2922,20 @@ public class AccountUserBaseServiceImpl extends BaseServiceImplcom.aliyun.oss aliyun-sdk-oss + + com.aliyun + aliyun-java-sdk-core + 4.5.16 + + + com.aliyun + aliyun-java-sdk-dysmsapi + 2.1.0 + + + com.tencentcloudapi + tencentcloud-sdk-java + 3.1.87 + + + com.github.qcloudsms + qcloudsms + 1.0.6 + + + com.apistd.uni + uni-sdk + 0.0.4 + + + com.qcloud + cos_api + 5.6.8 + + + + org.slf4j + slf4j-log4j12 + + + + + com.huaweicloud + esdk-obs-java-bundle + 3.21.11 + com.googlecode.libphonenumber diff --git a/mall-common/src/main/java/com/suisung/mall/common/constant/CommonConstant.java b/mall-common/src/main/java/com/suisung/mall/common/constant/CommonConstant.java index 00e110ff..3fa9c704 100644 --- a/mall-common/src/main/java/com/suisung/mall/common/constant/CommonConstant.java +++ b/mall-common/src/main/java/com/suisung/mall/common/constant/CommonConstant.java @@ -18,4 +18,17 @@ public class CommonConstant { public static final Integer Delivery_Amount_Comput_Type_Original = 1; public static final Integer Delivery_Amount_Comput_Type_Discounted = 2; public static final Integer Delivery_Amount_Comput_Type_Payment = 3; + + // 店铺角色权限组 + public static final String STORE_RIGHT_GROUP_ADMIN = "店铺管理员"; // 店铺管理员; + public static final String STORE_RIGHT_GROUP_YYJL = "运营经理"; // 店铺管理员; + public static final String STORE_RIGHT_GROUP_DDSHY = "订单审核员"; // 店铺管理员; + public static final String STORE_RIGHT_GROUP_CWSHY = "财务审核员"; // 店铺管理员; + public static final String STORE_RIGHT_GROUP_FHSHY = "发货审核员"; // 店铺管理员; + public static final String STORE_RIGHT_GROUP_YWJL = "业务经理"; // 店铺管理员; + public static final String STORE_RIGHT_GROUP_CKGLY = "仓库管理员"; // 店铺管理员; + public static final String STORE_RIGHT_GROUP_ZLWHY = "资料维护员"; // 店铺管理员; + public static final String STORE_RIGHT_GROUP_KF = "客服"; // 店铺管理员; + public static final String STORE_RIGHT_GROUP_KZ1 = "扩展1"; // 店铺管理员; + public static final String STORE_RIGHT_GROUP_KZ2 = "扩展2"; // 店铺管理员; } diff --git a/mall-common/src/main/java/com/suisung/mall/common/pojo/dto/EmailDto.java b/mall-common/src/main/java/com/suisung/mall/common/pojo/dto/EmailDto.java new file mode 100644 index 00000000..46d1f4a9 --- /dev/null +++ b/mall-common/src/main/java/com/suisung/mall/common/pojo/dto/EmailDto.java @@ -0,0 +1,44 @@ +package com.suisung.mall.common.pojo.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = false) +@ApiModel(value = "邮件配置DTO", description = "邮件配置DTO") +public class EmailDto { + @ApiModelProperty("发信邮箱") + private String emailAddr; + + @ApiModelProperty("发信人") + private String emailFromname; + + @ApiModelProperty("SMTP 服务器") + private String emailHost; + + @ApiModelProperty("SMTP 端口号") + private Integer emailPort; + + @ApiModelProperty("单行SMTP 身份验证用户名") + private String emailId; + + @ApiModelProperty("SMTP 身份验证密码") + private String emailPass; + + @ApiModelProperty("是否加密") + private String emailSecure; + + @ApiModelProperty("调试级别") + private String emailDebug; + + @ApiModelProperty("测试接收的邮件地址") + private String emailToAddress; + + @ApiModelProperty("邮件主题") + private String subject; + + @ApiModelProperty("邮件内容") + private String content; +} \ No newline at end of file diff --git a/mall-common/src/main/java/com/suisung/mall/common/pojo/dto/ErrorTypeEnum.java b/mall-common/src/main/java/com/suisung/mall/common/pojo/dto/ErrorTypeEnum.java new file mode 100644 index 00000000..541135da --- /dev/null +++ b/mall-common/src/main/java/com/suisung/mall/common/pojo/dto/ErrorTypeEnum.java @@ -0,0 +1,51 @@ +package com.suisung.mall.common.pojo.dto; + +import cn.hutool.core.collection.CollUtil; +import lombok.Getter; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Getter +public enum ErrorTypeEnum { + + ERR_NOT_DEFINITION("未分类异常", 0), + ERR_WX_JSPI("微信JSPI异常", 2001), + ERR_WX_XCX("微信小程序异常", 2002), + ERR_WX_MP("微信公众号异常", 2003), + ERR_ALI_PAY("支付宝支付异常", 3001), + ERR_PSUH_MSG("消息推送异常", 4001), + ERR_ALI_SERVICE("阿里云服务异常", 5001), + ERR_TENCENT_SERVICE("腾讯云服务异常", 5002), + ERR_HUAWEI_SERVICE("华为云服务异常", 5003), + + ERR_ORDER_SERVICE("订单处理异常", 6001); + + private final String label; + + private final int value; + + ErrorTypeEnum(String label, int value) { + this.label = label; + this.value = value; + } + + private static final List> errorTypes = new ArrayList<>(); + + public static List> getAllValues() { + if (CollUtil.isNotEmpty(errorTypes)) { + return errorTypes; + } + ErrorTypeEnum[] typeEnumList = values(); + for (ErrorTypeEnum typeEnum : typeEnumList) { + Map errorMap = new HashMap<>(); + errorMap.put("label", typeEnum.getLabel()); + errorMap.put("value", typeEnum.getValue()); + errorTypes.add(errorMap); + } + return errorTypes; + } + +} diff --git a/mall-common/src/main/java/com/suisung/mall/common/pojo/dto/SmsDto.java b/mall-common/src/main/java/com/suisung/mall/common/pojo/dto/SmsDto.java new file mode 100644 index 00000000..cc991d98 --- /dev/null +++ b/mall-common/src/main/java/com/suisung/mall/common/pojo/dto/SmsDto.java @@ -0,0 +1,73 @@ +package com.suisung.mall.common.pojo.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Map; + +@Data +@EqualsAndHashCode(callSuper = false) +@ApiModel(value = "短信发送DTO", description = "短信发送DTO") +public class SmsDto { + + @ApiModelProperty(value = "短信类型") + private Integer smsType; + + @ApiModelProperty(value = "手机号码") + private String mobile; + + @ApiModelProperty(value = "短信内容") + private String content; + + @ApiModelProperty(value = "模板编号-扩展使用") + private String tplId; + + @ApiModelProperty(value = "签名通道号-扩展使用") + private String messageTplSender; + + @ApiModelProperty(value = "动态参数-扩展使用") + private Map tplParas; + + @ApiModelProperty(value = "账号/平台id") + private String serviceUserId; + + @ApiModelProperty(value = "短信KEY/平台KEY") + private String serviceAppKey; + + + @ApiModelProperty(value = "tengxun_sms_app_id") + private Integer tengxunAppId; + + @ApiModelProperty(value = "tengxun_sms_app_key") + private String tengxunAppkey; + + + @ApiModelProperty(value = "腾讯云模板id") + private Integer tengxunTemplateId; + + @ApiModelProperty(value = "huawei_sms_access_key") + private String huaweiSmsKey; + + @ApiModelProperty(value = "huawei_sms_access_secret") + private String huaweiSmsKeySecret; + + @ApiModelProperty(value = "aliyun_sms_access_key_id") + private String aliyunSmsAccessKeyId; + + @ApiModelProperty(value = "aliyun_sms_access_key_secret") + private String aliyunSmsAccessKeySecret; + + @ApiModelProperty(value = "aliyun_sms_region_id") + private String aliyunSmsRegionId; + + @ApiModelProperty(value = "阿里云模板code") + private String templateCode; + + @ApiModelProperty(value = "阿里云短信参数") + private Map paramMap; + + @ApiModelProperty(value = "sms_sign") + private String smsSign; +} \ No newline at end of file diff --git a/mall-common/src/main/java/com/suisung/mall/common/service/ThirdService.java b/mall-common/src/main/java/com/suisung/mall/common/service/ThirdService.java new file mode 100644 index 00000000..c8f67ee1 --- /dev/null +++ b/mall-common/src/main/java/com/suisung/mall/common/service/ThirdService.java @@ -0,0 +1,10 @@ +package com.suisung.mall.common.service; + +import com.suisung.mall.common.pojo.dto.SmsDto; + +/** + * 第三方服务 + */ +public interface ThirdService { + void send(SmsDto smsDto); +} diff --git a/mall-common/src/main/java/com/suisung/mall/common/service/impl/AliServiceImpl.java b/mall-common/src/main/java/com/suisung/mall/common/service/impl/AliServiceImpl.java new file mode 100644 index 00000000..df5168eb --- /dev/null +++ b/mall-common/src/main/java/com/suisung/mall/common/service/impl/AliServiceImpl.java @@ -0,0 +1,67 @@ +package com.suisung.mall.common.service.impl; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.json.JSONUtil; +import com.aliyuncs.DefaultAcsClient; +import com.aliyuncs.IAcsClient; +import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest; +import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse; +import com.aliyuncs.exceptions.ClientException; +import com.aliyuncs.profile.DefaultProfile; +import com.suisung.mall.common.exception.ApiException; +import com.suisung.mall.common.pojo.dto.ErrorTypeEnum; +import com.suisung.mall.common.pojo.dto.SmsDto; +import com.suisung.mall.common.service.ThirdService; +import com.suisung.mall.common.utils.LogUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +import java.util.Map; + +@Service +public class AliServiceImpl implements ThirdService { + private final Logger logger = LoggerFactory.getLogger(AliServiceImpl.class); + + @Override + public void send(SmsDto smsDto) { + String aliyunSmsAccessKeyId = smsDto.getAliyunSmsAccessKeyId(); + String aliyunSmsAccessKeySecret = smsDto.getAliyunSmsAccessKeySecret(); + String aliyunSmsRegionId = smsDto.getAliyunSmsRegionId(); + String smsSign = smsDto.getSmsSign(); + + DefaultProfile profile = DefaultProfile.getProfile(aliyunSmsRegionId, aliyunSmsAccessKeyId, aliyunSmsAccessKeySecret); + IAcsClient client = new DefaultAcsClient(profile); + // 组装请求对象-具体描述见控制台-文档部分内容 + SendSmsRequest request = new SendSmsRequest(); + // 必填:待发送手机号 + request.setPhoneNumbers(smsDto.getMobile()); + // 必填:短信签名-可在短信控制台中找到 + request.setSignName(smsSign); + // 必填:短信模板-可在短信控制台中找到 + request.setTemplateCode(smsDto.getTemplateCode()); + // 选填:参考:https://help.aliyun.com/zh/sms/developer-reference/api-dysmsapi-2017-05-25-sendsms?spm=a2c4g.11186623.help-menu-44282.d_4_2_4_2_0.380018db3iM2mx + Map paramMap = smsDto.getParamMap(); + if (CollUtil.isNotEmpty(paramMap)) { +// String str = paramMap.toString(); +// str = str.replaceAll("=", ":"); + request.setTemplateParam(JSONUtil.toJsonStr(paramMap)); // json 格式 + } + + logger.info("阿里云短信发送请求的参数:{}", JSONUtil.toJsonStr(smsDto)); + + // 获取发送结果 + try { + SendSmsResponse response = client.getAcsResponse(request); + logger.info("阿里云短信发送返回结果:{}", response); + if (!response.getCode().equals("OK")) { + String errMsg = response.getMessage(); + LogUtil.error(ErrorTypeEnum.ERR_ALI_SERVICE.getValue(), errMsg); + throw new ApiException(errMsg); + } + } catch (ClientException e) { + LogUtil.error(ErrorTypeEnum.ERR_ALI_SERVICE.getValue(), e); + throw new ApiException(e.getMessage()); + } + } +} diff --git a/mall-common/src/main/java/com/suisung/mall/common/service/impl/DefaultSmsServiceImpl.java b/mall-common/src/main/java/com/suisung/mall/common/service/impl/DefaultSmsServiceImpl.java new file mode 100644 index 00000000..6e8e2ad9 --- /dev/null +++ b/mall-common/src/main/java/com/suisung/mall/common/service/impl/DefaultSmsServiceImpl.java @@ -0,0 +1,50 @@ +package com.suisung.mall.common.service.impl; + +import com.suisung.mall.common.exception.ApiException; +import com.suisung.mall.common.pojo.dto.ErrorTypeEnum; +import com.suisung.mall.common.pojo.dto.SmsDto; +import com.suisung.mall.common.service.ThirdService; +import com.suisung.mall.common.utils.LogUtil; +import com.suisung.mall.core.web.service.CloundService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Service; + +import java.util.Map; + +@Service +@Primary +public class DefaultSmsServiceImpl implements ThirdService { + + @Autowired + private CloundService cloundService; + + @Override + public void send(SmsDto smsDto) { + boolean flag = true; + String configBaseUserId = smsDto.getServiceUserId(); + String configBaseAppKey = smsDto.getServiceAppKey(); + + com.suisung.mall.core.web.model.SmsDto smsData = new com.suisung.mall.core.web.model.SmsDto(); + smsData.setMobile(smsDto.getMobile()); + smsData.setServiceUserId(configBaseUserId); + smsData.setServiceAppKey(configBaseAppKey); + + String msgContent = smsDto.getContent(); + + for (Map.Entry entry : smsDto.getParamMap().entrySet()) { + String variable = "[" + entry.getKey() + "]"; + Object value = entry.getValue(); + msgContent = msgContent.replace(variable, value.toString()); + } + + smsData.setContent(msgContent); + + try { + cloundService.send(smsData); + } catch (Exception e) { + LogUtil.error(ErrorTypeEnum.ERR_NOT_DEFINITION.getValue(), e); + throw new ApiException(e.getMessage()); + } + } +} diff --git a/mall-common/src/main/java/com/suisung/mall/common/service/impl/HuaweiServiceimpl.java b/mall-common/src/main/java/com/suisung/mall/common/service/impl/HuaweiServiceimpl.java new file mode 100644 index 00000000..23511fb4 --- /dev/null +++ b/mall-common/src/main/java/com/suisung/mall/common/service/impl/HuaweiServiceimpl.java @@ -0,0 +1,43 @@ +package com.suisung.mall.common.service.impl; + +import com.apistd.uni.Uni; +import com.apistd.uni.UniException; +import com.apistd.uni.UniResponse; +import com.apistd.uni.sms.UniMessage; +import com.apistd.uni.sms.UniSMS; +import com.suisung.mall.common.pojo.dto.ErrorTypeEnum; +import com.suisung.mall.common.pojo.dto.SmsDto; +import com.suisung.mall.common.service.ThirdService; +import com.suisung.mall.common.utils.LogUtil; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.Map; + +@Service +public class HuaweiServiceimpl implements ThirdService { + @Override + public void send(SmsDto smsDto) { + String huaweiSmsKey = smsDto.getHuaweiSmsKey(); + String huaweiSmsKeySecret = smsDto.getHuaweiSmsKeySecret(); + // 初始化 + Uni.init(huaweiSmsKey, huaweiSmsKeySecret); + // 若使用简易验签模式仅传入第一个参数即可 + // 设置自定义参数 (变量短信) + Map templateData = new HashMap<>(); + templateData.put("code", smsDto.getContent()); + // 构建信息 + UniMessage message = UniSMS.buildMessage() + .setTo(smsDto.getMobile()) + .setSignature("UniSMS") + .setTemplateId("login_tmpl") + .setTemplateData(templateData); + // 发送短信 + try { + UniResponse res = message.send(); + // todo + } catch (UniException e) { + LogUtil.error(ErrorTypeEnum.ERR_HUAWEI_SERVICE.getValue(), e); + } + } +} diff --git a/mall-common/src/main/java/com/suisung/mall/common/service/impl/TencentServiceImpl.java b/mall-common/src/main/java/com/suisung/mall/common/service/impl/TencentServiceImpl.java new file mode 100644 index 00000000..b6b678eb --- /dev/null +++ b/mall-common/src/main/java/com/suisung/mall/common/service/impl/TencentServiceImpl.java @@ -0,0 +1,61 @@ +package com.suisung.mall.common.service.impl; + +import cn.hutool.core.convert.Convert; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; +import com.github.qcloudsms.SmsSingleSender; +import com.github.qcloudsms.SmsSingleSenderResult; +import com.github.qcloudsms.httpclient.HTTPException; +import com.github.qcloudsms.httpclient.HTTPResponse; +import com.suisung.mall.common.exception.ApiException; +import com.suisung.mall.common.pojo.dto.ErrorTypeEnum; +import com.suisung.mall.common.pojo.dto.SmsDto; +import com.suisung.mall.common.service.ThirdService; +import com.suisung.mall.common.utils.LogUtil; +import org.springframework.stereotype.Service; + +import java.io.IOException; +import java.util.Map; + +@Service +public class TencentServiceImpl implements ThirdService { + @Override + public void send(SmsDto smsDto) { + // 短信应用SDK AppID 1400开头 + Integer tengxunAppId =smsDto.getTengxunAppId(); + // 短信应用SDK AppKey + String tengxunAppkey = smsDto.getTengxunAppkey(); + // 短信模板ID,需要在短信应用中申请 + Integer tengxunTemplateId = smsDto.getTengxunTemplateId(); + // 签名,使用的是签名内容,而不是签名ID + String smsSign = smsDto.getSmsSign(); + //参数,一定要对应短信模板中的参数顺序和个数, + String[] params = new String[smsDto.getParamMap().size()]; + int i = 0; + for (Map.Entry entry : smsDto.getParamMap().entrySet()) { + params[i++] = entry.getValue().toString(); + } + + //创建ssender对象 + SmsSingleSender ssender = new SmsSingleSender(tengxunAppId, tengxunAppkey); + //发送 + SmsSingleSenderResult result; + try { + result = ssender.sendWithParam("86", smsDto.getMobile(), tengxunTemplateId, params, smsSign, "", ""); + HTTPResponse response = result.getResponse(); + String body = response.body; + JSONObject res = JSONUtil.parseObj(body); + Integer resultCode = Convert.toInt(res.get("result")); + // todo 成功状态码不确定是多少,待配置成功后再试 + if (resultCode != 0) { + String errmsg = Convert.toStr(res.get("errmsg")); + LogUtil.error(ErrorTypeEnum.ERR_TENCENT_SERVICE.getValue(), errmsg); + throw new ApiException(errmsg); + } + + } catch (HTTPException | IOException e) { + LogUtil.error(ErrorTypeEnum.ERR_TENCENT_SERVICE.getValue(), e); + throw new ApiException(e.getMessage()); + } + } +} diff --git a/mall-common/src/main/java/com/suisung/mall/common/utils/ContextUtil.java b/mall-common/src/main/java/com/suisung/mall/common/utils/ContextUtil.java index 26bc4044..c29c74e0 100644 --- a/mall-common/src/main/java/com/suisung/mall/common/utils/ContextUtil.java +++ b/mall-common/src/main/java/com/suisung/mall/common/utils/ContextUtil.java @@ -73,8 +73,6 @@ public class ContextUtil { if (loginUser == null) { throw new ApiException(ResultCode.UNAUTHORIZED); - } else { - } return loginUser.getId(); diff --git a/mall-common/src/main/java/com/suisung/mall/common/utils/ThirdUtil.java b/mall-common/src/main/java/com/suisung/mall/common/utils/ThirdUtil.java new file mode 100644 index 00000000..2abdb32b --- /dev/null +++ b/mall-common/src/main/java/com/suisung/mall/common/utils/ThirdUtil.java @@ -0,0 +1,37 @@ +package com.suisung.mall.common.utils; + +import com.suisung.mall.common.pojo.dto.SmsDto; +import com.suisung.mall.common.service.ThirdService; +import com.suisung.mall.common.service.impl.AliServiceImpl; +import com.suisung.mall.common.service.impl.DefaultSmsServiceImpl; +import com.suisung.mall.common.service.impl.HuaweiServiceimpl; +import com.suisung.mall.common.service.impl.TencentServiceImpl; +import org.springframework.context.ApplicationContext; +import org.springframework.stereotype.Component; + +import java.util.HashMap; +import java.util.Map; + +@Component +public class ThirdUtil { + + private static final Map thirdMap = new HashMap<>(); + + public ThirdUtil(ApplicationContext applicationContext) { + // todo 自带短信代码放出来,走设计模式,消除if else 降低维护成本 + thirdMap.put(0, applicationContext.getBean(DefaultSmsServiceImpl.class)); + thirdMap.put(1, applicationContext.getBean(AliServiceImpl.class)); + thirdMap.put(2, applicationContext.getBean(TencentServiceImpl.class)); + thirdMap.put(3, applicationContext.getBean(HuaweiServiceimpl.class)); + } + + /** + * 发送短信 + * + * @param smsDto + */ + public static void send(SmsDto smsDto) { + ThirdService thirdService = thirdMap.get(smsDto.getSmsType()); + thirdService.send(smsDto); + } +} diff --git a/mall-gateway/src/main/java/com/suisung/mall/MallGatewayApplication.java b/mall-gateway/src/main/java/com/suisung/mall/MallGatewayApplication.java index 26b31028..dd53df73 100644 --- a/mall-gateway/src/main/java/com/suisung/mall/MallGatewayApplication.java +++ b/mall-gateway/src/main/java/com/suisung/mall/MallGatewayApplication.java @@ -2,7 +2,12 @@ package com.suisung.mall; import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure; import com.suisung.mall.common.config.DruidConfig; +import com.suisung.mall.common.service.impl.AliServiceImpl; +import com.suisung.mall.common.service.impl.DefaultSmsServiceImpl; +import com.suisung.mall.common.service.impl.HuaweiServiceimpl; +import com.suisung.mall.common.service.impl.TencentServiceImpl; import com.suisung.mall.common.utils.ContextUtil; +import com.suisung.mall.common.utils.ThirdUtil; import com.suisung.mall.common.weblog.ControllerLogAspect; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -20,7 +25,12 @@ import org.springframework.web.bind.annotation.RestControllerAdvice; @ComponentScan.Filter(type = FilterType.ANNOTATION, value = {RestControllerAdvice.class}), @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = {ControllerLogAspect.class}), @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = DruidConfig.class), - @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = ContextUtil.class) + @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = ContextUtil.class), + @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = ThirdUtil.class), + @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = DefaultSmsServiceImpl.class), + @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = AliServiceImpl.class), + @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = TencentServiceImpl.class), + @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = HuaweiServiceimpl.class) }) // 排除,不包含一些东西 @SpringBootApplication(exclude = {DruidDataSourceAutoConfigure.class, DataSourceAutoConfiguration.class}) diff --git a/mall-search/src/main/java/com/suisung/mall/search/service/impl/EsProductServiceImpl.java b/mall-search/src/main/java/com/suisung/mall/search/service/impl/EsProductServiceImpl.java index 36d704f8..7680517c 100644 --- a/mall-search/src/main/java/com/suisung/mall/search/service/impl/EsProductServiceImpl.java +++ b/mall-search/src/main/java/com/suisung/mall/search/service/impl/EsProductServiceImpl.java @@ -8,6 +8,7 @@ import cn.hutool.json.JSONUtil; import com.suisung.mall.common.modules.product.ShopProductIndex; import com.suisung.mall.common.pojo.dto.ProductRecommendDTO; import com.suisung.mall.common.pojo.dto.ProductSearchDTO; +import com.suisung.mall.common.utils.CheckUtil; import com.suisung.mall.search.dao.EsProductDao; import com.suisung.mall.search.domain.EsProduct; import com.suisung.mall.search.repository.EsProductRepository; @@ -132,7 +133,7 @@ public class EsProductServiceImpl implements EsProductService { } } // 品牌编号过滤 - if (productSearchDTO.getBrand_id() != null) { + if (CheckUtil.isNotEmpty(productSearchDTO.getBrand_id())) { boolQueryBuilder.must(QueryBuilders.termQuery("brandId", productSearchDTO.getBrand_id())); } @@ -142,7 +143,7 @@ public class EsProductServiceImpl implements EsProductService { } // 商品分类过滤 - if (productSearchDTO.getCategory_id() != null) { + if (CheckUtil.isNotEmpty(productSearchDTO.getCategory_id())) { boolQueryBuilder.must(QueryBuilders.termQuery("categoryId", productSearchDTO.getCategory_id())); } diff --git a/mall-shop/pom.xml b/mall-shop/pom.xml index e9518400..61418e93 100644 --- a/mall-shop/pom.xml +++ b/mall-shop/pom.xml @@ -157,6 +157,15 @@ + + + + com.qcloud + qcloud-java-sdk + 2.0.1 + + + @@ -217,7 +226,7 @@ commons-codec commons-codec - 1.9 + 1.11 @@ -277,6 +286,12 @@ org.apache.httpcomponents httpclient + + com.suisung.mall + mall-account + 1.0-SNAPSHOT + compile + diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/components/quartz/job/RsyncNoticeMsgJob.java b/mall-shop/src/main/java/com/suisung/mall/shop/components/quartz/job/RsyncNoticeMsgJob.java index f1ffd8ba..0f3f3cba 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/components/quartz/job/RsyncNoticeMsgJob.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/components/quartz/job/RsyncNoticeMsgJob.java @@ -6,6 +6,7 @@ import com.suisung.mall.common.service.MessageService; import com.suisung.mall.common.utils.I18nUtil; import com.suisung.mall.shop.config.SpringUtil; import com.suisung.mall.shop.message.service.ShopMessageTemplateService; +import lombok.extern.slf4j.Slf4j; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; import org.slf4j.Logger; @@ -20,9 +21,10 @@ import java.util.Map; */ public class RsyncNoticeMsgJob extends QuartzJobBean { + private Logger logger = LoggerFactory.getLogger(RsyncNoticeMsgJob.class); + @Override protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException { - Logger logger = LoggerFactory.getLogger(RsyncNoticeMsgJob.class); MessageService messageService = SpringUtil.getBean(MessageService.class); ShopMessageTemplateService shopMessageTemplateService = SpringUtil.getBean(ShopMessageTemplateService.class); @@ -31,9 +33,7 @@ public class RsyncNoticeMsgJob extends QuartzJobBean { String key = messageService.getKey("notice_msg"); int times = 10000; - //如果队列有数据,一直读完 - while (times > 0) { String data = messageService.receiveNoticeMsg(); @@ -41,8 +41,9 @@ public class RsyncNoticeMsgJob extends QuartzJobBean { break; } - JSONObject queue_row = JSONUtil.parseObj(data); + logger.debug("异步通知消息作业接收到的数据{}", data); + JSONObject queue_row = JSONUtil.parseObj(data); Integer user_id = (Integer) queue_row.get("user_id"); Integer store_id = (Integer) queue_row.get("store_id"); @@ -58,6 +59,7 @@ public class RsyncNoticeMsgJob extends QuartzJobBean { //判断是否超时 if (true || new Date().getTime() - time < 60 * 10) { //发送消息 + logger.debug("异步通知消息作业key:{}开始执行", key); if (!shopMessageTemplateService.send(user_id, store_id, message_tpl_id, args)) { logger.error(String.format(I18nUtil._("发送消息失败 : %s - %s - %s - %s"), user_id, store_id, message_tpl_id, args)); } diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/message/service/ShopMessageTemplateService.java b/mall-shop/src/main/java/com/suisung/mall/shop/message/service/ShopMessageTemplateService.java index 980c9423..26fea0cf 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/message/service/ShopMessageTemplateService.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/message/service/ShopMessageTemplateService.java @@ -4,6 +4,7 @@ import com.suisung.mall.common.modules.message.ShopMessageTemplate; import com.suisung.mall.common.modules.wechat.ShopWechatTplmsg; import com.suisung.mall.core.web.service.IBaseService; +import java.util.List; import java.util.Map; @@ -31,4 +32,15 @@ public interface ShopMessageTemplateService extends IBaseService tmplParams); + + Integer aliyunSmsSend(List mobiles, String tmplCode, Map tmplParams); + } diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/message/service/impl/ShopMessageTemplateServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/message/service/impl/ShopMessageTemplateServiceImpl.java index d1f649eb..8d5fafaf 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/message/service/impl/ShopMessageTemplateServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/message/service/impl/ShopMessageTemplateServiceImpl.java @@ -7,6 +7,12 @@ import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; import com.alibaba.fastjson.JSON; +import com.aliyuncs.DefaultAcsClient; +import com.aliyuncs.IAcsClient; +import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest; +import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse; +import com.aliyuncs.exceptions.ClientException; +import com.aliyuncs.profile.DefaultProfile; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.suisung.mall.common.api.BindCode; import com.suisung.mall.common.exception.ApiException; @@ -18,10 +24,14 @@ import com.suisung.mall.common.modules.account.AccountUserLogin; import com.suisung.mall.common.modules.message.ShopMessageTemplate; import com.suisung.mall.common.modules.store.ShopStoreBase; import com.suisung.mall.common.modules.wechat.ShopWechatTplmsg; +import com.suisung.mall.common.pojo.dto.ErrorTypeEnum; +import com.suisung.mall.common.pojo.dto.SmsDto; +import com.suisung.mall.common.service.impl.AliServiceImpl; import com.suisung.mall.common.utils.EmailUtil; +import com.suisung.mall.common.utils.LogUtil; +import com.suisung.mall.common.utils.ThirdUtil; import com.suisung.mall.common.utils.WxHttpUtil; import com.suisung.mall.common.utils.pojo.dto.EmailDTO; -import com.suisung.mall.core.web.model.SmsDto; import com.suisung.mall.core.web.service.CloundService; import com.suisung.mall.core.web.service.impl.BaseServiceImpl; import com.suisung.mall.shop.base.service.AccountBaseConfigService; @@ -33,6 +43,8 @@ import com.suisung.mall.shop.store.service.ShopStoreBaseService; import com.suisung.mall.shop.wechat.service.ShopWechatTplmsgService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.text.StringSubstitutor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Service; @@ -104,8 +116,10 @@ public class ShopMessageTemplateServiceImpl extends BaseServiceImpl 0 && !user_setting.isEmpty()) { String email = (String) user_setting.get("email"); @@ -250,27 +263,61 @@ public class ShopMessageTemplateServiceImpl extends BaseServiceImpl 0 && !user_setting.isEmpty() && activeProfile.equals("prod")) { String mobile = (String) user_setting.get("mobile"); if (StrUtil.isNotEmpty(mobile)) { - String message_sms = dealMessageTemplate(message_row.getMessage_sms(), args); + // String message_sms = dealMessageTemplate(message_row.getMessage_sms(), args); //str = '您[chain_name]的商品库存不足,请及时补货。SPU:[product_id],SKU:[item_id],可去店铺查看详情。'; mobile = StrUtil.removePrefix(mobile, "+86"); - SmsDto smsDTO = new SmsDto(); - smsDTO.setMobile(mobile); - smsDTO.setContent(message_sms); - //读取sms配置信息 String service_user_id = accountBaseConfigService.getConfig("service_user_id"); String service_app_key = accountBaseConfigService.getConfig("service_app_key"); - smsDTO.setServiceUserId(service_user_id); - smsDTO.setServiceAppKey(service_app_key); + SmsDto smsDto = new SmsDto(); + + smsDto.setSmsType(accountBaseConfigService.getConfig("sms_type", 0)); //默认短信通道 + smsDto.setServiceUserId(service_user_id); + smsDto.setServiceAppKey(service_app_key); + + //其它通道,要赋值通道信息 appid 以及 key + String aliyunSmsAccessKeyId = accountBaseConfigService.getConfig("aliyun_sms_access_key_id"); + String aliyunSmsAccessKeySecret = accountBaseConfigService.getConfig("aliyun_sms_access_key_secret"); + String aliyunSmsRegionId = accountBaseConfigService.getConfig("aliyun_sms_region_id"); + String aliyunSmsSign = accountBaseConfigService.getConfig("aliyun_sms_sign"); + + smsDto.setAliyunSmsAccessKeyId(aliyunSmsAccessKeyId); + smsDto.setAliyunSmsAccessKeySecret(aliyunSmsAccessKeySecret); + smsDto.setAliyunSmsRegionId(aliyunSmsRegionId); + smsDto.setSmsSign(aliyunSmsSign); + + String huaweiSmsKey = accountBaseConfigService.getConfig("huawei_sms_access_key"); + String huaweiSmsKeySecret = accountBaseConfigService.getConfig("huawei_sms_access_secret"); + smsDto.setHuaweiSmsKey(huaweiSmsKey); + smsDto.setHuaweiSmsKeySecret(huaweiSmsKeySecret); + + + // 短信应用SDK AppID 1400开头 + Integer tengxunAppId = accountBaseConfigService.getConfig("tengxun_sms_app_id", 0); + // 短信应用SDK AppKey + String tengxunAppkey = accountBaseConfigService.getConfig("tengxun_sms_app_key"); + smsDto.setTengxunAppId(tengxunAppId); + smsDto.setTengxunAppkey(tengxunAppkey); + + + smsDto.setMobile(mobile); + smsDto.setTemplateCode(message_row.getMessage_tpl_id()); + smsDto.setContent(message_row.getMessage_sms()); + smsDto.setParamMap(args); //传入模板对应参数 + + smsDto.setTengxunTemplateId(Convert.toInt(message_row.getMessage_tpl_id())); + try { - cloundService.send(smsDTO); + ThirdUtil.send(smsDto); + + log.debug("消息发送的数据:{}", smsDto); } catch (Exception e) { - log.error(e.getMessage()); + LogUtil.error(ErrorTypeEnum.ERR_PSUH_MSG.getValue(), e); } } } @@ -533,4 +580,84 @@ public class ShopMessageTemplateServiceImpl extends BaseServiceImpl tmplParams) { + if (StrUtil.isBlank(mobile) || StrUtil.isBlank(tmplCode)) { + LogUtil.error("阿里云发送短信时,缺少必要参数!"); + return false; + } + + // 先从redis里获取,才从数据库里获取 + String aliyunSmsAccessKeyId = accountBaseConfigService.getConfig("aliyun_sms_access_key_id"); + String aliyunSmsAccessKeySecret = accountBaseConfigService.getConfig("aliyun_sms_access_key_secret"); + String aliyunSmsRegionId = accountBaseConfigService.getConfig("aliyun_sms_region_id"); + String aliyunSmsSign = accountBaseConfigService.getConfig("aliyun_sms_sign"); + if (StrUtil.isBlank(aliyunSmsAccessKeyId) || StrUtil.isBlank(aliyunSmsAccessKeySecret) || StrUtil.isBlank(aliyunSmsRegionId) || StrUtil.isBlank(aliyunSmsSign)) { + LogUtil.error("阿里云发送短信时,获取不到关键参数!"); + return false; + } + + DefaultProfile profile = DefaultProfile.getProfile(aliyunSmsRegionId, aliyunSmsAccessKeyId, aliyunSmsAccessKeySecret); + IAcsClient client = new DefaultAcsClient(profile); + // 组装请求对象-具体描述见控制台-文档部分内容 + SendSmsRequest request = new SendSmsRequest(); + // 必填:待发送手机号 + request.setPhoneNumbers(mobile); + // 必填:短信签名-可在短信控制台中找到 + request.setSignName(aliyunSmsSign); + // 必填:短信模板-可在短信控制台中找到 + request.setTemplateCode(tmplCode); + // 选填:参考:https://help.aliyun.com/zh/sms/developer-reference/api-dysmsapi-2017-05-25-sendsms?spm=a2c4g.11186623.help-menu-44282.d_4_2_4_2_0.380018db3iM2mx + if (CollUtil.isNotEmpty(tmplParams)) { + request.setTemplateParam(JSONUtil.toJsonStr(tmplParams)); // json 格式 + } + + // 获取发送结果 + try { + SendSmsResponse response = client.getAcsResponse(request); + if (response == null) { + LogUtil.error(ErrorTypeEnum.ERR_ALI_SERVICE.getValue(), "阿里云短信服务返回失败!"); + return false; + } + + log.debug("阿里云短信发送返回结果:{}", JSONUtil.toJsonStr(response)); + if (response.getCode() == null || !"OK".equals(response.getCode())) { + String errMsg = response.getMessage(); + LogUtil.error(ErrorTypeEnum.ERR_ALI_SERVICE.getValue(), errMsg); + return false; + } + + return true; + } catch (ClientException e) { + LogUtil.error(ErrorTypeEnum.ERR_ALI_SERVICE.getValue(), e); + log.error("阿里云短信发送出错:{}", e.getMessage()); + return false; + } + } + + /** + * @param mobiles + * @param tmplCode + * @param tmplParams + * @return + */ + @Override + public Integer aliyunSmsSend(List mobiles, String tmplCode, Map tmplParams) { + int successCnt = 0; + for (String mobile : mobiles) { + if (aliyunSmsSend(mobile, tmplCode, tmplParams)) { + successCnt++; + } + } + + return successCnt; + } } \ No newline at end of file diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/order/listener/MessageListener.java b/mall-shop/src/main/java/com/suisung/mall/shop/order/listener/MessageListener.java index 9d49d58d..6165e89a 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/order/listener/MessageListener.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/order/listener/MessageListener.java @@ -28,6 +28,7 @@ public class MessageListener { String messageId = message.getMessageProperties().getMessageId(); try { + log.debug("消息监听到:{} ### {}",messageId, msgTO); boolean flag = messageService.sendNoticeMsg(msgTO.getUser_id(), msgTO.getStore_id(), msgTO.getMessage_id(), msgTO.getArgs()); if (flag) { channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/order/service/impl/ShopOrderBaseServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/order/service/impl/ShopOrderBaseServiceImpl.java index e9149f80..2ec3f100 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/order/service/impl/ShopOrderBaseServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/order/service/impl/ShopOrderBaseServiceImpl.java @@ -78,6 +78,7 @@ import com.suisung.mall.shop.invoicing.service.InvoicingStockBillItemService; import com.suisung.mall.shop.invoicing.service.InvoicingStockBillService; import com.suisung.mall.shop.invoicing.service.InvoicingWarehouseBaseService; import com.suisung.mall.shop.message.service.MqMessageService; +import com.suisung.mall.shop.message.service.ShopMessageTemplateService; import com.suisung.mall.shop.message.vo.MqMessageVo; import com.suisung.mall.shop.number.service.ShopNumberSeqService; import com.suisung.mall.shop.order.mapper.ShopOrderBaseMapper; @@ -280,6 +281,10 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl shopKeepers = storeEmployeeService.selectEmployeeByStoreId(store_id, CommonConstant.STORE_RIGHT_GROUP_ADMIN); + if (CollUtil.isNotEmpty(shopKeepers)) { + // 获取所有店铺管理员的手机号 + List shopKeeperMobiles = new ArrayList<>(); + for (Integer userId : shopKeepers) { + String mobile = ""; + Map bind_row = accountService.getBind(userId, BindCode.MOBILE); + if (bind_row == null || bind_row.get("bind_id") == null) { + // 补偿手机号码 + AccountUserInfo accountUserInfo = accountService.getUserInfo(userId); + if(accountUserInfo!=null && StrUtil.isNotBlank(accountUserInfo.getUser_mobile()) ){ + mobile = accountUserInfo.getUser_mobile(); + } + }else{ + mobile = bind_row.get("bind_id").toString(); + } + + // 获取所有店铺管理员的手机号 + shopKeeperMobiles.add(mobile); + + // 老流程(之前获取用户id不正确,现在更正) 2024-12-10 update 获取所有店铺管理员的 user_id + MsgTO sellerMsgTo = new MsgTO(userId, store_id, message_id, args); + mqMessageVos.add(new MqMessageVo(MqConstant.SHOP_EXCHANGE, MqConstant.SHOP_MSG_ROUTING_KEY, JSONUtil.parseObj(sellerMsgTo))); + logger.info("提醒商家发货,请求参数:{}", sellerMsgTo); + } + + // 2024-12-10 add + Map tmplArgs = new HashMap<>(2); + tmplArgs.put("order_id", order_id); + tmplArgs.put("order_payment_amount", order_payment_amount); + // 所有店铺管理员的发送邮件, 提醒商家:您收到一笔${order_payment_amount}元新订单${order_id}付款,请及时处理! + shopMessageTemplateService.aliyunSmsSend(shopKeeperMobiles, "SMS_475831067", tmplArgs);//SMS_475945807 + } // 付款成功,对通知推广员进行提醒 if (accountBaseConfigService.getConfig("plantform_fx_enable", false)) { @@ -3877,10 +3919,11 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl order_ids, List order_rows, boolean check_paid_flag) { @@ -3894,16 +3937,22 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl orderOpl = order_rows.stream().filter(s -> ObjectUtil.equal(order_id, Convert.toStr(s.get("order_id")))).findFirst(); Map order = orderOpl.orElseGet(HashMap::new); + // 订单状态(LIST):2011-待订单审核;2013-待财务审核;2020-待配货/待出库审核;2030-待发货;2040-已发货/待收货确认;2060-已完成/已签收;2070-已取消/已作废; Integer order_state_id = (Integer) order.get("order_state_id"); + // 付款状态(ENUM):3010-未付款;3011-付款待审核;3012-部分付款;3013-已付款 Integer order_is_paid = (Integer) order.get("order_is_paid"); + // 要检查订单付款状态 if (check_paid_flag) { if (ifCancel(order_state_id, order_is_paid)) { + // 未付款,未配送的订单才能取消订单 cancel_id_row.add(order_id); } } else { + // 不检查订单付款状态 cancel_id_row.add(order_id); } } @@ -3919,8 +3968,8 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl baseQueryWrapper = new QueryWrapper<>(); baseQueryWrapper.in("order_id", order_ids); - baseQueryWrapper.ne("order_state_id", StateCode.ORDER_STATE_CANCEL); - if (!edit(orderBase, baseQueryWrapper)) { + baseQueryWrapper.ne("order_state_id", StateCode.ORDER_STATE_CANCEL); // 2070-已取消 + if (!edit(orderBase, baseQueryWrapper)) {// 批量更改状态 throw new ApiException(ResultCode.FAILED); } @@ -3930,9 +3979,8 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl infoQueryWrapper = new QueryWrapper<>(); infoQueryWrapper.in("order_id", cancel_id_row); infoQueryWrapper.ne("order_state_id", StateCode.ORDER_STATE_CANCEL); - if (!shopOrderInfoService.edit(shopOrderInfo, infoQueryWrapper)) { - throw new ApiException(String.format("修改订单取消状态有误: %s", CollUtil.join(cancel_id_row, ","))); + throw new ApiException(String.format("订单:%s 取消状态有误!", CollUtil.join(cancel_id_row, ","))); } // 积分退还 order_resource_ext1 默认为积分。 @@ -3944,8 +3992,8 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl 0 && CheckUtil.isNotEmpty(buyer_user_id)) { Integer store_id = (Integer) order.get("store_id"); @@ -3956,10 +4004,11 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl 0 && CheckUtil.isNotEmpty(buyer_user_id)) { - String desc = String.format("%s 众宝退还", order_resource_ext2); - // todo shopUserPointsHistoryService.sp(buyer_user_id,order_resource_ext2,SpType.SP_TYPE_CONSUME_RETRUN, desc); - } + // 程序没有编写完成,缺失众宝积分退回功能 + //if (ObjectUtil.compare(order_resource_ext2, BigDecimal.ZERO) > 0 && CheckUtil.isNotEmpty(buyer_user_id)) { + // String desc = String.format("%s 众宝退还", order_resource_ext2); + // todo shopUserPointsHistoryService.sp(buyer_user_id,order_resource_ext2,SpType.SP_TYPE_CONSUME_RETRUN, desc); + //} } // 限购商品数量退还 @@ -3976,10 +4025,12 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl productBuyList = shopUserProductBuyService.find(buyQueryWrapper); Integer order_item_quantity = order_item_row.getOrder_item_quantity(); - for (ShopUserProductBuy productBuy : productBuyList) { - productBuy.setProduct_buy_num(productBuy.getProduct_buy_num() - order_item_quantity); - } if (CollUtil.isNotEmpty(productBuyList)) { + + for (ShopUserProductBuy productBuy : productBuyList) { + productBuy.setProduct_buy_num(productBuy.getProduct_buy_num() - order_item_quantity); + } + if (!shopUserProductBuyService.saveOrUpdate(productBuyList)) { throw new ApiException(ResultCode.FAILED); } @@ -4854,7 +4905,7 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl shopOrderInfos = shopOrderInfoService.gets(order_ids); List rows = Convert.toList(Map.class, shopOrderInfos); - + // 检查登录用户和订单店铺是否有权限操作取消动作 if (CheckUtil.checkDataRights(user_id, rows, "buyer_user_id") || CheckUtil.checkDataRights(Convert.toInt(user.getStore_id()), rows, "store_id")) { cancel(order_ids, rows, true); } else { @@ -7817,14 +7868,16 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl order_states = Arrays.asList(StateCode.ORDER_STATE_WAIT_PAY, StateCode.ORDER_STATE_WAIT_REVIEW, StateCode.ORDER_STATE_WAIT_FINANCE_REVIEW, StateCode.ORDER_STATE_PICKING, StateCode.ORDER_STATE_WAIT_SHIPPING); + // 3010-未付款,未付款的订单才能取消 return order_states.contains(order_state_id) && ObjectUtil.equal(order_is_paid, StateCode.ORDER_PAID_STATE_NO); } diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/product/service/ShopProductBaseService.java b/mall-shop/src/main/java/com/suisung/mall/shop/product/service/ShopProductBaseService.java index d6005eef..0a957657 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/product/service/ShopProductBaseService.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/product/service/ShopProductBaseService.java @@ -9,6 +9,7 @@ import com.suisung.mall.common.pojo.dto.ProductSearchDTO; import com.suisung.mall.core.web.service.IBaseService; import com.suisung.mall.shop.product.pojo.vo.ProductVo; import org.apache.ibatis.annotations.Param; +import org.springframework.transaction.annotation.Transactional; import javax.servlet.http.HttpServletResponse; import java.io.Serializable; @@ -258,4 +259,7 @@ public interface ShopProductBaseService extends IBaseService { * @return */ Map getProductBasicInfo(Long product_id, Integer store_id); + + @Transactional + boolean updateProductSubsite(Integer store_id); } diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/product/service/impl/ShopProductAnalyticsServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/product/service/impl/ShopProductAnalyticsServiceImpl.java index 50b6a6dd..4a4c7d92 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/product/service/impl/ShopProductAnalyticsServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/product/service/impl/ShopProductAnalyticsServiceImpl.java @@ -5,6 +5,7 @@ import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.ObjectUtil; import com.suisung.mall.common.modules.product.ShopProductAnalytics; import com.suisung.mall.common.modules.product.ShopProductItem; +import com.suisung.mall.common.utils.CheckUtil; import com.suisung.mall.core.web.service.impl.BaseServiceImpl; import com.suisung.mall.shop.product.mapper.ShopProductAnalyticsMapper; import com.suisung.mall.shop.product.service.ShopProductAnalyticsService; @@ -44,7 +45,8 @@ public class ShopProductAnalyticsServiceImpl extends BaseServiceImpl indexQueryWrapper = new QueryWrapper<>(); + indexQueryWrapper.eq("store_id", store_id); + + if (!shopProductIndexService.edit(shopProductIndex, indexQueryWrapper)) { + throw new ApiException(I18nUtil._("产品索引信息修改失败!")); + } + + return true; + } + + public String initProductLangIndex(Long productId, String productNameIndex) { + QueryWrapper queryParams = new QueryWrapper<>(); + queryParams.eq("table_name", "shop_product_base"); + queryParams.eq("column_name", "product_name"); + queryParams.eq("primary_key", productId); + + List langmetaRows = shopBaseLangMetaService.find(queryParams); + + // 处理唯一的meta_value列 + List langNameIndexRow = CommonUtil.column(langmetaRows, ShopBaseLangMeta::getMeta_value); + + if (!langNameIndexRow.isEmpty()) { + productNameIndex = String.format("%s -|- %s", productNameIndex, String.join(" ", langNameIndexRow)); + } + + return productNameIndex; + } } diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/sfexpress/service/impl/SFExpressApiServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/sfexpress/service/impl/SFExpressApiServiceImpl.java index 4eec36d8..7c065bd3 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/sfexpress/service/impl/SFExpressApiServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/sfexpress/service/impl/SFExpressApiServiceImpl.java @@ -273,9 +273,9 @@ public class SFExpressApiServiceImpl implements SFExpressApiService { // 更改商城订单状态为:已取消,注意事务问题 List orderList = new ArrayList<>(); orderList.add(shopStoreSfOrderExist.getShop_order_id()); - Boolean success = shopOrderBaseService.cancel(orderList, null, false); + // 取消订单, 流程:订单状态;积分、众宝、库存、礼包、优惠券 有就统统退还 + Boolean success = shopOrderBaseService.cancel(orderList, null, false); // 不检查订单付款状态 if (!success) { -// return new SFExpressApiRes().fail(1, "取消商家订单失败!"); throw new ApiException(I18nUtil._("取消商家订单失败!")); } @@ -286,7 +286,6 @@ public class SFExpressApiServiceImpl implements SFExpressApiService { shopStoreSfOrder.setStatus_desc("线上商城发起取消订单"); success = shopStoreSfOrderService.updateShopStoreSfOrderStatus(shopStoreSfOrder); if (!success) { -// return new SFExpressApiRes().fail(1, "取消顺丰订单失败!"); throw new ApiException(I18nUtil._("取消顺丰订单失败!")); } diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/store/controller/admin/ShopStorePrinterController.java b/mall-shop/src/main/java/com/suisung/mall/shop/store/controller/admin/ShopStorePrinterController.java index e781a2ab..0a900024 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/store/controller/admin/ShopStorePrinterController.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/store/controller/admin/ShopStorePrinterController.java @@ -1,7 +1,9 @@ package com.suisung.mall.shop.store.controller.admin; +import cn.hutool.core.collection.CollUtil; import com.suisung.mall.common.api.CommonResult; import com.suisung.mall.common.modules.store.ShopStorePrinter; +import com.suisung.mall.shop.store.service.ShopStoreEmployeeService; import com.suisung.mall.shop.store.service.ShopStorePrinterService; import com.suisung.mall.shop.store.service.ShopStoreSameCityTransportBaseService; import io.swagger.annotations.Api; @@ -13,6 +15,9 @@ import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; import java.math.BigDecimal; +import java.util.HashMap; +import java.util.List; +import java.util.Map; @Api(tags = "门店打票机打印业务") @RestController @@ -25,13 +30,16 @@ public class ShopStorePrinterController { @Resource private ShopStoreSameCityTransportBaseService shopStoreSameCityTransportBaseService; + @Resource + private ShopStoreEmployeeService shopStoreEmployeeService; @ApiOperation(value = "内部测试案例", notes = "内部测试案例") @RequestMapping(value = "/testcase", method = {RequestMethod.GET}) public CommonResult TestCase() { - Object data = shopStoreSameCityTransportBaseService.computeSameCityTransportFee(3L, BigDecimal.valueOf(110.07123874241765), BigDecimal.valueOf(23.366250981849255), 100, BigDecimal.valueOf(0.5), BigDecimal.valueOf(5.5), BigDecimal.valueOf(5.5), true); +// Object data = shopStoreSameCityTransportBaseService.computeSameCityTransportFee(3L, BigDecimal.valueOf(110.07123874241765), BigDecimal.valueOf(23.366250981849255), 100, BigDecimal.valueOf(0.5), BigDecimal.valueOf(5.5), BigDecimal.valueOf(5.5), true); - return CommonResult.success(data); + List list = shopStoreEmployeeService.selectEmployeeByStoreId(3,"店铺管理员"); + return CommonResult.success(list); } @ApiOperation(value = "测试打印模版消息", notes = "测试打印模版消息") diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/store/mapper/ShopStoreEmployeeMapper.java b/mall-shop/src/main/java/com/suisung/mall/shop/store/mapper/ShopStoreEmployeeMapper.java index 30aa1eaa..32a1a8d4 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/store/mapper/ShopStoreEmployeeMapper.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/store/mapper/ShopStoreEmployeeMapper.java @@ -2,8 +2,11 @@ package com.suisung.mall.shop.store.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.suisung.mall.common.modules.store.ShopStoreEmployee; +import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Repository; +import java.util.List; + /** *

* 卖家用户表—公司员工employee-通过user id启用用户中心 Mapper 接口 @@ -16,4 +19,11 @@ import org.springframework.stereotype.Repository; @Repository public interface ShopStoreEmployeeMapper extends BaseMapper { + /** + * 根据店铺id和角色权限组id获取多条 userId + * @param storeId + * @param groupId + * @return + */ + List selectByStoreIdRightGroupId(@Param("storeId") Integer storeId, @Param("groupId") Integer groupId); } diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/ShopStoreEmployeeRightsGroupService.java b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/ShopStoreEmployeeRightsGroupService.java index ea0b8d43..5432872f 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/ShopStoreEmployeeRightsGroupService.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/ShopStoreEmployeeRightsGroupService.java @@ -17,4 +17,12 @@ import java.util.Map; public interface ShopStoreEmployeeRightsGroupService extends IBaseService { Map getList(ShopStoreEmployeeRightsGroup shopStoreEmployeeRightsGroup, Integer pageNum, Integer pageSize); + + /** + * 根据店铺id和角色权限组名称获取一条记录 + * @param storeId + * @param groupName + * @return + */ + ShopStoreEmployeeRightsGroup getByGroupName(Integer storeId, String groupName); } diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/ShopStoreEmployeeService.java b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/ShopStoreEmployeeService.java index 13d165da..b9279682 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/ShopStoreEmployeeService.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/ShopStoreEmployeeService.java @@ -29,4 +29,12 @@ public interface ShopStoreEmployeeService extends IBaseService selectEmployeeByStoreId(Integer storeId, String rightsGroupName); + } diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/ShopStoreInfoService.java b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/ShopStoreInfoService.java index 431feb0c..79d35388 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/ShopStoreInfoService.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/ShopStoreInfoService.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.suisung.mall.common.modules.store.ShopStoreInfo; import com.suisung.mall.core.web.service.IBaseService; +import java.util.List; import java.util.Map; @@ -21,4 +22,11 @@ public interface ShopStoreInfoService extends IBaseService { Map getInfoList(QueryWrapper queryWrapper, Integer pageNum, Integer pageSize); + /** + * 获取店长的手机号码 + * @param storeId + * @return + */ + List getStoreKeeperMobile(Integer storeId); + } diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopStoreEmployeeRightsGroupServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopStoreEmployeeRightsGroupServiceImpl.java index 92fa3492..87aeb9ed 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopStoreEmployeeRightsGroupServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopStoreEmployeeRightsGroupServiceImpl.java @@ -36,7 +36,18 @@ public class ShopStoreEmployeeRightsGroupServiceImpl extends BaseServiceImpl lists = lists(queryWrapper, pageNum, pageSize); return toMobileResult(lists); + } - + /** + * 根据店铺id和角色权限组名称获取一条记录 + * @param storeId + * @param rightsGroupName + * @return + */ + @Override + public ShopStoreEmployeeRightsGroup getByGroupName(Integer storeId, String rightsGroupName) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("store_id", storeId).eq("rights_group_name", rightsGroupName); + return getOne(queryWrapper); } } \ No newline at end of file diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopStoreEmployeeServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopStoreEmployeeServiceImpl.java index a0dde755..5c293688 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopStoreEmployeeServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopStoreEmployeeServiceImpl.java @@ -3,6 +3,7 @@ package com.suisung.mall.shop.store.service.impl; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.convert.Convert; import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.suisung.mall.common.api.CommonResult; @@ -26,6 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import javax.annotation.Resource; import java.util.*; import java.util.stream.Collectors; @@ -43,15 +45,18 @@ import static com.suisung.mall.common.utils.ContextUtil.getCurrentUser; @Service public class ShopStoreEmployeeServiceImpl extends BaseServiceImpl implements ShopStoreEmployeeService { - @Autowired - private ShopStoreEmployeeService shopStoreEmployeeService; +// @Resource +// private ShopStoreEmployeeService shopStoreEmployeeService; - @Autowired + @Resource private AccountService accountService; - @Autowired + @Resource private ShopStoreEmployeeRightsGroupService shopStoreEmployeeRightsGroupService; + @Resource + private ShopStoreEmployeeMapper shopStoreEmployeeMapper; + @Override public Map getList(QueryWrapper wrapper, Integer pageNum, Integer pageSize) { @@ -62,7 +67,7 @@ public class ShopStoreEmployeeServiceImpl extends BaseServiceImpl items = (List) data.get("items"); - shopStoreEmployeeService.fixUserInfo(items); + fixUserInfo(items); handleGroupName(items, store_id); return data; @@ -204,4 +209,26 @@ public class ShopStoreEmployeeServiceImpl extends BaseServiceImpl selectEmployeeByStoreId(Integer storeId, String rightsGroupName) { + if ((storeId == null || storeId <= 0) && StrUtil.isBlank(rightsGroupName)) { + return null; + } + + Integer rightsGroupId = null; + ShopStoreEmployeeRightsGroup rightsGroup = shopStoreEmployeeRightsGroupService.getByGroupName(storeId, rightsGroupName); + if (rightsGroup != null) { + rightsGroupId = rightsGroup.getRights_group_id(); + } + + return shopStoreEmployeeMapper.selectByStoreIdRightGroupId(storeId, rightsGroupId); + } } diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopStoreInfoServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopStoreInfoServiceImpl.java index 4c74fe9c..63f124a0 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopStoreInfoServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopStoreInfoServiceImpl.java @@ -85,10 +85,22 @@ public class ShopStoreInfoServiceImpl extends BaseServiceImpl getStoreKeeperMobile(Integer storeId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("store_id", storeId).select("store_tel"); + return null; + } + } diff --git a/mall-shop/src/main/resources/mapper/store/ShopStoreEmployeeMapper.xml b/mall-shop/src/main/resources/mapper/store/ShopStoreEmployeeMapper.xml index e2f1ab27..0f3eea12 100644 --- a/mall-shop/src/main/resources/mapper/store/ShopStoreEmployeeMapper.xml +++ b/mall-shop/src/main/resources/mapper/store/ShopStoreEmployeeMapper.xml @@ -7,4 +7,19 @@ employee_id, store_id, user_id, rights_group_id, employee_is_admin, employee_login_time, employee_is_kefu + + + +