Browse Source

Merge remote-tracking branch 'origin/master'

ningsy 4 years ago
parent
commit
6c88535268

+ 1 - 0
suishenbang-system/src/main/java/com/dgtly/system/mapper/SysUserMapper.java

@@ -180,4 +180,5 @@ public interface SysUserMapper
      * @date: 2020/10/19 14:36
      */
     List<SysUser> selectUserByOrgCode(String orgCode);
+
 }

+ 1 - 0
suishenbang-system/src/main/java/com/dgtly/system/service/ISysUserService.java

@@ -238,6 +238,7 @@ public interface ISysUserService
      */
     Map<String,Map<String,Object>> selectLoginNamesByCostumerCode(Set<String> customerCodes);
 
+
     public int insertPersonalAccount(SysUser user);
 
     /**

+ 1 - 0
suishenbang-system/src/main/java/com/dgtly/system/service/impl/SysUserServiceImpl.java

@@ -600,6 +600,7 @@ public class SysUserServiceImpl implements ISysUserService
         return userMapper.selectLoginNamesByCostumerCode(a);
     }
 
+
     @Override
     public int insertPersonalAccount(SysUser user) {
         return userMapper.updateUser(user);

+ 42 - 0
suishenbang-wxportal/suishenbang-wxportal-api/src/main/java/com/dgtly/wxportal/controller/WxController.java

@@ -8,6 +8,8 @@ import com.dgtly.common.core.domain.ParameterObject;
 import com.dgtly.common.utils.http.HttpUtils;
 import com.dgtly.common.utils.security.EncryptPassWordClass;
 import com.dgtly.system.service.ISysConfigService;
+import com.dgtly.wxportal.domain.WxSendMessage;
+import com.dgtly.wxportal.mapper.WxSendMessageMapper;
 import com.dgtly.wxportal.utils.qywxutils.QyWxSendMessageUtil;
 import com.dgtly.wxportal.utils.qywxutils.QyWxUserUtil;
 import com.dgtly.common.utils.RedisUtil;
@@ -26,6 +28,7 @@ import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -55,6 +58,9 @@ public class WxController extends ApiBaseController {
     @Value(value = "${libang.getUserByTicket}")
     private String getUserByTicketUrl;
 
+    @Autowired
+    private WxSendMessageMapper wxSendMessageMapper;
+
 
     @ApiOperation(value = "获取微信授权跳转url",notes = "参数:{url:www.baidu.com}")
     @ApiImplicitParams({
@@ -99,6 +105,42 @@ public class WxController extends ApiBaseController {
         }
     }
 
+    @ApiOperation(value = "根据用户经销商customer_code发送收货文本",
+            notes = "参数:{\"deliveryNumber\":\"123456\"" +
+                    ",\"shipmentNumber\":\"123456\"" +
+                    ",\"belongTo\":\"123456\"" +
+                    ",\"orderNumber\":\"123456\"}" )
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "params" , paramType = "body")
+    })
+    @PostMapping("sendDeliveryMessage")
+    public Object sendDeliveryMessage(){
+        ParameterObject obj =  getParameterObject();
+        obj.checkParameterNotNull("belongTo,deliveryNumber,shipmentNumber,orderNumber");
+        String belongTo = obj.getString("belongTo");
+        String deliveryNumber = obj.getString("deliveryNumber");
+        String shipmentNumber = obj.getString("shipmentNumber");
+        String orderNumber = obj.getString("orderNumber");
+        String belongToName = obj.getString("belongToName");
+        if(belongToName==null){
+            belongToName = "经销商";
+        }
+        Set<String> customerCodes = new HashSet<>();
+        customerCodes.add(belongTo);
+        logger.info("收到需要通知的经销商组织代码:"+belongTo);
+        Map<String,Map<String,Object>> maps = sysUserService.selectLoginNamesByCostumerCode(customerCodes);
+        String temple =configService.selectConfigByKey("wx.notification.delivery");
+
+        //消息
+        String message = String.format(temple,deliveryNumber,shipmentNumber,belongTo,orderNumber,belongToName);
+        if(customerCodes.size()>0){
+            qyWxSendMessageUtil.sendDeliveryMessage(customerCodes,maps,message);
+        }
+
+        return AjaxResult.success();
+    }
+
+
     @ApiOperation(value = "根据用户经销商组织代码 customer_code发送文本",
             notes = "参数:{\"XXX\":\"123,456\"}(说明:key是经销商code 值是订单编号列表)" )
     @ApiImplicitParams({

+ 4 - 8
suishenbang-wxportal/suishenbang-wxportal-api/src/main/java/com/dgtly/wxportal/controller/WxPortalController.java

@@ -80,12 +80,8 @@ public class WxPortalController extends ApiBaseController {
         String userId = obj.getString("userId");
         SysUserExt userExt = userExtService.selectSysUserExtById(Long.parseLong(userId));
         if (userExt!=null){
-            if ("1".equals(userExt.getIsCustomerManager())){
-                List<SysUser> userList = userService.selectUserByOrgCode(userExt.getOrgCode());
-                return AjaxResult.success().putKV("userList",userList);
-            }else{
-                return AjaxResult.error("不是负责人");
-            }
+            List<SysUser> userList = userService.selectUserByOrgCode(userExt.getOrgCode());
+            return AjaxResult.success().putKV("userList",userList);
         }else{
             return AjaxResult.error("用户不存在");
         }
@@ -108,9 +104,9 @@ public class WxPortalController extends ApiBaseController {
         user.setIsConsignee(IsConsignee);
         int i = userService.updateUser(user);
         if (i>0){
-            return AjaxResult.success("成功");
+            return AjaxResult.success();
         }else {
-            return AjaxResult.error("失败");
+            return AjaxResult.error();
         }
     }
 }

+ 13 - 0
suishenbang-wxportal/suishenbang-wxportal-common/src/main/java/com/dgtly/wxportal/domain/WxSendMessage.java

@@ -34,6 +34,10 @@ public class WxSendMessage extends BaseEntity
     @Excel(name = "类型")
     private String type ="text";
 
+
+    /** 种类 (过信用0、收货1)*/
+    private String form;
+
     public void setId(Long id) 
     {
         this.id = id;
@@ -80,6 +84,15 @@ public class WxSendMessage extends BaseEntity
         return type;
     }
 
