张延森 3 years ago
parent
commit
9edd63c12e
20 changed files with 504 additions and 16 deletions
  1. 6
    0
      src/main/java/com/yunzhi/nanyang/common/Constants.java
  2. 60
    0
      src/main/java/com/yunzhi/nanyang/common/MessageUtil.java
  3. 12
    3
      src/main/java/com/yunzhi/nanyang/controller/TaDispatchController.java
  4. 119
    0
      src/main/java/com/yunzhi/nanyang/controller/TaMessageTemplateController.java
  5. 12
    4
      src/main/java/com/yunzhi/nanyang/controller/TaWithdrawalController.java
  6. 13
    0
      src/main/java/com/yunzhi/nanyang/controller/WxMaController.java
  7. 57
    0
      src/main/java/com/yunzhi/nanyang/entity/TaMessageTemplate.java
  8. 8
    0
      src/main/java/com/yunzhi/nanyang/entity/TaWithdrawal.java
  9. 19
    0
      src/main/java/com/yunzhi/nanyang/event/WorkDispatchEvent.java
  10. 18
    0
      src/main/java/com/yunzhi/nanyang/event/listener/WorkDispatchEventListener.java
  11. 18
    0
      src/main/java/com/yunzhi/nanyang/mapper/TaMessageTemplateMapper.java
  12. 3
    0
      src/main/java/com/yunzhi/nanyang/mapper/TaPersonMapper.java
  13. 3
    0
      src/main/java/com/yunzhi/nanyang/service/ITaMessageService.java
  14. 20
    0
      src/main/java/com/yunzhi/nanyang/service/ITaMessageTemplateService.java
  15. 1
    1
      src/main/java/com/yunzhi/nanyang/service/impl/TaAccountServiceImpl.java
  16. 75
    2
      src/main/java/com/yunzhi/nanyang/service/impl/TaMessageServiceImpl.java
  17. 44
    0
      src/main/java/com/yunzhi/nanyang/service/impl/TaMessageTemplateServiceImpl.java
  18. 3
    0
      src/main/java/com/yunzhi/nanyang/vo/AccountRecord.java
  19. 8
    6
      src/main/resources/mapper/TaAccountLogMapper.xml
  20. 5
    0
      src/main/resources/mapper/TaMessageTemplateMapper.xml

+ 6
- 0
src/main/java/com/yunzhi/nanyang/common/Constants.java View File

52
     public final static int WORK_PAUSE = 2;   // 暂停
52
     public final static int WORK_PAUSE = 2;   // 暂停
53
     public final static int WORK_DONE = 3;   // 已完成
53
     public final static int WORK_DONE = 3;   // 已完成
54
 
54
 
55
+    // 消息类型
56
+    public final static String MESSAGE_SMS = "sms"; // 短信
57
+    public final static String MESSAGE_MINIAPP = "miniapp"; // 小程序
58
+
59
+    public final static String MESSAGE_ORDER_NOTIFY = "order_notify";   // 订单通知
60
+    public final static String MESSAGE_ORDER_EXPIRE = "order_expire";   // 订单超时
55
 }
61
 }

+ 60
- 0
src/main/java/com/yunzhi/nanyang/common/MessageUtil.java View File

1
+package com.yunzhi.nanyang.common;
2
+
3
+import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage;
4
+import com.alibaba.fastjson.JSONArray;
5
+import com.alibaba.fastjson.JSONObject;
6
+import com.yunzhi.nanyang.entity.TaMessageTemplate;
7
+import lombok.Data;
8
+
9
+import java.util.Formatter;
10
+import java.util.List;
11
+
12
+public class MessageUtil {
13
+
14
+    public static List<WxMaSubscribeMessage.MsgData> getWxMessageData(String jsonStr, Object ...values) {
15
+        String str = new Formatter().format(jsonStr, values).toString();
16
+
17
+        return JSONArray.parseArray(str, WxMaSubscribeMessage.MsgData.class);
18
+    }
19
+
20
+    public static WxMaSubscribeMessage getWxMaSubscribeMessage(TaMessageTemplate taMessageTemplate) {
21
+        if (null == taMessageTemplate) return null;
22
+
23
+        WxMaSubscribeMessage message = new WxMaSubscribeMessage();
24
+        message.setTemplateId(taMessageTemplate.getAppTplId());
25
+
26
+        return message;
27
+    }
28
+
29
+    public static SMSUtils.Message getSmsMessage(TaMessageTemplate taMessageTemplate) {
30
+        if (null == taMessageTemplate) return null;
31
+
32
+        SMSUtils.Message message = new SMSUtils.Message();
33
+        message.setCode(taMessageTemplate.getAppTplId());
34
+        message.setSign(taMessageTemplate.getAppTplSign());
35
+
36
+        return message;
37
+    }
38
+
39
+    @Data
40
+    public static class NaviPage {
41
+        private String page;
42
+        private String query;
43
+
44
+        NaviPage() {}
45
+        public static NaviPage fromJSON(String jsonStr) {
46
+            JSONObject jsonObject = JSONObject.parseObject(jsonStr);
47
+            NaviPage naviPage = new NaviPage();
48
+            naviPage.page = (String) jsonObject.get("page");
49
+            naviPage.query = (String) jsonObject.get("query");
50
+            return naviPage;
51
+        }
52
+
53
+        public String toURL(Object ...values) {
54
+            String queryString = new Formatter().format(this.query, values).toString();
55
+            return this.page + "?" + queryString;
56
+        }
57
+
58
+    }
59
+
60
+}

