张延森 il y a 3 ans
Parent
révision
48d9354448
21 fichiers modifiés avec 384 ajouts et 74 suppressions
  1. 14
    0
      pom.xml
  2. 5
    0
      src/main/java/com/njyunzhi/pet_identity/common/Constants.java
  3. 9
    0
      src/main/java/com/njyunzhi/pet_identity/common/DateUtils.java
  4. 1
    1
      src/main/java/com/njyunzhi/pet_identity/config/SaTokenConfigure.java
  5. 86
    25
      src/main/java/com/njyunzhi/pet_identity/controller/TaApplicationController.java
  6. 5
    4
      src/main/java/com/njyunzhi/pet_identity/controller/TaOrderController.java
  7. 18
    18
      src/main/java/com/njyunzhi/pet_identity/controller/TaPersonController.java
  8. 36
    5
      src/main/java/com/njyunzhi/pet_identity/controller/TaPetController.java
  9. 55
    3
      src/main/java/com/njyunzhi/pet_identity/controller/TaPetIdentityController.java
  10. 15
    14
      src/main/java/com/njyunzhi/pet_identity/controller/WxPayController.java
  11. 3
    0
      src/main/java/com/njyunzhi/pet_identity/entity/TaOrder.java
  12. 3
    0
      src/main/java/com/njyunzhi/pet_identity/mapper/TaOrderMapper.java
  13. 4
    0
      src/main/java/com/njyunzhi/pet_identity/mapper/TaSequenceMapper.java
  14. 9
    1
      src/main/java/com/njyunzhi/pet_identity/service/ITaOrderService.java
  15. 2
    0
      src/main/java/com/njyunzhi/pet_identity/service/ITaPetIdentityService.java
  16. 1
    0
      src/main/java/com/njyunzhi/pet_identity/service/ITaSequenceService.java
  17. 90
    0
      src/main/java/com/njyunzhi/pet_identity/service/impl/TaOrderServiceImpl.java
  18. 14
    2
      src/main/java/com/njyunzhi/pet_identity/service/impl/TaPetIdentityServiceImpl.java
  19. 4
    0
      src/main/java/com/njyunzhi/pet_identity/service/impl/TaSequenceServiceImpl.java
  20. 1
    1
      src/main/resources/application.yml
  21. 9
    0
      src/main/resources/mapper/TaOrderMapper.xml

+ 14
- 0
pom.xml Voir le fichier

159
 						<artifactId>maven-resources-plugin</artifactId>
159
 						<artifactId>maven-resources-plugin</artifactId>
160
 						<configuration>
160
 						<configuration>
161
 							<encoding>UTF-8</encoding>
161
 							<encoding>UTF-8</encoding>
162
+							<nonFilteredFileExtensions>
163
+								<nonFilteredFileExtension>pem</nonFilteredFileExtension>
164
+								<nonFilteredFileExtension>pfx</nonFilteredFileExtension>
165
+								<nonFilteredFileExtension>p12</nonFilteredFileExtension>
166
+							</nonFilteredFileExtensions>
162
 						</configuration>
167
 						</configuration>
163
 					</plugin>
168
 					</plugin>
164
 				</plugins>
169
 				</plugins>
168
 						<filtering>true</filtering>
173
 						<filtering>true</filtering>
169
 						<includes>
174
 						<includes>
170
 							<include>**/*.xml</include>
175
 							<include>**/*.xml</include>
176
+							<include>**/*.p12</include>
177
+							<include>**/*.pem</include>
171
 <!--							<include>*.xlsx</include>-->
178
 <!--							<include>*.xlsx</include>-->
172
 							<include>application.yml</include>
179
 							<include>application.yml</include>
173
 							<include>application-${profileActive}.yml</include>
180
 							<include>application-${profileActive}.yml</include>
210
 						<artifactId>maven-resources-plugin</artifactId>
217
 						<artifactId>maven-resources-plugin</artifactId>
211
 						<configuration>
218
 						<configuration>
212
 							<encoding>UTF-8</encoding>
219
 							<encoding>UTF-8</encoding>
220
+							<nonFilteredFileExtensions>
221
+								<nonFilteredFileExtension>pem</nonFilteredFileExtension>
222
+								<nonFilteredFileExtension>pfx</nonFilteredFileExtension>
223
+								<nonFilteredFileExtension>p12</nonFilteredFileExtension>
224
+							</nonFilteredFileExtensions>
213
 						</configuration>
225
 						</configuration>
214
 					</plugin>
226
 					</plugin>
215
 				</plugins>
227
 				</plugins>
218
 						<directory>src/main/resources</directory>
230
 						<directory>src/main/resources</directory>
219
 						<filtering>true</filtering>
231
 						<filtering>true</filtering>
220
 						<includes>
232
 						<includes>
233
+							<include>**/*.p12</include>
234
+							<include>**/*.pem</include>
221
 							<include>**/*.xml</include>
235
 							<include>**/*.xml</include>
222
 <!--							<include>*.xlsx</include>-->
236
 <!--							<include>*.xlsx</include>-->
223
 							<include>application.yml</include>
237
 							<include>application.yml</include>

+ 5
- 0
src/main/java/com/njyunzhi/pet_identity/common/Constants.java Voir le fichier

28
     public final static int PAY_STATUS_READY = 0;  // 未支付
28
     public final static int PAY_STATUS_READY = 0;  // 未支付
29
     public final static int PAY_STATUS_PAYING = 1;  // 支付中
29
     public final static int PAY_STATUS_PAYING = 1;  // 支付中
30
     public final static int PAY_STATUS_PAID = 2;  // 已支付
30
     public final static int PAY_STATUS_PAID = 2;  // 已支付
31
+    public final static int PAY_STATUS_REFUND = 3;  // 已退款
31
 
32
 
32
     // 审核状态
33
     // 审核状态
33
     public final static int AUDIT_STATUS_READY = 0;  // 未审核
34
     public final static int AUDIT_STATUS_READY = 0;  // 未审核
50
     public final static int WORKFLOW_STATUS_AUDIT = 2;  // 已审批
51
     public final static int WORKFLOW_STATUS_AUDIT = 2;  // 已审批
51
     public final static int WORKFLOW_STATUS_MADE = 3;  // 已发证
52
     public final static int WORKFLOW_STATUS_MADE = 3;  // 已发证
52
 
53
 
54
+    // 流程进度
55
+    public final static int WORKFLOW_PROCESS_AUDIT = 1;  // 待审批
56
+    public final static int WORKFLOW_PROCESS_MADE = 2;  // 待发证
57
+
53
     // 系统参数
58
     // 系统参数
54
     public final static String SYSSETTING_EXPRESS_FEE = "express_fee";  // 快递费
59
     public final static String SYSSETTING_EXPRESS_FEE = "express_fee";  // 快递费
55
     public final static String SYSSETTING_PRODUCTION_COST = "production_cost";  // 工本费
60
     public final static String SYSSETTING_PRODUCTION_COST = "production_cost";  // 工本费

+ 9
- 0
src/main/java/com/njyunzhi/pet_identity/common/DateUtils.java Voir le fichier

48
         if (dt == null || dt.equals("")) return null;
48
         if (dt == null || dt.equals("")) return null;
49
         return from(dt + " 23:59:59", "yyyy-MM-dd HH:mm:ss");
