Преглед на файлове

Merge remote-tracking branch 'remotes/origin/developer' into developerA

# Conflicts:
#	src/main/java/com/caimei/model/vo/AuthVo.java
#	src/main/java/com/caimei/model/vo/ProductListVo.java
#	src/main/java/com/caimei/utils/SmsUtils.java
#	src/main/resources/mapper/AuthMapper.xml
#	src/main/resources/mapper/AuthProductMapper.xml
Aslee преди 2 години
родител
ревизия
6a34917e61
променени са 24 файла, в които са добавени 630 реда и са изтрити 42 реда
  1. 12 0
      pom.xml
  2. 16 0
      src/main/java/com/caimei/aop/IpSave.java
  3. 102 0
      src/main/java/com/caimei/aop/IpSaveAspect.java
  4. 8 2
      src/main/java/com/caimei/controller/wechat/RegisterApi.java
  5. 4 0
      src/main/java/com/caimei/controller/wechat/WxAuthApi.java
  6. 6 0
      src/main/java/com/caimei/controller/wechat/WxDataApi.java
  7. 63 0
      src/main/java/com/caimei/listener/IpSaveListener.java
  8. 8 0
      src/main/java/com/caimei/mapper/aopMapper/IpSaveRepository.java
  9. 58 0
      src/main/java/com/caimei/model/dto/MessageDto.java
  10. 46 0
      src/main/java/com/caimei/model/po/IpSavePo.java
  11. 5 0
      src/main/java/com/caimei/model/vo/AuthVo.java
  12. 4 0
      src/main/java/com/caimei/model/vo/ProductListVo.java
  13. 73 0
      src/main/java/com/caimei/service/aopservice/IpSaveService.java
  14. 126 0
      src/main/java/com/caimei/service/aopservice/RocketMqService.java
  15. 2 2
      src/main/java/com/caimei/service/auth/impl/AuthClubServiceImpl.java
  16. 1 1
      src/main/java/com/caimei/service/wechat/RegisterService.java
  17. 17 2
      src/main/java/com/caimei/service/wechat/impl/RegisterServiceImpl.java
  18. 26 22
      src/main/java/com/caimei/utils/SmsUtils.java
  19. 14 1
      src/main/resources/config/beta/application-beta.yml
  20. 12 0
      src/main/resources/config/dev/application-dev.yml
  21. 12 0
      src/main/resources/config/prod/application-prod.yml
  22. 6 4
      src/main/resources/mapper/AuthMapper.xml
  23. 7 6
      src/main/resources/mapper/AuthProductMapper.xml
  24. 2 2
      src/main/resources/mapper/ShopMapper.xml

+ 12 - 0
pom.xml

@@ -313,6 +313,18 @@
             <artifactId>jjwt</artifactId>
             <version>0.9.1</version>
         </dependency>
+        <!-- https://mvnrepository.com/artifact/org.apache.rocketmq/rocketmq-spring-boot-starter -->
+        <!-- RocketMQ starter -->
+        <dependency>
+            <groupId>org.apache.rocketmq</groupId>
+            <artifactId>rocketmq-spring-boot-starter</artifactId>
+            <version>2.2.0</version>
+        </dependency>
+        <!-- mongo -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-mongodb</artifactId>
+        </dependency>
 
         <dependency>
             <groupId>com.twelvemonkeys.imageio</groupId>

+ 16 - 0
src/main/java/com/caimei/aop/IpSave.java

@@ -0,0 +1,16 @@
+package com.caimei.aop;
+
+import java.lang.annotation.*;
+
+/**
+ * @author Administrator
+ */
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface IpSave {
+
+    String saveName();
+
+    boolean saveParams();
+}

+ 102 - 0
src/main/java/com/caimei/aop/IpSaveAspect.java