+ 12
- 3
src/main/java/com/yunzhi/nanyang/controller/TaDispatchController.java View File

7
 import com.yunzhi.nanyang.entity.SysUser;
7
 import com.yunzhi.nanyang.entity.SysUser;
8
 import com.yunzhi.nanyang.entity.TaOrder;
8
 import com.yunzhi.nanyang.entity.TaOrder;
9
 import com.yunzhi.nanyang.entity.TaWorkJob;
9
 import com.yunzhi.nanyang.entity.TaWorkJob;
10
+import com.yunzhi.nanyang.event.WorkDispatchEvent;
10
 import com.yunzhi.nanyang.service.*;
11
 import com.yunzhi.nanyang.service.*;
11
 import io.swagger.annotations.Api;
12
 import io.swagger.annotations.Api;
12
 import io.swagger.annotations.ApiOperation;
13
 import io.swagger.annotations.ApiOperation;
15
 import org.slf4j.Logger;
16
 import org.slf4j.Logger;
16
 import org.slf4j.LoggerFactory;
17
 import org.slf4j.LoggerFactory;
17
 import org.springframework.beans.factory.annotation.Autowired;
18
 import org.springframework.beans.factory.annotation.Autowired;
19
+import org.springframework.context.ApplicationEventPublisher;
18
 import org.springframework.web.bind.annotation.PathVariable;
20
 import org.springframework.web.bind.annotation.PathVariable;
19
 import org.springframework.web.bind.annotation.RequestBody;
21
 import org.springframework.web.bind.annotation.RequestBody;
20
 import org.springframework.web.bind.annotation.RequestMapping;
22
 import org.springframework.web.bind.annotation.RequestMapping;
62
     @Autowired
64
     @Autowired
63
     public ISysUserService iSysUserService;
65
     public ISysUserService iSysUserService;
64
 
66
 
67
+    @Autowired
68
+    ApplicationEventPublisher applicationEventPublisher;
69
+
65
 
70
 
66
     /**
71
     /**
67
      * 分页查询列表
72
      * 分页查询列表
143
         if (iTaDispatchService.save(taDispatch)){
148
         if (iTaDispatchService.save(taDispatch)){
144
 
149
 
145
             // 生成作业信息
150
             // 生成作业信息
146
-            iTaWorkJobService.createByDispatch(taDispatch, taOrder);
151
+            TaWorkJob taWorkJob = iTaWorkJobService.createByDispatch(taDispatch, taOrder);
147
 
152
 
148
             // 更新订单状态
153
             // 更新订单状态
149
             iTaOrderService.updateStatus(taDispatch.getOrderId(), "dispatch_status", Constants.DISPATCH_DONE);
154
             iTaOrderService.updateStatus(taDispatch.getOrderId(), "dispatch_status", Constants.DISPATCH_DONE);
150
 
155
 
156
+            // 发送通知
157
+            applicationEventPublisher.publishEvent(new WorkDispatchEvent(this, taWorkJob, taOrder));
158
+
151
             return ResponseBean.success(taDispatch);
159
             return ResponseBean.success(taDispatch);
152
         }else {
160
         }else {
153
             return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
161
             return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
221
 
229
 
222
     /**
230
     /**
223
      * 根据id查询对象
231
      * 根据id查询对象
224
-     * @param id  实体ID
232
+     * @param orderId  实体ID
225
      */
233
      */
226
     @RequestMapping(value="/admin/order/{orderId}/dispatch",method= RequestMethod.GET)
234
     @RequestMapping(value="/admin/order/{orderId}/dispatch",method= RequestMethod.GET)
227
     @ApiOperation(value="调度详情", notes = "调度详情", httpMethod = "GET", response = ResponseBean.class)
235
     @ApiOperation(value="调度详情", notes = "调度详情", httpMethod = "GET", response = ResponseBean.class)
228
     public ResponseBean taDispatchGet(@ApiParam("订单ID") @PathVariable String orderId) throws Exception{
236
     public ResponseBean taDispatchGet(@ApiParam("订单ID") @PathVariable String orderId) throws Exception{
229
-        return ResponseBean.success(iTaDispatchService.getExistBy("order_id", orderId, false, true));
237
+        TaDispatch taDispatch = iTaDispatchService.getExistBy("order_id", orderId, false, true);
238
+        return ResponseBean.success(taDispatch);
230
     }
239
     }
231
 }
240
 }

+ 119
- 0
src/main/java/com/yunzhi/nanyang/controller/TaMessageTemplateController.java View File