49
         return from(dt + " 23:59:59", "yyyy-MM-dd HH:mm:ss");
50
     }
50
     }
51
+
52
+    public static String today(String ...formaters) {
53
+        String formater = "yyyy-MM-dd";
54
+        if (formaters.length > 0) {
55
+            formater = formaters[0];
56
+        }
57
+
58
+        return toString(LocalDateTime.now(ZoneId.of("Asia/Shanghai")), formater);
59
+    }
51
 }
60
 }

+ 1
- 1
src/main/java/com/njyunzhi/pet_identity/config/SaTokenConfigure.java Voir le fichier

21
         anonList.add("/swagger-ui/**");
21
         anonList.add("/swagger-ui/**");
22
         anonList.add("/swagger-resources/**");
22
         anonList.add("/swagger-resources/**");
23
         anonList.add("/v2/**");
23
         anonList.add("/v2/**");
24
-//        anonList.add("/wxpay/notify/**");
24
+        anonList.add("/wxpay/notify/**");
25
         anonList.add("/h5/**");
25
         anonList.add("/h5/**");
26
         anonList.add("/**/sms-captcha");
26
         anonList.add("/**/sms-captcha");
27
         anonList.add("/**/**/sms-captcha");
27
         anonList.add("/**/**/sms-captcha");

+ 86
- 25
src/main/java/com/njyunzhi/pet_identity/controller/TaApplicationController.java Voir le fichier

7
 import com.njyunzhi.pet_identity.common.Constants;
7
 import com.njyunzhi.pet_identity.common.Constants;
8
 import com.njyunzhi.pet_identity.common.ResponseBean;
8
 import com.njyunzhi.pet_identity.common.ResponseBean;
9
 import com.njyunzhi.pet_identity.common.StringUtils;
9
 import com.njyunzhi.pet_identity.common.StringUtils;
10
-import com.njyunzhi.pet_identity.entity.SysUser;
11
-import com.njyunzhi.pet_identity.entity.TaPerson;
12
-import com.njyunzhi.pet_identity.entity.TaPetIdentity;
10
+import com.njyunzhi.pet_identity.entity.*;
11
+import com.njyunzhi.pet_identity.service.ITaOrderService;
13
 import com.njyunzhi.pet_identity.service.ITaPetIdentityService;
12
 import com.njyunzhi.pet_identity.service.ITaPetIdentityService;
14
 import com.njyunzhi.pet_identity.vo.AuditParam;
13
 import com.njyunzhi.pet_identity.vo.AuditParam;
15
 import com.njyunzhi.pet_identity.vo.MakeCardParam;
14
 import com.njyunzhi.pet_identity.vo.MakeCardParam;
25
 import org.springframework.web.bind.annotation.RequestMethod;
24
 import org.springframework.web.bind.annotation.RequestMethod;
26
 import org.springframework.web.bind.annotation.RequestParam;
25
 import org.springframework.web.bind.annotation.RequestParam;
27
 import com.njyunzhi.pet_identity.service.ITaApplicationService;
26
 import com.njyunzhi.pet_identity.service.ITaApplicationService;
28
-import com.njyunzhi.pet_identity.entity.TaApplication;
29
 import org.springframework.web.bind.annotation.RestController;
27
 import org.springframework.web.bind.annotation.RestController;
30
 
28
 
31
 import java.time.LocalDateTime;
29
 import java.time.LocalDateTime;
30
+import java.util.ArrayList;
32
 
31
 
