From cbf2486983b77a27af9968bbb362cb8d43789115 Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期三, 26 三月 2025 15:30:53 +0800 Subject: [PATCH] 修改统计bug和部分功能修改 --- ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserPointServiceImpl.java | 20 - ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/CommissionServiceImpl.java | 56 +++--- ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserSignRecordController.java | 6 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShareController.java | 3 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopPointController.java | 6 ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/UserPoint.java | 14 ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/BalanceChangeRecordCopy.java | 10 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopPointCopy.java | 14 - ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/ShopPointClient.java | 3 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java | 18 + ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java | 79 ++++++-- ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopBalanceStatement.java | 12 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserPointController.java | 15 + ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/OrderMapper.java | 10 + ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/BalanceChangeRecordClientFallbackFactory.java | 4 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopPoint.java | 14 - ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/BalanceChangeRecordServiceImpl.java | 23 - ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/WithdrawalRequestsServiceImpl.java | 3 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/ShopBalanceStatementClientFallbackFactory.java | 6 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AppUserServiceImpl.java | 12 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WithdrawalRequestsController.java | 9 ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/UserPointClient.java | 3 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopBalanceStatementController.java | 18 + ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopBalanceStatementServiceImpl.java | 7 ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/feignClient/OrderClient.java | 10 + ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/ShopBalanceStatementClient.java | 3 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopWithdrawController.java | 9 ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/UserPointCopy.java | 12 ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/UserPointFallbackFactory.java | 6 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java | 21 - ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/BalanceChangeRecordController.java | 4 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopBalanceStatementCopy.java | 14 - ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/OrderService.java | 11 + ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/BalanceChangeRecord.java | 10 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/ShopPointClientFallbackFactory.java | 5 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WalletController.java | 3 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java | 7 ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/factory/OrderClientFallbackFactory.java | 5 ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/BalanceChangeRecordClient.java | 11 + ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/BalanceChangeRecordCopyController.java | 15 + ruoyi-service/ruoyi-account/src/main/resources/mapper/account/AppUserMapper.xml | 3 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserCouponController.java | 3 ruoyi-service/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml | 15 + 43 files changed, 310 insertions(+), 222 deletions(-) diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/BalanceChangeRecordClientFallbackFactory.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/BalanceChangeRecordClientFallbackFactory.java index b4b6fb2..6812184 100644 --- a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/BalanceChangeRecordClientFallbackFactory.java +++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/BalanceChangeRecordClientFallbackFactory.java @@ -32,6 +32,10 @@ return R.fail("删除分佣临时流水数据失败:" + cause.getMessage()); } + @Override + public R deleteBalanceChangeRecordCopyByIds(List<Long> ids) { + return R.fail("删除分佣临时数据失败:" + cause.getMessage()); + } @Override public R<List<BalanceChangeRecordCopy>> getBalanceChangeRecordCopy(Long orderId, List<Integer> changeType) { diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/UserPointFallbackFactory.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/UserPointFallbackFactory.java index 021a5a2..e5b48ab 100644 --- a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/UserPointFallbackFactory.java +++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/UserPointFallbackFactory.java @@ -32,6 +32,12 @@ return R.fail("删除积分流水记录失败:" + cause.getMessage()); } + + @Override + public R deleteUserPointCopyByIds(List<Long> ids) { + return R.fail("删除积分流水记录失败:" + cause.getMessage()); + } + @Override public R<List<UserPointCopy>> getUserPointCopy(Long orderId, List<Integer> type) { return R.fail("查询积分流水记录失败:" + cause.getMessage()); diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/BalanceChangeRecordClient.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/BalanceChangeRecordClient.java index db8eee2..110e3b5 100644 --- a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/BalanceChangeRecordClient.java +++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/BalanceChangeRecordClient.java @@ -45,6 +45,17 @@ @DeleteMapping("/balanceChangeRecordCopy/deleteBalanceChangeRecordCopy") R deleteBalanceChangeRecordCopy(@RequestParam("orderId") Long orderId, @RequestParam("changeType") List<Integer> changeType); + + + /** + * 删除分佣临时数据 + * @param ids + * @return + */ + @DeleteMapping("/balanceChangeRecordCopy/deleteBalanceChangeRecordCopyByIds") + R deleteBalanceChangeRecordCopyByIds(@RequestParam("ids") List<Long> ids); + + /** * 查询分佣临时流水数据 * @param orderId diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/UserPointClient.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/UserPointClient.java index ce8477b..a6519b3 100644 --- a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/UserPointClient.java +++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/UserPointClient.java @@ -34,6 +34,9 @@ @DeleteMapping("/user-point/deleteUserPointCopy") R deleteUserPointCopy(@RequestParam("orderId") Long orderId, @RequestParam("type") List<Integer> type); + @DeleteMapping("/user-point/deleteUserPointCopyByIds") + R deleteUserPointCopyByIds(@RequestParam("ids") List<Long> ids); + @PostMapping("/user-point/getUserPointCopy") R<List<UserPointCopy>> getUserPointCopy(@RequestParam("orderId") Long orderId, @RequestParam("type") List<Integer> type); diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/BalanceChangeRecord.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/BalanceChangeRecord.java index 5a681b5..852a9bb 100644 --- a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/BalanceChangeRecord.java +++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/BalanceChangeRecord.java @@ -41,9 +41,6 @@ @Excel(name = "变更类型", readConverterExp = "1=充值,2=提现,3=红包,4=分佣,5=商城购物,6=订单取消回退") private Integer changeType; - @ApiModelProperty("变更前金额") - private BigDecimal beforeAmount; - @ApiModelProperty("变更金额") private BigDecimal changeAmount; @ApiModelProperty("变更金额-带人民币符号") @@ -51,15 +48,16 @@ @TableField(exist = false) private String changeAmountString; - @ApiModelProperty("变更后金额") - private BigDecimal afterAmount; - @ApiModelProperty("删除(0=否,1=是") private Integer delFlag; @ApiModelProperty("添加时间") @Excel(name = "变更时间",dateFormat = "yyyy-MM-dd HH:mm:ss") private LocalDateTime createTime; + + @ApiModelProperty(value = "变动方向(-1:减少,1:增加)") + @TableField("change_direction") + private Integer changeDirection; @TableField(exist = false) @ApiModelProperty("消费用户名称") diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/BalanceChangeRecordCopy.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/BalanceChangeRecordCopy.java index 304cacd..e31b529 100644 --- a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/BalanceChangeRecordCopy.java +++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/BalanceChangeRecordCopy.java @@ -39,18 +39,16 @@ @Excel(name = "变更类型", readConverterExp = "1=充值,2=提现,3=红包,4=分佣,5=商城购物,6=订单取消回退") private Integer changeType; - @ApiModelProperty("变更前金额") - private BigDecimal beforeAmount; - @ApiModelProperty("变更金额") private BigDecimal changeAmount; @ApiModelProperty("变更金额-带人民币符号") @Excel(name = "变更数量") @TableField(exist = false) private String changeAmountString; - - @ApiModelProperty("变更后金额") - private BigDecimal afterAmount; + + @ApiModelProperty(value = "变动方向(-1:减少,1:增加)") + @TableField("change_direction") + private Integer changeDirection; @ApiModelProperty("删除(0=否,1=是") private Integer delFlag; diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/UserPoint.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/UserPoint.java index 9a165cd..b30e367 100644 --- a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/UserPoint.java +++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/UserPoint.java @@ -44,18 +44,10 @@ @TableField("type") private Integer type; - @ApiModelProperty(value = "历史余额") - @TableField("historical_point") - private Integer historicalPoint; - @ApiModelProperty(value = "变动金额") @TableField("variable_point") @Excel(name = "变动金额") private Integer variablePoint; - - @ApiModelProperty(value = "变动后余额") - @TableField("balance") - private Integer balance; @ApiModelProperty(value = "变动时间") @TableField("create_time") @@ -73,6 +65,12 @@ @ApiModelProperty(value = "拓展字段") @TableField("extention") private String extention; + + @ApiModelProperty(value = "变动方向(-1:减少,1:增加)") + @TableField("change_direction") + private Integer changeDirection; + + @ApiModelProperty(value = "用户名称") @Excel(name = "用户名称") diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/UserPointCopy.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/UserPointCopy.java index 751c8ea..ea55a6d 100644 --- a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/UserPointCopy.java +++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/UserPointCopy.java @@ -39,17 +39,9 @@ @TableField("type") private Integer type; - @ApiModelProperty(value = "历史余额") - @TableField("historical_point") - private Integer historicalPoint; - @ApiModelProperty(value = "变动金额") @TableField("variable_point") private Integer variablePoint; - - @ApiModelProperty(value = "变动后余额") - @TableField("balance") - private Integer balance; @ApiModelProperty(value = "变动时间") @TableField("create_time") @@ -66,6 +58,10 @@ @ApiModelProperty(value = "拓展字段") @TableField("extention") private String extention; + + @ApiModelProperty(value = "变动方向(-1:减少,1:增加)") + @TableField("change_direction") + private Integer changeDirection; @ApiModelProperty(value = "用户名称") @TableField(exist = false) diff --git a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/factory/OrderClientFallbackFactory.java b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/factory/OrderClientFallbackFactory.java index 315e863..9cffd40 100644 --- a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/factory/OrderClientFallbackFactory.java +++ b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/factory/OrderClientFallbackFactory.java @@ -59,6 +59,11 @@ public R<Long> getOrderCountByAppUserId(Long appUserId) { return R.fail("获取用户订单数量失败:" + cause.getMessage()); } + + @Override + public R<List<Order>> getOrderByAppUserIdsAndWriteOffShop(Integer shopId, Set<Long> appUserId) { + return R.fail("查询给定用户在给定门店核销的订单失败:" + cause.getMessage()); + } }; } } diff --git a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/feignClient/OrderClient.java b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/feignClient/OrderClient.java index 2aeda43..1c14e24 100644 --- a/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/feignClient/OrderClient.java +++ b/ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/feignClient/OrderClient.java @@ -88,4 +88,14 @@ */ @PostMapping("/order/getOrderCountByAppUserId") R<Long> getOrderCountByAppUserId(@RequestParam("id") Long appUserId); + + + /** + * 查询给定用户在给定门店核销的订单 + * @param shopId + * @param appUserId + * @return + */ + @PostMapping("/order/getOrderByAppUserIdsAndWriteOffShop") + R<List<Order>> getOrderByAppUserIdsAndWriteOffShop(@RequestParam("shopId") Integer shopId, @RequestParam("appUserId") Set<Long> appUserId); } diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopBalanceStatement.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopBalanceStatement.java index 1215ebb..c4e4473 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopBalanceStatement.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopBalanceStatement.java @@ -55,10 +55,6 @@ @Excel(name = "变更类型",readConverterExp = "1=服务商分佣,2=高级服务商分佣,3=核销门店服务费") private Integer type; - @ApiModelProperty(value = "历史余额") - @TableField("historical_balance") - private BigDecimal historicalBalance; - @ApiModelProperty(value = "变动金额") @TableField("variable_amount") private BigDecimal variableAmount; @@ -71,10 +67,6 @@ @Excel(name = "变更数量") private String variableAmountString; - @ApiModelProperty(value = "变动后余额") - @TableField("balance") - private BigDecimal balance; - @ApiModelProperty(value = "变动用户id") @@ -84,6 +76,10 @@ @ApiModelProperty(value = "关联对象id") @TableField("object_id") private Long objectId; + + @ApiModelProperty(value = "变动方向(-1:减少,1:增加)") + @TableField("change_direction") + private Integer changeDirection; diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopBalanceStatementCopy.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopBalanceStatementCopy.java index cf86d9c..5254bd0 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopBalanceStatementCopy.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopBalanceStatementCopy.java @@ -55,10 +55,6 @@ @Excel(name = "变更类型",readConverterExp = "1=服务商分佣,2=高级服务商分佣,3=核销门店服务费,4=提现") private Integer type; - @ApiModelProperty(value = "历史余额") - @TableField("historical_balance") - private BigDecimal historicalBalance; - @ApiModelProperty(value = "变动金额") @TableField("variable_amount") private BigDecimal variableAmount; @@ -70,12 +66,6 @@ @TableField(exist = false) @Excel(name = "变更数量") private String variableAmountString; - - @ApiModelProperty(value = "变动后余额") - @TableField("balance") - private BigDecimal balance; - - @ApiModelProperty(value = "变动用户id") @TableField("create_user_id") @@ -106,4 +96,8 @@ @ApiModelProperty(value = "扩展字段") @TableField("extension") private String extension; + + @ApiModelProperty(value = "变动方向(-1:减少,1:增加)") + @TableField("change_direction") + private Integer changeDirection; } diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopPoint.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopPoint.java index 34e632c..566124b 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopPoint.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopPoint.java @@ -62,20 +62,10 @@ @Excel(name = "变动时间") private LocalDateTime createTime; - @ApiModelProperty(value = "历史余额") - @TableField("historical_point") - private Integer historicalPoint; - @ApiModelProperty(value = "变动金额") @TableField("variable_point") @Excel(name = "变动金额") private Integer variablePoint; - - @ApiModelProperty(value = "变动后余额") - @TableField("balance") - private Integer balance; - - @ApiModelProperty(value = "变动用户id") @TableField("create_user_id") @@ -88,6 +78,10 @@ @ApiModelProperty(value = "订单号") @TableField("order_num") private String orderNum; + + @ApiModelProperty(value = "变动方向(-1:减少,1:增加)") + @TableField("change_direction") + private Integer changeDirection; diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopPointCopy.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopPointCopy.java index 7901046..d7731d0 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopPointCopy.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopPointCopy.java @@ -61,20 +61,10 @@ @Excel(name = "变动时间") private LocalDateTime createTime; - @ApiModelProperty(value = "历史余额") - @TableField("historical_point") - private Integer historicalPoint; - @ApiModelProperty(value = "变动金额") @TableField("variable_point") @Excel(name = "变动金额") private Integer variablePoint; - - @ApiModelProperty(value = "变动后余额") - @TableField("balance") - private Integer balance; - - @ApiModelProperty(value = "变动用户id") @TableField("create_user_id") @@ -87,6 +77,10 @@ @ApiModelProperty(value = "订单号") @TableField("order_num") private String orderNum; + + @ApiModelProperty(value = "变动方向(-1:减少,1:增加)") + @TableField("change_direction") + private Integer changeDirection; diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/ShopBalanceStatementClientFallbackFactory.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/ShopBalanceStatementClientFallbackFactory.java index 4a14c2c..99d117a 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/ShopBalanceStatementClientFallbackFactory.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/ShopBalanceStatementClientFallbackFactory.java @@ -35,7 +35,11 @@ public R<Boolean> deleteShopBalanceStatementCopy(Long orderId, List<Integer> type) { return R.fail("删除门店余额流水失败:" + cause.getMessage()); } - + + @Override + public R<Boolean> deleteShopBalanceStatementCopyByIds(List<Long> ids) { + return R.fail("删除门店余额流水失败:" + cause.getMessage()); + } @Override public R<List<ShopBalanceStatementCopy>> getShopBalanceStatementCopy(Long orderId, List<Integer> type) { diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/ShopPointClientFallbackFactory.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/ShopPointClientFallbackFactory.java index 45c6fe6..598799e 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/ShopPointClientFallbackFactory.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/ShopPointClientFallbackFactory.java @@ -34,6 +34,11 @@ @Override + public void deleteShopPointCopyByIds(List<Long> ids) { + + } + + @Override public R<List<ShopPointCopy>> getShopPointCopy(Long orderId, List<Integer> type) { return R.fail("获取门店积分流水失败:" + cause.getMessage()); } diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/ShopBalanceStatementClient.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/ShopBalanceStatementClient.java index 9ce0fb9..db48b10 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/ShopBalanceStatementClient.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/ShopBalanceStatementClient.java @@ -36,6 +36,9 @@ @DeleteMapping("/shop-balance-statement/deleteShopBalanceStatementCopy") R<Boolean> deleteShopBalanceStatementCopy(@RequestParam("orderId") Long orderId, @RequestParam("type") List<Integer> type); + @DeleteMapping("/shop-balance-statement/deleteShopBalanceStatementCopyByIds") + R<Boolean> deleteShopBalanceStatementCopyByIds(@RequestParam("ids") List<Long> ids); + @PostMapping("/shop-balance-statement/getShopBalanceStatementCopy") R<List<ShopBalanceStatementCopy>> getShopBalanceStatementCopy(@RequestParam("orderId") Long orderId, @RequestParam("type") List<Integer> type); diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/ShopPointClient.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/ShopPointClient.java index 127cc9c..1607ef1 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/ShopPointClient.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/ShopPointClient.java @@ -33,6 +33,9 @@ @DeleteMapping("/shop-point/deleteShopPointCopy") void deleteShopPointCopy(@RequestParam("orderId") Long orderId, @RequestParam("type") List<Integer> type); + @DeleteMapping("/shop-point/deleteShopPointCopyByIds") + void deleteShopPointCopyByIds(@RequestParam("ids") List<Long> ids); + @PostMapping("/shop-point/getShopPointCopy") R<List<ShopPointCopy>> getShopPointCopy(@RequestParam("orderId") Long orderId, @RequestParam("type") List<Integer> type); diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java index 5dae7c5..013d0f6 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java @@ -1206,8 +1206,8 @@ public R<UserStatisticsDetail> statisticsDetail(@ApiParam(value = "用户id") Long userId) { Long userid = tokenService.getLoginUser().getUserid(); SysUser data = sysUserClient.getSysUser(userid).getData(); - Integer shopId = null; - Set<Long> userIds = null; + Integer shopId = 0; + Set<Long> userIds = new HashSet<>(); if(null != userId){ userIds = new HashSet<>(); userIds.add(userId); @@ -1225,6 +1225,9 @@ } UserStatisticsDetail userStatisticsDetail = appUserMapper.getUserStatisticsDetail(null, userIds); + List<Order> orderList = orderClient.getOrderByAppUserIdsAndWriteOffShop(shopId, userIds).getData(); + BigDecimal shopAmount = orderList.stream().map(Order::getPaymentAmount).reduce(BigDecimal.ZERO, BigDecimal::add); + userStatisticsDetail.setShopAmount(shopAmount); return R.ok(userStatisticsDetail); } diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/BalanceChangeRecordController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/BalanceChangeRecordController.java index e5ee3d1..496314c 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/BalanceChangeRecordController.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/BalanceChangeRecordController.java @@ -49,9 +49,7 @@ IPage<BalanceChangeRecord> page = balanceChangeRecordService.pageList(agentQuery); for (BalanceChangeRecord record : page.getRecords()) { - BigDecimal beforeAmount = record.getBeforeAmount(); - BigDecimal afterAmount = record.getAfterAmount(); - if (beforeAmount.compareTo(afterAmount) > 0){ + if (record.getChangeDirection() == -1){ record.setFlag(2); }else { record.setFlag(1); diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/BalanceChangeRecordCopyController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/BalanceChangeRecordCopyController.java index 6e36c2e..da7e5ef 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/BalanceChangeRecordCopyController.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/BalanceChangeRecordCopyController.java @@ -35,6 +35,21 @@ } + + /** + * 删除分佣临时数据 + * @param ids + * @return + */ + @DeleteMapping("/deleteBalanceChangeRecordCopyByIds") + public R deleteBalanceChangeRecordCopyByIds(@RequestParam("ids") List<Long> ids){ + balanceChangeRecordCopyService.removeBatchByIds(ids); + return R.ok(); + } + + + + /** * 查询分佣临时流水数据 * @param orderId diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserCouponController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserCouponController.java index a796064..e607e75 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserCouponController.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserCouponController.java @@ -250,12 +250,11 @@ if(point > 0){ UserPoint userPoint = new UserPoint(); userPoint.setType(15); - userPoint.setHistoricalPoint(lavePoint); userPoint.setVariablePoint(point); - userPoint.setBalance(byId.getLavePoint()); userPoint.setAppUserId(userid); userPoint.setObjectId(Long.valueOf(data.getId())); userPoint.setCreateTime(LocalDateTime.now()); + userPoint.setChangeDirection(-1); userPointService.save(userPoint); } } diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserPointController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserPointController.java index 5e2eefa..9d5ca8d 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserPointController.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserPointController.java @@ -131,6 +131,14 @@ } + + @DeleteMapping("/deleteUserPointCopyByIds") + public R deleteUserPointCopyByIds(@RequestParam("ids") List<Long> ids){ + userPointCopyMapper.deleteBatchIds(ids); + return R.ok(); + } + + @PostMapping("/getUserPointCopy") public R<List<UserPointCopy>> getUserPointCopy(@RequestParam("orderId") Long orderId, @RequestParam("type") List<Integer> type) { List<UserPointCopy> list = userPointCopyMapper.selectList(new LambdaQueryWrapper<UserPointCopy>().in(UserPointCopy::getType, type) @@ -175,13 +183,10 @@ record.setExtention(data.getOrderNumber()); } } - int i = record.getHistoricalPoint() - record.getBalance(); - if (i>0){ + if (record.getChangeDirection() == -1){ record.setVariableType(2); - }else if (i<0){ - record.setVariableType(1); }else{ - record.setVariableType(0); + record.setVariableType(1); } } return R.ok(page); diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserSignRecordController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserSignRecordController.java index ed7cb65..a374b67 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserSignRecordController.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserSignRecordController.java @@ -100,11 +100,10 @@ if(signPoint > 0){ UserPoint userPoint = new UserPoint(); userPoint.setType(5); - userPoint.setHistoricalPoint(lavePoint); userPoint.setVariablePoint(signPoint); - userPoint.setBalance(appUser.getLavePoint()); userPoint.setCreateTime(LocalDateTime.now()); userPoint.setAppUserId(appUser.getId()); + userPoint.setChangeDirection(1); userPointService.save(userPoint); } //变更等级 @@ -126,11 +125,10 @@ balanceChangeRecord.setAppUserId(appUser.getId()); balanceChangeRecord.setVipId(appUser.getVipId()); balanceChangeRecord.setChangeType(3); - balanceChangeRecord.setBeforeAmount(appUser.getBalance()); balanceChangeRecord.setChangeAmount(bigDecimalR.getData()); - balanceChangeRecord.setAfterAmount(appUser.getBalance().add(bigDecimalR.getData())); balanceChangeRecord.setDelFlag(0); balanceChangeRecord.setCreateTime(LocalDateTime.now()); + balanceChangeRecord.setChangeDirection(1); balanceChangeRecordService.save(balanceChangeRecord); SignBackRDto signBackRDto = new SignBackRDto(); signBackRDto.setPoint(userSignRecord.getPoint()); diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WalletController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WalletController.java index a463f14..187f9b4 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WalletController.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WalletController.java @@ -209,11 +209,10 @@ balanceChangeRecord.setVipId(appUser.getVipId()); balanceChangeRecord.setOrderId(balanceChangeRecord.getId()); balanceChangeRecord.setChangeType(1); - balanceChangeRecord.setBeforeAmount(balance); balanceChangeRecord.setChangeAmount(money); - balanceChangeRecord.setAfterAmount(appUser.getBalance()); balanceChangeRecord.setDelFlag(0); balanceChangeRecord.setCreateTime(LocalDateTime.now()); + balanceChangeRecord.setChangeDirection(1); balanceChangeRecordService.save(balanceChangeRecord); balancePayment.setStatus(2); diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WithdrawalRequestsController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WithdrawalRequestsController.java index 2472e5f..81fe08f 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WithdrawalRequestsController.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WithdrawalRequestsController.java @@ -124,11 +124,10 @@ balanceChangeRecord.setVipId(appUser.getVipId()); // balanceChangeRecord.setOrderId(withdrawalRequests.getId()); balanceChangeRecord.setChangeType(2); - balanceChangeRecord.setBeforeAmount(balance); balanceChangeRecord.setChangeAmount(withdrawalAmount); - balanceChangeRecord.setAfterAmount(appUser.getBalance()); balanceChangeRecord.setDelFlag(0); balanceChangeRecord.setCreateTime(LocalDateTime.now()); + balanceChangeRecord.setChangeDirection(-1); balanceChangeRecordService.save(balanceChangeRecord); return R.fail("转账失败"); } @@ -155,11 +154,10 @@ balanceChangeRecord.setVipId(appUser.getVipId()); balanceChangeRecord.setOrderId(withdrawal.getId()); balanceChangeRecord.setChangeType(2); - balanceChangeRecord.setBeforeAmount(balance); balanceChangeRecord.setChangeAmount(withdrawalAmount); - balanceChangeRecord.setAfterAmount(appUser.getBalance()); balanceChangeRecord.setDelFlag(0); balanceChangeRecord.setCreateTime(LocalDateTime.now()); + balanceChangeRecord.setChangeDirection(-1); balanceChangeRecordService.save(balanceChangeRecord); } withdrawal.setAuditStatus(auditStatus); @@ -205,11 +203,10 @@ balanceChangeRecord.setVipId(appUser.getVipId()); balanceChangeRecord.setOrderId(withdrawalRequests.getId()); balanceChangeRecord.setChangeType(2); - balanceChangeRecord.setBeforeAmount(balance); balanceChangeRecord.setChangeAmount(withdrawalAmount); - balanceChangeRecord.setAfterAmount(appUser.getBalance()); balanceChangeRecord.setDelFlag(0); balanceChangeRecord.setCreateTime(LocalDateTime.now()); + balanceChangeRecord.setChangeDirection(-1); balanceChangeRecordService.save(balanceChangeRecord); withdrawalRequests.setStatus(3); diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AppUserServiceImpl.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AppUserServiceImpl.java index 7ce7769..dfa6c27 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AppUserServiceImpl.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AppUserServiceImpl.java @@ -382,11 +382,10 @@ //构建积分流水记录 UserPoint userPoint = new UserPoint(); userPoint.setType(7); - userPoint.setHistoricalPoint(0); userPoint.setVariablePoint(regisPoint); - userPoint.setBalance(appUser.getLavePoint()); userPoint.setCreateTime(LocalDateTime.now()); userPoint.setAppUserId(appUser.getId()); + userPoint.setChangeDirection(1); userPointService.save(userPoint); } //获取优惠券 @@ -433,11 +432,10 @@ if(newPoint > 0){ UserPoint userPoint = new UserPoint(); userPoint.setType(3); - userPoint.setHistoricalPoint(appUser2.getLavePoint() - newPoint); userPoint.setVariablePoint(newPoint); - userPoint.setBalance(appUser2.getLavePoint()); userPoint.setCreateTime(LocalDateTime.now()); userPoint.setAppUserId(appUser2.getId()); + userPoint.setChangeDirection(1); userPointService.save(userPoint); } //变更等级 @@ -457,11 +455,10 @@ if(newPoint > 0){ UserPoint userPoint = new UserPoint(); userPoint.setType(3); - userPoint.setHistoricalPoint(appUser3.getLavePoint() - newPoint); userPoint.setVariablePoint(newPoint); - userPoint.setBalance(appUser3.getLavePoint()); userPoint.setCreateTime(LocalDateTime.now()); userPoint.setAppUserId(appUser3.getId()); + userPoint.setChangeDirection(1); userPointService.save(userPoint); } //变更等级 @@ -1070,11 +1067,10 @@ UserPoint userPoint = new UserPoint(); userPoint.setType(6); - userPoint.setHistoricalPoint(lavePoint); userPoint.setVariablePoint(hourPoint); - userPoint.setBalance(appUser.getLavePoint()); userPoint.setCreateTime(LocalDateTime.now()); userPoint.setAppUserId(appUser.getId()); + userPoint.setChangeDirection(1); userPointService.save(userPoint); //变更等级 vipUpgrade(appUser.getId()); diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/BalanceChangeRecordServiceImpl.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/BalanceChangeRecordServiceImpl.java index 637469f..94bfac2 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/BalanceChangeRecordServiceImpl.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/BalanceChangeRecordServiceImpl.java @@ -66,16 +66,11 @@ // 过滤商城购物 List<BalanceChangeRecord> collect = balanceChangeRecordIPage.getRecords().stream().filter(e -> e.getChangeType() != 5).collect(Collectors.toList()); for (BalanceChangeRecord changeRecord : collect) { - if (changeRecord.getBeforeAmount()!=null && changeRecord.getAfterAmount()!=null){ - BigDecimal subtract = changeRecord.getBeforeAmount().subtract(changeRecord.getAfterAmount()); - if (subtract.compareTo(BigDecimal.ZERO)>0){ - // 减少 - changeRecord.setChangeAmountString("-¥"+changeRecord.getChangeAmount()); - }else if (subtract.compareTo(BigDecimal.ZERO)<0){ - changeRecord.setChangeAmountString("+¥"+changeRecord.getChangeAmount()); - }else{ - changeRecord.setChangeAmountString("¥"+changeRecord.getChangeAmount()); - } + if (changeRecord.getChangeDirection() == -1){ + // 减少 + changeRecord.setChangeAmountString("-¥"+changeRecord.getChangeAmount()); + }else { + changeRecord.setChangeAmountString("+¥"+changeRecord.getChangeAmount()); } } balanceChangeRecordIPage.setRecords(collect); @@ -95,14 +90,12 @@ WalletStatisticsDetail walletStatisticsDetail = new WalletStatisticsDetail(); BeanUtils.copyBeanProp(walletStatisticsDetail, changeRecord); - BigDecimal beforeAmount = changeRecord.getBeforeAmount(); - BigDecimal afterAmount = changeRecord.getAfterAmount(); if(changeRecord.getChangeType() == 2){ BigDecimal changeAmount = changeRecord.getChangeAmount(); totalWithdraw = totalWithdraw.add(changeAmount); } - if (beforeAmount.compareTo(afterAmount) > 0){ + if (changeRecord.getChangeDirection() == -1){ walletStatisticsDetail.setFlag(2); }else { walletStatisticsDetail.setFlag(1); @@ -181,9 +174,7 @@ } }); - BigDecimal beforeAmount = bc.getBeforeAmount(); - BigDecimal afterAmount = bc.getAfterAmount(); - if (beforeAmount.compareTo(afterAmount) > 0){ + if (bc.getChangeDirection() == -1){ bc.setFlag(2); }else { bc.setFlag(1); diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserPointServiceImpl.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserPointServiceImpl.java index 9f91beb..134a7cf 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserPointServiceImpl.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserPointServiceImpl.java @@ -173,12 +173,11 @@ if(point > 0){ UserPoint userPoint = new UserPoint(); userPoint.setType(12); - userPoint.setHistoricalPoint(lavePoint1); userPoint.setVariablePoint(point); - userPoint.setBalance(appUserForPhoe.getLavePoint()); userPoint.setCreateTime(LocalDateTime.now()); userPoint.setAppUserId(appUserForPhoe.getId()); userPoint.setObjectId(userid); + userPoint.setChangeDirection(1); userPointService.save(userPoint); } @@ -191,12 +190,11 @@ if(point > 0){ UserPoint userPoint = new UserPoint(); userPoint.setType(13); - userPoint.setHistoricalPoint(lavePoint); userPoint.setVariablePoint(point); - userPoint.setBalance(appUser.getLavePoint()); userPoint.setCreateTime(LocalDateTime.now()); userPoint.setAppUserId(appUser.getId()); userPoint.setObjectId(appUserForPhoe.getId()); + userPoint.setChangeDirection(-1); userPointService.save(userPoint); } return R.ok(); @@ -208,12 +206,7 @@ List<UserPoint> userPointList = this.baseMapper.selectUserPoint(userPoint); userPointList.forEach(item -> { - int i = item.getHistoricalPoint() - item.getBalance(); - if (i>0){ - item.setVariablePoint(item.getVariablePoint() * -1); - }else { - item.setVariablePoint(item.getVariablePoint()); - } + item.setVariablePoint(item.getVariablePoint() * item.getChangeDirection()); }); Map<Integer, Integer> userBalanceMap = userPointList.stream() @@ -252,12 +245,7 @@ public IPage<UserPoint> getUserPointPage(Page<UserPoint> page, UserPoint userPoint) { IPage<UserPoint> userPointIPage = this.baseMapper.queryUserPointPage(page, userPoint); userPointIPage.getRecords().forEach(item -> { - int i = item.getHistoricalPoint() - item.getBalance(); - if (i>0){ - item.setVariablePoint(item.getVariablePoint() * -1); - }else { - item.setVariablePoint(item.getVariablePoint()); - } + item.setVariablePoint(item.getVariablePoint() * item.getChangeDirection()); }); return userPointIPage; } diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/WithdrawalRequestsServiceImpl.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/WithdrawalRequestsServiceImpl.java index fbf8840..70092ba 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/WithdrawalRequestsServiceImpl.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/WithdrawalRequestsServiceImpl.java @@ -114,11 +114,10 @@ balanceChangeRecord.setVipId(appUser.getVipId()); balanceChangeRecord.setOrderId(withdrawalRequests.getId()); balanceChangeRecord.setChangeType(2); - balanceChangeRecord.setBeforeAmount(balance); balanceChangeRecord.setChangeAmount(withdrawalAmount); - balanceChangeRecord.setAfterAmount(appUser.getBalance()); balanceChangeRecord.setDelFlag(0); balanceChangeRecord.setCreateTime(LocalDateTime.now()); + balanceChangeRecord.setChangeDirection(-1); balanceChangeRecordService.save(balanceChangeRecord); } diff --git a/ruoyi-service/ruoyi-account/src/main/resources/mapper/account/AppUserMapper.xml b/ruoyi-service/ruoyi-account/src/main/resources/mapper/account/AppUserMapper.xml index 423f894..74cf2d2 100644 --- a/ruoyi-service/ruoyi-account/src/main/resources/mapper/account/AppUserMapper.xml +++ b/ruoyi-service/ruoyi-account/src/main/resources/mapper/account/AppUserMapper.xml @@ -149,8 +149,7 @@ ifnull(SUM(tau.total_performance_point), 0) achievementScore, ifnull(SUM(tau.total_distribution_amount), 0) totalRebate, ifnull(SUM(tau.total_recharge_amount), 0) totalRecharge, - ifnull(SUM(tau.withdrawn_amount), 0) totalWithdraw, - ifnull(SUM(tau.shop_amount), 0) shopAmount + ifnull(SUM(tau.withdrawn_amount), 0) totalWithdraw FROM t_app_user tau <where> diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java index ef43ba7..50e5e44 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java @@ -681,7 +681,21 @@ .eq(Order::getPayStatus, 2)); return R.ok(count); } - - + + + + + + /** + * 查询给定用户在给定门店核销的订单 + * @param shopId + * @param appUserId + * @return + */ + @PostMapping("/getOrderByAppUserIdsAndWriteOffShop") + public R<List<Order>> getOrderByAppUserIdsAndWriteOffShop(@RequestParam("shopId") Integer shopId, @RequestParam("appUserId") Set<Long> appUserId){ + List<Order> list = orderService.getOrderByAppUserIdsAndWriteOffShop(shopId, appUserId); + return R.ok(list); + } } diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/OrderMapper.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/OrderMapper.java index e9bce9e..1ee41c3 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/OrderMapper.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/OrderMapper.java @@ -8,6 +8,7 @@ import java.time.LocalDateTime; import java.util.List; +import java.util.Set; /** * <p> @@ -56,4 +57,13 @@ Integer getShopSaleNumByShopIds(@Param("shopIds") List<Integer> shopIds, @Param("type") Integer type); List<OrderExport> getOrderExportList( @Param("item") OrderPageList order); + + + /** + * 查询给定用户在给定门店核销的订单 + * @param shopId + * @param appUserId + * @return + */ + List<Order> getOrderByAppUserIdsAndWriteOffShop(@Param("shopId") Integer shopId, @Param("appUserId") Set<Long> appUserId); } diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/OrderService.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/OrderService.java index e2f5c92..5d4d8a8 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/OrderService.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/OrderService.java @@ -6,9 +6,11 @@ import com.ruoyi.order.model.Order; import com.ruoyi.order.util.payment.model.RefundCallbackResult; import com.ruoyi.order.vo.*; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.multipart.MultipartFile; import java.util.List; +import java.util.Set; /** * <p> @@ -126,4 +128,13 @@ void importExpress(String url); Integer getShopSaleNumByShopIds(List<Integer> shopIds, Integer type); + + + /** + * 查询给定用户在给定门店核销的订单 + * @param shopId + * @param appUserId + * @return + */ + List<Order> getOrderByAppUserIdsAndWriteOffShop(@RequestParam("shopId") Integer shopId, @RequestParam("appUserId") Set<Long> appUserId); } diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/CommissionServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/CommissionServiceImpl.java index b08938b..b03e17e 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/CommissionServiceImpl.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/CommissionServiceImpl.java @@ -185,8 +185,11 @@ changeRecord.setId(null); balanceChangeRecordClient.saveBalanceChangeRecord(changeRecord); } + if(data2.size() > 0){ + List<Long> ids = data2.stream().map(BalanceChangeRecordCopy::getId).collect(Collectors.toList()); + balanceChangeRecordClient.deleteBalanceChangeRecordCopyByIds(ids); + } } - balanceChangeRecordClient.deleteBalanceChangeRecordCopy(order.getId(), Arrays.asList(4)); List<UserPointCopy> data3 = userPointClient.getUserPointCopy(order.getId(), Arrays.asList(2,8,9,10,14)).getData(); if(null != data3){ @@ -196,8 +199,11 @@ userPoint.setId(null); userPointClient.saveUserPoint(userPoint); } + if(data3.size() > 0){ + List<Long> ids = data3.stream().map(UserPointCopy::getId).collect(Collectors.toList()); + userPointClient.deleteUserPointCopyByIds(ids); + } } - userPointClient.deleteUserPointCopy(order.getId(), Arrays.asList(2,8,9,10,14)); List<ShopBalanceStatementCopy> data4 = shopBalanceStatementClient.getShopBalanceStatementCopy(order.getId(), Arrays.asList(1,2,3)).getData(); @@ -208,8 +214,11 @@ shopBalanceStatement.setId(null); shopBalanceStatementClient.saveShopBalanceStatement(shopBalanceStatement); } + if(data4.size() > 0){ + List<Long> ids = data4.stream().map(ShopBalanceStatementCopy::getId).collect(Collectors.toList()); + shopBalanceStatementClient.deleteShopBalanceStatementCopyByIds(ids); + } } - shopBalanceStatementClient.deleteShopBalanceStatementCopy(order.getId(), Arrays.asList(1,2,3)); List<ShopPointCopy> data5 = shopPointClient.getShopPointCopy(order.getId(), Arrays.asList(1,2,3)).getData(); if(null != data5){ @@ -219,8 +228,11 @@ shopPoint.setId(null); shopPointClient.saveShopPoint(shopPoint); } + if(data5.size() > 0){ + List<Long> ids = data5.stream().map(ShopPointCopy::getId).collect(Collectors.toList()); + shopPointClient.deleteShopPointCopyByIds(ids); + } } - shopPointClient.deleteShopPointCopy(order.getId(), Arrays.asList(1,2,3)); order.setIsCommission(3); orderService.updateById(order); @@ -335,24 +347,22 @@ balanceChangeRecordCopy.setVipId(superiorLeader.getVipId()); balanceChangeRecordCopy.setOrderId(order.getId()); balanceChangeRecordCopy.setChangeType(4); - balanceChangeRecordCopy.setBeforeAmount(balance); balanceChangeRecordCopy.setChangeAmount(zdls_price); - balanceChangeRecordCopy.setAfterAmount(superiorLeader.getBalance().add(zdls_price)); balanceChangeRecordCopy.setDelFlag(0); balanceChangeRecordCopy.setCreateTime(LocalDateTime.now()); + balanceChangeRecordCopy.setChangeDirection(1); balanceChangeRecordClient.saveBalanceChangeRecordCopy(balanceChangeRecordCopy); } //添加积分明细 if(zdls_point > 0){ UserPointCopy userPointCopy = new UserPointCopy(); userPointCopy.setType(2); - userPointCopy.setHistoricalPoint(lavePoint); userPointCopy.setVariablePoint(zdls_point); - userPointCopy.setBalance(superiorLeader.getLavePoint() + zdls_point); userPointCopy.setCreateTime(LocalDateTime.now()); userPointCopy.setAppUserId(superiorLeader.getId()); userPointCopy.setObjectId(order.getId()); userPointCopy.setExtention(order.getOrderNumber()); + userPointCopy.setChangeDirection(1); userPointClient.saveUserPointCopy(userPointCopy); //变更等级 // appUserClient.vipUpgrade(superiorLeader.getId()); @@ -440,26 +450,24 @@ ShopBalanceStatementCopy shopBalanceStatementCopy = new ShopBalanceStatementCopy(); shopBalanceStatementCopy.setShopId(shop1.getId()); shopBalanceStatementCopy.setType(1); - shopBalanceStatementCopy.setHistoricalBalance(shopBalance); shopBalanceStatementCopy.setVariableAmount(fws_price); - shopBalanceStatementCopy.setBalance(shop1.getBalance().add(fws_price)); shopBalanceStatementCopy.setCreateTime(LocalDateTime.now()); shopBalanceStatementCopy.setCreateUserId(order.getAppUserId()); shopBalanceStatementCopy.setObjectId(order.getId()); shopBalanceStatementCopy.setExtension(order.getOrderNumber()); + shopBalanceStatementCopy.setChangeDirection(1); shopBalanceStatementClient.saveShopBalanceStatementCopy(shopBalanceStatementCopy); } //添加积分明细 if(fws_point > 0){ UserPointCopy userPointCopy = new UserPointCopy(); userPointCopy.setType(9); - userPointCopy.setHistoricalPoint(lavePoint); userPointCopy.setVariablePoint(fws_point); - userPointCopy.setBalance(bdShopAppUser.getLavePoint() + fws_point); userPointCopy.setCreateTime(LocalDateTime.now()); userPointCopy.setAppUserId(bdShopAppUser.getId()); userPointCopy.setObjectId(order.getId()); userPointCopy.setExtention(order.getOrderNumber()); + userPointCopy.setChangeDirection(1); userPointClient.saveUserPointCopy(userPointCopy); //变更等级 // appUserClient.vipUpgrade(bdShopAppUser.getId()); @@ -469,13 +477,12 @@ ShopPointCopy shopPointCopy = new ShopPointCopy(); shopPointCopy.setShopId(shop1.getId()); shopPointCopy.setType(2); - shopPointCopy.setHistoricalPoint(shopLavePoint); shopPointCopy.setVariablePoint(fws_point); - shopPointCopy.setBalance(shop1.getLavePoint() + fws_point); shopPointCopy.setCreateTime(LocalDateTime.now()); shopPointCopy.setCreateUserId(order.getAppUserId()); shopPointCopy.setObjectId(order.getId()); shopPointCopy.setOrderNum(order.getOrderNumber()); + shopPointCopy.setChangeDirection(1); shopPointClient.saveShopPointCopy(shopPointCopy); } } @@ -566,26 +573,24 @@ ShopBalanceStatementCopy shopBalanceStatementCopy = new ShopBalanceStatementCopy(); shopBalanceStatementCopy.setShopId(shop2.getId()); shopBalanceStatementCopy.setType(2); - shopBalanceStatementCopy.setHistoricalBalance(shopBalance); shopBalanceStatementCopy.setVariableAmount(gjfws_price); - shopBalanceStatementCopy.setBalance(shop2.getBalance().add(gjfws_price)); shopBalanceStatementCopy.setCreateTime(LocalDateTime.now()); shopBalanceStatementCopy.setCreateUserId(order.getAppUserId()); shopBalanceStatementCopy.setObjectId(order.getId()); shopBalanceStatementCopy.setExtension(order.getOrderNumber()); + shopBalanceStatementCopy.setChangeDirection(1); shopBalanceStatementClient.saveShopBalanceStatementCopy(shopBalanceStatementCopy); } //添加积分明细 if(gjfws_point > 0){ UserPointCopy userPointCopy = new UserPointCopy(); userPointCopy.setType(14); - userPointCopy.setHistoricalPoint(lavePoint); userPointCopy.setVariablePoint(gjfws_point); - userPointCopy.setBalance(sjShopAppUser.getLavePoint() + gjfws_point); userPointCopy.setCreateTime(LocalDateTime.now()); userPointCopy.setAppUserId(sjShopAppUser.getId()); userPointCopy.setObjectId(order.getId()); userPointCopy.setExtention(order.getOrderNumber()); + userPointCopy.setChangeDirection(1); userPointClient.saveUserPointCopy(userPointCopy); //变更等级 // appUserClient.vipUpgrade(sjShopAppUser.getId()); @@ -595,13 +600,12 @@ ShopPointCopy shopPointCopy = new ShopPointCopy(); shopPointCopy.setShopId(shop2.getId()); shopPointCopy.setType(3); - shopPointCopy.setHistoricalPoint(shopLavePoint); shopPointCopy.setVariablePoint(gjfws_point); - shopPointCopy.setBalance(shop2.getLavePoint() + gjfws_point); shopPointCopy.setCreateTime(LocalDateTime.now()); shopPointCopy.setCreateUserId(order.getAppUserId()); shopPointCopy.setObjectId(order.getId()); shopPointCopy.setOrderNum(order.getOrderNumber()); + shopPointCopy.setChangeDirection(1); shopPointClient.saveShopPointCopy(shopPointCopy); } } @@ -723,26 +727,24 @@ ShopBalanceStatementCopy shopBalanceStatementCopy = new ShopBalanceStatementCopy(); shopBalanceStatementCopy.setShopId(shop.getId()); shopBalanceStatementCopy.setType(3); - shopBalanceStatementCopy.setHistoricalBalance(shopBalance); shopBalanceStatementCopy.setVariableAmount(hxmd_price); - shopBalanceStatementCopy.setBalance(shop.getBalance().add(hxmd_price)); shopBalanceStatementCopy.setCreateTime(LocalDateTime.now()); shopBalanceStatementCopy.setCreateUserId(order.getAppUserId()); shopBalanceStatementCopy.setObjectId(order.getId()); shopBalanceStatementCopy.setExtension(order.getOrderNumber()); + shopBalanceStatementCopy.setChangeDirection(1); shopBalanceStatementClient.saveShopBalanceStatementCopy(shopBalanceStatementCopy); } //添加积分明细 if(hxmd_point > 0){ UserPointCopy userPointCopy = new UserPointCopy(); userPointCopy.setType(8); - userPointCopy.setHistoricalPoint(lavePoint); userPointCopy.setVariablePoint(hxmd_point); - userPointCopy.setBalance(shopAppUser.getLavePoint() + hxmd_point); userPointCopy.setCreateTime(LocalDateTime.now()); userPointCopy.setAppUserId(shopAppUser.getId()); userPointCopy.setObjectId(order.getId()); userPointCopy.setExtention(order.getOrderNumber()); + userPointCopy.setChangeDirection(1); userPointClient.saveUserPointCopy(userPointCopy); //变更等级 // appUserClient.vipUpgrade(shopAppUser.getId()); @@ -752,13 +754,12 @@ ShopPointCopy shopPointCopy = new ShopPointCopy(); shopPointCopy.setShopId(shop.getId()); shopPointCopy.setType(1); - shopPointCopy.setHistoricalPoint(shopLavePoint); shopPointCopy.setVariablePoint(hxmd_point); - shopPointCopy.setBalance(shop.getLavePoint() + hxmd_point); shopPointCopy.setCreateTime(LocalDateTime.now()); shopPointCopy.setCreateUserId(order.getAppUserId()); shopPointCopy.setObjectId(order.getId()); shopPointCopy.setOrderNum(order.getOrderNumber()); + shopPointCopy.setChangeDirection(1); shopPointClient.saveShopPointCopy(shopPointCopy); } } @@ -809,13 +810,12 @@ if(js_point > 0){ UserPointCopy userPointCopy = new UserPointCopy(); userPointCopy.setType(10); - userPointCopy.setHistoricalPoint(lavePoint); userPointCopy.setVariablePoint(js_point); - userPointCopy.setBalance(technicianAppUser.getLavePoint() + js_point); userPointCopy.setCreateTime(LocalDateTime.now()); userPointCopy.setAppUserId(technicianAppUser.getId()); userPointCopy.setObjectId(order.getId()); userPointCopy.setExtention(order.getOrderNumber()); + userPointCopy.setChangeDirection(1); userPointClient.saveUserPointCopy(userPointCopy); //变更等级 // appUserClient.vipUpgrade(technicianAppUser.getId()); diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java index f0fa211..52e263b 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java @@ -103,6 +103,7 @@ @Resource private BalanceChangeRecordClient balanceChangeRecordClient; + @Resource private UserPointClient userPointClient; @@ -468,9 +469,6 @@ if (200 != r3.getCode()) { // 项目没有分布式事务,此处报错可能会导致数据不一致 throw new RuntimeException("订单取消失败"); } - shopPointClient.deleteShopPointCopy(orderId, Arrays.asList(1,2,3)); - appUserGiveawayTemporaryClient.delAppUserGiveawayTemporary(orderId); - shopGiveawayTemporaryClient.delShopGiveawayTemporary(orderId); return r; } @@ -527,10 +525,13 @@ OrderBalancePayment orderBalancePayment = orderBalancePaymentService.getOne(new LambdaQueryWrapper<OrderBalancePayment>().eq(OrderBalancePayment::getOrderId, order.getId())); BigDecimal balance = appUser.getBalance(); if (null != orderBalancePayment) { + //回加红包金额 appUser.setTotalRedPacketAmount(appUser.getTotalRedPacketAmount().add(orderBalancePayment.getRedPacketAmount()).setScale(2, RoundingMode.HALF_EVEN)); // appUser.setTotalDistributionAmount(appUser.getTotalDistributionAmount().add(orderBalancePayment.getDistributionAmount()).setScale(2, RoundingMode.HALF_EVEN)); } + //回加账户余额 appUser.setBalance(balance.add(paymentAmount).setScale(2, RoundingMode.HALF_EVEN)); + //扣减门店消费金额 appUser.setShopAmount(appUser.getShopAmount().subtract(paymentAmount).setScale(2, RoundingMode.HALF_EVEN)); //查询最后一次的消费订单 Order order1 = this.getOne(new LambdaQueryWrapper<Order>().eq(Order::getAppUserId, order.getAppUserId()).eq(Order::getPayStatus, 2) @@ -541,24 +542,21 @@ appUser.setLastShopTime(null); } - //构建账户余额流水明细 + //构建账户余额流水明细(账户支付订单的流水,不属于冻结数据) BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord(); balanceChangeRecord.setOrderId(order.getId()); balanceChangeRecord.setAppUserId(order.getAppUserId()); balanceChangeRecord.setVipId(appUser.getVipId()); balanceChangeRecord.setChangeType(6); - balanceChangeRecord.setBeforeAmount(balance); balanceChangeRecord.setChangeAmount(paymentAmount); - balanceChangeRecord.setAfterAmount(appUser.getBalance()); balanceChangeRecord.setDelFlag(0); balanceChangeRecord.setCreateTime(LocalDateTime.now()); + balanceChangeRecord.setChangeDirection(1); balanceChangeRecordClient.saveBalanceChangeRecord(balanceChangeRecord); //退回获得的消费积分 //需要先检查会员等级时候回回退,使用回退后的会员等级查询配置 - Integer lavePoint = appUser.getLavePoint(); - UserPoint userPoint1 = new UserPoint(); userPoint1.setType(1); userPoint1.setAppUserId(appUser.getId()); @@ -577,16 +575,15 @@ } appUser.setTotalPoint(appUser.getTotalPoint() - shopPoint); - //构建积分流水明细 + //构建积分流水明细(消费金额,不属于冻结数据) if (shopPoint > 0) { UserPoint userPoint = new UserPoint(); userPoint.setType(1); - userPoint.setHistoricalPoint(lavePoint); userPoint.setVariablePoint(shopPoint); - userPoint.setBalance(appUser.getLavePoint()); userPoint.setCreateTime(LocalDateTime.now()); userPoint.setAppUserId(order.getAppUserId()); userPoint.setObjectId(order.getId()); + userPoint.setChangeDirection(-1); userPointClient.saveUserPoint(userPoint); } appUserClient.editAppUserById(appUser); @@ -624,17 +621,16 @@ // appUser.setTotalDistributionAmount(appUser.getTotalDistributionAmount().add(orderBalancePayment.getDistributionAmount()).setScale(2, RoundingMode.HALF_EVEN)); } appUser.setBalance(balance.add(expressAmount).setScale(2, RoundingMode.HALF_EVEN)); - //构建账户余额流水明细 + //构建账户余额流水明细(消费支付的余额流水) BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord(); balanceChangeRecord.setOrderId(order.getId()); balanceChangeRecord.setAppUserId(order.getAppUserId()); balanceChangeRecord.setVipId(appUser.getVipId()); balanceChangeRecord.setChangeType(6); - balanceChangeRecord.setBeforeAmount(balance); balanceChangeRecord.setChangeAmount(expressAmount); - balanceChangeRecord.setAfterAmount(appUser.getBalance()); balanceChangeRecord.setDelFlag(0); balanceChangeRecord.setCreateTime(LocalDateTime.now()); + balanceChangeRecord.setChangeDirection(1); balanceChangeRecordClient.saveBalanceChangeRecord(balanceChangeRecord); } } @@ -654,16 +650,15 @@ } appUser.setTransferablePoint(appUser.getTransferablePoint() + transferablePoint); - //构建积分流水明细 + //构建积分流水明细(支付的积分,不属于冻结数据) if (order.getPoint() > 0) { UserPoint userPoint = new UserPoint(); userPoint.setType(11); - userPoint.setHistoricalPoint(lavePoint); userPoint.setVariablePoint(order.getPoint()); - userPoint.setBalance(appUser.getLavePoint()); userPoint.setCreateTime(LocalDateTime.now()); userPoint.setAppUserId(order.getAppUserId()); userPoint.setObjectId(order.getId()); + userPoint.setChangeDirection(1); userPointClient.saveUserPoint(userPoint); } appUserClient.editAppUserById(appUser); @@ -672,8 +667,36 @@ order.setRefundStatus(2); order.setRefundTime(LocalDateTime.now()); - shopPointClient.deleteShopPointCopy(order.getId(), Arrays.asList(1,2,3)); - shopBalanceStatementClient.deleteShopBalanceStatementCopy(order.getId(), Arrays.asList(1,2,3)); + //生成反向冻结流水数据 + List<UserPointCopy> data2 = userPointClient.getUserPointCopy(order.getId(), Arrays.asList(2, 8, 9, 10, 14)).getData(); + for (UserPointCopy userPointCopy : data2) { + userPointCopy.setId(null); + userPointCopy.setCreateTime(LocalDateTime.now()); + userPointCopy.setChangeDirection(-1); + userPointClient.saveUserPointCopy(userPointCopy); + } + List<BalanceChangeRecordCopy> data3 = balanceChangeRecordClient.getBalanceChangeRecordCopy(order.getId(), Arrays.asList(4)).getData(); + for (BalanceChangeRecordCopy balanceChangeRecordCopy : data3) { + balanceChangeRecordCopy.setId(null); + balanceChangeRecordCopy.setCreateTime(LocalDateTime.now()); + balanceChangeRecordCopy.setChangeDirection(-1); + balanceChangeRecordClient.saveBalanceChangeRecordCopy(balanceChangeRecordCopy); + } + List<ShopPointCopy> data = shopPointClient.getShopPointCopy(order.getId(), Arrays.asList(1, 2, 3)).getData(); + for (ShopPointCopy datum : data) { + datum.setId(null); + datum.setCreateTime(LocalDateTime.now()); + datum.setChangeDirection(-1); + shopPointClient.saveShopPointCopy(datum); + } + List<ShopBalanceStatementCopy> data1 = shopBalanceStatementClient.getShopBalanceStatementCopy(order.getId(), Arrays.asList(1, 2, 3)).getData(); + for (ShopBalanceStatementCopy shopBalanceStatementCopy : data1) { + shopBalanceStatementCopy.setId(null); + shopBalanceStatementCopy.setCreateTime(LocalDateTime.now()); + shopBalanceStatementCopy.setChangeDirection(-1); + shopBalanceStatementClient.saveShopBalanceStatementCopy(shopBalanceStatementCopy); + } + //删除用户和门店添加的汇总数据(冻结数据) appUserGiveawayTemporaryClient.delAppUserGiveawayTemporary(order.getId()); shopGiveawayTemporaryClient.delShopGiveawayTemporary(order.getId()); return R.ok(); @@ -722,12 +745,11 @@ if (shopPoint > 0) { UserPoint userPoint = new UserPoint(); userPoint.setType(1); - userPoint.setHistoricalPoint(lavePoint); userPoint.setVariablePoint(shopPoint); - userPoint.setBalance(appUser.getLavePoint()); userPoint.setCreateTime(LocalDateTime.now()); userPoint.setAppUserId(order.getAppUserId()); userPoint.setObjectId(order.getId()); + userPoint.setChangeDirection(-1); userPointClient.saveUserPoint(userPoint); } appUserClient.editAppUserById(appUser); @@ -784,12 +806,11 @@ if (order.getPoint() > 0) { UserPoint userPoint = new UserPoint(); userPoint.setType(11); - userPoint.setHistoricalPoint(lavePoint); userPoint.setVariablePoint(order.getPoint()); - userPoint.setBalance(appUser.getLavePoint()); userPoint.setCreateTime(LocalDateTime.now()); userPoint.setAppUserId(order.getAppUserId()); userPoint.setObjectId(order.getId()); + userPoint.setChangeDirection(1); userPointClient.saveUserPoint(userPoint); } return R.ok(); @@ -1167,4 +1188,16 @@ public List<OrderExport> getOrderExportList(OrderPageList orderPageList) { return Collections.emptyList(); } + + + /** + * 查询给定用户在给定门店核销的订单 + * @param shopId + * @param appUserId + * @return + */ + @Override + public List<Order> getOrderByAppUserIdsAndWriteOffShop(Integer shopId, Set<Long> appUserId) { + return this.baseMapper.getOrderByAppUserIdsAndWriteOffShop(shopId, appUserId); + } } diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java index ee69283..134fe1a 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java @@ -1152,13 +1152,12 @@ if(earnPoint > 0){ UserPoint userPoint = new UserPoint(); userPoint.setType(1); - userPoint.setHistoricalPoint(lavePoint); userPoint.setVariablePoint(earnPoint); - userPoint.setBalance(appUser.getLavePoint()); userPoint.setCreateTime(LocalDateTime.now()); userPoint.setAppUserId(appUser.getId()); userPoint.setObjectId(order.getId()); userPoint.setExtention(jsonObject.toJSONString()); + userPoint.setChangeDirection(1); userPointClient.saveUserPoint(userPoint); } } @@ -1257,13 +1256,12 @@ if(earnPoint > 0){ UserPoint userPoint = new UserPoint(); userPoint.setType(1); - userPoint.setHistoricalPoint(appUser.getLavePoint() - earnPoint); userPoint.setVariablePoint(earnPoint); - userPoint.setBalance(appUser.getLavePoint()); userPoint.setCreateTime(LocalDateTime.now()); userPoint.setAppUserId(appUser.getId()); userPoint.setObjectId(order.getId()); userPoint.setExtention(jsonObject.toJSONString()); + userPoint.setChangeDirection(1); userPointClient.saveUserPoint(userPoint); } } @@ -1278,11 +1276,10 @@ balanceChangeRecord.setVipId(appUser.getVipId()); balanceChangeRecord.setOrderId(order.getId()); balanceChangeRecord.setChangeType(5); - balanceChangeRecord.setBeforeAmount(balance.add(paymentMoney)); balanceChangeRecord.setChangeAmount(paymentMoney); - balanceChangeRecord.setAfterAmount(balance); balanceChangeRecord.setDelFlag(0); balanceChangeRecord.setCreateTime(LocalDateTime.now()); + balanceChangeRecord.setChangeDirection(-1); balanceChangeRecordClient.saveBalanceChangeRecord(balanceChangeRecord); //修改订支付状态 order.setPayStatus(2); @@ -1341,13 +1338,12 @@ if(orderPoint > 0){ UserPoint userPoint = new UserPoint(); userPoint.setType(11); - userPoint.setHistoricalPoint(lavePoint); userPoint.setVariablePoint(orderPoint); - userPoint.setBalance(appUser.getLavePoint()); userPoint.setCreateTime(LocalDateTime.now()); userPoint.setAppUserId(appUser.getId()); userPoint.setObjectId(order.getId()); userPoint.setExtention((tra >= 0 ? orderPoint : transferablePoint) + ""); + userPoint.setChangeDirection(-1); userPointClient.saveUserPoint(userPoint); } @@ -1400,11 +1396,10 @@ balanceChangeRecord.setVipId(appUser.getVipId()); balanceChangeRecord.setOrderId(order.getId()); balanceChangeRecord.setChangeType(5); - balanceChangeRecord.setBeforeAmount(balance.add(expressFee)); balanceChangeRecord.setChangeAmount(expressFee); - balanceChangeRecord.setAfterAmount(balance); balanceChangeRecord.setDelFlag(0); balanceChangeRecord.setCreateTime(LocalDateTime.now()); + balanceChangeRecord.setChangeDirection(-1); balanceChangeRecordClient.saveBalanceChangeRecord(balanceChangeRecord); //修改订支付状态 order.setPayStatus(2); @@ -1498,13 +1493,12 @@ if(earnPoint > 0){ UserPoint userPoint = new UserPoint(); userPoint.setType(1); - userPoint.setHistoricalPoint(lavePoint); userPoint.setVariablePoint(earnPoint); - userPoint.setBalance(appUser.getLavePoint()); userPoint.setCreateTime(LocalDateTime.now()); userPoint.setAppUserId(appUser.getId()); userPoint.setObjectId(order.getId()); userPoint.setExtention(jsonObject.toJSONString()); + userPoint.setChangeDirection(1); userPointClient.saveUserPoint(userPoint); } } @@ -1584,13 +1578,12 @@ if(orderPoint > 0){ UserPoint userPoint = new UserPoint(); userPoint.setType(11); - userPoint.setHistoricalPoint(lavePoint); userPoint.setVariablePoint(orderPoint); - userPoint.setBalance(appUser.getLavePoint()); userPoint.setCreateTime(LocalDateTime.now()); userPoint.setAppUserId(appUser.getId()); userPoint.setObjectId(order.getId()); userPoint.setExtention((tra >= 0 ? orderPoint : transferablePoint) + ""); + userPoint.setChangeDirection(-1); userPointClient.saveUserPoint(userPoint); } diff --git a/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml b/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml index 9a95ea0..6f60683 100644 --- a/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml +++ b/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml @@ -226,4 +226,19 @@ </if> order by o.create_time desc </select> + + + + <select id="getOrderByAppUserIdsAndWriteOffShop" resultType="com.ruoyi.order.model.Order"> + select * from t_order where del_flag = 0 and pay_status = 2 and order_status in (1, 2, 3, 4, 5, 7, 8) + <if test="null != shopId and 0 != shopId"> + and shop_id = #{shopId} and (order_type = 1 or (order_type = 2 and distribution_mode = 1)) + </if> + <if test="null != appUserId and appUserId.size() > 0"> + and app_user_id in + <foreach collection="appUserId" item="item" index="index" open="(" separator="," close=")"> + #{item} + </foreach> + </if> + </select> </mapper> diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShareController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShareController.java index efd454d..1ec67ed 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShareController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShareController.java @@ -333,11 +333,10 @@ UserPoint userPoint = new UserPoint(); userPoint.setAppUserId(userid); userPoint.setType(4); - userPoint.setHistoricalPoint(lavePoint); userPoint.setVariablePoint(everySharePoint); - userPoint.setBalance(appUser.getLavePoint()); userPoint.setCreateTime(LocalDateTime.now()); userPoint.setAppUserId(appUser.getId()); + userPoint.setChangeDirection(1); userPointClient.saveUserPoint(userPoint); } } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopBalanceStatementController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopBalanceStatementController.java index e14d195..8fb928f 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopBalanceStatementController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopBalanceStatementController.java @@ -226,7 +226,15 @@ .eq(ShopBalanceStatementCopy::getObjectId, orderId)); return R.ok(); } - + + + + @DeleteMapping("/deleteShopBalanceStatementCopyByIds") + public R<Boolean> deleteShopBalanceStatementCopyByIds(@RequestParam("ids") List<Long> ids){ + shopBalanceStatementCopyMapper.deleteBatchIds(ids); + return R.ok(); + } + @PostMapping("/getShopBalanceStatementCopy") public R<List<ShopBalanceStatementCopy>> getShopBalanceStatementCopy(@RequestParam("orderId") Long orderId, @RequestParam("type") List<Integer> type) { @@ -379,9 +387,7 @@ detail.setTime(copy.getCreateTime()); detail.setAmount(copy.getVariableAmount()); - BigDecimal beforeAmount = copy.getHistoricalBalance(); - BigDecimal afterAmount = copy.getBalance(); - if (beforeAmount.compareTo(afterAmount) > 0) { + if (copy.getChangeDirection() == -1) { detail.setType(2); } else { detail.setType(1); @@ -395,9 +401,7 @@ detail.setTime(statement.getCreateTime()); detail.setAmount(statement.getVariableAmount()); - BigDecimal beforeAmount = statement.getHistoricalBalance(); - BigDecimal afterAmount = statement.getBalance(); - if (beforeAmount.compareTo(afterAmount) > 0) { + if (statement.getChangeDirection() == -1) { detail.setType(2); } else { detail.setType(1); diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopPointController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopPointController.java index de691c8..9530eb1 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopPointController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopPointController.java @@ -127,6 +127,12 @@ } + @DeleteMapping("/deleteShopPointCopyByIds") + public void deleteShopPointCopyByIds(@RequestParam("ids") List<Long> ids){ + shopPointCopyMapper.deleteBatchIds(ids); + } + + @PostMapping("/getShopPointCopy") public R<List<ShopPointCopy>> getShopPointCopy(@RequestParam("orderId") Long orderId, @RequestParam("type") List<Integer> type){ List<ShopPointCopy> shopPointCopies = shopPointCopyMapper.selectList(new LambdaQueryWrapper<ShopPointCopy>().in(ShopPointCopy::getType, type) diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopWithdrawController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopWithdrawController.java index b5ab210..828b3c1 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopWithdrawController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopWithdrawController.java @@ -208,12 +208,11 @@ ShopBalanceStatement shopBalanceStatement = new ShopBalanceStatement(); shopBalanceStatement.setShopId(shop.getId()); shopBalanceStatement.setType(4); - shopBalanceStatement.setHistoricalBalance(balance); shopBalanceStatement.setVariableAmount(money); - shopBalanceStatement.setBalance(shop.getBalance()); shopBalanceStatement.setCreateUserId(userId); shopBalanceStatement.setCreateTime(LocalDateTime.now()); shopBalanceStatement.setObjectId(shopWithdraw.getId()); + shopBalanceStatement.setChangeDirection(-1); shopBalanceStatementService.save(shopBalanceStatement); } @@ -274,12 +273,11 @@ ShopBalanceStatement shopBalanceStatement = new ShopBalanceStatement(); shopBalanceStatement.setShopId(shop.getId()); shopBalanceStatement.setType(4); - shopBalanceStatement.setHistoricalBalance(balance); shopBalanceStatement.setVariableAmount(money); - shopBalanceStatement.setBalance(shop.getBalance()); shopBalanceStatement.setCreateUserId(loginUser.getUserid()); shopBalanceStatement.setCreateTime(LocalDateTime.now()); shopBalanceStatement.setObjectId(shopWithdraw.getId()); + shopBalanceStatement.setChangeDirection(-1); shopBalanceStatementService.save(shopBalanceStatement); } shopWithdraw1.setAuditStatus(shopWithdraw.getAuditStatus()); @@ -325,12 +323,11 @@ ShopBalanceStatement shopBalanceStatement = new ShopBalanceStatement(); shopBalanceStatement.setShopId(shop.getId()); shopBalanceStatement.setType(4); - shopBalanceStatement.setHistoricalBalance(balance); shopBalanceStatement.setVariableAmount(shopWithdraw.getMoney()); - shopBalanceStatement.setBalance(shop.getBalance()); shopBalanceStatement.setCreateUserId(shopWithdraw.getAuditUserId()); shopBalanceStatement.setCreateTime(LocalDateTime.now()); shopBalanceStatement.setObjectId(shopWithdraw.getId()); + shopBalanceStatement.setChangeDirection(-1); shopBalanceStatementService.save(shopBalanceStatement); shopWithdraw.setStatus(3); shopWithdraw.setRemark(singlePayCallbackResult.getErrorCodeDesc()); diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopBalanceStatementServiceImpl.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopBalanceStatementServiceImpl.java index 9799f6b..31797f0 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopBalanceStatementServiceImpl.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopBalanceStatementServiceImpl.java @@ -51,14 +51,11 @@ shopCommissionStatisticsVO.setTotalAmount(totalAmount); IPage<ShopBalanceStatement> statementIPage = this.baseMapper.queryShopBalanceStatementPage(page, shopBalanceStatement); for (ShopBalanceStatement record : statementIPage.getRecords()) { - BigDecimal subtract = record.getHistoricalBalance().subtract(record.getBalance()); - if (subtract.compareTo(BigDecimal.ZERO)>0){ + if (record.getChangeDirection() == -1){ // 减少 record.setVariableAmountString("-¥"+record.getVariableAmount()); - }else if (subtract.compareTo(BigDecimal.ZERO)<0){ - record.setVariableAmountString("+¥"+record.getVariableAmount()); }else{ - record.setVariableAmountString("¥"+record.getVariableAmount()); + record.setVariableAmountString("+¥"+record.getVariableAmount()); } } shopCommissionStatisticsVO.setStatementIPage(statementIPage); -- Gitblit v1.7.1