소스 검색

Merge branch 'master' of http://223.75.76.159:9090/zq/picc

jz.kai 5 년 전
부모
커밋
5d18b705f0
38개의 변경된 파일977개의 추가작업 그리고 1161개의 파일을 삭제
  1. 66 0
      picc-admin-server/src/main/java/com/jpsoft/picc/modules/admin/controller/JwtsUserController.java
  2. 53 69
      picc-admin-server/src/main/java/com/jpsoft/picc/modules/business/controller/InsurancePolicyController.java
  3. 2 2
      picc-admin-server/src/main/resources/application-dev.yml
  4. 2 2
      picc-admin-server/src/main/resources/application-test.yml
  5. 20 0
      picc-common/src/main/java/com/jpsoft/picc/modules/base/dao/ReplyMessageDAO.java
  6. 7 1
      picc-common/src/main/java/com/jpsoft/picc/modules/base/entity/CompanyMember.java
  7. 38 0
      picc-common/src/main/java/com/jpsoft/picc/modules/base/entity/ReplyMessage.java
  8. 19 0
      picc-common/src/main/java/com/jpsoft/picc/modules/base/service/ReplyMessageService.java
  9. 1 1
      picc-common/src/main/java/com/jpsoft/picc/modules/base/service/TemplateMessageService.java
  10. 75 0
      picc-common/src/main/java/com/jpsoft/picc/modules/base/service/impl/ReplyMessageServiceImpl.java
  11. 17 8
      picc-common/src/main/java/com/jpsoft/picc/modules/base/service/impl/TemplateMessageServiceImpl.java
  12. 20 381
      picc-common/src/main/java/com/jpsoft/picc/modules/business/entity/InsuranceApplication.java
  13. 20 318
      picc-common/src/main/java/com/jpsoft/picc/modules/business/entity/InsurancePolicy.java
  14. 2 2
      picc-common/src/main/java/com/jpsoft/picc/modules/common/constant/PolicyStatus.java
  15. 1 1
      picc-common/src/main/java/com/jpsoft/picc/modules/common/utils/ItextPDFUtil.java
  16. 2 2
      picc-common/src/main/java/com/jpsoft/picc/modules/common/utils/SignUtil.java
  17. 38 21
      picc-common/src/main/java/com/jpsoft/picc/modules/common/utils/Watermark.java
  18. 162 154
      picc-common/src/main/resources/mapper/base/CompanyMember.xml
  19. 88 0
      picc-common/src/main/resources/mapper/base/ReplyMessage.xml
  20. 11 1
      picc-common/src/main/resources/mapper/business/InsuranceApplication.xml
  21. 11 1
      picc-common/src/main/resources/mapper/business/InsurancePolicy.xml
  22. 11 2
      picc-enterprise-server/src/main/java/com/jpsoft/picc/modules/auth/controller/InsuranceApplicationController.java
  23. 62 19
      picc-enterprise-server/src/main/java/com/jpsoft/picc/modules/auth/controller/InsurancePolicyController.java
  24. 1 1
      picc-enterprise-server/src/main/java/com/jpsoft/picc/modules/auth/controller/InsurancePolicyUserController.java
  25. 43 5
      picc-enterprise-server/src/main/java/com/jpsoft/picc/modules/pub/controller/PayController.java
  26. 2 2
      picc-enterprise-server/src/main/resources/application-test.yml
  27. 6 0
      weixin-middleware/pom.xml
  28. 2 1
      weixin-middleware/src/main/java/com/jpsoft/weixin/callback/EventCallback.java
  29. 26 9
      weixin-middleware/src/main/java/com/jpsoft/weixin/callback/PromotionCallback.java
  30. 1 6
      weixin-middleware/src/main/java/com/jpsoft/weixin/controller/ReplyMessageController.java
  31. 33 16
      weixin-middleware/src/main/java/com/jpsoft/weixin/controller/WeixinController.java
  32. 1 1
      weixin-middleware/src/main/java/com/jpsoft/weixin/dao/ReplyMessageDAO.java
  33. 14 70
      weixin-middleware/src/main/java/com/jpsoft/weixin/entity/ReplyMessage.java
  34. 1 1
      weixin-middleware/src/main/java/com/jpsoft/weixin/service/impl/ReplyMessageServiceImpl.java
  35. 45 0
      weixin-middleware/src/main/java/com/jpsoft/weixin/utils/VelocityHelper.java
  36. 1 1
      weixin-middleware/src/main/resources/application-dev.yml
  37. 1 1
      weixin-middleware/src/main/resources/application-production.yml
  38. 72 62
      weixin-middleware/src/main/resources/mapper/ReplyMessage.xml

+ 66 - 0
picc-admin-server/src/main/java/com/jpsoft/picc/modules/admin/controller/JwtsUserController.java

@@ -1,11 +1,15 @@
 package com.jpsoft.picc.modules.admin.controller;
 
 import com.jpsoft.picc.modules.base.entity.CompanyUser;
+import com.jpsoft.picc.modules.base.entity.ReplyMessage;
+import com.jpsoft.picc.modules.base.service.CompanyUserService;
+import com.jpsoft.picc.modules.base.service.ReplyMessageService;
 import com.jpsoft.picc.modules.common.config.WeixinConfig;
 import com.jpsoft.picc.modules.common.constant.WeixinEvent;
 import com.jpsoft.picc.modules.common.dto.MessageResult;
 import com.jpsoft.picc.modules.common.dto.MsgResult;
 import com.jpsoft.picc.modules.common.utils.DES3;
+import com.jpsoft.picc.modules.common.utils.VelocityHelper;
 import com.jpsoft.picc.modules.common.utils.WeixinUtil;
 import com.jpsoft.picc.modules.sys.entity.User;
 import com.jpsoft.picc.modules.sys.service.UserService;
@@ -26,9 +30,12 @@ import springfox.documentation.annotations.ApiIgnore;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpSession;
+import java.net.URLEncoder;
 import java.security.Key;
 import java.util.Base64;
 import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
 @Slf4j