33
 /**
32
 /**
34
  * <p>
33
  * <p>
52
     @Autowired
51
     @Autowired
53
     public ITaPetIdentityService iTaPetIdentityService;
52
     public ITaPetIdentityService iTaPetIdentityService;
54
 
53
 
54
+    @Autowired
55
+    public ITaOrderService iTaOrderService;
56
+
55
     /**
57
     /**
56
      * 分页查询列表
58
      * 分页查询列表
57
      * @param pageNum
59
      * @param pageNum
61
     @RequestMapping(value="/admin/application",method= RequestMethod.GET)
63
     @RequestMapping(value="/admin/application",method= RequestMethod.GET)
62
     @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
64
     @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
63
     public ResponseBean taApplicationList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
65
     public ResponseBean taApplicationList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
64
-									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
66
+                                          @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
67
+                                          @ApiParam("表单进度") @RequestParam(value ="process", defaultValue = "0") Integer process) throws Exception{
65
 
68
 
66
         SysUser sysUser = currentUser();
69
         SysUser sysUser = currentUser();
67
 
70
 
69
         QueryWrapper<TaApplication> queryWrapper = new QueryWrapper<>();
72
         QueryWrapper<TaApplication> queryWrapper = new QueryWrapper<>();
70
         queryWrapper.gt("status", Constants.STATUS_DELETE);
73
         queryWrapper.gt("status", Constants.STATUS_DELETE);
71
 
74
 
72
-        // 审核人角色
73
-        if (Constants.USER_AUDITOR.equals(sysUser.getRoleName())) {
74
-            queryWrapper.ge("status", Constants.WORKFLOW_STATUS_PROCESSING);
75
-            queryWrapper.le("status", Constants.WORKFLOW_STATUS_AUDIT);
75
+        if (Constants.WORKFLOW_PROCESS_AUDIT == process) {
76
+            // 过滤待审批列表
77
+            // 必须是已交费的 或者 续期的
78
+            queryWrapper.in("status", new Integer[] { Constants.WORKFLOW_STATUS_PROCESSING, Constants.WORKFLOW_STATUS_AUDIT });
79
+            queryWrapper.nested(q -> q.eq("pay_status", Constants.PAY_STATUS_PAID).or().eq("apply_type", Constants.APPLY_TYPE_RENEWAL));
80
+        } else if (Constants.WORKFLOW_PROCESS_MADE == process) {
81
+            // 过滤待制卡列表
82
+            // 必须是审核通过的, 且是初次提审或者挂失补办的
83
+            queryWrapper.in("status", new Integer[] { Constants.WORKFLOW_STATUS_AUDIT, Constants.WORKFLOW_STATUS_MADE });
84
+            queryWrapper.eq("verify_Status", Constants.AUDIT_STATUS_PASSED);
85
+            queryWrapper.in("apply_type", new String[] { Constants.APPLY_TYPE_FIRST,  Constants.APPLY_TYPE_REISSUE});
76
         }
86
         }
77
 
87
 
78
-        // 发证(制卡)人角色
79
-        if (Constants.USER_MAKER.equals(sysUser.getRoleName())) {
80
-            queryWrapper.ge("status", Constants.WORKFLOW_STATUS_AUDIT);
81
-            queryWrapper.le("status", Constants.WORKFLOW_STATUS_MADE);
82
-        }
88
+//        // 审核人角色
89
+//        if (Constants.USER_AUDITOR.equals(sysUser.getRoleName())) {
90
+//            queryWrapper.ge("status", Constants.WORKFLOW_STATUS_PROCESSING);
91
+//            queryWrapper.le("status", Constants.WORKFLOW_STATUS_AUDIT);
92
+//        }
93
+//
94
+//        // 发证(制卡)人角色
95
+//        if (Constants.USER_MAKER.equals(sysUser.getRoleName())) {
96
+//            queryWrapper.ge("status", Constants.WORKFLOW_STATUS_AUDIT);
97
+//            queryWrapper.le("status", Constants.WORKFLOW_STATUS_MADE);
98
+//        }
83
 
99
 
84
         queryWrapper.orderByAsc("status");
100
         queryWrapper.orderByAsc("status");
85
         queryWrapper.orderByDesc("create_date");
101
         queryWrapper.orderByDesc("create_date");
136
         taApplication.setVerifyStatus(Constants.AUDIT_STATUS_READY);
152
         taApplication.setVerifyStatus(Constants.AUDIT_STATUS_READY);
137
         taApplication.setMakeStatus(Constants.MAKE_STATUS_READY);
153
         taApplication.setMakeStatus(Constants.MAKE_STATUS_READY);
138
 
154
 
155
+        if (Constants.APPLY_TYPE_RENEWAL.equals(taApplication.getApplyType())) {
156
+            // 如果是续期申请
157
+            if (StringUtils.isEmpty(taApplication.getOriginCardNo())) {
158
+                return ResponseBean.error("未找到原始证件信息");
159
+            }
160
+            TaPetIdentity taPetIdentity = iTaPetIdentityService.getExistBy("card_no", taApplication.getOriginCardNo(), false, true);
161
+            if (null == taPetIdentity) {
162
+                return ResponseBean.error("未找到原始证件信息");
163
+            }
164
+            taApplication.setStatus(Constants.WORKFLOW_STATUS_PROCESSING);
165
+        } else if (Constants.APPLY_TYPE_REISSUE.equals(taApplication.getApplyType())) {
166
+            // 如果是挂失补办
167
+            if (StringUtils.isEmpty(taApplication.getOriginCardNo())) {
168
+                return ResponseBean.error("未找到原始证件信息");
169
+            }
170
+            TaPetIdentity taPetIdentity = iTaPetIdentityService.getExistBy("card_no", taApplication.getOriginCardNo(), false, true);
171
+            if (null == taPetIdentity) {
172
+                return ResponseBean.error("未找到原始证件信息");
173
+            }
174
+
175
+            // 直接将原卡置为挂失
176
+            taPetIdentity.setStatus(Constants.CARD_STATUS_LOSS);
177
+            if (!iTaPetIdentityService.updateById(taPetIdentity)) {
178
+                return ResponseBean.error("挂失证件失败, 请重试");
179
+            }
180
+        } else {
181
+            // 当前狗狗是否存在证件
182
+            TaPetIdentity origin = iTaPetIdentityService.getByPet(taApplication.getPetId(), taApplication.getPersonId());
183
+            if (null != origin) {
184
+                return ResponseBean.error("请先挂失原始证件");
185
+            }
186
+        }
187
+
139
         if (iTaApplicationService.save(taApplication)){
188
         if (iTaApplicationService.save(taApplication)){
140
             return ResponseBean.success(taApplication);
189
             return ResponseBean.success(taApplication);
141
         } else {
190
         } else {
183
     public ResponseBean audit(@ApiParam("对象ID") @PathVariable Integer id,
232
     public ResponseBean audit(@ApiParam("对象ID") @PathVariable Integer id,
184
                                         @ApiParam("更新内容") @RequestBody AuditParam auditParam) throws Exception{
233
                                         @ApiParam("更新内容") @RequestBody AuditParam auditParam) throws Exception{
185
 
234
 
235
+        // 目前业务有 3 种, 初次申请, 挂失, 续期
236
+        // 其中 续期 不需要缴费
237
+        // 如果审核驳回,那么已缴费用, 需要原路返回
238
+
186
         SysUser sysUser = currentUser();
239
         SysUser sysUser = currentUser();
187
         if (!checkRole(sysUser.getRoleName(), Constants.USER_AUDITOR)) {
240
         if (!checkRole(sysUser.getRoleName(), Constants.USER_AUDITOR)) {
188
             return ResponseBean.error("暂无权限");
241
             return ResponseBean.error("暂无权限");
229
             if (null == taPetIdentity) {
282
             if (null == taPetIdentity) {
230
                 return ResponseBean.error("未找到原始证件信息");
283
                 return ResponseBean.error("未找到原始证件信息");
231
             }
284
             }
232
-
233
-            // 审核同意之后, 直接作废原始证件
234
-            if (Constants.AUDIT_STATUS_PASSED == auditParam.getVerifyStatus()) {
235
-                taPetIdentity.setStatus(Constants.CARD_STATUS_LOSS);
236
-                if (!iTaPetIdentityService.updateById(taPetIdentity)) {
237
-                    return ResponseBean.error("续期挂失失败, 请重试");
238
-                }
239
-            }
240
         } else {
285
         } else {
241
             return ResponseBean.error("申办业务类型不支持");
286
             return ResponseBean.error("申办业务类型不支持");
242
         }
287
         }
245
             return ResponseBean.error("当前记录已审批");
290
             return ResponseBean.error("当前记录已审批");
246
         }
291
         }
247
 
292
 
248
-        if (auditParam.getVerifyStatus() == Constants.AUDIT_STATUS_REJECT && StringUtils.isEmpty(auditParam.getRejectReason())) {
249
-            return ResponseBean.error("请填写驳回理由");
293
+        if (auditParam.getVerifyStatus() == Constants.AUDIT_STATUS_REJECT) {
294
+            if (StringUtils.isEmpty(auditParam.getRejectReason())) {
295
+                return ResponseBean.error("请填写驳回理由");
296
+            }
297
+
298
+            // 如果已经缴费, 则原路退回费用
299
+            if (Constants.PAY_STATUS_PAID == taApplication.getPayStatus()) {
300
+                iTaOrderService.refundByApplication(taApplication);
301
+            }
250
         }
302
         }
251
 
303
 
252
         taApplication.setVerifyStatus(auditParam.getVerifyStatus());
304
         taApplication.setVerifyStatus(auditParam.getVerifyStatus());
305
+        taApplication.setRejectReason(auditParam.getRejectReason());
253
         taApplication.setVerifyDate(LocalDateTime.now());
306
         taApplication.setVerifyDate(LocalDateTime.now());
254
         taApplication.setVerifyUser(sysUser.getUserId());
307
         taApplication.setVerifyUser(sysUser.getUserId());
255
         taApplication.setVerifyUserName(sysUser.getUserName());
308
         taApplication.setVerifyUserName(sysUser.getUserName());
309
+        taApplication.setStatus(Constants.WORKFLOW_STATUS_AUDIT);
256
 
310
 
257
         if (iTaApplicationService.updateById(taApplication)){
311
         if (iTaApplicationService.updateById(taApplication)){
258
             return ResponseBean.success(taApplication);
312
             return ResponseBean.success(taApplication);
297
         }
351
         }
298
 
352
 
299
         if (taApplication.getApplyMethod() == Constants.APPLY_METHOD_EXPRESS) {
353
         if (taApplication.getApplyMethod() == Constants.APPLY_METHOD_EXPRESS) {
300
-            if (StringUtils.isEmpty(taApplication.getTrackingType()) || StringUtils.isEmpty(taApplication.getTrackingNo())) {
354
+            if (StringUtils.isEmpty(makeCardParam.getTrackingType()) || StringUtils.isEmpty(makeCardParam.getTrackingNo())) {
301
                 return ResponseBean.error("请填写快递信息");
355
                 return ResponseBean.error("请填写快递信息");
356
+            } else {
357
+                taApplication.setTrackingNo(makeCardParam.getTrackingNo());
358
+                taApplication.setTrackingType(makeCardParam.getTrackingType());
302
             }
359
             }
303
         }
360
         }
304
 
361
 
311
             }
368
             }
312
         }
369
         }
313
 
370
 
371
+        // 关联证件
372
+        taApplication.setOriginCardNo(makeCardParam.getCardNo());
314
         taApplication.setMakeStatus(Constants.MAKE_STATUS_MADE);
373
         taApplication.setMakeStatus(Constants.MAKE_STATUS_MADE);
315
         taApplication.setMakeDate(LocalDateTime.now());
374
         taApplication.setMakeDate(LocalDateTime.now());
316
         taApplication.setMakeUser(sysUser.getUserId());
375
         taApplication.setMakeUser(sysUser.getUserId());
317
         taApplication.setMakeUserName(sysUser.getUserName());
376
         taApplication.setMakeUserName(sysUser.getUserName());
318
         taApplication.setTrackingType(makeCardParam.getTrackingType());
377
         taApplication.setTrackingType(makeCardParam.getTrackingType());
319
         taApplication.setTrackingNo(makeCardParam.getTrackingNo());
378
         taApplication.setTrackingNo(makeCardParam.getTrackingNo());
379
+        taApplication.setStatus(Constants.WORKFLOW_STATUS_MADE);
320
 
380
 
321
         if (iTaApplicationService.updateById(taApplication)){
381
         if (iTaApplicationService.updateById(taApplication)){
322
             TaPetIdentity newCard = iTaPetIdentityService.createNewCard(taApplication, makeCardParam);
382
             TaPetIdentity newCard = iTaPetIdentityService.createNewCard(taApplication, makeCardParam);
363
 
423
 
364
         return ResponseBean.success(taApplication);
424
         return ResponseBean.success(taApplication);
365
     }
425
     }
426
+
366
 }
427
 }

+ 5
- 4
src/main/java/com/njyunzhi/pet_identity/controller/TaOrderController.java Voir le fichier

106
 
106
 
107
         // 快递费
107
         // 快递费
108
         SysSetting expressFeeSetting = iSysSettingService.getById(Constants.SYSSETTING_EXPRESS_FEE);
108
         SysSetting expressFeeSetting = iSysSettingService.getById(Constants.SYSSETTING_EXPRESS_FEE);
109
-        Integer expressFee = Float.valueOf(expressFeeSetting.getContent()).intValue();
109
+        float expressFee = Float.parseFloat(expressFeeSetting.getContent());
110
         // 工本费
110
         // 工本费
111
         SysSetting productionCostSetting = iSysSettingService.getById(Constants.SYSSETTING_PRODUCTION_COST);
111
         SysSetting productionCostSetting = iSysSettingService.getById(Constants.SYSSETTING_PRODUCTION_COST);
112
-        Integer productionCost = Float.valueOf(productionCostSetting.getContent()).intValue();
112
+        float productionCost = Float.parseFloat(productionCostSetting.getContent());
113
 
113
 
114
         TaOrder taOrder = new TaOrder();
114
         TaOrder taOrder = new TaOrder();
115
         String orderNo = iTaOrderService.createOrderNo();
115
         String orderNo = iTaOrderService.createOrderNo();
116
         taOrder.setOrderNo(orderNo);
116
         taOrder.setOrderNo(orderNo);
117
         taOrder.setApplyId(applyId);
117
         taOrder.setApplyId(applyId);
118
-        taOrder.setProductionCost(productionCost);
118
+        taOrder.setProductionCost((int) (productionCost * 100));
119
         // 如果没有选择快递提取, 则没有快递费用
119
         // 如果没有选择快递提取, 则没有快递费用
120
-        taOrder.setExpressFee(taApplication.getApplyMethod() == 2 ? expressFee : 0);
120
+        taOrder.setExpressFee(taApplication.getApplyMethod() == 2 ? (int) (expressFee * 100) : 0);
121
         taOrder.setCharges(taOrder.getExpressFee() + taOrder.getProductionCost());
121
         taOrder.setCharges(taOrder.getExpressFee() + taOrder.getProductionCost());
122
         taOrder.setStatus(Constants.PAY_STATUS_READY);
122
         taOrder.setStatus(Constants.PAY_STATUS_READY);
123
         taOrder.setCreateDate(LocalDateTime.now());
123
         taOrder.setCreateDate(LocalDateTime.now());
153
 
153
 
154
             return ResponseBean.success(rtn);
154
             return ResponseBean.success(rtn);
155
         } catch (Exception e) {
155
         } catch (Exception e) {
156
+            e.printStackTrace();
156
             return ResponseBean.error("生成微信预支付信息失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
157
             return ResponseBean.error("生成微信预支付信息失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
157
         }
158
         }
158
     }
159
     }

+ 18
- 18
src/main/java/com/njyunzhi/pet_identity/controller/TaPersonController.java Voir le fichier

39
     @Autowired
39
     @Autowired
40
     public ITaPersonService iTaPersonService;
40
     public ITaPersonService iTaPersonService;
41
 
41
 
42
+    /**
43
+     * 分页查询列表
44
+     * @param pageNum
45
+     * @param pageSize
46
+     * @return
47
+     */
48
+    @RequestMapping(value="/admin/person",method= RequestMethod.GET)
49
+    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
50
+    public ResponseBean taPersonList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
51
+									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
42
 