1
+package com.yunzhi.nanyang.controller;
2
+
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.baomidou.mybatisplus.core.metadata.IPage;
5
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
+import com.yunzhi.nanyang.common.BaseController;
7
+import com.yunzhi.nanyang.common.ResponseBean;
8
+import io.swagger.annotations.Api;
9
+import io.swagger.annotations.ApiOperation;
10
+import io.swagger.annotations.ApiParam;
11
+import org.slf4j.Logger;
12
+import org.slf4j.LoggerFactory;
13
+import org.springframework.beans.factory.annotation.Autowired;
14
+import org.springframework.web.bind.annotation.PathVariable;
15
+import org.springframework.web.bind.annotation.RequestBody;
16
+import org.springframework.web.bind.annotation.RequestMapping;
17
+import org.springframework.web.bind.annotation.RequestMethod;
18
+import org.springframework.web.bind.annotation.RequestParam;
19
+import com.yunzhi.nanyang.service.ITaMessageTemplateService;
20
+import com.yunzhi.nanyang.entity.TaMessageTemplate;
21
+import org.springframework.web.bind.annotation.RestController;
22
+
23
+/**
24
+ * <p>
25
+    * 消息模板 前端控制器
26
+    * </p>
27
+ *
28
+ * @author yansen
29
+ * @since 2022-04-11
30
+ */
31
+
32
+@Api(tags = "消息模板")
33
+@RestController
34
+@RequestMapping("/")
35
+public class TaMessageTemplateController extends BaseController {
36
+
37
+    private final Logger logger = LoggerFactory.getLogger(TaMessageTemplateController.class);
38
+
39
+    @Autowired
40
+    public ITaMessageTemplateService iTaMessageTemplateService;
41
+
42
+
43
+    /**
44
+     * 分页查询列表
45
+     * @param pageNum
46
+     * @param pageSize
47
+     * @return
48
+     */
49
+    @RequestMapping(value="/taMessageTemplate",method= RequestMethod.GET)
50
+    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
51
+    public ResponseBean taMessageTemplateList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
52
+									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
53
+
54
+		    IPage<TaMessageTemplate> pg = new Page<>(pageNum, pageSize);
55
+            QueryWrapper<TaMessageTemplate> queryWrapper = new QueryWrapper<>();
56
+            queryWrapper.orderByDesc("create_date");
57
+
58
+            IPage<TaMessageTemplate> result = iTaMessageTemplateService.page(pg, queryWrapper);
59
+            return ResponseBean.success(result);
60
+    }
61
+
62
+    /**
63
+     * 保存对象
64
+     * @param taMessageTemplate 实体对象
65
+     * @return
66
+     */
67
+    @RequestMapping(value="/taMessageTemplate",method= RequestMethod.POST)
68
+    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
69
+    public ResponseBean taMessageTemplateAdd(@ApiParam("保存内容") @RequestBody TaMessageTemplate taMessageTemplate) throws Exception{
70
+
71
+        if (iTaMessageTemplateService.save(taMessageTemplate)){
72
+            return ResponseBean.success(taMessageTemplate);
73
+        }else {
74
+            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
75
+        }
76
+    }
77
+
78
+    /**
79
+     * 根据id删除对象
80
+     * @param id  实体ID
81
+     */
82
+    @RequestMapping(value="/taMessageTemplate/{id}", method= RequestMethod.DELETE)
83
+    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
84
+    public ResponseBean taMessageTemplateDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
85
+        if(iTaMessageTemplateService.removeById(id)){
86
+            return ResponseBean.success("success");
87
+        }else {
88
+            return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
89
+        }
90
+    }
91
+
92
+    /**
93
+     * 修改对象
94
+     * @param id  实体ID
95
+     * @param taMessageTemplate 实体对象
96
+     * @return
97
+     */
98
+    @RequestMapping(value="/taMessageTemplate/{id}",method= RequestMethod.PUT)
99
+    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
100
+    public ResponseBean taMessageTemplateUpdate(@ApiParam("对象ID") @PathVariable Integer id,
101
+                                        @ApiParam("更新内容") @RequestBody TaMessageTemplate taMessageTemplate) throws Exception{
102
+
103
+        if (iTaMessageTemplateService.updateById(taMessageTemplate)){
104
+            return ResponseBean.success(iTaMessageTemplateService.getById(id));
105
+        }else {
106
+            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
107
+        }
108
+    }
109
+
110
+    /**
111
+     * 根据id查询对象
112
+     * @param id  实体ID
113
+     */
114
+    @RequestMapping(value="/taMessageTemplate/{id}",method= RequestMethod.GET)
115
+    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
116
+    public ResponseBean taMessageTemplateGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
117
+        return ResponseBean.success(iTaMessageTemplateService.getById(id));
118
+    }
119
+}

+ 12
- 4
src/main/java/com/yunzhi/nanyang/controller/TaWithdrawalController.java View File

5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
 import com.yunzhi.nanyang.common.*;
6
 import com.yunzhi.nanyang.common.*;
7
 import com.yunzhi.nanyang.entity.*;
7
 import com.yunzhi.nanyang.entity.*;
8
-import com.yunzhi.nanyang.service.ISysUserService;
9
-import com.yunzhi.nanyang.service.ITaAccountService;
10
-import com.yunzhi.nanyang.service.ITaBankCardService;
8
+import com.yunzhi.nanyang.service.*;
11
 import io.swagger.annotations.Api;
9
 import io.swagger.annotations.Api;
12
 import io.swagger.annotations.ApiOperation;
10
 import io.swagger.annotations.ApiOperation;
13
 import io.swagger.annotations.ApiParam;
11
 import io.swagger.annotations.ApiParam;
19
 import org.springframework.web.bind.annotation.RequestMapping;
