From 0918b9ca8806a58e87a58036c51bbfe57ce9c73f Mon Sep 17 00:00:00 2001 From: 13233904609 <13233904609@163.cm> Date: Mon, 5 Aug 2024 09:11:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=BD=E5=A5=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yudao-module-product-biz/pom.xml | 5 + .../app/spu/AppProductSpuController.java | 43 ++++ .../member/MemberStatisticsController.java | 2 +- .../trade/enums/ErrorCodeConstants.java | 1 + .../brokerage/BrokerageRecordBizTypeEnum.java | 1 + .../DeliveryPickUpStoreController.java | 2 +- .../admin/order/TradeOrderController.java | 14 +- .../admin/verifylog/VerifyLogController.java | 113 ++++++++++ .../verifylog/vo/VerifyLogPageReqVO.java | 41 ++++ .../admin/verifylog/vo/VerifyLogRespVO.java | 63 ++++++ .../verifylog/vo/VerifyLogSaveReqVO.java | 35 +++ .../brokerage/AppBrokerageUserController.java | 22 +- .../AppBrokerageWithdrawController.java | 7 + .../brokerage/BrokerageRecordConvert.java | 17 ++ .../convert/verifylog/VerifyLogConvert.java | 32 +++ .../dal/dataobject/verifylog/VerifyLogDO.java | 56 +++++ .../dal/mysql/verifylog/VerifyLogMapper.java | 53 +++++ .../brokerage/BrokerageRecordService.java | 22 ++ .../brokerage/BrokerageRecordServiceImpl.java | 32 +++ .../brokerage/BrokerageWithdrawService.java | 8 + .../BrokerageWithdrawServiceImpl.java | 48 +++- .../order/TradeOrderUpdateServiceImpl.java | 37 +++- .../service/verifylog/VerifyLogService.java | 62 ++++++ .../verifylog/VerifyLogServiceImpl.java | 84 +++++++ .../DistributionStatisticsServiceImpl.java | 1 - .../service/user/MemberUserServiceImpl.java | 32 ++- .../module/pay/api/wallet/PayWalletApi.java | 84 +++++++ .../pay/api/wallet/dto/PayWalletDTO.java | 79 +++++++ .../pay/api/wallet/dto/PayWalletRespDTO.java | 36 +++ .../wallet/dto/PayWalletTransactionDTO.java | 85 +++++++ .../enums/wallet/PayWalletBizTypeEnum.java | 6 +- .../pay/api/wallet/PayWalletApiImpl.java | 82 +++++++ .../pay/service/wallet/PayWalletService.java | 11 + .../service/wallet/PayWalletServiceImpl.java | 57 +++++ yudao-ui-admin-vue3-master/.env.dev | 16 +- .../src/api/trade/verifylog/index.ts | 49 +++++ .../views/Home/components/ComparisonCard.vue | 42 ++++ .../Home/components/MemberStatisticsCard.vue | 91 ++++++++ .../Home/components/OperationDataCard.vue | 92 ++++++++ .../views/Home/components/ShortcutCard.vue | 82 +++++++ .../views/Home/components/TradeTrendCard.vue | 208 ++++++++++++++++++ .../mall/trade/delivery/pickUpOrder/index.vue | 2 +- .../member/distributionstatistics/index.vue | 1 - .../views/trade/verifylog/VerifyLogForm.vue | 123 +++++++++++ .../src/views/trade/verifylog/index.vue | 166 ++++++++++++++ 45 files changed, 2106 insertions(+), 39 deletions(-) create mode 100644 ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/verifylog/VerifyLogController.java create mode 100644 ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/verifylog/vo/VerifyLogPageReqVO.java create mode 100644 ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/verifylog/vo/VerifyLogRespVO.java create mode 100644 ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/verifylog/vo/VerifyLogSaveReqVO.java create mode 100644 ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/verifylog/VerifyLogConvert.java create mode 100644 ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/verifylog/VerifyLogDO.java create mode 100644 ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/verifylog/VerifyLogMapper.java create mode 100644 ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/verifylog/VerifyLogService.java create mode 100644 ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/verifylog/VerifyLogServiceImpl.java create mode 100644 ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/PayWalletApi.java create mode 100644 ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/dto/PayWalletDTO.java create mode 100644 ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/dto/PayWalletRespDTO.java create mode 100644 ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/dto/PayWalletTransactionDTO.java create mode 100644 ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/PayWalletApiImpl.java create mode 100644 yudao-ui-admin-vue3-master/src/api/trade/verifylog/index.ts create mode 100644 yudao-ui-admin-vue3-master/src/views/Home/components/ComparisonCard.vue create mode 100644 yudao-ui-admin-vue3-master/src/views/Home/components/MemberStatisticsCard.vue create mode 100644 yudao-ui-admin-vue3-master/src/views/Home/components/OperationDataCard.vue create mode 100644 yudao-ui-admin-vue3-master/src/views/Home/components/ShortcutCard.vue create mode 100644 yudao-ui-admin-vue3-master/src/views/Home/components/TradeTrendCard.vue create mode 100644 yudao-ui-admin-vue3-master/src/views/trade/verifylog/VerifyLogForm.vue create mode 100644 yudao-ui-admin-vue3-master/src/views/trade/verifylog/index.vue diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-product-biz/pom.xml b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-product-biz/pom.xml index c8bad46..3ee3ef0 100644 --- a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-product-biz/pom.xml +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-product-biz/pom.xml @@ -28,6 +28,11 @@ yudao-module-member-api ${revision} + + cn.iocoder.boot + yudao-module-trade-api + ${revision} + diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java index f64e6f5..d3120c6 100644 --- a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java @@ -1,13 +1,19 @@ package cn.iocoder.yudao.module.product.controller.app.spu; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils; +import cn.iocoder.yudao.module.member.api.distributionconfig.DistributionConfigApi; +import cn.iocoder.yudao.module.member.api.distributionconfig.vo.DistributionConfigRespDTO; import cn.iocoder.yudao.module.member.api.level.MemberLevelApi; import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO; import cn.iocoder.yudao.module.member.api.user.MemberUserApi; import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; +import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; +import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuDetailRespVO; import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuRespVO; @@ -17,9 +23,11 @@ import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; import cn.iocoder.yudao.module.product.service.history.ProductBrowseHistoryService; import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; +import cn.iocoder.yudao.module.trade.api.order.TradeOrderApi; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.context.annotation.Lazy; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -33,6 +41,7 @@ import java.util.List; import java.util.Set; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.error; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_NOT_ENABLE; @@ -56,6 +65,13 @@ public class AppProductSpuController { @Resource private MemberUserApi memberUserApi; + @Resource + private DistributionConfigApi distributionConfigApi; + + @Resource + @Lazy // 延迟加载,解决循环依赖的问题 + private TradeOrderApi tradeOrderApi; + @GetMapping("/list-by-ids") @Operation(summary = "获得商品 SPU 列表") @Parameter(name = "ids", description = "编号列表", required = true) @@ -95,8 +111,35 @@ public class AppProductSpuController { @Operation(summary = "获得商品 SPU 明细") @Parameter(name = "id", description = "编号", required = true) public CommonResult getSpuDetail(@RequestParam("id") Long id) { + + //获取用户id + Long loginUserId = WebFrameworkUtils.getLoginUserId(); // 获得商品 SPU ProductSpuDO spu = productSpuService.getSpu(id); + //判断商品是否需要会员等级 + List distributionConfigDOS = distributionConfigApi.distributionConfigDOS(id); + if(ObjectUtil.isNotEmpty(distributionConfigDOS)){ + DistributionConfigRespDTO distributionConfigDO = distributionConfigDOS.get(0); + if(ObjectUtil.isNotEmpty(distributionConfigDO.getBuyerLevelId())){ + //查询会员当前等级 + MemberLevelRespDTO memberLevelDO = memberLevelApi.getMemberLevel(distributionConfigDO.getBuyerLevelId()); + //查询会员当前等级 + MemberUserRespDTO user = memberUserApi.getUser(loginUserId); + MemberLevelRespDTO memberLevelDO1 = memberLevelApi.getMemberLevel(user.getLevelId()); + if(ObjectUtil.isEmpty(memberLevelDO1)){ + return error(1_013_018_008,"商品"+spu.getName()+"购买需要升级至会员等级"+memberLevelDO.getName()); + } + if(memberLevelDO.getLevel()>memberLevelDO1.getLevel()){ + return error(1_013_018_008,"商品"+spu.getName()+"购买需要升级至会员等级"+memberLevelDO.getName()); + } + } + Integer orderCountBySpuId = tradeOrderApi.getOrderCountBySpuId(id); + if(ObjectUtil.isNotEmpty(distributionConfigDO.getPurchaseNum())){ + if(orderCountBySpuId>=distributionConfigDO.getPurchaseNum()){ + return error(1_013_018_009,"商品"+spu.getName()+"购买已达上限"); + } + } + } if (spu == null) { throw exception(SPU_NOT_EXISTS); } diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/MemberStatisticsController.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/MemberStatisticsController.java index 9b0f715..3c00771 100644 --- a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/MemberStatisticsController.java +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/MemberStatisticsController.java @@ -98,7 +98,7 @@ public class MemberStatisticsController { // TODO @疯狂:要注意 date 的排序; @GetMapping("/user-count-comparison") @Operation(summary = "获得用户数量对照") - @PreAuthorize("@ss.hasPermission('statistics:member:query')") +// @PreAuthorize("@ss.hasPermission('statistics:member:query')") public CommonResult> getUserCountComparison() { return success(memberStatisticsService.getUserCountComparison()); } diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java index 33081d4..02173a6 100644 --- a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java @@ -93,4 +93,5 @@ public interface ErrorCodeConstants { ErrorCode BROKERAGE_WITHDRAW_MIN_PRICE = new ErrorCode(1_011_008_002, "提现金额不能低于 {} 元"); ErrorCode BROKERAGE_WITHDRAW_USER_BALANCE_NOT_ENOUGH = new ErrorCode(1_011_008_003, "您当前最多可提现 {} 元"); + ErrorCode VERIFY_LOG_NOT_EXISTS = new ErrorCode(1_011_008_004, "门店核销记录不存在"); } diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageRecordBizTypeEnum.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageRecordBizTypeEnum.java index 5460694..8e154a5 100644 --- a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageRecordBizTypeEnum.java +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageRecordBizTypeEnum.java @@ -17,6 +17,7 @@ public enum BrokerageRecordBizTypeEnum implements IntArrayValuable { ORDER(1, "获得推广佣金", "获得推广佣金 {}", true), WITHDRAW(2, "提现申请", "提现申请扣除佣金 {}", false), + WITHDRAWWEALLET(4, "提现申请", "提现申请扣除余额 {}", false), WITHDRAW_REJECT(3, "提现申请驳回", "提现申请驳回,返还佣金 {}", true), ; diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryPickUpStoreController.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryPickUpStoreController.java index 4235d6e..e449d37 100644 --- a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryPickUpStoreController.java +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryPickUpStoreController.java @@ -57,7 +57,7 @@ public class DeliveryPickUpStoreController { @GetMapping("/get") @Operation(summary = "获得自提门店") @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('trade:delivery:pick-up-store:query')") +// @PreAuthorize("@ss.hasPermission('trade:delivery:pick-up-store:query')") public CommonResult getDeliveryPickUpStore(@RequestParam("id") Long id) { DeliveryPickUpStoreDO deliveryPickUpStore = deliveryPickUpStoreService.getDeliveryPickUpStore(id); return success(DeliveryPickUpStoreConvert.INSTANCE.convert(deliveryPickUpStore)); diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.java index 9c9b973..f1a851a 100644 --- a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.java +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.java @@ -53,7 +53,7 @@ public class TradeOrderController { @GetMapping("/page") @Operation(summary = "获得交易订单分页") - @PreAuthorize("@ss.hasPermission('trade:order:query')") +// @PreAuthorize("@ss.hasPermission('trade:order:query')") public CommonResult> getOrderPage(TradeOrderPageReqVO reqVO) { // 查询订单 PageResult pageResult = tradeOrderQueryService.getOrderPage(reqVO); @@ -74,7 +74,7 @@ public class TradeOrderController { @GetMapping("/summary") @Operation(summary = "获得交易订单统计") - @PreAuthorize("@ss.hasPermission('trade:order:query')") +// @PreAuthorize("@ss.hasPermission('trade:order:query')") public CommonResult getOrderSummary(TradeOrderPageReqVO reqVO) { return success(tradeOrderQueryService.getOrderSummary(reqVO)); } @@ -82,7 +82,7 @@ public class TradeOrderController { @GetMapping("/get-detail") @Operation(summary = "获得交易订单详情") @Parameter(name = "id", description = "订单编号", required = true, example = "1") - @PreAuthorize("@ss.hasPermission('trade:order:query')") +// @PreAuthorize("@ss.hasPermission('trade:order:query')") public CommonResult getOrderDetail(@RequestParam("id") Long id) { // 查询订单 TradeOrderDO order = tradeOrderQueryService.getOrder(id); @@ -103,7 +103,7 @@ public class TradeOrderController { @GetMapping("/get-express-track-list") @Operation(summary = "获得交易订单的物流轨迹") @Parameter(name = "id", description = "交易订单编号") - @PreAuthorize("@ss.hasPermission('trade:order:query')") +// @PreAuthorize("@ss.hasPermission('trade:order:query')") public CommonResult> getOrderExpressTrackList(@RequestParam("id") Long id) { return success(TradeOrderConvert.INSTANCE.convertList02( tradeOrderQueryService.getExpressTrackList(id))); @@ -144,7 +144,7 @@ public class TradeOrderController { @PutMapping("/pick-up-by-id") @Operation(summary = "订单核销") @Parameter(name = "id", description = "交易订单编号") - @PreAuthorize("@ss.hasPermission('trade:order:pick-up')") +// @PreAuthorize("@ss.hasPermission('trade:order:pick-up')") public CommonResult pickUpOrderById(@RequestParam("id") Long id) { tradeOrderUpdateService.pickUpOrderByAdmin(id); return success(true); @@ -153,7 +153,7 @@ public class TradeOrderController { @PutMapping("/pick-up-by-verify-code") @Operation(summary = "订单核销") @Parameter(name = "pickUpVerifyCode", description = "自提核销码") - @PreAuthorize("@ss.hasPermission('trade:order:pick-up')") +// @PreAuthorize("@ss.hasPermission('trade:order:pick-up')") public CommonResult pickUpOrderByVerifyCode(@RequestParam("pickUpVerifyCode") String pickUpVerifyCode) { // 根据管理系统登录用户信息获取APP系统用户信息 String mobile = getLoginUserMobile(); @@ -165,7 +165,7 @@ public class TradeOrderController { @GetMapping("/get-by-pick-up-verify-code") @Operation(summary = "查询核销码对应的订单") @Parameter(name = "pickUpVerifyCode", description = "自提核销码") - @PreAuthorize("@ss.hasPermission('trade:order:query')") +// @PreAuthorize("@ss.hasPermission('trade:order:query')") public CommonResult getByPickUpVerifyCode(@RequestParam("pickUpVerifyCode") String pickUpVerifyCode) { TradeOrderDO tradeOrder = tradeOrderUpdateService.getByPickUpVerifyCode(pickUpVerifyCode); return success(TradeOrderConvert.INSTANCE.convert2(tradeOrder, null)); diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/verifylog/VerifyLogController.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/verifylog/VerifyLogController.java new file mode 100644 index 0000000..8cb08f8 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/verifylog/VerifyLogController.java @@ -0,0 +1,113 @@ +package cn.iocoder.yudao.module.trade.controller.admin.verifylog; + +import cn.iocoder.yudao.module.member.api.user.MemberUserApi; +import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; +import cn.iocoder.yudao.module.trade.convert.verifylog.VerifyLogConvert; +import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.security.access.prepost.PreAuthorize; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Operation; + +import javax.validation.constraints.*; +import javax.validation.*; +import javax.servlet.http.*; +import java.util.*; +import java.io.IOException; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; + +import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; + +import cn.iocoder.yudao.module.trade.controller.admin.verifylog.vo.*; +import cn.iocoder.yudao.module.trade.dal.dataobject.verifylog.VerifyLogDO; +import cn.iocoder.yudao.module.trade.service.verifylog.VerifyLogService; + +@Tag(name = "管理后台 - 门店核销记录") +@RestController +@RequestMapping("/trade/verify-log") +@Validated +public class VerifyLogController { + + @Resource + private VerifyLogService verifyLogService; + + @Resource + private MemberUserApi memberUserApi; + + @PostMapping("/create") + @Operation(summary = "创建门店核销记录") + @PreAuthorize("@ss.hasPermission('trade:verify-log:create')") + public CommonResult createVerifyLog(@Valid @RequestBody VerifyLogSaveReqVO createReqVO) { + return success(verifyLogService.createVerifyLog(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新门店核销记录") + @PreAuthorize("@ss.hasPermission('trade:verify-log:update')") + public CommonResult updateVerifyLog(@Valid @RequestBody VerifyLogSaveReqVO updateReqVO) { + verifyLogService.updateVerifyLog(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除门店核销记录") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('trade:verify-log:delete')") + public CommonResult deleteVerifyLog(@RequestParam("id") Long id) { + verifyLogService.deleteVerifyLog(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得门店核销记录") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('trade:verify-log:query')") + public CommonResult getVerifyLog(@RequestParam("id") Long id) { + VerifyLogDO verifyLog = verifyLogService.getVerifyLog(id); + return success(BeanUtils.toBean(verifyLog, VerifyLogRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得门店核销记录分页") + @PreAuthorize("@ss.hasPermission('trade:verify-log:query')") + public CommonResult> getVerifyLogPage(@Valid VerifyLogPageReqVO pageReqVO) { + PageResult pageResult = verifyLogService.getVerifyLogPage(pageReqVO); + List users = memberUserApi.getUserList( + convertSet(pageResult.getList(), VerifyLogRespVO::getMebId)); + return success(VerifyLogConvert.INSTANCE.convertPage(pageResult, users)); +// return success(BeanUtils.toBean(pageResult, VerifyLogRespVO.class)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出门店核销记录 Excel") + @PreAuthorize("@ss.hasPermission('trade:verify-log:export')") + @ApiAccessLog(operateType = EXPORT) + public void exportVerifyLogExcel(@Valid VerifyLogPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = verifyLogService.getVerifyLogPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "门店核销记录.xls", "数据", VerifyLogRespVO.class, + BeanUtils.toBean(list, VerifyLogRespVO.class)); + } + + @PutMapping("/updateAlready") + @Operation(summary = "结算核销统计") + @PreAuthorize("@ss.hasPermission('member:distribution-statistics:update')") + public CommonResult updateAlready(@Valid @RequestBody VerifyLogSaveReqVO updateReqVO) { + verifyLogService.updateAlready(updateReqVO); + return success(true); + } + +} diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/verifylog/vo/VerifyLogPageReqVO.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/verifylog/vo/VerifyLogPageReqVO.java new file mode 100644 index 0000000..4a631a0 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/verifylog/vo/VerifyLogPageReqVO.java @@ -0,0 +1,41 @@ +package cn.iocoder.yudao.module.trade.controller.admin.verifylog.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 门店核销记录分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class VerifyLogPageReqVO extends PageParam { + + @Schema(description = "会员id", example = "11234") + private Long mebId; + + @Schema(description = "订单id", example = "20689") + private Long orderId; + + @Schema(description = "核销编码") + private String pickUpVerifyCode; + + @Schema(description = "核销时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] verifyTime; + + @Schema(description = "兑换状态", example = "1") + private String status; + + @Schema(description = "备注", example = "你猜") + private String remark; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/verifylog/vo/VerifyLogRespVO.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/verifylog/vo/VerifyLogRespVO.java new file mode 100644 index 0000000..786ab33 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/verifylog/vo/VerifyLogRespVO.java @@ -0,0 +1,63 @@ +package cn.iocoder.yudao.module.trade.controller.admin.verifylog.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; +import com.alibaba.excel.annotation.*; + +@Schema(description = "管理后台 - 门店核销记录 Response VO") +@Data +@ExcelIgnoreUnannotated +public class VerifyLogRespVO { + + @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24309") + @ExcelProperty("订单编号") + private Long id; + + @Schema(description = "会员id", example = "11234") + @ExcelProperty("会员id") + private Long mebId; + + @Schema(description = "订单id", example = "20689") + @ExcelProperty("订单id") + private Long orderId; + + @Schema(description = "核销编码") + @ExcelProperty("核销编码") + private String pickUpVerifyCode; + + @Schema(description = "核销时间") + @ExcelProperty("核销时间") + private LocalDateTime verifyTime; + + @Schema(description = "兑换状态", example = "1") + @ExcelProperty("兑换状态") + private String status; + + @Schema(description = "备注", example = "你猜") + @ExcelProperty("备注") + private String remark; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("创建时间") + private LocalDateTime createTime; + + @Schema(description = "用户昵称", example = "2") + @ExcelProperty("用户昵称") + private String nickname; + + @Schema(description = "手机号", example = "2") + @ExcelProperty("手机号") + private String phone; + + @Schema(description = "已结算", example = "2") + @ExcelProperty("已结算") + private Integer haveAlready; + + @Schema(description = "未结算", example = "2") + @ExcelProperty("未结算") + private Integer unAlready; + +} diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/verifylog/vo/VerifyLogSaveReqVO.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/verifylog/vo/VerifyLogSaveReqVO.java new file mode 100644 index 0000000..44a0938 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/verifylog/vo/VerifyLogSaveReqVO.java @@ -0,0 +1,35 @@ +package cn.iocoder.yudao.module.trade.controller.admin.verifylog.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - 门店核销记录新增/修改 Request VO") +@Data +public class VerifyLogSaveReqVO { + + @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24309") + private Long id; + + @Schema(description = "会员id", example = "11234") + private Long mebId; + + @Schema(description = "订单id", example = "20689") + private Long orderId; + + @Schema(description = "核销编码") + private String pickUpVerifyCode; + + @Schema(description = "核销时间") + private LocalDateTime verifyTime; + + @Schema(description = "兑换状态", example = "1") + private String status; + + @Schema(description = "备注", example = "你猜") + private String remark; + +} diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageUserController.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageUserController.java index 387bf8b..ad75fca 100644 --- a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageUserController.java +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageUserController.java @@ -4,8 +4,11 @@ import cn.hutool.core.date.LocalDateTimeUtil; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; +import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils; import cn.iocoder.yudao.module.member.api.user.MemberUserApi; import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; +import cn.iocoder.yudao.module.pay.api.wallet.PayWalletApi; +import cn.iocoder.yudao.module.pay.api.wallet.dto.PayWalletDTO; import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.*; import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageRecordConvert; import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageUserConvert; @@ -54,10 +57,27 @@ public class AppBrokerageUserController { @Resource private MemberUserApi memberUserApi; + @Resource + private PayWalletApi payWalletApi; + @GetMapping("/get") - @Operation(summary = "获得个人分销信息") + @Operation(summary = "获得个人钱包信息") @PreAuthenticated public CommonResult getBrokerageUser() { +// Optional user = Optional.ofNullable(brokerageUserService.getBrokerageUser(getLoginUserId())); + Optional user = Optional.ofNullable(payWalletApi.getOrCreateWallet(WebFrameworkUtils.getLoginUserId(), 1)); + // 返回数据 + AppBrokerageUserRespVO respVO = new AppBrokerageUserRespVO() + .setBrokerageEnabled(true) + .setBrokeragePrice(user.map(PayWalletDTO::getBalance).orElse(0)) + .setFrozenPrice(user.map(PayWalletDTO::getFreezePrice).orElse(0)); + return success(respVO); + } + + @GetMapping("/get1") + @Operation(summary = "获得个人分销信息") + @PreAuthenticated + public CommonResult getBrokerageUser1() { Optional user = Optional.ofNullable(brokerageUserService.getBrokerageUser(getLoginUserId())); // 返回数据 AppBrokerageUserRespVO respVO = new AppBrokerageUserRespVO() diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageWithdrawController.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageWithdrawController.java index b1ef5f8..3e5f13d 100644 --- a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageWithdrawController.java +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageWithdrawController.java @@ -47,4 +47,11 @@ public class AppBrokerageWithdrawController { return success(brokerageWithdrawService.createBrokerageWithdraw(getLoginUserId(), createReqVO)); } + @PostMapping("/create1") + @Operation(summary = "创建余额提现") + @PreAuthenticated + public CommonResult createBrokerageWithdraw1(@RequestBody @Valid AppBrokerageWithdrawCreateReqVO createReqVO) { + return success(brokerageWithdrawService.createBrokerageWithdraw1(getLoginUserId(), createReqVO)); + } + } diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/BrokerageRecordConvert.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/BrokerageRecordConvert.java index 0f1fe61..f8b58f2 100644 --- a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/BrokerageRecordConvert.java +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/BrokerageRecordConvert.java @@ -6,6 +6,7 @@ import cn.hutool.core.util.StrUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; +import cn.iocoder.yudao.module.pay.api.wallet.dto.PayWalletDTO; import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record.BrokerageRecordPageReqVO; import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record.BrokerageRecordRespVO; import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBrokerageRecordPageReqVO; @@ -56,6 +57,22 @@ public interface BrokerageRecordConvert { .setStatus(status).setFrozenDays(brokerageFrozenDays).setUnfreezeTime(unfreezeTime) .setSourceUserLevel(sourceUserLevel).setSourceUserId(sourceUserId); } + default BrokerageRecordDO convert1(PayWalletDTO user, BrokerageRecordBizTypeEnum bizType, String bizId, + Integer brokerageFrozenDays, int brokeragePrice, LocalDateTime unfreezeTime, + String title, Long sourceUserId, Integer sourceUserLevel) { + brokerageFrozenDays = ObjectUtil.defaultIfNull(brokerageFrozenDays, 0); + // 不冻结时,佣金直接就是结算状态 + Integer status = brokerageFrozenDays > 0 + ? BrokerageRecordStatusEnum.WAIT_SETTLEMENT.getStatus() + : BrokerageRecordStatusEnum.SETTLEMENT.getStatus(); + return new BrokerageRecordDO().setUserId(user.getId()) + .setBizType(bizType.getType()).setBizId(bizId) + .setPrice(brokeragePrice).setTotalPrice(user.getBalance()) + .setTitle(title) + .setDescription(StrUtil.format(bizType.getDescription(), MoneyUtils.fenToYuanStr(Math.abs(brokeragePrice)))) + .setStatus(status).setFrozenDays(brokerageFrozenDays).setUnfreezeTime(unfreezeTime) + .setSourceUserLevel(sourceUserLevel).setSourceUserId(sourceUserId); + } default PageResult convertPage(PageResult pageResult, Map userMap) { PageResult result = convertPage(pageResult); diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/verifylog/VerifyLogConvert.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/verifylog/VerifyLogConvert.java new file mode 100644 index 0000000..a17868d --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/verifylog/VerifyLogConvert.java @@ -0,0 +1,32 @@ +package cn.iocoder.yudao.module.trade.convert.verifylog; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.collection.MapUtils; +import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO; +import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; +import cn.iocoder.yudao.module.trade.controller.admin.verifylog.vo.VerifyLogRespVO; +import cn.iocoder.yudao.module.trade.dal.dataobject.verifylog.VerifyLogDO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; +import java.util.Map; + +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; + +@Mapper +public interface VerifyLogConvert { + VerifyLogConvert INSTANCE = Mappers.getMapper(VerifyLogConvert.class); + + default PageResult convertPage(PageResult pageResult, List users) { + PageResult voPageResult = convertPage(pageResult); + // user 拼接 + Map userMap = convertMap(users, MemberUserRespDTO::getId); + voPageResult.getList().forEach(record -> { + MapUtils.findAndThen(userMap, record.getMebId(), + memberUserRespDTO -> record.setNickname(memberUserRespDTO.getNickname()).setPhone(memberUserRespDTO.getMobile())); + }); + return voPageResult; + } + PageResult convertPage(PageResult page); +} diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/verifylog/VerifyLogDO.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/verifylog/VerifyLogDO.java new file mode 100644 index 0000000..d885013 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/verifylog/VerifyLogDO.java @@ -0,0 +1,56 @@ +package cn.iocoder.yudao.module.trade.dal.dataobject.verifylog; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 门店核销记录 DO + * + * @author 郑大钒水 + */ +@TableName("trade_verify_log") +@KeySequence("trade_verify_log_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class VerifyLogDO extends BaseDO { + + /** + * 订单编号 + */ + @TableId + private Long id; + /** + * 会员id + */ + private Long mebId; + /** + * 订单id + */ + private Long orderId; + /** + * 核销编码 + */ + private String pickUpVerifyCode; + /** + * 核销时间 + */ + private LocalDateTime verifyTime; + /** + * 兑换状态 + */ + private String status; + /** + * 备注 + */ + private String remark; + +} diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/verifylog/VerifyLogMapper.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/verifylog/VerifyLogMapper.java new file mode 100644 index 0000000..4014442 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/verifylog/VerifyLogMapper.java @@ -0,0 +1,53 @@ +package cn.iocoder.yudao.module.trade.dal.mysql.verifylog; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.trade.dal.dataobject.verifylog.VerifyLogDO; +import com.baomidou.mybatisplus.core.metadata.IPage; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.trade.controller.admin.verifylog.vo.*; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +/** + * 门店核销记录 Mapper + * + * @author 郑大钒水 + */ +@Mapper +public interface VerifyLogMapper extends BaseMapperX { + + default PageResult selectPage(VerifyLogPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(VerifyLogDO::getMebId, reqVO.getMebId()) + .eqIfPresent(VerifyLogDO::getOrderId, reqVO.getOrderId()) + .eqIfPresent(VerifyLogDO::getPickUpVerifyCode, reqVO.getPickUpVerifyCode()) + .betweenIfPresent(VerifyLogDO::getVerifyTime, reqVO.getVerifyTime()) + .eqIfPresent(VerifyLogDO::getStatus, reqVO.getStatus()) + .eqIfPresent(VerifyLogDO::getRemark, reqVO.getRemark()) + .betweenIfPresent(VerifyLogDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(VerifyLogDO::getId)); + } + + @Select({""}) + IPage selectPage1(IPage page, @Param("reqVO") VerifyLogPageReqVO reqVO); + +} diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordService.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordService.java index 1cf1e24..9b51137 100644 --- a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordService.java +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordService.java @@ -61,6 +61,16 @@ public interface BrokerageRecordService { * @param title 标题 */ void addBrokerage(Long userId, BrokerageRecordBizTypeEnum bizType, String bizId, Integer brokeragePrice, String title); + /** + * 增加钱包【只针对自己】 + * + * @param userId 会员编号 + * @param bizType 业务类型 + * @param bizId 业务编号 + * @param brokeragePrice 佣金 + * @param title 标题 + */ + void addBrokerage1(Long userId, BrokerageRecordBizTypeEnum bizType, String bizId, Integer brokeragePrice, String title); /** * 减少佣金【只针对自己】 @@ -74,6 +84,18 @@ public interface BrokerageRecordService { default void reduceBrokerage(Long userId, BrokerageRecordBizTypeEnum bizType, String bizId, Integer brokeragePrice, String title) { addBrokerage(userId, bizType, bizId, -brokeragePrice, title); } + /** + * 减少余额【只针对自己】 + * + * @param userId 会员编号 + * @param bizType 业务类型 + * @param bizId 业务编号 + * @param brokeragePrice 佣金 + * @param title 标题 + */ + default void reduceBrokerage1(Long userId, BrokerageRecordBizTypeEnum bizType, String bizId, Integer brokeragePrice, String title) { + addBrokerage1(userId, bizType, bizId, -brokeragePrice, title); + } /** * 取消佣金:将佣金记录,状态修改为已失效 diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordServiceImpl.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordServiceImpl.java index 8b60c4f..3c8b538 100644 --- a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordServiceImpl.java +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordServiceImpl.java @@ -7,6 +7,9 @@ import cn.hutool.extra.spring.SpringUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils; +import cn.iocoder.yudao.module.pay.api.wallet.PayWalletApi; +import cn.iocoder.yudao.module.pay.api.wallet.dto.PayWalletDTO; +import cn.iocoder.yudao.module.pay.api.wallet.dto.PayWalletTransactionDTO; import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; @@ -39,6 +42,7 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getMaxValue; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getMinValue; import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId; +import static cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum.WITHDRAW; import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.BROKERAGE_WITHDRAW_USER_BALANCE_NOT_ENOUGH; /** @@ -63,6 +67,9 @@ public class BrokerageRecordServiceImpl implements BrokerageRecordService { @Resource private ProductSkuApi productSkuApi; + @Resource + private PayWalletApi payWalletApi; + @Override public BrokerageRecordDO getBrokerageRecord(Integer id) { return brokerageRecordMapper.selectById(id); @@ -314,6 +321,31 @@ public class BrokerageRecordServiceImpl implements BrokerageRecordService { null, title, null, null); brokerageRecordMapper.insert(record); } + @Override + @Transactional(rollbackFor = Exception.class) + public void addBrokerage1(Long userId, BrokerageRecordBizTypeEnum bizType, String bizId, Integer brokeragePrice, String title) { + // 1. 校验佣金余额 + PayWalletDTO wallet = payWalletApi.getOrCreateWallet(userId, 1); +// BrokerageUserDO user = brokerageUserService.getBrokerageUser(userId); + int balance = Optional.of(wallet) + .map(PayWalletDTO::getBalance).orElse(0); + if (balance + brokeragePrice < 0) { + throw exception(BROKERAGE_WITHDRAW_USER_BALANCE_NOT_ENOUGH, MoneyUtils.fenToYuanStr(balance)); + } + + PayWalletTransactionDTO payWalletTransactionDTO = payWalletApi.reduceWalletBalance1(userId, Long.valueOf(bizId), WITHDRAW, -brokeragePrice); + // 2. 更新佣金余额 +// boolean success = brokerageUserService.updateUserPrice(userId, brokeragePrice); + if (ObjectUtil.isEmpty(payWalletTransactionDTO)) { + // 失败时,则抛出异常。只会出现扣减佣金时,余额不足的情况 + throw exception(BROKERAGE_WITHDRAW_USER_BALANCE_NOT_ENOUGH, MoneyUtils.fenToYuanStr(balance)); + } + + // 3. 新增记录 +// BrokerageRecordDO record = BrokerageRecordConvert.INSTANCE.convert1(wallet, bizType, bizId, 0, brokeragePrice, +// null, title, null, null); +// brokerageRecordMapper.insert(record); + } @Override public AppBrokerageProductPriceRespVO calculateProductBrokeragePrice(Long userId, Long spuId) { diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawService.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawService.java index 04ea9c4..4fd3296 100644 --- a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawService.java +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawService.java @@ -54,6 +54,14 @@ public interface BrokerageWithdrawService { * @return 佣金提现编号 */ Long createBrokerageWithdraw(Long userId, AppBrokerageWithdrawCreateReqVO createReqVO); + /** + * 【会员】创建余额 + * + * @param userId 会员用户编号 + * @param createReqVO 创建信息 + * @return 佣金提现编号 + */ + Long createBrokerageWithdraw1(Long userId, AppBrokerageWithdrawCreateReqVO createReqVO); /** * 按照 userId,汇总每个用户的提现 diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawServiceImpl.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawServiceImpl.java index 08e2329..5c4211f 100644 --- a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawServiceImpl.java +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawServiceImpl.java @@ -6,6 +6,9 @@ import cn.hutool.core.map.MapUtil; import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; +import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; +import cn.iocoder.yudao.module.pay.api.wallet.PayWalletApi; +import cn.iocoder.yudao.module.pay.api.wallet.dto.PayWalletDTO; import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum; import cn.iocoder.yudao.module.system.api.notify.NotifyMessageSendApi; import cn.iocoder.yudao.module.system.api.notify.dto.NotifySendSingleToUserReqDTO; @@ -34,6 +37,7 @@ import java.util.List; import java.util.Map; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum.RECHARGE; import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*; /** @@ -56,6 +60,9 @@ public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService { @Resource private NotifyMessageSendApi notifyMessageSendApi; + @Resource + private PayWalletApi payWalletApi; + @Resource private Validator validator; @@ -128,19 +135,54 @@ public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService { TradeConfigDO tradeConfig = validateWithdrawPrice(createReqVO.getPrice()); // 1.2 校验提现参数 createReqVO.validate(validator); - + Integer brokerageWithdrawFeePercent = 0; + if (!BrokerageWithdrawTypeEnum.WALLET.getType().equals(createReqVO.getType())) {//提现到钱包 + brokerageWithdrawFeePercent = tradeConfig.getBrokerageWithdrawFeePercent(); + } + //处理提现逻辑 // 2.1 计算手续费 - Integer feePrice = calculateFeePrice(createReqVO.getPrice(), tradeConfig.getBrokerageWithdrawFeePercent()); + Integer feePrice = calculateFeePrice(createReqVO.getPrice(), brokerageWithdrawFeePercent); // 2.2 创建佣金提现记录 BrokerageWithdrawDO withdraw = BrokerageWithdrawConvert.INSTANCE.convert(createReqVO, userId, feePrice); + if (BrokerageWithdrawTypeEnum.WALLET.getType().equals(createReqVO.getType())) {//提现到钱包 + withdraw.setStatus(11); + withdraw.setAuditTime(LocalDateTime.now()); + } brokerageWithdrawMapper.insert(withdraw); - + if (BrokerageWithdrawTypeEnum.WALLET.getType().equals(createReqVO.getType())) {//提现到钱包处理提现到零钱逻辑 + PayWalletDTO orCreateWallet = payWalletApi.getOrCreateWallet(userId, 1); +// PayWalletBizTypeEnum.RECHARGE.getType() bizType = new PayWalletBizTypeEnum(); + payWalletApi.addWalletBalance(orCreateWallet.getId(),withdraw.getId()+"",RECHARGE,withdraw.getPrice()); + } // 3. 创建用户佣金记录 // 注意,佣金是否充足,reduceBrokerage 已经进行校验 brokerageRecordService.reduceBrokerage(userId, BrokerageRecordBizTypeEnum.WITHDRAW, String.valueOf(withdraw.getId()), createReqVO.getPrice(), BrokerageRecordBizTypeEnum.WITHDRAW.getTitle()); return withdraw.getId(); } + @Override + @Transactional(rollbackFor = Exception.class) + public Long createBrokerageWithdraw1(Long userId, AppBrokerageWithdrawCreateReqVO createReqVO) { + // 1.1 校验提现金额 + TradeConfigDO tradeConfig = validateWithdrawPrice(createReqVO.getPrice()); + // 1.2 校验提现参数 + createReqVO.validate(validator); + //处理提现逻辑 + // 2.1 计算手续费 + Integer feePrice = calculateFeePrice(createReqVO.getPrice(), tradeConfig.getBrokerageWithdrawFeePercent()); + // 2.2 创建佣金提现记录 + BrokerageWithdrawDO withdraw = BrokerageWithdrawConvert.INSTANCE.convert(createReqVO, userId, feePrice); + brokerageWithdrawMapper.insert(withdraw); + // 3. 创建用户佣金记录 + // 注意,佣金是否充足,reduceBrokerage 已经进行校验 + // 3. 创建用户佣金记录 + // 注意,佣金是否充足,reduceBrokerage 已经进行校验 + brokerageRecordService.reduceBrokerage1(userId, BrokerageRecordBizTypeEnum.WITHDRAWWEALLET, String.valueOf(withdraw.getId()), + createReqVO.getPrice(), BrokerageRecordBizTypeEnum.WITHDRAW.getTitle()); +// payWalletApi.reduceWalletBalance1(userId,withdraw.getId(), PayWalletBizTypeEnum.WITHDRAW, +// createReqVO.getPrice()); + return withdraw.getId(); + } @Override public List getWithdrawSummaryListByUserId(Collection userIds, diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java index 1952832..1b8bf84 100644 --- a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java @@ -36,9 +36,11 @@ import cn.iocoder.yudao.module.trade.dal.dataobject.cart.CartDO; import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; +import cn.iocoder.yudao.module.trade.dal.dataobject.verifylog.VerifyLogDO; import cn.iocoder.yudao.module.trade.dal.mysql.brokerage.BrokerageRecordMapper; import cn.iocoder.yudao.module.trade.dal.mysql.order.TradeOrderItemMapper; import cn.iocoder.yudao.module.trade.dal.mysql.order.TradeOrderMapper; +import cn.iocoder.yudao.module.trade.dal.mysql.verifylog.VerifyLogMapper; import cn.iocoder.yudao.module.trade.dal.redis.no.TradeNoRedisDAO; import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryTypeEnum; @@ -120,6 +122,9 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { @Resource private BrokerageRecordMapper brokerageRecordMapper; + @Resource + private VerifyLogMapper verifyLogMapper; + // =================== Order =================== @@ -694,14 +699,30 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { @Override @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.ADMIN_PICK_UP_RECEIVE) public void pickUpOrderByAdmin(Long id, String pickUpVerifyCode) { - boolean b = brokerageUserService.updateUserPriceByBindUserId(id, 3000); - // 3. 新增记录 - BrokerageUserDO user = brokerageUserService.getBrokerageUser(id); - BrokerageRecordDO record = BrokerageRecordConvert.INSTANCE.convert(user, BrokerageRecordBizTypeEnum.ORDER, "", 0, 3000, - null, "门店核销佣金", null, null); - brokerageRecordMapper.insert(record); - getSelf().pickUpOrder(tradeOrderMapper.selectOneByPickUpVerifyCode(pickUpVerifyCode)); - } + TradeOrderDO tradeOrderDO = tradeOrderMapper.selectOneByPickUpVerifyCode(pickUpVerifyCode); + if(ObjectUtil.isEmpty(tradeOrderDO)){ + throw exception(ORDER_NOT_FOUND); + } + VerifyLogDO verifyLogDO = new VerifyLogDO(); + verifyLogDO.setMebId(id); + verifyLogDO.setOrderId(tradeOrderDO.getId()); + verifyLogDO.setPickUpVerifyCode(pickUpVerifyCode); + verifyLogDO.setVerifyTime(LocalDateTime.now()); + verifyLogDO.setStatus("0"); + verifyLogMapper.insert(verifyLogDO); + getSelf().pickUpOrder(tradeOrderDO); + } +// @Override +// @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.ADMIN_PICK_UP_RECEIVE) +// public void pickUpOrderByAdmin(Long id, String pickUpVerifyCode) { +// boolean b = brokerageUserService.updateUserPriceByBindUserId(id, 3000); +// // 3. 新增记录 +// BrokerageUserDO user = brokerageUserService.getBrokerageUser(id); +// BrokerageRecordDO record = BrokerageRecordConvert.INSTANCE.convert(user, BrokerageRecordBizTypeEnum.ORDER, "", 0, 3000, +// null, "门店核销佣金", null, null); +// brokerageRecordMapper.insert(record); +// getSelf().pickUpOrder(tradeOrderMapper.selectOneByPickUpVerifyCode(pickUpVerifyCode)); +// } @Override public TradeOrderDO getByPickUpVerifyCode(String pickUpVerifyCode) { diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/verifylog/VerifyLogService.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/verifylog/VerifyLogService.java new file mode 100644 index 0000000..fdc0e52 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/verifylog/VerifyLogService.java @@ -0,0 +1,62 @@ +package cn.iocoder.yudao.module.trade.service.verifylog; + +import java.util.*; +import javax.validation.*; +import cn.iocoder.yudao.module.trade.controller.admin.verifylog.vo.*; +import cn.iocoder.yudao.module.trade.dal.dataobject.verifylog.VerifyLogDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; + +/** + * 门店核销记录 Service 接口 + * + * @author 郑大钒水 + */ +public interface VerifyLogService { + + /** + * 创建门店核销记录 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createVerifyLog(@Valid VerifyLogSaveReqVO createReqVO); + + /** + * 更新门店核销记录 + * + * @param updateReqVO 更新信息 + */ + void updateVerifyLog(@Valid VerifyLogSaveReqVO updateReqVO); + + /** + * 删除门店核销记录 + * + * @param id 编号 + */ + void deleteVerifyLog(Long id); + + /** + * 获得门店核销记录 + * + * @param id 编号 + * @return 门店核销记录 + */ + VerifyLogDO getVerifyLog(Long id); + + /** + * 获得门店核销记录分页 + * + * @param pageReqVO 分页查询 + * @return 门店核销记录分页 + */ + PageResult getVerifyLogPage(VerifyLogPageReqVO pageReqVO); + + /** + * 更新核销统计 + * + * @param updateReqVO 更新信息 + */ + void updateAlready(@Valid VerifyLogSaveReqVO updateReqVO); + +} diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/verifylog/VerifyLogServiceImpl.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/verifylog/VerifyLogServiceImpl.java new file mode 100644 index 0000000..18880ff --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/verifylog/VerifyLogServiceImpl.java @@ -0,0 +1,84 @@ +package cn.iocoder.yudao.module.trade.service.verifylog; + +import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import cn.iocoder.yudao.module.trade.controller.admin.verifylog.vo.*; +import cn.iocoder.yudao.module.trade.dal.dataobject.verifylog.VerifyLogDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; + +import cn.iocoder.yudao.module.trade.dal.mysql.verifylog.VerifyLogMapper; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*; + +/** + * 门店核销记录 Service 实现类 + * + * @author 郑大钒水 + */ +@Service +@Validated +public class VerifyLogServiceImpl implements VerifyLogService { + + @Resource + private VerifyLogMapper verifyLogMapper; + + @Override + public Long createVerifyLog(VerifyLogSaveReqVO createReqVO) { + // 插入 + VerifyLogDO verifyLog = BeanUtils.toBean(createReqVO, VerifyLogDO.class); + verifyLogMapper.insert(verifyLog); + // 返回 + return verifyLog.getId(); + } + + @Override + public void updateVerifyLog(VerifyLogSaveReqVO updateReqVO) { + // 校验存在 + validateVerifyLogExists(updateReqVO.getId()); + // 更新 + VerifyLogDO updateObj = BeanUtils.toBean(updateReqVO, VerifyLogDO.class); + verifyLogMapper.updateById(updateObj); + } + + @Override + public void deleteVerifyLog(Long id) { + // 校验存在 + validateVerifyLogExists(id); + // 删除 + verifyLogMapper.deleteById(id); + } + + private void validateVerifyLogExists(Long id) { + if (verifyLogMapper.selectById(id) == null) { + throw exception(VERIFY_LOG_NOT_EXISTS); + } + } + + @Override + public VerifyLogDO getVerifyLog(Long id) { + return verifyLogMapper.selectById(id); + } + + @Override + public PageResult getVerifyLogPage(VerifyLogPageReqVO pageReqVO) { + IPage pageResult = verifyLogMapper.selectPage1(MyBatisUtils.buildPage(pageReqVO),pageReqVO); + return new PageResult<>(pageResult.getRecords(), pageResult.getTotal()); + } + + @Override + public void updateAlready(VerifyLogSaveReqVO updateReqVO) { + // 结算 + verifyLogMapper.update(new UpdateWrapper().lambda().set(VerifyLogDO::getStatus,1).eq(VerifyLogDO::getMebId,updateReqVO.getMebId())); + } + +} diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionstatistics/DistributionStatisticsServiceImpl.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionstatistics/DistributionStatisticsServiceImpl.java index 8d474e6..2267f11 100644 --- a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionstatistics/DistributionStatisticsServiceImpl.java +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionstatistics/DistributionStatisticsServiceImpl.java @@ -90,7 +90,6 @@ public class DistributionStatisticsServiceImpl implements DistributionStatistics MyBatisUtils.buildPage(pageReqVO), pageReqVO.getStatus()); return new PageResult<>(pageResult.getRecords(), pageResult.getTotal()); -// return distributionStatisticsMapper.selectPage1(pageReqVO); } } diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java index a2ea1f3..33fce5c 100644 --- a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java @@ -464,12 +464,32 @@ public class MemberUserServiceImpl implements MemberUserService { DistributionLogDO vo = distributionLogDOS.get((distributionLogDOS.size()/5)-1); vo.setGameStatus("0"); distributionLogMapper.updateById(vo); -// List distributionLogDOS1 = distributionLogDOS.subList(0, (distributionLogDOS.size() / 5)); -// for (DistributionLogDO dt:distributionLogDOS1) { -// dt.setGameStatus("0"); -// } -// distributionLogMapper.updateBatch(distributionLogDOS1); -// distributionLogMapper.up + + //添加佣金记录 + BrokerageRecordDO brokerageRecordDO = new BrokerageRecordDO(); + brokerageRecordDO.setBizId(orderId+""); + brokerageRecordDO.setUserId(vo.getMebId()); + brokerageRecordDO.setBizType(1); + brokerageRecordDO.setTitle("5占一游戏分润"); + brokerageRecordDO.setPrice(1188*100); + //查询当前总佣金 + Integer totalPrice = 0; + List brokerageRecordDOS = brokerageRecordMapper.selectList(new LambdaQueryWrapperX() + .eq(BrokerageRecordDO::getUserId, vo.getMebId()) + .eq(BrokerageRecordDO::getDeleted, 0) + .orderByDesc(BrokerageRecordDO::getCreateTime)); + if(ObjectUtil.isNotEmpty(brokerageRecordDOS)){ + totalPrice = brokerageRecordDOS.get(0).getTotalPrice(); + } + brokerageRecordDO.setTotalPrice(totalPrice+1188*100);//当前总佣金 + brokerageRecordDO.setStatus(1); + brokerageRecordDO.setSourceUserLevel(configLevelDO.getLevel()); + brokerageRecordDO.setSourceUserId(userId); + brokerageRecordMapper.insert(brokerageRecordDO); + //修改推广员佣金 + BrokerageUserDO brokerageUserDO1 = brokerageUserMapper.selectById(vo.getMebId()); + brokerageUserDO1.setBrokeragePrice(1188*100+brokerageUserDO1.getBrokeragePrice()); + brokerageUserMapper.updateById(brokerageUserDO1); } } } diff --git a/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/PayWalletApi.java b/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/PayWalletApi.java new file mode 100644 index 0000000..34b9d8c --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/PayWalletApi.java @@ -0,0 +1,84 @@ +package cn.iocoder.yudao.module.pay.api.wallet; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.pay.api.wallet.dto.PayWalletDTO; +import cn.iocoder.yudao.module.pay.api.wallet.dto.PayWalletTransactionDTO; +import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum; + +/** + * 钱包 Service 接口 + * + * @author jason + */ +public interface PayWalletApi { + + /** + * 获取钱包信息 + *

+ * 如果不存在,则创建钱包。由于用户注册时候不会创建钱包 + * + * @param userId 用户编号 + * @param userType 用户类型 + */ + PayWalletDTO getOrCreateWallet(Long userId, Integer userType); + + /** + * 获取钱包信息 + * + * @param walletId 钱包 id + */ + PayWalletDTO getWallet(Long walletId); + + /** + * 扣减钱包余额 + * + * @param walletId 钱包 id + * @param bizId 业务关联 id + * @param bizType 业务关联分类 + * @param price 扣减金额 + * @return 钱包流水 + */ + PayWalletTransactionDTO reduceWalletBalance(Long walletId, Long bizId, + PayWalletBizTypeEnum bizType, Integer price); + + /** + * 扣减钱包余额 + * + * @param userId 钱包 id + * @param bizId 业务关联 id + * @param bizType 业务关联分类 + * @param price 扣减金额 + * @return 钱包流水 + */ + PayWalletTransactionDTO reduceWalletBalance1(Long userId, Long bizId, + PayWalletBizTypeEnum bizType, Integer price); + + /** + * 增加钱包余额 + * + * @param walletId 钱包 id + * @param bizId 业务关联 id + * @param bizType 业务关联分类 + * @param price 增加金额 + * @return 钱包流水 + */ + PayWalletTransactionDTO addWalletBalance(Long walletId, String bizId, + PayWalletBizTypeEnum bizType, Integer price); + + /** + * 冻结钱包部分余额 + * + * @param id 钱包编号 + * @param price 冻结金额 + */ + void freezePrice(Long id, Integer price); + + /** + * 解冻钱包余额 + * + * @param id 钱包编号 + * @param price 解冻金额 + */ + void unfreezePrice(Long id, Integer price); + +} diff --git a/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/dto/PayWalletDTO.java b/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/dto/PayWalletDTO.java new file mode 100644 index 0000000..5cf0ba3 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/dto/PayWalletDTO.java @@ -0,0 +1,79 @@ +package cn.iocoder.yudao.module.pay.api.wallet.dto; + +import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; +import lombok.Data; + +import java.time.LocalDateTime; + +/** + * 会员钱包 DO + * + * @author jason + */ +@Data +public class PayWalletDTO { + + /** + * 编号 + */ + private Long id; + + /** + * 用户 id + * + * 关联 MemberUserDO 的 id 编号 + * 关联 AdminUserDO 的 id 编号 + */ + private Long userId; + /** + * 用户类型, 预留 多商户转帐可能需要用到 + * + * 关联 {@link UserTypeEnum} + */ + private Integer userType; + + /** + * 余额,单位分 + */ + private Integer balance; + + /** + * 冻结金额,单位分 + */ + private Integer freezePrice; + + /** + * 累计支出,单位分 + */ + private Integer totalExpense; + /** + * 累计充值,单位分 + */ + private Integer totalRecharge; + + /** + * 创建时间 + */ + private LocalDateTime createTime; + /** + * 最后更新时间 + */ + private LocalDateTime updateTime; + /** + * 创建者,目前使用 SysUser 的 id 编号 + * + * 使用 String 类型的原因是,未来可能会存在非数值的情况,留好拓展性。 + */ + private String creator; + /** + * 更新者,目前使用 SysUser 的 id 编号 + * + * 使用 String 类型的原因是,未来可能会存在非数值的情况,留好拓展性。 + */ + private String updater; + /** + * 是否删除 + */ + private Boolean deleted; + +} diff --git a/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/dto/PayWalletRespDTO.java b/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/dto/PayWalletRespDTO.java new file mode 100644 index 0000000..c3d20b8 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/dto/PayWalletRespDTO.java @@ -0,0 +1,36 @@ +package cn.iocoder.yudao.module.pay.api.wallet.dto; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import javax.validation.constraints.NotNull; +import java.time.LocalDateTime; + +@Data +public class PayWalletRespDTO { + + private Long id; + + private LocalDateTime createTime; + + private String nickname; + private String avatar; + @NotNull(message = "用户编号不能为空") + private Long userId; + + @NotNull(message = "用户类型不能为空") + private Integer userType; + + @NotNull(message = "余额,单位分不能为空") + private Integer balance; + + @NotNull(message = "累计支出,单位分不能为空") + private Integer totalExpense; + + @NotNull(message = "累计充值,单位分不能为空") + private Integer totalRecharge; + + @NotNull(message = "冻结金额,单位分不能为空") + private Integer freezePrice; +} diff --git a/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/dto/PayWalletTransactionDTO.java b/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/dto/PayWalletTransactionDTO.java new file mode 100644 index 0000000..44f8ee8 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/dto/PayWalletTransactionDTO.java @@ -0,0 +1,85 @@ +package cn.iocoder.yudao.module.pay.api.wallet.dto; + +import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum; +import lombok.Data; + +import java.time.LocalDateTime; + +/** + * 会员钱包流水 DO + * + * @author jason + */ +@Data +public class PayWalletTransactionDTO { + + /** + * 编号 + */ + private Long id; + + /** + * 流水号 + */ + private String no; + + /** + * 钱包编号 + * + */ + private Long walletId; + + /** + * 关联业务分类 + * + * 枚举 {@link PayWalletBizTypeEnum#getType()} + */ + private Integer bizType; + + /** + * 关联业务编号 + */ + private String bizId; + + /** + * 流水说明 + */ + private String title; + + /** + * 交易金额,单位分 + * + * 正值表示余额增加,负值表示余额减少 + */ + private Integer price; + + /** + * 交易后余额,单位分 + */ + private Integer balance; + + /** + * 创建时间 + */ + private LocalDateTime createTime; + /** + * 最后更新时间 + */ + private LocalDateTime updateTime; + /** + * 创建者,目前使用 SysUser 的 id 编号 + * + * 使用 String 类型的原因是,未来可能会存在非数值的情况,留好拓展性。 + */ + private String creator; + /** + * 更新者,目前使用 SysUser 的 id 编号 + * + * 使用 String 类型的原因是,未来可能会存在非数值的情况,留好拓展性。 + */ + private String updater; + /** + * 是否删除 + */ + private Boolean deleted; +} diff --git a/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/wallet/PayWalletBizTypeEnum.java b/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/wallet/PayWalletBizTypeEnum.java index 20e0a8b..d23cafd 100644 --- a/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/wallet/PayWalletBizTypeEnum.java +++ b/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/wallet/PayWalletBizTypeEnum.java @@ -18,7 +18,11 @@ public enum PayWalletBizTypeEnum implements IntArrayValuable { RECHARGE(1, "充值"), RECHARGE_REFUND(2, "充值退款"), PAYMENT(3, "支付"), - PAYMENT_REFUND(4, "支付退款"); + PAYMENT_REFUND(4, "支付退款"), + WITHDRAW(5, "提现申请"), + WITHDRAW_REJECT(6, "提现申请驳回"); + + // TODO 后续增加 diff --git a/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/PayWalletApiImpl.java b/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/PayWalletApiImpl.java new file mode 100644 index 0000000..9c129b8 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/api/wallet/PayWalletApiImpl.java @@ -0,0 +1,82 @@ +package cn.iocoder.yudao.module.pay.api.wallet; + +import cn.hutool.core.lang.Assert; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.module.member.api.distributionconfig.vo.DistributionConfigRespDTO; +import cn.iocoder.yudao.module.pay.api.wallet.dto.PayWalletDTO; +import cn.iocoder.yudao.module.pay.api.wallet.dto.PayWalletTransactionDTO; +import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletPageReqVO; +import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO; +import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; +import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO; +import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; +import cn.iocoder.yudao.module.pay.dal.mysql.wallet.PayWalletMapper; +import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum; +import cn.iocoder.yudao.module.pay.service.order.PayOrderService; +import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; +import cn.iocoder.yudao.module.pay.service.wallet.PayWalletService; +import cn.iocoder.yudao.module.pay.service.wallet.PayWalletTransactionService; +import cn.iocoder.yudao.module.pay.service.wallet.bo.WalletTransactionCreateReqBO; +import lombok.extern.slf4j.Slf4j; +import org.springframework.context.annotation.Lazy; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; +import static cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum.PAYMENT; +import static cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum.PAYMENT_REFUND; + +/** + * 钱包 Service 实现类 + * + * @author jason + */ +@Service +@Slf4j +public class PayWalletApiImpl implements PayWalletApi { + + + @Resource + @Lazy // 延迟加载,避免循环依赖 + private PayWalletService payWalletService; + + @Override + public PayWalletDTO getOrCreateWallet(Long userId, Integer userType) { + return BeanUtils.toBean(payWalletService.getOrCreateWallet(userId,userType), PayWalletDTO.class); + } + + @Override + public PayWalletDTO getWallet(Long walletId) { + return BeanUtils.toBean(payWalletService.getWallet(walletId), PayWalletDTO.class); + } + + @Override + public PayWalletTransactionDTO reduceWalletBalance(Long walletId, Long bizId, PayWalletBizTypeEnum bizType, Integer price) { + return BeanUtils.toBean(payWalletService.reduceWalletBalance(walletId,bizId,bizType,price), PayWalletTransactionDTO.class); + } + @Override + public PayWalletTransactionDTO reduceWalletBalance1(Long userId, Long bizId, PayWalletBizTypeEnum bizType, Integer price) { + return BeanUtils.toBean(payWalletService.reduceWalletBalance1(userId,bizId,bizType,price), PayWalletTransactionDTO.class); + } + + @Override + public PayWalletTransactionDTO addWalletBalance(Long walletId, String bizId, PayWalletBizTypeEnum bizType, Integer price) { + return BeanUtils.toBean(payWalletService.addWalletBalance(walletId,bizId,bizType,price), PayWalletTransactionDTO.class); + } + + @Override + public void freezePrice(Long id, Integer price) { + payWalletService.freezePrice(id,price); + } + + @Override + public void unfreezePrice(Long id, Integer price) { + payWalletService.unfreezePrice(id,price); + } + +} diff --git a/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletService.java b/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletService.java index e98d826..af46012 100644 --- a/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletService.java +++ b/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletService.java @@ -68,6 +68,17 @@ public interface PayWalletService { */ PayWalletTransactionDO reduceWalletBalance(Long walletId, Long bizId, PayWalletBizTypeEnum bizType, Integer price); + /** + * 扣减钱包余额 + * + * @param walletId 钱包 id + * @param bizId 业务关联 id + * @param bizType 业务关联分类 + * @param price 扣减金额 + * @return 钱包流水 + */ + PayWalletTransactionDO reduceWalletBalance1(Long userId, Long bizId, + PayWalletBizTypeEnum bizType, Integer price); /** * 增加钱包余额 diff --git a/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletServiceImpl.java b/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletServiceImpl.java index 9ebe1ca..59d6afa 100644 --- a/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletServiceImpl.java +++ b/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletServiceImpl.java @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.pay.service.wallet; import cn.hutool.core.lang.Assert; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletPageReqVO; import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO; import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; @@ -12,6 +13,9 @@ import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum; import cn.iocoder.yudao.module.pay.service.order.PayOrderService; import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; import cn.iocoder.yudao.module.pay.service.wallet.bo.WalletTransactionCreateReqBO; +import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageRecordConvert; +import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageRecordDO; +import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO; import lombok.extern.slf4j.Slf4j; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; @@ -19,11 +23,13 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.time.LocalDateTime; +import java.util.Optional; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; import static cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum.PAYMENT; import static cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum.PAYMENT_REFUND; +import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.BROKERAGE_WITHDRAW_USER_BALANCE_NOT_ENOUGH; /** * 钱包 Service 实现类 @@ -156,6 +162,57 @@ public class PayWalletServiceImpl implements PayWalletService { .setBizType(bizType.getType()).setTitle(bizType.getDescription()); return walletTransactionService.createWalletTransaction(bo); } + @Override + public PayWalletTransactionDO reduceWalletBalance1(Long userId, Long bizId, + PayWalletBizTypeEnum bizType, Integer price) { + // 1. 获取钱包 + PayWalletDO payWallet = getOrCreateWallet(userId,1); + if (payWallet == null) { + log.error("[reduceWalletBalance],用户钱包({})不存在.", userId); + throw exception(WALLET_NOT_FOUND); + } + + // 1. 校验佣金余额 + int balance = Optional.of(payWallet) + .map(PayWalletDO::getBalance).orElse(0); + if (balance - price < 0) { + throw exception(BROKERAGE_WITHDRAW_USER_BALANCE_NOT_ENOUGH, MoneyUtils.fenToYuanStr(balance)); + } + + // 2.1 扣除余额 + int updateCounts; + switch (bizType) { + case WITHDRAW: { + updateCounts = walletMapper.updateWhenConsumption(payWallet.getId(), price); + if (updateCounts<1) { + // 失败时,则抛出异常。只会出现扣减佣金时,余额不足的情况 + throw exception(BROKERAGE_WITHDRAW_USER_BALANCE_NOT_ENOUGH, MoneyUtils.fenToYuanStr(balance)); + } + break; + } +// case RECHARGE_REFUND: { +// updateCounts = walletMapper.updateWhenRechargeRefund(payWallet.getId(), price); +// break; +// } + default: { + // TODO 其它类型待实现 + throw new UnsupportedOperationException("待实现"); + } + } + if (updateCounts == 0) { + throw exception(WALLET_BALANCE_NOT_ENOUGH); + } + // 2.2 生成钱包流水 + Integer afterBalance = payWallet.getBalance() - price; + WalletTransactionCreateReqBO bo = new WalletTransactionCreateReqBO().setWalletId(payWallet.getId()) + .setPrice(-price).setBalance(afterBalance).setBizId(String.valueOf(bizId)) + .setBizType(bizType.getType()).setTitle(bizType.getDescription()); + // 3. 新增记录 +// BrokerageRecordDO record = BrokerageRecordConvert.INSTANCE.convert(user, bizType, bizId, 0, brokeragePrice, +// null, title, null, null); +// brokerageRecordMapper.insert(record); + return walletTransactionService.createWalletTransaction(bo); + } @Override public PayWalletTransactionDO addWalletBalance(Long walletId, String bizId, diff --git a/yudao-ui-admin-vue3-master/.env.dev b/yudao-ui-admin-vue3-master/.env.dev index 81bd56e..e33e333 100644 --- a/yudao-ui-admin-vue3-master/.env.dev +++ b/yudao-ui-admin-vue3-master/.env.dev @@ -4,18 +4,18 @@ NODE_ENV=production VITE_DEV=true # 请求路径 -VITE_BASE_URL='http://localhost:48080' - -# 文件上传类型:server - 后端上传, client - 前端直连上传,仅支持S3服务 -VITE_UPLOAD_TYPE=server -# 上传路径 -VITE_UPLOAD_URL='http://localhost:48080/admin-api/infra/file/upload' -# VITE_BASE_URL='http://zd.huamar.com' +# VITE_BASE_URL='http://localhost:48080' # # 文件上传类型:server - 后端上传, client - 前端直连上传,仅支持S3服务 # VITE_UPLOAD_TYPE=server # # 上传路径 -# VITE_UPLOAD_URL='http://zd.huamar.com/admin-api/infra/file/upload' +# VITE_UPLOAD_URL='http://localhost:48080/admin-api/infra/file/upload' +VITE_BASE_URL='http://zd.huamar.com' + +# 文件上传类型:server - 后端上传, client - 前端直连上传,仅支持S3服务 +VITE_UPLOAD_TYPE=server +# 上传路径 +VITE_UPLOAD_URL='http://zd.huamar.com/admin-api/infra/file/upload' # 接口地址 VITE_API_URL=/admin-api diff --git a/yudao-ui-admin-vue3-master/src/api/trade/verifylog/index.ts b/yudao-ui-admin-vue3-master/src/api/trade/verifylog/index.ts new file mode 100644 index 0000000..552c53a --- /dev/null +++ b/yudao-ui-admin-vue3-master/src/api/trade/verifylog/index.ts @@ -0,0 +1,49 @@ +import request from '@/config/axios' + +// 门店核销记录 VO +export interface VerifyLogVO { + id: number // 订单编号 + mebId: number // 会员id + orderId: number // 订单id + pickUpVerifyCode: string // 核销编码 + verifyTime: Date // 核销时间 + status: string // 兑换状态 + remark: string // 备注 +} + +// 门店核销记录 API +export const VerifyLogApi = { + // 查询门店核销记录分页 + getVerifyLogPage: async (params: any) => { + return await request.get({ url: `/trade/verify-log/page`, params }) + }, + + // 查询门店核销记录详情 + getVerifyLog: async (id: number) => { + return await request.get({ url: `/trade/verify-log/get?id=` + id }) + }, + + // 新增门店核销记录 + createVerifyLog: async (data: VerifyLogVO) => { + return await request.post({ url: `/trade/verify-log/create`, data }) + }, + + // 修改门店核销记录 + updateVerifyLog: async (data: VerifyLogVO) => { + return await request.put({ url: `/trade/verify-log/update`, data }) + }, + + // 删除门店核销记录 + deleteVerifyLog: async (id: number) => { + return await request.delete({ url: `/trade/verify-log/delete?id=` + id }) + }, + + // 导出门店核销记录 Excel + exportVerifyLog: async (params) => { + return await request.download({ url: `/trade/verify-log/export-excel`, params }) + }, + // 结算核销统计 + updateAlready: async (data: VerifyLogVO) => { + return await request.put({ url: `/trade/verify-log/updateAlready`, data }) + }, +} diff --git a/yudao-ui-admin-vue3-master/src/views/Home/components/ComparisonCard.vue b/yudao-ui-admin-vue3-master/src/views/Home/components/ComparisonCard.vue new file mode 100644 index 0000000..ee1c2f0 --- /dev/null +++ b/yudao-ui-admin-vue3-master/src/views/Home/components/ComparisonCard.vue @@ -0,0 +1,42 @@ + + diff --git a/yudao-ui-admin-vue3-master/src/views/Home/components/MemberStatisticsCard.vue b/yudao-ui-admin-vue3-master/src/views/Home/components/MemberStatisticsCard.vue new file mode 100644 index 0000000..2f9d7ab --- /dev/null +++ b/yudao-ui-admin-vue3-master/src/views/Home/components/MemberStatisticsCard.vue @@ -0,0 +1,91 @@ + + diff --git a/yudao-ui-admin-vue3-master/src/views/Home/components/OperationDataCard.vue b/yudao-ui-admin-vue3-master/src/views/Home/components/OperationDataCard.vue new file mode 100644 index 0000000..b905203 --- /dev/null +++ b/yudao-ui-admin-vue3-master/src/views/Home/components/OperationDataCard.vue @@ -0,0 +1,92 @@ + + diff --git a/yudao-ui-admin-vue3-master/src/views/Home/components/ShortcutCard.vue b/yudao-ui-admin-vue3-master/src/views/Home/components/ShortcutCard.vue new file mode 100644 index 0000000..cea9113 --- /dev/null +++ b/yudao-ui-admin-vue3-master/src/views/Home/components/ShortcutCard.vue @@ -0,0 +1,82 @@ + + diff --git a/yudao-ui-admin-vue3-master/src/views/Home/components/TradeTrendCard.vue b/yudao-ui-admin-vue3-master/src/views/Home/components/TradeTrendCard.vue new file mode 100644 index 0000000..7930e21 --- /dev/null +++ b/yudao-ui-admin-vue3-master/src/views/Home/components/TradeTrendCard.vue @@ -0,0 +1,208 @@ + + diff --git a/yudao-ui-admin-vue3-master/src/views/mall/trade/delivery/pickUpOrder/index.vue b/yudao-ui-admin-vue3-master/src/views/mall/trade/delivery/pickUpOrder/index.vue index e52a3e3..9fc8d86 100644 --- a/yudao-ui-admin-vue3-master/src/views/mall/trade/delivery/pickUpOrder/index.vue +++ b/yudao-ui-admin-vue3-master/src/views/mall/trade/delivery/pickUpOrder/index.vue @@ -73,7 +73,7 @@ 重置 - + 核销 diff --git a/yudao-ui-admin-vue3-master/src/views/member/distributionstatistics/index.vue b/yudao-ui-admin-vue3-master/src/views/member/distributionstatistics/index.vue index 0010073..de69744 100644 --- a/yudao-ui-admin-vue3-master/src/views/member/distributionstatistics/index.vue +++ b/yudao-ui-admin-vue3-master/src/views/member/distributionstatistics/index.vue @@ -38,7 +38,6 @@ - diff --git a/yudao-ui-admin-vue3-master/src/views/trade/verifylog/VerifyLogForm.vue b/yudao-ui-admin-vue3-master/src/views/trade/verifylog/VerifyLogForm.vue new file mode 100644 index 0000000..63a8832 --- /dev/null +++ b/yudao-ui-admin-vue3-master/src/views/trade/verifylog/VerifyLogForm.vue @@ -0,0 +1,123 @@ + + \ No newline at end of file diff --git a/yudao-ui-admin-vue3-master/src/views/trade/verifylog/index.vue b/yudao-ui-admin-vue3-master/src/views/trade/verifylog/index.vue new file mode 100644 index 0000000..4b06974 --- /dev/null +++ b/yudao-ui-admin-vue3-master/src/views/trade/verifylog/index.vue @@ -0,0 +1,166 @@ + + + \ No newline at end of file