52
 
43
-//    /**
44
-//     * 分页查询列表
45
-//     * @param pageNum
46
-//     * @param pageSize
47
-//     * @return
48
-//     */
49
-//    @RequestMapping(value="/taPerson",method= RequestMethod.GET)
50
-//    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
51
-//    public ResponseBean taPersonList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
52
-//									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
53
-//
54
-//        IPage<TaPerson> pg = new Page<>(pageNum, pageSize);
55
-//        QueryWrapper<TaPerson> queryWrapper = new QueryWrapper<>();
56
-//        queryWrapper.orderByDesc("create_date");
57
-//
58
-//        IPage<TaPerson> result = iTaPersonService.page(pg, queryWrapper);
59
-//        return ResponseBean.success(result);
60
-//    }
53
+        IPage<TaPerson> pg = new Page<>(pageNum, pageSize);
54
+        QueryWrapper<TaPerson> queryWrapper = new QueryWrapper<>();
55
+        queryWrapper.isNotNull("phone");
56
+        queryWrapper.orderByDesc("create_date");
57
+
58
+        IPage<TaPerson> result = iTaPersonService.page(pg, queryWrapper);
59
+        return ResponseBean.success(result);
60
+    }
61
 
61
 
62
 //    /**
62
 //    /**
63
 //     * 保存对象
63
 //     * 保存对象

+ 36
- 5
src/main/java/com/njyunzhi/pet_identity/controller/TaPetController.java Voir le fichier

7
 import com.njyunzhi.pet_identity.common.Constants;
7
 import com.njyunzhi.pet_identity.common.Constants;
8
 import com.njyunzhi.pet_identity.common.ResponseBean;
8
 import com.njyunzhi.pet_identity.common.ResponseBean;
9
 import com.njyunzhi.pet_identity.entity.TaPerson;
9
 import com.njyunzhi.pet_identity.entity.TaPerson;
10
+import com.njyunzhi.pet_identity.entity.TaPetIdentity;
11
+import com.njyunzhi.pet_identity.service.ITaPetIdentityService;
10
 import io.swagger.annotations.Api;