17
 import org.springframework.web.bind.annotation.RequestMapping;
20
 import org.springframework.web.bind.annotation.RequestMethod;
18
 import org.springframework.web.bind.annotation.RequestMethod;
21
 import org.springframework.web.bind.annotation.RequestParam;
19
 import org.springframework.web.bind.annotation.RequestParam;
22
-import com.yunzhi.nanyang.service.ITaWithdrawalService;
23
 import org.springframework.web.bind.annotation.RestController;
20
 import org.springframework.web.bind.annotation.RestController;
24
 
21
 
25
 import java.time.LocalDateTime;
22
 import java.time.LocalDateTime;
52
     @Autowired
49
     @Autowired
53
     public ITaAccountService iTaAccountService;
50
     public ITaAccountService iTaAccountService;
54
 
51
 
52
+    @Autowired
53
+    public ITaOrgService iTaOrgService;
54
+
55
 
55
 
56
     /**
56
     /**
57
      * 分页查询列表
57
      * 分页查询列表
120
         taWithdrawal.setUserId(sysUser.getUserId());
120
         taWithdrawal.setUserId(sysUser.getUserId());
121
         taWithdrawal.setUserName(sysUser.getUserName());
121
         taWithdrawal.setUserName(sysUser.getUserName());
122
         taWithdrawal.setOrgId(sysUser.getOrgId());
122
         taWithdrawal.setOrgId(sysUser.getOrgId());
123
+        taWithdrawal.setStatus(Constants.STATUS_NORMAL);
123
 
124
 
124
         if (iTaWithdrawalService.save(taWithdrawal)){
125
         if (iTaWithdrawalService.save(taWithdrawal)){
125
             return ResponseBean.success(taWithdrawal);
126
             return ResponseBean.success(taWithdrawal);
256
         origin.setAuditUserName(sysUser.getUserName());
257
         origin.setAuditUserName(sysUser.getUserName());
257
         origin.setAuditStatus(taWithdrawal.getAuditStatus());
258
         origin.setAuditStatus(taWithdrawal.getAuditStatus());
258
         origin.setAuditRemark(taWithdrawal.getAuditRemark());
259
         origin.setAuditRemark(taWithdrawal.getAuditRemark());
260
+        origin.setAuditDate(LocalDateTime.now());
259
 
261
 
260
         if (iTaWithdrawalService.updateById(origin)){
262
         if (iTaWithdrawalService.updateById(origin)){
261
 
263
 
280
             return ResponseBean.error("提现申请不存在");
282
             return ResponseBean.error("提现申请不存在");
281
         }
283
         }
282
 
284
 
285
+        SysUser user = iSysUserService.getById(taWithdrawal.getUserId());
286
+        taWithdrawal.setPhone(user.getPhone());
287
+
283
         SysUser sysUser = currentUser();
288
         SysUser sysUser = currentUser();
284
         String orgId = taWithdrawal.getOrgId();
289
         String orgId = taWithdrawal.getOrgId();
285
         boolean isAdmin = Constants.ADMIN_ID.equals(sysUser.getUserId());
290
         boolean isAdmin = Constants.ADMIN_ID.equals(sysUser.getUserId());
289
             }
294
             }
290
         }
295
         }
291
 
296
 
297
+        TaOrg taOrg = iTaOrgService.getById(orgId);
298
+        taWithdrawal.setOrgName(taOrg.getName());
299
+
292
         TaBankCard taBankCard = iTaBankCardService.getById(taWithdrawal.getAccountCardNo());
300
         TaBankCard taBankCard = iTaBankCardService.getById(taWithdrawal.getAccountCardNo());
293
         taWithdrawal.setBankCard(taBankCard);
301
         taWithdrawal.setBankCard(taBankCard);
294
 
302
 

+ 13
- 0
src/main/java/com/yunzhi/nanyang/controller/WxMaController.java View File

6
 import cn.binarywang.wx.miniapp.bean.WxMaUserInfo;
6
 import cn.binarywang.wx.miniapp.bean.WxMaUserInfo;
7
 import com.yunzhi.nanyang.common.*;
7
 import com.yunzhi.nanyang.common.*;
8
 import com.yunzhi.nanyang.entity.SysMiniapp;
8
 import com.yunzhi.nanyang.entity.SysMiniapp;
9
+import com.yunzhi.nanyang.entity.TaMessageTemplate;
9
 import com.yunzhi.nanyang.entity.TaPerson;
10
 import com.yunzhi.nanyang.entity.TaPerson;
10
 import com.yunzhi.nanyang.service.ISysMiniappService;
11
 import com.yunzhi.nanyang.service.ISysMiniappService;
12
+import com.yunzhi.nanyang.service.ITaMessageTemplateService;
11
 import com.yunzhi.nanyang.service.ITaPersonService;
13
 import com.yunzhi.nanyang.service.ITaPersonService;
12
 import com.yunzhi.nanyang.shiro.utils.JWTUtil;
14
 import com.yunzhi.nanyang.shiro.utils.JWTUtil;
13
 import com.yunzhi.nanyang.vo.LoginParam;
15
 import com.yunzhi.nanyang.vo.LoginParam;
21
 
23
 
22
 import java.time.LocalDateTime;
24
 import java.time.LocalDateTime;
23
 import java.util.HashMap;
25
 import java.util.HashMap;
26
+import java.util.List;
24
 import java.util.Map;
27
 import java.util.Map;
25
 
28
 
26
 @Api(tags = "小程序登入/登出")
29
 @Api(tags = "小程序登入/登出")
34
     @Autowired
37
     @Autowired
35
     ITaPersonService iTaPersonService;
38
     ITaPersonService iTaPersonService;
36
 
39
 
40
+    @Autowired
41
+    ITaMessageTemplateService iTaMessageTemplateService;
42
+
37
     @Autowired
43
     @Autowired
38
     SMSCaptcha smsCaptcha;
44
     SMSCaptcha smsCaptcha;
39
 
45
 
60
     public ResponseBean preload(@ApiParam("客户端ID") @PathVariable String clientId,
66
     public ResponseBean preload(@ApiParam("客户端ID") @PathVariable String clientId,
61
                                 @ApiParam("小程序预加载参数") @RequestParam WxMaPreload wxMaPreload) throws Exception {
67
                                 @ApiParam("小程序预加载参数") @RequestParam WxMaPreload wxMaPreload) throws Exception {
62
 
68
 
69
+        if (Constants.CLIENT_WORKER.equals(clientId)) {
70
+            List<TaMessageTemplate> list = iTaMessageTemplateService.getByTplType(Constants.MESSAGE_MINIAPP);
71
+            ResponseBean.success(new HashMap<String, Object>(){{
72
+                put("tpls", list);
73
+            }});
74
+        }
75
+
63
         return ResponseBean.success(null);
76
         return ResponseBean.success(null);
64
     }
77
     }
65
 
78
 

+ 57
- 0
src/main/java/com/yunzhi/nanyang/entity/TaMessageTemplate.java View File

1
+package com.yunzhi.nanyang.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableId;
5
+import java.io.Serializable;
6
+import io.swagger.annotations.ApiModel;
7
+import io.swagger.annotations.ApiModelProperty;
8
+import lombok.Data;
9
+import lombok.EqualsAndHashCode;
10
+import lombok.experimental.Accessors;
11
+
12
+/**
13
+ * <p>
14
+ * 消息模板
15
+ * </p>
16
+ *
17
+ * @author yansen
18
+ * @since 2022-04-11
19
+ */
20
+@Data
21
+@EqualsAndHashCode(callSuper = false)
22
+@Accessors(chain = true)
23
+@ApiModel(value="TaMessageTemplate对象", description="消息模板")
24
+public class TaMessageTemplate implements Serializable {
25
+
26
+    private static final long serialVersionUID = 1L;
27
+
28
+    @ApiModelProperty(value = "模板ID")
29
+    @TableId(value = "tpl_id", type = IdType.AUTO)
30
+    private Integer tplId;
31
+
32
+    @ApiModelProperty(value = "模板类型;sms短信,miniapp小程序")
33
+    private String tplType;
34
+
35
+    @ApiModelProperty(value = "适用业务")
36
+    private String bizType;
37
+
38
+    @ApiModelProperty(value = "模块ID")
39
+    private String appId;
40
+
41
+    @ApiModelProperty(value = "对应模板ID;模板类型对应的模板ID,比如短信模板ID")
42
+    private String appTplId;
43
+
44
+    @ApiModelProperty(value = "模板sign")
45
+    private String appTplSign;
46
+
47
+    @ApiModelProperty(value = "模板内容;JSON格式")
48
+    private String appTplContent;
49
+
50
+    @ApiModelProperty(value = "模板动作;JSON格式")
51
+    private String appTplAction;
52
+
53
+    @ApiModelProperty(value = "状态")
54
+    private Integer status;
55
+
56
+
57
+}