@@ -0,0 +1,102 @@
+package com.caimei.aop;
+
+
+import com.alibaba.fastjson.JSONObject;
+import com.caimei.model.dto.MessageDto;
+import com.caimei.service.aopservice.RocketMqService;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringUtils;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Pointcut;
+import org.aspectj.lang.reflect.MethodSignature;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.web.context.request.RequestAttributes;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import java.lang.reflect.Method;
+
+
+/**
+ *
+ */
+@Slf4j
+@Aspect
+@Component
+public class IpSaveAspect {
+
+    @Autowired
+    private RocketMqService rocketMqService;
+    /**
+     * 切入点,根据自定义IpSave实际路径进行调整
+     */
+    @Pointcut("@annotation(com.caimei.aop.IpSave)")
+    public void executeIdempotent() {
+    }
+
+    @Around("executeIdempotent()")
+    public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
+        //获取方法对象
+        Method method = ((MethodSignature) joinPoint.getSignature()).getMethod();
+        RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
+        ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) requestAttributes;
+        HttpServletRequest request = servletRequestAttributes.getRequest();
+        // ip
+        String unknown = "unknown";
+        String ip = "";
+        ip = request.getHeader("x-forwarded-for");
+        if (StringUtils.isBlank(ip)) {
+            ip = request.getHeader("X-Real-IP");
+        }
+        if (ip == null || ip.length() == 0 || unknown.equalsIgnoreCase(ip)) {
+            ip = request.getHeader("Proxy-Client-IP");
+        }
+
+        if (ip == null || ip.length() == 0 || unknown.equalsIgnoreCase(ip)) {
+            ip = request.getHeader("WL-Proxy-Client-IP");
+        }
+
+        if (ip == null || ip.length() == 0 || unknown.equalsIgnoreCase(ip)) {
+            ip = request.getRemoteAddr();
+        }
+        // 接口路径
+        String requestURI = request.getRequestURI();
+        //获取自定义注解
+        IpSave ipSave = method.getAnnotation(IpSave.class);
+        // 访问名 注解的值
+        String s = ipSave.saveName();
+        // 是否存储发送参数
+        boolean sp = ipSave.saveParams();
+        // 接口真实发送参数
+        String queryString = "";
+        JSONObject jsonObject = new JSONObject();
+        if (sp) {
+            queryString = request.getQueryString();
+            jsonObject.put("queryString",queryString);
+        }
+        if (StringUtils.isNotBlank(ip)) {
+            jsonObject.put("ip",ip);
+        }
+        if (StringUtils.isNotBlank(requestURI)) {
+            jsonObject.put("URI",requestURI);
+        }
+        if (StringUtils.isNotBlank(s)) {
+            jsonObject.put("saveName",s);
+        }
+        MessageDto messageDto = new MessageDto();
+        messageDto.setTopic("zpIp");
+        messageDto.setContent(jsonObject.toJSONString());
+        messageDto.setSort(1);
+        messageDto.setAsync(1);
+        //异步给mq存
+        rocketMqService.sendCommonMessage(messageDto);
+
+        return joinPoint.proceed();
+    }
+}
+

+ 8 - 2
src/main/java/com/caimei/controller/wechat/RegisterApi.java

@@ -42,19 +42,25 @@ public class RegisterApi {
         String verifyCode = parseObject.getString("verifyCode");
         String password = parseObject.getString("password");
         Integer authUserId = parseObject.getInteger("authUserId");
+        Integer authId = parseObject.getInteger("authId");
+        // 注册类型:1密码注册,2验证码注册(默认密码,短信推送)
+        int registerType = 1;
+        if (null != authId && StringUtils.isEmpty(password)) {
+            registerType = 2;
+        }
         if (StringUtils.isEmpty(mobile)) {
             return ResponseJson.error("手机号不能为空", null);
         }
         if (StringUtils.isEmpty(verifyCode)) {
             return ResponseJson.error("验证码不能为空", null);
         }
-        if (StringUtils.isEmpty(password)) {
+        if (1 == registerType && StringUtils.isEmpty(password)) {
             return ResponseJson.error("密码不能为空", null);
         }
         if (null == authUserId) {
             return ResponseJson.error("供应商用户id不能为空", null);
         }
-        return registerService.simpleRegister(mobile, verifyCode, password, authUserId, null);
+        return registerService.simpleRegister(mobile, verifyCode, password, authUserId, authId, registerType);
     }
 
     @ApiOperation("全部注册")

+ 4 - 0
src/main/java/com/caimei/controller/wechat/WxAuthApi.java

@@ -1,6 +1,7 @@
 package com.caimei.controller.wechat;
 
 import com.alibaba.fastjson.JSONObject;
+import com.caimei.aop.IpSave;
 import com.caimei.model.ResponseJson;
 import com.caimei.model.dto.ProductSaveDto;
 import com.caimei.model.po.CmBrandAuthPo;
@@ -64,6 +65,7 @@ public class WxAuthApi {
             @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
             @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
     })
