From a981c07d34edd0975b9d556d97c1f851ce79974c Mon Sep 17 00:00:00 2001 From: luodangjia <luodangjia> Date: 星期三, 04 十二月 2024 13:40:00 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/ShopClient.java | 35 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/enums/TechnicianStatus.java | 26 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/ConfirmOrder.java | 4 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/BaseSettingController.java | 27 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java | 85 + ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Goods.java | 2 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/GoodsShopClient.java | 11 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/UserPointDetailVO.java | 2 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/UserPointVO.java | 13 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserAddressController.java | 57 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/UserCouponService.java | 14 ruoyi-service/ruoyi-account/src/main/resources/mapper/account/UserShopMapper.xml | 6 ruoyi-api/ruoyi-api-order/src/main/java/model/OrderGood.java | 48 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/CouponInfoClientFallbackFactory.java | 24 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/GoodsShopClientFallbackFactory.java | 8 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/ConfirmOrderVo.java | 10 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/WalletServiceImpl.java | 5 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/UserShopService.java | 11 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/ShopMapper.java | 3 ruoyi-service/ruoyi-order/pom.xml | 7 ruoyi-common/ruoyi-common-log/src/main/java/com/ruoyi/common/log/service/AsyncLogService.java | 3 ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/utils/DictUtils.java | 76 + ruoyi-api/ruoyi-api-account/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports | 6 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/CommissionServiceImpl.java | 111 + ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictDataServiceImpl.java | 4 ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysUser.java | 33 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UserShopServiceImpl.java | 16 ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/SysUserFallbackFactory.java | 5 ruoyi-api/ruoyi-api-order/src/main/java/feignClient/RemoteOrderGoodsClient.java | 9 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/enums/WithdrawalAuditStatus.java | 2 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/CommissionService.java | 12 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/ShoppingCartService.java | 22 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/BaseSettingClientFallbackFactory.java | 22 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/SystemConfigController.java | 17 ruoyi-api/ruoyi-api-order/src/main/java/vo/OrderDetailVO.java | 6 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/SystemConfigClient.java | 27 ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/web/domain/AjaxResult.java | 45 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserPointController.java | 30 ruoyi-service/ruoyi-other/src/main/resources/mapper/other/SeckillActivityInfoMapper.xml | 6 ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/task/AfterSalesTask.java | 39 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TechnicianSubscribeServiceImpl.java | 32 ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/BalanceChangeRecordClientFallbackFactory.java | 23 ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppUserClient.java | 20 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsShopController.java | 13 ruoyi-api/ruoyi-api-order/src/main/java/vo/OrderGoodsVO.java | 4 ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/feignClient/SysUserClient.java | 10 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/CouponInfoController.java | 21 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AppUserServiceImpl.java | 180 ++ ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/TechnicianSubscribeService.java | 3 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/UserPointService.java | 7 ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/AppUserShop.java | 31 ruoyi-api/ruoyi-api-order/src/main/java/feignClient/RemoteOrderClient.java | 41 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TechnicianSubscribeController.java | 36 ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/UserAddressClientFallbackFactory.java | 28 ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/BalanceChangeRecord.java | 12 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/TechnicianClient.java | 20 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/enums/OrderType.java | 26 ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/vo/PaymentUserCouponVo.java | 9 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WalletController.java | 62 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserCouponController.java | 48 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsController.java | 13 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/CouponInfoClient.java | 28 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/vo/GetGoodsShopByGoodsIds.java | 21 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserPointServiceImpl.java | 54 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/OrderActivityInfoController.java | 27 ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/vo/CouponInfoVo.java | 3 ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/UserCouponClient.java | 39 ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/model/UserShop.java | 31 ruoyi-common/ruoyi-common-log/src/main/java/com/ruoyi/common/log/aspect/LogAspect.java | 2 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/LoginVo.java | 2 ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/UserPoint.java | 8 ruoyi-api/ruoyi-api-order/src/main/java/factory/RemoteOrderFallbackFactory.java | 38 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java | 28 ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserClientFallbackFactory.java | 18 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/AppUserShopService.java | 11 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/enums/PointChangeType.java | 34 ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/UserCouponClientFallbackFactory.java | 32 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AppUserShopServiceImpl.java | 15 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/OrderActivityInfoClientFallbackFactory.java | 20 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsCategoryController.java | 2 ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/UserPointClient.java | 26 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/NearbyReferrerVo.java | 4 ruoyi-api/ruoyi-api-order/src/main/java/factory/RemoteOrderGoodsFallbackFactory.java | 15 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/RemoteVipSettingClient.java | 5 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/BannerController.java | 4 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/ShopClientFallbackFactory.java | 25 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/AppUserShopMapper.java | 11 ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/UserPointFallbackFactory.java | 22 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java | 840 +++++++++++++ ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/BalanceChangeRecordController.java | 37 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserCouponServiceImpl.java | 67 + ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/UserAddressClient.java | 34 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/MyShoppingCartVo.java | 62 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java | 36 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/TechnicianClientFallbackFactory.java | 23 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/WalletVO.java | 3 .gitignore | 3 ruoyi-service/ruoyi-account/pom.xml | 4 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/VipSettingController.java | 9 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/ShoppingCartPayment.java | 10 ruoyi-api/ruoyi-api-order/src/main/java/model/Order.java | 12 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java | 24 ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/AppUser.java | 27 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/AppUserService.java | 14 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/SystemConfigClientFallbackFactory.java | 22 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/SeckillActivityInfoController.java | 12 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/StoreClient.java | 1 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/BaseSettingClient.java | 26 ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/vo/PaymentUserCoupon.java | 25 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/GoodsClientFallbackFactory.java | 5 ruoyi-api/ruoyi-api-other/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports | 10 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/SeckillActivityInfoClientFallbackFactory.java | 3 ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysLoginService.java | 10 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/OrderActivityInfoClient.java | 26 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/enums/OrderStatus.java | 32 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/UserShopMapper.java | 11 ruoyi-modules/ruoyi-system/src/main/resources/mapping/system/UserShopMapper.xml | 5 /dev/null | 44 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/BaseSetting.java | 2 ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysRecordLogService.java | 1 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java | 39 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserShopController.java | 31 ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/GoodsClient.java | 8 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/OrderService.java | 8 ruoyi-service/ruoyi-other/pom.xml | 6 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/ShoppingCartController.java | 37 ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/BalanceChangeRecordClient.java | 26 127 files changed, 3,234 insertions(+), 414 deletions(-) diff --git a/.gitignore b/.gitignore index 09e64c6..29f93e5 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,5 @@ *.yaml *.yml -*.log \ No newline at end of file +*.log +*.iml \ No newline at end of file diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserClientFallbackFactory.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserClientFallbackFactory.java index e371a18..c877f44 100644 --- a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserClientFallbackFactory.java +++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/AppUserClientFallbackFactory.java @@ -2,9 +2,13 @@ import com.ruoyi.account.api.feignClient.AppUserClient; import com.ruoyi.account.api.model.AppUser; +import com.ruoyi.account.api.model.AppUserShop; import com.ruoyi.common.core.domain.R; import lombok.extern.slf4j.Slf4j; import org.springframework.cloud.openfeign.FallbackFactory; +import org.springframework.web.bind.annotation.PostMapping; + +import java.util.List; /** * @author zhibing.pu @@ -19,7 +23,8 @@ public AppUserClient create(Throwable cause) { return new AppUserClient() { - @Override + @PostMapping("/appUser/getAppUserById") + @Override public AppUser getAppUserById(Long id) { log.error("根据id获取用户失败:{}", cause.getMessage()); throw new RuntimeException("根据id获取用户失败"); @@ -38,6 +43,17 @@ } @Override + public R<List<AppUserShop>> getAppUserShop(Long userId) { + log.error("获取用户门店信息失败:{}", cause.getMessage()); + throw new RuntimeException("获取用户门店信息失败"); + } + + @Override + public R<List<AppUser>> getUserAncestorList(Long id) { + log.error("获取用户祖籍列表失败:{}", cause.getMessage()); + throw new RuntimeException("获取用户祖籍列表失败"); + } + @Override public R<Long> getVipCount(Long userId, Integer vipId) { log.error("获取直推会员数失败:{}", cause.getMessage()); throw new RuntimeException("获取直推会员数失败"); 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 new file mode 100644 index 0000000..7471ade --- /dev/null +++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/BalanceChangeRecordClientFallbackFactory.java @@ -0,0 +1,23 @@ +package com.ruoyi.account.api.factory; + +import com.ruoyi.account.api.feignClient.BalanceChangeRecordClient; +import com.ruoyi.account.api.model.BalanceChangeRecord; +import com.ruoyi.common.core.domain.R; +import org.springframework.cloud.openfeign.FallbackFactory; + +/** + * @author zhibing.pu + * @Date 2024/12/2 15:35 + */ +public class BalanceChangeRecordClientFallbackFactory implements FallbackFactory<BalanceChangeRecordClient> { + @Override + public BalanceChangeRecordClient create(Throwable cause) { + return new BalanceChangeRecordClient(){ + + @Override + public R saveBalanceChangeRecord(BalanceChangeRecord balanceChangeRecord) { + return R.fail("保存账户流水记录失败:" + cause.getMessage()); + } + }; + } +} diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/UserAddressClientFallbackFactory.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/UserAddressClientFallbackFactory.java new file mode 100644 index 0000000..f6b2f98 --- /dev/null +++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/UserAddressClientFallbackFactory.java @@ -0,0 +1,28 @@ +package com.ruoyi.account.api.factory; + +import com.ruoyi.account.api.feignClient.UserAddressClient; +import com.ruoyi.account.api.model.UserAddress; +import com.ruoyi.common.core.domain.R; +import org.springframework.cloud.openfeign.FallbackFactory; + +/** + * @author zhibing.pu + * @Date 2024/11/29 11:55 + */ +public class UserAddressClientFallbackFactory implements FallbackFactory<UserAddressClient> { + @Override + public UserAddressClient create(Throwable cause) { + return new UserAddressClient(){ + + @Override + public R<UserAddress> getDefaultUserAddress(Long userId) { + return R.fail("获取用户默认地址失败:" + cause.getMessage()); + } + + @Override + public R<UserAddress> getUserAddressById(Integer id) { + return R.fail("根据id获取用户地址信息失败:" + cause.getMessage()); + } + }; + } +} diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/UserCouponClientFallbackFactory.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/UserCouponClientFallbackFactory.java new file mode 100644 index 0000000..1ab202f --- /dev/null +++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/UserCouponClientFallbackFactory.java @@ -0,0 +1,32 @@ +package com.ruoyi.account.api.factory; + +import com.ruoyi.account.api.feignClient.UserCouponClient; +import com.ruoyi.account.api.vo.CouponInfoVo; +import com.ruoyi.account.api.vo.PaymentUserCoupon; +import com.ruoyi.account.api.vo.PaymentUserCouponVo; +import com.ruoyi.common.core.domain.R; +import org.springframework.cloud.openfeign.FallbackFactory; + +import java.util.List; + +/** + * @author zhibing.pu + * @Date 2024/11/29 14:23 + */ +public class UserCouponClientFallbackFactory implements FallbackFactory<UserCouponClient> { + @Override + public UserCouponClient create(Throwable cause) { + return new UserCouponClient() { + + @Override + public R<List<PaymentUserCouponVo>> getPaymentUserCoupon(PaymentUserCoupon paymentUserCoupon) { + return R.fail("根据id获取优惠券数据失败:" + cause.getMessage()); + } + + @Override + public R<CouponInfoVo> getCouponInfo(Long userCouponId) { + return R.fail("根据用户优惠券id获取优惠券详情失败:" + cause.getMessage()); + } + }; + } +} 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 new file mode 100644 index 0000000..96ac46e --- /dev/null +++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/factory/UserPointFallbackFactory.java @@ -0,0 +1,22 @@ +package com.ruoyi.account.api.factory; + +import com.ruoyi.account.api.feignClient.UserPointClient; +import com.ruoyi.account.api.model.UserPoint; +import com.ruoyi.common.core.domain.R; +import org.springframework.cloud.openfeign.FallbackFactory; + +/** + * @author zhibing.pu + * @Date 2024/12/2 15:04 + */ +public class UserPointFallbackFactory implements FallbackFactory<UserPointClient> { + @Override + public UserPointClient create(Throwable cause) { + return new UserPointClient() { + @Override + public R saveUserPoint(UserPoint userPoint) { + return R.fail("保存积分流水记录失败:" + cause.getMessage()); + } + }; + } +} diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppUserClient.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppUserClient.java index 0e95dad..8d5b424 100644 --- a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppUserClient.java +++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/AppUserClient.java @@ -2,11 +2,16 @@ import com.ruoyi.account.api.factory.AppUserClientFallbackFactory; import com.ruoyi.account.api.model.AppUser; +import com.ruoyi.account.api.model.AppUserShop; import com.ruoyi.common.core.constant.ServiceNameConstants; import com.ruoyi.common.core.domain.R; import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; + +import java.util.List; /** * @author zhibing.pu @@ -20,7 +25,7 @@ * @param id * @return */ - @PostMapping("/app-user/getAppUserById") + @PostMapping("/appUser/getAppUserById") AppUser getAppUserById(@RequestParam("id") Long id); /** @@ -32,6 +37,19 @@ @PostMapping("/app-user/getCouponCount") R<Long> getCouponCount(@RequestParam("userId")Long userId, @RequestParam("couponId") Integer couponId ); + /** + * 根据用户id查询用户门店信息 + */ + @GetMapping("/appUserShop/shop/{userId}") + R<List<AppUserShop>> getAppUserShop(@PathVariable("userId") Long userId); + + /** + * 根据用户id获取用户的祖籍列表 + */ + @GetMapping("/appletLogin/getUserAncestorList") + R<List<AppUser>> getUserAncestorList(@RequestParam("id") Long id); + + @PostMapping("/app-user/getVipCount") R<Long> getVipCount(@RequestParam("userId")Long userId, @RequestParam("vipId") Integer vipId ); 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 new file mode 100644 index 0000000..3722e49 --- /dev/null +++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/BalanceChangeRecordClient.java @@ -0,0 +1,26 @@ +package com.ruoyi.account.api.feignClient; + +import com.ruoyi.account.api.factory.BalanceChangeRecordClientFallbackFactory; +import com.ruoyi.account.api.model.BalanceChangeRecord; +import com.ruoyi.common.core.constant.ServiceNameConstants; +import com.ruoyi.common.core.domain.R; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +/** + * @author zhibing.pu + * @Date 2024/12/2 15:34 + */ +@FeignClient(contextId = "BalanceChangeRecordClient", value = ServiceNameConstants.ACCOUNT_SERVICE, fallbackFactory = BalanceChangeRecordClientFallbackFactory.class) +public interface BalanceChangeRecordClient { + + + /** + * 保存账户流水记录 + * @param balanceChangeRecord + * @return + */ + @PostMapping("/balanceChangeRecord/saveBalanceChangeRecord") + R saveBalanceChangeRecord(@RequestBody BalanceChangeRecord balanceChangeRecord); +} diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/UserAddressClient.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/UserAddressClient.java new file mode 100644 index 0000000..90ce1db --- /dev/null +++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/UserAddressClient.java @@ -0,0 +1,34 @@ +package com.ruoyi.account.api.feignClient; + +import com.ruoyi.account.api.factory.UserAddressClientFallbackFactory; +import com.ruoyi.account.api.model.UserAddress; +import com.ruoyi.common.core.constant.ServiceNameConstants; +import com.ruoyi.common.core.domain.R; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; + +/** + * @author zhibing.pu + * @Date 2024/11/29 11:54 + */ +@FeignClient(contextId = "UserAddressClient", value = ServiceNameConstants.ACCOUNT_SERVICE, fallbackFactory = UserAddressClientFallbackFactory.class) +public interface UserAddressClient { + + /** + * 获取用户默认地址 + * @param userId + * @return + */ + @PostMapping("/user-address/getDefaultUserAddress") + R<UserAddress> getDefaultUserAddress(@RequestParam("userId") Long userId); + + + /** + * 根据id获取用户地址信息 + * @param id + * @return + */ + @PostMapping("/user-address/getUserAddressById") + R<UserAddress> getUserAddressById(@RequestParam("id") Integer id); +} diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/UserCouponClient.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/UserCouponClient.java new file mode 100644 index 0000000..84b2d1c --- /dev/null +++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/UserCouponClient.java @@ -0,0 +1,39 @@ +package com.ruoyi.account.api.feignClient; + +import com.ruoyi.account.api.factory.UserCouponClientFallbackFactory; +import com.ruoyi.account.api.vo.CouponInfoVo; +import com.ruoyi.account.api.vo.PaymentUserCoupon; +import com.ruoyi.account.api.vo.PaymentUserCouponVo; +import com.ruoyi.common.core.constant.ServiceNameConstants; +import com.ruoyi.common.core.domain.R; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; + +import java.util.List; + +/** + * @author zhibing.pu + * @Date 2024/11/29 14:22 + */ +@FeignClient(contextId = "UserCouponClient", value = ServiceNameConstants.ACCOUNT_SERVICE, fallbackFactory = UserCouponClientFallbackFactory.class) +public interface UserCouponClient { + + /** + * 根据id获取优惠券数据 + * @param paymentUserCoupon + * @return + */ + @PostMapping("/user-coupon/getPaymentUserCoupon") + R<List<PaymentUserCouponVo>> getPaymentUserCoupon(@RequestBody PaymentUserCoupon paymentUserCoupon); + + + /** + * 根据用户优惠券id获取优惠券详情 + * @param userCouponId + * @return + */ + @PostMapping("/user-coupon/getCouponInfo") + R<CouponInfoVo> getCouponInfo(@RequestParam("userCouponId") Long userCouponId); +} 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 new file mode 100644 index 0000000..c7af699 --- /dev/null +++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/feignClient/UserPointClient.java @@ -0,0 +1,26 @@ +package com.ruoyi.account.api.feignClient; + +import com.ruoyi.account.api.factory.UserPointFallbackFactory; +import com.ruoyi.account.api.model.UserPoint; +import com.ruoyi.common.core.constant.ServiceNameConstants; +import com.ruoyi.common.core.domain.R; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +/** + * @author zhibing.pu + * @Date 2024/12/2 15:04 + */ +@FeignClient(contextId = "UserPointClient", value = ServiceNameConstants.ACCOUNT_SERVICE, fallbackFactory = UserPointFallbackFactory.class) +public interface UserPointClient { + + /** + * 保存积分流水记录 + * @param userPoint + * @return + */ + @PostMapping("/user-point/saveUserPoint") + R saveUserPoint(@RequestBody UserPoint userPoint); + +} diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/AppUser.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/AppUser.java index 026c52b..4914aad 100644 --- a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/AppUser.java +++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/AppUser.java @@ -33,6 +33,9 @@ @TableId("id") private Long id; + @ApiModelProperty(value = "用户类型(1-普通用户,2-门店员工)") + private Integer userType; + @ApiModelProperty(value = "用户") @TableField("name") private String name; @@ -100,19 +103,19 @@ @ApiModelProperty(value = "合伙人积分数") @TableField("part_point") - private BigDecimal partPoint; + private Integer partPoint; @ApiModelProperty(value = "合伙人培育积分数") @TableField("part_grow_point") - private BigDecimal partGrowPoint; + private Integer partGrowPoint; @ApiModelProperty(value = "消费积分数") @TableField("shop_point") - private BigDecimal shopPoint; + private Integer shopPoint; @ApiModelProperty(value = "返佣积分数") @TableField("share_point") - private BigDecimal sharePoint; + private Integer sharePoint; @ApiModelProperty(value = "消费总金额") @TableField("shop_amount") @@ -121,6 +124,10 @@ @ApiModelProperty(value = "最后消费时间") @TableField("last_shop_time") private LocalDateTime lastShopTime; + + @ApiModelProperty(value = "账户余额") + @TableField("balance") + private BigDecimal balance; @ApiModelProperty(value = "可提现金额") @TableField("withdrawable_amount") @@ -141,10 +148,11 @@ @ApiModelProperty(value = "分销总金额") @TableField("total_distribution_amount") private BigDecimal totalDistributionAmount; - + + @ApiModelProperty(value = "剩余积分") @TableField("lave_point") - private BigDecimal lavePoint; + private Integer lavePoint; @ApiModelProperty(value = "是否可更换推广人(0=否,1=是)") @TableField("change_promoter") @@ -183,24 +191,31 @@ private String districtCode; @ApiModelProperty("等级1会员数") + @TableField(exist = false) private Long count1; @ApiModelProperty("等级2会员数") + @TableField(exist = false) private Long count2; @ApiModelProperty("等级3会员数") + @TableField(exist = false) private Long count3; @ApiModelProperty("等级4会员数") + @TableField(exist = false) private Long count4; @ApiModelProperty("等级5会员数") + @TableField(exist = false) private Long count5; @ApiModelProperty("等级6会员数") + @TableField(exist = false) private Long count6; @ApiModelProperty("等级7会员数") + @TableField(exist = false) private Long count7; diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/AppUserShop.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/AppUserShop.java new file mode 100644 index 0000000..c43a629 --- /dev/null +++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/AppUserShop.java @@ -0,0 +1,31 @@ +package com.ruoyi.account.api.model; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +/** + * @author zhibing.pu + * @Date 2024/12/2 9:18 + */ +@Data +@TableName("t_app_user_shop") +public class AppUserShop { + /** + * 主键 + */ + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + /** + * 用户id + */ + @TableField("app_user_id") + private Long appUserId; + /** + * 门店id + */ + @TableField("shop_id") + private Integer shopId; +} 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 8de1bfd..a3a839d 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 @@ -1,6 +1,7 @@ package com.ruoyi.account.api.model; import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; @@ -31,7 +32,7 @@ private Long orderId; @ApiModelProperty("类型:1充值2提现3红包4分佣5商城购物") - private Integer type; + private Integer changeType; @ApiModelProperty("变更前金额") private BigDecimal beforeAmount; @@ -47,4 +48,13 @@ @ApiModelProperty("添加时间") private LocalDateTime createTime; + + @TableField(exist = false) + @ApiModelProperty("消费用户名称") + private String userName; + + @TableField(exist = false) + @ApiModelProperty("消费金额") + private BigDecimal amount; + } 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 9a98d9d..89d0ba8 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 @@ -38,11 +38,15 @@ @ApiModelProperty(value = "历史余额") @TableField("historical_point") - private BigDecimal historicalPoint; + private Integer historicalPoint; @ApiModelProperty(value = "变动金额") @TableField("variable_point") - private BigDecimal variablePoint; + private Integer variablePoint; + + @ApiModelProperty(value = "变动后余额") + @TableField("balance") + private Integer balance; @ApiModelProperty(value = "变动时间") @TableField("create_time") diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/vo/CouponInfoVo.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/vo/CouponInfoVo.java index 55013f0..3b0ec23 100644 --- a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/vo/CouponInfoVo.java +++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/vo/CouponInfoVo.java @@ -1,5 +1,6 @@ package com.ruoyi.account.api.vo; + import com.baomidou.mybatisplus.annotation.*; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -12,7 +13,7 @@ /** * <p> - * + * * </p> * * @author luodangjia diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/vo/PaymentUserCoupon.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/vo/PaymentUserCoupon.java new file mode 100644 index 0000000..a8ad0fe --- /dev/null +++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/vo/PaymentUserCoupon.java @@ -0,0 +1,25 @@ +package com.ruoyi.account.api.vo; + +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author zhibing.pu + * @Date 2024/11/29 14:32 + */ +@Data +public class PaymentUserCoupon { + /** + * 用户id + */ + private Long userId; + /** + * 订单金额 + */ + private BigDecimal orderMoney; + /** + * 商品类型(1=服务,2=实体商品) + */ + private Integer type; +} diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/CouponInfoVo.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/vo/PaymentUserCouponVo.java similarity index 79% rename from ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/CouponInfoVo.java rename to ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/vo/PaymentUserCouponVo.java index 28a838d..64713fd 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/CouponInfoVo.java +++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/vo/PaymentUserCouponVo.java @@ -1,18 +1,19 @@ -package com.ruoyi.order.vo; +package com.ruoyi.account.api.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.math.BigDecimal; +import java.util.List; /** * @author zhibing.pu - * @Date 2024/11/25 17:59 + * @Date 2024/11/29 16:39 */ @Data @ApiModel -public class CouponInfoVo { +public class PaymentUserCouponVo { @ApiModelProperty("优惠券id") private Long id; @ApiModelProperty("优惠券名称") @@ -31,6 +32,8 @@ private String periodStartTime; @ApiModelProperty("有效期结束时间") private String periodEndTime; + @ApiModelProperty("适用商品id集合,为null表示全部适用") + private List<Integer> forGoodIds; @ApiModelProperty("是否可用") private Boolean available; } diff --git a/ruoyi-api/ruoyi-api-account/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/ruoyi-api/ruoyi-api-account/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index 332cd6d..3261002 100644 --- a/ruoyi-api/ruoyi-api-account/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ b/ruoyi-api/ruoyi-api-account/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -1 +1,5 @@ -com.ruoyi.account.api.factory.AppUserClientFallbackFactory \ No newline at end of file +com.ruoyi.account.api.factory.AppUserClientFallbackFactory +com.ruoyi.account.api.factory.UserAddressClientFallbackFactory +com.ruoyi.account.api.factory.UserCouponClientFallbackFactory +com.ruoyi.account.api.factory.UserPointFallbackFactory +com.ruoyi.account.api.factory.BalanceChangeRecordClientFallbackFactory \ No newline at end of file diff --git a/ruoyi-api/ruoyi-api-order/src/main/java/factory/RemoteOrderFallbackFactory.java b/ruoyi-api/ruoyi-api-order/src/main/java/factory/RemoteOrderFallbackFactory.java index 031b643..d62e606 100644 --- a/ruoyi-api/ruoyi-api-order/src/main/java/factory/RemoteOrderFallbackFactory.java +++ b/ruoyi-api/ruoyi-api-order/src/main/java/factory/RemoteOrderFallbackFactory.java @@ -1,19 +1,19 @@ -package factory; - -import feignClient.RemoteOrderClient; -import org.springframework.cloud.openfeign.FallbackFactory; -import org.springframework.stereotype.Component; - -/** - * 订单服务降级处理 - * @author luofl - */ -@Component -public class RemoteOrderFallbackFactory implements FallbackFactory<RemoteOrderClient> { - - @Override - public RemoteOrderClient create(Throwable cause) { - return new RemoteOrderClient() { - }; - } -} +//package factory; +// +//import feignClient.RemoteOrderClient; +//import org.springframework.cloud.openfeign.FallbackFactory; +//import org.springframework.stereotype.Component; +// +///** +// * 订单服务降级处理 +// * @author luofl +// */ +//@Component +//public class RemoteOrderFallbackFactory implements FallbackFactory<RemoteOrderClient> { +// +// @Override +// public RemoteOrderClient create(Throwable cause) { +// return new RemoteOrderClient() { +// }; +// } +//} diff --git a/ruoyi-api/ruoyi-api-order/src/main/java/factory/RemoteOrderGoodsFallbackFactory.java b/ruoyi-api/ruoyi-api-order/src/main/java/factory/RemoteOrderGoodsFallbackFactory.java index d270ee6..c18ea13 100644 --- a/ruoyi-api/ruoyi-api-order/src/main/java/factory/RemoteOrderGoodsFallbackFactory.java +++ b/ruoyi-api/ruoyi-api-order/src/main/java/factory/RemoteOrderGoodsFallbackFactory.java @@ -3,7 +3,7 @@ import com.ruoyi.common.core.domain.R; import feignClient.RemoteOrderGoodsClient; import lombok.extern.slf4j.Slf4j; -import model.OrderGood; +import model.Order; import org.springframework.cloud.openfeign.FallbackFactory; import java.util.List; @@ -14,10 +14,17 @@ public RemoteOrderGoodsClient create(Throwable cause) { return new RemoteOrderGoodsClient(){ @Override - public R<List<OrderGood>> goodsOrder(List<Long> goodsIds) { - log.error("编辑用户信息失败:{}", cause.getMessage()); - throw new RuntimeException("编辑用户信息失败"); + public R<List<Order>> goodsOrder(List<Long> goodsIds) { + log.error("获取订单商品失败:{}", cause.getMessage()); + throw new RuntimeException("获取订单商品失败"); + } + + @Override + public R<List<Order>> getOrderListByIds(List<Long> orderIds) { + log.error("获取订单列表失败:{}", cause.getMessage()); + throw new RuntimeException("获取订单列表失败"); } }; + } } diff --git a/ruoyi-api/ruoyi-api-order/src/main/java/feignClient/RemoteOrderClient.java b/ruoyi-api/ruoyi-api-order/src/main/java/feignClient/RemoteOrderClient.java index 362df6f..1bfdb19 100644 --- a/ruoyi-api/ruoyi-api-order/src/main/java/feignClient/RemoteOrderClient.java +++ b/ruoyi-api/ruoyi-api-order/src/main/java/feignClient/RemoteOrderClient.java @@ -1,17 +1,24 @@ -package feignClient; - -import com.ruoyi.common.core.constant.ServiceNameConstants; -import com.ruoyi.common.core.domain.R; -import factory.RemoteOrderFallbackFactory; -import model.Order; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; - -/** - * 订单远程调用接口 - * @author luofl - */ -@FeignClient(contextId = "RemoteOrderClient", value = ServiceNameConstants.ORDER_SERVICE, fallbackFactory = RemoteOrderFallbackFactory.class) -public interface RemoteOrderClient { -} +//package feignClient; +// +//import com.ruoyi.common.core.constant.ServiceNameConstants; +//import com.ruoyi.common.core.domain.R; +//import factory.RemoteOrderFallbackFactory; +//import model.Order; +//import model.OrderGood; +//import org.springframework.cloud.openfeign.FeignClient; +//import org.springframework.web.bind.annotation.GetMapping; +//import org.springframework.web.bind.annotation.PostMapping; +//import org.springframework.web.bind.annotation.RequestBody; +//import org.springframework.web.bind.annotation.RequestParam; +// +//import java.util.List; +// +///** +// * 订单远程调用接口 +// * @author luofl +// */ +//@FeignClient(contextId = "RemoteOrderClient", value = ServiceNameConstants.ORDER_SERVICE, fallbackFactory = RemoteOrderFallbackFactory.class) +//public interface RemoteOrderClient { +// +// +//} diff --git a/ruoyi-api/ruoyi-api-order/src/main/java/feignClient/RemoteOrderGoodsClient.java b/ruoyi-api/ruoyi-api-order/src/main/java/feignClient/RemoteOrderGoodsClient.java index 95afd49..a4cd0bd 100644 --- a/ruoyi-api/ruoyi-api-order/src/main/java/feignClient/RemoteOrderGoodsClient.java +++ b/ruoyi-api/ruoyi-api-order/src/main/java/feignClient/RemoteOrderGoodsClient.java @@ -4,6 +4,7 @@ import com.ruoyi.common.core.constant.ServiceNameConstants; import com.ruoyi.common.core.domain.R; import factory.RemoteOrderGoodsFallbackFactory; +import model.Order; import model.OrderGood; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; @@ -18,5 +19,11 @@ * 查询指定商品订单 */ @PostMapping("/order-good/selectGoodsOrder") - public R<List<OrderGood>> goodsOrder(@RequestBody List<Long> goodsIds); + public R<List<Order>> goodsOrder(@RequestBody List<Long> goodsIds); + + /** + * 根据ids查找订单列表 + */ + @PostMapping("/order/getOrderListByIds") + public R<List<Order>> getOrderListByIds(@RequestBody List<Long> orderIds); } diff --git a/ruoyi-api/ruoyi-api-order/src/main/java/model/Order.java b/ruoyi-api/ruoyi-api-order/src/main/java/model/Order.java index c0bf9a7..bbb2401 100644 --- a/ruoyi-api/ruoyi-api-order/src/main/java/model/Order.java +++ b/ruoyi-api/ruoyi-api-order/src/main/java/model/Order.java @@ -44,9 +44,17 @@ @TableField("order_status") private Integer orderStatus; + @ApiModelProperty(value = "是否已分佣: 0-否 1-是") + @TableField("is_commission") + private Integer isCommission; + @ApiModelProperty(value = "核销时间") @TableField("end_time") private LocalDateTime endTime; + + @ApiModelProperty(value = "售后截止日期") + @TableField("after_sale_time") + private LocalDateTime afterSaleTime; @ApiModelProperty(value = "技师id") @TableField("technician_id") @@ -103,7 +111,7 @@ @ApiModelProperty(value = "使用积分") @TableField("point") - private BigDecimal point; + private Integer point; @ApiModelProperty(value = "1wx2积分") @TableField("pay_method") @@ -135,7 +143,7 @@ @ApiModelProperty(value = "本单获取的积分") @TableField("get_point") - private BigDecimal getPoint; + private Integer getPoint; @ApiModelProperty(value = "微信支付号") @TableField("serial_number") diff --git a/ruoyi-api/ruoyi-api-order/src/main/java/model/OrderGood.java b/ruoyi-api/ruoyi-api-order/src/main/java/model/OrderGood.java index 01c601d..cc8495c 100644 --- a/ruoyi-api/ruoyi-api-order/src/main/java/model/OrderGood.java +++ b/ruoyi-api/ruoyi-api-order/src/main/java/model/OrderGood.java @@ -31,11 +31,11 @@ @ApiModelProperty(value = "商品id") @TableField("goods_id") - private Long goodsId; + private Integer goodsId; @ApiModelProperty(value = "订单id") @TableField("order_id") - private Integer orderId; + private Long orderId; @ApiModelProperty(value = "商品券优惠金额") @TableField("good_amount") @@ -61,6 +61,50 @@ @ApiModelProperty(value = "添加时间") @TableField("create_time") private LocalDateTime createTime; + + @ApiModelProperty(value = "可获得消费积分") + @TableField("earn_spending_points") + private Integer earnSpendingPoints; + + @ApiModelProperty(value = "上级获得分佣金额") + @TableField("superior_subcommission") + private BigDecimal superiorSubcommission; + + @ApiModelProperty(value = "上级获得返佣积分") + @TableField("superior_rebate_points") + private Integer superiorRebatePoints; + + @ApiModelProperty(value = "获取返佣积分上级类型(1=直推上级,2=直帮上级)") + @TableField("superior_type") + private Integer superiorType; + + @ApiModelProperty(value = "核销门店可获得服务费") + @TableField("servuce_shop_charges") + private BigDecimal servuceShopCharges; + + @ApiModelProperty(value = "核销门店可获得服务积分") + @TableField("servuce_shop_points") + private Integer servuceShopPoints; + + @ApiModelProperty(value = "技师可获得服务积分") + @TableField("technician_points") + private Integer technicianPoints; + + @ApiModelProperty(value = "绑定门店可获得分佣金额") + @TableField("bound_shop_charges") + private BigDecimal boundShopCharges; + + @ApiModelProperty(value = "绑定门店可获得返佣积分") + @TableField("bound_shop_points") + private Integer boundShopPoints; + + @ApiModelProperty(value = "绑定门店上级门店可获得分佣金额") + @TableField("bound_shop_superiors_charges") + private BigDecimal boundShopSuperiorsCharges; + + @ApiModelProperty(value = "绑定门店上级门店可获得返佣积分") + @TableField("bound_shop_superiors_points") + private Integer boundShopSuperiorsPoints; } diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/OrderDetailVO.java b/ruoyi-api/ruoyi-api-order/src/main/java/vo/OrderDetailVO.java similarity index 93% rename from ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/OrderDetailVO.java rename to ruoyi-api/ruoyi-api-order/src/main/java/vo/OrderDetailVO.java index 2377c61..4063627 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/OrderDetailVO.java +++ b/ruoyi-api/ruoyi-api-order/src/main/java/vo/OrderDetailVO.java @@ -1,4 +1,4 @@ -package com.ruoyi.order.vo; +package vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -18,7 +18,7 @@ private List<OrderGoodsVO> goodsList; @ApiModelProperty(value = "使用积分") - private BigDecimal point; + private Integer point; @ApiModelProperty(value = "收货地址id") private Long addressId; @@ -54,7 +54,7 @@ private BigDecimal expressAmount; @ApiModelProperty(value = "可获得积分") - private BigDecimal pointAmount; + private Integer pointAmount; @ApiModelProperty(value = "实际支付价格") private BigDecimal paymentAmount; diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/OrderGoodsVO.java b/ruoyi-api/ruoyi-api-order/src/main/java/vo/OrderGoodsVO.java similarity index 92% rename from ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/OrderGoodsVO.java rename to ruoyi-api/ruoyi-api-order/src/main/java/vo/OrderGoodsVO.java index e19f665..3ecb979 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/OrderGoodsVO.java +++ b/ruoyi-api/ruoyi-api-order/src/main/java/vo/OrderGoodsVO.java @@ -1,4 +1,4 @@ -package com.ruoyi.order.vo; +package vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -10,7 +10,7 @@ @ApiModel(value = "订单商品") public class OrderGoodsVO { @ApiModelProperty(value = "商品id") - private Long goodsId; + private Integer goodsId; @ApiModelProperty(value = "商品名称") private String goodsName; diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/BaseSetting.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/BaseSetting.java index 5fbef93..d8c2d8a 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/BaseSetting.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/BaseSetting.java @@ -26,7 +26,7 @@ private static final long serialVersionUID = 1L; - @ApiModelProperty(value = "1:合伙人积分设置一 2:合伙人积分设置二 3:会员说明设置 4:活动管理-活动设置 1开0关") + @ApiModelProperty(value = "1:合伙人积分设置一 2:合伙人积分设置二 3:会员说明设置 4:活动管理-活动设置 1开0关 5:售后设置") @TableId("id") private Integer id; diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Goods.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Goods.java index cd1e819..4e6f8d7 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Goods.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Goods.java @@ -28,7 +28,7 @@ @ApiModelProperty(value = "主键") @TableId(value = "id", type = IdType.AUTO) - private Long id; + private Integer id; @ApiModelProperty(value = "名称") @TableField("name") diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/BaseSettingClientFallbackFactory.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/BaseSettingClientFallbackFactory.java new file mode 100644 index 0000000..9c26e4f --- /dev/null +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/BaseSettingClientFallbackFactory.java @@ -0,0 +1,22 @@ +package com.ruoyi.other.api.factory; + +import com.ruoyi.common.core.domain.R; +import com.ruoyi.other.api.domain.BaseSetting; +import com.ruoyi.other.api.domain.Shop; +import com.ruoyi.other.api.feignClient.BaseSettingClient; +import com.ruoyi.other.api.feignClient.ShopClient; +import lombok.extern.slf4j.Slf4j; +import org.springframework.cloud.openfeign.FallbackFactory; + +@Slf4j +public class BaseSettingClientFallbackFactory implements FallbackFactory<BaseSettingClient> { + @Override + public BaseSettingClient create(Throwable cause) { + return new BaseSettingClient(){ + @Override + public R<BaseSetting> getBaseSetting(Integer id) { + return R.fail("获取基础配置失败:" + cause.getMessage()); + } + }; + } +} diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/CouponInfoClientFallbackFactory.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/CouponInfoClientFallbackFactory.java new file mode 100644 index 0000000..b587851 --- /dev/null +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/CouponInfoClientFallbackFactory.java @@ -0,0 +1,24 @@ +package com.ruoyi.other.api.factory; + +import com.ruoyi.common.core.domain.R; +import com.ruoyi.other.api.domain.CouponInfo; +import com.ruoyi.other.api.feignClient.CouponInfoClient; +import org.springframework.cloud.openfeign.FallbackFactory; + +import java.util.List; + +/** + * @author zhibing.pu + * @Date 2024/11/29 14:37 + */ +public class CouponInfoClientFallbackFactory implements FallbackFactory<CouponInfoClient> { + @Override + public CouponInfoClient create(Throwable cause) { + return new CouponInfoClient() { + @Override + public R<List<CouponInfo>> getCouponInfoList(List<Integer> ids) { + return R.fail("根据id集合获取优惠券数据失败:" + cause.getMessage()); + } + }; + } +} diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/GoodsClientFallbackFactory.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/GoodsClientFallbackFactory.java index 110c0a0..1447469 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/GoodsClientFallbackFactory.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/GoodsClientFallbackFactory.java @@ -24,6 +24,11 @@ public R<List<Goods>> getGoodsByType(Integer type) { return R.fail("根据类型(1=服务商品,2=单品商品)获取商品数据失败:" + cause.getMessage()); } + + @Override + public R<Goods> getGoodsById(Integer id) { + return R.fail("根据id获取商品详情失败:" + cause.getMessage()); + } }; } } diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/GoodsShopClientFallbackFactory.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/GoodsShopClientFallbackFactory.java index c320e21..671bc36 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/GoodsShopClientFallbackFactory.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/GoodsShopClientFallbackFactory.java @@ -3,7 +3,10 @@ import com.ruoyi.common.core.domain.R; import com.ruoyi.other.api.domain.GoodsShop; import com.ruoyi.other.api.feignClient.GoodsShopClient; +import com.ruoyi.other.api.vo.GetGoodsShopByGoodsIds; import org.springframework.cloud.openfeign.FallbackFactory; + +import java.util.List; /** * @author zhibing.pu @@ -19,6 +22,11 @@ public R<GoodsShop> getGoodsShop(GoodsShop goodsShop) { return R.fail("获取商品门店关系数据失败:" + cause.getMessage()); } + + @Override + public R<List<GoodsShop>> getGoodsShopByGoodsIds(GetGoodsShopByGoodsIds goodsIds) { + return R.fail("根据商品id集合和门店id查询数据失败:" + cause.getMessage()); + } }; } } diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/OrderActivityInfoClientFallbackFactory.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/OrderActivityInfoClientFallbackFactory.java new file mode 100644 index 0000000..99214e9 --- /dev/null +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/OrderActivityInfoClientFallbackFactory.java @@ -0,0 +1,20 @@ +package com.ruoyi.other.api.factory; + +import com.ruoyi.common.core.domain.R; +import com.ruoyi.other.api.domain.OrderActivityInfo; +import com.ruoyi.other.api.feignClient.OrderActivityInfoClient; +import lombok.extern.slf4j.Slf4j; +import org.springframework.cloud.openfeign.FallbackFactory; + +@Slf4j +public class OrderActivityInfoClientFallbackFactory implements FallbackFactory<OrderActivityInfoClient> { + @Override + public OrderActivityInfoClient create(Throwable cause) { + return new OrderActivityInfoClient(){ + @Override + public R<OrderActivityInfo> getNowOrderActivityInfo(Integer vip) { + return R.fail("获取当前生效的活动失败:" + cause.getMessage()); + } + }; + } +} diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/SeckillActivityInfoClientFallbackFactory.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/SeckillActivityInfoClientFallbackFactory.java index d15db4b..e54d7a6 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/SeckillActivityInfoClientFallbackFactory.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/SeckillActivityInfoClientFallbackFactory.java @@ -5,9 +5,10 @@ import com.ruoyi.other.api.feignClient.SeckillActivityInfoClient; import com.ruoyi.other.api.vo.GetSeckillActivityInfo; import lombok.extern.slf4j.Slf4j; +import org.springframework.cloud.openfeign.FallbackFactory; @Slf4j -public class SeckillActivityInfoClientFallbackFactory implements org.springframework.cloud.openfeign.FallbackFactory<SeckillActivityInfoClient> { +public class SeckillActivityInfoClientFallbackFactory implements FallbackFactory<SeckillActivityInfoClient> { @Override public SeckillActivityInfoClient create(Throwable cause) { return new SeckillActivityInfoClient(){ diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/ShopClientFallbackFactory.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/ShopClientFallbackFactory.java new file mode 100644 index 0000000..933c976 --- /dev/null +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/ShopClientFallbackFactory.java @@ -0,0 +1,25 @@ +package com.ruoyi.other.api.factory; + +import com.ruoyi.common.core.domain.R; +import com.ruoyi.other.api.domain.Shop; +import com.ruoyi.other.api.feignClient.ShopClient; +import lombok.extern.slf4j.Slf4j; +import org.springframework.cloud.openfeign.FallbackFactory; + +@Slf4j +public class ShopClientFallbackFactory implements FallbackFactory<ShopClient> { + @Override + public ShopClient create(Throwable cause) { + return new ShopClient(){ + @Override + public R<Shop> getShopById(Integer id) { + return R.fail("根据id获取门店信息失败:" + cause.getMessage()); + } + + @Override + public R<Shop> getShopByPhone(String phone) { + return R.fail("根据店铺管理员电话获取门店数据失败:" + cause.getMessage()); + } + }; + } +} diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/SystemConfigClientFallbackFactory.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/SystemConfigClientFallbackFactory.java new file mode 100644 index 0000000..7578e37 --- /dev/null +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/SystemConfigClientFallbackFactory.java @@ -0,0 +1,22 @@ +package com.ruoyi.other.api.factory; + +import com.ruoyi.common.core.domain.R; +import com.ruoyi.other.api.domain.SystemConfig; +import com.ruoyi.other.api.feignClient.SystemConfigClient; +import org.springframework.cloud.openfeign.FallbackFactory; + +/** + * @author zhibing.pu + * @Date 2024/11/29 15:58 + */ +public class SystemConfigClientFallbackFactory implements FallbackFactory<SystemConfigClient> { + @Override + public SystemConfigClient create(Throwable cause) { + return new SystemConfigClient() { + @Override + public R<SystemConfig> getSystemConfig(Integer type) { + return R.fail("根据类型获取系统配置失败:" + cause.getMessage()); + } + }; + } +} diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/TechnicianClientFallbackFactory.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/TechnicianClientFallbackFactory.java new file mode 100644 index 0000000..3fc2995 --- /dev/null +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/TechnicianClientFallbackFactory.java @@ -0,0 +1,23 @@ +package com.ruoyi.other.api.factory; + +import com.ruoyi.common.core.domain.R; +import com.ruoyi.other.api.domain.Technician; +import com.ruoyi.other.api.feignClient.TechnicianClient; +import org.springframework.cloud.openfeign.FallbackFactory; + +public class TechnicianClientFallbackFactory implements FallbackFactory<TechnicianClient> { + @Override + public TechnicianClient create(Throwable cause) { + return new TechnicianClient() { + @Override + public R<Technician> shopdetail(Integer techId) { + return R.fail("根据省市区获取地区价格配置失败:" + cause.getMessage()); + } + + @Override + public R<Void> updateStatus(Integer status, Integer subscribeId) { + return R.fail("跟新技师预约状态失败:" + cause.getMessage()); + } + }; + } +} diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/BaseSettingClient.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/BaseSettingClient.java new file mode 100644 index 0000000..79935d0 --- /dev/null +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/BaseSettingClient.java @@ -0,0 +1,26 @@ +package com.ruoyi.other.api.feignClient; + +import com.ruoyi.common.core.constant.ServiceNameConstants; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.other.api.domain.BaseSetting; +import com.ruoyi.other.api.factory.BaseSettingClientFallbackFactory; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; + +/** + * @author zhibing.pu + * @Date 2024/11/29 11:34 + */ +@FeignClient(contextId = "BaseSettingClient", value = ServiceNameConstants.OTHER_SERVICE, fallbackFactory = BaseSettingClientFallbackFactory.class) +public interface BaseSettingClient { + + + /** + * 获取基础配置 + * @param id + * @return + */ + @PostMapping("/base-setting/getBaseSetting") + R<BaseSetting> getBaseSetting(@RequestParam("id") Integer id); +} diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/CouponInfoClient.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/CouponInfoClient.java new file mode 100644 index 0000000..1b447e5 --- /dev/null +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/CouponInfoClient.java @@ -0,0 +1,28 @@ +package com.ruoyi.other.api.feignClient; + +import com.ruoyi.common.core.constant.ServiceNameConstants; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.other.api.domain.CouponInfo; +import com.ruoyi.other.api.factory.CouponInfoClientFallbackFactory; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; + +import java.util.List; + +/** + * @author zhibing.pu + * @Date 2024/11/29 14:36 + */ +@FeignClient(contextId = "CouponInfoClient", value = ServiceNameConstants.OTHER_SERVICE, fallbackFactory = CouponInfoClientFallbackFactory.class) +public interface CouponInfoClient { + + + /** + * 根据id集合获取优惠券数据 + * @param ids + * @return + */ + @PostMapping("/coupon-info/getCouponInfoList") + R<List<CouponInfo>> getCouponInfoList(@RequestParam("ids") List<Integer> ids); +} diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/GoodsClient.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/GoodsClient.java index f24bb8d..4384c32 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/GoodsClient.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/GoodsClient.java @@ -26,4 +26,12 @@ @PostMapping("/goods/getGoodsByType") R<List<Goods>> getGoodsByType(@RequestParam("type") Integer type); + + /** + * 根据id获取商品详情 + * @param id + * @return + */ + @PostMapping("/goods/getGoodsById") + R<Goods> getGoodsById(@RequestParam("id") Integer id); } diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/GoodsShopClient.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/GoodsShopClient.java index cc033c8..300d0f3 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/GoodsShopClient.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/GoodsShopClient.java @@ -4,9 +4,12 @@ import com.ruoyi.common.core.domain.R; import com.ruoyi.other.api.domain.GoodsShop; import com.ruoyi.other.api.factory.GoodsShopClientFallbackFactory; +import com.ruoyi.other.api.vo.GetGoodsShopByGoodsIds; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; + +import java.util.List; /** * @author zhibing.pu @@ -22,4 +25,12 @@ */ @PostMapping("/goods-shop/getGoodsShop") R<GoodsShop> getGoodsShop(@RequestBody GoodsShop goodsShop); + + /** + * 根据商品id集合和门店id查询数据 + * @param goodsIds + * @return + */ + @PostMapping("/goods-shop/getGoodsShopByGoodsIds") + R<List<GoodsShop>> getGoodsShopByGoodsIds(@RequestBody GetGoodsShopByGoodsIds goodsIds); } diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/OrderActivityInfoClient.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/OrderActivityInfoClient.java new file mode 100644 index 0000000..6404f0d --- /dev/null +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/OrderActivityInfoClient.java @@ -0,0 +1,26 @@ +package com.ruoyi.other.api.feignClient; + +import com.ruoyi.common.core.constant.ServiceNameConstants; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.other.api.domain.OrderActivityInfo; +import com.ruoyi.other.api.factory.OrderActivityInfoClientFallbackFactory; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; + +/** + * @author zhibing.pu + * @Date 2024/11/29 10:55 + */ +@FeignClient(contextId = "OrderActivityInfoClient", value = ServiceNameConstants.ORDER_SERVICE, fallbackFactory = OrderActivityInfoClientFallbackFactory.class) +public interface OrderActivityInfoClient { + + + /** + * 获取当前生效的活动 + * @param vip + * @return + */ + @PostMapping("/order-activity-info/getNowOrderActivityInfo") + R<OrderActivityInfo> getNowOrderActivityInfo(@RequestParam("vip") Integer vip); +} diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/RemoteVipSettingClient.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/RemoteVipSettingClient.java index 7df1f05..d99075a 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/RemoteVipSettingClient.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/RemoteVipSettingClient.java @@ -6,10 +6,11 @@ import com.ruoyi.other.api.factory.RemoteVipSettingFallbackFactory; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; -@FeignClient(contextId = "RemoteOrderGoodsClient", value = ServiceNameConstants.ORDER_SERVICE, fallbackFactory = RemoteVipSettingFallbackFactory.class) +@FeignClient(contextId = "RemoteVipSettingClient", value = ServiceNameConstants.OTHER_SERVICE, fallbackFactory = RemoteVipSettingFallbackFactory.class) public interface RemoteVipSettingClient { @GetMapping("/vip-setting/getVipSettingById") - R<VipSetting> getVipSettingById(Integer id); + R<VipSetting> getVipSettingById(@RequestParam(value = "id",required = true) Integer id); } diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/ShopClient.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/ShopClient.java new file mode 100644 index 0000000..a49ac62 --- /dev/null +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/ShopClient.java @@ -0,0 +1,35 @@ +package com.ruoyi.other.api.feignClient; + +import com.ruoyi.common.core.constant.ServiceNameConstants; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.other.api.domain.Shop; +import com.ruoyi.other.api.factory.ShopClientFallbackFactory; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; + +/** + * @author zhibing.pu + * @Date 2024/11/29 10:28 + */ +@FeignClient(contextId = "ShopClient", value = ServiceNameConstants.ORDER_SERVICE, fallbackFactory = ShopClientFallbackFactory.class) +public interface ShopClient { + + + /** + * 根据id获取门店信息 + * @param id + * @return + */ + @PostMapping("/shop/getShopById") + R<Shop> getShopById(@RequestParam("id") Integer id); + + + /** + * 根据店铺管理员电话获取门店数据 + * @param phone + * @return + */ + @PostMapping("/shop/getShopByPhone") + R<Shop> getShopByPhone(@RequestParam("phone") String phone); +} diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/StoreClient.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/StoreClient.java index 79cc539..f4cbb4f 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/StoreClient.java +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/StoreClient.java @@ -3,7 +3,6 @@ import com.ruoyi.common.core.constant.ServiceNameConstants; import com.ruoyi.common.core.domain.R; import com.ruoyi.other.api.domain.Shop; -import com.ruoyi.other.api.factory.OrderFallbackFactory; import com.ruoyi.other.api.factory.StoreFallbackFactory; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/SystemConfigClient.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/SystemConfigClient.java new file mode 100644 index 0000000..9eff59d --- /dev/null +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/SystemConfigClient.java @@ -0,0 +1,27 @@ +package com.ruoyi.other.api.feignClient; + +import com.ruoyi.common.core.constant.ServiceNameConstants; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.other.api.domain.SystemConfig; +import com.ruoyi.other.api.factory.SystemConfigClientFallbackFactory; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; + +/** + * @author zhibing.pu + * @Date 2024/11/29 15:58 + */ +@FeignClient(contextId = "SystemConfigClient", value = ServiceNameConstants.ORDER_SERVICE, fallbackFactory = SystemConfigClientFallbackFactory.class) +public interface SystemConfigClient { + + + /** + * 根据类型获取系统配置 + * @param type + * @return + */ + @PostMapping("/system-config/getSystemConfig") + R<SystemConfig> getSystemConfig(@RequestParam("type") Integer type); + +} diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/TechnicianClient.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/TechnicianClient.java new file mode 100644 index 0000000..da8b289 --- /dev/null +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/TechnicianClient.java @@ -0,0 +1,20 @@ +package com.ruoyi.other.api.feignClient; + +import com.ruoyi.common.core.constant.ServiceNameConstants; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.other.api.domain.Technician; +import com.ruoyi.other.api.factory.TechnicianClientFallbackFactory; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestParam; + +@FeignClient(contextId = "TechnicianClient", value = ServiceNameConstants.ORDER_SERVICE, fallbackFactory = TechnicianClientFallbackFactory.class) +public interface TechnicianClient { + + @PostMapping("/technician/shop/detail") + R<Technician> shopdetail(@RequestParam("techId") Integer techId); + + @PutMapping("/technician-subscribe/updateStatus") + R<Void> updateStatus(@RequestParam("status") Integer status, @RequestParam("subscribeId") Integer subscribeId); +} diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/vo/GetGoodsShopByGoodsIds.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/vo/GetGoodsShopByGoodsIds.java new file mode 100644 index 0000000..81a2f96 --- /dev/null +++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/vo/GetGoodsShopByGoodsIds.java @@ -0,0 +1,21 @@ +package com.ruoyi.other.api.vo; + +import lombok.Data; + +import java.util.List; + +/** + * @author zhibing.pu + * @Date 2024/12/2 10:18 + */ +@Data +public class GetGoodsShopByGoodsIds { + /** + * 门店id + */ + private Integer shopId; + /** + * 商品id集合 + */ + private List<Integer> goodsIds; +} diff --git a/ruoyi-api/ruoyi-api-other/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/ruoyi-api/ruoyi-api-other/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index 55fb60b..1790609 100644 --- a/ruoyi-api/ruoyi-api-other/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ b/ruoyi-api/ruoyi-api-other/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -4,4 +4,12 @@ com.ruoyi.other.api.factory.GoodsVipClientFallbackFactory com.ruoyi.other.api.factory.SeckillActivityInfoClientFallbackFactory com.ruoyi.other.api.factory.GoodsBargainPriceClientFallbackFactory -com.ruoyi.other.api.factory.RemoteVipSettingFallbackFactory \ No newline at end of file +com.ruoyi.other.api.factory.RemoteVipSettingFallbackFactory +com.ruoyi.other.api.factory.ShopClientFallbackFactory +com.ruoyi.other.api.factory.OrderActivityInfoClientFallbackFactory +com.ruoyi.other.api.factory.BaseSettingClientFallbackFactory +com.ruoyi.other.api.factory.CouponInfoClientFallbackFactory +com.ruoyi.other.api.factory.SystemConfigClientFallbackFactory +com.ruoyi.other.api.factory.StoreFallbackFactory +com.ruoyi.other.api.factory.CouponClientFallbackFactory +com.ruoyi.other.api.factory.TechnicianClientFallbackFactory \ No newline at end of file diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysUser.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysUser.java index 14189c9..84549eb 100644 --- a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysUser.java +++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysUser.java @@ -115,7 +115,7 @@ /** * 角色类型 1=平台 2=公司 3=门店 4=修理厂 */ - @ApiModelProperty(value = "角色类型 1=平台 2=合作商") + @ApiModelProperty(value = "角色类型 1=平台 2=门店") private Integer roleType; @Excel(name = "密码修改时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT) @@ -131,13 +131,9 @@ @TableField("forbidden_remark") private String forbiddenRemark; - @ApiModelProperty(value = "充电站") - @TableField(exist = false) - private List<String> siteNames; - - @ApiModelProperty(value = "充电站id", required = true) - @TableField(exist = false) - private List<Integer> siteIds; + @ApiModelProperty(value = "前端用户id") + @TableField("app_user_id") + private Long appUserId; @ApiModelProperty(value = "角色") @TableField(exist = false) @@ -386,25 +382,12 @@ this.roleId = roleId; } - - public List<String> getSiteNames() { - return siteNames; + public Long getAppUserId() { + return appUserId; } - public void setSiteNames(List<String> siteNames) { - this.siteNames = siteNames; - } - - public List<String> getRoleNames() { - return roleNames; - } - - public List<Integer> getSiteIds() { - return siteIds; - } - - public void setSiteIds(List<Integer> siteIds) { - this.siteIds = siteIds; + public void setAppUserId(Long appUserId) { + this.appUserId = appUserId; } public void setRoleNames(List<String> roleNames) { diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/SysUserFallbackFactory.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/SysUserFallbackFactory.java index f13ead3..bf86892 100644 --- a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/SysUserFallbackFactory.java +++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/SysUserFallbackFactory.java @@ -73,6 +73,11 @@ public R resetPassword(SysUser user) { return R.fail("重置用户密码失败:" + cause.getMessage()); } + + @Override + public R saveShopUser(SysUser user) { + return R.fail("新增加门店员工账号数据失败:" + cause.getMessage()); + } }; } } diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/feignClient/SysUserClient.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/feignClient/SysUserClient.java index 4c8f0ed..e9dc726 100644 --- a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/feignClient/SysUserClient.java +++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/feignClient/SysUserClient.java @@ -88,4 +88,14 @@ */ @PostMapping("/user/resetPassword") R resetPassword(@RequestBody SysUser user); + + + /** + * 新增加门店员工账号数据 + * @param user + * @return + */ + @PostMapping("/user/saveShopUser") + R saveShopUser(@RequestBody SysUser user); + } diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/model/UserShop.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/model/UserShop.java new file mode 100644 index 0000000..bc8a12a --- /dev/null +++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/model/UserShop.java @@ -0,0 +1,31 @@ +package com.ruoyi.system.api.model; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +/** + * @author zhibing.pu + * @Date 2024/12/2 9:36 + */ +@Data +@TableName("t_user_shop") +public class UserShop { + /** + * 主键 + */ + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + /** + * 用户id + */ + @TableField("user_id") + private Integer userId; + /** + * 门店id + */ + @TableField("shop_id") + private Integer shopId; +} diff --git a/ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysLoginService.java b/ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysLoginService.java index 53ed3c5..3c1c904 100644 --- a/ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysLoginService.java +++ b/ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysLoginService.java @@ -1,5 +1,6 @@ package com.ruoyi.auth.service; +import com.ruoyi.system.api.RemoteUserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import com.ruoyi.common.core.constant.CacheConstants; @@ -17,6 +18,7 @@ import com.ruoyi.system.api.domain.SysUser; import com.ruoyi.system.api.model.LoginUser; +import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; /** @@ -26,16 +28,16 @@ */ @Component public class SysLoginService { - @Autowired + @Resource private RemoteUserService remoteUserService; - @Autowired + @Resource private SysPasswordService passwordService; - @Autowired + @Resource private SysRecordLogService recordLogService; - @Autowired + @Resource private RedisService redisService; /** diff --git a/ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysRecordLogService.java b/ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysRecordLogService.java index f0e13a6..588cd20 100644 --- a/ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysRecordLogService.java +++ b/ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysRecordLogService.java @@ -1,6 +1,7 @@ package com.ruoyi.auth.service; import com.ruoyi.system.api.domain.SysLoginLog; +import com.ruoyi.system.api.feignClient.SysLoginLogClient; import org.springframework.stereotype.Component; import javax.annotation.Resource; diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/web/domain/AjaxResult.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/web/domain/AjaxResult.java index f4e88db..951d83d 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/web/domain/AjaxResult.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/web/domain/AjaxResult.java @@ -4,28 +4,24 @@ import java.util.Objects; import com.ruoyi.common.core.constant.HttpStatus; import com.ruoyi.common.core.utils.StringUtils; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; /** * 操作消息提醒 * * @author ruoyi */ -@ApiModel -public class AjaxResult<T> extends HashMap { +public class AjaxResult<T> extends HashMap<String, Object> +{ + private static final long serialVersionUID = 1L; /** 状态码 */ - @ApiModelProperty("状态码") - private int code; + public static final String CODE_TAG = "code"; /** 返回内容 */ - @ApiModelProperty("描述内容") - private String msg = ""; + public static final String MSG_TAG = "msg"; /** 数据对象 */ - @ApiModelProperty("结果集") - private T data; + public static final String DATA_TAG = "data"; /** * 初始化一个新创建的 AjaxResult 对象,使其表示一个空消息。 @@ -42,8 +38,8 @@ */ public AjaxResult(int code, String msg) { - this.code = code; - this.msg = msg; + super.put(CODE_TAG, code); + super.put(MSG_TAG, msg); } /** @@ -53,12 +49,12 @@ * @param msg 返回内容 * @param data 数据对象 */ - public AjaxResult(int code, String msg, T data) + public AjaxResult(int code, String msg, Object data) { - this.code = code; - this.msg = msg; + super.put(CODE_TAG, code); + super.put(MSG_TAG, msg); if (StringUtils.isNotNull(data)) { - this.data = data; + super.put(DATA_TAG, data); } } @@ -185,7 +181,7 @@ */ public boolean isSuccess() { - return Objects.equals(HttpStatus.SUCCESS, this.code); + return Objects.equals(HttpStatus.SUCCESS, this.get(CODE_TAG)); } /** @@ -199,4 +195,19 @@ } + + + /** + * 方便链式调用 + * + * @param key + * @param value + * @return + */ + @Override + public AjaxResult put(String key, Object value) + { + super.put(key, value); + return this; + } } diff --git a/ruoyi-common/ruoyi-common-log/src/main/java/com/ruoyi/common/log/aspect/LogAspect.java b/ruoyi-common/ruoyi-common-log/src/main/java/com/ruoyi/common/log/aspect/LogAspect.java index 2d674db..b41dcff 100644 --- a/ruoyi-common/ruoyi-common-log/src/main/java/com/ruoyi/common/log/aspect/LogAspect.java +++ b/ruoyi-common/ruoyi-common-log/src/main/java/com/ruoyi/common/log/aspect/LogAspect.java @@ -5,7 +5,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import com.ruoyi.system.api.model.SysOperLog; +import com.ruoyi.system.api.domain.SysOperLog; import org.apache.commons.lang3.ArrayUtils; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.annotation.AfterReturning; diff --git a/ruoyi-common/ruoyi-common-log/src/main/java/com/ruoyi/common/log/service/AsyncLogService.java b/ruoyi-common/ruoyi-common-log/src/main/java/com/ruoyi/common/log/service/AsyncLogService.java index 3b712b3..334b50f 100644 --- a/ruoyi-common/ruoyi-common-log/src/main/java/com/ruoyi/common/log/service/AsyncLogService.java +++ b/ruoyi-common/ruoyi-common-log/src/main/java/com/ruoyi/common/log/service/AsyncLogService.java @@ -1,6 +1,7 @@ package com.ruoyi.common.log.service; -import com.ruoyi.system.api.model.SysOperLog; +import com.ruoyi.system.api.RemoteLogService; +import com.ruoyi.system.api.domain.SysOperLog; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import com.ruoyi.common.core.constant.SecurityConstants; diff --git a/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/utils/DictUtils.java b/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/utils/DictUtils.java new file mode 100644 index 0000000..4471ce0 --- /dev/null +++ b/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/utils/DictUtils.java @@ -0,0 +1,76 @@ +package com.ruoyi.common.security.utils; + +import com.alibaba.fastjson2.JSONArray; +import com.ruoyi.common.core.constant.CacheConstants; +import com.ruoyi.common.core.utils.SpringUtils; +import com.ruoyi.common.core.utils.StringUtils; +import com.ruoyi.common.redis.service.RedisService; +import com.ruoyi.system.api.domain.SysDictData; + +import java.util.Collection; +import java.util.List; + +/** + * 字典工具类 + * + * @author ruoyi + */ +public class DictUtils +{ + /** + * 设置字典缓存 + * + * @param key 参数键 + * @param dictDatas 字典数据列表 + */ + public static void setDictCache(String key, List<SysDictData> dictDatas) + { + SpringUtils.getBean(RedisService.class).setCacheObject(getCacheKey(key), dictDatas); + } + + /** + * 获取字典缓存 + * + * @param key 参数键 + * @return dictDatas 字典数据列表 + */ + public static List<SysDictData> getDictCache(String key) + { + JSONArray arrayCache = SpringUtils.getBean(RedisService.class).getCacheObject(getCacheKey(key)); + if (StringUtils.isNotNull(arrayCache)) + { + return arrayCache.toList(SysDictData.class); + } + return null; + } + + /** + * 删除指定字典缓存 + * + * @param key 字典键 + */ + public static void removeDictCache(String key) + { + SpringUtils.getBean(RedisService.class).deleteObject(getCacheKey(key)); + } + + /** + * 清空字典缓存 + */ + public static void clearDictCache() + { + Collection<String> keys = SpringUtils.getBean(RedisService.class).keys(CacheConstants.SYS_DICT_KEY + "*"); + SpringUtils.getBean(RedisService.class).deleteObject(keys); + } + + /** + * 设置cache key + * + * @param configKey 参数键 + * @return 缓存键key + */ + public static String getCacheKey(String configKey) + { + return CacheConstants.SYS_DICT_KEY + configKey; + } +} diff --git a/ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/task/AfterSalesTask.java b/ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/task/AfterSalesTask.java new file mode 100644 index 0000000..f6915f7 --- /dev/null +++ b/ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/task/AfterSalesTask.java @@ -0,0 +1,39 @@ +package com.ruoyi.job.task; + +import lombok.extern.log4j.Log4j2; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.util.Set; + +@Component("ryTask") +@Log4j2 +public class AfterSalesTask { + @Resource + private RedisTemplate<String, String> redisTemplate; + + /** + * 计算佣金(设置每分钟执行一次) + */ + public void afterSales() + { + long now = System.currentTimeMillis() / 1000; // 获取当前时间戳(秒) + // 从延迟队列中获取需要处理的订单 + Set<String> orderIds = redisTemplate.opsForZSet().rangeByScore("delay_queue:commission", 0, now); + if (orderIds != null && !orderIds.isEmpty()) { + // 处理完后移除已处理的订单 + redisTemplate.opsForZSet().removeRangeByScore("delay_queue:commission", 0, now); + } + } + + /** + * 佣金补偿(每天执行一次) + * redis未配置持久化,为防止数据丢失,每天执行一次,将到期未处理的订单重新放入延迟队列中 + */ + public void afterSalesCompensation() + { + // 获取未处理的订单 + + } +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java index 203f152..b03f0a2 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java @@ -15,6 +15,7 @@ import com.ruoyi.system.api.domain.SysRole; import com.ruoyi.system.api.domain.SysUser; import com.ruoyi.system.api.model.LoginUser; +import com.ruoyi.system.api.model.UserShop; import com.ruoyi.system.api.query.ChangeUserQuery; import com.ruoyi.system.domain.SysUserRole; import com.ruoyi.system.query.GetSysUserList; @@ -64,6 +65,9 @@ @Resource private ISysUserRoleService sysUserRoleService; + + @Resource + private UserShopService userShopService; @@ -528,4 +532,39 @@ public SysUser getSysUserById(@RequestParam("userId") Long userId){ return userService.getById(userId); } + + + /** + * 保存门店员工管理后台账号 + * @param user + * @return + */ + @ResponseBody + @PostMapping("/saveShopUser") + public R saveShopUser(@RequestBody SysUser user){ + Integer shopId = user.getObjectId(); + SysUser one = userService.getOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getPhonenumber, user.getPhonenumber()).eq(SysUser::getDelFlag, "0") + .eq(SysUser::getStatus, "0").eq(SysUser::getRoleType, 2).eq(SysUser::getAppUserId, user.getAppUserId())); + if(null == one){ + user.setObjectId(null); + user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); + userService.save(user); + //添加用户角色数据 + SysUserRole userRole = new SysUserRole(); + userRole.setUserId(user.getUserId()); + userRole.setRoleId(2L); + userRoleService.save(userRole); + }else{ + user = one; + } + //添加门店关系数据 + UserShop userShop = userShopService.getOne(new LambdaQueryWrapper<UserShop>().eq(UserShop::getShopId, shopId).eq(UserShop::getUserId, user.getAppUserId())); + if(null == userShop){ + userShop = new UserShop(); + userShop.setUserId(user.getUserId().intValue()); + userShop.setShopId(user.getObjectId()); + userShopService.save(userShop); + } + return R.ok(); + } } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/UserShopMapper.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/UserShopMapper.java new file mode 100644 index 0000000..cb3443e --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/UserShopMapper.java @@ -0,0 +1,11 @@ +package com.ruoyi.system.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.system.api.model.UserShop; + +/** + * @author zhibing.pu + * @Date 2024/12/2 9:38 + */ +public interface UserShopMapper extends BaseMapper<UserShop> { +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/UserShopService.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/UserShopService.java new file mode 100644 index 0000000..27b2dff --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/UserShopService.java @@ -0,0 +1,11 @@ +package com.ruoyi.system.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.system.api.model.UserShop; + +/** + * @author zhibing.pu + * @Date 2024/12/2 9:39 + */ +public interface UserShopService extends IService<UserShop> { +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictDataServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictDataServiceImpl.java index d30b433..2532cae 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictDataServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictDataServiceImpl.java @@ -4,9 +4,9 @@ import com.ruoyi.system.api.domain.SysDictData; import com.ruoyi.system.mapper.SysDictDataMapper; import com.ruoyi.system.service.ISysDictDataService; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import javax.annotation.Resource; import java.util.List; /** @@ -17,7 +17,7 @@ @Service public class SysDictDataServiceImpl implements ISysDictDataService { - @Autowired + @Resource private SysDictDataMapper dictDataMapper; /** diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UserShopServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UserShopServiceImpl.java new file mode 100644 index 0000000..95cc931 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UserShopServiceImpl.java @@ -0,0 +1,16 @@ +package com.ruoyi.system.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.system.api.model.UserShop; +import com.ruoyi.system.mapper.UserShopMapper; +import com.ruoyi.system.service.UserShopService; +import org.springframework.stereotype.Service; + +/** + * @author zhibing.pu + * @Date 2024/12/2 9:39 + */ + +@Service +public class UserShopServiceImpl extends ServiceImpl<UserShopMapper, UserShop> implements UserShopService { +} diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapping/system/UserShopMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapping/system/UserShopMapper.xml new file mode 100644 index 0000000..8e235db --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapping/system/UserShopMapper.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.ruoyi.system.mapper.UserShopMapper"> + +</mapper> \ No newline at end of file diff --git a/ruoyi-service/ruoyi-account/pom.xml b/ruoyi-service/ruoyi-account/pom.xml index 7e756da..7f5e8f8 100644 --- a/ruoyi-service/ruoyi-account/pom.xml +++ b/ruoyi-service/ruoyi-account/pom.xml @@ -121,6 +121,10 @@ <groupId>junit</groupId> <artifactId>junit</artifactId> </dependency> + <dependency> + <groupId>com.github.pagehelper</groupId> + <artifactId>pagehelper-spring-boot-starter</artifactId> + </dependency> </dependencies> <build> 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 4972e5f..fb71383 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 @@ -25,8 +25,8 @@ import com.ruoyi.account.api.model.AppUser; import com.ruoyi.account.service.AppUserService; import com.ruoyi.account.vo.*; +import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.web.controller.BaseController; -import com.ruoyi.common.core.web.domain.AjaxResult; import com.ruoyi.common.core.web.page.TableDataInfo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -48,7 +48,7 @@ @Api(tags = {"登录注册-小程序"}) @RestController @RequestMapping("/app-user") -public class AppUserController { +public class AppUserController extends BaseController { @@ -69,11 +69,18 @@ return appUserService.mobileLogin(mobileLogin); } + @PostMapping("getAppUserById") + AppUser getAppUserById(@RequestParam("id") Long id){ + return appUserService.getById(id); + } + + + @ResponseBody @PostMapping("/appletLogin") @ApiOperation(value = "小程序一键登录") - public AjaxResult<LoginVo> appletLogin(@RequestBody AppletLogin appletLogin){ + public R<LoginVo> appletLogin(@RequestBody AppletLogin appletLogin){ return appUserService.appletLogin(appletLogin); } @@ -89,6 +96,10 @@ public R<Void> editAppUserById(@RequestParam("appUser") AppUser appUser){ appUserService.updateById(appUser); return R.ok(); + @PostMapping("/mobileLogin") + @ApiOperation(value = "手机号登录") + public R<LoginVo> mobileLogin(@RequestBody MobileLogin mobileLogin){ + return appUserService.mobileLogin(mobileLogin); } @ResponseBody @@ -105,13 +116,13 @@ return R.ok(count); } - + @ResponseBody @PostMapping("/getSMSCode") @ApiOperation(value = "获取短信验证码") - public AjaxResult getSMSCode(@RequestBody SMSCode smsCode){ + public R getSMSCode(@RequestBody SMSCode smsCode){ return appUserService.getSMSCode(smsCode); } @@ -120,7 +131,7 @@ @ResponseBody @PostMapping("/registerAccount") @ApiOperation(value = "注册新账号") - public AjaxResult<LoginVo> registerAccount(@RequestBody RegisterAccount registerAccount){ + public R<LoginVo> registerAccount(@RequestBody RegisterAccount registerAccount){ return appUserService.registerAccount(registerAccount); } @@ -131,11 +142,11 @@ @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "推荐人id", required = true, dataType = "long") }) - public AjaxResult<String> getReferrer(@PathVariable("id") Long id){ + public R<String> getReferrer(@PathVariable("id") Long id){ AppUser appUser = appUserService.getById(id); String phone = appUser.getPhone(); phone = phone.substring(0, 3) + "****" + phone.substring(7); - return AjaxResult.success(appUser.getName() + "-" + phone); + return R.ok(appUser.getName() + "-" + phone); } @@ -219,6 +230,15 @@ } + /** + * 获取用户的祖籍列表 + */ + @GetMapping("/getUserAncestorList") + public R<List<AppUser>> getUserAncestorList(Long id){ + List<AppUser> list = appUserService.getUserAncestorList(id,null); + return R.ok(list); + } + } diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserShopController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserShopController.java new file mode 100644 index 0000000..320d19b --- /dev/null +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserShopController.java @@ -0,0 +1,31 @@ +package com.ruoyi.account.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.ruoyi.account.api.model.AppUserShop; +import com.ruoyi.account.service.AppUserShopService; +import com.ruoyi.common.core.domain.R; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.List; + + +/** + * @author zhibing.pu + * @Date 2024/12/2 9:21 + */ +@RestController +@RequestMapping("/appUserShop") +public class AppUserShopController { + @Resource + private AppUserShopService appUserShopService; + + @GetMapping("/shop/{userId}") + public R<List<AppUserShop>> getAppUserShop(@PathVariable("userId") Long userId) { + return R.ok(appUserShopService.list(new LambdaQueryWrapper<AppUserShop>() + .eq(AppUserShop::getAppUserId,userId))); + } + + + +} 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 new file mode 100644 index 0000000..eb01dad --- /dev/null +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/BalanceChangeRecordController.java @@ -0,0 +1,37 @@ +package com.ruoyi.account.controller; + +import com.ruoyi.account.api.model.BalanceChangeRecord; +import com.ruoyi.account.service.BalanceChangeRecordService; +import com.ruoyi.common.core.domain.R; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +/** + * @author zhibing.pu + * @Date 2024/12/2 15:36 + */ +@RestController +@RequestMapping("/balanceChangeRecord") +public class BalanceChangeRecordController { + + @Resource + private BalanceChangeRecordService balanceChangeRecordService; + + + /** + * 保存账户流水记录 + * @param balanceChangeRecord + * @return + */ + @PostMapping("/saveBalanceChangeRecord") + public R saveBalanceChangeRecord(@RequestBody BalanceChangeRecord balanceChangeRecord){ + balanceChangeRecordService.save(balanceChangeRecord); + return R.ok(); + } + + +} diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserAddressController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserAddressController.java index 6d0bdf9..73091a9 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserAddressController.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/UserAddressController.java @@ -1,6 +1,14 @@ package com.ruoyi.account.controller; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.ruoyi.account.api.model.UserAddress; +import com.ruoyi.account.service.UserAddressService; +import com.ruoyi.common.core.domain.R; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.List; import com.ruoyi.account.api.model.AppUser; import com.ruoyi.account.api.model.UserAddress; import com.ruoyi.account.service.UserAddressService; @@ -23,16 +31,39 @@ @RestController @RequestMapping("/user-address") public class UserAddressController { + + @Resource + private UserAddressService userAddressService; + + @Resource + private TokenService tokenService; + + + /** + * 获取用户默认地址 + * @param userId + * @return + */ + @ResponseBody + @PostMapping("/getDefaultUserAddress") + public R<UserAddress> getDefaultUserAddress(@RequestParam("userId") Long userId){ + List<UserAddress> list = userAddressService.list(new LambdaQueryWrapper<UserAddress>().eq(UserAddress::getAppUserId, userId).eq(UserAddress::getDelFlag, 0)); + if(list.size() == 0){ + return R.ok(); + } + UserAddress userAddress = list.stream().filter(s -> s.getIsDefault() == 1).findFirst().get(); + if(null == userAddress){ + userAddress = list.get(0); + } + return R.ok(userAddress); + } - @Resource - private TokenService tokenService; - @Resource - private UserAddressService userAddressService; + @ResponseBody @PostMapping("/add") @ApiOperation(value = "添加", tags = {"小程序-个人中心首页-我的地址"}) public R add(@RequestBody UserAddress userAddress){ - Long userId = tokenService.getLoginUserApplet().getUserId(); + Long userId = tokenService.getLoginUserApplet().getUserid(); userAddress.setAppUserId(userId); userAddressService.save(userAddress); return R.ok(); @@ -56,7 +87,7 @@ @PostMapping("/set") @ApiOperation(value = "设为默认", tags = {"小程序-个人中心首页-我的地址"}) public R set(@RequestParam Integer id){ - Long userId = tokenService.getLoginUserApplet().getUserId(); + Long userId = tokenService.getLoginUserApplet().getUserid(); List<UserAddress> list = userAddressService.lambdaQuery().eq(UserAddress::getAppUserId, userId).list(); for (UserAddress userAddress : list) { userAddress.setIsDefault(0); @@ -68,6 +99,18 @@ userAddressService.updateById(byId); return R.ok(); } - + + /** + * 根据id获取用户地址信息 + * @param id + * @return + */ + @ResponseBody + @PostMapping("/getUserAddressById") + public R<UserAddress> getUserAddressById(@RequestParam("id") Integer id){ + UserAddress userAddress = userAddressService.getById(id); + return R.ok(userAddress); + } + } 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 f0a9b72..dd50fd1 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 @@ -7,12 +7,21 @@ import com.ruoyi.account.api.model.UserCoupon; import com.ruoyi.account.api.model.UserPoint; import com.ruoyi.account.api.vo.CouponInfoVo; +import com.ruoyi.account.api.vo.PaymentUserCouponVo; import com.ruoyi.account.service.AppUserService; import com.ruoyi.account.service.UserCouponService; import com.ruoyi.account.service.UserPointService; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.utils.bean.BeanUtils; +import com.ruoyi.account.api.vo.CouponInfoVo; +import com.ruoyi.account.api.vo.PaymentUserCoupon; +import com.ruoyi.account.service.UserCouponService; +import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.web.domain.AjaxResult; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.List; import com.ruoyi.common.security.service.TokenService; import com.ruoyi.other.api.domain.Banner; import com.ruoyi.other.api.domain.CouponInfo; @@ -90,7 +99,7 @@ if (data==null){ return R.fail("当前优惠券不存在,请刷新后重试"); } - if (data.getSendType()!=1&&byId.getLavePoint().compareTo(data.getNeedPoint())==-1){ + if (data.getSendType()!=1&&byId.getLavePoint().compareTo(data.getNeedPoint().intValue())==-1){ return R.fail("当前积分不足,兑换失败"); } //检验发放时间 @@ -103,12 +112,12 @@ UserPoint userPoint = new UserPoint(); userPoint.setType(4); userPoint.setHistoricalPoint(byId.getLavePoint()); - userPoint.setVariablePoint(data.getNeedPoint()); + userPoint.setVariablePoint(data.getNeedPoint().intValue()); userPoint.setAppUserId(userid); userPoint.setObjectId(Long.valueOf(data.getId())); userPointService.save(userPoint); //扣除积分 - byId.setLavePoint(byId.getLavePoint().subtract(userPoint.getVariablePoint())); + byId.setLavePoint(byId.getLavePoint() - userPoint.getVariablePoint()); appUserService.updateById(byId); } //增加优惠券记录,根据时间类型设置开始结束时间 @@ -128,9 +137,34 @@ } - - - - + + + /** + * 获取支付页面用户优惠券列表数据 + * @param paymentUserCoupon + * @return + */ + @ResponseBody + @PostMapping("/getPaymentUserCoupon") + public R<List<PaymentUserCouponVo>> getPaymentUserCoupon(@RequestBody PaymentUserCoupon paymentUserCoupon){ + List<PaymentUserCouponVo> userCoupon = userCouponService.getUserCoupon(paymentUserCoupon.getUserId(), paymentUserCoupon.getType()); + return R.ok(userCoupon); + } + + + /** + * 根据用户优惠券id获取优惠券详情 + * @param userCouponId + * @return + */ + @ResponseBody + @PostMapping("/getCouponInfo") + public R<CouponInfoVo> getCouponInfo(@RequestParam("userCouponId") Long userCouponId){ + UserCoupon userCoupon = userCouponService.getById(userCouponId); + CouponInfo data = couponClient.detail(userCoupon.getCouponId()).getData(); + CouponInfoVo couponInfoVo = new CouponInfoVo(); + BeanUtils.copyProperties(data, couponInfoVo); + return R.ok(couponInfoVo); + } } 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 4152c2c..780c330 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 @@ -1,23 +1,23 @@ package com.ruoyi.account.controller; +import com.ruoyi.account.api.model.UserPoint; import com.ruoyi.account.service.UserPointService; import com.ruoyi.account.vo.UserPointDetailVO; import com.ruoyi.account.vo.UserPointVO; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.web.controller.BaseController; +import com.ruoyi.common.core.web.page.TableDataInfo; import com.ruoyi.common.security.utils.SecurityUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.math.BigDecimal; import java.time.LocalDateTime; +import java.util.List; /** * <p> @@ -29,7 +29,7 @@ */ @RestController @RequestMapping("/user-point") -@Api("用户积分") +@Api(tags = "个人积分") public class UserPointController extends BaseController { @Resource private UserPointService userPointService; @@ -49,11 +49,13 @@ */ @GetMapping("/getUserPointDetail") @ApiOperation("获取变更明细") - public R<UserPointDetailVO> getUserPointDetail(@ApiParam("指定日期") LocalDateTime date, - @ApiParam("变动类型(1=消费积分,2=返佣积分,3=拉新人积分,4=兑换商品 " + + public TableDataInfo getUserPointDetail(@ApiParam("指定日期") LocalDateTime date, + @ApiParam("变动类型(1=消费积分,2=返佣积分,3=拉新人积分,4=兑换商品 " + "5 = 门店业绩积分 6 =门店返佣积分7=技师业绩积分8 =转赠积分 9 =做工积分 " + "10 =注册积分)") Integer type){ - return R.ok(); + startPage(); + List<UserPointDetailVO> list = userPointService.getUserPointDetail(SecurityUtils.getUserId(), date, type); + return getDataTable(list); } /** @@ -64,5 +66,17 @@ public R<Void> transferPoint(@ApiParam("积分") BigDecimal point, @ApiParam("手机号") Long phone){ return R.ok(); } + + + /** + * 保存积分流水记录 + * @param userPoint + * @return + */ + @PostMapping("/saveUserPoint") + public R saveUserPoint(@RequestBody UserPoint userPoint){ + userPointService.save(userPoint); + return R.ok(); + } } 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 291de10..b71c1de 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 @@ -1,7 +1,10 @@ package com.ruoyi.account.controller; +import cn.hutool.core.collection.CollectionUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.ruoyi.account.api.model.AppUser; import com.ruoyi.account.api.model.BalanceChangeRecord; +import com.ruoyi.account.service.AppUserService; import com.ruoyi.account.service.BalanceChangeRecordService; import com.ruoyi.account.service.WalletService; import com.ruoyi.account.vo.WalletVO; @@ -9,17 +12,30 @@ import com.ruoyi.common.core.web.controller.BaseController; import com.ruoyi.common.security.service.TokenService; import com.ruoyi.common.security.utils.SecurityUtils; +import com.ruoyi.other.api.feignClient.OrderClient; import com.ruoyi.system.api.model.LoginUser; +import feignClient.RemoteOrderClient; +import feignClient.RemoteOrderGoodsClient; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import model.Order; +import model.OrderGood; +import org.springframework.format.annotation.DateTimeFormat; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; -@Api("钱包") +@Api(tags = "小程序-个人中心-我的钱包") @RestController @RequestMapping("wallet") public class WalletController extends BaseController { @@ -29,12 +45,16 @@ private TokenService tokenService; @Resource private WalletService walletService; + @Resource + private RemoteOrderGoodsClient remoteOrderGoodsClient; + @Resource + private AppUserService appUserService; /** * 钱包详情 */ @GetMapping("detail") - @ApiOperation(value = "钱包详情", notes = "钱包详情", tags = {"小程序-个人中心-我的钱包-钱包详情"}) + @ApiOperation(value = "钱包详情", notes = "钱包详情") public R<WalletVO> detail() { LoginUser loginUserApplet = tokenService.getLoginUserApplet(); WalletVO walletVO = walletService.getWalletByUserId(loginUserApplet.getUserid()); @@ -44,12 +64,42 @@ /** * 变更明细 */ - @ApiOperation(value = "变更明细", notes = "变更明细", tags = {"小程序-个人中心-我的钱包-变更记录"}) + @ApiOperation(value = "变更明细", notes = "变更明细") @GetMapping("change") - public R<List<BalanceChangeRecord>> change() { + public R<List<BalanceChangeRecord>> change(@ApiParam(value = "变更类型") + @RequestParam(required = false) Integer changeType, + @ApiParam(value = "创建时间") + @RequestParam(required = false) + @DateTimeFormat(pattern = "yyyy-MM") + LocalDate createTime) { Long userId = SecurityUtils.getUserId(); - return R.ok(balanceChangeRecordService.list(new LambdaQueryWrapper<BalanceChangeRecord>() - .eq(BalanceChangeRecord::getAppUserId, userId))); + + LocalDateTime localDateTime = null; + if (createTime != null) { + LocalTime specificTime = LocalTime.of(0, 0); + localDateTime = createTime.atTime(specificTime); + } + + List<BalanceChangeRecord> list = balanceChangeRecordService.list(new LambdaQueryWrapper<BalanceChangeRecord>() + .eq(changeType != null, BalanceChangeRecord::getChangeType, changeType) + .eq(createTime != null, BalanceChangeRecord::getCreateTime, localDateTime) + .eq(BalanceChangeRecord::getAppUserId, userId)); + + List<Long> orderIds = list.stream().map(BalanceChangeRecord::getOrderId).collect(Collectors.toList()); + R<List<Order>> r = remoteOrderGoodsClient.getOrderListByIds(orderIds); + if (!R.isSuccess(r)){ + return R.fail(r.getMsg()); + } + List<Order> orderList = r.getData(); + list.forEach(bc -> { + orderList.stream().filter(o -> o.getId().equals(bc.getOrderId())).findFirst().ifPresent(o -> { + Long appUserId = o.getAppUserId(); + AppUser appUser = appUserService.getById(appUserId); + bc.setUserName(appUser.getName()); + bc.setAmount(o.getPaymentAmount()); + }); + }); + return R.ok(list); } // /** diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/enums/PointChangeType.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/enums/PointChangeType.java new file mode 100644 index 0000000..7b2f61b --- /dev/null +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/enums/PointChangeType.java @@ -0,0 +1,34 @@ +package com.ruoyi.account.enums; + +import lombok.Getter; + +@Getter +public enum PointChangeType { + CONSUME(1, "消费积分"), + COMMISSION_RETURN(2, "返佣积分"), + NEW_USER_REFERRAL(3, "拉新人积分"), + EXCHANGE_GOODS(4, "兑换商品"), + STORE_PERFORMANCE(5, "门店业绩积分"), + STORE_COMMISSION_RETURN(6, "门店返佣积分"), + TECHNICIAN_PERFORMANCE(7, "技师业绩积分"), + TRANSFER_POINTS(8, "转赠积分"), + WORK_PERFORMANCE(9, "做工积分"), + REGISTRATION(10, "注册积分"); + + private final int code; + private final String description; + + PointChangeType(int code, String description) { + this.code = code; + this.description = description; + } + + public static PointChangeType fromCode(int code) { + for (PointChangeType type : values()) { + if (type.getCode() == code) { + return type; + } + } + throw new IllegalArgumentException("Invalid code: " + code); + } +} diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/WithdrawalAuditStatus.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/enums/WithdrawalAuditStatus.java similarity index 91% rename from ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/WithdrawalAuditStatus.java rename to ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/enums/WithdrawalAuditStatus.java index 3daa060..4788fd6 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/WithdrawalAuditStatus.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/enums/WithdrawalAuditStatus.java @@ -1,4 +1,4 @@ -package com.ruoyi.account; +package com.ruoyi.account.enums; import lombok.Getter; diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/AppUserShopMapper.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/AppUserShopMapper.java new file mode 100644 index 0000000..814b968 --- /dev/null +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/mapper/AppUserShopMapper.java @@ -0,0 +1,11 @@ +package com.ruoyi.account.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.account.api.model.AppUserShop; + +/** + * @author zhibing.pu + * @Date 2024/12/2 9:20 + */ +public interface AppUserShopMapper extends BaseMapper<AppUserShop> { +} diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/AppUserService.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/AppUserService.java index b8c6555..a313542 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/AppUserService.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/AppUserService.java @@ -3,6 +3,7 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.account.api.model.AppUser; import com.ruoyi.account.vo.*; +import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.web.domain.AjaxResult; import java.util.List; @@ -23,7 +24,7 @@ * @param appletLogin * @return */ - AjaxResult appletLogin(AppletLogin appletLogin); + R appletLogin(AppletLogin appletLogin); /** @@ -31,7 +32,7 @@ * @param mobileLogin * @return */ - AjaxResult<LoginVo> mobileLogin(MobileLogin mobileLogin); + R<LoginVo> mobileLogin(MobileLogin mobileLogin); /** @@ -39,7 +40,7 @@ * @param smsCode * @return */ - AjaxResult getSMSCode(SMSCode smsCode); + R getSMSCode(SMSCode smsCode); /** @@ -47,7 +48,7 @@ * @param registerAccount * @return */ - AjaxResult<LoginVo> registerAccount(RegisterAccount registerAccount); + R<LoginVo> registerAccount(RegisterAccount registerAccount); /** @@ -56,4 +57,9 @@ * @return */ List<NearbyReferrerVo> getNearbyReferrer(NearbyReferrer nearbyReferrer); + + /** + * 获取用户的祖籍列表 + */ + List<AppUser> getUserAncestorList(Long id,List<AppUser> list); } diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/AppUserShopService.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/AppUserShopService.java new file mode 100644 index 0000000..30c1247 --- /dev/null +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/AppUserShopService.java @@ -0,0 +1,11 @@ +package com.ruoyi.account.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.account.api.model.AppUserShop; + +/** + * @author zhibing.pu + * @Date 2024/12/2 9:20 + */ +public interface AppUserShopService extends IService<AppUserShop> { +} diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/TAppUserService.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/TAppUserService.java deleted file mode 100644 index 2482d4a..0000000 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/TAppUserService.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.ruoyi.account.service; - -import com.baomidou.mybatisplus.extension.service.IService; - -import java.util.Map; - -/** - * <p> - * 服务类 - * </p> - * - * @author luodangjia - * @since 2024-08-06 - */ -public interface TAppUserService extends IService<TAppUser> { - - /** - * 微信小程序登录用户封装 - * @param appletUserDecodeData - * @return - */ - Map<String, Object> wxLogin(AppletUserDecodeData appletUserDecodeData,Long inviteUserId); - - /** - * 支付宝小程序登录用户封装 - * @param response - * @return - */ -// Map<String, Object> aliLogin(AlipaySystemOauthTokenResponse response, AlipayUserInfoShareResponse userInfo); - Map<String, Object> aliLogin(AlipaySystemOauthTokenResponse response,String phone,Long inviteUserId); - - /** - * 封装用户信息和token - * @param appUser - * @return - */ - Map<String, Object> getUserInfo(TAppUser appUser); - - /** - * 账号判断 - * @param status - */ - public void throwInfo(Integer status); -} diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/UserCouponService.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/UserCouponService.java index 988f9ed..9edcda4 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/UserCouponService.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/UserCouponService.java @@ -2,6 +2,12 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.account.api.model.UserCoupon; +import com.ruoyi.account.api.vo.CouponInfoVo; +import com.ruoyi.account.api.vo.PaymentUserCouponVo; +import org.springframework.web.bind.annotation.RequestParam; + +import java.math.BigDecimal; +import java.util.List; /** * <p> @@ -12,5 +18,11 @@ * @since 2024-11-21 */ public interface UserCouponService extends IService<UserCoupon> { - + + /** + * 获取用户支付页面的优惠券列表 + * @param userId + * @return + */ + List<PaymentUserCouponVo> getUserCoupon(Long userId, Integer type); } diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/UserPointService.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/UserPointService.java index 1e104a9..4092f6f 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/UserPointService.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/UserPointService.java @@ -2,7 +2,11 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.account.api.model.UserPoint; +import com.ruoyi.account.vo.UserPointDetailVO; import com.ruoyi.account.vo.UserPointVO; + +import java.time.LocalDateTime; +import java.util.List; /** * <p> @@ -15,4 +19,7 @@ public interface UserPointService extends IService<UserPoint> { UserPointVO getUserPoint(Long userId); + + + List<UserPointDetailVO> getUserPointDetail(Long userId, LocalDateTime date, Integer type); } 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 e85907f..da54600 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 @@ -2,23 +2,29 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.account.api.model.AppUserShop; import com.ruoyi.account.mapper.AppUserMapper; import com.ruoyi.account.api.model.AppUser; import com.ruoyi.account.service.AppUserService; +import com.ruoyi.account.service.AppUserShopService; import com.ruoyi.account.util.weChat.WeChatUtil; import com.ruoyi.account.vo.*; +import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.web.domain.AjaxResult; import com.ruoyi.common.redis.service.RedisService; import com.ruoyi.common.security.service.TokenService; +import com.ruoyi.other.api.domain.Shop; +import com.ruoyi.other.api.feignClient.ShopClient; +import com.ruoyi.system.api.domain.SysUser; +import com.ruoyi.system.api.feignClient.SysUserClient; import com.ruoyi.system.api.model.LoginUser; +import org.checkerframework.checker.units.qual.A; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.math.BigDecimal; import java.time.LocalDateTime; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * <p> @@ -40,6 +46,20 @@ @Resource private RedisService redisService; + @Resource + private ShopClient shopClient; + + @Resource + private AppUserShopService appUserShopService; + + @Resource + private SysUserClient sysUserClient; + + + + + + /** * 小程序一键登录 @@ -47,12 +67,12 @@ * @return */ @Override - public AjaxResult appletLogin(AppletLogin appletLogin) { + public R appletLogin(AppletLogin appletLogin) { //使用jscode获取微信openid Map<String, Object> map = weChatUtil.code2Session(appletLogin.getJscode()); Integer errcode = Integer.valueOf(map.get("errcode").toString()); if(0 != errcode){ - return AjaxResult.error(map.get("msg").toString()); + return R.fail(map.get("msg").toString()); } String openid = map.get("openid").toString(); //查询用户是否注册,没有注册则跳转到注册页面 @@ -60,11 +80,11 @@ if(null == appUser){ LoginVo loginVo = new LoginVo(); loginVo.setSkipPage(2); - return AjaxResult.success(loginVo); + return R.ok(loginVo); } //账户被冻结,给出提示 if(2 == appUser.getStatus()){ - return AjaxResult.error("账户已被冻结,请联系管理员!"); + return R.fail("账户已被冻结,请联系管理员!"); } LoginVo loginVo = new LoginVo(); loginVo.setSkipPage(1); @@ -77,7 +97,7 @@ Map<String, Object> tokenApplet = tokenService.createTokenApplet(loginUser); loginVo.setToken(tokenApplet.get("access_token").toString()); loginVo.setFailureTime(Long.valueOf(tokenApplet.get("expires_in").toString())); - return AjaxResult.success(loginVo); + return R.ok(loginVo); } @@ -87,23 +107,23 @@ * @return */ @Override - public AjaxResult<LoginVo> mobileLogin(MobileLogin mobileLogin) { - //校验验证码 - String code = redisService.getCacheObject(mobileLogin.getPhone()); - if(null == code || !code.equals(mobileLogin.getCode())){ - return AjaxResult.error("验证码错误"); - } + public R<LoginVo> mobileLogin(MobileLogin mobileLogin) { + //校验验证码 TODO 待完善 +// String code = redisService.getCacheObject(mobileLogin.getPhone()); +// if(null == code || !code.equals(mobileLogin.getCode())){ +// return R.fail("验证码错误"); +// } //查询用户是否注册,没有注册则跳转到注册页面 AppUser appUser = this.getOne(new LambdaQueryWrapper<AppUser>().eq(AppUser::getPhone, mobileLogin.getPhone()).ne(AppUser::getStatus, 3).eq(AppUser::getDelFlag, 0)); if(null == appUser){ LoginVo loginVo = new LoginVo(); loginVo.setSkipPage(2); - return AjaxResult.success(loginVo); + return R.ok(loginVo); } //账户被冻结,给出提示 if(2 == appUser.getStatus()){ - return AjaxResult.error("账户已被冻结,请联系管理员!"); + return R.fail("账户已被冻结,请联系管理员!"); } LoginVo loginVo = new LoginVo(); loginVo.setSkipPage(1); @@ -116,7 +136,7 @@ Map<String, Object> tokenApplet = tokenService.createTokenApplet(loginUser); loginVo.setToken(tokenApplet.get("access_token").toString()); loginVo.setFailureTime(Long.valueOf(tokenApplet.get("expires_in").toString())); - return AjaxResult.success(loginVo); + return R.ok(loginVo); } @@ -126,7 +146,7 @@ * @return */ @Override - public AjaxResult getSMSCode(SMSCode smsCode) { + public R getSMSCode(SMSCode smsCode) { //校验验证码获取评率(1分钟5次) String key = smsCode.getType() + "&" + smsCode.getPhone(); Map<String, Object> cacheMap = redisService.getCacheMap(key); @@ -134,7 +154,7 @@ Integer number = Integer.valueOf(cacheMap.get("number").toString()) + 1; Long startTime = Long.valueOf(cacheMap.get("startTime").toString()); if(number > 5 && (System.currentTimeMillis() - startTime) < 60000){ - return AjaxResult.error("获取验证码太频繁,请稍后重试!"); + return R.fail("获取验证码太频繁,请稍后重试!"); } if(number <= 5){ cacheMap.put("number", number); @@ -156,7 +176,7 @@ code += Double.valueOf(Math.random() * 10).intValue(); } //发送短信 todo 待对接短信 - return AjaxResult.success(); + return R.ok(); } @@ -166,33 +186,35 @@ * @return */ @Override - public AjaxResult<LoginVo> registerAccount(RegisterAccount registerAccount) { + public R<LoginVo> registerAccount(RegisterAccount registerAccount) { + // TODO 待完善 //校验验证码 - String code = redisService.getCacheObject(registerAccount.getPhone()); - if(null == code || !code.equals(registerAccount.getCode())){ - return AjaxResult.error("验证码错误"); - } +// String code = redisService.getCacheObject(registerAccount.getPhone()); +// if(null == code || !code.equals(registerAccount.getCode())){ +// return R.fail("验证码错误"); +// } //使用jscode获取微信openid - Map<String, Object> map = weChatUtil.code2Session(registerAccount.getJscode()); - Integer errcode = Integer.valueOf(map.get("errcode").toString()); - if(0 != errcode){ - return AjaxResult.error(map.get("msg").toString()); - } - String openid = map.get("openid").toString(); - //查询用户是否注册 - AppUser appUser = this.getOne(new LambdaQueryWrapper<AppUser>().eq(AppUser::getWxOpenid, openid).ne(AppUser::getStatus, 3).eq(AppUser::getDelFlag, 0)); - if(null != appUser){ - return AjaxResult.error("此微信号已注册,请直接登录!"); - } +// Map<String, Object> map = weChatUtil.code2Session(registerAccount.getJscode()); +// Integer errcode = Integer.valueOf(map.get("errcode").toString()); +// if(0 != errcode){ +// return R.fail(map.get("msg").toString()); +// } +// String openid = map.get("openid").toString(); +// //查询用户是否注册 +// AppUser appUser = this.getOne(new LambdaQueryWrapper<AppUser>().eq(AppUser::getWxOpenid, openid).ne(AppUser::getStatus, 3).eq(AppUser::getDelFlag, 0)); +// if(null != appUser){ +// return R.fail("此微信号已注册,请直接登录!"); +// } + AppUser appUser = null; AppUser appUser1 = this.getOne(new LambdaQueryWrapper<AppUser>().eq(AppUser::getPhone, registerAccount.getPhone()).ne(AppUser::getStatus, 3).eq(AppUser::getDelFlag, 0)); if(null != appUser1){ - return AjaxResult.error("手机号已注册,请直接登录!"); + return R.fail("手机号已注册,请直接登录!"); } if(null == appUser){ appUser = new AppUser(); appUser.setName(registerAccount.getName()); appUser.setPhone(registerAccount.getPhone()); - appUser.setWxOpenid(openid); +// appUser.setWxOpenid(openid); //注册默认为普通会员 appUser.setVipId(1); appUser.setStatus(1); @@ -207,22 +229,23 @@ AppUser appUser2 = this.getById(registerAccount.getPromoter()); appUser.setInviteUserId(registerAccount.getPromoter()); appUser.setShopId(appUser2.getShopId()); - appUser.setPartPoint(BigDecimal.ZERO); - appUser.setPartGrowPoint(BigDecimal.ZERO); - appUser.setShopPoint(BigDecimal.ZERO); - appUser.setSharePoint(BigDecimal.ZERO); + appUser.setPartPoint(0); + appUser.setPartGrowPoint(0); + appUser.setShopPoint(0); + appUser.setSharePoint(0); appUser.setShopAmount(BigDecimal.ZERO); appUser.setWithdrawableAmount(BigDecimal.ZERO); appUser.setWithdrawnAmount(BigDecimal.ZERO); appUser.setTotalRechargeAmount(BigDecimal.ZERO); appUser.setTotalRedPacketAmount(BigDecimal.ZERO); appUser.setTotalDistributionAmount(BigDecimal.ZERO); - appUser.setLavePoint(BigDecimal.ZERO); + appUser.setBalance(BigDecimal.ZERO); + appUser.setLavePoint(0); //根据平台的配置未达标,则标注为可修改推广人 appUser.setChangePromoter(0); appUser.setLongitude(registerAccount.getLongitude()); appUser.setLatitude(registerAccount.getLatitude()); - //调用地图获取省市区数据 + //调用地图获取省市区数据 TODO 待完善 // appUser.setProvince(); // appUser.setProvinceCode(); // appUser.setCity(); @@ -230,6 +253,33 @@ // appUser.setDistrict(); // appUser.setDistrictCode(); this.save(appUser); + + //查询当前注册的手机号是都和门店管理员手机号相同 + Shop shop = shopClient.getShopByPhone(registerAccount.getPhone()).getData(); + if(null != shop){ + //添加门店用户关系数据 + AppUserShop appUserShop = appUserShopService.getOne(new LambdaQueryWrapper<AppUserShop>().eq(AppUserShop::getAppUserId, appUser.getId()).eq(AppUserShop::getShopId, shop.getId())); + if(null == appUserShop){ + appUserShop = new AppUserShop(); + appUserShop.setShopId(shop.getId()); + appUserShop.setAppUserId(appUser.getId()); + appUserShopService.save(appUserShop); + //添加管理后台账号 + SysUser user = new SysUser(); + user.setDeptId(1L); + user.setUserName(appUser.getName()); + user.setNickName(appUser.getName()); + user.setPhonenumber(appUser.getPhone()); + user.setAvatar(appUser.getAvatar()); + user.setStatus("0"); + user.setDelFlag("0"); + user.setRoleType(2); + user.setObjectId(shop.getId()); + user.setAppUserId(appUser.getId()); + sysUserClient.saveShopUser(user); + } + } + } LoginVo loginVo = new LoginVo(); loginVo.setSkipPage(1); @@ -242,7 +292,7 @@ Map<String, Object> tokenApplet = tokenService.createTokenApplet(loginUser); loginVo.setToken(tokenApplet.get("access_token").toString()); loginVo.setFailureTime(Long.valueOf(tokenApplet.get("expires_in").toString())); - return AjaxResult.success(loginVo); + return R.ok(loginVo); } @@ -257,11 +307,11 @@ } public AppUser getTopAppUser(List<AppUser> list, Long id){ - AppUser appUser = list.stream().filter(s -> s.getInviteUserId().equals(id)).findFirst().get(); + AppUser appUser = list.stream().filter(s -> s.getId().equals(id)).findFirst().get(); if(null == appUser.getInviteUserId()){ return appUser; } - return getTopAppUser(list, appUser.getId()); + return getTopAppUser(list, appUser.getInviteUserId()); } @@ -275,8 +325,42 @@ //使用地图获取省市区数据 String longitude = nearbyReferrer.getLongitude(); String latitude = nearbyReferrer.getLatitude(); - String cityCode = ""; + String cityCode = ""; // TODO 待完善 List<NearbyReferrerVo> list = this.baseMapper.getNearbyReferrer(cityCode, nearbyReferrer); return list; } + + @Override + public List<AppUser> getUserAncestorList(Long id, List<AppUser> list) { + if (list == null) { + list = new ArrayList<>(); + } + + Set<Long> visitedIds = new HashSet<>(); + Long currentId = id; + + while (currentId != null && !visitedIds.contains(currentId)) { + AppUser appUser = getById(currentId); + if (appUser == null) { + break; // 如果用户不存在,终止循环 + } + + Long inviteUserId = appUser.getInviteUserId(); + if (inviteUserId != null) { + AppUser invitedUser = getById(inviteUserId); + if (invitedUser != null) { + list.add(invitedUser); + visitedIds.add(currentId); + currentId = inviteUserId; + } else { + break; // 如果邀请用户不存在,终止循环 + } + } else { + break; // 如果没有邀请用户,终止循环 + } + } + + return list; + } + } diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AppUserShopServiceImpl.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AppUserShopServiceImpl.java new file mode 100644 index 0000000..625f5cb --- /dev/null +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AppUserShopServiceImpl.java @@ -0,0 +1,15 @@ +package com.ruoyi.account.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.account.api.model.AppUserShop; +import com.ruoyi.account.mapper.AppUserShopMapper; +import com.ruoyi.account.service.AppUserShopService; +import org.springframework.stereotype.Service; + +/** + * @author zhibing.pu + * @Date 2024/12/2 9:21 + */ +@Service +public class AppUserShopServiceImpl extends ServiceImpl<AppUserShopMapper, AppUserShop> implements AppUserShopService { +} diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserCouponServiceImpl.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserCouponServiceImpl.java index 607932c..b1c2894 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserCouponServiceImpl.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserCouponServiceImpl.java @@ -1,10 +1,24 @@ package com.ruoyi.account.service.impl; +import com.alibaba.fastjson2.JSON; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.account.api.vo.CouponInfoVo; +import com.ruoyi.account.api.vo.PaymentUserCouponVo; import com.ruoyi.account.mapper.UserCouponMapper; import com.ruoyi.account.api.model.UserCoupon; import com.ruoyi.account.service.UserCouponService; +import com.ruoyi.other.api.domain.CouponInfo; +import com.ruoyi.other.api.feignClient.CouponInfoClient; import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.time.Instant; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; /** * <p> @@ -16,5 +30,56 @@ */ @Service public class UserCouponServiceImpl extends ServiceImpl<UserCouponMapper, UserCoupon> implements UserCouponService { - + + @Resource + private CouponInfoClient couponInfoClient; + + + + /** + * 获取支付页面的优惠券列表数据 + * @param userId + * @param orderMoney + * @return + */ + @Override + public List<PaymentUserCouponVo> getUserCoupon(Long userId, Integer type) { + List<UserCoupon> list = this.list(new LambdaQueryWrapper<UserCoupon>().eq(UserCoupon::getAppUserId, userId).eq(UserCoupon::getDelFlag, 0) + .last(" and now() between start_time and end_time")); + List<Integer> couponIds = list.stream().map(UserCoupon::getCouponId).collect(Collectors.toList()); + if(couponIds.size() == 0){ + return null; + } + List<CouponInfo> couponInfoList = couponInfoClient.getCouponInfoList(couponIds).getData(); + //构建返回数据 + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + List<PaymentUserCouponVo> infoVoList = new ArrayList<>(); + for (UserCoupon userCoupon : list) { + CouponInfo couponInfo = couponInfoList.stream().filter(s -> s.getId().equals(userCoupon.getCouponId())).findFirst().get(); + //排除商品券(商品券线下领取) + if(4 == couponInfo.getCouponType()){ + continue; + } + PaymentUserCouponVo couponInfoVo = new PaymentUserCouponVo(); + couponInfoVo.setId(userCoupon.getId()); + couponInfoVo.setName(couponInfo.getCouponName()); + couponInfoVo.setCouponType(couponInfo.getCouponType()); + couponInfoVo.setConditionAmount(couponInfo.getConditionAmount()); + couponInfoVo.setDiscountAmount(couponInfo.getDiscountAmount()); + couponInfoVo.setMoneyAmount(couponInfo.getMoneyAmount()); + couponInfoVo.setDiscount(couponInfo.getDiscount()); + couponInfoVo.setPeriodEndTime(couponInfo.getPeriodStartTime().format(formatter)); + couponInfoVo.setPeriodEndTime(couponInfo.getPeriodEndTime().format(formatter)); + String forGoodIds = couponInfo.getForGoodIds(); + Integer instant = JSON.parseArray(forGoodIds).getInteger(0); + if(-1 == instant){ + couponInfoVo.setForGoodIds(null); + }else{ + couponInfoVo.setForGoodIds(JSON.parseArray(forGoodIds, Integer.class)); + } + couponInfoVo.setAvailable(false); + infoVoList.add(couponInfoVo); + } + return infoVoList; + } } 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 f010f2e..1cedad4 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 @@ -1,15 +1,29 @@ package com.ruoyi.account.service.impl; +import cn.hutool.core.collection.CollectionUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.ruoyi.account.mapper.UserPointMapper; +import com.ruoyi.account.api.feignClient.AppUserClient; +import com.ruoyi.account.api.model.AppUser; import com.ruoyi.account.api.model.UserPoint; +import com.ruoyi.account.enums.PointChangeType; +import com.ruoyi.account.mapper.UserPointMapper; import com.ruoyi.account.service.UserPointService; +import com.ruoyi.account.vo.UserPointDetailVO; import com.ruoyi.account.vo.UserPointVO; import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + /** * <p> - * 服务实现类 + * 服务实现类 * </p> * * @author luodangjia @@ -17,10 +31,42 @@ */ @Service public class UserPointServiceImpl extends ServiceImpl<UserPointMapper, UserPoint> implements UserPointService { + @Resource + private AppUserClient appUserClient; @Override public UserPointVO getUserPoint(Long userId) { - // TODO 待实现 - return null; + AppUser appUser = appUserClient.getAppUserById(userId); + List<UserPoint> userPointList = list(new LambdaQueryWrapper<UserPoint>() + .eq(UserPoint::getAppUserId, userId)); + + Map<Integer, Integer> userBalanceMap = userPointList.stream() + .collect(Collectors.toMap(UserPoint::getType, UserPoint::getBalance)); + + Integer lavePoint = appUser.getLavePoint(); + UserPointVO userPointVO = new UserPointVO(); + userPointVO.setTotalPoint(lavePoint); + userPointVO.setShopPoint(userBalanceMap.get(PointChangeType.CONSUME.getCode())); + userPointVO.setSharePoint(userBalanceMap.get(PointChangeType.COMMISSION_RETURN.getCode())); + userPointVO.setPullNewPoint(userBalanceMap.get(PointChangeType.NEW_USER_REFERRAL.getCode())); + userPointVO.setShopAchievementPoint(userBalanceMap.get(PointChangeType.STORE_PERFORMANCE.getCode())); + userPointVO.setShopSharePoint(userBalanceMap.get(PointChangeType.STORE_COMMISSION_RETURN.getCode())); + return userPointVO; + } + + @Override + public List<UserPointDetailVO> getUserPointDetail(Long userId, LocalDateTime date, Integer type) { + List<UserPoint> userPointList = list(new LambdaQueryWrapper<UserPoint>() + .eq(UserPoint::getAppUserId, userId)); + if (CollectionUtil.isNotEmpty(userPointList)) { + return userPointList.stream().map(p -> { + UserPointDetailVO userPointDetailVO = new UserPointDetailVO(); + userPointDetailVO.setType(p.getType()); + userPointDetailVO.setVariablePoint(p.getVariablePoint()); + userPointDetailVO.setCreateTime(p.getCreateTime()); + return userPointDetailVO; + }).collect(Collectors.toList()); + } + return Collections.emptyList(); } } diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/WalletServiceImpl.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/WalletServiceImpl.java index ba74390..0d4f040 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/WalletServiceImpl.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/WalletServiceImpl.java @@ -1,7 +1,7 @@ package com.ruoyi.account.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.ruoyi.account.WithdrawalAuditStatus; +import com.ruoyi.account.enums.WithdrawalAuditStatus; import com.ruoyi.account.api.model.AppUser; import com.ruoyi.account.api.model.WithdrawalRequests; import com.ruoyi.account.service.AppUserService; @@ -34,9 +34,6 @@ } Integer vipId = appUser.getVipId(); R<VipSetting> r = remoteVipSettingClient.getVipSettingById(vipId); - if (r == null || r.getCode() != R.SUCCESS) { - throw new RuntimeException("获取会员设置信息失败"); - } VipSetting data = r.getData(); if (data == null) { throw new RuntimeException("会员设置信息为空"); diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/LoginVo.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/LoginVo.java index b69d2be..1e239de 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/LoginVo.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/LoginVo.java @@ -9,7 +9,7 @@ * @Date 2024/11/25 9:39 */ @Data -@ApiModel +@ApiModel("登录结果") public class LoginVo { @ApiModelProperty("token") private String token; diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/NearbyReferrerVo.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/NearbyReferrerVo.java index 7377ddb..e598dfa 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/NearbyReferrerVo.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/NearbyReferrerVo.java @@ -11,7 +11,7 @@ * @Date 2024/11/25 10:42 */ @Data -@ApiModel +@ApiModel("附近推荐人") public class NearbyReferrerVo { @ApiModelProperty("id") private String id; @@ -21,6 +21,6 @@ private String name; @ApiModelProperty("会员类型名称") private String vip; - @ApiModelProperty("距离(km)") + @ApiModelProperty("距离(m)") private BigDecimal distance; } diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/UserPointDetailVO.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/UserPointDetailVO.java index 92dc03c..bab1ff6 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/UserPointDetailVO.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/UserPointDetailVO.java @@ -16,7 +16,7 @@ private Integer type; @ApiModelProperty(value = "变动金额") - private BigDecimal variablePoint; + private Integer variablePoint; @ApiModelProperty(value = "变动时间") private LocalDateTime createTime; diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/UserPointVO.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/UserPointVO.java index d81b7c9..01f5b32 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/UserPointVO.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/UserPointVO.java @@ -1,11 +1,8 @@ package com.ruoyi.account.vo; -import com.baomidou.mybatisplus.annotation.TableField; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; - -import java.math.BigDecimal; @Data @ApiModel(value="UserPoint对象", description="") @@ -15,17 +12,17 @@ private Integer totalPoint; @ApiModelProperty(value = "消费积分数") - private BigDecimal shopPoint; + private Integer shopPoint; @ApiModelProperty(value = "返佣积分数") - private BigDecimal sharePoint; + private Integer sharePoint; @ApiModelProperty(value = "拉新积分") - private BigDecimal pullNewPoint; + private Integer pullNewPoint; @ApiModelProperty(value = "门店业绩积分") - private BigDecimal shopAchievementPoint; + private Integer shopAchievementPoint; @ApiModelProperty(value = "门店返佣积分") - private BigDecimal shopSharePoint; + private Integer shopSharePoint; } diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/WalletVO.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/WalletVO.java index d93c21f..4e0bd10 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/WalletVO.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/vo/WalletVO.java @@ -10,6 +10,9 @@ @ApiModel(value="钱包对象", description="") public class WalletVO { + @ApiModelProperty(value = "账户余额") + private BigDecimal balance; + @ApiModelProperty(value = "可提现金额") private BigDecimal withdrawalAmount; diff --git a/ruoyi-service/ruoyi-account/src/main/resources/mapper/account/UserShopMapper.xml b/ruoyi-service/ruoyi-account/src/main/resources/mapper/account/UserShopMapper.xml new file mode 100644 index 0000000..13d3fa4 --- /dev/null +++ b/ruoyi-service/ruoyi-account/src/main/resources/mapper/account/UserShopMapper.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.ruoyi.account.mapper.AppUserShopMapper"> + + +</mapper> \ No newline at end of file diff --git a/ruoyi-service/ruoyi-order/pom.xml b/ruoyi-service/ruoyi-order/pom.xml index 05fd8b5..788f0f9 100644 --- a/ruoyi-service/ruoyi-order/pom.xml +++ b/ruoyi-service/ruoyi-order/pom.xml @@ -124,7 +124,7 @@ <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> - <version>3.5.2</version> + <version>3.5.4</version> </dependency> <dependency> @@ -145,6 +145,11 @@ </exclusions> </dependency> + + <dependency> + <groupId>com.github.pagehelper</groupId> + <artifactId>pagehelper-spring-boot-starter</artifactId> + </dependency> </dependencies> <build> 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 7a8f0ab..1bdb648 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 @@ -1,20 +1,19 @@ package com.ruoyi.order.controller; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.security.service.TokenService; import com.ruoyi.order.service.OrderService; -import com.ruoyi.order.vo.OrderDetailVO; +import org.springframework.web.bind.annotation.*; +import vo.OrderDetailVO; import com.ruoyi.order.vo.OrderVO; import com.ruoyi.system.api.model.LoginUser; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import model.Order; import javax.annotation.Resource; import java.util.List; @@ -51,6 +50,14 @@ } /** + * 通过订单ids获取订单列表 + */ + @PostMapping("/getOrderListByIds") + public R<List<Order>> getOrderListByIds(@RequestBody List<Long> ids){ + return R.ok(orderService.listByIds(ids)); + } + + /** * 订单详情 */ @ApiOperation(value = "订单详情", tags = {"小程序-订单详情"}) @@ -70,8 +77,11 @@ @ApiImplicitParam(value = "分享id", name = "shareId", required = true, dataType = "int", paramType="query"), }) @GetMapping("/check/{orderNumber}/{shopId}") - public R<Boolean> check(@PathVariable("orderNumber") String orderNumber, @PathVariable("shopId") Long shopId){ - return R.ok(orderService.check(orderNumber, shopId)); + public R<Boolean> check(@PathVariable("orderNumber") String orderNumber, @PathVariable("shopId") Integer shopId){ + LoginUser loginUserApplet = tokenService.getLoginUserApplet(); + Order order = orderService.getOne(new LambdaQueryWrapper<Order>() + .eq(Order::getOrderNumber, orderNumber)); + return R.ok(orderService.check(order, shopId, loginUserApplet.getUserid())); } /** diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/ShoppingCartController.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/ShoppingCartController.java index aeaa5dc..8b28d1f 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/ShoppingCartController.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/ShoppingCartController.java @@ -4,6 +4,7 @@ import com.ruoyi.common.core.web.controller.BaseController; import com.ruoyi.common.core.web.domain.AjaxResult; import com.ruoyi.common.core.web.page.TableDataInfo; +import com.ruoyi.common.security.service.TokenService; import com.ruoyi.order.service.ShoppingCartService; import com.ruoyi.order.vo.*; import io.swagger.annotations.Api; @@ -22,6 +23,12 @@ @Resource private ShoppingCartService shoppingCartService; + + @Resource + private TokenService tokenService; + + + @ResponseBody @@ -47,27 +54,43 @@ @ResponseBody @PostMapping("/setGoodsNumber") @ApiOperation(value = "修改购物车数量", tags = {"商城-购物车-小程序"}) - public AjaxResult setGoodsNumber(@RequestBody SetGoodsNumber setGoodsNumber){ + public R setGoodsNumber(@RequestBody SetGoodsNumber setGoodsNumber){ return shoppingCartService.setGoodsNumber(setGoodsNumber); } @ResponseBody + @DeleteMapping("/delShoppingCart") + @ApiOperation(value = "删除购物车", tags = {"商城-购物车-小程序"}) + public R delShoppingCart(Long id){ + Long userid = tokenService.getLoginUserApplet().getUserid(); + ShoppingCart shoppingCart = shoppingCartService.getById(id); + if(!userid.equals(shoppingCart.getAppUserId())){ + return R.fail("权限不足,不允许此操作"); + } + shoppingCartService.removeById(id); + return R.ok(); + } + + + + + + @ResponseBody @PostMapping("/confirmOrder") @ApiOperation(value = "确定购物车订单", tags = {"商城-购物车-小程序"}) - public AjaxResult<ConfirmOrderVo> confirmOrder(@RequestBody ConfirmOrder confirmOrder){ - // todo 待完善 pu - return AjaxResult.success(); + public R<ConfirmOrderVo> confirmOrder(@RequestBody ConfirmOrder confirmOrder){ + ConfirmOrderVo confirmOrderVo = shoppingCartService.confirmOrder(confirmOrder); + return R.ok(confirmOrderVo); } @ResponseBody @PostMapping("/shoppingCartPayment") @ApiOperation(value = "购物车订单支付", tags = {"商城-购物车-小程序"}) - public AjaxResult<Void> shoppingCartPayment(@RequestBody ShoppingCartPayment shoppingCartPayment){ - // todo 待完善 pu - return AjaxResult.success(); + public R<Void> shoppingCartPayment(@RequestBody ShoppingCartPayment shoppingCartPayment){ + return shoppingCartService.shoppingCartPayment(shoppingCartPayment); } diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/enums/OrderStatus.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/enums/OrderStatus.java new file mode 100644 index 0000000..c8cfe81 --- /dev/null +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/enums/OrderStatus.java @@ -0,0 +1,32 @@ +package com.ruoyi.order.enums; + +import lombok.Getter; + +@Getter +public enum OrderStatus { + PENDING_SHIPMENT(1, "待发货"), + PENDING_RECEIPT(2, "待收货"), + PENDING_USE(3, "待使用"), + COMPLETED(4, "已完成"), + CANCELLED(5, "已取消"), + REFUNDED(6, "已退款"), + AFTER_SALE(7, "售后中"); + + private final int code; + private final String description; + + OrderStatus(int code, String description) { + this.code = code; + this.description = description; + } + + // 根据代码获取对应的OrderStatus + public static OrderStatus fromCode(int code) { + for (OrderStatus status : values()) { + if (status.getCode() == code) { + return status; + } + } + throw new IllegalArgumentException("Unknown order status code: " + code); + } +} \ No newline at end of file diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/enums/OrderType.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/enums/OrderType.java new file mode 100644 index 0000000..c3a581f --- /dev/null +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/enums/OrderType.java @@ -0,0 +1,26 @@ +package com.ruoyi.order.enums; + +import lombok.Getter; + +@Getter +public enum OrderType { + SERVICE(1, "服务单"), + GOOD(2, "商品单"); + + private final int code; + private final String description; + + OrderType(int code, String description) { + this.code = code; + this.description = description; + } + + public static OrderType fromCode(int code) { + for (OrderType type : OrderType.values()) { + if (type.getCode() == code) { + return type; + } + } + return null; + } +} diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/CommissionService.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/CommissionService.java new file mode 100644 index 0000000..da99507 --- /dev/null +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/CommissionService.java @@ -0,0 +1,12 @@ +package com.ruoyi.order.service; + +import java.time.LocalDateTime; +import java.util.List; + +public interface CommissionService { + + // 计算佣金 + void calculationCommission(List<Long> orderIds); + + void addToCommissionDelayQueue(Long orderId, LocalDateTime afterSalesDeadline); +} 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 cd40477..709bfce 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 @@ -1,7 +1,7 @@ package com.ruoyi.order.service; import com.baomidou.mybatisplus.extension.service.IService; -import com.ruoyi.order.vo.OrderDetailVO; +import vo.OrderDetailVO; import com.ruoyi.order.vo.OrderVO; import model.Order; @@ -20,5 +20,9 @@ OrderDetailVO getOrderDetail(Long orderId); - boolean check(String orderNumber, Long shopId); + boolean check(Order order, Integer shopId, Long userId); + + void writeOff(String code,Integer shopId); + + void commission(Long orderId); } diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/ShoppingCartService.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/ShoppingCartService.java index 2e414aa..9d62792 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/ShoppingCartService.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/ShoppingCartService.java @@ -1,9 +1,9 @@ package com.ruoyi.order.service; import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.web.domain.AjaxResult; -import com.ruoyi.order.vo.MyShoppingCartVo; -import com.ruoyi.order.vo.SetGoodsNumber; +import com.ruoyi.order.vo.*; import model.ShoppingCart; import org.springframework.web.bind.annotation.RequestBody; @@ -32,5 +32,21 @@ * @param setGoodsNumber * @return */ - AjaxResult setGoodsNumber(SetGoodsNumber setGoodsNumber); + R setGoodsNumber(SetGoodsNumber setGoodsNumber); + + + /** + * 确认购物车订单 + * @param confirmOrder + * @return + */ + ConfirmOrderVo confirmOrder(ConfirmOrder confirmOrder); + + + /** + * 购物车支付操作 + * @param shoppingCartPayment + * @return + */ + R shoppingCartPayment(ShoppingCartPayment shoppingCartPayment); } 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 new file mode 100644 index 0000000..08804ba --- /dev/null +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/CommissionServiceImpl.java @@ -0,0 +1,111 @@ +package com.ruoyi.order.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.ruoyi.account.api.feignClient.AppUserClient; +import com.ruoyi.account.api.model.AppUser; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.order.service.CommissionService; +import com.ruoyi.order.service.OrderGoodService; +import com.ruoyi.order.service.OrderService; +import com.ruoyi.other.api.domain.Shop; +import com.ruoyi.other.api.feignClient.ShopClient; +import model.Order; +import model.OrderGood; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +@Service +public class CommissionServiceImpl implements CommissionService { + @Resource + private OrderService orderService; + @Resource + private OrderGoodService orderGoodService; + @Resource + private AppUserClient appUserClient; + @Resource + private ShopClient shopClient; + @Resource + private RedisTemplate<String, String> redisTemplate; + + /** + * 返佣延迟队列(redis有序集合) + * + * @param orderId 订单ID + * @param afterSalesDeadline 售后截止日期(计算日期) + */ + @Override + public void addToCommissionDelayQueue(Long orderId, LocalDateTime afterSalesDeadline) { + // 获取订单售后截止日期时间戳(秒) + long deadlineTimestamp = afterSalesDeadline.atZone(ZoneId.systemDefault()).toEpochSecond(); + redisTemplate.opsForZSet().add("delay_queue:commission", orderId.toString(), deadlineTimestamp); + } + + @Override + public void calculationCommission(List<Long> orderIds) { + List<OrderGood> orderGoods = orderGoodService.list(new LambdaQueryWrapper<OrderGood>() + .in(OrderGood::getOrderId, orderIds)); + + Map<Long, List<OrderGood>> ogMap = orderGoods.stream().collect(Collectors.groupingBy(OrderGood::getOrderId)); + + for (Map.Entry<Long, List<OrderGood>> entry : ogMap.entrySet()) { + Long k = entry.getKey(); + List<OrderGood> v = entry.getValue(); + Order order = orderService.getById(k); + if (order.getIsCommission() == 1) { + continue; + } + R<Shop> r = shopClient.getShopById(order.getShopId()); + if (!R.isSuccess(r)) { + throw new RuntimeException("获取门店信息失败"); + } + Shop shop = r.getData(); + if (shop == null) { + throw new RuntimeException("获取门店信息失败"); + } + + Long appUserId = order.getAppUserId(); + AppUser appUser = appUserClient.getAppUserById(appUserId); + if (appUser == null) { + throw new RuntimeException("获取用户信息失败"); + } + Long inviteUserId = appUser.getInviteUserId(); + AppUser inviteUser = appUserClient.getAppUserById(inviteUserId); + + for (OrderGood og : v) {// 累计分销金额 + + // 上级分销金额 + if (inviteUser != null){ + BigDecimal superiorSubcommission = og.getSuperiorSubcommission(); + BigDecimal totalDistributionAmount = inviteUser.getTotalDistributionAmount(); + totalDistributionAmount = totalDistributionAmount.add(superiorSubcommission); + // + Integer superiorType = og.getSuperiorType(); + Integer sharePoint = inviteUser.getSharePoint(); + if (superiorType == 1) { + Integer superiorRebatePoints = og.getSuperiorRebatePoints(); + sharePoint = sharePoint + superiorRebatePoints; + } else if (superiorType == 2) { + + } else { + continue; + } + inviteUser.setTotalDistributionAmount(totalDistributionAmount); + inviteUser.setSharePoint(sharePoint); + } + + // 门店分销金额 + og.getBoundShopCharges(); + } + } + + + } +} 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 07e2af9..55b7583 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 @@ -3,25 +3,36 @@ import com.alibaba.fastjson2.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.account.api.feignClient.AppUserClient; +import com.ruoyi.account.api.model.AppUserShop; import com.ruoyi.account.api.model.UserAddress; +import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.exception.ServiceException; import com.ruoyi.common.core.utils.StringUtils; +import com.ruoyi.common.security.service.TokenService; +import com.ruoyi.order.enums.OrderStatus; +import com.ruoyi.order.enums.OrderType; import com.ruoyi.order.mapper.OrderGoodMapper; import com.ruoyi.order.mapper.OrderMapper; import com.ruoyi.order.service.OrderService; -import com.ruoyi.order.vo.OrderDetailVO; -import com.ruoyi.order.vo.OrderGoodsVO; +import vo.OrderDetailVO; +import vo.OrderGoodsVO; import com.ruoyi.order.vo.OrderVO; import com.ruoyi.other.api.domain.CouponInfo; import com.ruoyi.other.api.domain.Goods; import com.ruoyi.other.api.domain.OrderActivityInfo; +import com.ruoyi.other.api.domain.Technician; +import com.ruoyi.other.api.feignClient.TechnicianClient; +import com.ruoyi.system.api.model.LoginUser; import model.Order; import model.OrderGood; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; /** * <p> @@ -35,7 +46,15 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements OrderService { @Resource private OrderMapper orderMapper; + @Resource private OrderGoodMapper orderGoodMapper; + @Resource + private AppUserClient appUserClient; + @Resource + private TokenService tokenService; + @Resource + private TechnicianClient technicianClient; + @Override public List<OrderVO> selectOrderListByUserId(Integer status, Long userId) { @@ -115,10 +134,62 @@ } @Override - public boolean check(String orderNumber, Long shopId) { - Order order = getOne(new LambdaQueryWrapper<Order>() - .eq(Order::getOrderNumber, orderNumber) - .eq(Order::getShopId, shopId)); - return order != null; + public boolean check(Order order, Integer shopId, Long userId) { + R<List<AppUserShop>> r = appUserClient.getAppUserShop(userId); + if (r.getCode() != R.SUCCESS){ + throw new ServiceException("获取用户门店信息失败"); + } + List<AppUserShop> appUserShopList = r.getData(); + if (appUserShopList == null || appUserShopList.isEmpty()){ + return false; + } + + // 判断用户是否拥有该门店 + List<AppUserShop> userShopList = appUserShopList.stream() + .filter(appUserShop -> appUserShop.getShopId().equals(shopId)) + .collect(Collectors.toList()); + if (userShopList.isEmpty()){ + return false; + } + + // 判断订单是否属于该门店 + if (order == null){ + throw new ServiceException("订单不存在"); + } + + return order.getShopId().equals(shopId); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void writeOff(String code,Integer shopId) { + LoginUser loginUserApplet = tokenService.getLoginUserApplet(); + Order order = orderMapper.selectOne(new LambdaQueryWrapper<Order>() + .eq(Order::getOrderNumber, code)); + boolean check = check(order, shopId, loginUserApplet.getUserid()); + if (!check){ + throw new ServiceException("订单不存在"); + } + order.setOrderStatus(OrderStatus.COMPLETED.getCode()); + orderMapper.updateById(order); + Integer orderType = order.getOrderType(); + if (orderType.equals(OrderType.SERVICE.getCode())){ + R<Technician> shopdetail = technicianClient.shopdetail(order.getTechnicianId()); + if (shopdetail.getCode() != R.SUCCESS){ + throw new ServiceException("获取技师信息失败"); + } + Technician technician = shopdetail.getData(); + R<Void> r = technicianClient.updateStatus(2, technician.getId()); + if (r.getCode() != R.SUCCESS){ + throw new ServiceException("修改技师状态失败"); + } + } + } + + + + @Override + public void commission(Long orderId) { + } } 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 1f254ea..cac0a44 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 @@ -1,28 +1,45 @@ package com.ruoyi.order.service.impl; +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONArray; +import com.alibaba.fastjson2.JSONObject; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.ruoyi.account.api.feignClient.AppUserClient; +import com.ruoyi.account.api.feignClient.*; import com.ruoyi.account.api.model.AppUser; +import com.ruoyi.account.api.model.BalanceChangeRecord; +import com.ruoyi.account.api.model.UserAddress; +import com.ruoyi.account.api.model.UserPoint; +import com.ruoyi.account.api.vo.CouponInfoVo; +import com.ruoyi.account.api.vo.PaymentUserCoupon; +import com.ruoyi.account.api.vo.PaymentUserCouponVo; +import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.web.domain.AjaxResult; import com.ruoyi.common.security.service.TokenService; import com.ruoyi.order.mapper.ShoppingCartMapper; +import com.ruoyi.order.service.OrderGoodService; +import com.ruoyi.order.service.OrderService; import com.ruoyi.order.service.ShoppingCartService; -import com.ruoyi.order.vo.MyShoppingCartVo; -import com.ruoyi.order.vo.SetGoodsNumber; +import com.ruoyi.order.vo.*; import com.ruoyi.other.api.domain.*; import com.ruoyi.other.api.feignClient.*; import com.ruoyi.other.api.vo.GetGoodsBargainPrice; +import com.ruoyi.other.api.vo.GetGoodsShopByGoodsIds; import com.ruoyi.other.api.vo.GetSeckillActivityInfo; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import model.Order; +import model.OrderGood; import model.ShoppingCart; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; +import java.math.RoundingMode; +import java.text.SimpleDateFormat; +import java.time.LocalDateTime; +import java.util.*; import java.util.stream.Collectors; @Service @@ -52,6 +69,36 @@ @Resource private GoodsBargainPriceClient goodsBargainPriceClient; + @Resource + private OrderService orderService; + + @Resource + private OrderGoodService orderGoodService; + + @Resource + private ShopClient shopClient; + + @Resource + private OrderActivityInfoClient orderActivityInfoClient; + + @Resource + private BaseSettingClient baseSettingClient; + + @Resource + private UserAddressClient userAddressClient; + + @Resource + private UserCouponClient userCouponClient; + + @Resource + private SystemConfigClient systemConfigClient; + + @Resource + private UserPointClient userPointClient; + + @Resource + private BalanceChangeRecordClient balanceChangeRecordClient; + @@ -72,47 +119,11 @@ if(null == data){ throw new RuntimeException("根据类型(1=服务商品,2=单品商品)获取商品数据失败"); } - List<Long> goodsIds = data.stream().map(Goods::getId).collect(Collectors.toList()); + List<Integer> goodsIds = data.stream().map(Goods::getId).collect(Collectors.toList()); //查询符合商品类型的商品数据 List<ShoppingCart> list = this.list(new LambdaQueryWrapper<ShoppingCart>().eq(ShoppingCart::getAppUserId, userid).in(ShoppingCart::getGoodsId, goodsIds)); - List<MyShoppingCartVo> page = new ArrayList<>(); //构建返回数据 - for (ShoppingCart shoppingCart : list) { - Goods goods = data.stream().filter(s -> s.getId().equals(shoppingCart.getGoodsId())).findFirst().get(); - MyShoppingCartVo vo = new MyShoppingCartVo(); - vo.setId(shoppingCart.getId()); - vo.setHomePicture(goods.getHomePagePicture()); - vo.setName(goods.getName()); - - //获取支付价格 - Price price = getPrice(appUser, shoppingCart.getGoodsId(), shopId); - if(null == price){ - //使用商品的基础价格 - price.setCash(1 == goods.getCashPayment() ? goods.getSellingPrice() : null); - price.setPoint(1 == goods.getPointPayment() ? goods.getIntegral() : null); - } - //构建价格展示内容 - String sellingPrice = ""; - if(null != price.getCash() && null != price.getPoint()){ - sellingPrice = price.getCash() + "或" + price.getPoint() + "积分"; - } - if(null != price.getCash() && null == price.getPoint()){ - sellingPrice = price.getCash() + ""; - } - if(null == price.getCash() && null != price.getPoint()){ - sellingPrice = price.getPoint() + "积分"; - } - vo.setSellingPrice(sellingPrice); - vo.setEndTime(price.getEndTime()); - vo.setOriginalPrice(goods.getOriginalPrice().toString()); - vo.setNumber(shoppingCart.getNumber()); - GoodsShop goodsShop = new GoodsShop(); - goodsShop.setGoodsId(shoppingCart.getGoodsId()); - goodsShop.setShopId(shopId); - GoodsShop goodsShop1 = goodsShopClient.getGoodsShop(goodsShop).getData(); - vo.setVerifiable(null == goodsShop1 ? false : true); - page.add(vo); - } + List<MyShoppingCartVo> page = buildDetail(appUser, shopId, list, null); return page; } @@ -157,14 +168,60 @@ }else{ price.setCash(goodsVip.getSellingPrice()); price.setPoint(goodsVip.getIntegral()); + price.setCashPayment(goodsVip.getCashPayment() == 1 ? true : false); + price.setPointPayment(goodsVip.getPointPayment() == 1 ? true : false); + price.setEarnSpendingPoints(goodsVip.getEarnSpendingPoints()); + price.setSuperiorSubcommission(goodsVip.getSuperiorSubcommission()); + price.setSuperiorRebatePoints(goodsVip.getSuperiorRebatePoints()); + price.setSuperiorType(goodsVip.getSuperiorType()); + price.setServuceShopCharges(goodsVip.getServuceShopCharges()); + price.setServuceShopPoints(goodsVip.getServuceShopPoints()); + price.setTechnicianPoints(goodsVip.getTechnicianPoints()); + price.setBoundShopCharges(goodsVip.getBoundShopCharges()); + price.setBoundShopPoints(goodsVip.getBoundShopPoints()); + price.setBoundShopSuperiorsCharges(goodsVip.getBoundShopSuperiorsCharges()); + price.setBoundShopSuperiorsPoints(goodsVip.getBoundShopSuperiorsPoints()); } }else{ price.setCash(goodsArea.getSellingPrice()); price.setPoint(goodsArea.getIntegral()); + price.setCashPayment(goodsArea.getCashPayment() == 1 ? true : false); + price.setPointPayment(goodsArea.getPointPayment() == 1 ? true : false); + price.setEarnSpendingPoints(goodsArea.getEarnSpendingPoints()); + price.setSuperiorSubcommission(goodsArea.getSuperiorSubcommission()); + price.setSuperiorRebatePoints(goodsArea.getSuperiorRebatePoints()); + price.setSuperiorType(goodsArea.getSuperiorType()); + price.setServuceShopCharges(goodsArea.getServuceShopCharges()); + price.setServuceShopPoints(goodsArea.getServuceShopPoints()); + price.setTechnicianPoints(goodsArea.getTechnicianPoints()); + price.setBoundShopCharges(goodsArea.getBoundShopCharges()); + price.setBoundShopPoints(goodsArea.getBoundShopPoints()); + price.setBoundShopSuperiorsCharges(goodsArea.getBoundShopSuperiorsCharges()); + price.setBoundShopSuperiorsPoints(goodsArea.getBoundShopSuperiorsPoints()); } }else{ price.setCash(bargainPriceDetail.getSellingPrice()); price.setPoint(bargainPriceDetail.getIntegral()); + price.setCashPayment(bargainPriceDetail.getSellingPrice() != null ? true : false); + price.setPointPayment(bargainPriceDetail.getIntegral() != null ? true : false); + //门店特价,消费积分使用会员等级的消费积分 + GoodsArea area = new GoodsArea(); + area.setDistrictsCode(appUser.getDistrictCode()); + area.setCityCode(appUser.getCityCode()); + area.setProvinceCode(appUser.getProvinceCode()); + area.setVip(appUser.getVipId()); + GoodsArea goodsArea = goodsAreaClient.getGoodsArea(area).getData(); + price.setEarnSpendingPoints(goodsArea.getEarnSpendingPoints()); + price.setSuperiorSubcommission(goodsArea.getSuperiorSubcommission()); + price.setSuperiorRebatePoints(goodsArea.getSuperiorRebatePoints()); + price.setSuperiorType(goodsArea.getSuperiorType()); + price.setServuceShopCharges(goodsArea.getServuceShopCharges()); + price.setServuceShopPoints(goodsArea.getServuceShopPoints()); + price.setTechnicianPoints(goodsArea.getTechnicianPoints()); + price.setBoundShopCharges(goodsArea.getBoundShopCharges()); + price.setBoundShopPoints(goodsArea.getBoundShopPoints()); + price.setBoundShopSuperiorsCharges(goodsArea.getBoundShopSuperiorsCharges()); + price.setBoundShopSuperiorsPoints(goodsArea.getBoundShopSuperiorsPoints()); } }else{ //构建价格数据 @@ -178,7 +235,20 @@ if(goodsSeckill.getCashPayment() == 0 && goodsSeckill.getPointPayment() == 1){ price.setPoint(goodsSeckill.getIntegral()); } + price.setCashPayment(goodsSeckill.getCashPayment() == 1 ? true : false); + price.setPointPayment(goodsSeckill.getPointPayment() == 1 ? true : false); price.setEndTime(goodsSeckill.getEndTime()); + price.setEarnSpendingPoints(goodsSeckill.getEarnSpendingPoints()); + price.setSuperiorSubcommission(goodsSeckill.getSuperiorSubcommission()); + price.setSuperiorRebatePoints(goodsSeckill.getSuperiorRebatePoints()); + price.setSuperiorType(goodsSeckill.getSuperiorType()); + price.setServuceShopCharges(goodsSeckill.getServuceShopCharges()); + price.setServuceShopPoints(goodsSeckill.getServuceShopPoints()); + price.setTechnicianPoints(goodsSeckill.getTechnicianPoints()); + price.setBoundShopCharges(goodsSeckill.getBoundShopCharges()); + price.setBoundShopPoints(goodsSeckill.getBoundShopPoints()); + price.setBoundShopSuperiorsCharges(goodsSeckill.getBoundShopSuperiorsCharges()); + price.setBoundShopSuperiorsPoints(goodsSeckill.getBoundShopSuperiorsPoints()); } return price; } @@ -198,6 +268,58 @@ * 获取结束时间 */ private Long endTime; + /** + * 现金支付 + */ + private Boolean cashPayment; + /** + * 积分支付 + */ + private Boolean pointPayment; + /** + * 可获得消费积分 + */ + private Integer earnSpendingPoints; + /** + * 上级获得分佣金额 + */ + private BigDecimal superiorSubcommission; + /** + * 上级获得返佣积分 + */ + private Integer superiorRebatePoints; + /** + * 获取返佣积分上级类型(1=直推上级,2=直帮上级) + */ + private Integer superiorType; + /** + * 核销门店可获得服务费 + */ + private BigDecimal servuceShopCharges; + /** + * 核销门店可获得服务积分 + */ + private Integer servuceShopPoints; + /** + * 技师可获得服务积分 + */ + private Integer technicianPoints; + /** + * 绑定门店可获得分佣金额 + */ + private BigDecimal boundShopCharges; + /** + * 绑定门店可获得返佣积分 + */ + private Integer boundShopPoints; + /** + * 绑定门店上级门店可获得分佣金额 + */ + private BigDecimal boundShopSuperiorsCharges; + /** + * 绑定门店上级门店可获得返佣积分 + */ + private Integer boundShopSuperiorsPoints; } @@ -215,15 +337,639 @@ * @return */ @Override - public AjaxResult setGoodsNumber(SetGoodsNumber setGoodsNumber) { + public R setGoodsNumber(SetGoodsNumber setGoodsNumber) { if(0 >= setGoodsNumber.getNumber()){ - return AjaxResult.error("修改数量不能小于等于0"); + return R.fail("修改数量不能小于等于0"); } ShoppingCart shoppingCart = this.getById(setGoodsNumber.getId()); + Goods goods = goodsClient.getGoodsById(shoppingCart.getGoodsId()).getData(); + if(null != goods.getPurchaseLimit() && -1 != goods.getPurchaseLimit() && goods.getPurchaseLimit() < setGoodsNumber.getNumber()){ + return R.fail("修改数量不能大于限购数量"); + } if(null != shoppingCart){ shoppingCart.setNumber(setGoodsNumber.getNumber()); this.updateById(shoppingCart); } - return AjaxResult.success(); + return R.ok(); + } + + + /** + * 确认购物车订单 + * @param confirmOrder + * @return + */ + @Override + public ConfirmOrderVo confirmOrder(ConfirmOrder confirmOrder) { + Long userid = tokenService.getLoginUserApplet().getUserid(); + AppUser appUser = appUserClient.getAppUserById(userid); + Integer shopId = confirmOrder.getShopId(); + Shop shop = shopClient.getShopById(shopId).getData(); + String goodsJson = confirmOrder.getGoodsJson(); + List<Long> ids = new ArrayList<>(); + JSONArray objects = JSON.parseArray(goodsJson); + for (int i = 0; i < objects.size(); i++) { + Long id = objects.getJSONObject(i).getLong("id"); + ids.add(id); + } + List<ShoppingCart> list = this.listByIds(ids); + ConfirmOrderVo confirmOrderVo = new ConfirmOrderVo(); + //构建商品明细列表 + List<MyShoppingCartVo> goodsList = buildDetail(appUser, shopId, list, objects); + confirmOrderVo.setGoodsList(goodsList); + confirmOrderVo.setShopId(confirmOrder.getShopId()); + confirmOrderVo.setShopName(shop.getName()); + //现金支付 + if(confirmOrder.getPaymentType() == 1){ + BigDecimal bigDecimal = goodsList.stream().map(MyShoppingCartVo::getCash).reduce(BigDecimal::add).get(); + confirmOrderVo.setOrderMoney(bigDecimal); + }else{ + int sum = goodsList.stream().mapToInt(MyShoppingCartVo::getPoint).sum(); + confirmOrderVo.setOrderPoint(sum); + } + //查询当前是否有订单活动 + OrderActivityInfo orderActivityInfo = orderActivityInfoClient.getNowOrderActivityInfo(appUser.getVipId()).getData(); + BigDecimal orderMoney = confirmOrderVo.getOrderMoney(); + BigDecimal paymentMoney = orderMoney; + //满XX才打折,只有现金才能优惠 + if(null != orderActivityInfo && confirmOrder.getPaymentType() == 1 && orderActivityInfo.getConditionAmount().compareTo(orderMoney) <= 0){ + confirmOrderVo.setActivityName(orderActivityInfo.getActivityName()); + paymentMoney = orderActivityInfo.getDiscount().divide(new BigDecimal(10)).multiply(orderMoney); + confirmOrderVo.setDiscountAmount(orderMoney.subtract(paymentMoney).setScale(2, RoundingMode.HALF_EVEN)); + } + BaseSetting baseSetting = baseSettingClient.getBaseSetting(4).getData(); + confirmOrderVo.setUseSimultaneously(baseSetting.getContent().equals("1") ? true : false); + int earnPoint = goodsList.stream().mapToInt(MyShoppingCartVo::getEarnSpendingPoints).sum(); + confirmOrderVo.setEarnPoint(earnPoint); + //支付金额,订单金额-订单优惠 + confirmOrderVo.setPayMoney(paymentMoney); + confirmOrderVo.setResidualPoint(appUser.getLavePoint().intValue()); + //获取默认收货地址 + UserAddress userAddress = userAddressClient.getDefaultUserAddress(userid).getData(); + confirmOrderVo.setUserAddress(userAddress); + confirmOrderVo.setPaymentType(confirmOrder.getPaymentType()); + //获取用户优惠券,用户全部优惠券,不能使用的需要标识出来置灰展示 + PaymentUserCoupon paymentUserCoupon = new PaymentUserCoupon(); + paymentUserCoupon.setUserId(userid); + paymentUserCoupon.setOrderMoney(orderMoney); + paymentUserCoupon.setType(confirmOrder.getType()); + if(confirmOrder.getPaymentType() == 1){ + List<PaymentUserCouponVo> data = userCouponClient.getPaymentUserCoupon(paymentUserCoupon).getData(); + for (PaymentUserCouponVo couponInfo : data) { + List<Integer> forGoodIds = couponInfo.getForGoodIds(); + //全部商品适用 + if(null == forGoodIds){ + //满减券 + if(1 == couponInfo.getCouponType() && orderMoney.compareTo(couponInfo.getConditionAmount()) >= 0){ + couponInfo.setAvailable(true); + } + //代金券和折扣券 + if(2 == couponInfo.getCouponType() || 3 == couponInfo.getCouponType()){ + couponInfo.setAvailable(true); + } + }else{ + //部分商品适用 + BigDecimal goodsMoney = BigDecimal.ZERO; + for (MyShoppingCartVo myShoppingCartVo : goodsList) { + Integer goodsId = myShoppingCartVo.getGoodsId(); + BigDecimal cash = myShoppingCartVo.getCash(); + if(forGoodIds.contains(goodsId)){ + goodsMoney = goodsMoney.add(cash); + } + } + //满减 + if(1 == couponInfo.getCouponType() && couponInfo.getConditionAmount().compareTo(goodsMoney) <= 0){ + couponInfo.setAvailable(true); + } + //代金券 + if(2 == couponInfo.getCouponType() || 3 == couponInfo.getCouponType()){ + couponInfo.setAvailable(true); + } + } + } + confirmOrderVo.setCoupon(data); + } + //获取快递策略 + SystemConfig systemConfig = systemConfigClient.getSystemConfig(3).getData(); + JSONObject jsonObject = JSON.parseObject(systemConfig.getContent()); + confirmOrderVo.setExpressFee(jsonObject.getBigDecimal("expressFee")); + List<Integer> vip = jsonObject.getJSONArray("vip").toList(Integer.class); + //包邮条件(所有会员或者满足条件的会员) + if(vip.get(0) == -1 || vip.contains(appUser.getVipId())){ + if(confirmOrder.getPaymentType() == 1){ + //现金支付,支付金额满足包邮条件 + BigDecimal cash = jsonObject.getBigDecimal("cash"); + if(confirmOrderVo.getPayMoney().compareTo(cash) >= 0){ + confirmOrderVo.setExpressFee(BigDecimal.ZERO); + } + }else{ + //积分支付,支付积分是否满足包邮条件 + Integer point = jsonObject.getInteger("point"); + if(confirmOrderVo.getOrderPoint().compareTo(point) >= 0){ + confirmOrderVo.setExpressFee(BigDecimal.ZERO); + } + } + } + return confirmOrderVo; + } + + + /** + * 构建购物车商品列表 + * @param appUser + * @param shopId + * @param list + * @param objects + * @return + */ + private List<MyShoppingCartVo> buildDetail(AppUser appUser, Integer shopId, List<ShoppingCart> list, JSONArray objects){ + List<MyShoppingCartVo> page = new ArrayList<>(); + for (ShoppingCart shoppingCart : list) { + Goods goods = goodsClient.getGoodsById(shoppingCart.getGoodsId()).getData(); + MyShoppingCartVo vo = new MyShoppingCartVo(); + vo.setId(shoppingCart.getId()); + vo.setGoodsId(goods.getId()); + vo.setHomePicture(goods.getHomePagePicture()); + vo.setName(goods.getName()); + int num = shoppingCart.getNumber(); + if(null != objects){ + for (int i = 0; i < objects.size(); i++) { + Long id = objects.getJSONObject(i).getLong("id"); + if(id.equals(shoppingCart.getId())){ + num = objects.getJSONObject(i).getInteger("num"); + break; + } + } + } + //获取支付价格 + Price price = getPrice(appUser, shoppingCart.getGoodsId(), shopId); + if(null == price){ + //使用商品的基础价格 + price.setCash(1 == goods.getCashPayment() ? goods.getSellingPrice() : null); + price.setPoint(1 == goods.getPointPayment() ? goods.getIntegral() : null); + price.setCashPayment(goods.getCashPayment() == 1 ? true : false); + price.setPointPayment(goods.getPointPayment() == 1 ? true : false); + } + vo.setCash(price.getCash()); + vo.setPoint(price.getPoint()); + vo.setCashPayment(price.getCashPayment()); + vo.setPointPayment(price.getPointPayment()); + vo.setEndTime(price.getEndTime()); + vo.setOriginalPrice(goods.getOriginalPrice().toString()); + vo.setNumber(num); + GoodsShop goodsShop = new GoodsShop(); + goodsShop.setGoodsId(shoppingCart.getGoodsId()); + goodsShop.setShopId(shopId); + GoodsShop goodsShop1 = goodsShopClient.getGoodsShop(goodsShop).getData(); + vo.setVerifiable(null == goodsShop1 ? false : true); + //判断当前数量是否已经超出限购数量(需要计算已经购买的数量) + if(null == goods.getPurchaseLimit() || -1 == goods.getPurchaseLimit()){ + vo.setPurchaseLimit(false); + }else{ + List<Order> orders = orderService.list(new LambdaQueryWrapper<Order>().eq(Order::getAppUserId, appUser.getId()).eq(Order::getDelFlag, 0).in(Order::getOrderStatus, Arrays.asList(4, 8))); + List<Long> orderIds = orders.stream().map(Order::getId).collect(Collectors.toList()); + int sum = 0; + if(orderIds.size() > 0){ + List<OrderGood> orderGoodList = orderGoodService.list(new LambdaQueryWrapper<OrderGood>().in(OrderGood::getOrderId, orderIds) + .eq(OrderGood::getGoodsId, shoppingCart.getGoodsId()).eq(OrderGood::getDelFlag, 0)); + sum = orderGoodList.stream().mapToInt(OrderGood::getNum).sum(); + } + vo.setPurchaseLimit((num + sum) > goods.getPurchaseLimit() ? true : false); + } + vo.setDistributionMode(goods.getDistributionMode()); + vo.setEarnSpendingPoints(price.getEarnSpendingPoints()); + vo.setSuperiorSubcommission(price.getSuperiorSubcommission()); + vo.setSuperiorRebatePoints(price.getSuperiorRebatePoints()); + vo.setSuperiorType(price.getSuperiorType()); + vo.setServuceShopCharges(price.getServuceShopCharges()); + vo.setServuceShopPoints(price.getServuceShopPoints()); + vo.setTechnicianPoints(price.getTechnicianPoints()); + vo.setBoundShopCharges(price.getBoundShopCharges()); + vo.setBoundShopPoints(price.getBoundShopPoints()); + vo.setBoundShopSuperiorsCharges(price.getBoundShopSuperiorsCharges()); + vo.setBoundShopSuperiorsPoints(price.getBoundShopSuperiorsPoints()); + page.add(vo); + } + return page; + } + + + /** + * 购物车支付操作 + * @param shoppingCartPayment + * @return + */ + @Override + public R shoppingCartPayment(ShoppingCartPayment shoppingCartPayment) { + Long userid = tokenService.getLoginUserApplet().getUserid(); + AppUser appUser = appUserClient.getAppUserById(userid); + Integer shopId = shoppingCartPayment.getShopId(); + String goodsJson = shoppingCartPayment.getGoodsJson(); + List<Long> ids = new ArrayList<>(); + Integer num = 0; + JSONArray objects = JSON.parseArray(goodsJson); + for (int i = 0; i < objects.size(); i++) { + Long id = objects.getJSONObject(i).getLong("id"); + Integer num1 = objects.getJSONObject(i).getInteger("num"); + num += num1; + ShoppingCart shoppingCart = this.getById(id); + //判断当前数量是否已经超出限购数量(需要计算已经购买的数量) + Goods goods = goodsClient.getGoodsById(shoppingCart.getGoodsId()).getData(); + if(null != goods.getPurchaseLimit() && -1 != goods.getPurchaseLimit()){ + List<Order> orders = orderService.list(new LambdaQueryWrapper<Order>().eq(Order::getAppUserId, appUser.getId()).eq(Order::getDelFlag, 0).in(Order::getOrderStatus, Arrays.asList(4, 8))); + List<Long> orderIds = orders.stream().map(Order::getId).collect(Collectors.toList()); + int sum = 0; + if(orderIds.size() > 0){ + List<OrderGood> orderGoodList = orderGoodService.list(new LambdaQueryWrapper<OrderGood>().in(OrderGood::getOrderId, orderIds) + .eq(OrderGood::getGoodsId, shoppingCart.getGoodsId()).eq(OrderGood::getDelFlag, 0)); + sum = orderGoodList.stream().mapToInt(OrderGood::getNum).sum(); + } + if((num1 + sum) > goods.getPurchaseLimit()){ + return R.fail(goods.getName() + "已超出购买上限"); + } + } + ids.add(id); + } + + List<ShoppingCart> list = this.listByIds(ids); + //构建商品明细列表 + List<MyShoppingCartVo> goodsList = buildDetail(appUser, shopId, list, objects); + //判断支付当时是否正确 + if(1 == shoppingCartPayment.getPaymentType() || 2 == shoppingCartPayment.getPaymentType()){ + //现金支付 + long count = goodsList.stream().filter(s -> s.getCashPayment()).count(); + if(count != goodsList.size()){ + return R.fail("支付方式不正确"); + } + } else if(3 == shoppingCartPayment.getPaymentType()){ + //积分支付 + long count = goodsList.stream().filter(s -> s.getPointPayment()).count(); + if(count != goodsList.size()){ + return R.fail("支付方式不正确"); + } + }else{ + return R.fail("支付方式不正确"); + } + //判断门店是都可以核销所有的商品 + List<Integer> goodsIds = goodsList.stream().map(MyShoppingCartVo::getGoodsId).collect(Collectors.toList()); + GetGoodsShopByGoodsIds goodsShopByGoodsIds = new GetGoodsShopByGoodsIds(); + goodsShopByGoodsIds.setGoodsIds(goodsIds); + goodsShopByGoodsIds.setShopId(shopId); + List<GoodsShop> data = goodsShopClient.getGoodsShopByGoodsIds(goodsShopByGoodsIds).getData(); + List<Integer> collect = data.stream().map(GoodsShop::getGoodsId).collect(Collectors.toList()); + if(data.size() != goodsList.size()){ + String goodsName = ""; + for (Integer goodsId : goodsIds) { + if(!collect.contains(goodsId)){ + goodsName = goodsClient.getGoodsById(goodsId).getData().getName(); + break; + } + } + return R.fail(goodsName + "不能在该门店核销"); + } + //开始构建支付信息 + //现金支付的订单金额 + BigDecimal orderMoney = BigDecimal.ZERO; + //折扣(9折) + BigDecimal discount = null; + //积分支付的订单积分 + Integer orderPoint = 0; + if(3 != shoppingCartPayment.getPaymentType()){ + orderMoney = goodsList.stream().map(MyShoppingCartVo::getCash).reduce(BigDecimal::add).get(); + }else{ + orderPoint = goodsList.stream().mapToInt(MyShoppingCartVo::getPoint).sum(); + if(appUser.getLavePoint().intValue() < orderPoint){ + return R.fail("账户剩余积分不足"); + } + } + //现金的支付金额 + BigDecimal paymentMoney = orderMoney; + //满减金额 + BigDecimal fullReductionAmount = BigDecimal.ZERO; + //代金券抵扣金额 + BigDecimal moneyAmount = BigDecimal.ZERO; + //折扣券抵扣金额 + BigDecimal discountAmount = BigDecimal.ZERO; + //活动优惠金额 + BigDecimal activityAmount = BigDecimal.ZERO; + + //减去优惠券优惠金额 + CouponInfoVo couponInfoVo = null; + if(null != shoppingCartPayment.getUserCouponId() && 3 != shoppingCartPayment.getPaymentType()){ + couponInfoVo = userCouponClient.getCouponInfo(shoppingCartPayment.getUserCouponId()).getData(); + String forGoodIds = couponInfoVo.getForGoodIds(); + List<Integer> parseArray = JSON.parseArray(forGoodIds, Integer.class); + //全部商品 + if(parseArray.contains(-1)){ + //满减 + if(1 == couponInfoVo.getCouponType() && couponInfoVo.getConditionAmount().compareTo(paymentMoney) <= 0){ + paymentMoney = paymentMoney.subtract(couponInfoVo.getDiscountAmount()); + fullReductionAmount = fullReductionAmount.add(couponInfoVo.getDiscountAmount()); + } + //代金券 + if(2 == couponInfoVo.getCouponType()){ + paymentMoney = paymentMoney.subtract(couponInfoVo.getMoneyAmount()); + moneyAmount = moneyAmount.add(couponInfoVo.getMoneyAmount()); + if(paymentMoney.compareTo(BigDecimal.ZERO) < 0){ + paymentMoney = BigDecimal.ZERO; + } + } + //折扣券 + if(3 == couponInfoVo.getCouponType()){ + BigDecimal paymentMoney1 = couponInfoVo.getDiscount().divide(new BigDecimal(10)).multiply(paymentMoney); + BigDecimal bigDecimal = paymentMoney.subtract(paymentMoney1).setScale(2, RoundingMode.HALF_EVEN); + discount = couponInfoVo.getDiscount(); + paymentMoney = paymentMoney1; + discountAmount = discountAmount.add(bigDecimal); + } + }else{ + //部分商品,需要计算参与优惠商品的支付金额,然后再对商品进行优惠券处理 + paymentMoney = BigDecimal.ZERO; + BigDecimal goodsMoney = BigDecimal.ZERO; + for (MyShoppingCartVo myShoppingCartVo : goodsList) { + Integer goodsId = myShoppingCartVo.getGoodsId(); + BigDecimal cash = myShoppingCartVo.getCash(); + if(parseArray.contains(goodsId)){ + goodsMoney = goodsMoney.add(cash); + }else{ + paymentMoney = paymentMoney.add(cash); + } + } + + //满减 + if(1 == couponInfoVo.getCouponType() && couponInfoVo.getConditionAmount().compareTo(goodsMoney) <= 0){ + goodsMoney = goodsMoney.subtract(couponInfoVo.getDiscountAmount()); + fullReductionAmount = fullReductionAmount.add(couponInfoVo.getDiscountAmount()); + } + //代金券 + if(2 == couponInfoVo.getCouponType()){ + goodsMoney = goodsMoney.subtract(couponInfoVo.getMoneyAmount()); + moneyAmount = moneyAmount.add(couponInfoVo.getMoneyAmount()); + if(goodsMoney.compareTo(BigDecimal.ZERO) < 0){ + goodsMoney = BigDecimal.ZERO; + } + } + //折扣券 + if(3 == couponInfoVo.getCouponType()){ + BigDecimal paymentMoney1 = couponInfoVo.getDiscount().divide(new BigDecimal(10)).multiply(goodsMoney); + BigDecimal bigDecimal = goodsMoney.subtract(paymentMoney1).setScale(2, RoundingMode.HALF_EVEN); + discount = couponInfoVo.getDiscount(); + goodsMoney = paymentMoney1; + discountAmount = discountAmount.add(bigDecimal); + } + paymentMoney = paymentMoney.add(goodsMoney); + } + } + + //查询当前是否有订单活动 + OrderActivityInfo orderActivityInfo = orderActivityInfoClient.getNowOrderActivityInfo(appUser.getVipId()).getData(); + BaseSetting baseSetting = baseSettingClient.getBaseSetting(4).getData(); + //系统活动设置(优惠券和活动能否同时使用) + boolean useSimultaneously = baseSetting.getContent().equals("1") ? true : false; + //满XX才打折,只有现金才能优惠 + //如果使用优惠券,则需要判断是否可以和同时使用,且活动满足使用条件。 + //没有使用优惠券,只需要判断是都满足使用条件 + if(((useSimultaneously && null != shoppingCartPayment.getUserCouponId()) || null == shoppingCartPayment.getUserCouponId()) && + null != orderActivityInfo && shoppingCartPayment.getPaymentType() != 3 && orderActivityInfo.getConditionAmount().compareTo(paymentMoney) <= 0){ + BigDecimal paymentMoney1 = orderActivityInfo.getDiscount().divide(new BigDecimal(10)).multiply(paymentMoney); + BigDecimal bigDecimal = paymentMoney.subtract(paymentMoney1).setScale(2, RoundingMode.HALF_EVEN); + discount = orderActivityInfo.getDiscount(); + paymentMoney = paymentMoney1; + activityAmount = activityAmount.add(bigDecimal); + } + + //可获得的消费积分 + int earnPoint = goodsList.stream().mapToInt(MyShoppingCartVo::getEarnSpendingPoints).sum(); + if(null != shoppingCartPayment.getUserAddressId()){ + userAddressClient.getUserAddressById(shoppingCartPayment.getUserAddressId()).getData(); + } + + //获取快递策略,计算快递费 + BigDecimal expressFee = BigDecimal.ZERO; + if(null != shoppingCartPayment.getUserAddressId()){ + SystemConfig systemConfig = systemConfigClient.getSystemConfig(3).getData(); + JSONObject jsonObject = JSON.parseObject(systemConfig.getContent()); + //快递费 + expressFee = jsonObject.getBigDecimal("expressFee"); + List<Integer> vip = jsonObject.getJSONArray("vip").toList(Integer.class); + //包邮条件(所有会员或者满足条件的会员) + if(vip.get(0) == -1 || vip.contains(appUser.getVipId())){ + if(shoppingCartPayment.getPaymentType() != 3){ + //现金支付,支付金额满足包邮条件 + BigDecimal cash = jsonObject.getBigDecimal("cash"); + if(paymentMoney.compareTo(cash) >= 0){ + expressFee = BigDecimal.ZERO; + } + }else{ + //积分支付,支付积分是否满足包邮条件 + Integer point = jsonObject.getInteger("point"); + if(orderPoint.compareTo(point) >= 0){ + expressFee = BigDecimal.ZERO; + } + } + } + } + //构建订单明细 + Order order = new Order(); + order.setAppUserId(userid); + order.setNum(num); + String goodPics = ""; + String goodName = ""; + for (MyShoppingCartVo myShoppingCartVo : goodsList) { + goodPics += myShoppingCartVo.getHomePicture() + ","; + goodName += myShoppingCartVo.getName() + ","; + } + order.setGoodPics(goodPics.substring(0, goodPics.length() - 1)); + order.setGoodName(goodName.substring(0, goodName.length() - 1)); + Goods goods = goodsClient.getGoodsById(goodsList.get(0).getGoodsId()).getData(); + order.setOrderType(goods.getType()); + order.setOrderStatus(1); + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); + order.setOrderNumber("QJS" + getNumber(3) + sdf.format(new Date())); + order.setTotalAmount(orderMoney.setScale(2, RoundingMode.HALF_EVEN)); + order.setFullReductionAmount(fullReductionAmount); + order.setMoneyAmount(moneyAmount); + order.setDiscountAmount(discountAmount); + order.setActivityAmount(activityAmount); + order.setDiscountTotalAmount(fullReductionAmount.add(moneyAmount).add(discountAmount).add(activityAmount)); + order.setPaymentAmount(paymentMoney); + order.setPoint(orderPoint); + order.setPayMethod(shoppingCartPayment.getPaymentType()); + if(3 != shoppingCartPayment.getPaymentType() && (fullReductionAmount.compareTo(BigDecimal.ZERO) > 0 ||moneyAmount.compareTo(BigDecimal.ZERO) > 0 || discountAmount.compareTo(BigDecimal.ZERO) > 0)){ + order.setCouponJson(JSON.toJSONString(couponInfoVo)); + } + if(activityAmount.compareTo(BigDecimal.ZERO) > 0){ + order.setActivityJson(JSON.toJSONString(orderActivityInfo)); + } + if(null != shoppingCartPayment.getUserAddressId()){ + UserAddress address = userAddressClient.getUserAddressById(shoppingCartPayment.getUserAddressId()).getData(); + order.setExpressAmount(expressFee); + order.setAddressJson(JSON.toJSONString(address)); + } + order.setGetPoint(earnPoint); + order.setPayStatus(1); + order.setShopId(shoppingCartPayment.getShopId()); + order.setDelFlag(0); + order.setCreateTime(LocalDateTime.now()); + + if(2 == shoppingCartPayment.getPaymentType()){ + BigDecimal balance = appUser.getBalance(); + if(balance.compareTo(paymentMoney.add(expressFee)) < 0){ + return R.fail("账户余额不足"); + } + } + orderService.save(order); + //构建订单明细数据 + for (MyShoppingCartVo myShoppingCartVo : goodsList) { + OrderGood orderGood = new OrderGood(); + orderGood.setGoodsId(myShoppingCartVo.getGoodsId()); + orderGood.setOrderId(order.getId()); + GetSeckillActivityInfo info = new GetSeckillActivityInfo(); + info.setGoodsId(myShoppingCartVo.getGoodsId()); + info.setVip(appUser.getVipId()); + GoodsSeckill goodsSeckill = seckillActivityInfoClient.getSeckillActivityInfo(info).getData(); + if(null != goodsSeckill){ + orderGood.setSeckillJson(JSON.toJSONString(goodsSeckill)); + } + for (int i = 0; i < objects.size(); i++) { + Long id = objects.getJSONObject(i).getLong("id"); + if(myShoppingCartVo.getId().equals(id)){ + Integer num1 = objects.getJSONObject(i).getInteger("num"); + orderGood.setNum(num1); + Goods goods1 = goodsClient.getGoodsById(myShoppingCartVo.getGoodsId()).getData(); + orderGood.setGoodJson(JSON.toJSONString(goods1)); + break; + } + } + orderGood.setDelFlag(0); + orderGood.setCreateTime(LocalDateTime.now()); + orderGood.setEarnSpendingPoints(myShoppingCartVo.getEarnSpendingPoints()); + orderGood.setSuperiorSubcommission(myShoppingCartVo.getSuperiorSubcommission()); + orderGood.setSuperiorRebatePoints(myShoppingCartVo.getSuperiorRebatePoints()); + orderGood.setSuperiorType(myShoppingCartVo.getSuperiorType()); + orderGood.setServuceShopCharges(myShoppingCartVo.getServuceShopCharges()); + orderGood.setServuceShopPoints(myShoppingCartVo.getServuceShopPoints()); + orderGood.setTechnicianPoints(myShoppingCartVo.getTechnicianPoints()); + orderGood.setBoundShopCharges(myShoppingCartVo.getBoundShopCharges()); + orderGood.setBoundShopPoints(myShoppingCartVo.getBoundShopPoints()); + orderGood.setBoundShopSuperiorsCharges(myShoppingCartVo.getBoundShopSuperiorsCharges()); + orderGood.setBoundShopSuperiorsPoints(myShoppingCartVo.getBoundShopSuperiorsPoints()); + orderGoodService.save(orderGood); + } + + //开始构建支付数据 + //现金支付 + paymentMoney = paymentMoney.add(expressFee).setScale(2, RoundingMode.HALF_EVEN); + if(1 == shoppingCartPayment.getPaymentType()){ + //调起微信支付 TODO 待完善 + + + + } + //账户余额 + if(2 == shoppingCartPayment.getPaymentType()){ + BigDecimal totalRedPacketAmount = appUser.getTotalRedPacketAmount(); + BigDecimal totalDistributionAmount = appUser.getTotalDistributionAmount(); + BigDecimal balance = appUser.getBalance(); + if(paymentMoney.compareTo(totalRedPacketAmount) <= 0){ + totalRedPacketAmount = totalRedPacketAmount.subtract(paymentMoney); + balance = balance.subtract(paymentMoney); + appUser.setTotalRedPacketAmount(totalRedPacketAmount); + appUser.setBalance(balance); + }else{ + paymentMoney = paymentMoney.subtract(totalRedPacketAmount); + totalRedPacketAmount = BigDecimal.ZERO; + if(paymentMoney.compareTo(totalDistributionAmount) <= 0){ + totalDistributionAmount = totalDistributionAmount.subtract(paymentMoney); + balance = balance.subtract(paymentMoney); + appUser.setTotalRedPacketAmount(totalRedPacketAmount); + appUser.setTotalDistributionAmount(totalDistributionAmount); + appUser.setBalance(balance); + }else{ + paymentMoney = paymentMoney.subtract(totalDistributionAmount); + totalDistributionAmount = BigDecimal.ZERO; + balance = balance.subtract(paymentMoney); + appUser.setTotalRedPacketAmount(totalRedPacketAmount); + appUser.setTotalDistributionAmount(totalDistributionAmount); + appUser.setBalance(balance); + } + } + //构建积分流水记录 + if(earnPoint > 0){ + appUser.setShopPoint(appUser.getShopPoint() + earnPoint); + appUser.setLavePoint(appUser.getLavePoint() + earnPoint); + + 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()); + userPointClient.saveUserPoint(userPoint); + } + appUserClient.editAppUserById(appUser); + //构建余额明细变动记录 + BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord(); + balanceChangeRecord.setAppUserId(appUser.getId()); + 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()); + balanceChangeRecordClient.saveBalanceChangeRecord(balanceChangeRecord); + //修改订支付状态 + order.setPayStatus(2); + orderService.updateById(order); + //删除购物车数据 + this.removeBatchByIds(ids); + } + //积分支付 + if(3 == shoppingCartPayment.getPaymentType()){ + Integer lavePoint = appUser.getLavePoint(); + appUser.setLavePoint(lavePoint - orderPoint); + appUser.setShopPoint(appUser.getShopPoint() + earnPoint); + appUser.setLavePoint(appUser.getLavePoint() + earnPoint); + appUserClient.editAppUserById(appUser); + //构建积分流水记录 + UserPoint userPoint = new UserPoint(); + userPoint.setType(4); + userPoint.setHistoricalPoint(lavePoint); + userPoint.setVariablePoint(orderPoint); + userPoint.setBalance(appUser.getLavePoint()); + userPoint.setCreateTime(LocalDateTime.now()); + userPoint.setAppUserId(appUser.getId()); + userPoint.setObjectId(order.getId()); + userPointClient.saveUserPoint(userPoint); + if(earnPoint > 0){ + 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()); + userPointClient.saveUserPoint(userPoint); + } + //修改订支付状态 + order.setPayStatus(2); + orderService.updateById(order); + //删除购物车数据 + this.removeBatchByIds(ids); + } + return R.ok(); + } + + + public String getNumber(Integer size){ + String str = ""; + for (Integer i = 0; i < size; i++) { + str += Double.valueOf(Math.random() * 10).intValue(); + } + return str; } } diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/ConfirmOrder.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/ConfirmOrder.java index 7382984..b68c2f0 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/ConfirmOrder.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/ConfirmOrder.java @@ -11,10 +11,12 @@ @Data @ApiModel public class ConfirmOrder { - @ApiModelProperty(value = "购物商品id JSON", required = true) + @ApiModelProperty(value = "购物车数据id,数量 JSON[{id:1212,num:2}]", required = true) private String goodsJson; @ApiModelProperty(value = "支付方式(1=现金,2=积分)", required = true) private Integer paymentType; @ApiModelProperty(value = "核销门店id", required = true) private Integer shopId; + @ApiModelProperty(value = "商品类型(1=服务商品,2=单品商品)", required = true) + private Integer type; } diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/ConfirmOrderVo.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/ConfirmOrderVo.java index f48ea43..dabda03 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/ConfirmOrderVo.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/ConfirmOrderVo.java @@ -1,6 +1,8 @@ package com.ruoyi.order.vo; import com.ruoyi.account.api.model.UserAddress; +import com.ruoyi.account.api.vo.CouponInfoVo; +import com.ruoyi.account.api.vo.PaymentUserCouponVo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -31,14 +33,18 @@ private Integer earnPoint; @ApiModelProperty("支付金额") private BigDecimal payMoney; - @ApiModelProperty("订单总金额") + @ApiModelProperty("订单总积分") private Integer orderPoint; @ApiModelProperty("剩余积分") private Integer residualPoint; @ApiModelProperty("收货地址") private UserAddress userAddress; + @ApiModelProperty("快递费") + private BigDecimal expressFee; @ApiModelProperty("支付方式(1=现金,2=积分)") private Integer paymentType; + @ApiModelProperty("活动是否可以和优惠券同时使用") + private Boolean useSimultaneously; @ApiModelProperty("优惠券列表") - private List<CouponInfoVo> coupon; + private List<PaymentUserCouponVo> coupon; } diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/MyShoppingCartVo.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/MyShoppingCartVo.java index bc3d266..77ba777 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/MyShoppingCartVo.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/MyShoppingCartVo.java @@ -4,6 +4,8 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.math.BigDecimal; + /** * @author zhibing.pu * @Date 2024/11/25 11:51 @@ -13,12 +15,16 @@ public class MyShoppingCartVo { @ApiModelProperty("数据id") private Long id; + @ApiModelProperty("商品id") + private Integer goodsId; @ApiModelProperty("封面图") private String homePicture; @ApiModelProperty("商品名称") private String name; - @ApiModelProperty("售价") - private String sellingPrice; + @ApiModelProperty("售价现金") + private BigDecimal cash; + @ApiModelProperty("售价积分") + private Integer point; @ApiModelProperty("原价") private String originalPrice; @ApiModelProperty("购买数量") @@ -27,4 +33,56 @@ private Long endTime; @ApiModelProperty("是否可核销(0=否,1=是)") private Boolean verifiable; + @ApiModelProperty("是否超出限购数量") + private Boolean purchaseLimit; + @ApiModelProperty("现金支付") + private Boolean cashPayment; + @ApiModelProperty("积分支付") + private Boolean pointPayment; + @ApiModelProperty("配送方式(1=自提,2=快递)") + private Integer distributionMode; + /** + * 可获得消费积分 + */ + private Integer earnSpendingPoints; + /** + * 上级获得分佣金额 + */ + private BigDecimal superiorSubcommission; + /** + * 上级获得返佣积分 + */ + private Integer superiorRebatePoints; + /** + * 获取返佣积分上级类型(1=直推上级,2=直帮上级) + */ + private Integer superiorType; + /** + * 核销门店可获得服务费 + */ + private BigDecimal servuceShopCharges; + /** + * 核销门店可获得服务积分 + */ + private Integer servuceShopPoints; + /** + * 技师可获得服务积分 + */ + private Integer technicianPoints; + /** + * 绑定门店可获得分佣金额 + */ + private BigDecimal boundShopCharges; + /** + * 绑定门店可获得返佣积分 + */ + private Integer boundShopPoints; + /** + * 绑定门店上级门店可获得分佣金额 + */ + private BigDecimal boundShopSuperiorsCharges; + /** + * 绑定门店上级门店可获得返佣积分 + */ + private Integer boundShopSuperiorsPoints; } diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/ShoppingCartPayment.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/ShoppingCartPayment.java index 02db9f0..e4e3a0a 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/ShoppingCartPayment.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/ShoppingCartPayment.java @@ -11,12 +11,16 @@ @Data @ApiModel public class ShoppingCartPayment { - @ApiModelProperty(value = "购物商品id JSON", required = true) + @ApiModelProperty(value = "购物车数据id,数量 JSON[{id:1212,num:2}]", required = true) private String goodsJson; - @ApiModelProperty(value = "支付方式(1=现金,2=积分)", required = true) + @ApiModelProperty(value = "支付方式(1=微信,2=账户余额,3=积分)", required = true) private Integer paymentType; @ApiModelProperty(value = "核销门店id", required = true) private Integer shopId; @ApiModelProperty(value = "优惠券id", required = false) - private String userCouponId; + private Long userCouponId; + @ApiModelProperty(value = "配送方式(1=自提,2=快递)", required = false) + private Integer distributionMode; + @ApiModelProperty(value = "配送地址id", required = false) + private Integer userAddressId; } diff --git a/ruoyi-service/ruoyi-other/pom.xml b/ruoyi-service/ruoyi-other/pom.xml index 0bef49f..2ee7e3b 100644 --- a/ruoyi-service/ruoyi-other/pom.xml +++ b/ruoyi-service/ruoyi-other/pom.xml @@ -114,7 +114,7 @@ <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> - <version>3.5.2</version> + <version>3.5.4</version> </dependency> <dependency> @@ -132,6 +132,10 @@ <version>RELEASE</version> <scope>compile</scope> </dependency> + <dependency> + <groupId>com.github.pagehelper</groupId> + <artifactId>pagehelper-spring-boot-starter</artifactId> + </dependency> </dependencies> <build> diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/BannerController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/BannerController.java index 5fe3a69..bb53a14 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/BannerController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/BannerController.java @@ -32,8 +32,8 @@ @ApiOperation(value = "banner列表", tags = {"小程序-banner"}) public R<List<Banner>> list(String name, Integer jumpType, Integer position){ List<Banner> list = bannerService.lambdaQuery().like(StringUtils.isNotEmpty(name), Banner::getName, name) - .eq(Banner::getJumpType, jumpType) - .eq(Banner::getPosition, position) + .eq(jumpType!=null,Banner::getJumpType, jumpType) + .eq(position!=null,Banner::getPosition, position) .list(); return R.ok(list); } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/BaseSettingController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/BaseSettingController.java index 32ea9cf..7f360cb 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/BaseSettingController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/BaseSettingController.java @@ -1,8 +1,12 @@ package com.ruoyi.other.controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.other.api.domain.BaseSetting; +import com.ruoyi.other.service.BaseSettingService; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; /** * <p> @@ -16,5 +20,24 @@ @RequestMapping("/base-setting") public class BaseSettingController { + @Resource + private BaseSettingService baseSettingService; + + + /** + * 获取基础配置 + * @param id + * @return + */ + @ResponseBody + @PostMapping("/getBaseSetting") + public R<BaseSetting> getBaseSetting(@RequestParam("id") Integer id){ + BaseSetting baseSetting = baseSettingService.getById(id); + return R.ok(baseSetting); + } + + + + } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/CouponInfoController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/CouponInfoController.java index 961b1c4..6c9c0cd 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/CouponInfoController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/CouponInfoController.java @@ -13,6 +13,13 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.other.api.domain.CouponInfo; +import com.ruoyi.other.service.CouponInfoService; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.List; import javax.annotation.Resource; import java.time.LocalDateTime; @@ -76,5 +83,19 @@ } } + + + /** + * 根据id获取优惠券数据 + * @param ids + * @return + */ + @ResponseBody + @PostMapping("/getCouponInfoList") + public R<List<CouponInfo>> getCouponInfoList(@RequestParam("ids") List<Integer> ids){ + List<CouponInfo> couponInfos = couponInfoService.listByIds(ids); + return R.ok(couponInfos); + } + } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsCategoryController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsCategoryController.java index 3f1dfcc..a63bd12 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsCategoryController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsCategoryController.java @@ -34,7 +34,7 @@ @Resource private GoodsCategoryService goodsCategoryService; - @PostMapping("/index/list") + @GetMapping("/index/list") @ApiOperation(value = "商品分类", tags = {"小程序-首页"}) public R<List<GoodsCategory>> indexlist(){ List<GoodsCategory> indexlist = goodsCategoryService.lambdaQuery() diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsController.java index aabd51b..91ea840 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsController.java @@ -74,5 +74,18 @@ return R.ok(list); } + + /** + * 根据id获取商品信息 + * @param id + * @return + */ + @ResponseBody + @PostMapping("/getGoodsById") + public R<Goods> getGoodsById(@RequestParam("id") Integer id){ + Goods goods = goodsService.getById(id); + return R.ok(goods); + } + } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsShopController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsShopController.java index 4511634..0578e20 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsShopController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsShopController.java @@ -4,10 +4,12 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.ruoyi.common.core.domain.R; import com.ruoyi.other.api.domain.GoodsShop; +import com.ruoyi.other.api.vo.GetGoodsShopByGoodsIds; import com.ruoyi.other.service.GoodsShopService; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import java.util.List; /** * <p> @@ -39,5 +41,16 @@ } + /** + * 根据商品id集合和门店id查询数据 + * @param goodsIds + * @return + */ + @ResponseBody + @PostMapping("/getGoodsShopByGoodsIds") + public R<List<GoodsShop>> getGoodsShopByGoodsIds(@RequestBody GetGoodsShopByGoodsIds goodsIds) { + List<GoodsShop> list = goodsShopService.list(new LambdaQueryWrapper<GoodsShop>().eq(GoodsShop::getShopId, goodsIds.getShopId()).in(GoodsShop::getGoodsId, goodsIds.getGoodsIds())); + return R.ok(list); + } } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/OrderActivityInfoController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/OrderActivityInfoController.java index 5ca965f..d94fa02 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/OrderActivityInfoController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/OrderActivityInfoController.java @@ -1,8 +1,13 @@ package com.ruoyi.other.controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.other.api.domain.OrderActivityInfo; +import com.ruoyi.other.service.OrderActivityInfoService; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; /** * <p> @@ -16,5 +21,23 @@ @RequestMapping("/order-activity-info") public class OrderActivityInfoController { + @Resource + private OrderActivityInfoService orderActivityInfoService; + + + /** + * 获取当前生效的活动 + * @param vip + * @return + */ + @ResponseBody + @PostMapping("/getNowOrderActivityInfo") + public R<OrderActivityInfo> getNowOrderActivityInfo(@RequestParam("vip") Integer vip){ + OrderActivityInfo one = orderActivityInfoService.getOne(new LambdaQueryWrapper<OrderActivityInfo>().eq(OrderActivityInfo::getDelFlag, 0) + .last(" and now() between start_time and end_time and FIND_IN_SET(" + vip + ", vip_ids) limit 0, 1")); + return R.ok(one); + } + + } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/SeckillActivityInfoController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/SeckillActivityInfoController.java index a57807b..e2a2d77 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/SeckillActivityInfoController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/SeckillActivityInfoController.java @@ -11,6 +11,8 @@ import com.ruoyi.other.api.vo.GetSeckillActivityInfo; import com.ruoyi.other.service.GoodsSeckillService; import com.ruoyi.other.service.SeckillActivityInfoService; +import com.ruoyi.other.vo.SeckillActivityDetailVO; +import com.ruoyi.other.vo.SeckillActivityVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.*; @@ -49,10 +51,10 @@ */ @GetMapping("/list") @ApiOperation(value = "秒杀活动列表",tags = {"小程序-商城-首页-秒杀活动列表"}) - public AjaxResult list(Goods goods) + public R<List<SeckillActivityVO>> list(Goods goods) { startPage(); - return AjaxResult.success(seckillActivityInfoService.listSeckillActivity(goods)); + return R.ok(seckillActivityInfoService.listSeckillActivity(goods)); } /** @@ -60,16 +62,14 @@ */ @GetMapping("/detail/{id}") @ApiOperation(value = "秒杀活动详情", tags = {"小程序-商城-首页-秒杀活动列表-秒杀活动详情"}) - public AjaxResult detail(@PathVariable("id") Integer id) + public R<SeckillActivityDetailVO> detail(@PathVariable("id") Integer id) { - return AjaxResult.success(seckillActivityInfoService.detail(id)); + return R.ok(seckillActivityInfoService.detail(id)); } /** * 根据商品id和会员等级获取对应的秒杀活动 - * @param info - * @return */ @PostMapping("/getSeckillActivityInfo") public R<GoodsSeckill> getSeckillActivityInfo(@RequestBody GetSeckillActivityInfo info){ diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java index 5159c40..130409a 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java @@ -6,8 +6,10 @@ import com.ruoyi.account.api.model.AppUser; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.web.controller.BaseController; +import com.ruoyi.common.core.web.domain.AjaxResult; import com.ruoyi.common.security.utils.SecurityUtils; import com.ruoyi.other.api.domain.Shop; +import com.ruoyi.other.api.domain.Technician; import com.ruoyi.other.enums.ShopStatus; import com.ruoyi.other.service.ShopService; import com.ruoyi.other.service.TechnicianService; @@ -114,5 +116,31 @@ // todo 待完善 pu return R.ok(); } + + + /** + * 根据id获取门店信息 + * @param id + * @return + */ + @ResponseBody + @PostMapping("/getShopById") + public R<Shop> getShopById(@RequestParam("id") Integer id){ + Shop shop = shopService.getById(id); + return R.ok(shop); + } + + + /** + * 根据店铺管理员电话获取门店数据 + * @param phone + * @return + */ + @ResponseBody + @PostMapping("/getShopByPhone") + public R<Shop> getShopByPhone(@RequestParam("phone") String phone){ + Shop one = shopService.getOne(new LambdaQueryWrapper<Shop>().eq(Shop::getPhone, phone).eq(Shop::getDelFlag, 0).eq(Shop::getStatus, 1)); + return R.ok(one); + } } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/SystemConfigController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/SystemConfigController.java index 21dd4a3..8a05bbc 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/SystemConfigController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/SystemConfigController.java @@ -9,6 +9,8 @@ import com.ruoyi.other.api.dto.StartPageSetDto; import com.ruoyi.other.service.SystemConfigService; import org.springframework.web.bind.annotation.*; +import io.swagger.annotations.Api; +import org.springframework.web.bind.annotation.*; import io.swagger.annotations.ApiOperation; import javax.annotation.Resource; @@ -39,7 +41,7 @@ systemConfigService.save(systemConfig); return R.ok(); } - @PostMapping("/index/detail") + @GetMapping("/index/detail") @ApiOperation(value = "宣传图片-公司简介", tags = {"后台-广告管理-首页配置","小程序-首页"}) public R<IndexConfigSetDto> detail(){ SystemConfig one = systemConfigService.lambdaQuery().eq(SystemConfig::getType, 2).one(); @@ -50,6 +52,19 @@ return R.ok(indexConfigSetDto); } + + + /** + * 根据类型获取系统配置 + * @param type + * @return + */ + @ResponseBody + @PostMapping("/getSystemConfig") + public R<SystemConfig> getSystemConfig(@RequestParam("type") Integer type){ + SystemConfig one = systemConfigService.lambdaQuery().eq(SystemConfig::getType, type).last("limit 1").one(); + return R.ok(one); + } @PostMapping("/index/start") @ApiOperation(value = "宣传图片-公司简介", tags = {"小程序-启动页"}) diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TechnicianSubscribeController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TechnicianSubscribeController.java index 9b6010f..f28c7ca 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TechnicianSubscribeController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TechnicianSubscribeController.java @@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.web.controller.BaseController; import com.ruoyi.common.core.web.page.TableDataInfo; @@ -19,7 +20,7 @@ /** * <p> - * 前端控制器 + * 前端控制器 * </p> * * @author luodangjia @@ -38,10 +39,10 @@ @GetMapping("/list") @ApiOperation(value = "预约列表", notes = "预约列表", tags = {"小程序-个人中心-门店管理-预约列表"}) public TableDataInfo list(@ApiParam(value = "状态") @RequestParam Integer status, - @ApiParam(value = "门店id") @RequestParam Long shopId){ + @ApiParam(value = "门店id") @RequestParam Long shopId) { startPage(); List<TechnicianSubscribeVO> list = technicianSubscribeService - .getTechnicianSubscribeByUserAndShop(SecurityUtils.getUserId(),shopId); + .getTechnicianSubscribeByUserAndShop(SecurityUtils.getUserId(), shopId); return getDataTable(list); } @@ -50,8 +51,8 @@ */ @PostMapping("/subscribe") @ApiOperation(value = "预约技师", notes = "预约技师", tags = {"小程序-个人中心-门店管理-预约列表-预约技师"}) - public R<Void> subscribe(@RequestBody TechnicianSubscribe technicianSubscribe){ - technicianSubscribeService.subscribe(technicianSubscribe); + public R<Void> subscribe(@RequestBody TechnicianSubscribe technicianSubscribe) { + technicianSubscribeService.subscribe(technicianSubscribe, technicianSubscribe.getTechnicianId()); return R.ok(); } @@ -60,12 +61,12 @@ */ @GetMapping("/cancel") @ApiOperation(value = "取消服务", notes = "取消服务", tags = {"小程序-个人中心-门店管理-预约列表-取消服务"}) - public R<Void> cancel(@ApiParam(value = "预约id") @RequestParam Long id){ + public R<Void> cancel(@ApiParam(value = "预约id") @RequestParam Long id) { TechnicianSubscribe subscribe = technicianSubscribeService.getOne(new LambdaQueryWrapper<TechnicianSubscribe>() .eq(TechnicianSubscribe::getId, id) .eq(TechnicianSubscribe::getStatus, 0)); - if (null == subscribe){ + if (null == subscribe) { return R.fail("不满足取消条件"); } subscribe.setStatus(2); @@ -73,13 +74,30 @@ return R.ok(); } + /** + * 更新技师预约状态 + * + * @param status + */ + @PutMapping("/updateStatus") + @ApiOperation(value = "更新技师预约状态", notes = "更新技师预约状态", tags = {"后台-技师预约管理-更新技师预约状态"}) + public R<Void> updateStatus(@ApiParam @RequestParam Integer status, @ApiParam @RequestParam Long subscribeId) { + boolean update = technicianSubscribeService.update(new LambdaUpdateWrapper<TechnicianSubscribe>() + .eq(TechnicianSubscribe::getId, subscribeId) + .set(TechnicianSubscribe::getStatus, status)); + if (!update) { + return R.fail("更新失败"); + } + return R.ok(); + } + @GetMapping("/home/list") @ApiOperation(value = "列表", notes = "列表", tags = {"小程序-个人中心-我的预约"}) - public TableDataInfo homelist(@ApiParam(value = "状态 0=待服务,1=已服务,2=已取消 4 已到期") @RequestParam Integer status){ + public TableDataInfo homelist(@ApiParam(value = "状态 0=待服务,1=已服务,2=已取消 4 已到期") @RequestParam Integer status) { startPage(); List<TechnicianSubscribeVO> list = technicianSubscribeService - .getTechnicianSubscribeByUser(SecurityUtils.getUserId(),status); + .getTechnicianSubscribeByUser(SecurityUtils.getUserId(), status); return getDataTable(list); } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/VipSettingController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/VipSettingController.java index 51d6b2f..2f20fc2 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/VipSettingController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/VipSettingController.java @@ -10,16 +10,13 @@ import com.ruoyi.other.service.VipGoodService; import com.ruoyi.other.service.VipSettingService; import io.swagger.annotations.ApiOperation; -import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.*; import com.ruoyi.common.core.domain.R; import com.ruoyi.other.api.domain.VipSetting; import com.ruoyi.other.service.VipSettingService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; import java.util.List; @@ -92,7 +89,7 @@ List<VipGood> list = vipGoodService.lambdaQuery().eq(VipGood::getVipId, id).list(); for (VipGood vipGood : list) { //挨个判断是否购买商品 - + } @@ -110,7 +107,7 @@ @GetMapping("getVipSettingById") @ApiOperation(value = "获取会员设置") - public R<VipSetting> getVipSettingById(@ApiParam(value = "会员id") Integer id){ + public R<VipSetting> getVipSettingById(@ApiParam(value = "会员id") @RequestParam Integer id){ return R.ok(vipSettingService.getById(id)); } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/enums/TechnicianStatus.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/enums/TechnicianStatus.java new file mode 100644 index 0000000..3edfa0c --- /dev/null +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/enums/TechnicianStatus.java @@ -0,0 +1,26 @@ +package com.ruoyi.other.enums; + +import lombok.Getter; + +@Getter +public enum TechnicianStatus { + UNSUBSCRIBE(0, "待服务"), + SERVE(1, "已服务"), + CANCEL(2, "已取消"); + private final Integer code; + private final String message; + + TechnicianStatus(Integer code, String message) { + this.code = code; + this.message = message; + } + + public static String getMessage(Integer code) { + for (TechnicianStatus value : TechnicianStatus.values()) { + if (value.getCode().equals(code)) { + return value.getMessage(); + } + } + return null; + } +} diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/ShopMapper.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/ShopMapper.java index 9255a70..be480ad 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/ShopMapper.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/ShopMapper.java @@ -4,6 +4,7 @@ import com.ruoyi.other.api.domain.Shop; import com.ruoyi.other.vo.NearbyShopVO; import com.ruoyi.other.vo.ShopDetailVO; +import org.apache.ibatis.annotations.Param; import java.util.List; @@ -17,7 +18,7 @@ */ public interface ShopMapper extends BaseMapper<Shop> { - List<NearbyShopVO> selectNearbyShopList(String longitude, String latitude); + List<NearbyShopVO> selectNearbyShopList(@Param("longitude") String longitude,@Param("latitude") String latitude); ShopDetailVO selectShopDetail(Integer shopId); diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/TechnicianSubscribeService.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/TechnicianSubscribeService.java index b31e9a0..d3796aa 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/TechnicianSubscribeService.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/TechnicianSubscribeService.java @@ -20,7 +20,8 @@ * 查询用于指定门店的相关预约记录 */ List<TechnicianSubscribeVO> getTechnicianSubscribeByUserAndShop(Long userId, Long shopId); + List<TechnicianSubscribeVO> getTechnicianSubscribeByUser(Long userId, Integer status); - void subscribe(TechnicianSubscribe technicianSubscribe); + void subscribe(TechnicianSubscribe technicianSubscribe, Long technicianId); } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TechnicianSubscribeServiceImpl.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TechnicianSubscribeServiceImpl.java index 3220f8c..710c44d 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TechnicianSubscribeServiceImpl.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TechnicianSubscribeServiceImpl.java @@ -1,18 +1,18 @@ package com.ruoyi.other.service.impl; -import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.common.core.exception.ServiceException; +import com.ruoyi.common.redis.annotation.DistributedLock; import com.ruoyi.common.security.utils.SecurityUtils; -import com.ruoyi.other.api.domain.Technician; import com.ruoyi.other.api.domain.TechnicianSubscribe; import com.ruoyi.other.enums.TechnicianErrorCode; +import com.ruoyi.other.enums.TechnicianStatus; import com.ruoyi.other.mapper.TechnicianMapper; import com.ruoyi.other.mapper.TechnicianSubscribeMapper; import com.ruoyi.other.service.TechnicianSubscribeService; import com.ruoyi.other.vo.TechnicianSubscribeVO; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.time.LocalDateTime; @@ -43,26 +43,22 @@ } @Override - @Transactional(rollbackFor = Exception.class) - public void subscribe(TechnicianSubscribe technicianSubscribe) { +// @DistributedLock(lockNamePre = "#technician_subscribe_lock", lockNamePost = "#technicianId") + public void subscribe(TechnicianSubscribe subscribe, Long technicianId) { +// Long count = technicianSubscribeMapper.selectCount(new LambdaQueryWrapper<TechnicianSubscribe>() +// .eq(TechnicianSubscribe::getTechnicianId, technicianId) +// .eq(TechnicianSubscribe::getSubscribeTime, subscribe.getSubscribeTime()) +// .eq(TechnicianSubscribe::getStatus, TechnicianStatus.UNSUBSCRIBE.getCode())); +// if (count > 0) { +// throw new ServiceException("当前时间段已被预约", TechnicianErrorCode.TECHNICIAN_ALREADY_SUBSCRIBED.getCode()); +// } // 创建技师预约单 - Long technicianId = technicianSubscribe.getTechnicianId(); Long userId = SecurityUtils.getUserId(); - TechnicianSubscribe subscribe = new TechnicianSubscribe(); subscribe.setAppUserId(userId); + subscribe.setStatus(TechnicianStatus.UNSUBSCRIBE.getCode()); subscribe.setDelFlag(0); subscribe.setCreateTime(LocalDateTime.now()); technicianSubscribeMapper.insert(subscribe); - // 更新技师状态 - UpdateWrapper<Technician> updateWrapper = new UpdateWrapper<>(); - updateWrapper.eq("id", technicianId); - updateWrapper.eq("subscribe_status", 1); - updateWrapper.eq("status", 2); - updateWrapper.set("subscribe_status", 2); - updateWrapper.set("create_time", LocalDateTime.now()); - int update = technicianMapper.update(null, updateWrapper); - if (update == 0){ - throw new ServiceException("该技师已被预约", TechnicianErrorCode.TECHNICIAN_ALREADY_SUBSCRIBED.getCode()); - } + } } diff --git a/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/SeckillActivityInfoMapper.xml b/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/SeckillActivityInfoMapper.xml index 742f5e8..0703c40 100644 --- a/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/SeckillActivityInfoMapper.xml +++ b/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/SeckillActivityInfoMapper.xml @@ -15,9 +15,9 @@ FROM t_seckill_activity_info tsai LEFT JOIN t_goods tg ON tsai.good_id = tg.id - LEFT JOIN t_goods_seckill tgs ON tgs.goods_id = tg.id + LEFT JOIN t_goods_seckill tgs ON tgs.seckill_activity_info_id = tsai.id WHERE tsai.end_time >= NOW() - <if test="goodsName != null and goodsName != ''"> + <if test="name != null and name != ''"> AND tg.`name` LIKE concat('%',#{goodsName},'%') </if> <if test="goodsCategoryId != null"> @@ -43,7 +43,7 @@ FROM t_seckill_activity_info tsai LEFT JOIN t_goods tg ON tsai.good_id = tg.id - LEFT JOIN t_goods_seckill tgs ON tgs.goods_id = tg.id + LEFT JOIN t_goods_seckill tgs ON tgs.seckill_activity_info_id = tsai.id WHERE tsai.id = #{seckillActivityId} </select> </mapper> \ No newline at end of file -- Gitblit v1.7.1