+ 8
- 0
src/main/java/com/yunzhi/nanyang/entity/TaWithdrawal.java View File

38
     @ApiModelProperty(value = "申请人姓名")
38
     @ApiModelProperty(value = "申请人姓名")
39
     private String userName;
39
     private String userName;
40
 
40
 
41
+    @TableField(exist = false)
42
+    @ApiModelProperty(value = "申请人手机号")
43
+    private String phone;
44
+
41
     @ApiModelProperty(value = "提现金额")
45
     @ApiModelProperty(value = "提现金额")
42
     private Integer money;
46
     private Integer money;
43
 
47
 
53
     @ApiModelProperty(value = "审核结果")
57
     @ApiModelProperty(value = "审核结果")
54
     private String auditRemark;
58
     private String auditRemark;
55
 
59
 
60
+    @ApiModelProperty(value = "审核时间")
61
+    private LocalDateTime auditDate;
62
+
56
     @ApiModelProperty(value = "备注")
63
     @ApiModelProperty(value = "备注")
57
     private String remarks;
64
     private String remarks;
58
 
65
 
71
     @ApiModelProperty(value = "机构ID")
78
     @ApiModelProperty(value = "机构ID")
72
     private String orgId;
79
     private String orgId;
73
 
80
 
81
+    @TableField(exist = false)
74
     @ApiModelProperty(value = "机构名称")
82
     @ApiModelProperty(value = "机构名称")
75
     private String orgName;
83
     private String orgName;
76
 
84
 

