张延森 4 年 前
コミット
abb0942d7d
共有21 個のファイルを変更した335 個の追加101 個の削除を含む
  1. 2
    1
      src/main/java/com/yunzhi/niucai/controller/PayController.java
  2. 1
    1
      src/main/java/com/yunzhi/niucai/controller/TaCustomerAccountController.java
  3. 1
    1
      src/main/java/com/yunzhi/niucai/controller/TaOrderController.java
  4. 0
    67
      src/main/java/com/yunzhi/niucai/controller/TaShopController.java
  5. 3
    0
      src/main/java/com/yunzhi/niucai/entity/TaOrder.java
  6. 49
    0
      src/main/java/com/yunzhi/niucai/entity/TaShopAccount.java
  7. 61
    0
      src/main/java/com/yunzhi/niucai/entity/TaShopBill.java
  8. 18
    0
      src/main/java/com/yunzhi/niucai/mapper/TaShopAccountMapper.java
  9. 18
    0
      src/main/java/com/yunzhi/niucai/mapper/TaShopBillMapper.java
  10. 2
    1
      src/main/java/com/yunzhi/niucai/service/ITaCustomerAccountService.java
  11. 1
    1
      src/main/java/com/yunzhi/niucai/service/ITaOrderService.java
  12. 20
    0
      src/main/java/com/yunzhi/niucai/service/ITaShopAccountService.java
  13. 1
    0
      src/main/java/com/yunzhi/niucai/service/ITaShopAppService.java
  14. 16
    0
      src/main/java/com/yunzhi/niucai/service/ITaShopBillService.java
  15. 29
    14
      src/main/java/com/yunzhi/niucai/service/impl/TaCustomerAccountServiceImpl.java
  16. 5
    2
      src/main/java/com/yunzhi/niucai/service/impl/TaOrderPayServiceImpl.java
  17. 12
    13
      src/main/java/com/yunzhi/niucai/service/impl/TaOrderServiceImpl.java
  18. 66
    0
      src/main/java/com/yunzhi/niucai/service/impl/TaShopAccountServiceImpl.java
  19. 20
    0
      src/main/java/com/yunzhi/niucai/service/impl/TaShopBillServiceImpl.java
  20. 5
    0
      src/main/resources/mapper/TaShopAccountMapper.xml
  21. 5
    0
      src/main/resources/mapper/TaShopBillMapper.xml

+ 2
- 1
src/main/java/com/yunzhi/niucai/controller/PayController.java ファイルの表示

@@ -220,7 +220,8 @@ public class PayController extends BaseController {
220 220
         }
221 221
 