@@ -50,6 +57,12 @@ public class JwtsUserController {
     @Autowired
     private RedisTemplate redisTemplate;
 
+    @Autowired
+    private ReplyMessageService replyMessageService;
+
+    @Autowired
+    private CompanyUserService companyUserService;
+
     @PostMapping("/login")
     @ApiOperation(value="登录获取token,在swagger ui中获取token时将写入session,调用其它接口时不用再设置header")
     @ApiImplicitParams({
@@ -250,6 +263,59 @@ public class JwtsUserController {
         return msgResult;
     }
 
+    /**
+     * 推广码扫码回调
+     * @param eventKey
+     * @param wechatId
+     * @param openId
+     * @return 返回值会在微信中显示
+     */
+    @ApiOperation(value = "推广码扫码回调")
+    @PostMapping(value="/pub/qrcode/promotion/scan")
+    @ResponseBody
+    public String scanQrcodePromotionCallback(String eventKey,String wechatId,String openId){
+        log.warn(openId + "推广码扫码回调!");
+        String message = "";
+
+        try {
+            CompanyUser companyUser = companyUserService.findByOpenId(openId);
+
+            if(companyUser==null) {
+                //未注册用户
+                String[] arr = eventKey.split(",");
+
+                String promoter = arr[1];
+
+                ReplyMessage replyMessage = replyMessageService.findByEvent(wechatId,
+                                            String.valueOf(WeixinEvent.PICC_ADMIN_SCAN_QRCODE_PROMOTION));
+
+                if(replyMessage!=null) {
+                    StringBuilder urlBuilder = new StringBuilder();
+
+                    urlBuilder.append("openId=" + openId);
+                    urlBuilder.append("&promoter=" + URLEncoder.encode(promoter, "UTF-8"));
+
+                    Map<String, Object> vars = new HashMap<>();
+                    vars.put("params", urlBuilder.toString());
+
+                    message = VelocityHelper.format(replyMessage.getMessage(), vars);
+                }
+                else{
+                    message = "当前公众号没有绑定事件:" + WeixinEvent.PICC_ADMIN_SCAN_QRCODE_PROMOTION;
+                }
+            }
+            else{
+                message = "当前用户已注册!";
+            }
+        }
+        catch (Exception ex){
+            log.error(ex.getMessage(),ex);
+            message = ex.getMessage();
+        }
+
+        return message;
+    }
+
     /**
      * 接收扫码登录回调
      * @param eventKey

+ 53 - 69
picc-admin-server/src/main/java/com/jpsoft/picc/modules/business/controller/InsurancePolicyController.java

@@ -33,6 +33,7 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
 import java.math.BigDecimal;
+import java.text.DecimalFormat;
 import java.text.SimpleDateFormat;
 import java.util.*;
 
@@ -388,17 +389,20 @@ public class InsurancePolicyController {
         MessageResult<Integer> msgResult = new MessageResult<>();
 
         try {
-            PolicyStatus policyStatus;
+            InsurancePolicy insurancePolicy = insurancePolicyService.get(policyId);
+            PolicyStatus srcPolicyStatus = PolicyStatus.valueOf(Integer.valueOf(insurancePolicy.getStatus()));
+
+            PolicyStatus destPolicyStatus;
 
             if (processStatus.equals("正常")) {
                 //30
-                policyStatus = PolicyStatus.PendingRetrial;
+                destPolicyStatus = PolicyStatus.PendingRetrial;
             } else {
                 //15
-                policyStatus = PolicyStatus.Back;
+                destPolicyStatus = PolicyStatus.Back;
             }
 
-            int affectCount = approval(applicationId, policyId, processStatus, opinion, policyStatus.getValue() + "", subject);
+            int affectCount = approval(applicationId, policyId, processStatus, opinion, destPolicyStatus.getValue() + "", subject);
 
             if (processStatus.equals("正常")) {
                 //修改花名册人员状态为初审
@@ -406,7 +410,7 @@ public class InsurancePolicyController {
             }
 
             //发送微信通知
-            templateMessageService.sendTemplateMessage(policyId, policyStatus);
+            templateMessageService.sendTemplateMessage(policyId, srcPolicyStatus, destPolicyStatus);
 
             msgResult.setResult(true);
             msgResult.setData(affectCount);
@@ -419,8 +423,8 @@ public class InsurancePolicyController {
         return msgResult;
     }
 
-    private void sendWeixinMessage(String policyId, PolicyStatus policyStatus) {
-        templateMessageService.sendTemplateMessage(policyId,policyStatus);
+    private void sendWeixinMessage(String policyId,PolicyStatus srcPolicyStatus, PolicyStatus destPolicyStatus) {
+        templateMessageService.sendTemplateMessage(policyId, srcPolicyStatus, destPolicyStatus);
     }
 
     @ApiOperation(value="PICC复审")
@@ -439,30 +443,31 @@ public class InsurancePolicyController {
         MessageResult<Integer> msgResult = new MessageResult<>();
 
         try {
-            PolicyStatus policyStatus;
+            InsurancePolicy insurancePolicy = insurancePolicyService.get(policyId);
+            PolicyStatus srcPolicyStatus = PolicyStatus.valueOf(Integer.valueOf(insurancePolicy.getStatus()));
+
+            PolicyStatus destPolicyStatus;
 
             if (processStatus.equals("正常")) {
                 //40
-                InsurancePolicy insurancePolicy = insurancePolicyService.get(policyId);
-
                 if (insurancePolicy != null) {
                     int no = insurancePolicy.getNo();
                     if (no > 1) {
                         //待制单
-                        policyStatus = PolicyStatus.PendingMakePolicy;
+                        destPolicyStatus = PolicyStatus.PendingMakePolicy;
                     } else {
                         //待缴费
-                        policyStatus = PolicyStatus.PendingPay;
+                        destPolicyStatus = PolicyStatus.PendingPay;
                     }
                 } else {
                     throw new Exception("下月投保单不存在");
                 }
             } else {
                 //20
-                policyStatus = PolicyStatus.PendingTrial;
+                destPolicyStatus = PolicyStatus.PendingTrial;
             }
 
-            int affectCount = approval(applicationId, policyId, processStatus, opinion, policyStatus.getValue() + "", subject);
+            int affectCount = approval(applicationId, policyId, processStatus, opinion,destPolicyStatus.getValue() + "", subject);
 
             if (processStatus.equals("正常")) {
                 //修改花名册人员状态为初审
@@ -470,7 +475,7 @@ public class InsurancePolicyController {
             }
 
             //发送微信通知
-            templateMessageService.sendTemplateMessage(policyId, policyStatus);
+            templateMessageService.sendTemplateMessage(policyId,srcPolicyStatus, destPolicyStatus);
 
             msgResult.setResult(true);
             msgResult.setData(affectCount);
@@ -502,29 +507,29 @@ public class InsurancePolicyController {
         MessageResult<Integer> msgResult = new MessageResult<>();
 
         try {
-            PolicyStatus policyStatus;
+            InsurancePolicy insurancePolicy = insurancePolicyService.get(policyId);
+            PolicyStatus srcPolicyStatus = PolicyStatus.valueOf(Integer.valueOf(insurancePolicy.getStatus()));
+
+            PolicyStatus destPolicyStatus;
 
             if (processStatus.equals("正常")) {
                 //70
-                policyStatus = PolicyStatus.SendOutPolicy;
+                destPolicyStatus = PolicyStatus.SendOutPolicy;
             } else {
                 //50
-                policyStatus = PolicyStatus.PendingMakePolicy;
+                destPolicyStatus = PolicyStatus.PendingMakePolicy;
             }
 
             if (StringUtils.isNotEmpty(insurancePolicyFile)) {
-                InsurancePolicy insurancePolicy = insurancePolicyService.get(policyId);
-
                 insurancePolicy.setInsurancePolicyFile(insurancePolicyFile);
-
                 insurancePolicyService.update(insurancePolicy);
             }
 
             //todo 审批并生成下月投保单
-            approveAndGenPolicyInTrans(applicationId, policyId,processStatus,opinion,policyStatus,subject);
+            approveAndGenPolicyInTrans(applicationId, policyId,processStatus,opinion,destPolicyStatus,subject);
 
             //发送微信通知
-            templateMessageService.sendTemplateMessage(policyId, policyStatus);
+            templateMessageService.sendTemplateMessage(policyId,srcPolicyStatus, destPolicyStatus);
 
             msgResult.setResult(true);
         }
@@ -542,44 +547,6 @@ public class InsurancePolicyController {
         return msgResult;
     }
 
-
-
-    @ApiOperation(value="企业缴费")
-    @RequestMapping(value = "pay",method = RequestMethod.POST)
-    @ApiImplicitParams({
-            @ApiImplicitParam(name="applicationId",value = "投保单ID",required = true,paramType = "query"),
-            @ApiImplicitParam(name="policyId",value = "每月投保单ID",required = true,paramType = "query"),
-            @ApiImplicitParam(name="processStatus",value = "流程审核状态(正常/回退)",required = true,paramType = "query"),
-            @ApiImplicitParam(name="opinion",value = "意见",required = true,paramType = "query")
-    })
-    public MessageResult<Integer> pay(String applicationId,String policyId,String processStatus,String opinion, @RequestAttribute String subject){
-
-        //当前用户ID
-        System.out.println(subject);
-
-        MessageResult<Integer> msgResult = new MessageResult<>();
-
-        String status ="";
-
-        if(processStatus.equals("正常")){
-            //50
-            status = String.valueOf(PolicyStatus.PendingMakePolicy.getValue());
-        }
-        else{
-            //30
-            status = String.valueOf(PolicyStatus.PendingRetrial.getValue());
-        }
-
-        int affectCount = approval(applicationId,policyId,processStatus,opinion,status ,subject);
-
-        msgResult.setResult(true);
-        msgResult.setData(affectCount);
-
-        return msgResult;
-    }
-
-
-
     @ApiOperation(value="人才超市与PICC转账")
     @RequestMapping(value = "transfer",method = RequestMethod.POST)
     @ApiImplicitParams({
@@ -603,14 +570,17 @@ public class InsurancePolicyController {
 
         try {
 //        String status ="";
-            PolicyStatus policyStatus;
+            InsurancePolicy insurancePolicy = insurancePolicyService.get(policyId);
+            PolicyStatus srcPolicyStatus = PolicyStatus.valueOf(Integer.valueOf(insurancePolicy.getStatus()));
+
+            PolicyStatus destPolicyStatus;
 
             if (processStatus.equals("正常")) {
                 //60
-                policyStatus = PolicyStatus.PendingOutPolicy;
+                destPolicyStatus = PolicyStatus.PendingOutPolicy;
             } else {
                 //40
-                policyStatus = PolicyStatus.PendingPay;
+                destPolicyStatus = PolicyStatus.PendingPay;
             }
 
             InsurancePolicy item = insurancePolicyService.get(policyId);
@@ -626,11 +596,11 @@ public class InsurancePolicyController {
             int affectCount1 = 0;
 
             if (affectCount > 0) {
-                affectCount1 = approval(applicationId, policyId, processStatus, opinion, policyStatus.getValue() + "", subject);
+                affectCount1 = approval(applicationId, policyId, processStatus, opinion, destPolicyStatus.getValue() + "", subject);
             }
 
             //发送微信通知
-            templateMessageService.sendTemplateMessage(policyId, policyStatus);
+            templateMessageService.sendTemplateMessage(policyId, srcPolicyStatus, destPolicyStatus);
 
             msgResult.setResult(true);
             msgResult.setData(affectCount1);
@@ -705,21 +675,35 @@ public class InsurancePolicyController {
         PojoUtils.map(srcPolicy,destPolicy);
 
         DateTime startTime = new DateTime(srcPolicy.getEndTime());
+        DateTime createTime = new DateTime(insuranceApplication.getCreateTime());
+
+        destPolicy.setId(UUID.randomUUID().toString());
+        destPolicy.setNo(srcPolicy.getNo()+1);
+
+        DecimalFormat df = new DecimalFormat("00");
+        destPolicy.setPolicyNo(createTime.toString("yyyyMMddHHmmssSSS") + "-" + df.format(destPolicy.getNo()));
 
         destPolicy.setStartTime(startTime.toDate());
         destPolicy.setEndTime(startTime.plusMonths(1).toDate());
         destPolicy.setEffectiveDate(startTime.toString("yyyyMM"));
+        destPolicy.setStatus(PolicyStatus.Draft.getValue() + "");
+        destPolicy.setCreateTime(new Date());
+        destPolicy.setCreateBy(subject);
+        destPolicy.setUpdateBy(null);
+        destPolicy.setUpdateTime(null);
+        destPolicy.setFinishTime(null);
 
         //todo 如果有则判断关联当前投保单的下月投保记录是否存在
         boolean exist = insurancePolicyService.existByApplicationIdAndEffectiveDate(applicationId, destPolicy.getEffectiveDate());
 
         if (!exist) {
-            //todo 关联投保单及下月投保单
+            insurancePolicyService.insert(destPolicy);
+
+            //todo 关联投保申请单及下月月投保单
             ApplicationPolicy applicationPolicy = new ApplicationPolicy();
+
             applicationPolicy.setId(UUID.randomUUID().toString());
             applicationPolicy.setApplicationId(applicationId);
-
-            //下月投保单已存在(创建时间)<当前投保单创建时间,所以排序要按照start_time
             applicationPolicy.setPolicyId(destPolicy.getId());
 
             applicationPolicyService.insert(applicationPolicy);

+ 2 - 2
picc-admin-server/src/main/resources/application-dev.yml

@@ -19,7 +19,7 @@ pdf:
 weixin:
   appId: wxc0ddd6a415c535d9
   appSecret: 042fe6c9c970c1d9fe585dccfca89221
-  tokenUrl: "http://www.jzrccs.com/weixin-middleware/token"
-  createQrCodeUrl: "http://www.jzrccs.com/weixin-middleware/qrcode/create"
+  tokenUrl: "http://localhost:8086/weixin-middleware/token"
+  createQrCodeUrl: "http://localhost:8086/weixin-middleware/qrcode/create"
   sendTmplMsgUrl: "https://api.weixin.qq.com/cgi-bin/message/template/send"
   sendTmplId1: "oc6Kh7_ZkANmsUnl2keg-X2nUKRBkAwjnGI3z1gTodo"

+ 2 - 2
picc-admin-server/src/main/resources/application-test.yml

@@ -24,7 +24,7 @@ pdf:
 weixin:
   appId: wxf6af207d9143d1de
   appSecret: c86c042923e72c61c76a3a8658349312
-  tokenUrl: "http://www.jzrccs.com/weixin-middleware/token"
-  createQrCodeUrl: "http://www.jzrccs.com/weixin-middleware/qrcode/create"
+  tokenUrl: "http://picc.jzrccs.com/weixin-middleware/token"
+  createQrCodeUrl: "http://picc.jzrccs.com/weixin-middleware/qrcode/create"
   sendTmplMsgUrl: "https://api.weixin.qq.com/cgi-bin/message/template/send"
   sendTmplId1: "oc6Kh7_ZkANmsUnl2keg-X2nUKRBkAwjnGI3z1gTodo"

+ 20 - 0
picc-common/src/main/java/com/jpsoft/picc/modules/base/dao/ReplyMessageDAO.java

@@ -0,0 +1,20 @@
+package com.jpsoft.picc.modules.base.dao;
+
+import com.jpsoft.picc.modules.base.entity.ReplyMessage;
+import com.jpsoft.picc.modules.common.dto.Sort;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+import java.util.Map;
+
+@Repository
+public interface ReplyMessageDAO {
+	int insert(ReplyMessage entity);
+	int update(ReplyMessage entity);
+	int exist(String id);
+	ReplyMessage get(String id);
+	int delete(String id);
+	List<ReplyMessage> list();
+	List<ReplyMessage> search(Map<String, Object> searchParams, List<Sort> sortList);
+	ReplyMessage findByEvent(String wechatId, String event);
+}

+ 7 - 1
picc-common/src/main/java/com/jpsoft/picc/modules/base/entity/CompanyMember.java

@@ -23,8 +23,10 @@ public class CompanyMember {
 	private String companyId;
     @ApiModelProperty(value = "姓名")
 	private String name;
-    @ApiModelProperty(value = "证件类型")
+    @ApiModelProperty(value = "证件类型(值)")
 	private String cardType;
+	@ApiModelProperty(value = "证件类型(名称)")
+	private String cardTypeN;
     @ApiModelProperty(value = "证件编号")
 	private String cardNo;
     @ApiModelProperty(value = "性别")
@@ -43,10 +45,14 @@ public class CompanyMember {
 	private String status;
     @ApiModelProperty(value = "创建人")
 	private String createBy;
+	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
+	@JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
     @ApiModelProperty(value = "创建时间")
 	private Date createTime;
     @ApiModelProperty(value = "更新人")
 	private String updateBy;
+	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
+	@JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
     @ApiModelProperty(value = "更新时间")
 	private Date updateTime;
     @ApiModelProperty(value = "是否删除")

+ 38 - 0
picc-common/src/main/java/com/jpsoft/picc/modules/base/entity/ReplyMessage.java

@@ -0,0 +1,38 @@
+package com.jpsoft.picc.modules.base.entity;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+/**
+  描述:wechat_reply_message的实体类
+ */
+@Data
+@ApiModel(value = "自动回复消息设置")
+public class ReplyMessage {
+    @ApiModelProperty(value = "编号")
+	private String id;
+	@ApiModelProperty(value = "微信公众号")
+	private String wechatId;
+    @ApiModelProperty(value = "事件")
+	private String event;
+    @ApiModelProperty(value = "回复消息")
+	private String message;
+
+	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
+	@JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
+    @ApiModelProperty(value = "创建时间")
+	private Date createTime;
+
+	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
+	@JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
+    @ApiModelProperty(value = "更新时间")
+	private Date updateTime;
+
+	@ApiModelProperty(value = "回调地址")
+	private String callbackUrl;
+}

+ 19 - 0
picc-common/src/main/java/com/jpsoft/picc/modules/base/service/ReplyMessageService.java

@@ -0,0 +1,19 @@
+package com.jpsoft.picc.modules.base.service;
+
+import com.github.pagehelper.Page;
+import com.jpsoft.picc.modules.base.entity.ReplyMessage;
+import com.jpsoft.picc.modules.common.dto.Sort;
+
+import java.util.List;
+import java.util.Map;
+
+public interface ReplyMessageService {
+	ReplyMessage get(String id);
+	boolean exist(String id);
+	int insert(ReplyMessage model);
+	int update(ReplyMessage model);
+	int delete(String id);
+	List<ReplyMessage> list();
+	Page<ReplyMessage> pageSearch(Map<String, Object> searchParams, int pageNum, int pageSize, List<Sort> sortList);
+	ReplyMessage findByEvent(String fromUserName, String event);
+}

+ 1 - 1
picc-common/src/main/java/com/jpsoft/picc/modules/base/service/TemplateMessageService.java

@@ -16,5 +16,5 @@ public interface TemplateMessageService {
 	List<TemplateMessage> list();
 	Page<TemplateMessage> pageSearch(Map<String, Object> searchParams,int pageNum,int pageSize,List<Sort> sortList);
 
-	boolean sendTemplateMessage(String policyId, PolicyStatus policyStatus);
+	boolean sendTemplateMessage(String policyId, PolicyStatus srcPolicyStatus,PolicyStatus destPolicyStatus);
 }

+ 75 - 0
picc-common/src/main/java/com/jpsoft/picc/modules/base/service/impl/ReplyMessageServiceImpl.java

@@ -0,0 +1,75 @@
+package com.jpsoft.picc.modules.base.service.impl;
+
+import com.github.pagehelper.Page;
+import com.github.pagehelper.PageHelper;
+import com.jpsoft.picc.modules.base.dao.ReplyMessageDAO;
+import com.jpsoft.picc.modules.base.entity.ReplyMessage;
+import com.jpsoft.picc.modules.base.service.ReplyMessageService;
+import com.jpsoft.picc.modules.common.dto.Sort;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.util.List;
+import java.util.Map;
+
+@Transactional
+@Component(value="replyMessageService")
+public class ReplyMessageServiceImpl implements ReplyMessageService {
+	@Resource(name="replyMessageDAO")
+	private ReplyMessageDAO replyMessageDAO;
+
+	@Override
+	public ReplyMessage get(String id) {
+		// TODO Auto-generated method stub
+		return replyMessageDAO.get(id);
+	}
+
+	@Override
+	public int insert(ReplyMessage model) {
+		// TODO Auto-generated method stub
+		//model.set${PkFieldName}(UUID.randomUUID().toString());
+		
+		return replyMessageDAO.insert(model);
+	}
+
+	@Override
+	public int update(ReplyMessage model) {
+		// TODO Auto-generated method stub
+		return replyMessageDAO.update(model);		
+	}
+
+	@Override
+	public int delete(String id) {
+		// TODO Auto-generated method stub
+		return replyMessageDAO.delete(id);
+	}
+
+	@Override
+	public boolean exist(String id) {
+		// TODO Auto-generated method stub
+		int count = replyMessageDAO.exist(id);
+		
+		return count > 0 ? true : false;
+	}
+	
+	@Override
+	public List<ReplyMessage> list() {
+		// TODO Auto-generated method stub
+		return replyMessageDAO.list();
+	}
+
+	@Override
+	public Page<ReplyMessage> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize,List<Sort> sortList) {
+        Page<ReplyMessage> page = PageHelper.startPage(pageNumber,pageSize).doSelectPage(()->{
+            replyMessageDAO.search(searchParams,sortList);
+        });
+        
+        return page;
+	}
+
+	@Override
+	public ReplyMessage findByEvent(String id, String event) {
+		return replyMessageDAO.findByEvent(id,event);
+	}
+}

+ 17 - 8
picc-common/src/main/java/com/jpsoft/picc/modules/base/service/impl/TemplateMessageServiceImpl.java

@@ -114,19 +114,21 @@ public class TemplateMessageServiceImpl implements TemplateMessageService {
 	}
 
 	@Override
-	public boolean sendTemplateMessage(String policyId, PolicyStatus policyStatus) {
+	public boolean sendTemplateMessage(String policyId,PolicyStatus srcPolicyStatus, PolicyStatus destPolicyStatus) {
 		boolean result = false;
 
 		try {
+			log.warn(srcPolicyStatus.getText() + "->" + destPolicyStatus.getText());
+
 			InsurancePolicy insurancePolicy = insurancePolicyDAO.get(policyId);
 			InsuranceApplication insuranceApplication = insuranceApplicationDAO.get(insurancePolicy.getLatestApplicationId());
 			Company company = companyDAO.get(insurancePolicy.getCompanyId());
 			CompanyUser companyUser = companyUserDAO.findByCompanyId(company.getId());
 
-			TemplateMessage templateMessage = templateMessageDAO.get(policyStatus.getValue() + "");
+			TemplateMessage templateMessage = templateMessageDAO.get(destPolicyStatus.getValue() + "");
 
 			if (templateMessage==null){
-				throw new Exception(policyStatus.getText() + "对应模板消息不存在!");
+				throw new Exception(destPolicyStatus.getText() + "对应模板消息不存在!");
 			}
 
 			List<Map> targetList = new ArrayList<>();
@@ -154,7 +156,7 @@ public class TemplateMessageServiceImpl implements TemplateMessageService {
 				String userId = (String) map.get("userId");
 				String openId = (String) map.get("openId");
 
-				sendMessage(userId, openId, templateMessage, insuranceApplication, insurancePolicy, companyUser);
+				sendMessage(userId, openId, templateMessage, insuranceApplication, insurancePolicy, companyUser,srcPolicyStatus, destPolicyStatus);
 			}
 
 			result = true;
@@ -171,7 +173,8 @@ public class TemplateMessageServiceImpl implements TemplateMessageService {
 							 TemplateMessage templateMessage,
 							 InsuranceApplication insuranceApplication,
 							 InsurancePolicy insurancePolicy,
-							 CompanyUser companyUser){
+							 CompanyUser companyUser,
+							 PolicyStatus srcPolicyStatus,PolicyStatus destPolicyStatus){
 		String content = templateMessage.getContent();
 
 		Map<String,Object> contentVars = new HashMap<>();
@@ -201,12 +204,18 @@ public class TemplateMessageServiceImpl implements TemplateMessageService {
 		//写站内消息
 		Message message = new Message();
 		message.setId(UUID.randomUUID().toString());
+		message.setTitle(templateMessage.getTitle());
+
+		if(destPolicyStatus == PolicyStatus.Back){
+			//退回时显示退回步骤
+			message.setTitle(templateMessage.getTitle() + "-" + srcPolicyStatus.getText());
+		}
+
+		message.setContent(content);
+		message.setRecipientId(userId);
 		message.setStatus(false);
 		message.setDelFlag(false);
 		message.setCreateTime(new Date());
-		message.setContent(content);
-		message.setTitle(templateMessage.getTitle());
-		message.setRecipientId(userId);
 
 		messageDAO.insert(message);
 	}

+ 20 - 381
picc-common/src/main/java/com/jpsoft/picc/modules/business/entity/InsuranceApplication.java

@@ -1,11 +1,10 @@
 package com.jpsoft.picc.modules.business.entity;
 
-import java.io.Serializable;
 import java.util.Date;
-import java.text.SimpleDateFormat;
 import java.math.BigDecimal;
 
 import com.jpsoft.picc.modules.common.constant.PolicyStatus;
+import lombok.Data;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.format.annotation.DateTimeFormat;
 import com.fasterxml.jackson.annotation.JsonFormat;
@@ -15,6 +14,7 @@ import io.swagger.annotations.ApiModel;
 /**
   描述:business_insurance_application的实体类
  */
+@Data
 @ApiModel(value = "business_insurance_application的实体类")
 public class InsuranceApplication {
     @ApiModelProperty(value = "ID")
@@ -53,10 +53,17 @@ public class InsuranceApplication {
 	private String companyAddress;
     @ApiModelProperty(value = "近三年损失情况")
 	private String lossInRecentYears;
+
+	@DateTimeFormat(pattern="yyyy-MM-dd")
+	@JsonFormat(pattern = "yyyy-MM-dd",timezone ="GMT+8")
     @ApiModelProperty(value = "保障开始时间")
 	private Date startTime;
+
+	@DateTimeFormat(pattern="yyyy-MM-dd")
+	@JsonFormat(pattern = "yyyy-MM-dd",timezone ="GMT+8")
     @ApiModelProperty(value = "保障结束时间")
 	private Date endTime;
+
     @ApiModelProperty(value = "保险费合计(总金额)")
 	private BigDecimal insuranceFee;
     @ApiModelProperty(value = "状态:草稿10/待初审20/待复审30/待缴费40/待制单50/待出单60/已出单70/已过期100")
@@ -67,10 +74,16 @@ public class InsuranceApplication {
 	private String processStatus;
     @ApiModelProperty(value = "创建人")
 	private String createBy;
+
+	@DateTimeFormat(pattern="yyyy-MM-dd")
+	@JsonFormat(pattern = "yyyy-MM-dd",timezone ="GMT+8")
     @ApiModelProperty(value = "创建时间")
 	private Date createTime;
     @ApiModelProperty(value = "更新人")
 	private String updateBy;
+
+	@DateTimeFormat(pattern="yyyy-MM-dd")
+	@JsonFormat(pattern = "yyyy-MM-dd",timezone ="GMT+8")
     @ApiModelProperty(value = "更新时间")
 	private Date updateTime;
     @ApiModelProperty(value = "是否删除")
@@ -81,359 +94,14 @@ public class InsuranceApplication {
 	@ApiModelProperty(value = "最新的每月投保单,不写入数据库,作查询使用")
 	private InsurancePolicy insurancePolicy;
 
-	/**
-	 *获取ID
-	 */
-    	public String getId(){
-		return id;
-	}
-	
-	/**
-	 *设置ID
-	 */
-	public void setId(String id){
-		this.id = id;
-	}
-	/**
-	 *获取企业ID
-	 */
-    	public String getCompanyId(){
-		return companyId;
-	}
-	
-	/**
-	 *设置企业ID
-	 */
-	public void setCompanyId(String companyId){
-		this.companyId = companyId;
-	}
-	/**
-	 *获取保险种类
-	 */
-    	public String getDefinitionId(){
-		return definitionId;
-	}
-	
-	/**
-	 *设置保险种类
-	 */
-	public void setDefinitionId(String definitionId){
-		this.definitionId = definitionId;
-	}
-	/**
-	 *获取投保人姓名
-	 */
-    	public String getInsuredName(){
-		return insuredName;
-	}
-	
-	/**
-	 *设置投保人姓名
-	 */
-	public void setInsuredName(String insuredName){
-		this.insuredName = insuredName;
-	}
-	/**
-	 *获取联系电话
-	 */
-    	public String getInsuredTel(){
-		return insuredTel;
-	}
-	
-	/**
-	 *设置联系电话
-	 */
-	public void setInsuredTel(String insuredTel){
-		this.insuredTel = insuredTel;
-	}
-	/**
-	 *获取企业名称
-	 */
-    	public String getCompanyName(){
-		return companyName;
-	}
-	
-	/**
-	 *设置企业名称
-	 */
-	public void setCompanyName(String companyName){
-		this.companyName = companyName;
-	}
-	/**
-	 *获取组织机构代码证
-	 */
-    	public String getUsccCode(){
-		return usccCode;
-	}
-	
-	/**
-	 *设置组织机构代码证
-	 */
-	public void setUsccCode(String usccCode){
-		this.usccCode = usccCode;
-	}
-	/**
-	 *获取营业范围
-	 */
-    	public String getBusinessScope(){
-		return businessScope;
-	}
-	
-	/**
-	 *设置营业范围
-	 */
-	public void setBusinessScope(String businessScope){
-		this.businessScope = businessScope;
-	}
-	/**
-	 *获取行业类型
-	 */
-    	public String getIndustryType(){
-		return industryType;
-	}
-	
-	/**
-	 *设置行业类型
-	 */
-	public void setIndustryType(String industryType){
-		this.industryType = industryType;
-	}
-	/**
-	 *获取联系电话
-	 */
-    	public String getTel(){
-		return tel;
-	}
-	
-	/**
-	 *设置联系电话
-	 */
-	public void setTel(String tel){
-		this.tel = tel;
-	}
-	/**
-	 *获取邮编
-	 */
-    	public String getPostal(){
-		return postal;
-	}
-	
-	/**
-	 *设置邮编
-	 */
-	public void setPostal(String postal){
-		this.postal = postal;
-	}
-	/**
-	 *获取雇员人数
-	 */
-    	public Integer getEmployeesNumber(){
-		return employeesNumber;
-	}
-	
-	/**
-	 *设置雇员人数
-	 */
-	public void setEmployeesNumber(Integer employeesNumber){
-		this.employeesNumber = employeesNumber;
-	}
-	/**
-	 *获取已投保人数
-	 */
-    	public Integer getInsuredNumber(){
-		return insuredNumber;
-	}
-	
-	/**
-	 *设置已投保人数
-	 */
-	public void setInsuredNumber(Integer insuredNumber){
-		this.insuredNumber = insuredNumber;
-	}
-	/**
-	 *获取公司地址
-	 */
-    	public String getCompanyAddress(){
-		return companyAddress;
-	}
-	
-	/**
-	 *设置公司地址
-	 */
-	public void setCompanyAddress(String companyAddress){
-		this.companyAddress = companyAddress;
-	}
-	/**
-	 *获取近三年损失情况
-	 */
-    	public String getLossInRecentYears(){
-		return lossInRecentYears;
-	}
-	
-	/**
-	 *设置近三年损失情况
-	 */
-	public void setLossInRecentYears(String lossInRecentYears){
-		this.lossInRecentYears = lossInRecentYears;
-	}
-	/**
-	 *获取保障开始时间
-	 */
-	@DateTimeFormat(pattern="yyyy-MM-dd")
-	@JsonFormat(pattern = "yyyy-MM-dd",timezone ="GMT+8")
-		public Date getStartTime(){
-		return startTime;
-	}
-	
-	/**
-	 *设置保障开始时间
-	 */
-	public void setStartTime(Date startTime){
-		this.startTime = startTime;
-	}
-	/**
-	 *获取保障结束时间
-	 */
+	@ApiModelProperty(value = "投保单号")
+	private String policyNo;
+
 	@DateTimeFormat(pattern="yyyy-MM-dd")
 	@JsonFormat(pattern = "yyyy-MM-dd",timezone ="GMT+8")
-		public Date getEndTime(){
-		return endTime;
-	}
-	
-	/**
-	 *设置保障结束时间
-	 */
-	public void setEndTime(Date endTime){
-		this.endTime = endTime;
-	}
-	/**
-	 *获取保险费合计(总金额)
-	 */
-    	public BigDecimal getInsuranceFee(){
-		return insuranceFee;
-	}
-	
-	/**
-	 *设置保险费合计(总金额)
-	 */
-	public void setInsuranceFee(BigDecimal insuranceFee){
-		this.insuranceFee = insuranceFee;
-	}
-	/**
-	 *获取状态:草稿10/待初审20/待复审30/待缴费40/待制单50/待出单60/已出单70/已过期100
-	 */
-    	public String getStatus(){
-		return status;
-	}
-	
-	/**
-	 *设置状态:草稿10/待初审20/待复审30/待缴费40/待制单50/待出单60/已出单70/已过期100
-	 */
-	public void setStatus(String status){
-		this.status = status;
-	}
-	/**
-	 *获取流程审核状态:正常/回退等
-	 */
-    	public String getProcessStatus(){
-		return processStatus;
-	}
-	
-	/**
-	 *设置流程审核状态:正常/回退等
-	 */
-	public void setProcessStatus(String processStatus){
-		this.processStatus = processStatus;
-	}
-	/**
-	 *获取创建人
-	 */
-    	public String getCreateBy(){
-		return createBy;
-	}
-	
-	/**
-	 *设置创建人
-	 */
-	public void setCreateBy(String createBy){
-		this.createBy = createBy;
-	}
-	/**
-	 *获取创建时间
-	 */
-    	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
-	@JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
-		public Date getCreateTime(){
-		return createTime;
-	}
-	
-	/**
-	 *设置创建时间
-	 */
-	public void setCreateTime(Date createTime){
-		this.createTime = createTime;
-	}
-	/**
-	 *获取更新人
-	 */
-    	public String getUpdateBy(){
-		return updateBy;
-	}
-	
-	/**
-	 *设置更新人
-	 */
-	public void setUpdateBy(String updateBy){
-		this.updateBy = updateBy;
-	}
-	/**
-	 *获取更新时间
-	 */
-    	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
-	@JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
-		public Date getUpdateTime(){
-		return updateTime;
-	}
-	
-	/**
-	 *设置更新时间
-	 */
-	public void setUpdateTime(Date updateTime){
-		this.updateTime = updateTime;
-	}
-	/**
-	 *获取是否删除
-	 */
-    	public Boolean getDelFlag(){
-		return delFlag;
-	}
-	
-	/**
-	 *设置是否删除
-	 */
-	public void setDelFlag(Boolean delFlag){
-		this.delFlag = delFlag;
-	}
+	@ApiModelProperty(value = "出单时间")
+	private Date finishTime;
 
-	/**
-	 * 险种名称
-	 * @return
-	 */
-	public String getDefinitionName() {
-		return definitionName;
-	}
-
-	public void setDefinitionName(String definitionName) {
-		this.definitionName = definitionName;
-	}
-
-	public String getBusinessNature() {
-		return businessNature;
-	}
-
-	public void setBusinessNature(String businessNature) {
-		this.businessNature = businessNature;
-	}
 
 	/**
 	 * 状态翻译
@@ -456,33 +124,4 @@ public class InsuranceApplication {
 
 		return statusN;
 	}
-
-	public void setStatusN(String statusN){
-		this.statusN = statusN;
-	}
-
-
-	public InsurancePolicy getInsurancePolicy() {
-		return insurancePolicy;
-	}
-
-	public void setInsurancePolicy(InsurancePolicy insurancePolicy) {
-		this.insurancePolicy = insurancePolicy;
-	}
-
-	public String getBusinessNatureN() {
-		return businessNatureN;
-	}
-
-	public void setBusinessNatureN(String businessNatureN) {
-		this.businessNatureN = businessNatureN;
-	}
-
-	public String getCombinePolicyId() {
-		return combinePolicyId;
-	}
-
-	public void setCombinePolicyId(String combinePolicyId) {
-		this.combinePolicyId = combinePolicyId;
-	}
 }

+ 20 - 318
picc-common/src/main/java/com/jpsoft/picc/modules/business/entity/InsurancePolicy.java

@@ -7,6 +7,7 @@ import java.math.BigDecimal;
 
 import com.jpsoft.picc.modules.base.entity.InsuranceAgent;
 import com.jpsoft.picc.modules.common.constant.PolicyStatus;
+import lombok.Data;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.format.annotation.DateTimeFormat;
 import com.fasterxml.jackson.annotation.JsonFormat;
@@ -16,6 +17,7 @@ import io.swagger.annotations.ApiModel;
 /**
  描述:business_insurance_policy的实体类
  */
+@Data
 @ApiModel(value = "business_insurance_policy的实体类")
 public class InsurancePolicy {
     @ApiModelProperty(value = "编号")
@@ -32,8 +34,14 @@ public class InsurancePolicy {
     private String processStatus;
     @ApiModelProperty(value = "保险费合计(总金额)")
     private BigDecimal insuranceFee;
+
+    @DateTimeFormat(pattern="yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd",timezone ="GMT+8")
     @ApiModelProperty(value = "开始时间")
     private Date startTime;
+
+    @DateTimeFormat(pattern="yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd",timezone ="GMT+8")
     @ApiModelProperty(value = "结束时间")
     private Date endTime;
     @ApiModelProperty(value = "人数")
@@ -60,318 +68,32 @@ public class InsurancePolicy {
     private Boolean delFlag;
     @ApiModelProperty(value = "创建人")
     private String createBy;
+
+    @DateTimeFormat(pattern="yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd",timezone ="GMT+8")
     @ApiModelProperty(value = "创建时间")
     private Date createTime;
+
     @ApiModelProperty(value = "修改人")
     private String updateBy;
+
+    @DateTimeFormat(pattern="yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd",timezone ="GMT+8")
     @ApiModelProperty(value = "修改时间")
     private Date updateTime;
+
     @ApiModelProperty(value = "投保企业编号")
     private String companyId;
     @ApiModelProperty(value = "最后关联投保申请单编号")
     private String latestApplicationId;
 
-    /**
-     *获取编号
-     */
-    public String getId(){
-        return id;
-    }
-
-    /**
-     *设置编号
-     */
-    public void setId(String id){
-        this.id = id;
-    }
-    /**
-     *获取状态:待制单50/待出单60/已出单70
-     */
-    public String getStatus(){
-        return status;
-    }
-
-    /**
-     *设置状态:待制单50/待出单60/已出单70
-     */
-    public void setStatus(String status){
-        this.status = status;
-    }
-    /**
-     *获取流程审核状态:正常/回退等
-     */
-    public String getProcessStatus(){
-        return processStatus;
-    }
+    @ApiModelProperty(value = "投保单号")
+    private String policyNo;
 
-    /**
-     *设置流程审核状态:正常/回退等
-     */
-    public void setProcessStatus(String processStatus){
-        this.processStatus = processStatus;
-    }
-    /**
-     *获取保险费合计(总金额)
-     */
-    public BigDecimal getInsuranceFee(){
-        return insuranceFee;
-    }
-
-    /**
-     *设置保险费合计(总金额)
-     */
-    public void setInsuranceFee(BigDecimal insuranceFee){
-        this.insuranceFee = insuranceFee;
-    }
-    /**
-     *获取开始时间
-     */
     @DateTimeFormat(pattern="yyyy-MM-dd")
     @JsonFormat(pattern = "yyyy-MM-dd",timezone ="GMT+8")
-    public Date getStartTime(){
-        return startTime;
-    }
-
-    /**
-     *设置开始时间
-     */
-    public void setStartTime(Date startTime){
-        this.startTime = startTime;
-    }
-    /**
-     *获取结束时间
-     */
-    @DateTimeFormat(pattern="yyyy-MM-dd")
-    @JsonFormat(pattern = "yyyy-MM-dd",timezone ="GMT+8")
-    public Date getEndTime(){
-        return endTime;
-    }
-
-    /**
-     *设置结束时间
-     */
-    public void setEndTime(Date endTime){
-        this.endTime = endTime;
-    }
-    /**
-     *获取人数
-     */
-    public Integer getNumber(){
-        return number;
-    }
-
-    /**
-     *设置人数
-     */
-    public void setNumber(Integer number){
-        this.number = number;
-    }
-    /**
-     *获取入账银行
-     */
-    public String getAccountBank(){
-        return accountBank;
-    }
-
-    /**
-     *设置入账银行
-     */
-    public void setAccountBank(String accountBank){
-        this.accountBank = accountBank;
-    }
-    /**
-     *获取出账银行
-     */
-    public String getIssuingBank(){
-        return issuingBank;
-    }
-
-    /**
-     *设置出账银行
-     */
-    public void setIssuingBank(String issuingBank){
-        this.issuingBank = issuingBank;
-    }
-    /**
-     *获取单号
-     */
-    public String getSinglNumber(){
-        return singlNumber;
-    }
-
-    /**
-     *设置单号
-     */
-    public void setSinglNumber(String singlNumber){
-        this.singlNumber = singlNumber;
-    }
-    /**
-     *获取转账时间
-     */
-    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
-    public Date getTransferTime(){
-        return transferTime;
-    }
-
-    /**
-     *设置转账时间
-     */
-    public void setTransferTime(Date transferTime){
-        this.transferTime = transferTime;
-    }
-    /**
-     *获取保险代理人
-     */
-    public String getAgentId(){
-        return agentId;
-    }
-
-    /**
-     *设置保险代理人
-     */
-    public void setAgentId(String agentId){
-        this.agentId = agentId;
-    }
-
-    /**
-     *获取保险代理人
-     */
-    public InsuranceAgent getAgent(){
-        return agent;
-    }
-
-    /**
-     *设置保险代理人
-     */
-    public void setAgent(InsuranceAgent agent){
-        this.agent = agent;
-    }
-    /**
-     *获取投保单附件
-     */
-    public String getInsurancePolicyFile(){
-        return insurancePolicyFile;
-    }
-
-    /**
-     *设置投保单附件
-     */
-    public void setInsurancePolicyFile(String insurancePolicyFile){
-        this.insurancePolicyFile = insurancePolicyFile;
-    }
-    /**
-     *获取当前第几份
-     */
-    public Integer getNo(){
-        return no;
-    }
-
-    /**
-     *设置当前第几份
-     */
-    public void setNo(Integer no){
-        this.no = no;
-    }
-    /**
-     *获取生效年月(yyyyMM)
-     */
-    public String getEffectiveDate(){
-        return effectiveDate;
-    }
-
-    /**
-     *设置生效年月(yyyyMM)
-     */
-    public void setEffectiveDate(String effectiveDate){
-        this.effectiveDate = effectiveDate;
-    }
-    /**
-     *获取是否删除
-     */
-    public Boolean getDelFlag(){
-        return delFlag;
-    }
-
-    /**
-     *设置是否删除
-     */
-    public void setDelFlag(Boolean delFlag){
-        this.delFlag = delFlag;
-    }
-    /**
-     *获取创建人
-     */
-    public String getCreateBy(){
-        return createBy;
-    }
-
-    /**
-     *设置创建人
-     */
-    public void setCreateBy(String createBy){
-        this.createBy = createBy;
-    }
-    /**
-     *获取创建时间
-     */
-    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
-    public Date getCreateTime(){
-        return createTime;
-    }
-
-    /**
-     *设置创建时间
-     */
-    public void setCreateTime(Date createTime){
-        this.createTime = createTime;
-    }
-    /**
-     *获取修改人
-     */
-    public String getUpdateBy(){
-        return updateBy;
-    }
-
-    /**
-     *设置修改人
-     */
-    public void setUpdateBy(String updateBy){
-        this.updateBy = updateBy;
-    }
-    /**
-     *获取修改时间
-     */
-    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
-    public Date getUpdateTime(){
-        return updateTime;
-    }
-
-    /**
-     *设置修改时间
-     */
-    public void setUpdateTime(Date updateTime){
-        this.updateTime = updateTime;
-    }
-
-    public String getDefinitionName() {
-        return definitionName;
-    }
-
-    public void setDefinitionName(String definitionName) {
-        this.definitionName = definitionName;
-    }
-
-    public String getDefinitionId() {
-        return definitionId;
-    }
-
-    public void setDefinitionId(String definitionId) {
-        this.definitionId = definitionId;
-    }
-
+    @ApiModelProperty(value = "出单时间")
+    private Date finishTime;
 
     /**
      * 状态翻译
@@ -394,24 +116,4 @@ public class InsurancePolicy {
 
         return statusN;
     }
-
-    public void setStatusN(String statusN){
-        this.statusN = statusN;
-    }
-
-    public String getCompanyId() {
-        return companyId;
-    }
-
-    public void setCompanyId(String companyId) {
-        this.companyId = companyId;
-    }
-
-    public String getLatestApplicationId() {
-        return latestApplicationId;
-    }
-
-    public void setLatestApplicationId(String latestApplicationId) {
-        this.latestApplicationId = latestApplicationId;
-    }
 }

+ 2 - 2
picc-common/src/main/java/com/jpsoft/picc/modules/common/constant/PolicyStatus.java

@@ -6,8 +6,8 @@ package com.jpsoft.picc.modules.common.constant;
 public enum PolicyStatus {
     Draft("草稿",10),
     Back("已退回",15),
-    PendingTrial("待初审",20),
-    PendingRetrial("待复审",30),
+    PendingTrial("人才超市核准",20),
+    PendingRetrial("中国人保审核",30),
     PendingPay("待缴费",40),
     PendingMakePolicy("待制单",50),
     PendingOutPolicy("待出单",60),

+ 1 - 1
picc-common/src/main/java/com/jpsoft/picc/modules/common/utils/ItextPDFUtil.java

@@ -169,7 +169,7 @@ public class ItextPDFUtil {
     public void generatePDF(Document document,InsuranceApplication insuranceApplication, List<Map<String,Object>> mapList,List<InsurancePolicyMember> list,String logoUrl) throws Exception {
      //   Image image1 = Image.getInstance("C:/Users/Administrator/Desktop/picc/logo.png");
         Image image1 = Image.getInstance(logoUrl);
-        Paragraph p1 = new Paragraph("00000000000001", titlefont);
+        Paragraph p1 = new Paragraph("", titlefont);
         //设置文字居中 0靠左   1,居中     2,靠右
         p1.setAlignment(2);
         //设置左缩进

+ 2 - 2
picc-common/src/main/java/com/jpsoft/picc/modules/common/utils/SignUtil.java

@@ -88,10 +88,10 @@ public class SignUtil {
     public static void main(String[] args){
         HashMap<String,Object> signMap = new HashMap<String,Object>();
 
-        signMap.put("orderNo","20200308141313953");
+        signMap.put("orderNo","20200309163902105");
         signMap.put("payType","1");
         signMap.put("code","008");
-        signMap.put("payTime","1583647993");
+        signMap.put("payTime","1583743142");
         signMap.put("userMoney","1000");
 
         String md5_sign = "";

+ 38 - 21
picc-common/src/main/java/com/jpsoft/picc/modules/common/utils/Watermark.java

@@ -45,38 +45,55 @@ public class Watermark extends PdfPageEventHelper {
             gs1.setFillOpacity(0.25f);
 
             Image image = Image.getInstance(images);
-            int imgHeight = (int)image.getHeight();
-            int imgWidth = (int)image.getWidth();
+         //   int imgHeight = (int)image.getHeight();
+        //    int imgWidth = (int)image.getWidth();
 
             int n = reader.getNumberOfPages();
             PdfContentByte under;
 
-            for (int i = 1; i <= n; i++) {
+            under = stamper.getOverContent(2);
+            under.setGState(gs1);
+
+            Rectangle pageRect = reader.getPageSizeWithRotation(2);
+
+          //  image.setRotation(45);
+            image.scaleToFit(pageRect.getWidth()/5,pageRect.getHeight()/5);
+
+            image.setAbsolutePosition(pageRect.getWidth()/2,pageRect.getHeight()/5);
+            under.addImage(image);
+
+
+
+            for (int i = 4; i <= n; i++) {
                 // 获得PDF最顶层
                 under = stamper.getOverContent(i);
                 under.setGState(gs1);
 
-                Rectangle pageRect = reader.getPageSizeWithRotation(i);
+           //     Rectangle pageRect1 = reader.getPageSizeWithRotation(i);
 
                 //A4像素 842*596
                 float maxSize = 842;
-
-                for (int y = 0; y < Math.min(pageRect.getHeight(), maxSize); y += imgHeight)
-                {
-                    for (int x = 0; x < Math.min(pageRect.getWidth(), maxSize); x += imgWidth)
-                    {
-                        // 水印文字成45度角倾斜
-//                        image.setRotation(30);// 旋转 弧度
-                        // 设置旋转角度
-//                        image.setRotationDegrees(-45);// 旋转 角度
-                        // 设置等比缩放
-//                        under.setColorFill(BaseColor.GRAY);
-//                        image.scaleToFit(80,120);
-                        image.setRotation(45);
-                        image.setAbsolutePosition(x, y);
-                        under.addImage(image);
-                    }
-                }
+             //   image.setRotation(45);
+                image.scaleToFit(pageRect.getWidth()/5,pageRect.getHeight()/5);
+                image.setAbsolutePosition(2*pageRect.getWidth()/3,4*pageRect.getHeight()/5);
+                under.addImage(image);
+
+//                for (int y = 0; y < Math.min(pageRect.getHeight(), maxSize); y += imgHeight)
+//                {
+//                    for (int x = 0; x < Math.min(pageRect.getWidth(), maxSize); x += imgWidth)
+//                    {
+//                        // 水印文字成45度角倾斜
+////                        image.setRotation(30);// 旋转 弧度
+//                        // 设置旋转角度
+////                        image.setRotationDegrees(-45);// 旋转 角度
+//                        // 设置等比缩放
+////                        under.setColorFill(BaseColor.GRAY);
+////                        image.scaleToFit(80,120);
+//                        image.setRotation(45);
+//                        image.setAbsolutePosition(x, y);
+//                        under.addImage(image);
+//                    }
+//                }
             }
             stamper.close();
             reader.close();

+ 162 - 154
picc-common/src/main/resources/mapper/base/CompanyMember.xml

@@ -1,169 +1,177 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 
-"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <!-- namespace必须指向DAO接口 -->
 <mapper namespace="com.jpsoft.picc.modules.base.dao.CompanyMemberDAO">
-	<resultMap id="CompanyMemberMap" type="com.jpsoft.picc.modules.base.entity.CompanyMember">
-		<id property="id" column="id_" />
-			<result property="companyId" column="company_id" />
-			<result property="name" column="name_" />
-			<result property="cardType" column="card_type" />
-			<result property="cardNo" column="card_no" />
-			<result property="sex" column="sex_" />
-			<result property="age" column="age_" />
-			<result property="jobsId" column="jobs_id" />
-			<result property="jobName" column="job_name" />
-			<result property="healthStatus" column="health_status" />
-			<result property="cardFiles" column="card_files" />
-			<result property="status" column="status_" />
-			<result property="createBy" column="create_by" />
-			<result property="createTime" column="create_time" />
-			<result property="updateBy" column="update_by" />
-			<result property="updateTime" column="update_time" />
-			<result property="delFlag" column="del_flag" />
-			</resultMap>
-	<insert id="insert" parameterType="com.jpsoft.picc.modules.base.entity.CompanyMember">
-	<!--
-	<selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
-		select sys_guid() from dual
-	</selectKey>
-	-->
-	<![CDATA[
+    <resultMap id="CompanyMemberMap" type="com.jpsoft.picc.modules.base.entity.CompanyMember">
+        <id property="id" column="id_"/>
+        <result property="companyId" column="company_id"/>
+        <result property="name" column="name_"/>
+        <result property="cardType" column="card_type"/>
+        <result property="cardNo" column="card_no"/>
+        <result property="sex" column="sex_"/>
+        <result property="age" column="age_"/>
+        <result property="jobsId" column="jobs_id"/>
+        <result property="jobName" column="job_name"/>
+        <result property="healthStatus" column="health_status"/>
+        <result property="cardFiles" column="card_files"/>
+        <result property="status" column="status_"/>
+        <result property="createBy" column="create_by"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateBy" column="update_by"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="delFlag" column="del_flag"/>
+        <association property="cardTypeN"
+                     column="{catalogName=card_type_catalog,value=card_type}"
+                     select="com.jpsoft.picc.modules.sys.dao.DataDictionaryDAO.findNameByCatalogNameAndValue"
+        />
+    </resultMap>
+    <insert id="insert" parameterType="com.jpsoft.picc.modules.base.entity.CompanyMember">
+        <!--
+        <selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
+            select sys_guid() from dual
+        </selectKey>
+        -->
+        <![CDATA[
 		insert into base_company_member
 	    (id_,company_id,name_,card_type,card_no,sex_,age_,jobs_id,health_status,card_files,status_,create_by,create_time,update_by,update_time,del_flag)
 		values
 		(
-#{id,jdbcType=VARCHAR}
-,#{companyId,jdbcType=VARCHAR}
-,#{name,jdbcType=VARCHAR}
-,#{cardType,jdbcType=VARCHAR}
-,#{cardNo,jdbcType=VARCHAR}
-,#{sex,jdbcType= NUMERIC }
-,#{age,jdbcType= NUMERIC }
-,#{jobsId,jdbcType=VARCHAR}
-,#{healthStatus,jdbcType=VARCHAR}
-,#{cardFiles,jdbcType=VARCHAR}
-,#{status,jdbcType=VARCHAR}
-,#{createBy,jdbcType=VARCHAR}
-,#{createTime,jdbcType= TIMESTAMP }
-,#{updateBy,jdbcType=VARCHAR}
-,#{updateTime,jdbcType= TIMESTAMP }
-,#{delFlag,jdbcType= NUMERIC }
+			#{id,jdbcType=VARCHAR}
+			,#{companyId,jdbcType=VARCHAR}
+			,#{name,jdbcType=VARCHAR}
+			,#{cardType,jdbcType=VARCHAR}
+			,#{cardNo,jdbcType=VARCHAR}
+			,#{sex,jdbcType= NUMERIC }
+			,#{age,jdbcType= NUMERIC }
+			,#{jobsId,jdbcType=VARCHAR}
+			,#{healthStatus,jdbcType=VARCHAR}
+			,#{cardFiles,jdbcType=VARCHAR}
+			,#{status,jdbcType=VARCHAR}
+			,#{createBy,jdbcType=VARCHAR}
+			,#{createTime,jdbcType= TIMESTAMP }
+			,#{updateBy,jdbcType=VARCHAR}
+			,#{updateTime,jdbcType= TIMESTAMP }
+			,#{delFlag,jdbcType= NUMERIC }
 		)
 	]]>
-	</insert>
-	<delete id="delete" parameterType="string">
-		delete from base_company_member where id_=#{id,jdbcType=VARCHAR}
-	</delete>
-	<update id="update" parameterType="com.jpsoft.picc.modules.base.entity.CompanyMember">
-		update base_company_member
-		<set>
-				<if test="companyId!=null">
-		company_id=#{companyId,jdbcType=VARCHAR},
-		</if>
-				<if test="name!=null">
-		name_=#{name,jdbcType=VARCHAR},
-		</if>
-				<if test="cardType!=null">
-		card_type=#{cardType,jdbcType=VARCHAR},
-		</if>
-				<if test="cardNo!=null">
-		card_no=#{cardNo,jdbcType=VARCHAR},
-		</if>
-				<if test="sex!=null">
-		sex_=#{sex,jdbcType= NUMERIC },
-		</if>
-				<if test="age!=null">
-		age_=#{age,jdbcType= NUMERIC },
-		</if>
-				<if test="jobsId!=null">
-		jobs_id=#{jobsId,jdbcType=VARCHAR},
-		</if>
-				<if test="healthStatus!=null">
-		health_status=#{healthStatus,jdbcType=VARCHAR},
-		</if>
-				<if test="cardFiles!=null">
-		card_files=#{cardFiles,jdbcType=VARCHAR},
-		</if>
-				<if test="status!=null">
-		status_=#{status,jdbcType=VARCHAR},
-		</if>
-				<if test="createBy!=null">
-		create_by=#{createBy,jdbcType=VARCHAR},
-		</if>
-				<if test="createTime!=null">
-		create_time=#{createTime,jdbcType= TIMESTAMP },
-		</if>
-				<if test="updateBy!=null">
-		update_by=#{updateBy,jdbcType=VARCHAR},
-		</if>
-				<if test="updateTime!=null">
-		update_time=#{updateTime,jdbcType= TIMESTAMP },
-		</if>
-				<if test="delFlag!=null">
-		del_flag=#{delFlag,jdbcType= NUMERIC },
-		</if>
-		</set>
-	where id_=#{id}
-	</update>
-	<select id="get" parameterType="string" resultMap="CompanyMemberMap">
-		select t1.*,t2.name_ as job_name from base_company_member t1 left join base_jobs t2 on t1.jobs_id=t2.id_
-		where t1.id_=#{0}
-	</select>
-	<select id="exist" parameterType="string" resultType="int">
-		select count(*) from base_company_member t1 where t1.id_=#{0}
-	</select>
-	<select id="list" resultMap="CompanyMemberMap">
-		select t1.*,t2.name_ as job_name from base_company_member t1 left join base_jobs t2 on t1.jobs_id=t2.id_
-		where t1.del_flag=0
-	</select>
-	<select id="search" parameterType="hashmap" resultMap="CompanyMemberMap">
-		<![CDATA[
-			select * from (
+    </insert>
+    <delete id="delete" parameterType="string">
+        delete from base_company_member where id_=#{id,jdbcType=VARCHAR}
+    </delete>
+    <update id="update" parameterType="com.jpsoft.picc.modules.base.entity.CompanyMember">
+        update base_company_member
+        <set>
+            <if test="companyId!=null">
+                company_id=#{companyId,jdbcType=VARCHAR},
+            </if>
+            <if test="name!=null">
+                name_=#{name,jdbcType=VARCHAR},
+            </if>
+            <if test="cardType!=null">
+                card_type=#{cardType,jdbcType=VARCHAR},
+            </if>
+            <if test="cardNo!=null">
+                card_no=#{cardNo,jdbcType=VARCHAR},
+            </if>
+            <if test="sex!=null">
+                sex_=#{sex,jdbcType= NUMERIC },
+            </if>
+            <if test="age!=null">
+                age_=#{age,jdbcType= NUMERIC },
+            </if>
+            <if test="jobsId!=null">
+                jobs_id=#{jobsId,jdbcType=VARCHAR},
+            </if>
+            <if test="healthStatus!=null">
+                health_status=#{healthStatus,jdbcType=VARCHAR},
+            </if>
+            <if test="cardFiles!=null">
+                card_files=#{cardFiles,jdbcType=VARCHAR},
+            </if>
+            <if test="status!=null">
+                status_=#{status,jdbcType=VARCHAR},
+            </if>
+            <if test="createBy!=null">
+                create_by=#{createBy,jdbcType=VARCHAR},
+            </if>
+            <if test="createTime!=null">
+                create_time=#{createTime,jdbcType= TIMESTAMP },
+            </if>
+            <if test="updateBy!=null">
+                update_by=#{updateBy,jdbcType=VARCHAR},
+            </if>
+            <if test="updateTime!=null">
+                update_time=#{updateTime,jdbcType= TIMESTAMP },
+            </if>
+            <if test="delFlag!=null">
+                del_flag=#{delFlag,jdbcType= NUMERIC },
+            </if>
+        </set>
+        where id_=#{id}
+    </update>
+    <select id="get" parameterType="string" resultMap="CompanyMemberMap">
+        select t1.*,t2.name_ as job_name,'证件类型' as card_type_catalog
+        from
+        base_company_member t1 left join base_jobs t2 on t1.jobs_id=t2.id_
+        where t1.id_=#{0}
+    </select>
+    <select id="exist" parameterType="string" resultType="int">
+        select count(*) from base_company_member t1 where t1.id_=#{0}
+    </select>
+    <select id="list" resultMap="CompanyMemberMap">
+        select t1.*,t2.name_ as job_name,'证件类型' as card_type_catalog
+        from base_company_member t1 left join base_jobs t2 on t1.jobs_id=t2.id_
+        where t1.del_flag=0
+    </select>
+    <select id="search" parameterType="hashmap" resultMap="CompanyMemberMap">
+        <![CDATA[
+			select t.*,'证件类型' as card_type_catalog from (
 				select t1.*,t2.name_ as job_name from base_company_member t1
 				left join base_jobs t2 on t1.jobs_id=t2.id_
 			) as t
 		]]>
-		<where>
-			<if test="searchParams.id != null">
-				and ID_ like #{searchParams.id}
-			</if>
-			<if test="searchParams.companyId != null">
-				and company_id = #{searchParams.companyId}
-			</if>
-			<if test="searchParams.memberName != null">
-				and name_ like #{searchParams.memberName}
-			</if>
-			<if test="searchParams.jobsId != null">
-				and jobs_id = #{searchParams.jobsId}
-			</if>
-			<if test="searchParams.delFlag != null">
-				and del_flag = #{searchParams.delFlag}
-			</if>
-			<if test="searchParams.cardNo != null">
-				and card_no = #{searchParams.cardNo}
-			</if>
-			<if test="searchParams.excludePolicyId != null">
-				and id_ not in(
-					select member_id from business_insurance_policy_member
-					where policy_id = #{searchParams.excludePolicyId}
-					and del_flag=0
-				)
-			</if>
-		</where>
-		<foreach item="sort" collection="sortList"  open="order by" separator=",">
-	        ${sort.name} ${sort.order}
-	 	</foreach>
-	</select>
+        <where>
+            <if test="searchParams.id != null">
+                and ID_ like #{searchParams.id}
+            </if>
+            <if test="searchParams.companyId != null">
+                and company_id = #{searchParams.companyId}
+            </if>
+            <if test="searchParams.memberName != null">
+                and name_ like #{searchParams.memberName}
+            </if>
+            <if test="searchParams.jobsId != null">
+                and jobs_id = #{searchParams.jobsId}
+            </if>
+            <if test="searchParams.delFlag != null">
+                and del_flag = #{searchParams.delFlag}
+            </if>
+            <if test="searchParams.cardNo != null">
+                and card_no = #{searchParams.cardNo}
+            </if>
+            <if test="searchParams.excludePolicyId != null">
+                and id_ not in(
+                select member_id from business_insurance_policy_member
+                where policy_id = #{searchParams.excludePolicyId}
+                and del_flag=0
+                )
+            </if>
+        </where>
+        <foreach item="sort" collection="sortList" open="order by" separator=",">
+            ${sort.name} ${sort.order}
+        </foreach>
+    </select>
     <select id="findByNotInPolicyMember" resultMap="CompanyMemberMap">
-		select * from base_company_member t1
-		where t1.del_flag=0 and t1.company_id=#{companyId}
-		and t1.id_ not in(
-			select member_id from business_insurance_policy_member
-			where del_flag=0
-			<foreach item="policyId" collection="excludePolicyIds" open=" and policy_id in(" separator="," close=")">
-				#{policyId}
-			</foreach>
-		)
-	</select>
+        select t1.*,'证件类型' as card_type_catalog
+        from base_company_member t1
+        where t1.del_flag=0 and t1.company_id=#{companyId}
+        and t1.id_ not in(
+        select member_id from business_insurance_policy_member
+        where del_flag=0
+        <foreach item="policyId" collection="excludePolicyIds" open=" and policy_id in(" separator="," close=")">
+            #{policyId}
+        </foreach>
+        )
+    </select>
 </mapper>

+ 88 - 0
picc-common/src/main/resources/mapper/base/ReplyMessage.xml

@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<!-- namespace必须指向DAO接口 -->
+<mapper namespace="com.jpsoft.weixin.dao.ReplyMessageDAO">
+    <resultMap id="ReplyMessageMap" type="com.jpsoft.picc.modules.base.entity.ReplyMessage">
+        <id property="id" column="id_"/>
+        <result property="wechatId" column="wechat_id"/>
+        <result property="event" column="event_"/>
+        <result property="message" column="message_"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="callbackUrl" column="callback_url"/>
+    </resultMap>
+    <insert id="insert" parameterType="com.jpsoft.picc.modules.base.entity.ReplyMessage">
+        <!--
+        <selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
+            select sys_guid() from dual
+        </selectKey>
+        -->
+        <![CDATA[
+		insert into wechat_reply_message
+	    (id_,wechat_id,event_,message_,create_time,update_time,callback_url)
+		values
+		(
+			#{id,jdbcType=VARCHAR}
+			,#{wechatId,jdbcType=VARCHAR}
+			,#{event,jdbcType=VARCHAR}
+			,#{message,jdbcType=VARCHAR}
+			,#{createTime,jdbcType= TIMESTAMP }
+			,#{updateTime,jdbcType= TIMESTAMP }
+			,#{callbackUrl,jdbcType=VARCHAR}
+		)
+	]]>
+    </insert>
+    <delete id="delete" parameterType="string">
+        delete from wechat_reply_message where id_=#{id,jdbcType=VARCHAR}
+    </delete>
+    <update id="update" parameterType="com.jpsoft.picc.modules.base.entity.ReplyMessage">
+        update wechat_reply_message
+        <set>
+            <if test="wechatId!=null">
+                wechat_id=#{wechatId,jdbcType=VARCHAR},
+            </if>
+            <if test="event!=null">
+                event_=#{event,jdbcType=VARCHAR},
+            </if>
+            <if test="message!=null">
+                message_=#{message,jdbcType=VARCHAR},
+            </if>
+            <if test="createTime!=null">
+                create_time=#{createTime,jdbcType= TIMESTAMP },
+            </if>
+            <if test="updateTime!=null">
+                update_time=#{updateTime,jdbcType= TIMESTAMP },
+            </if>
+            <if test="callbackUrl!=null">
+                callback_url=#{callbackUrl,jdbcType=VARCHAR},
+            </if>
+        </set>
+        where id_=#{id}
+    </update>
+    <select id="get" parameterType="string" resultMap="ReplyMessageMap">
+        select * from wechat_reply_message where id_=#{0}
+    </select>
+    <select id="exist" parameterType="string" resultType="int">
+        select count(*) from wechat_reply_message where id_=#{0}
+    </select>
+    <select id="list" resultMap="ReplyMessageMap">
+        select * from wechat_reply_message
+    </select>
+    <select id="search" parameterType="hashmap" resultMap="ReplyMessageMap">
+        <![CDATA[
+			select * from wechat_reply_message
+		]]>
+        <where>
+            <if test="searchParams.id != null">
+                and ID_ like #{searchParams.id}
+            </if>
+        </where>
+        <foreach item="sort" collection="sortList" open="order by" separator=",">
+            ${sort.name} ${sort.order}
+        </foreach>
+    </select>
+    <select id="findByEvent" resultMap="ReplyMessageMap">
+        select * from wechat_reply_message where wechat_id=#{wechatId} and event_=#{event} limit 1
+    </select>
+</mapper>

+ 11 - 1
picc-common/src/main/resources/mapper/business/InsuranceApplication.xml

@@ -32,6 +32,8 @@
         <result property="updateTime" column="update_time"/>
         <result property="delFlag" column="del_flag"/>
         <result property="combinePolicyId" column="combine_policy_id"/>
+        <result property="policyNo" column="policy_no"/>
+        <result property="finishTime" column="finish_time"/>
     </resultMap>
     <resultMap id="InsuranceApplicationMap2" extends="InsuranceApplicationMap" type="com.jpsoft.picc.modules.business.entity.InsuranceApplication">
         <association property="businessNatureN"
@@ -50,7 +52,7 @@
 	    (id_,company_id,definition_id,insured_name,insured_tel,company_name,uscc_code,
 	    business_scope,business_nature,industry_type,tel_,postal_,employees_number,insured_number,company_address,
 	    loss_in_recent_years,start_time,end_time,insurance_fee,status_,process_status,create_by,create_time,
-	    update_by,update_time,del_flag,combine_policy_id)
+	    update_by,update_time,del_flag,combine_policy_id,policy_no,finish_time)
 		values
 		(
             #{id,jdbcType=VARCHAR}
@@ -80,6 +82,8 @@
             ,#{updateTime,jdbcType= TIMESTAMP }
             ,#{delFlag,jdbcType= NUMERIC }
             ,#{combinePolicyId,jdbcType=VARCHAR}
+            ,#{policyNo,jdbcType=VARCHAR}
+            ,#{finishTime,jdbcType= TIMESTAMP }
 		)
 	]]>
     </insert>
@@ -167,6 +171,12 @@
             <if test="combinePolicyId!=null">
                 combine_policy_id=#{combinePolicyId,jdbcType=VARCHAR},
             </if>
+            <if test="policyNo!=null">
+                policy_no=#{policyNo,jdbcType=VARCHAR},
+            </if>
+            <if test="finishTime!=null">
+                finish_time=#{finishTime,jdbcType= TIMESTAMP },
+            </if>
         </set>
         where id_=#{id}
     </update>

+ 11 - 1
picc-common/src/main/resources/mapper/business/InsurancePolicy.xml

@@ -28,6 +28,8 @@
         <result property="updateTime" column="update_time" />
         <result property="latestApplicationId" column="latest_application_id"/>
         <result property="companyId" column="company_id"/>
+        <result property="policyNo" column="policy_no"/>
+        <result property="finishTime" column="finish_time"/>
         <association property="agent" column="agent_id" select="com.jpsoft.picc.modules.base.dao.InsuranceAgentDAO.get"></association>
    </resultMap>
     <insert id="insert" parameterType="com.jpsoft.picc.modules.business.entity.InsurancePolicy">
@@ -41,7 +43,7 @@
 	    (id_,definition_id,status_,process_status,insurance_fee,start_time,end_time,
 	    number_,account_bank,issuing_bank,singl_number,transfer_time,
 	    agent_id,insurance_policy_file,no_,effective_date,del_flag,create_by,create_time,update_by,update_time,
-	    company_id,latest_application_id)
+	    company_id,latest_application_id,policy_no,finish_time)
 		values
 		(
             #{id,jdbcType=VARCHAR}
@@ -67,6 +69,8 @@
             ,#{updateTime,jdbcType= TIMESTAMP }
             ,#{companyId,jdbcType=VARCHAR}
             ,#{latestApplicationId,jdbcType=VARCHAR}
+            ,#{policyNo,jdbcType=VARCHAR}
+            ,#{finishTime,jdbcType= TIMESTAMP }
 		)
 	]]>
     </insert>
@@ -142,6 +146,12 @@
             <if test="latestApplicationId!=null">
                 latest_application_id=#{latestApplicationId,jdbcType=VARCHAR},
             </if>
+            <if test="policyNo!=null">
+                policy_no=#{policyNo,jdbcType=VARCHAR},
+            </if>
+            <if test="finishTime!=null">
+                finish_time=#{finishTime,jdbcType= TIMESTAMP },
+            </if>
         </set>
         where id_=#{id}
     </update>

+ 11 - 2
picc-enterprise-server/src/main/java/com/jpsoft/picc/modules/auth/controller/InsuranceApplicationController.java

@@ -384,6 +384,11 @@ public class InsuranceApplicationController {
 
             //更新每月投保单
             InsurancePolicy insurancePolicy = insurancePolicyService.get(policyId);
+            PolicyStatus srcPolicyStatus = PolicyStatus.Draft;
+
+            if(StringUtils.isNotEmpty(insurancePolicy.getStatus())) {
+                srcPolicyStatus = PolicyStatus.valueOf(Integer.valueOf(insurancePolicy.getStatus()));
+            }
 
             insurancePolicy.setLatestApplicationId(applicationId);
             insurancePolicy.setCompanyId(insuranceApplication.getCompanyId());
@@ -392,6 +397,7 @@ public class InsuranceApplicationController {
             insurancePolicy.setInsuranceFee(totalAmount);
             insurancePolicy.setNumber(totalNumber);
             insurancePolicy.setNo(1); //首月
+            insurancePolicy.setPolicyNo(insuranceApplication.getPolicyNo()); //首页投保单相同
             insurancePolicy.setEffectiveDate(startTime.toString("yyyyMM"));
 
             insurancePolicy.setStartTime(startTime.toDate());
@@ -402,7 +408,7 @@ public class InsuranceApplicationController {
 
             insurancePolicyService.update(insurancePolicy);
 
-            templateMessageService.sendTemplateMessage(policyId,PolicyStatus.PendingTrial);
+            templateMessageService.sendTemplateMessage(policyId,srcPolicyStatus,PolicyStatus.PendingTrial);
 
             msgResult.setResult(true);
         }
@@ -450,7 +456,10 @@ public class InsuranceApplicationController {
 
                 insuranceApplication.setDelFlag(false);
                 insuranceApplication.setCreateBy(principal.getName());
-                insuranceApplication.setCreateTime(new Date());
+
+                DateTime createTime = DateTime.now();
+                insuranceApplication.setCreateTime(createTime.toDate());
+                insuranceApplication.setPolicyNo(createTime.toString("yyyyMMddHHmmss") + "-01");
 
                 affectCount = insuranceApplicationService.insert(insuranceApplication);
             }else {

+ 62 - 19
picc-enterprise-server/src/main/java/com/jpsoft/picc/modules/auth/controller/InsurancePolicyController.java

@@ -28,6 +28,8 @@ import org.joda.time.Interval;
 import org.joda.time.Months;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.format.annotation.DateTimeFormat;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
@@ -373,7 +375,7 @@ public class InsurancePolicyController {
 
             insurancePolicyService.update(insurancePolicy);
 
-            templateMessageService.sendTemplateMessage(policyId,policyStatus);
+            templateMessageService.sendTemplateMessage(policyId,PolicyStatus.Draft,policyStatus);
 
             msgResult.setResult(true);
         }
@@ -544,15 +546,12 @@ public class InsurancePolicyController {
             insurancePolicyService.update(insurancePolicy);
 
             if (insurancePolicy.getNo().equals(1)){
-                 List<InsuranceApplication> applicationList = applicationPolicyService.findApplicationByPolicyId(insurancePolicy.getId());
+                InsuranceApplication insuranceApplication = insuranceApplicationService.get(insurancePolicy.getLatestApplicationId());
+                insuranceApplication.setStatus(status);
+                insuranceApplication.setUpdateBy(principal.getName());
+                insurancePolicy.setUpdateTime(new Date());
 
-                for (InsuranceApplication insuranceApplication: applicationList) {
-                    insuranceApplication.setStatus(status);
-                    insuranceApplication.setUpdateBy(principal.getName());
-                    insurancePolicy.setUpdateTime(new Date());
-
-                    insuranceApplicationService.update(insuranceApplication);
-                }
+                insuranceApplicationService.update(insuranceApplication);
             }
 
             messageResult.setResult(true);
@@ -634,25 +633,21 @@ public class InsurancePolicyController {
 
     @PostMapping(value="addMemberOfNextMonthPolicy")
     @ApiOperation(value = "下月投保单中新增人员")
+    @Transactional(rollbackFor = Exception.class)
     @ApiImplicitParams({
         @ApiImplicitParam(name = "policyId",value = "下月投保单", required = true, paramType = "form")
     })
-    public MessageResult<String> addMemberOfNextMonthPolicy(String policyId,HttpServletRequest request){
-        MessageResult<String> messageResult = new MessageResult<>();
+    public MessageResult<Map> addMemberOfNextMonthPolicy(String policyId,HttpServletRequest request){
+        MessageResult<Map> messageResult = new MessageResult<>();
 
         try {
             AttributePrincipal principal = (AttributePrincipal) request.getUserPrincipal();
             CompanyUser companyUser = companyUserService.findByUserName(principal.getName());
 
             //todo 新增一份投保单用于缴费,截止月份相同,起始月份为当前投保单月份,流程只需要经过初审、复审、缴费后就合并。
-            List<InsuranceApplication> applicationList = applicationPolicyService.findApplicationByPolicyId(policyId);
-            InsuranceApplication insuranceApplication = null;
-
             InsurancePolicy insurancePolicy = insurancePolicyService.get(policyId);
 
-            if (applicationList.size()>0) {
-                insuranceApplication = applicationList.get(0);
-            }
+            InsuranceApplication insuranceApplication = insuranceApplicationService.get(insurancePolicy.getLatestApplicationId());
 
             //todo 判断当前相同企业、相同险种、生效期限相同的投保单是否存在
 //            List<InsuranceApplication> destList = insuranceApplicationService.findByDuration(insuranceApplication.getCompanyId(),
@@ -671,6 +666,9 @@ public class InsurancePolicyController {
             if(destApplication==null) {
                 destApplication = insuranceApplication;
                 destApplication.setId(UUID.randomUUID().toString());
+
+                //todo 新增参保申请单号与原参保申请单一致
+                destApplication.setPolicyNo(insuranceApplication.getPolicyNo());
                 destApplication.setCreateTime(new Date());
                 destApplication.setCreateBy(principal.getName());
                 destApplication.setInsuranceFee(new BigDecimal(0));
@@ -681,15 +679,60 @@ public class InsurancePolicyController {
                 destApplication.setCombinePolicyId(policyId); //设置要合并的每月投保单
 
                 insuranceApplicationService.insert(destApplication);
-                messageResult.setData(destApplication.getId());
+
+                //todo 新增一份每月投保单
+                InsurancePolicy newPolicy = new InsurancePolicy();
+                newPolicy.setId(UUID.randomUUID().toString());
+                newPolicy.setLatestApplicationId(destApplication.getId());
+                newPolicy.setPolicyNo(insurancePolicy.getPolicyNo()); //由于是用来合并,保持与原投保单一致
+
+                newPolicy.setDelFlag(false);
+                newPolicy.setCreateBy(principal.getName());
+                newPolicy.setCreateTime(new Date());
+                newPolicy.setNo(1);
+
+                int affectCount = insurancePolicyService.insert(newPolicy);
+
+                if (affectCount > 0) {
+                    //todo 关联投保申请单月与每月投保单
+                    ApplicationPolicy applicationPolicy = new ApplicationPolicy();
+                    applicationPolicy.setId(UUID.randomUUID().toString());
+
+                    applicationPolicy.setApplicationId(destApplication.getId());
+                    applicationPolicy.setPolicyId(newPolicy.getId());
+
+                    applicationPolicyService.insert(applicationPolicy);
+                }
+
+                Map<String,Object> dataMap = new HashMap<>();
+
+                dataMap.put("applicationId",destApplication.getId());
+                dataMap.put("policyId",newPolicy.getId());
+                dataMap.put("companyId",destApplication.getCompanyId());
+
+                messageResult.setData(dataMap);
+            }
+            else{
+                InsurancePolicy firstPolicy = applicationPolicyService.findFirstPolicyByApplicationId(destApplication.getId());
+
+                Map<String,Object> dataMap = new HashMap<>();
+
+                dataMap.put("applicationId",destApplication.getId());
+                dataMap.put("policyId",firstPolicy.getId());
+                dataMap.put("companyId",destApplication.getCompanyId());
+
+                messageResult.setData(dataMap);
             }
 
             messageResult.setResult(true);
-            messageResult.setData(destApplication.getId());
         }
         catch (Exception ex){
             messageResult.setResult(false);
             messageResult.setMessage(ex.getMessage());
+
+            //在实际开发中,我们往往需要在方法中进行异常的捕获,从而对异常进行判断,为客户端返回提示信息。
+            //但是此时由于异常的被捕获,导致事务的回滚没有被触发,导致事务的失败。
+            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
         }
 
         return messageResult;

+ 1 - 1
picc-enterprise-server/src/main/java/com/jpsoft/picc/modules/auth/controller/InsurancePolicyUserController.java

@@ -73,7 +73,7 @@ public class InsurancePolicyUserController {
             @RequestParam(value="pageSize",defaultValue="20") int pageSize,
             HttpServletRequest request){
         AttributePrincipal principal = (AttributePrincipal) request.getUserPrincipal();
-        Company company = companyService.findByCreateBy(principal.getName());
+//        Company company = companyService.findByCreateBy(principal.getName());
 
         MessageResult<Map> msgResult = new MessageResult<>();
 

+ 43 - 5
picc-enterprise-server/src/main/java/com/jpsoft/picc/modules/pub/controller/PayController.java

@@ -2,9 +2,11 @@ package com.jpsoft.picc.modules.pub.controller;
 
 import cn.hutool.json.JSONObject;
 import com.jpsoft.picc.config.JpCloudConfig;
+import com.jpsoft.picc.modules.base.entity.Company;
+import com.jpsoft.picc.modules.base.entity.CompanyUser;
+import com.jpsoft.picc.modules.base.entity.Message;
 import com.jpsoft.picc.modules.base.entity.TransactionRecord;
-import com.jpsoft.picc.modules.base.service.CompanyService;
-import com.jpsoft.picc.modules.base.service.TransactionRecordService;
+import com.jpsoft.picc.modules.base.service.*;
 import com.jpsoft.picc.modules.business.entity.ApplicationPolicy;
 import com.jpsoft.picc.modules.business.entity.InsuranceApplication;
 import com.jpsoft.picc.modules.business.entity.InsurancePolicy;
@@ -31,6 +33,7 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
+import java.text.DecimalFormat;
 import java.util.*;
 
 /**
@@ -64,6 +67,15 @@ public class PayController {
     @Autowired
     private CompanyService companyService;
 
+    @Autowired
+    private CompanyUserService companyUserService;
+
+    @Autowired
+    private TemplateMessageService templateMessageService;
+
+    @Autowired
+    private MessageService messageService;
+
     @PostMapping(value = "/orderNotifyBack")
     @ResponseBody
     @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED)
@@ -121,7 +133,33 @@ public class PayController {
                     insuranceApplicationService.update(insuranceApplication);
                 }
 
-                //todo 处理合并投保单
+                //todo 发送微信模板消息
+                InsurancePolicy insurancePolicy = applicationPolicyService.findFirstPolicyByApplicationId(insuranceApplication.getId());
+
+                templateMessageService.sendTemplateMessage(insurancePolicy.getId(),PolicyStatus.PendingPay,PolicyStatus.PendingMakePolicy);
+
+                //todo 发送站内消息通知企业用户(正常缴费荆鹏云会发短信消息给企业用户)
+                CompanyUser companyUser = companyUserService.findByCompanyId(insuranceApplication.getCompanyId());
+
+                if (companyUser!=null){
+                    Message siteMessage = new Message();
+
+                    siteMessage.setId(UUID.randomUUID().toString());
+                    siteMessage.setTitle("缴费成功通知");
+
+                    DecimalFormat df = new DecimalFormat("0.00");
+
+                    siteMessage.setContent("投保单号:" + insuranceApplication.getPolicyNo() + "已缴费成功,共计:"
+                            + df.format(insuranceApplication.getInsuranceFee()) + "元。");
+
+                    siteMessage.setCreateTime(new Date());
+                    siteMessage.setRecipientId(companyUser.getId());
+                    siteMessage.setDelFlag(false);
+
+                    messageService.insert(siteMessage);
+                }
+
+                //todo 处理合并投保单(会将当前投保单设为假删除,放最后处理)
                 processCombinePolicy(insuranceApplication);
 
                 message = "订单已支付";
@@ -199,11 +237,11 @@ public class PayController {
             insurancePolicyService.updatePolicyNumAndAmount(combinePolicy, null);
 
             //todo 因为已合并,将当前投保申请单、当前每月投保单设为false
-            insuranceApplication.setDelFlag(false);
+            insuranceApplication.setDelFlag(true);
             insuranceApplication.setUpdateTime(new Date());
             insuranceApplicationService.update(insuranceApplication);
 
-            firstPolicy.setDelFlag(false);
+            firstPolicy.setDelFlag(true);
             firstPolicy.setUpdateTime(new Date());
             insurancePolicyService.update(firstPolicy);
         }

+ 2 - 2
picc-enterprise-server/src/main/resources/application-test.yml

@@ -31,8 +31,8 @@ jpcloud:
 weixin:
   appId: wxf6af207d9143d1de
   appSecret: c86c042923e72c61c76a3a8658349312
-  tokenUrl: "http://www.jzrccs.com/weixin-middleware/token"
-  createQrCodeUrl: "http://www.jzrccs.com/weixin-middleware/qrcode/create"
+  tokenUrl: "http://picc.jzrccs.com/weixin-middleware/token"
+  createQrCodeUrl: "http://picc.jzrccs.com/weixin-middleware/qrcode/create"
   sendTmplMsgUrl: "https://api.weixin.qq.com/cgi-bin/message/template/send"
   sendTmplId: "6CMGIpbgZLtqdr9xOdyEAlrCWXh8nJ260jRdktnv7vE"
 

+ 6 - 0
weixin-middleware/pom.xml

@@ -94,6 +94,12 @@
             <version>1.1.10</version>
         </dependency>
         <!-- 数据库相关 end-->
+        <!-- veloctiy -->
+        <dependency>
+            <groupId>org.apache.velocity</groupId>
+            <artifactId>velocity</artifactId>
+            <version>1.7</version>
+        </dependency>
     </dependencies>
 
 

+ 2 - 1
weixin-middleware/src/main/java/com/jpsoft/weixin/callback/EventCallback.java

@@ -31,7 +31,7 @@ public class EventCallback {
 //        this.message = message;
     }
 
-    public boolean process(String openId,String eventKey){
+    public boolean process(String wechatId,String openId,String eventKey){
         boolean result = false;
 
         try {
@@ -53,6 +53,7 @@ public class EventCallback {
 
             List<NameValuePair> list = new ArrayList<NameValuePair>();
             list.add(new BasicNameValuePair("eventKey", eventKey));
+            list.add(new BasicNameValuePair("wechatId", wechatId));
             list.add(new BasicNameValuePair("openId", openId));
 
             UrlEncodedFormEntity entity = new UrlEncodedFormEntity(list, "UTF-8");

+ 26 - 9
weixin-middleware/src/main/java/com/jpsoft/weixin/callback/PromotionCallback.java

@@ -1,17 +1,28 @@
 package com.jpsoft.weixin.callback;
 
+import cn.hutool.core.collection.CollUtil;
+import com.jpsoft.weixin.entity.ReplyMessage;
+import com.jpsoft.weixin.service.ReplyMessageService;
+import com.jpsoft.weixin.utils.VelocityHelper;
 import lombok.extern.slf4j.Slf4j;
-
 import java.net.URLEncoder;
+import java.util.HashMap;
+import java.util.Map;
 
 @Slf4j
 public class PromotionCallback extends EventCallback {
+    private ReplyMessageService replyMessageService;
+
     public PromotionCallback(String code,String callbackUrl){
         super(code,callbackUrl);
     }
 
+    public void setReplyMessageService(ReplyMessageService replyMessageService) {
+        this.replyMessageService = replyMessageService;
+    }
+
     @Override
-    public boolean process(String openId, String eventKey) {
+    public boolean process(String wechatId,String openId, String eventKey) {
         boolean result = false;
 
         try {
@@ -19,17 +30,23 @@ public class PromotionCallback extends EventCallback {
 
             String promoter = arr[1];
 
-            StringBuilder msgBuilder = new StringBuilder();
+            StringBuilder urlBuilder = new StringBuilder();
 
-            msgBuilder.append("<a href=\"");
+            urlBuilder.append(this.getCallbackUrl());
+            urlBuilder.append("?openId=" + openId);
+            urlBuilder.append("&promoter=" + URLEncoder.encode(promoter, "UTF-8"));
 
-            msgBuilder.append(this.getCallbackUrl());
-            msgBuilder.append("?openId=" + openId);
-            msgBuilder.append("&promoter=" + URLEncoder.encode(promoter, "UTF-8"));
+            ReplyMessage replyMessage = replyMessageService.findByEvent(wechatId,"promotion");
 
-            msgBuilder.append("\">请点击注册</a>");
+            if(replyMessage!=null) {
+                Map<String, Object> vars = new HashMap<>();
+                vars.put("callbackUrl", urlBuilder.toString());
 
-            setMessage(msgBuilder.toString());
+                setMessage(VelocityHelper.format(replyMessage.getMessage(), vars));
+            }
+            else{
+                setMessage("模板未配置!");
+            }
 
             result = true;
         }

+ 1 - 6
weixin-middleware/src/main/java/com/jpsoft/weixin/controller/ReplyMessageController.java

@@ -111,12 +111,7 @@ public class ReplyMessageController {
     public MessageResult<Map> pageList(
             String id,
             @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
-            @RequestParam(value="pageSize",defaultValue="20") int pageSize,
-            @RequestAttribute String subject){
-
-        //当前用户ID
-        System.out.println(subject);
-
+            @RequestParam(value="pageSize",defaultValue="20") int pageSize){
         MessageResult<Map> msgResult = new MessageResult<>();
 
         Map<String,Object> searchParams = new HashMap<>();

+ 33 - 16
weixin-middleware/src/main/java/com/jpsoft/weixin/controller/WeixinController.java

@@ -178,40 +178,54 @@ public class WeixinController {
             }
 
             //微信公众号编号
-            String toUserName = requestJson.getStr("ToUserName");
+            String wechatId = requestJson.getStr("ToUserName");
             //扫码用户openID
-            String fromUserName = requestJson.getStr("FromUserName");
+            String openId = requestJson.getStr("FromUserName");
 
-            List<EventCallback> callbackList = registerCallbackList();
+//            List<EventCallback> callbackList = registerCallbackList();
 
             boolean processed = false;
 
-            //开发者在5秒内未回复任何内容
-            for (EventCallback callback: callbackList) {
-                if (StringUtils.isNotEmpty(eventKey) && eventKey.startsWith(callback.getCode())){
-                    //fromUserName 接收方帐号(收到的OpenID)
-                    //toUserName 开发者微信号
-                    callback.process(fromUserName,eventKey);
+            if (StringUtils.isNotEmpty(eventKey) && eventKey.indexOf(",")!=-1) {
+                String[] keys = eventKey.split(",");
+                String eventCode = keys[0];
 
-                    //回复消息时,将两者颠倒
-                    WeixinUtil.replyTextMessage(response,toUserName,fromUserName,callback.getMessage());
+                ReplyMessage replyMessage = replyMessageService.findByEvent(wechatId, eventCode);
+
+                if (replyMessage != null) {
+                    EventCallback callback = new EventCallback(replyMessage.getEvent(), replyMessage.getCallbackUrl());
+
+                    callback.process(wechatId, openId, eventKey);
+
+                    WeixinUtil.replyTextMessage(response, wechatId, openId, callback.getMessage());
 
                     processed = true;
-                    break;
                 }
             }
+                //开发者在5秒内未回复任何内容
+//                for (EventCallback callback : callbackList) {
+//                    if (StringUtils.isNotEmpty(eventKey) && eventKey.startsWith(callback.getCode())) {
+//                        callback.process(wechatId, openId, eventKey);
+//
+//                        WeixinUtil.replyTextMessage(response, wechatId, openId, callback.getMessage());
+//
+//                        processed = true;
+//                        break;
+//                    }
+//                }
+//            }
 
             if(!processed) {
                 String responseText = "success";
 
                 if(event.equals("subscribe")){
-                    ReplyMessage replyMessage = replyMessageService.findByEvent(toUserName,event);
+                    ReplyMessage replyMessage = replyMessageService.findByEvent(wechatId,event);
 
                     if(replyMessage!=null) {
-                        WeixinUtil.replyTextMessage(response, toUserName, fromUserName, replyMessage.getMessage());
+                        WeixinUtil.replyTextMessage(response, wechatId, openId, replyMessage.getMessage());
                     }
                     else{
-                        log.warn(fromUserName + ",事件:" + event + "未设置自动回复!");
+                        log.warn(openId + ",事件:" + event + "未设置自动回复!");
                         response.getWriter().print(responseText);
                     }
                 }
@@ -238,9 +252,12 @@ public class WeixinController {
         list.add(new EventCallback(piccEntScanConfig.getBindingCode(),piccEntScanConfig.getBindingCallbackUrl()));
         list.add(new EventCallback(piccAdminScanConfig.getLoginCode(),piccAdminScanConfig.getLoginCallbackUrl()));
         list.add(new EventCallback(piccAdminScanConfig.getBindingCode(),piccAdminScanConfig.getBindingCallbackUrl()));
+        list.add(new EventCallback(piccAdminScanConfig.getPromotionCode(),piccAdminScanConfig.getPromotionCallbackUrl()));
+
+//        PromotionCallback promotionCallback = new PromotionCallback(piccAdminScanConfig.getPromotionCode(),piccAdminScanConfig.getPromotionCallbackUrl());
+//        promotionCallback.setReplyMessageService(replyMessageService);
 
 
-        list.add(new PromotionCallback(piccAdminScanConfig.getPromotionCode(),piccAdminScanConfig.getPromotionCallbackUrl()));
 
         return list;
     }

+ 1 - 1
weixin-middleware/src/main/java/com/jpsoft/weixin/dao/ReplyMessageDAO.java

@@ -16,5 +16,5 @@ public interface ReplyMessageDAO {
 	int delete(String id);
 	List<ReplyMessage> list();
 	List<ReplyMessage> search(Map<String,Object> searchParams,List<Sort> sortList);
-	ReplyMessage findByEvent(String id, String event);
+	ReplyMessage findByEvent(String wechatId, String event);
 }

+ 14 - 70
weixin-middleware/src/main/java/com/jpsoft/weixin/entity/ReplyMessage.java

@@ -4,6 +4,8 @@ import java.io.Serializable;
 import java.util.Date;
 import java.text.SimpleDateFormat;
 import java.math.BigDecimal;
+
+import lombok.Data;
 import org.springframework.format.annotation.DateTimeFormat;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModelProperty;
@@ -12,86 +14,28 @@ import io.swagger.annotations.ApiModel;
 /**
   描述:wechat_reply_message的实体类
  */
+@Data
 @ApiModel(value = "自动回复消息设置")
 public class ReplyMessage {
-    @ApiModelProperty(value = "微信号")
+    @ApiModelProperty(value = "号")
 	private String id;
+	@ApiModelProperty(value = "微信公众号")
+	private String wechatId;
     @ApiModelProperty(value = "事件")
 	private String event;
     @ApiModelProperty(value = "回复消息")
 	private String message;
+
+	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
+	@JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
     @ApiModelProperty(value = "创建时间")
 	private Date createTime;
+
+	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
+	@JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
     @ApiModelProperty(value = "更新时间")
 	private Date updateTime;
 
-	/**
-	 *获取微信号
-	 */
-    	public String getId(){
-		return id;
-	}
-	
-	/**
-	 *设置微信号
-	 */
-	public void setId(String id){
-		this.id = id;
-	}
-	/**
-	 *获取事件
-	 */
-    	public String getEvent(){
-		return event;
-	}
-	
-	/**
-	 *设置事件
-	 */
-	public void setEvent(String event){
-		this.event = event;
-	}
-	/**
-	 *获取回复消息
-	 */
-    	public String getMessage(){
-		return message;
-	}
-	
-	/**
-	 *设置回复消息
-	 */
-	public void setMessage(String message){
-		this.message = message;
-	}
-	/**
-	 *获取创建时间
-	 */
-    	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
-	@JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
-		public Date getCreateTime(){
-		return createTime;
-	}
-	
-	/**
-	 *设置创建时间
-	 */
-	public void setCreateTime(Date createTime){
-		this.createTime = createTime;
-	}
-	/**
-	 *获取更新时间
-	 */
-    	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
-	@JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
-		public Date getUpdateTime(){
-		return updateTime;
-	}
-	
-	/**
-	 *设置更新时间
-	 */
-	public void setUpdateTime(Date updateTime){
-		this.updateTime = updateTime;
-	}
+	@ApiModelProperty(value = "回调地址")
+	private String callbackUrl;
 }

+ 1 - 1
weixin-middleware/src/main/java/com/jpsoft/weixin/service/impl/ReplyMessageServiceImpl.java

@@ -59,7 +59,7 @@ public class ReplyMessageServiceImpl implements ReplyMessageService {
 		// TODO Auto-generated method stub
 		return replyMessageDAO.list();
 	}
-		
+
 	@Override
 	public Page<ReplyMessage> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize,List<Sort> sortList) {
         Page<ReplyMessage> page = PageHelper.startPage(pageNumber,pageSize).doSelectPage(()->{

+ 45 - 0
weixin-middleware/src/main/java/com/jpsoft/weixin/utils/VelocityHelper.java

@@ -0,0 +1,45 @@
+package com.jpsoft.weixin.utils;
+
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.Velocity;
+import org.apache.velocity.app.VelocityEngine;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.Map;
+import java.util.Properties;
+
+public class VelocityHelper {
+	private static VelocityEngine velocityEngine;
+	
+	public static synchronized VelocityEngine getEngine() {
+		if (velocityEngine==null) {
+			Properties properties=new Properties();
+			
+			properties.setProperty(Velocity.ENCODING_DEFAULT, "UTF-8");
+	        properties.setProperty(Velocity.INPUT_ENCODING, "UTF-8");
+	        properties.setProperty(Velocity.OUTPUT_ENCODING, "UTF-8");
+	        
+	        velocityEngine = new VelocityEngine(properties);
+		}
+		
+		return velocityEngine;
+	}
+	
+	public static String format(String tmplContent,Map<String,Object> variables) {
+		VelocityEngine velocityEngine = VelocityHelper.getEngine();
+		
+        VelocityContext context=new VelocityContext();
+        
+        for (String key : variables.keySet()) {
+			context.put(key, variables.get(key));
+		}
+        
+        StringWriter writer = new StringWriter();
+        StringReader reader = new StringReader(tmplContent);
+        
+        velocityEngine.evaluate(context, writer, "test", reader);
+        
+        return writer.toString();
+	}
+}

+ 1 - 1
weixin-middleware/src/main/resources/application-dev.yml

@@ -34,4 +34,4 @@ qrcode:
         bindingCode: "6001"
         bindingCallbackUrl: "http://localhost:8081/picc-admin-server/pub/qrcode/binding/scan"
         promotionCode: "7000"
-        promotionCallbackUrl: " http://vbvczi.natappfree.cc/weixin-middleware/demo"
+        promotionCallbackUrl: "http://localhost:8081/picc-admin-server/pub/qrcode/promotion/scan"

+ 1 - 1
weixin-middleware/src/main/resources/application-production.yml

@@ -35,4 +35,4 @@ qrcode:
         bindingCode: "6001"
         bindingCallbackUrl: "http://picc.jzrccs.com/picc-admin-server/pub/qrcode/binding/scan"
         promotionCode: "7000"
-        promotionCallbackUrl: " http://picc.jzrccs.com/picctg/customReg.html"
+        promotionCallbackUrl: "http://picc.jzrccs.com/picc-admin-server/pub/qrcode/promotion/scan"

+ 72 - 62
weixin-middleware/src/main/resources/mapper/ReplyMessage.xml

@@ -1,78 +1,88 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 
-"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <!-- namespace必须指向DAO接口 -->
 <mapper namespace="com.jpsoft.weixin.dao.ReplyMessageDAO">
-	<resultMap id="ReplyMessageMap" type="com.jpsoft.weixin.entity.ReplyMessage">
-		<id property="id" column="id_" />
-			<result property="event" column="event_" />
-			<result property="message" column="message_" />
-			<result property="createTime" column="create_time" />
-			<result property="updateTime" column="update_time" />
-			</resultMap>
-	<insert id="insert" parameterType="com.jpsoft.weixin.entity.ReplyMessage">
-	<!--
-	<selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
-		select sys_guid() from dual
-	</selectKey>
-	-->
-	<![CDATA[
+    <resultMap id="ReplyMessageMap" type="com.jpsoft.weixin.entity.ReplyMessage">
+        <id property="id" column="id_"/>
+        <result property="wechatId" column="wechat_id"/>
+        <result property="event" column="event_"/>
+        <result property="message" column="message_"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="callbackUrl" column="callback_url"/>
+    </resultMap>
+    <insert id="insert" parameterType="com.jpsoft.weixin.entity.ReplyMessage">
+        <!--
+        <selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
+            select sys_guid() from dual
+        </selectKey>
+        -->
+        <![CDATA[
 		insert into wechat_reply_message
-	    (id_,event_,message_,create_time,update_time)
+	    (id_,wechat_id,event_,message_,create_time,update_time,callback_url)
 		values
 		(
 			#{id,jdbcType=VARCHAR}
+			,#{wechatId,jdbcType=VARCHAR}
 			,#{event,jdbcType=VARCHAR}
 			,#{message,jdbcType=VARCHAR}
 			,#{createTime,jdbcType= TIMESTAMP }
 			,#{updateTime,jdbcType= TIMESTAMP }
+			,#{callbackUrl,jdbcType=VARCHAR}
 		)
 	]]>
-	</insert>
-	<delete id="delete" parameterType="string">
-		delete from wechat_reply_message where id_=#{id,jdbcType=VARCHAR}
-	</delete>
-	<update id="update" parameterType="com.jpsoft.weixin.entity.ReplyMessage">
-		update wechat_reply_message
-		<set>
-				<if test="event!=null">
-		event_=#{event,jdbcType=VARCHAR},
-		</if>
-				<if test="message!=null">
-		message_=#{message,jdbcType=VARCHAR},
-		</if>
-				<if test="createTime!=null">
-		create_time=#{createTime,jdbcType= TIMESTAMP },
-		</if>
-				<if test="updateTime!=null">
-		update_time=#{updateTime,jdbcType= TIMESTAMP },
-		</if>
-		</set>
-	where id_=#{id}
-	</update>
-	<select id="get" parameterType="string" resultMap="ReplyMessageMap">
-		select * from wechat_reply_message where id_=#{0}
-	</select>
-	<select id="exist" parameterType="string" resultType="int">
-		select count(*) from wechat_reply_message where id_=#{0}
-	</select>
-	<select id="list" resultMap="ReplyMessageMap">
-		select * from wechat_reply_message
-	</select>
-	<select id="search" parameterType="hashmap" resultMap="ReplyMessageMap">
-		<![CDATA[
+    </insert>
+    <delete id="delete" parameterType="string">
+        delete from wechat_reply_message where id_=#{id,jdbcType=VARCHAR}
+    </delete>
+    <update id="update" parameterType="com.jpsoft.weixin.entity.ReplyMessage">
+        update wechat_reply_message
+        <set>
+            <if test="wechatId!=null">
+                wechat_id=#{wechatId,jdbcType=VARCHAR},
+            </if>
+            <if test="event!=null">
+                event_=#{event,jdbcType=VARCHAR},
+            </if>
+            <if test="message!=null">
+                message_=#{message,jdbcType=VARCHAR},
+            </if>
+            <if test="createTime!=null">
+                create_time=#{createTime,jdbcType= TIMESTAMP },
+            </if>
+            <if test="updateTime!=null">
+                update_time=#{updateTime,jdbcType= TIMESTAMP },
+            </if>
+            <if test="callbackUrl!=null">
+                callback_url=#{callbackUrl,jdbcType=VARCHAR},
+            </if>
+        </set>
+        where id_=#{id}
+    </update>
+    <select id="get" parameterType="string" resultMap="ReplyMessageMap">
+        select * from wechat_reply_message where id_=#{0}
+    </select>
+    <select id="exist" parameterType="string" resultType="int">
+        select count(*) from wechat_reply_message where id_=#{0}
+    </select>
+    <select id="list" resultMap="ReplyMessageMap">
+        select * from wechat_reply_message
+    </select>
+    <select id="search" parameterType="hashmap" resultMap="ReplyMessageMap">
+        <![CDATA[
 			select * from wechat_reply_message
 		]]>
-		<where>
-			<if test="searchParams.id != null">
-				and ID_ like #{searchParams.id}
-			</if>
-		</where>
-		<foreach item="sort" collection="sortList"  open="order by" separator=",">
-	        ${sort.name} ${sort.order}
-	 	</foreach>
-	</select>
-	<select id="findByEvent" resultMap="ReplyMessageMap">
-		select * from wechat_reply_message where id_=#{id} and event_=#{event} limit 1
-	</select>
+        <where>
+            <if test="searchParams.id != null">
+                and ID_ like #{searchParams.id}
+            </if>
+        </where>
+        <foreach item="sort" collection="sortList" open="order by" separator=",">
+            ${sort.name} ${sort.order}
+        </foreach>
+    </select>
+    <select id="findByEvent" resultMap="ReplyMessageMap">
+        select * from wechat_reply_message where wechat_id=#{wechatId} and event_=#{event} limit 1
+    </select>
 </mapper>