+ 19
- 0
src/main/java/com/yunzhi/nanyang/event/WorkDispatchEvent.java View File

1
+package com.yunzhi.nanyang.event;
2
+
3
+import com.yunzhi.nanyang.entity.TaOrder;
4
+import com.yunzhi.nanyang.entity.TaWorkJob;
5
+import org.springframework.context.ApplicationEvent;
6
+
7
+public class WorkDispatchEvent extends ApplicationEvent {
8
+    private TaWorkJob taWorkJob;
9
+    private TaOrder taOrder;
10
+
11
+    public WorkDispatchEvent(Object source, TaWorkJob taDispatch, TaOrder taOrder) {
12
+        super(source);
13
+        this.taWorkJob = taDispatch;
14
+        this.taOrder = taOrder;
15
+    }
16
+
17
+    public TaWorkJob getTaWorkJob() { return taWorkJob; }
18
+    public TaOrder getTaOrder() { return taOrder; }
19
+}

+ 18
- 0
src/main/java/com/yunzhi/nanyang/event/listener/WorkDispatchEventListener.java View File

1
+package com.yunzhi.nanyang.event.listener;
2
+
3
+import com.yunzhi.nanyang.event.WorkDispatchEvent;
4
+import com.yunzhi.nanyang.service.ITaMessageService;
5
+import org.springframework.beans.factory.annotation.Autowired;
6
+import org.springframework.context.ApplicationListener;
7
+import org.springframework.stereotype.Component;
8
+
9
+@Component
10
+public class WorkDispatchEventListener implements ApplicationListener<WorkDispatchEvent> {
11
+    @Autowired
12
+    ITaMessageService iTaMessageService;
13
+
14
+    @Override
15
+    public void onApplicationEvent(WorkDispatchEvent evt) {
16
+        iTaMessageService.sendMessage(evt);
17
+    }
18
+}

+ 18
- 0
src/main/java/com/yunzhi/nanyang/mapper/TaMessageTemplateMapper.java View File

1
+package com.yunzhi.nanyang.mapper;
2
+
3
+import com.yunzhi.nanyang.entity.TaMessageTemplate;
4
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5
+import org.apache.ibatis.annotations.Mapper;
6
+
7
+/**
8
+ * <p>
9
+ * 消息模板 Mapper 接口
10
+ * </p>
11
+ *
12
+ * @author yansen
13
+ * @since 2022-04-11
14
+ */
15
+@Mapper
16
+public interface TaMessageTemplateMapper extends BaseMapper<TaMessageTemplate> {
17
+
18
+}

+ 3
- 0
src/main/java/com/yunzhi/nanyang/mapper/TaPersonMapper.java View File

19
 
19
 
20
     @Select("SELECT * FROM ta_person t WHERE t.app_id = #{appid} AND t.openid = #{openid} AND t.`status` > -1")
20
     @Select("SELECT * FROM ta_person t WHERE t.app_id = #{appid} AND t.openid = #{openid} AND t.`status` > -1")
21
     TaPerson getByOpenId(@Param("appid") String appid, @Param("openid") String openid);
21
     TaPerson getByOpenId(@Param("appid") String appid, @Param("openid") String openid);
22
+
23
+    @Select("SELECT * FROM ta_person t WHERE t.user_id = #{userId} AND t.`status` > -1")
24
+    TaPerson getByUserId(@Param("userId") String userId);
22
 }
25
 }

+ 3
- 0
src/main/java/com/yunzhi/nanyang/service/ITaMessageService.java View File

2
 
2
 
3
 import com.yunzhi.nanyang.entity.TaMessage;
3
 import com.yunzhi.nanyang.entity.TaMessage;
4
 import com.baomidou.mybatisplus.extension.service.IService;
4
 import com.baomidou.mybatisplus.extension.service.IService;
5
+import com.yunzhi.nanyang.event.WorkDispatchEvent;
5
 import com.yunzhi.nanyang.event.WorkExpiredEvent;
6
 import com.yunzhi.nanyang.event.WorkExpiredEvent;
6
 
7
 
7
 /**
8
 /**
15
 public interface ITaMessageService extends IBaseService<TaMessage> {
16
 public interface ITaMessageService extends IBaseService<TaMessage> {
16
 
17
 
17
     void sendMessage(WorkExpiredEvent evt);
18
     void sendMessage(WorkExpiredEvent evt);
19
+
20
+    void sendMessage(WorkDispatchEvent evt);
18
 }
21
 }

+ 20
- 0
src/main/java/com/yunzhi/nanyang/service/ITaMessageTemplateService.java View File

1
+package com.yunzhi.nanyang.service;
2
+
3
+import com.yunzhi.nanyang.entity.TaMessageTemplate;
4
+import com.baomidou.mybatisplus.extension.service.IService;
5
+
6
+import java.util.List;
7
+
8
+/**
9
+ * <p>
10
+ * 消息模板 服务类
11
+ * </p>
12
+ *
13
+ * @author yansen
14
+ * @since 2022-04-11
15
+ */
16
+public interface ITaMessageTemplateService extends IService<TaMessageTemplate> {
17
+    TaMessageTemplate getTemplateByType(String tplType, String bizType);
18
+
19
+    List<TaMessageTemplate> getByTplType(String tplType);
20
+}