222 222
         try {
223
-            iTaOrderService.payCallback(taOrder, outTradeNo, payStatus, failMessage, isSuccess, payTime);
223
+            TaOrderPay taOrderPay = iTaOrderPayService.getByTradeNo(outTradeNo);
224
+            iTaOrderService.payCallback(taOrder, taOrderPay, payStatus, failMessage, isSuccess, payTime);
224 225
         } catch (Exception e) {
225 226
             e.printStackTrace();
226 227
             log.error("支付回调处理失败[{}]: {}", outTradeNo, e.getMessage());

+ 1
- 1
src/main/java/com/yunzhi/niucai/controller/TaCustomerAccountController.java ファイルの表示

@@ -113,7 +113,7 @@ public class TaCustomerAccountController extends BaseController {
113 113
         payService.FundTrans(transParam);
114 114
 
115 115
         // 成功之后
116
-        iTaOrderService.payCallback(taOrder, taOrderPay.getTradeNo(), "SUCCESS", null, true, LocalDateTime.now());
116
+        iTaOrderService.payCallback(taOrder, taOrderPay, "SUCCESS", null, true, LocalDateTime.now());
117 117
 
118 118
         return ResponseBean.success("success");
119 119
     }

+ 1
- 1
src/main/java/com/yunzhi/niucai/controller/TaOrderController.java ファイルの表示

@@ -184,7 +184,7 @@ public class TaOrderController extends BaseController {
184 184
         payService.FundTrans(transParam);
185 185
 
186 186
         // 成功之后
187
-        iTaOrderService.payCallback(taOrder, taOrderPay.getTradeNo(), "SUCCESS", null, true, LocalDateTime.now());
187
+        iTaOrderService.payCallback(taOrder, taOrderPay, "SUCCESS", null, true, LocalDateTime.now());
188 188
 
189 189
         customerBetting.setIsCashed(true);
190 190
         iTaCustomerBettingService.updateById(customerBetting);

+ 0
- 67
src/main/java/com/yunzhi/niucai/controller/TaShopController.java ファイルの表示

@@ -92,73 +92,6 @@ public class TaShopController extends BaseController {
92 92
         return ResponseBean.success(updatedValidInfo);
93 93
     }
94 94
 
95
-//    /**
96
-//     * 分页查询列表
97
-//     * @param pageNum
98
-//     * @param pageSize
99
-//     * @return
100
-//     */
101
-//    @RequestMapping(value="/app/shop",method= RequestMethod.GET)
102
-//    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
103
-//    public ResponseBean taShopList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
104
-//                                   @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
105
-//
106
-//		    IPage<TaShop> pg = new Page<>(pageNum, pageSize);
107
-//            QueryWrapper<TaShop> queryWrapper = new QueryWrapper<>();
108
-//            queryWrapper.orderByDesc("create_date");
109
-//
110
-//            IPage<TaShop> result = iTaShopService.page(pg, queryWrapper);
111
-//            return ResponseBean.success(result);
112
-//    }
113
-//
114
-//    /**
115
-//     * 保存对象
116
-//     * @param taShop 实体对象
117
-//     * @return
118
-//     */
119
-//    @RequestMapping(value="/taShop",method= RequestMethod.POST)
120
-//    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
121
-//    public ResponseBean taShopAdd(@ApiParam("保存内容") @RequestBody TaShop taShop) throws Exception{
122
-//
123
-//        if (iTaShopService.save(taShop)){
124
-//            return ResponseBean.success(taShop);
125
-//        }else {
126
-//            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
127
-//        }
128
-//    }
129
-//
130
-//    /**
131
-//     * 根据id删除对象
132
-//     * @param id  实体ID
133
-//     */
134
-//    @RequestMapping(value="/taShop/{id}", method= RequestMethod.DELETE)
135
-//    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
136
-//    public ResponseBean taShopDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
137
-//        if(iTaShopService.removeById(id)){
138
-//            return ResponseBean.success("success");
139
-//        }else {
140
-//            return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
141
-//        }
142
-//    }
143
-//
144
-//    /**
145
-//     * 修改对象
146
-//     * @param id  实体ID
147
-//     * @param taShop 实体对象
148
-//     * @return
149
-//     */
150
-//    @RequestMapping(value="/taShop/{id}",method= RequestMethod.PUT)
151
-//    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
152
-//    public ResponseBean taShopUpdate(@ApiParam("对象ID") @PathVariable Integer id,
153
-//                                        @ApiParam("更新内容") @RequestBody TaShop taShop) throws Exception{
154
-//
155
-//        if (iTaShopService.updateById(taShop)){
156
-//            return ResponseBean.success(iTaShopService.getById(id));
157
-//        }else {
158
-//            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
159
-//        }
160
-//    }
161
-//
162 95
     /**
163 96
      * 查询当前店铺信息
164 97
      */

+ 3
- 0
src/main/java/com/yunzhi/niucai/entity/TaOrder.java ファイルの表示

@@ -71,6 +71,9 @@ public class TaOrder implements Serializable {
71 71
     @ApiModelProperty(value = "更新时间")
72 72
     private LocalDateTime updateDate;
73 73
 
74
+    @ApiModelProperty(value = "原始订单")
75
+    private String srcOrder;
76
+
74 77
     @ApiModelProperty(value = "客户投注")
75 78
     @TableField(exist = false)
76 79
     private TaCustomerBetting customerBetting;

+ 49
- 0
src/main/java/com/yunzhi/niucai/entity/TaShopAccount.java ファイルの表示

@@ -0,0 +1,49 @@
1
+package com.yunzhi.niucai.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableId;
5
+import java.time.LocalDateTime;
6
+import java.io.Serializable;
7
+import io.swagger.annotations.ApiModel;
8
+import io.swagger.annotations.ApiModelProperty;
9
+import lombok.Data;
10
+import lombok.EqualsAndHashCode;
11
+import lombok.experimental.Accessors;
12
+
13
+/**
14
+ * <p>
15
+ * 店铺账户
16
+ * </p>
17
+ *
18
+ * @author yansen
19
+ * @since 2020-10-19
20
+ */
21
+@Data
22
+@EqualsAndHashCode(callSuper = false)
23
+@Accessors(chain = true)
24
+@ApiModel(value="TaShopAccount对象", description="店铺账户")
25
+public class TaShopAccount implements Serializable {
26
+
27
+    private static final long serialVersionUID = 1L;
28
+
29
+    @ApiModelProperty(value = "账户ID")
30
+    @TableId(value = "account_id", type = IdType.AUTO)
31
+    private Integer accountId;
32
+
33
+    @ApiModelProperty(value = "店铺ID")
34
+    private Integer shopId;
35
+
36
+    @ApiModelProperty(value = "余额 单位分")
37
+    private Integer amount;
38
+
39
+    @ApiModelProperty(value = "充值 单位分")
40
+    private Integer cash;
41
+
42
+    @ApiModelProperty(value = "创建时间")
43
+    private LocalDateTime createDate;
44
+
45
+    @ApiModelProperty(value = "状态")
46
+    private Integer status;
47
+
48
+
49
+}

+ 61
- 0
src/main/java/com/yunzhi/niucai/entity/TaShopBill.java ファイルの表示

@@ -0,0 +1,61 @@
1
+package com.yunzhi.niucai.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableId;
5
+import java.time.LocalDateTime;
6
+import java.io.Serializable;
7
+import io.swagger.annotations.ApiModel;
8
+import io.swagger.annotations.ApiModelProperty;
9
+import lombok.Data;
10
+import lombok.EqualsAndHashCode;
11
+import lombok.experimental.Accessors;
12
+
13
+/**
14
+ * <p>
15
+ * 店铺账户流水
16
+ * </p>
17
+ *
18
+ * @author yansen
19
+ * @since 2020-10-19
20
+ */
21
+@Data
22
+@EqualsAndHashCode(callSuper = false)
23
+@Accessors(chain = true)
24
+@ApiModel(value="TaShopBill对象", description="店铺账户流水")
25
+public class TaShopBill implements Serializable {
26
+
27
+    private static final long serialVersionUID = 1L;
28
+
29
+    @ApiModelProperty(value = "流水序号")
30
+    @TableId(value = "serial_no", type = IdType.AUTO)
31
+    private Integer serialNo;
32
+
33
+    @ApiModelProperty(value = "账户ID")
34
+    private Integer accountId;
35
+
36
+    @ApiModelProperty(value = "店铺ID")
37
+    private Integer shopId;
38
+
39
+    @ApiModelProperty(value = "费用类型")
40
+    private String feeType;
41
+
42
+    @ApiModelProperty(value = "费用简介")
43
+    private String summary;
44
+
45
+    @ApiModelProperty(value = "金额 单位分")
46
+    private Integer amount;
47
+
48
+    @ApiModelProperty(value = "收支类型 1收,-1支")
49
+    private Integer feeSign;
50
+
51
+    @ApiModelProperty(value = "订单号")
52
+    private String orderId;
53
+
54
+    @ApiModelProperty(value = "创建时间")
55
+    private LocalDateTime createDate;
56
+
57
+    @ApiModelProperty(value = "状态")
58
+    private Integer status;
59
+
60
+
61
+}

+ 18
- 0
src/main/java/com/yunzhi/niucai/mapper/TaShopAccountMapper.java ファイルの表示

@@ -0,0 +1,18 @@
1
+package com.yunzhi.niucai.mapper;
2
+
3
+import com.yunzhi.niucai.entity.TaShopAccount;
4
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5
+import org.apache.ibatis.annotations.Mapper;
6
+
7
+/**
8
+ * <p>
9
+ * 店铺账户 Mapper 接口
10
+ * </p>
11
+ *
12
+ * @author yansen
13
+ * @since 2020-10-19
14
+ */
15
+@Mapper
16
+public interface TaShopAccountMapper extends BaseMapper<TaShopAccount> {
17
+
18
+}

+ 18
- 0
src/main/java/com/yunzhi/niucai/mapper/TaShopBillMapper.java ファイルの表示

@@ -0,0 +1,18 @@
1
+package com.yunzhi.niucai.mapper;
2
+
3
+import com.yunzhi.niucai.entity.TaShopBill;
4
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5
+import org.apache.ibatis.annotations.Mapper;
6
+
7
+/**
8
+ * <p>
9
+ * 店铺账户流水 Mapper 接口
10
+ * </p>
11
+ *
12
+ * @author yansen
13
+ * @since 2020-10-19
14
+ */
15
+@Mapper
16
+public interface TaShopBillMapper extends BaseMapper<TaShopBill> {
17
+
18
+}

+ 2
- 1
src/main/java/com/yunzhi/niucai/service/ITaCustomerAccountService.java ファイルの表示

@@ -4,6 +4,7 @@ import com.yunzhi.niucai.entity.TaCustomer;
4 4
 import com.yunzhi.niucai.entity.TaCustomerAccount;
5 5
 import com.baomidou.mybatisplus.extension.service.IService;
6 6
 import com.yunzhi.niucai.entity.TaOrder;
7
+import com.yunzhi.niucai.entity.TaOrderPay;
7 8
 
8 9
 /**
9 10
  * <p>
@@ -17,7 +18,7 @@ public interface ITaCustomerAccountService extends IService<TaCustomerAccount> {
17 18
 
18 19
     boolean newAccountBy(TaCustomer taCustomer) throws Exception;
19 20
 
20
-    void createBillBy(TaOrder taOrder, String feeType) throws Exception;
21
+    void createBillBy(TaOrder taOrder, TaOrderPay taOrderPay) throws Exception;
21 22
 
22 23
     TaCustomerAccount getByCustomer(Integer customerId) throws Exception;
23 24
 }

+ 1
- 1
src/main/java/com/yunzhi/niucai/service/ITaOrderService.java ファイルの表示

@@ -48,7 +48,7 @@ public interface ITaOrderService extends IService<TaOrder> {
48 48
      * @param isSuccess
49 49
      * @param payTime
50 50
      */
51
-    void payCallback(TaOrder taOrder, String outTradeNo, String payStatus, String failMessage, Boolean isSuccess, LocalDateTime payTime) throws Exception;
51
+    void payCallback(TaOrder taOrder, TaOrderPay taOrderPay, String payStatus, String failMessage, Boolean isSuccess, LocalDateTime payTime) throws Exception;
52 52
 
53 53
     /**
54 54
      * 转账提现订单

+ 20
- 0
src/main/java/com/yunzhi/niucai/service/ITaShopAccountService.java ファイルの表示

@@ -0,0 +1,20 @@
1
+package com.yunzhi.niucai.service;
2
+
3
+import com.yunzhi.niucai.entity.TaOrder;
4
+import com.yunzhi.niucai.entity.TaShopAccount;
5
+import com.baomidou.mybatisplus.extension.service.IService;
6
+
7
+/**
8
+ * <p>
9
+ * 店铺账户 服务类
10
+ * </p>
11
+ *
12
+ * @author yansen
13
+ * @since 2020-10-19
14
+ */
15
+public interface ITaShopAccountService extends IService<TaShopAccount> {
16
+
17
+    void createBill(TaOrder taOrder, String feeType, Integer charge, int feeSign) throws Exception;
18
+
19
+    void createPlatBill(TaOrder taOrder, String feeType, Integer charge, int feeSign) throws Exception;
20
+}

+ 1
- 0
src/main/java/com/yunzhi/niucai/service/ITaShopAppService.java ファイルの表示

@@ -1,5 +1,6 @@
1 1
 package com.yunzhi.niucai.service;
2 2
 
3
+import com.yunzhi.niucai.entity.TaOrder;
3 4
 import com.yunzhi.niucai.entity.TaShopApp;
4 5
 import com.baomidou.mybatisplus.extension.service.IService;
5 6
 

+ 16
- 0
src/main/java/com/yunzhi/niucai/service/ITaShopBillService.java ファイルの表示

@@ -0,0 +1,16 @@
1
+package com.yunzhi.niucai.service;
2
+
3
+import com.yunzhi.niucai.entity.TaShopBill;
4
+import com.baomidou.mybatisplus.extension.service.IService;
5
+
6
+/**
7
+ * <p>
8
+ * 店铺账户流水 服务类
9
+ * </p>
10
+ *
11
+ * @author yansen
12
+ * @since 2020-10-19
13
+ */
14
+public interface ITaShopBillService extends IService<TaShopBill> {
15
+
16
+}

+ 29
- 14
src/main/java/com/yunzhi/niucai/service/impl/TaCustomerAccountServiceImpl.java ファイルの表示

@@ -4,12 +4,11 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 4
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
5 5
 import com.yunzhi.niucai.entity.*;
6 6
 import com.yunzhi.niucai.enums.AccFeeTypeEnum;
7
+import com.yunzhi.niucai.enums.OrderTypeEnum;
7 8
 import com.yunzhi.niucai.enums.StatusEnum;
8 9
 import com.yunzhi.niucai.mapper.TaCustomerAccountMapper;
9
-import com.yunzhi.niucai.service.ITaCustomerAccountService;
10
+import com.yunzhi.niucai.service.*;
10 11
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
11
-import com.yunzhi.niucai.service.ITaCustomerBettingService;
12
-import com.yunzhi.niucai.service.ITaCustomerBillService;
13 12
 import org.springframework.beans.factory.annotation.Autowired;
14 13
 import org.springframework.stereotype.Service;
15 14
 
@@ -30,6 +29,9 @@ public class TaCustomerAccountServiceImpl extends ServiceImpl<TaCustomerAccountM
30 29
     @Autowired
31 30
     ITaCustomerBettingService iTaCustomerBettingService;
32 31
 
32
+    @Autowired
33
+    ITaShopAccountService iTaShopAccountService;
34
+
33 35
     @Override
34 36
     public boolean newAccountBy(TaCustomer taCustomer) throws Exception {
35 37
         TaCustomerAccount account = new TaCustomerAccount();
@@ -40,7 +42,26 @@ public class TaCustomerAccountServiceImpl extends ServiceImpl<TaCustomerAccountM
40 42
     }
41 43
 
42 44
     @Override
43
-    public void createBillBy(TaOrder taOrder, String feeType) throws Exception {
45
+    public void createBillBy(TaOrder taOrder, TaOrderPay taOrderPay) throws Exception {
46
+        // 判断订单类型, 决定写哪个表
47
+        if (OrderTypeEnum.BETTING.getCode().equals(taOrder.getOrderType())) {
48
+            // 投注, 需要写客户的出记录,以及商户的入记录
49
+            createCustomerBill(taOrder, AccFeeTypeEnum.BETTING.getCode(), taOrder.getCharge(), -1);
50
+            iTaShopAccountService.createBill(taOrder, AccFeeTypeEnum.BETTING.getCode(), taOrder.getCharge(), 1);
51
+        } else if (OrderTypeEnum.CASH_OUT.getCode().equals(taOrder.getOrderType())) {
52
+            // 提现, 需要写客户的(彩金)出记录, 以及平台商户的出记录
53
+            createCustomerBill(taOrder, AccFeeTypeEnum.CASH_OUT.getCode(), taOrder.getCharge(), -1);
54
+            iTaShopAccountService.createPlatBill(taOrder, AccFeeTypeEnum.CASH_OUT.getCode(), taOrder.getCharge(), -1);
55
+        } else if (OrderTypeEnum.SENT_AWARD.getCode().equals(taOrder.getOrderType())) {
56
+            // 派奖, 需要写商户的出记录, 以及平台的入记录, 以及客户的入记录
57
+            TaCustomerBetting betting = iTaCustomerBettingService.getById(taOrder.getBettingId());
58
+            createCustomerBill(taOrder, AccFeeTypeEnum.DRAW_LOTTERY.getCode(), betting.getWinAmount(), 1);
59
+            iTaShopAccountService.createBill(taOrder, AccFeeTypeEnum.DRAW_LOTTERY.getCode(), betting.getWinAmount(), -1);
60
+            iTaShopAccountService.createPlatBill(taOrder, AccFeeTypeEnum.DRAW_LOTTERY.getCode(), betting.getWinAmount(), 1);
61
+        }
62
+    }
63
+
64
+    private void createCustomerBill(TaOrder taOrder, String feeType, Integer charge, Integer feeSign) throws Exception {
44 65
         TaCustomerAccount account = getByCustomer(taOrder.getCustomerId());
45 66
 
46 67
         TaCustomerBill taCustomerBill = new TaCustomerBill();
@@ -49,36 +70,30 @@ public class TaCustomerAccountServiceImpl extends ServiceImpl<TaCustomerAccountM
49 70
         taCustomerBill.setFeeType(feeType);
50 71
         taCustomerBill.setOrderId(taOrder.getOrderId());
51 72
         taCustomerBill.setAmount(taOrder.getCharge());
73
+        taCustomerBill.setFeeSign(feeSign);
52 74
 
53 75
         UpdateWrapper<TaCustomerAccount> updateWrapper = new UpdateWrapper<>();
54
-
55 76
         // 投注
56 77
         if (AccFeeTypeEnum.BETTING.getCode().equals(feeType)) {
57
-            updateWrapper.set("expense", account.getExpense() + taOrder.getCharge());
78
+            updateWrapper.set("expense", account.getExpense() + charge);
58 79
             updateWrapper.eq("account_id", account.getAccountId());
59 80
             updateWrapper.eq("expense", account.getExpense());
60
-            taCustomerBill.setFeeSign(-1);
61 81
         }
62 82
 
63 83
         // 提现
64 84
         if (AccFeeTypeEnum.CASH_OUT.getCode().equals(feeType)) {
65
-            updateWrapper.set("cash", account.getCash() - taOrder.getCharge());
85
+            updateWrapper.set("cash", account.getCash() - charge);
66 86
             updateWrapper.eq("account_id", account.getAccountId());
67 87
             updateWrapper.eq("cash", account.getCash());
68
-            taCustomerBill.setFeeSign(-1);
69 88
         }
70 89
 
71 90
         // 中奖
72 91
         if (AccFeeTypeEnum.DRAW_LOTTERY.getCode().equals(feeType)) {
73
-            TaCustomerBetting betting = iTaCustomerBettingService.getById(taOrder.getBettingId());
74
-
75
-            updateWrapper.set("cash", account.getCash() + betting.getWinAmount());
92
+            updateWrapper.set("cash", account.getCash() + charge);
76 93
             updateWrapper.eq("account_id", account.getAccountId());
77 94
             updateWrapper.eq("cash", account.getCash());
78
-            taCustomerBill.setFeeSign(1);
79 95
         }
80 96
 
81
-        // 更新
82 97
         update(updateWrapper);
83 98
         iTaCustomerBillService.save(taCustomerBill);
84 99
     }

+ 5
- 2
src/main/java/com/yunzhi/niucai/service/impl/TaOrderPayServiceImpl.java ファイルの表示

@@ -67,7 +67,8 @@ public class TaOrderPayServiceImpl extends ServiceImpl<TaOrderPayMapper, TaOrder
67 67
         } else if (OrderTypeEnum.CASH_OUT.getCode().equals(taOrder.getOrderType())) {
68 68
             // 提现
69 69
             taOrderPay.setTradeType("b2c");
70
-            Map<String, String> payProfile = getPayTermProfile("b", taOrder.getShopId());
70
+            // 提现的付款放为平台
71
+            Map<String, String> payProfile = getPayTermProfile("b", 0);
71 72
             if (null != payProfile) {
72 73
                 taOrderPay.setPayee(payProfile.get("id"));
73 74
                 taOrderPay.setPayeeName(payProfile.get("name"));
@@ -85,7 +86,9 @@ public class TaOrderPayServiceImpl extends ServiceImpl<TaOrderPayMapper, TaOrder
85 86
                 taOrderPay.setPayee(payProfile.get("id"));
86 87
                 taOrderPay.setPayeeName(payProfile.get("name"));
87 88
             }
88
-            Map<String, String> remitterProfile = getPayTermProfile("b", taOrder.getCustomerId());
89
+
90
+            // 派奖的接受方位平台
91
+            Map<String, String> remitterProfile = getPayTermProfile("b", 0);
89 92
             if (null != payProfile) {
90 93
                 taOrderPay.setPayee(remitterProfile.get("id"));
91 94
                 taOrderPay.setPayeeName(remitterProfile.get("name"));

+ 12
- 13
src/main/java/com/yunzhi/niucai/service/impl/TaOrderServiceImpl.java ファイルの表示

@@ -160,14 +160,17 @@ public class TaOrderServiceImpl extends ServiceImpl<TaOrderMapper, TaOrder> impl
160 160
 
161 161
     @Override
162 162
     @Transactional(rollbackFor = Exception.class)
163
-    public void payCallback(TaOrder taOrder, String outTradeNo, String payStatus, String failMessage, Boolean isSuccess, LocalDateTime payTime) throws Exception {
163
+    public void payCallback(TaOrder taOrder, TaOrderPay taOrderPay, String payStatus, String failMessage, Boolean isSuccess, LocalDateTime payTime) throws Exception {
164
+        if (null == taOrderPay) {
165
+            throw new Exception("支付详情记录未找到");
166
+        }
167
+
164 168
         if (null != isSuccess && isSuccess) {
165 169
             taOrder.setPayStatus(CommConstants.SRTATUS_EFFECTIVE);
166 170
         } else {
167 171
             taOrder.setPayStatus(CommConstants.SRTATUS_UNPAYED);
168 172
         }
169 173
 
170
-        TaOrderPay taOrderPay = iTaOrderPayService.getByTradeNo(outTradeNo);
171 174
         taOrderPay.setPayResult(payStatus);
172 175
         taOrderPay.setPayTime(payTime);
173 176
         taOrderPay.setFailReason(failMessage);
@@ -176,15 +179,7 @@ public class TaOrderServiceImpl extends ServiceImpl<TaOrderMapper, TaOrder> impl
176 179
         iTaOrderPayService.updateById(taOrderPay);
177 180
 
178 181
         if (null != isSuccess && isSuccess) {
179
-            String feeType = null;
180
-            String orderType = taOrder.getOrderType();
181
-            if (OrderTypeEnum.BETTING.getCode().equals(orderType)) {
182
-                feeType = AccFeeTypeEnum.BETTING.getCode();
183
-            } else if (OrderTypeEnum.CASH_OUT.getCode().equals(orderType)) {
184
-                feeType = AccFeeTypeEnum.CASH_OUT.getCode();
185
-            }
186
-
187
-            iTaCustomerAccountService.createBillBy(taOrder, feeType);
182
+            iTaCustomerAccountService.createBillBy(taOrder, taOrderPay);
188 183
         }
189 184
     }
190 185
 
@@ -208,13 +203,17 @@ public class TaOrderServiceImpl extends ServiceImpl<TaOrderMapper, TaOrder> impl
208 203
     public TaOrder createBy(TaOrder TaOrder, TaShop taShop, TaCustomerBetting customerBetting) throws Exception {
209 204
         TaOrder taOrder = new TaOrder();
210 205
         taOrder.setOrderId(nextOrderNo("SW", 16, true));
211
-        taOrder.setOrderType(OrderTypeEnum.CASH_OUT.getCode());
206
+        taOrder.setOrderType(OrderTypeEnum.SENT_AWARD.getCode());
212 207
         taOrder.setAmount(1);
213 208
         taOrder.setCharge(customerBetting.getWinAmount());
214 209
         taOrder.setShopId(taOrder.getShopId());
215
-        taOrder.setCustomerId(taShop.getShopId());
210
+
211
+        // 派奖的流程是 商户转账到平台
212
+        // 但是此处仍然写 商户 跟 客户的关系, 平台商户固定为 0
213
+        taOrder.setCustomerId(taOrder.getCustomerId());
216 214
         taOrder.setStatus(StatusEnum.NORMAL.getCode());
217 215
         taOrder.setPayStatus(CommConstants.SRTATUS_UNPAYED);
216
+        taOrder.setSrcOrder(taOrder.getOrderId());
218 217
 
219 218
         save(taOrder);
220 219
         return taOrder;

+ 66
- 0
src/main/java/com/yunzhi/niucai/service/impl/TaShopAccountServiceImpl.java ファイルの表示

@@ -0,0 +1,66 @@
1
+package com.yunzhi.niucai.service.impl;
2
+
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.yunzhi.niucai.entity.TaOrder;
5
+import com.yunzhi.niucai.entity.TaShopAccount;
6
+import com.yunzhi.niucai.entity.TaShopBill;
7
+import com.yunzhi.niucai.mapper.TaShopAccountMapper;
8
+import com.yunzhi.niucai.service.ITaShopAccountService;
9
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
10
+import com.yunzhi.niucai.service.ITaShopBillService;
11
+import org.springframework.beans.factory.annotation.Autowired;
12
+import org.springframework.stereotype.Service;
13
+
14
+/**
15
+ * <p>
16
+ * 店铺账户 服务实现类
17
+ * </p>
18
+ *
19
+ * @author yansen
20
+ * @since 2020-10-19
21
+ */
22
+@Service
23
+public class TaShopAccountServiceImpl extends ServiceImpl<TaShopAccountMapper, TaShopAccount> implements ITaShopAccountService {
24
+
25
+    @Autowired
26
+    ITaShopBillService iTaShopBillService;
27
+
28
+    @Override
29
+    public void createBill(TaOrder taOrder, String feeType, Integer charge, int feeSign) throws Exception {
30
+        TaShopAccount account = getByShop(taOrder.getShopId());
31
+
32
+        TaShopBill taShopBill = new TaShopBill();
33
+        taShopBill.setAccountId(account.getAccountId());
34
+        taShopBill.setShopId(account.getShopId());
35
+        taShopBill.setFeeType(feeType);
36
+        taShopBill.setAmount(charge);
37
+        taShopBill.setFeeSign(feeSign);
38
+        taShopBill.setOrderId(taOrder.getOrderId());
39
+
40
+        iTaShopBillService.save(taShopBill);
41
+    }
42
+
43
+    @Override
44
+    public void createPlatBill(TaOrder taOrder, String feeType, Integer charge, int feeSign) throws Exception {
45
+        // 平台商户 ID 为 0
46
+        TaShopAccount account = getByShop(0);
47
+
48
+        TaShopBill taShopBill = new TaShopBill();
49
+        taShopBill.setAccountId(account.getAccountId());
50
+        taShopBill.setShopId(account.getShopId());
51
+        taShopBill.setFeeType(feeType);
52
+        taShopBill.setAmount(charge);
53
+        taShopBill.setFeeSign(feeSign);
54
+        taShopBill.setOrderId(taOrder.getOrderId());
55
+
56
+        iTaShopBillService.save(taShopBill);
57
+    }
58
+
59
+    private TaShopAccount getByShop(Integer shopId) {
60
+        QueryWrapper<TaShopAccount> queryWrapper = new QueryWrapper<>();
61
+        queryWrapper.eq("shop_id", shopId);
62
+        return getOne(queryWrapper);
63
+    }
64
+
65
+
66
+}

+ 20
- 0
src/main/java/com/yunzhi/niucai/service/impl/TaShopBillServiceImpl.java ファイルの表示

@@ -0,0 +1,20 @@
1
+package com.yunzhi.niucai.service.impl;
2
+
3
+import com.yunzhi.niucai.entity.TaShopBill;
4
+import com.yunzhi.niucai.mapper.TaShopBillMapper;
5
+import com.yunzhi.niucai.service.ITaShopBillService;
6
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7
+import org.springframework.stereotype.Service;
8
+
9
+/**
10
+ * <p>
11
+ * 店铺账户流水 服务实现类
12
+ * </p>
13
+ *
14
+ * @author yansen
15
+ * @since 2020-10-19
16
+ */
17
+@Service
18
+public class TaShopBillServiceImpl extends ServiceImpl<TaShopBillMapper, TaShopBill> implements ITaShopBillService {
19
+
20
+}

+ 5
- 0
src/main/resources/mapper/TaShopAccountMapper.xml ファイルの表示

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

+ 5
- 0
src/main/resources/mapper/TaShopBillMapper.xml ファイルの表示

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