12
 import io.swagger.annotations.Api;
11
 import io.swagger.annotations.ApiOperation;
13
 import io.swagger.annotations.ApiOperation;
12
 import io.swagger.annotations.ApiParam;
14
 import io.swagger.annotations.ApiParam;
35
 
37
 
36
 @Api(tags = "宠物表")
38
 @Api(tags = "宠物表")
37
 @RestController
39
 @RestController
38
-@RequestMapping("/wx/{clientId}")
40
+@RequestMapping("/")
39
 public class TaPetController extends BaseController {
41
 public class TaPetController extends BaseController {
40
 
42
 
41
     private final Logger logger = LoggerFactory.getLogger(TaPetController.class);
43
     private final Logger logger = LoggerFactory.getLogger(TaPetController.class);
43
     @Autowired
45
     @Autowired
44
     public ITaPetService iTaPetService;
46
     public ITaPetService iTaPetService;
45
 
47
 
48
+    @Autowired
49
+    public ITaPetIdentityService iTaPetIdentityService;
50
+
46
 
51
 
47
     /**
52
     /**
48
      * 分页查询列表
53
      * 分页查询列表
50
      * @param pageSize
55
      * @param pageSize
51
      * @return
56
      * @return
52
      */
57
      */
53
-    @RequestMapping(value="/pet",method= RequestMethod.GET)
58
+    @RequestMapping(value="/wx/{clientId}/pet",method= RequestMethod.GET)
54
     @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
59
     @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
55
     public ResponseBean taPetList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
60
     public ResponseBean taPetList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
56
 									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception {
61
 									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception {
71
      * @param taPet 实体对象
76
      * @param taPet 实体对象
72
      * @return
77
      * @return
73
      */
78
      */
74
-    @RequestMapping(value="/pet",method= RequestMethod.POST)
79
+    @RequestMapping(value="/wx/{clientId}/pet",method= RequestMethod.POST)
75
     @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
80
     @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
76
     public ResponseBean taPetAdd(@ApiParam("保存内容") @RequestBody TaPet taPet) throws Exception {
81
     public ResponseBean taPetAdd(@ApiParam("保存内容") @RequestBody TaPet taPet) throws Exception {
77
         TaPerson taPerson = currentPerson();
82
         TaPerson taPerson = currentPerson();
106
      * @param taPet 实体对象
111
      * @param taPet 实体对象
107
      * @return
112
      * @return
108
      */
113
      */
109
-    @RequestMapping(value="/pet/{id}",method= RequestMethod.PUT)
114
+    @RequestMapping(value="/wx/{clientId}/pet/{id}",method= RequestMethod.PUT)
110
     @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
115
     @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
111
     public ResponseBean taPetUpdate(@ApiParam("对象ID") @PathVariable String id,
116
     public ResponseBean taPetUpdate(@ApiParam("对象ID") @PathVariable String id,
112
                                         @ApiParam("更新内容") @RequestBody TaPet taPet) throws Exception{
117
                                         @ApiParam("更新内容") @RequestBody TaPet taPet) throws Exception{
125
      * 根据id查询对象
130
      * 根据id查询对象
126
      * @param id  实体ID
131
      * @param id  实体ID
127
      */
132
      */
128
-    @RequestMapping(value="/pet/{id}",method= RequestMethod.GET)
133
+    @RequestMapping(value="/wx/{clientId}/pet/{id}",method= RequestMethod.GET)
129
     @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
134
     @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
130
     public ResponseBean taPetGet(@ApiParam("对象ID") @PathVariable String id) throws Exception{
135
     public ResponseBean taPetGet(@ApiParam("对象ID") @PathVariable String id) throws Exception{
131
         return ResponseBean.success(iTaPetService.getById(id));
136
         return ResponseBean.success(iTaPetService.getById(id));
132
     }
137
     }
138
+
139
+    /**
140
+     * 根据id查询对象
141
+     * @param id  实体ID
142
+     */
143
+    @RequestMapping(value="/wx/{clientId}/pet/{id}/card",method= RequestMethod.GET)
144
+    @ApiOperation(value="狗子证件", notes = "狗子证件", httpMethod = "GET", response = ResponseBean.class)
145
+    public ResponseBean getCard(@ApiParam("对象ID") @PathVariable String id) throws Exception{
146
+
147
+        TaPetIdentity taPetIdentity = iTaPetIdentityService.getExistBy("pet_id", id, false, true);
148
+
149
+        return ResponseBean.success(taPetIdentity);
150
+    }
151
+
152
+    /**
153
+     * 根据id查询对象
154
+     * @param id  实体ID
155
+     */
156
+    @RequestMapping(value="/admin/pet/{id}/card",method= RequestMethod.GET)
157
+    @ApiOperation(value="狗子证件", notes = "狗子证件", httpMethod = "GET", response = ResponseBean.class)
158
+    public ResponseBean getPetCard(@ApiParam("对象ID") @PathVariable String id) throws Exception{
159
+
160
+        TaPetIdentity taPetIdentity = iTaPetIdentityService.getExistBy("pet_id", id, false, true);
161
+
162
+        return ResponseBean.success(taPetIdentity);
163
+    }
133
 }
164
 }

+ 55
- 3
src/main/java/com/njyunzhi/pet_identity/controller/TaPetIdentityController.java Voir le fichier

3
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
3
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
 import com.baomidou.mybatisplus.core.metadata.IPage;
4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
-import com.njyunzhi.pet_identity.common.BaseController;
7
-import com.njyunzhi.pet_identity.common.Constants;
8
-import com.njyunzhi.pet_identity.common.ResponseBean;
6
+import com.njyunzhi.pet_identity.common.*;
9
 import com.njyunzhi.pet_identity.entity.TaPerson;
7
 import com.njyunzhi.pet_identity.entity.TaPerson;
8
+import com.njyunzhi.pet_identity.service.ITaSequenceService;
10
 import io.swagger.annotations.Api;
9
 import io.swagger.annotations.Api;
11
 import io.swagger.annotations.ApiOperation;
10
 import io.swagger.annotations.ApiOperation;
12
 import io.swagger.annotations.ApiParam;
11
 import io.swagger.annotations.ApiParam;
41
     @Autowired
40
     @Autowired
42
     public ITaPetIdentityService iTaPetIdentityService;
41
     public ITaPetIdentityService iTaPetIdentityService;
43
 
42
 
43
+    @Autowired
44
+    public ITaSequenceService iTaSequenceService;
45
+
46
+    /**
47
+     * 分页查询列表
48
+     * @param pageNum
49
+     * @param pageSize
50
+     * @return
51
+     */
52
+    @RequestMapping(value="/admin/card",method= RequestMethod.GET)
53
+    @ApiOperation(value="证件列表", notes = "证件列表", httpMethod = "GET", response = ResponseBean.class)
54
+    public ResponseBean getList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
55
+                               @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
56
+
57
+        IPage<TaPetIdentity> pg = new Page<>(pageNum, pageSize);
58
+        QueryWrapper<TaPetIdentity> queryWrapper = new QueryWrapper<>();
59
+        queryWrapper.gt("status", Constants.STATUS_DELETE);
60
+        queryWrapper.orderByDesc("create_date");
61
+
62
+        IPage<TaPetIdentity> result = iTaPetIdentityService.page(pg, queryWrapper);
63
+        return ResponseBean.success(result);
64
+    }
44
 
65
 
45
     /**
66
     /**
46
      * 分页查询列表
67
      * 分页查询列表
112
 //        }
133
 //        }
113
 //    }
134
 //    }
114
 
135
 
136
+    /**
137
+     * 获取证件号码
138
+     * @param id  实体ID
139
+     */
140
+    @RequestMapping(value="/admin/card/next",method= RequestMethod.GET)
141
+    @ApiOperation(value="获取证件号码", notes = "获取证件号码", httpMethod = "GET", response = ResponseBean.class)
142
+    public ResponseBean getNewNo() throws Exception{
143
+        String seqName = String.format("%s-%s", "card", DateUtils.today("yyyyMMdd"));
144
+        Integer nextVal = iTaSequenceService.getNextVal(seqName);
145
+
146
+        String cardNo = StringUtils.lpad(nextVal.toString(), "0", 3);
147
+
148
+        return ResponseBean.success(DateUtils.today("yyyyMMdd")+cardNo);
149
+    }
150
+
115
     /**
151
     /**
116
      * 根据id查询对象
152
      * 根据id查询对象
117
      * @param id  实体ID
153
      * @param id  实体ID
126
 
162
 
127
         return ResponseBean.success(taPetIdentity);
163
         return ResponseBean.success(taPetIdentity);
128
     }
164
     }
165
+
166
+
167
+    /**
168
+     * 根据id查询对象
169
+     * @param id  实体ID
170
+     */
171
+    @RequestMapping(value="/admin/card/{id}",method= RequestMethod.GET)
172
+    @ApiOperation(value="证件详情", notes = "证件详情", httpMethod = "GET", response = ResponseBean.class)
173
+    public ResponseBean getDetail(@ApiParam("对象ID") @PathVariable String id) throws Exception{
174
+        TaPetIdentity taPetIdentity = iTaPetIdentityService.getExistBy("card_id", id, false, true);
175
+        if (null == taPetIdentity) {
176
+            return ResponseBean.error("未找到证件信息");
177
+        }
178
+
179
+        return ResponseBean.success(taPetIdentity);
180
+    }
129
 }
181
 }

+ 15
- 14
src/main/java/com/njyunzhi/pet_identity/controller/WxPayController.java Voir le fichier

2
 
2
 
3
 import com.github.binarywang.wxpay.bean.notify.WxPayNotifyResponse;
3
 import com.github.binarywang.wxpay.bean.notify.WxPayNotifyResponse;
4
 import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyV3Result;
4
 import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyV3Result;
5
+import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyV3Result;
5
 import com.github.binarywang.wxpay.service.WxPayService;
6
 import com.github.binarywang.wxpay.service.WxPayService;
6
 import com.njyunzhi.pet_identity.common.BaseController;
7
 import com.njyunzhi.pet_identity.common.BaseController;
7
 import com.njyunzhi.pet_identity.common.WxUtils;
8
 import com.njyunzhi.pet_identity.common.WxUtils;
41
 
42
 
42
     }
43
     }
43
 
44
 
44
-//    @ResponseBody
45
-//    @RequestMapping("/notify/refund")
46
-//    public String refundNotify(@RequestBody String jsonData) {
47
-//        WxPayService payService = wxUtils.getPayService();
48
-//        WxPayRefundNotifyV3Result result = null;
49
-//        try {
50
-//            result = payService.parseRefundNotifyV3Result(jsonData, null);
51
-//            orderPayService.refundNotifyOrder(result.getResult());
52
-//            return WxPayNotifyResponse.success("OK");
53
-//        } catch (Exception e) {
54
-//            e.printStackTrace();
55
-//            return WxPayNotifyResponse.fail(e.getMessage());
56
-//        }
57
-//    }
45
+    @ResponseBody
46
+    @RequestMapping("/notify/refund")
47
+    public String refundNotify(@RequestBody String jsonData) {
48
+        WxPayService payService = wxUtils.getPayService();
49
+        WxPayRefundNotifyV3Result result = null;
50
+        try {
51
+            result = payService.parseRefundNotifyV3Result(jsonData, null);
52
+            iTaOrderService.refundNotifyOrder(result.getResult());
53
+            return WxPayNotifyResponse.success("OK");
54
+        } catch (Exception e) {
55
+            e.printStackTrace();
56
+            return WxPayNotifyResponse.fail(e.getMessage());
57
+        }
58
+    }
58
 
59
 
59
 }