+
+    public String getForm() {
+        return form;
+    }
+
+    public void setForm(String form) {
+        this.form = form;
+    }
+
     @Override
     public String toString() {
         return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

+ 37 - 1
suishenbang-wxportal/suishenbang-wxportal-common/src/main/java/com/dgtly/wxportal/utils/qywxutils/QyWxSendMessageUtil.java

@@ -74,6 +74,7 @@ public class QyWxSendMessageUtil {
                     try{
                         sendMessage(qyWxTextMessage);
                         wm.setIsSuccess("1");
+                        wm.setForm("0");
                     }catch (Exception e){
                         log.error("对"+maps.get(code).get("touser")+"发送消息失败",e);
                     }finally {
@@ -91,10 +92,45 @@ public class QyWxSendMessageUtil {
 
                 log.error("发送微信信息时插入记录出错!!",e);
             }
+        }
+    }
 
+    @Async
+    public void sendDeliveryMessage(Set<String> customerCodes,Map<String,Map<String,Object>> maps,String msg){
+        List<WxSendMessage> wmList = new ArrayList<>();
+        if(customerCodes.size()>0){
+            for(String code:customerCodes){
+                if(maps.containsKey(code)&&maps.get(code).get("touser")!=null&&!maps.get(code).get("touser").toString().trim().equals("")){
+                    WxSendMessage wm= new WxSendMessage();
+                    QyWxTextMessage qyWxTextMessage = new QyWxTextMessage();
+                    qyWxTextMessage.setTouser(maps.get(code).get("touser").toString());
+                    wm.setToUser(qyWxTextMessage.getTouser());
+                    qyWxTextMessage.setText(msg);
+                    wm.setSendText(qyWxTextMessage.getText().getContent());
+                    try{
+                        sendMessage(qyWxTextMessage);
+                        wm.setIsSuccess("1");
+                        wm.setForm("1");
+                    }catch (Exception e){
+                        log.error("对"+maps.get(code).get("touser")+"发送消息失败",e);
+                    }finally {
+                        wmList.add(wm);
+                    }
+                }else{
+                    log.error("经销商code为:"+code+"的经销商未发现相应人员!!");
+                }
+            }
+        }
+        if(wmList.size()>0){
+            try{
+                wxSendMessageMapper.bathInsertWxSendMessage(wmList);
+            }catch (Exception e){
 
+                log.error("发送微信信息时插入记录出错!!",e);
+            }
         }
+    }
+
 
 
-    }
 }

+ 8 - 3
suishenbang-wxportal/suishenbang-wxportal-common/src/main/resources/mapper/wxportal/WxSendMessageMapper.xml

@@ -11,10 +11,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="isSuccess"    column="is_success"    />
         <result property="sendText"    column="send_text"    />
         <result property="type"    column="type"    />
+        <result property="form"    column="form"    />
     </resultMap>
 
     <sql id="selectWxSendMessageVo">
-        select id, create_time, to_user, is_success, send_text, type from wx_send_message
+        select id, create_time, to_user, is_success, send_text, type,form from wx_send_message
     </sql>
 
     <select id="selectWxSendMessageList" parameterType="WxSendMessage" resultMap="WxSendMessageResult">
@@ -24,6 +25,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="isSuccess != null  and isSuccess != ''"> and is_success = #{isSuccess}</if>
             <if test="sendText != null  and sendText != ''"> and send_text = #{sendText}</if>
             <if test="type != null  and type != ''"> and type = #{type}</if>
+            <if test="form != null  and form != ''"> and form = #{form}</if>
             <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
                 AND date_format(create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
             </if>
@@ -47,6 +49,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="isSuccess != null  and isSuccess != ''">is_success,</if>
             <if test="sendText != null  and sendText != ''">send_text,</if>
             <if test="type != null  and type != ''">type,</if>
+            <if test="form != null  and form != ''">form,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="id != null ">#{id},</if>
@@ -55,6 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="isSuccess != null  and isSuccess != ''">#{isSuccess},</if>
             <if test="sendText != null  and sendText != ''">#{sendText},</if>
             <if test="type != null  and type != ''">#{type},</if>
+            <if test="form != null  and form != ''">#{form},</if>
          </trim>
     </insert>
 
@@ -66,6 +70,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="isSuccess != null  and isSuccess != ''">is_success = #{isSuccess},</if>
             <if test="sendText != null  and sendText != ''">send_text = #{sendText},</if>
             <if test="type != null  and type != ''">type = #{type},</if>
+            <if test="form != null  and form != ''">type = #{form},</if>
         </trim>
         where id = #{id}
     </update>
@@ -82,9 +87,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </delete>
 
     <insert id="bathInsertWxSendMessage">
-        insert into wx_send_message(create_time, to_user,is_success,send_text,type) values
+        insert into wx_send_message(create_time, to_user,is_success,send_text,type,form) values
         <foreach item="item" index="index" collection="list" separator=",">
-            (now(),#{item.toUser},#{item.isSuccess},#{item.sendText},#{item.type})
+            (now(),#{item.toUser},#{item.isSuccess},#{item.sendText},#{item.type},#{item.form})
         </foreach>
     </insert>