+ 1
- 1
src/main/java/com/yunzhi/nanyang/service/impl/TaAccountServiceImpl.java View File

64
             amount += totalMoney;
64
             amount += totalMoney;
65
         }
65
         }
66
 
66
 
67
-        return taAccount.getAmounts() > amount;
67
+        return taAccount.getAmounts() >= amount;
68
     }
68
     }
69
 
69
 
70
     @Transactional(rollbackFor = Exception.class)
70
     @Transactional(rollbackFor = Exception.class)

+ 75
- 2
src/main/java/com/yunzhi/nanyang/service/impl/TaMessageServiceImpl.java View File

1
 package com.yunzhi.nanyang.service.impl;
1
 package com.yunzhi.nanyang.service.impl;
2
 
2
 
3
-import com.yunzhi.nanyang.entity.TaDispatch;
4
-import com.yunzhi.nanyang.entity.TaMessage;
3
+import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage;
4
+import com.yunzhi.nanyang.common.*;
5
+import com.yunzhi.nanyang.entity.*;
6
+import com.yunzhi.nanyang.event.WorkDispatchEvent;
5
 import com.yunzhi.nanyang.event.WorkExpiredEvent;
7
 import com.yunzhi.nanyang.event.WorkExpiredEvent;
6
 import com.yunzhi.nanyang.mapper.TaMessageMapper;
8
 import com.yunzhi.nanyang.mapper.TaMessageMapper;
9
+import com.yunzhi.nanyang.mapper.TaPersonMapper;
7
 import com.yunzhi.nanyang.service.ITaMessageService;
10
 import com.yunzhi.nanyang.service.ITaMessageService;
8
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
11
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
12
+import com.yunzhi.nanyang.service.ITaMessageTemplateService;
13
+import lombok.extern.slf4j.Slf4j;
14
+import org.springframework.beans.factory.annotation.Autowired;
9
 import org.springframework.scheduling.annotation.Async;
15
 import org.springframework.scheduling.annotation.Async;
10
 import org.springframework.stereotype.Service;
16
 import org.springframework.stereotype.Service;
11
 
17
 
18
+import java.util.List;
19
+
12
 /**
20
 /**
13
  * <p>
21
  * <p>
14
  * 消息表 服务实现类
22
  * 消息表 服务实现类
17
  * @author yansen
25
  * @author yansen
18
  * @since 2022-03-08
26
  * @since 2022-03-08
19
  */
27
  */
28
+@Slf4j
20
 @Service
29
 @Service
21
 public class TaMessageServiceImpl extends BaseServiceImpl<TaMessageMapper, TaMessage> implements ITaMessageService {
30
 public class TaMessageServiceImpl extends BaseServiceImpl<TaMessageMapper, TaMessage> implements ITaMessageService {
22
 
31
 
32
+    @Autowired
33
+    TaPersonMapper taPersonMapper;
34
+
35
+    @Autowired
36
+    ITaMessageTemplateService iTaMessageTemplateService;
37
+
38
+    @Autowired
39
+    WxUtils wxUtils;
40
+
23
     @Async
41
     @Async
24
     @Override
42
     @Override
25
     public void sendMessage(WorkExpiredEvent evt) {
43
     public void sendMessage(WorkExpiredEvent evt) {
26
         evt.getTaDispatch();
44
         evt.getTaDispatch();
27
     }
45
     }
46
+
47
+    @Async
48
+    @Override
49
+    public void sendMessage(WorkDispatchEvent evt) {
50
+
51
+        try {
52
+            TaWorkJob taWorkJob = evt.getTaWorkJob();
53
+            String jobId = taWorkJob.getJobId();
54
+            TaOrder taOrder = evt.getTaOrder();
55
+            String orderNo = taOrder.getOrderNo();
56
+            TaPerson taPerson = taPersonMapper.getByUserId(taWorkJob.getWorkerId());
57
+            if (null == taPerson) {
58
+                log.error("发送消息失败, 未找到对应的人员信息 " + taWorkJob.getWorkerId());
59
+                return;
60
+            }
61
+
62
+            // 先发送小程序
63
+            try {
64
+                TaMessageTemplate tpl = iTaMessageTemplateService.getTemplateByType(Constants.MESSAGE_MINIAPP, Constants.MESSAGE_ORDER_NOTIFY);
65
+                WxMaSubscribeMessage message = MessageUtil.getWxMaSubscribeMessage(tpl);
66
+                if (null != message) {
67
+                    message.setToUser(taPerson.getOpenid());
68
+                    String actionStr = tpl.getAppTplAction();
69
+                    message.setPage(MessageUtil.NaviPage.fromJSON(actionStr).toURL(jobId));
70
+                    List<WxMaSubscribeMessage.MsgData> data = MessageUtil.getWxMessageData(tpl.getAppTplContent(),
71
+                            orderNo,
72
+                            taWorkJob.getMachineryName(),
73
+                            "已派单",
74
+                            DateUtils.toString(taWorkJob.getCreateDate(), "yyyy-MM-dd HH:mm"));
75
+                    message.setData(data);
76
+
77
+                    wxUtils.getWorkerService().getMsgService().sendSubscribeMsg(message);
78
+                }
79
+            } catch (Exception e) {
80
+                e.printStackTrace();
81
+            }
82
+
83
+            // 再发送短信
84
+            try {
85
+                TaMessageTemplate tpl = iTaMessageTemplateService.getTemplateByType(Constants.MESSAGE_SMS, Constants.MESSAGE_ORDER_NOTIFY);
86
+                SMSUtils.Message message = MessageUtil.getSmsMessage(tpl);
87
+                if (!StringUtils.isEmpty(taPerson.getPhone()) && null != message) {
88
+                    message.setTel(taPerson.getPhone());
89
+                    message.setContent(String.format(tpl.getAppTplContent(), taWorkJob.getWorkerName(), orderNo));
90
+                } else {
91
+                    log.error("发送短信失败, 可能无用户手机 " + taPerson.getPersonId());
92
+                }
93
+            } catch (Exception e) {
94
+                e.printStackTrace();
95
+            }
96
+
97
+        } catch (Exception e) {
98
+            e.printStackTrace();
99
+        }
100
+    }
28
 }
101
 }