60
 }

+ 3
- 0
src/main/java/com/njyunzhi/pet_identity/entity/TaOrder.java Voir le fichier

54
     @ApiModelProperty(value = "支付日期")
54
     @ApiModelProperty(value = "支付日期")
55
     private LocalDateTime payDate;
55
     private LocalDateTime payDate;
56
 
56
 
57
+    @ApiModelProperty(value = "退款日期")
58
+    private LocalDateTime refundDate;
59
+
57
 }
60
 }

+ 3
- 0
src/main/java/com/njyunzhi/pet_identity/mapper/TaOrderMapper.java Voir le fichier

3
 import com.njyunzhi.pet_identity.entity.TaOrder;
3
 import com.njyunzhi.pet_identity.entity.TaOrder;
4
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5
 import org.apache.ibatis.annotations.Mapper;
5
 import org.apache.ibatis.annotations.Mapper;
6
+import org.apache.ibatis.annotations.Param;
6
 import org.apache.ibatis.annotations.Select;
7
 import org.apache.ibatis.annotations.Select;
7
 
8
 
8
 /**
9
 /**
18
 
19
 
19
     @Select("SELECT UUID_SHORT()")
20
     @Select("SELECT UUID_SHORT()")
20
     String getShortUUID();
21
     String getShortUUID();
22
+
23
+    TaOrder getByApplyId(@Param("applyId") String applyId);
21
 }
24
 }

+ 4
- 0
src/main/java/com/njyunzhi/pet_identity/mapper/TaSequenceMapper.java Voir le fichier

3
 import com.njyunzhi.pet_identity.entity.TaSequence;
3
 import com.njyunzhi.pet_identity.entity.TaSequence;
4
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5
 import org.apache.ibatis.annotations.Mapper;
5
 import org.apache.ibatis.annotations.Mapper;
6
+import org.apache.ibatis.annotations.Param;
7
+import org.apache.ibatis.annotations.Select;
6
 
8
 
7
 /**
9
 /**
8
  * <p>
10
  * <p>
15
 @Mapper
17
 @Mapper
16
 public interface TaSequenceMapper extends BaseMapper<TaSequence> {
18
 public interface TaSequenceMapper extends BaseMapper<TaSequence> {
17
 
19
 
20
+    @Select("SELECT fn_nextval(#{seqName})")
21
+    Integer getNextVal(@Param("seqName") String seqName);
18
 }
22
 }

+ 9
- 1
src/main/java/com/njyunzhi/pet_identity/service/ITaOrderService.java Voir le fichier

1
 package com.njyunzhi.pet_identity.service;
1
 package com.njyunzhi.pet_identity.service;
2
 
2
 
3
 import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyV3Result;
3
 import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyV3Result;
4
+import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyV3Result;
5
+import com.njyunzhi.pet_identity.entity.TaApplication;
4
 import com.njyunzhi.pet_identity.entity.TaOrder;
6
 import com.njyunzhi.pet_identity.entity.TaOrder;
5
-import com.baomidou.mybatisplus.extension.service.IService;
7
+import com.njyunzhi.pet_identity.entity.TaPerson;
6
 
8
 
7
 /**
9
 /**
8
  * <p>
10
  * <p>
17
     void notifyOrderPay(WxPayOrderNotifyV3Result.DecryptNotifyResult result) throws Exception;
19
     void notifyOrderPay(WxPayOrderNotifyV3Result.DecryptNotifyResult result) throws Exception;
18
 
20
 
19
     String createOrderNo() throws Exception;
21
     String createOrderNo() throws Exception;
22
+
23
+    boolean refundByApplication(TaApplication taApplication) throws Exception;
24
+
25
+    TaOrder createByApplication(TaPerson taPerson, TaApplication taApplication) throws Exception;
26
+
27
+    void refundNotifyOrder(WxPayRefundNotifyV3Result.DecryptNotifyResult result) throws Exception;
20
 }
28
 }

+ 2
- 0
src/main/java/com/njyunzhi/pet_identity/service/ITaPetIdentityService.java Voir le fichier

17
     TaPetIdentity createNewCard(TaApplication taApplication, MakeCardParam makeCardParam) throws Exception;
17
     TaPetIdentity createNewCard(TaApplication taApplication, MakeCardParam makeCardParam) throws Exception;
18
 
18
 
19
     boolean extendDate(TaPetIdentity taPetIdentity) throws Exception;
19
     boolean extendDate(TaPetIdentity taPetIdentity) throws Exception;
20
+
21
+    TaPetIdentity getByPet(String petId, String personId);
20
 }
22
 }

+ 1
- 0
src/main/java/com/njyunzhi/pet_identity/service/ITaSequenceService.java Voir le fichier

13
  */