+    @IpSave(saveName = "已认证机构列表",saveParams = true)
     @GetMapping("/club/list")
     public ResponseJson<PageInfo<WxClubListVo>> getWxClubList(Integer authUserId, String appId, String lngAndLat, String authParty, Integer provinceId,
                                                               Integer cityId, Integer townId,
@@ -87,6 +89,7 @@ public class WxAuthApi {
 
     @ApiOperation("已认证机构详情")
     @ApiImplicitParam(required = false, name = "authId", value = "正品联盟机构Id")
+    @IpSave(saveName = "已认证机构详情",saveParams = true)
     @GetMapping("/club/details")
     public ResponseJson<WxClubDetailsVo> getWxClubDetails(Integer authId) {
         return authClubService.getWxClubDetails(authId);
@@ -120,6 +123,7 @@ public class WxAuthApi {
             @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
             @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
     })
+    @IpSave(saveName = "认证商品列表",saveParams = true)
     @GetMapping("/product/list")
     public ResponseJson<PageInfo<WxProductListVo>> getWxProductList(Integer listType, Integer authId, Integer productTypeId,
                                                                     String authParty, String snCode,

+ 6 - 0
src/main/java/com/caimei/controller/wechat/WxDataApi.java

@@ -1,6 +1,7 @@
 package com.caimei.controller.wechat;
 
 import com.alibaba.fastjson.JSONObject;
+import com.caimei.aop.IpSave;
 import com.caimei.model.ResponseJson;
 import com.caimei.model.vo.*;
 import com.caimei.service.auth.*;
@@ -38,6 +39,7 @@ public class WxDataApi {
             @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
             @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
     })
+    @IpSave(saveName = "文章列表",saveParams = true)
     @GetMapping("/article/list")
     public ResponseJson<PageInfo<WxArticleListVo>> getWxArticleList(Integer authUserId, String articleTitle,
                                                                     @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
@@ -47,6 +49,7 @@ public class WxDataApi {
 
     @ApiOperation("资料库文章回显数据")
     @ApiImplicitParam(name = "articleId", value = "文章id", required = true)
+    @IpSave(saveName = "文章详情",saveParams = true)
     @GetMapping("/article/form/data")
     public ResponseJson<ArticleFormVo> getArticleFormData(Integer articleId) {
         return articleService.getArticleFormData(articleId);
@@ -59,6 +62,7 @@ public class WxDataApi {
             @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
             @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
     })
+    @IpSave(saveName = "图片列表",saveParams = true)
     @GetMapping("/image/list")
     public ResponseJson<PageInfo<WxImageListVo>> getWxImageList(Integer authUserId, String imageTitle,
                                                                 @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
@@ -73,6 +77,7 @@ public class WxDataApi {
             @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
             @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
     })
+    @IpSave(saveName = "资料库视频列表",saveParams = true)
     @GetMapping("/video/list")
     public ResponseJson<PageInfo<WxVideoListVo>> getWxVideoList(Integer authUserId, String videoTitle,
                                                                 @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
@@ -88,6 +93,7 @@ public class WxDataApi {
             @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
             @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
     })
+    @IpSave(saveName = "文件列表",saveParams = true)
     @GetMapping("/file/list")
     public ResponseJson<PageInfo<WxFileListVo>> getWxFileList(Integer authUserId, Integer fileType, String fileTitle,
                                                               @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,

+ 63 - 0
src/main/java/com/caimei/listener/IpSaveListener.java

@@ -0,0 +1,63 @@
+package com.caimei.listener;
+
+
+import com.alibaba.fastjson.JSONObject;
+import com.caimei.model.po.IpSavePo;
+import com.caimei.service.aopservice.IpSaveService;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringUtils;
+import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
+import org.apache.rocketmq.spring.core.RocketMQListener;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.io.UnsupportedEncodingException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * @author Administrator
+ */
+@Slf4j
+@Component
+@RocketMQMessageListener(
+        topic = "zpIp",
+        // messageModel = MessageModel.BROADCASTING,//指定为广播消费
+        // consumeMode = ConsumeMode.ORDERLY, // 指定消费模式为顺序消费,消费的顺序也和发送顺序一致
+        // selectorType = SelectorType.TAG,// 如果我们的生产者指定了Tag,但是消费者的selectorExpression没有设置,即用默认的“*”,那么这个消费者也会消费到
+        // selectorExpression = "tag",     // 指定了tag后,发送的消息如果不带tag,将会消费不到
+        consumerGroup = "Zp_group")
+public class IpSaveListener implements RocketMQListener<String> {
+
+    @Autowired
+    private IpSaveService ipSaveService;
+
+    @Override
+    public void onMessage(String message) {
+        log.info("{}收到消息:{}", this.getClass().getSimpleName(), message);
+        JSONObject jsonObject = JSONObject.parseObject(message);
+        //ip,接口路径,接口参数,注解名
+        String ip = (String) jsonObject.get("ip");
+        String path = (String) jsonObject.get("URI");
+        String param = (String) jsonObject.get("queryString");
+        String saveName = (String) jsonObject.get("saveName");
+        IpSavePo ipSavePo = new IpSavePo();
+        if (StringUtils.isNotBlank(path)) {
+            ipSavePo.setRequestUrl(path);
+        }
+        if (StringUtils.isNotBlank(saveName)) {
+            ipSavePo.setPortName(saveName);
+        }
+        if (StringUtils.isNotBlank(ip)) {
+            ipSavePo.setIp(ip);
+        }
+        if(StringUtils.isNotBlank(param)){
+            ipSavePo.setParams(param);
+        }
+        SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
+        String nowDate = format.format(new Date());
+        Long aLong = Long.valueOf(nowDate);
+        ipSavePo.setSaveTime(aLong);
+        ipSaveService.save(ipSavePo);
+    }
+}

+ 8 - 0
src/main/java/com/caimei/mapper/aopMapper/IpSaveRepository.java

@@ -0,0 +1,8 @@
+package com.caimei.mapper.aopMapper;
+
+import com.caimei.model.po.IpSavePo;
+import org.springframework.data.mongodb.repository.MongoRepository;
+
+public interface IpSaveRepository extends MongoRepository<IpSavePo,String> {
+
+}

+ 58 - 0
src/main/java/com/caimei/model/dto/MessageDto.java

@@ -0,0 +1,58 @@
+package com.caimei.model.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/6/17
+ */
+@ApiModel("发送消息接收参数")
+@Data
+public class MessageDto implements Serializable {
+    private static final long serialVersionUID = 1L;
+    /**
+     * 消息主题
+     */
+    @NotNull
+    @ApiModelProperty("消息主题")
+    private String topic;
+    /**
+     * 消息内容
+     */
+    @NotNull
+    @ApiModelProperty("消息内容")
+    private String content;
+    /**
+     * 消息标签(可选)
+     */
+    @ApiModelProperty("消息标签(可选)")
+    private String tag;
+    /**
+     * 有序消息(可选)
+     */
+    @ApiModelProperty("有序消息(可选):1是,0否")
+    private Integer sort;
+    /**
+     * 异步消息(可选)
+     */
+    @ApiModelProperty("异步消息(可选):1是,0否")
+    private Integer async;
+    /**
+     * 单向消息(可选)
+     */
+    @ApiModelProperty("单向消息(可选):1是,0否")
+    private Integer oneway;
+    /**
+     * 延时消息(可选)
+     */
+    @ApiModelProperty("延时消息(可选),延时等级:1-18,0否,对应时间依次:1s 5s 10s 30s 1m 2m 3m 4m 5m 6m 7m 8m 9m 10m 20m 30m 1h 2h")
+    private Integer delay;
+
+}

+ 46 - 0
src/main/java/com/caimei/model/po/IpSavePo.java

@@ -0,0 +1,46 @@
+package com.caimei.model.po;
+
+import lombok.Data;
+import lombok.ToString;
+import org.springframework.data.annotation.Id;
+import org.springframework.data.mongodb.core.mapping.Document;
+import org.springframework.data.mongodb.core.mapping.Field;
+
+import java.io.Serializable;
+
+/**
+ * @author Administrator
+ */ 
+//可以省略,如果省略,则默认使用类名小写映射集合
+@Document(collection="ZpIpCollection")
+@Data
+@ToString
+public class IpSavePo implements Serializable {
+    /**
+     * 主键标识,该属性的值会自动对应mongodb的主键字段"_id",如果该属性名就叫“id”,则该注解可以省略,否则必须写
+     */
+    @Id
+    private String id;
+    private String userId;
+    /**
+     * 该属性对应mongodb的字段的名字,如果一致,则无需该注解
+     */
+    @Field("ip")
+    private String ip;
+    /**
+     * 用户访问接口参数
+     */
+    private String params;
+    /**
+     * 用户访问路径
+     */
+    private String requestUrl;
+    /**
+     * 接口显示名称(展示名)
+     */
+    private String portName;
+    /**
+     * 时间
+     */
+    private Long saveTime;
+}

+ 5 - 0
src/main/java/com/caimei/model/vo/AuthVo.java

@@ -107,6 +107,11 @@ public class AuthVo {
      */
     private Date shopAuditTime;
 
+    /**
+     * 机构下设备数量
+     */
+    private Integer productNum;
+
     /**
      * 是否查看过:1是,0否
      */

+ 4 - 0
src/main/java/com/caimei/model/vo/ProductListVo.java

@@ -16,6 +16,10 @@ public class ProductListVo {
      */
     private Integer productId;
 
+    @ApiModelProperty("供应商用户id")
+    private Integer authUserId;
+
+    @ApiModelProperty("商品名称")
     /**
      * 机构设备关联id
      */

+ 73 - 0
src/main/java/com/caimei/service/aopservice/IpSaveService.java

@@ -0,0 +1,73 @@
+package com.caimei.service.aopservice;
+
+
+import com.caimei.mapper.aopMapper.IpSaveRepository;
+import com.caimei.model.po.IpSavePo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.mongodb.core.MongoTemplate;
+import org.springframework.stereotype.Service;
+
+
+import java.util.List;
+
+/**
+ * @author Administrator
+ */
+@Service
+public class IpSaveService {
+
+    @Autowired
+    private IpSaveRepository ipSaveRepository;
+    @Autowired
+    private MongoTemplate mongoTemplate;
+
+
+    /**
+     * 保存
+     * @param IpSavePo
+     */
+    public void save(IpSavePo IpSavePo){
+        //如果需要自定义主键,可以在这里指定主键;如果不指定主键,MongoDB会自动生成主键
+        //设置一些默认初始值。。。
+        //调用dao
+        ipSaveRepository.save(IpSavePo);
+    }
+
+    /**
+     * 修改
+     * @param IpSavePo
+     */
+    public void update(IpSavePo IpSavePo){
+        //调用dao
+        ipSaveRepository.save(IpSavePo);
+    }
+
+    /**
+     * 根据id删除
+     * @param id
+     */
+    public void deleteById(String id){
+        //调用dao
+        ipSaveRepository.deleteById(id);
+    }
+
+    /**
+     * 查询所有
+     * @return
+     */
+    public List<IpSavePo> findList(){
+        //调用dao
+        return ipSaveRepository.findAll();
+    }
+
+    /**
+     * 根据id查询
+     * @param id
+     * @return
+     */
+    public IpSavePo findById(String id){
+        //调用dao
+        return ipSaveRepository.findById(id).get();
+    }
+
+}

+ 126 - 0
src/main/java/com/caimei/service/aopservice/RocketMqService.java

@@ -0,0 +1,126 @@
+package com.caimei.service.aopservice;
+
+import com.alibaba.fastjson.JSON;
+import com.caimei.model.dto.MessageDto;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.rocketmq.client.producer.SendCallback;
+import org.apache.rocketmq.client.producer.SendResult;
+import org.apache.rocketmq.spring.core.RocketMQTemplate;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.messaging.Message;
+import org.springframework.messaging.support.MessageBuilder;
+import org.springframework.stereotype.Service;
+
+/**
+ * RocketMQ消息中间件实现类
+ *
+ * @author : Charles
+ * @date : 2021/6/17
+ */
+@Slf4j
+@Service
+@RequiredArgsConstructor
+public class RocketMqService {
+
+
+    public final Long timeout=3000L;
+
+    public final RocketMQTemplate rocketMQTemplate;
+
+    /**
+     * 发送消息
+     *
+     * @param messageDto {
+     *                   topic    消息主题
+     *                   content  消息内容
+     *                   tag      消息标签(可选)
+     *                   sort     有序消息(可选):1是,0否
+     *                   async    异步消息(可选):1是,0否
+     *                   oneway   单向消息(可选):1是,0否
+     *                   delay    延时消息等级(可选):1-18,0否,对应时间依次:1s 5s 10s 30s 1m 2m 3m 4m 5m 6m 7m 8m 9m 10m 20m 30m 1h 2h
+     *                   }
+     * @return SendResult
+     */
+    public SendResult sendCommonMessage(MessageDto messageDto) {
+        String destination = messageDto.getTopic();
+        if (StringUtils.isNotEmpty(messageDto.getTag())) {
+            destination += ":" + messageDto.getTag();
+        }
+        Message<String> message = MessageBuilder.withPayload(messageDto.getContent()).build();
+        SendResult returnResult = null;
+        boolean isAsync = (messageDto.getAsync() != null && messageDto.getAsync() == 1);
+        boolean isSort = (messageDto.getSort() != null && messageDto.getSort() == 1);
+        boolean isOneway = (messageDto.getOneway() != null && messageDto.getOneway() == 1);
+        boolean isDelay = (messageDto.getDelay() != null && messageDto.getDelay() > 0);
+        if (!isAsync) {
+            // 同步消息
+            if (isDelay) {
+                // 延时
+                returnResult = rocketMQTemplate.syncSend(destination, message, timeout, messageDto.getDelay());
+            } else {
+                if (isSort && isOneway) {
+                    // 单向有序
+                    rocketMQTemplate.sendOneWayOrderly(destination, message, "hashkey");
+                } else if (isSort) {
+                    // 有序
+                    returnResult = rocketMQTemplate.syncSendOrderly(destination, message, "hashkey");
+                } else if (isOneway) {
+                    // 单向
+                    rocketMQTemplate.sendOneWay(destination, message);
+                } else {
+                    returnResult = rocketMQTemplate.syncSend(destination, message);
+                }
+            }
+            log.info(returnResult.toString());
+        } else {
+            // 异步消息
+            if (isDelay) {
+                // 异步延时
+                rocketMQTemplate.asyncSend(destination, message, new SendCallback() {
+                    @Override
+                    public void onSuccess(SendResult sendResult) {
+                        log.info("异步消息发送成功:{}", JSON.toJSONString(sendResult));
+                        //可以处理相应的业务
+                    }
+                    @Override
+                    public void onException(Throwable throwable) {
+                        //可以处理相应的业务
+                        log.info("异步消息发送失败:{}", JSON.toJSONString(throwable));
+                    }
+                }, timeout, messageDto.getDelay());
+            } else {
+                if (isSort) {
+                    // 异步有序
+                    rocketMQTemplate.asyncSendOrderly(destination, message, "hashkey", new SendCallback() {
+                        @Override
+                        public void onSuccess(SendResult sendResult) {
+                            log.info("异步消息发送成功:{}", JSON.toJSONString(sendResult));
+                            //可以处理相应的业务
+                        }
+                        @Override
+                        public void onException(Throwable throwable) {
+                            //可以处理相应的业务
+                            log.info("异步消息发送失败:{}", JSON.toJSONString(throwable));
+                        }
+                    });
+                } else {
+                    rocketMQTemplate.asyncSend(destination, message, new SendCallback() {
+                        @Override
+                        public void onSuccess(SendResult sendResult) {
+                            log.info("异步消息发送成功:{}", JSON.toJSONString(sendResult));
+                            //可以处理相应的业务
+                        }
+                        @Override
+                        public void onException(Throwable throwable) {
+                            //可以处理相应的业务
+                            log.info("异步消息发送失败:{}", JSON.toJSONString(throwable));
+                        }
+                    });
+                }
+            }
+        }
+        return returnResult;
+    }
+}

+ 2 - 2
src/main/java/com/caimei/service/auth/impl/AuthClubServiceImpl.java

@@ -146,7 +146,8 @@ public class AuthClubServiceImpl implements AuthClubService {
                 return ResponseJson.error("该用户已存在,请勿重复添加");
             }
             clubUser.setAddTime(new Date());
-            clubUser.setPassword("rzt123456");
+            String md5Password = Md5Util.md5("rzt123456");
+            clubUser.setPassword(md5Password);
             clubUser.setStatus(1);
             clubMapper.insertClubUser(clubUser);
             // 获取供应商名称
@@ -164,7 +165,6 @@ public class AuthClubServiceImpl implements AuthClubService {
                 return ResponseJson.error("发送失败,请确认手机号无误");
             } else {
                 log.info("供应商添加机构用户-密码发送成功,手机号:" + mobile);
-
             }
         } else {
             clubUser.setId(clubUserId);

+ 1 - 1
src/main/java/com/caimei/service/wechat/RegisterService.java

@@ -14,7 +14,7 @@ public interface RegisterService {
     /**
      * 普通注册
      */
-    ResponseJson<WxClubUserVo> simpleRegister(String mobile, String verifyCode, String password, Integer authUserId, Integer authId);
+    ResponseJson<WxClubUserVo> simpleRegister(String mobile, String verifyCode, String password, Integer authUserId, Integer authId, Integer registerType);
 
     /**
      * 全部注册

+ 17 - 2
src/main/java/com/caimei/service/wechat/impl/RegisterServiceImpl.java

@@ -14,6 +14,7 @@ import com.caimei.service.auth.AuthProductService;
 import com.caimei.service.auth.AuthService;
 import com.caimei.service.wechat.RegisterService;
 import com.caimei.utils.Md5Util;
+import com.caimei.utils.SmsUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
@@ -47,7 +48,7 @@ public class RegisterServiceImpl implements RegisterService {
     private AuthProductService authProductService;
 
     @Override
-    public ResponseJson<WxClubUserVo> simpleRegister(String mobile, String verifyCode, String password, Integer authUserId, Integer authId) {
+    public ResponseJson<WxClubUserVo> simpleRegister(String mobile, String verifyCode, String password, Integer authUserId, Integer authId, Integer registerType) {
         // 校验手机号
         WxClubUserVo clubUserVo = clubMapper.getWxClubUser(mobile, null, authUserId, null, null);
         if (null != clubUserVo) {
@@ -68,6 +69,10 @@ public class RegisterServiceImpl implements RegisterService {
         if (!verifyCode.equals(redisVerifyCode)) {
             return ResponseJson.error("验证码错误,请重新输入", null);
         }
+        if (2 == registerType) {
+            // 验证码注册,默认密码
+            password = "rzt123456";
+        }
         String md5Password = Md5Util.md5(password);
         /*
          * 构建机构用户数据
@@ -90,6 +95,16 @@ public class RegisterServiceImpl implements RegisterService {
         clubUser.setAddTime(new Date());
         clubMapper.insertClubUser(clubUser);
         clubUserVo = clubMapper.getWxClubUser(mobile, null, authUserId, null, null);
+        if (2 == registerType) {
+            // 验证码注册,推送默认密码短信
+            String content = "您认证通登录密码为:rzt123456";
+            Boolean sendSms = SmsUtils.sendSms(11, mobile, content);
+            if (!sendSms) {
+                log.info("机构用户验证码注册-密码发送失败,手机号:" + mobile);
+            } else {
+                log.info("机构用户验证码注册-密码发送成功,手机号:" + mobile);
+            }
+        }
         return ResponseJson.success(clubUserVo);
     }
 
@@ -104,7 +119,7 @@ public class RegisterServiceImpl implements RegisterService {
             String mobile = (String) clubUserMap.get("mobile");
             String verifyCode = (String) clubUserMap.get("verifyCode");
             String password = (String) clubUserMap.get("password");
-            ResponseJson<WxClubUserVo> result = simpleRegister(mobile, verifyCode, password, authUserId, authId);
+            ResponseJson<WxClubUserVo> result = simpleRegister(mobile, verifyCode, password, authUserId, authId, 1);
             int code = result.getCode();
             if (0 != code) {
                 return result;

+ 26 - 22
src/main/java/com/caimei/utils/SmsUtils.java

@@ -36,31 +36,35 @@ public class SmsUtils {
 
     public static Boolean sendSms(Integer type, String mobile, String content) {
         try {
-            ArrayList<String> passList = new ArrayList<>();
+            List<String> passList = new ArrayList<>();
             passList.add("15113936829");
-            if (!"prod".equals(active) && !passList.contains(mobile)) {
-                return true;
-            }
-            if (StringUtils.isNotBlank(mobile) && mobile.length() == 11) {
-                String regex = "^(1[3-9]\\d{9}$)";
-                Pattern pattern = Pattern.compile(regex);
-                Matcher matcher = pattern.matcher(mobile);
-                if (matcher.matches()) {
-                    Map<String, Object> map = new HashMap<>(2);
-                    // 短信类型:1通知短信,2验证码短信,3营销短信
-                    map.put("type", type);
-                    map.put("content", content);
-                    map.put("mobile", mobile);
-                    String url = core + "/tools/sms/send";
-                    String result = HttpRequest.sendPost(url, map);
-                    JSONObject parseObject = JSONObject.parseObject(result);
-                    Integer code = parseObject.getInteger("code");
-                    if (code != 0) {
-                        log.info("短信发送失败,手机号>>>>" + mobile);
-                    } else {
-                        return true;
+            passList.add("18476937515");
+            passList.add("15917362709");
+            passList.add("15872950940");
+            if ("prod".equals(active) || passList.contains(mobile)) {
+                if (StringUtils.isNotBlank(mobile) && mobile.length() == 11) {
+                    String regex = "^(1[3-9]\\d{9}$)";
+                    Pattern pattern = Pattern.compile(regex);
+                    Matcher matcher = pattern.matcher(mobile);
+                    if (matcher.matches()) {
+                        Map<String, Object> map = new HashMap<>(3);
+                        // 短信类型:1通知短信,2验证码短信,3营销短信
+                        map.put("type", type);
+                        map.put("content", content);
+                        map.put("mobile", mobile);
+                        String url = core + "/tools/sms/send";
+                        String result = HttpRequest.sendPost(url, map);
+                        JSONObject parseObject = JSONObject.parseObject(result);
+                        Integer code = parseObject.getInteger("code");
+                        if (code != 0) {
+                            log.info("短信发送失败,手机号>>>>" + mobile);
+                        } else {
+                            return true;
+                        }
                     }
                 }
+            } else {
+                return true;
             }
         } catch (Exception e) {
             log.error("短信推送异常", e);

+ 14 - 1
src/main/resources/config/beta/application-beta.yml

@@ -22,6 +22,12 @@ spring:
       max-lifetime: 1800000
       connection-timeout: 30000
       connection-test-query: SELECT 1
+  #mongo数据源配置
+  data:
+    mongodb:
+      #使用uri连接
+      # mongodb://用户名:密码@IP地址:27017/数据库
+      uri: mongodb://zzj:easyCome.@47.107.48.218:27017/userInfo
   #数据源连接--end
 
   redis:
@@ -92,4 +98,11 @@ aliyunConfig:
   accessKeyId: LTAI4GBL3o4YkWnbKYgf2Xia
   accessKeySecret: dBjAXqbYiEPP6Ukuk2ZsXQeET7FVkK
   bucketName: caimei-oss
-  endpoint: https://oss-cn-shenzhen.aliyuncs.com
+  endpoint: https://oss-cn-shenzhen.aliyuncs.com
+
+# rocketmq 配置项,对应 RocketMQProperties 配置类
+rocketmq:
+  name-server: 47.107.48.218:9876  # RocketMQ Namesrv,测试环境120.79.25.27:9876未启动
+  producer:
+    group: caimei_beta_group            # 生产者分组
+    send-message-timeout: 3000     # 发送消息超时时间,单位:毫秒。默认为 3000 。

+ 12 - 0
src/main/resources/config/dev/application-dev.yml

@@ -22,6 +22,12 @@ spring:
       max-lifetime: 1800000
       connection-timeout: 30000
       connection-test-query: SELECT 1
+  data:
+    #mongo数据源配置
+    mongodb:
+      #使用uri连接
+      # mongodb://用户名:密码@IP地址:27017/数据库
+      uri: mongodb://zzj:easyCome.@192.168.2.100:27017/userInfo
   #数据源连接--end
 
   redis:
@@ -89,3 +95,9 @@ aliyunConfig:
   bucketName: caimei-oss
   endpoint: https://oss-cn-shenzhen.aliyuncs.com
 
+# rocketmq 配置项,对应 RocketMQProperties 配置类
+rocketmq:
+  name-server: 192.168.2.100:9876  # RocketMQ Namesrv
+  producer:
+    group: caimei_dev_group        # 生产者分组
+    send-message-timeout: 3000     # 发送消息超时时间,单位:毫秒。默认为 3000 。

+ 12 - 0
src/main/resources/config/prod/application-prod.yml

@@ -22,6 +22,11 @@ spring:
       max-lifetime: 1800000
       connection-timeout: 30000
       connection-test-query: SELECT 1
+  data:
+    mongodb:
+      #使用uri连接
+      # mongodb://用户名:密码@IP地址:27017/数据库
+      uri: mongodb://zzj:easyCome.@120.79.162.1:27017/userInfo
   #数据源连接--end
 
   redis:
@@ -85,3 +90,10 @@ aliyunConfig:
   accessKeySecret: dBjAXqbYiEPP6Ukuk2ZsXQeET7FVkK
   bucketName: caimei-oss
   endpoint: https://oss-cn-shenzhen.aliyuncs.com
+
+# rocketmq 配置项,对应 RocketMQProperties 配置类
+rocketmq:
+  name-server: 39.108.11.105:9876  # RocketMQ Namesrv
+  producer:
+    group: caimei_prod_group            # 生产者分组
+    send-message-timeout: 3000     # 发送消息超时时间,单位:毫秒。默认为 3000 。

+ 6 - 4
src/main/resources/mapper/AuthMapper.xml

@@ -113,16 +113,16 @@
         delete from cm_brand_auth_banner where authId = #{authId}
     </delete>
     <select id="getAuthList" resultType="com.caimei.model.vo.AuthVo">
-        select a.id as authId, authParty, cbcu2.mobile, a.status, a.auditStatus, a.shopAuditStatus, a.createTime,
+        select a.id as authId, a.authUserId, authParty, cbcu2.mobile, a.status, a.auditStatus, a.shopAuditStatus, a.createTime,
         if(a.createSource = 1,cu.name,cbcu1.mobile) as createBy,au.name as auditBy,a.auditTime,a.invalidReason,
         a.sendStatus, ifnull(au1.name,au1.mobile) as shopAuditBy,a.shopAuditTime,
         ifnull(ap.waitAuditNum,0) as waitAuditNum,
         ifnull(bp.waitAuditNum,0) as shopWaitAuditNum,
         if(ifnull(ap.waitAuditNum,0)>0,0,1) as lowerAuditStatus,
-        a.checkFlag,a.starFlag,a.scanCount
+        a.checkFlag,a.starFlag,a.scanCount,ifnull(cp.productNum,0) as productNum
         from cm_brand_auth a
         left join cm_brand_auth_user cu on a.createBy = cu.authUserId
-        left join cm_brand_club_user cbcu1 on a.createBy = cbcu1.id
+        left join cm_brand_club_user cbcu1 on a.createBy = cbcu1.id and cbcu1.delFlag = 0
         left join cm_brand_auth_user au on a.auditBy = au.authUserId
         left join cm_brand_auth_user au1 on a.shopAuditBy = au1.authUserId
         left join cm_brand_club_user cbcu2 on a.id = cbcu2.authId and cbcu2.delFlag = 0
@@ -132,6 +132,8 @@
         left join (select r.authId,count(*) as waitAuditNum from cm_brand_auth_product p
             left join cm_brand_product_relation r on p.id = r.productId
             where shopAuditStatus = 2 group by r.authId) bp on a.id = bp.authId
+        left join (select authId,count(*) as productNum from cm_brand_auth_product group by
+        authId) cp on a.id = cp.authId
         where a.authUserId = #{authUserId} and a.delFlag = 0
         <if test="authParty != null and authParty != ''">
             and a.authParty like CONCAT('%',#{authParty},'%')
@@ -279,7 +281,7 @@
     <select id="getAuthBaseInfo" resultType="com.caimei.model.vo.AuthFormVo">
         select a.id as authId, authParty, auditStatus, shopAuditStatus,if(u.id is null,0,1) as bindStatus
         from cm_brand_auth a
-        left join cm_brand_club_user u on a.id = u.authId
+        left join cm_brand_club_user u on a.id = u.authId and u.delFlag = 0
         <where>
             <if test="authUserId != null">
                 and a.authUserId = #{authUserId}

+ 7 - 6
src/main/resources/mapper/AuthProductMapper.xml

@@ -168,18 +168,19 @@
         where id = #{relationId}
     </update>
     <select id="getProductList" resultType="com.caimei.model.vo.ProductListVo">
-        select r.id as relationId,p.id as productId,if(p.productTypeId is null,p.name,t.name) as productName,
-        snCode,p.status,p.auditStatus,p.shopAuditStatus, p.createTime,
-        if(p.createSource = 1,cu.name,cbcu.mobile) as createBy,
-        au.name as auditBy,p.auditTime,p.invalidReason, ifnull(au1.name,au1.mobile) as shopAuditBy,
+        select r.id as relationId,p.id as productId,a.authUserId, if(p.productTypeId is null,p.name,t.name) as productName,
+               snCode,p.status,p.auditStatus,p.shopAuditStatus, p.createTime,
+               if(p.createSource = 1,cu.name,cbcu.mobile) as createBy,
+               au.name as auditBy,p.auditTime,p.invalidReason, ifnull(au1.name,au1.mobile) as shopAuditBy,
         p.shopAuditTime, p.checkFlag, p.scanCount
         from cm_brand_auth_product p
         left join cm_brand_product_relation r on p.id = r.productId
         left join cm_brand_product_type t on p.productTypeId = t.id and t.delFlag = 0
+        left join cm_brand_auth a on p.authId = a.id
         left join cm_brand_auth_user cu on p.createBy = cu.authUserId
         left join cm_brand_auth_user au on p.auditBy = au.authUserId
         left join cm_brand_auth_user au1 on p.shopAuditBy = au1.authUserId
-        left join cm_brand_club_user cbcu on p.createBy = cbcu.id
+        left join cm_brand_club_user cbcu on p.createBy = cbcu.id and cbcu.delFlag = 0
         where r.authId = #{authId}
         <if test="productName != null and productName != ''">
             and (t.name like CONCAT('%',#{productName},'%') or t.name like CONCAT('%',#{productName},'%'))
@@ -378,7 +379,7 @@
         from cm_brand_product_type t
         left join cm_brand_auth_user cu on t.createBy = cu.authUserId
         left join cm_brand_auth_user au on t.auditBy = au.authUserId
-        left join cm_brand_club_user cbcu on t.createBy = cbcu.id
+        left join cm_brand_club_user cbcu on t.createBy = cbcu.id and cbcu.delFlag = 0
         where t.authUserId = #{authUserId} and t.delFlag = 0
         <if test="name != null and name != ''">
             and t.name like CONCAT('%',#{name},'%')

+ 2 - 2
src/main/resources/mapper/ShopMapper.xml

@@ -238,7 +238,7 @@
         select cf.id as feedbackId, a.authParty as authParty, cu.mobile, content, commitTime, handleStatus, handleResult,
         handleTime
         from cm_brand_club_feedback cf
-        left join cm_brand_club_user cu on cf.clubUserId = cu.id
+        left join cm_brand_club_user cu on cf.clubUserId = cu.id and cu.delFlag = 0
         left join cm_brand_auth a on cu.authId = a.id
         left join cm_brand_auth_user au on cu.authUserId = au.authUserId
         where (a.authUserId = #{authUserId} or au.authUserId = #{authUserId})
@@ -255,7 +255,7 @@
     <select id="getFeedback" resultType="com.caimei.model.vo.FeedbackVo">
         select cf.id as feedbackId, a.authParty as authParty, cu.mobile, content, commitTime, handleStatus, handleResult, handleTime
         from cm_brand_club_feedback cf
-                 left join cm_brand_club_user cu on cf.clubUserId = cu.id
+                 left join cm_brand_club_user cu on cf.clubUserId = cu.id and cu.delFlag = 0
                  left join cm_brand_auth a on cu.authId = a.id
         where cf.id = #{feedbackId}
     </select>