+ 44
- 0
src/main/java/com/yunzhi/nanyang/service/impl/TaMessageTemplateServiceImpl.java View File

1
+package com.yunzhi.nanyang.service.impl;
2
+
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.yunzhi.nanyang.common.Constants;
5
+import com.yunzhi.nanyang.entity.TaMessageTemplate;
6
+import com.yunzhi.nanyang.mapper.TaMessageTemplateMapper;
7
+import com.yunzhi.nanyang.service.ITaMessageTemplateService;
8
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
9
+import org.springframework.stereotype.Service;
10
+
11
+import java.util.List;
12
+
13
+/**
14
+ * <p>
15
+ * 消息模板 服务实现类
16
+ * </p>
17
+ *
18
+ * @author yansen
19
+ * @since 2022-04-11
20
+ */
21
+@Service
22
+public class TaMessageTemplateServiceImpl extends ServiceImpl<TaMessageTemplateMapper, TaMessageTemplate> implements ITaMessageTemplateService {
23
+
24
+    @Override
25
+    public TaMessageTemplate getTemplateByType(String tplType, String bizType) {
26
+        QueryWrapper<TaMessageTemplate> queryWrapper = new QueryWrapper<>();
27
+        queryWrapper.eq("tpl_type", tplType);
28
+        queryWrapper.eq("biz_type", bizType);
29
+        queryWrapper.eq("status", Constants.STATUS_NORMAL);
30
+
31
+        return getOne(queryWrapper);
32
+    }
33
+
34
+    @Override
35
+    public List<TaMessageTemplate> getByTplType(String tplType) {
36
+        QueryWrapper<TaMessageTemplate> queryWrapper = new QueryWrapper<>();
37
+        queryWrapper.eq("tpl_type", tplType);
38
+        queryWrapper.eq("status", Constants.STATUS_NORMAL);
39
+
40
+        return list(queryWrapper);
41
+    }
42
+
43
+
44
+}

+ 3
- 0
src/main/java/com/yunzhi/nanyang/vo/AccountRecord.java View File

31
 
31
 
32
     @ApiModelProperty(value = "订单号")
32
     @ApiModelProperty(value = "订单号")
33
     private String orderNo;
33
     private String orderNo;
34
+
35
+    @ApiModelProperty(value = "支付方式")
36
+    private String payType;
34
 }
37
 }

+ 8
- 6
src/main/resources/mapper/TaAccountLogMapper.xml View File

5
     <select id="getPageBy" resultType="com.yunzhi.nanyang.vo.AccountRecord">
5
     <select id="getPageBy" resultType="com.yunzhi.nanyang.vo.AccountRecord">
6
         SELECT
6
         SELECT
7
             t.*,
7
             t.*,
8
-            n.person_id,
9
-            n.nick_name as person_name,
8
+            IFNULL(n.person_id, w.user_id) as person_id,
9
+            IFNULL(n.nick_name, w.user_name) as person_name,
10
             n.phone,
10
             n.phone,
11
             m.order_id as real_order_id,
11
             m.order_id as real_order_id,
12
             m.order_no,
12
             m.order_no,
13
             s.description,
13
             s.description,
14
-            s.pay_date
14
+            s.pay_date,
15
+            s.pay_type
15
         FROM
16
         FROM
16
             ta_account_log t
17
             ta_account_log t
17
-                INNER JOIN ta_pay s ON t.pay_id = s.pay_id
18
-                INNER JOIN ta_order m ON s.order_id = m.order_id
19
-                INNER JOIN ta_person n ON m.person_id = n.person_id
18
+                LEFT JOIN ta_pay s ON t.pay_id = s.pay_id
19
+                LEFT JOIN ta_order m ON t.order_id = m.order_id
20
+                LEFT JOIN ta_person n ON m.person_id = n.person_id
21
+                LEFT JOIN ta_withdrawal w ON t.order_id = w.withdrawal_id
20
         ORDER BY
22
         ORDER BY
21
             t.create_date DESC
23
             t.create_date DESC
22
     </select>
24
     </select>

+ 5
- 0
src/main/resources/mapper/TaMessageTemplateMapper.xml View File

1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+<mapper namespace="com.yunzhi.nanyang.mapper.TaMessageTemplateMapper">
4
+
5
+</mapper>