13
  */
14
 public interface ITaSequenceService extends IService<TaSequence> {
14
 public interface ITaSequenceService extends IService<TaSequence> {
15
 
15
 
16
+    Integer getNextVal(String seqName);
16
 }
17
 }

+ 90
- 0
src/main/java/com/njyunzhi/pet_identity/service/impl/TaOrderServiceImpl.java Voir le fichier

1
 package com.njyunzhi.pet_identity.service.impl;
1
 package com.njyunzhi.pet_identity.service.impl;
2
 
2
 
3
 import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyV3Result;
3
 import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyV3Result;
4
+import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyV3Result;
5
+import com.github.binarywang.wxpay.bean.request.WxPayRefundV3Request;
4
 import com.github.binarywang.wxpay.constant.WxPayConstants;
6
 import com.github.binarywang.wxpay.constant.WxPayConstants;
5
 import com.njyunzhi.pet_identity.common.Constants;
7
 import com.njyunzhi.pet_identity.common.Constants;
8
+import com.njyunzhi.pet_identity.common.ResponseBean;
6
 import com.njyunzhi.pet_identity.common.StringUtils;
9
 import com.njyunzhi.pet_identity.common.StringUtils;
10
+import com.njyunzhi.pet_identity.common.WxPayUtils;
11
+import com.njyunzhi.pet_identity.entity.SysSetting;
7
 import com.njyunzhi.pet_identity.entity.TaApplication;
12
 import com.njyunzhi.pet_identity.entity.TaApplication;
8
 import com.njyunzhi.pet_identity.entity.TaOrder;
13
 import com.njyunzhi.pet_identity.entity.TaOrder;
14
+import com.njyunzhi.pet_identity.entity.TaPerson;
9
 import com.njyunzhi.pet_identity.mapper.TaApplicationMapper;
15
 import com.njyunzhi.pet_identity.mapper.TaApplicationMapper;
10
 import com.njyunzhi.pet_identity.mapper.TaOrderMapper;
16
 import com.njyunzhi.pet_identity.mapper.TaOrderMapper;
17
+import com.njyunzhi.pet_identity.service.ISysSettingService;
11
 import com.njyunzhi.pet_identity.service.ITaOrderService;
18
 import com.njyunzhi.pet_identity.service.ITaOrderService;
12
 import org.springframework.beans.factory.annotation.Autowired;
19
 import org.springframework.beans.factory.annotation.Autowired;
13
 import org.springframework.stereotype.Service;
20
 import org.springframework.stereotype.Service;
28
     @Autowired
35
     @Autowired
29
     TaApplicationMapper applicationMapper;
36
     TaApplicationMapper applicationMapper;
30
 
37
 
38
+    @Autowired
39
+    ISysSettingService iSysSettingService;
40
+
41
+    @Autowired
42
+    WxPayUtils wxPayUtils;
43
+
31
     @Override
44
     @Override
32
     public void notifyOrderPay(WxPayOrderNotifyV3Result.DecryptNotifyResult result) throws Exception {
45
     public void notifyOrderPay(WxPayOrderNotifyV3Result.DecryptNotifyResult result) throws Exception {
33
         TaOrder taOrder = getExistBy("order_no", result.getOutTradeNo(), false, true);
46
         TaOrder taOrder = getExistBy("order_no", result.getOutTradeNo(), false, true);
53
         if (null == taApplication || Constants.STATUS_DELETE == taApplication.getStatus()) return;
66
         if (null == taApplication || Constants.STATUS_DELETE == taApplication.getStatus()) return;
54
 
67
 
55
         taApplication.setPayStatus(Constants.PAY_STATUS_PAID);
68
         taApplication.setPayStatus(Constants.PAY_STATUS_PAID);
69
+        taApplication.setStatus(Constants.WORKFLOW_STATUS_PROCESSING);
56
         applicationMapper.updateById(taApplication);
70
         applicationMapper.updateById(taApplication);
57
     }
71
     }
58
 
72
 
60
     public String createOrderNo() throws Exception {
74
     public String createOrderNo() throws Exception {
61
         return baseMapper.getShortUUID();
75
         return baseMapper.getShortUUID();
62
     }
76
     }
77
+
78
+    @Override
79
+    public boolean refundByApplication(TaApplication taApplication) throws Exception {
80
+        TaOrder taOrder = baseMapper.getByApplyId(taApplication.getApplyId().toString());
81
+
82
+        WxPayRefundV3Request request = new WxPayRefundV3Request();
83
+        request.setOutTradeNo(taOrder.getOrderNo()); // 原单号
84
+        request.setOutRefundNo("R-" + taOrder.getOrderNo()); // 退款单号
85
+        WxPayRefundV3Request.Amount amount = new  WxPayRefundV3Request.Amount();
86
+        amount.setTotal(taOrder.getCharges());
87
+        amount.setRefund(taOrder.getCharges());
88
+        amount.setCurrency("CNY");
89
+        request.setAmount(amount);
90
+        wxPayUtils.refund(request);
91
+
92
+        return true;
93
+    }
94
+
95
+    @Override
96
+    public TaOrder createByApplication(TaPerson taPerson, TaApplication taApplication) throws Exception {
97
+        if (!taPerson.getPersonId().equals(taApplication.getPersonId())) {
98
+            throw new Exception("非本人订单, 不能支付");
99
+        }
100
+
101
+        if (Constants.PAY_STATUS_PAID == taApplication.getPayStatus()) {
102
+            throw new Exception("当前申请已支付");
103
+        }
104
+
105
+        // 快递费
106
+        SysSetting expressFeeSetting = iSysSettingService.getById(Constants.SYSSETTING_EXPRESS_FEE);
107
+        float expressFee = Float.parseFloat(expressFeeSetting.getContent());
108
+        // 工本费
109
+        SysSetting productionCostSetting = iSysSettingService.getById(Constants.SYSSETTING_PRODUCTION_COST);
110
+        float productionCost = Float.parseFloat(productionCostSetting.getContent());
111
+
112
+        TaOrder taOrder = new TaOrder();
113
+        String orderNo = createOrderNo();
114
+        taOrder.setOrderNo(orderNo);
115
+        taOrder.setApplyId(taApplication.getApplyId().toString());
116
+        taOrder.setProductionCost((int) (productionCost * 100));
117
+        // 如果没有选择快递提取, 则没有快递费用
118
+        taOrder.setExpressFee(taApplication.getApplyMethod() == 2 ? (int) (expressFee * 100) : 0);
119
+        taOrder.setCharges(taOrder.getExpressFee() + taOrder.getProductionCost());
120
+        taOrder.setStatus(Constants.PAY_STATUS_READY);
121
+        taOrder.setCreateDate(LocalDateTime.now());
122
+
123
+        if (save(taOrder)) {
124
+            return taOrder;
125
+        } else {
126
+            throw new Exception("生成订单失败");
127
+        }
128
+    }
129
+
130
+    @Override
131
+    public void refundNotifyOrder(WxPayRefundNotifyV3Result.DecryptNotifyResult result) throws Exception {
132
+        String orderNo = result.getOutTradeNo();
133
+        TaOrder taOrder = getExistBy("order_no", orderNo, false, true);
134
+        if (null == taOrder) {
135
+            log.error("退款通知处理失败: 单号 " + orderNo);
136
+            log.error(result.toString());
137
+            return;
138
+        }
139
+
140
+        boolean isSuccess = WxPayConstants.RefundStatus.SUCCESS.equals(result.getRefundStatus());
141
+        if (isSuccess) {
142
+            // 更新订单
143
+            taOrder.setStatus(Constants.PAY_STATUS_REFUND);
144
+            taOrder.setRefundDate(LocalDateTime.now());
145
+            updateById(taOrder);
146
+            // 更新申请
147
+            TaApplication taApplication = applicationMapper.selectById(taOrder.getApplyId());
148
+            taApplication.setPayStatus(Constants.PAY_STATUS_REFUND);
149
+            applicationMapper.updateById(taApplication);
150
+        }
151
+
152
+    }
63
 }
153
 }

+ 14
- 2
src/main/java/com/njyunzhi/pet_identity/service/impl/TaPetIdentityServiceImpl.java Voir le fichier

1
 package com.njyunzhi.pet_identity.service.impl;
1
 package com.njyunzhi.pet_identity.service.impl;
2
 
2
 
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
3
 import com.njyunzhi.pet_identity.common.Constants;
4
 import com.njyunzhi.pet_identity.common.Constants;
4
 import com.njyunzhi.pet_identity.common.DateUtils;
5
 import com.njyunzhi.pet_identity.common.DateUtils;
5
 import com.njyunzhi.pet_identity.entity.SysSetting;
6
 import com.njyunzhi.pet_identity.entity.SysSetting;
52
         taPetIdentity.setPetImg2(taApplication.getImg2());
53
         taPetIdentity.setPetImg2(taApplication.getImg2());
53
         taPetIdentity.setAddress(taApplication.getAddress());
54
         taPetIdentity.setAddress(taApplication.getAddress());
54
         taPetIdentity.setStartDate(DateUtils.toString(now, "yyyy-MM-dd"));
55
         taPetIdentity.setStartDate(DateUtils.toString(now, "yyyy-MM-dd"));
55
-        taPetIdentity.setStartDate(DateUtils.toString(expire, "yyyy-MM-dd"));
56
+        taPetIdentity.setExpireDate(DateUtils.toString(expire, "yyyy-MM-dd"));
56
         taPetIdentity.setStatus(Constants.STATUS_NORMAL);
57
         taPetIdentity.setStatus(Constants.STATUS_NORMAL);
57
         taPetIdentity.setCreateDate(now);
58
         taPetIdentity.setCreateDate(now);
58
 
59
 
73
         LocalDateTime expire = now.plusDays(Long.parseLong(sysSetting.getContent()));
74
         LocalDateTime expire = now.plusDays(Long.parseLong(sysSetting.getContent()));
74
 
75
 
75
         taPetIdentity.setStartDate(DateUtils.toString(now, "yyyy-MM-dd"));
76
         taPetIdentity.setStartDate(DateUtils.toString(now, "yyyy-MM-dd"));
76
-        taPetIdentity.setStartDate(DateUtils.toString(expire, "yyyy-MM-dd"));
77
+        taPetIdentity.setExpireDate(DateUtils.toString(expire, "yyyy-MM-dd"));
77
 
78
 
78
         return updateById(taPetIdentity);
79
         return updateById(taPetIdentity);
79
     }
80
     }
81
+
82
+    @Override
83
+    public TaPetIdentity getByPet(String petId, String personId) {
84
+        QueryWrapper<TaPetIdentity> queryWrapper = new QueryWrapper<>();
85
+        queryWrapper.eq("pet_id", petId);
86
+        queryWrapper.eq("person_id", personId);
87
+        queryWrapper.in("status", new Integer[] { Constants.CARD_STATUS_NORMAL, Constants.CARD_STATUS_EXPIRE });
88
+        queryWrapper.last("limit 1");
89
+
90
+        return getOne(queryWrapper);
91
+    }
80
 }
92
 }

+ 4
- 0
src/main/java/com/njyunzhi/pet_identity/service/impl/TaSequenceServiceImpl.java Voir le fichier

17
 @Service
17
 @Service
18
 public class TaSequenceServiceImpl extends ServiceImpl<TaSequenceMapper, TaSequence> implements ITaSequenceService {
18
 public class TaSequenceServiceImpl extends ServiceImpl<TaSequenceMapper, TaSequence> implements ITaSequenceService {
19
 
19
 
20
+    @Override
21
+    public Integer getNextVal(String seqName) {
22
+        return baseMapper.getNextVal(seqName);
23
+    }
20
 }
24
 }

+ 1
- 1
src/main/resources/application.yml Voir le fichier

41
 ###
41
 ###
42
 yz:
42
 yz:
43
   default:
43
   default:
44
-    servBase: https://xxx
44
+    servBase: https://pet-certificate-online.njyunzhi.com/api
45
   sms:
45
   sms:
46
     ## ??????
46
     ## ??????
47
     appid: ubpa
47
     appid: ubpa

+ 9
- 0
src/main/resources/mapper/TaOrderMapper.xml Voir le fichier

2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
 <mapper namespace="com.njyunzhi.pet_identity.mapper.TaOrderMapper">
3
 <mapper namespace="com.njyunzhi.pet_identity.mapper.TaOrderMapper">
4
 
4
 
5
+    <select id="getByApplyId" resultType="com.njyunzhi.pet_identity.entity.TaOrder">
6
+        SELECT
7
+            *
8
+        FROM
9
+            ta_order t
10
+        WHERE
11
+            t.apply_id = #{applyId}
12
+          AND t.`status` = 2
13
+    </select>
5
 </mapper>
14
 </mapper>