| | |
| | | public AppUserClient create(Throwable cause) { |
| | | |
| | | return new AppUserClient() { |
| | | @Override |
| | | @Override |
| | | public AppUser getAppUserById(Long id) { |
| | | log.error("根据id获取用户失败:{}", cause.getMessage()); |
| | | throw new RuntimeException("根据id获取用户失败"); |
| | |
| | | |
| | | @TableId("id") |
| | | private Long id; |
| | | @TableField(exist = false) |
| | | private String uid; |
| | | |
| | | |
| | | @ApiModelProperty(value = "用户id") |
| | | @TableField("app_user_id") |
| | |
| | | import com.ruoyi.other.api.domain.VipGood; |
| | | import com.ruoyi.other.api.feignClient.VipGoodClient; |
| | | import org.springframework.cloud.openfeign.FallbackFactory; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | @Override |
| | | public VipGoodClient create(Throwable cause) { |
| | | return new VipGoodClient() { |
| | | @GetMapping("/vip-good/getVipGoodsByVipId") |
| | | @Override |
| | | public R<List<VipGood>> getVipGoodsByVipId(Integer vipId) { |
| | | return R.fail("根据会员id获取会员购买商品失败:" + cause.getMessage()); |
| | |
| | | * @author zhibing.pu |
| | | * @Date 2024/11/28 10:53 |
| | | */ |
| | | @FeignClient(contextId = "GoodsBargainPriceClient", value = ServiceNameConstants.ORDER_SERVICE, fallbackFactory = GoodsBargainPriceClientFallbackFactory.class) |
| | | @FeignClient(contextId = "GoodsBargainPriceClient", value = ServiceNameConstants.OTHER_SERVICE, fallbackFactory = GoodsBargainPriceClientFallbackFactory.class) |
| | | public interface GoodsBargainPriceClient { |
| | | |
| | | |
| | |
| | | * @author zhibing.pu |
| | | * @Date 2024/11/29 10:55 |
| | | */ |
| | | @FeignClient(contextId = "OrderActivityInfoClient", value = ServiceNameConstants.ORDER_SERVICE, fallbackFactory = OrderActivityInfoClientFallbackFactory.class) |
| | | @FeignClient(contextId = "OrderActivityInfoClient", value = ServiceNameConstants.OTHER_SERVICE, fallbackFactory = OrderActivityInfoClientFallbackFactory.class) |
| | | public interface OrderActivityInfoClient { |
| | | |
| | | |
| | |
| | | * 后台订单服务 |
| | | * @author ruoyi |
| | | */ |
| | | @FeignClient(contextId = "OrderClient", value = ServiceNameConstants.ORDER_SERVICE, fallbackFactory = OrderFallbackFactory.class) |
| | | @FeignClient(contextId = "OrderClient", value = ServiceNameConstants.OTHER_SERVICE, fallbackFactory = OrderFallbackFactory.class) |
| | | public interface OrderClient { |
| | | @PostMapping(value = "/management/give/vip") |
| | | public R<List<Long>> getOrderIdsByTechId(@RequestParam("id") Integer id); |
| | |
| | | * @author zhibing.pu |
| | | * @Date 2024/11/28 10:38 |
| | | */ |
| | | @FeignClient(contextId = "SeckillActivityInfoClient", value = ServiceNameConstants.ORDER_SERVICE, fallbackFactory = SeckillActivityInfoClientFallbackFactory.class) |
| | | @FeignClient(contextId = "SeckillActivityInfoClient", value = ServiceNameConstants.OTHER_SERVICE, fallbackFactory = SeckillActivityInfoClientFallbackFactory.class) |
| | | public interface SeckillActivityInfoClient { |
| | | |
| | | |
| | |
| | | * @author zhibing.pu |
| | | * @Date 2024/11/29 10:28 |
| | | */ |
| | | @FeignClient(contextId = "ShopClient", value = ServiceNameConstants.ORDER_SERVICE, fallbackFactory = ShopClientFallbackFactory.class) |
| | | @FeignClient(contextId = "ShopClient", value = ServiceNameConstants.OTHER_SERVICE, fallbackFactory = ShopClientFallbackFactory.class) |
| | | public interface ShopClient { |
| | | |
| | | |
| | |
| | | * @author zhibing.pu |
| | | * @Date 2024/11/29 15:58 |
| | | */ |
| | | @FeignClient(contextId = "SystemConfigClient", value = ServiceNameConstants.ORDER_SERVICE, fallbackFactory = SystemConfigClientFallbackFactory.class) |
| | | @FeignClient(contextId = "SystemConfigClient", value = ServiceNameConstants.OTHER_SERVICE, fallbackFactory = SystemConfigClientFallbackFactory.class) |
| | | public interface SystemConfigClient { |
| | | |
| | | |
| | |
| | | import org.springframework.web.bind.annotation.PutMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | @FeignClient(contextId = "TechnicianClient", value = ServiceNameConstants.ORDER_SERVICE, fallbackFactory = TechnicianClientFallbackFactory.class) |
| | | @FeignClient(contextId = "TechnicianClient", value = ServiceNameConstants.OTHER_SERVICE, fallbackFactory = TechnicianClientFallbackFactory.class) |
| | | public interface TechnicianClient { |
| | | |
| | | @PostMapping("/technician/shop/detail") |
| | |
| | | |
| | | import java.util.List; |
| | | |
| | | @FeignClient(contextId = "VipGoodClient", value = ServiceNameConstants.ORDER_SERVICE, fallbackFactory = VipGoodClientFallbackFactory.class) |
| | | @FeignClient(contextId = "VipGoodClient", value = ServiceNameConstants.OTHER_SERVICE, fallbackFactory = VipGoodClientFallbackFactory.class) |
| | | public interface VipGoodClient { |
| | | |
| | | @GetMapping("/vip-good/getVipGoodsByVipId") |
| | |
| | | com.ruoyi.other.api.factory.SystemConfigClientFallbackFactory |
| | | com.ruoyi.other.api.factory.StoreFallbackFactory |
| | | com.ruoyi.other.api.factory.CouponClientFallbackFactory |
| | | com.ruoyi.other.api.factory.TechnicianClientFallbackFactory |
| | | com.ruoyi.other.api.factory.TechnicianClientFallbackFactory |
| | | com.ruoyi.other.api.factory.PointSettingClientFallbackFactory |
| | | com.ruoyi.other.api.factory.VipGoodClientFallbackFactory |
| | |
| | | <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.alibaba.cloud</groupId> |
| | | <artifactId>spring-cloud-starter-alibaba-seata</artifactId> |
| | | </dependency> |
| | | <!--<dependency>--> |
| | | <!--<groupId>com.alibaba.cloud</groupId>--> |
| | | <!--<artifactId>spring-cloud-starter-alibaba-seata</artifactId>--> |
| | | <!--</dependency>--> |
| | | |
| | | <!-- SpringBoot Actuator --> |
| | | <dependency> |
| | |
| | | @ApiOperation(value = "添加", tags = {"小程序-个人中心首页-我的地址"}) |
| | | public R add(@RequestBody UserAddress userAddress){ |
| | | Long userId = tokenService.getLoginUserApplet().getUserid(); |
| | | |
| | | if (userAddress.getIsDefault()==1){ |
| | | List<UserAddress> list = userAddressService.lambdaQuery().eq(UserAddress::getAppUserId, userId).list(); |
| | | for (UserAddress userAddress1 : list) { |
| | | userAddress1.setIsDefault(0); |
| | | } |
| | | userAddressService.updateBatchById(list); |
| | | } |
| | | |
| | | userAddress.setAppUserId(userId); |
| | | userAddressService.save(userAddress); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @ResponseBody |
| | | @GetMapping("/list") |
| | | @ApiOperation(value = "列表", tags = {"小程序-个人中心首页-我的地址"}) |
| | | public R list(){ |
| | | Long userId = tokenService.getLoginUserApplet().getUserid(); |
| | | List<UserAddress> list = userAddressService.lambdaQuery().eq(UserAddress::getAppUserId, userId).orderByDesc(UserAddress::getIsDefault).list(); |
| | | for (UserAddress userAddress : list) { |
| | | userAddress.setUid(userAddress.getId().toString()); |
| | | } |
| | | return R.ok(list); |
| | | } |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/edit") |
| | | @ApiOperation(value = "编辑", tags = {"小程序-个人中心首页-我的地址"}) |
| | | public R edit(@RequestBody UserAddress userAddress){ |
| | | Long userId = tokenService.getLoginUserApplet().getUserid(); |
| | | if (userAddress.getIsDefault()==1){ |
| | | List<UserAddress> list = userAddressService.lambdaQuery().eq(UserAddress::getAppUserId, userId).list(); |
| | | for (UserAddress userAddress1 : list) { |
| | | userAddress1.setIsDefault(0); |
| | | } |
| | | userAddressService.updateBatchById(list); |
| | | } |
| | | userAddressService.updateById(userAddress); |
| | | return R.ok(); |
| | | } |
| | | @ResponseBody |
| | | @PostMapping("/delete") |
| | | @GetMapping("/delete") |
| | | @ApiOperation(value = "删除", tags = {"小程序-个人中心首页-我的地址"}) |
| | | public R edit(@RequestParam Integer id){ |
| | | public R edit(@RequestParam String id){ |
| | | userAddressService.removeById(id); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/set") |
| | | @GetMapping("/set") |
| | | @ApiOperation(value = "设为默认", tags = {"小程序-个人中心首页-我的地址"}) |
| | | public R set(@RequestParam Integer id){ |
| | | public R set(@RequestParam String id){ |
| | | Long userId = tokenService.getLoginUserApplet().getUserid(); |
| | | List<UserAddress> list = userAddressService.lambdaQuery().eq(UserAddress::getAppUserId, userId).list(); |
| | | for (UserAddress userAddress : list) { |
| | |
| | | |
| | | |
| | | |
| | | @PostMapping("/mine/list") |
| | | @GetMapping("/mine/list") |
| | | @ApiOperation(value = "已领取列表", tags = {"小程序-个人中心-优惠劵"}) |
| | | public R<Page<UserCoupon>> minelist(@RequestParam Integer pageNum, @RequestParam Integer pageSize, @ApiParam("1未使用2已使用3已过期") Integer status) { |
| | | Long userid = tokenService.getLoginUserApplet().getUserid(); |
| | | Page<UserCoupon> page = userCouponService.lambdaQuery() |
| | | .isNull(status==1||status==3,UserCoupon::getUseTime) |
| | | .isNotNull(status == 2,UserCoupon::getUseTime) |
| | | .lt(status == 3,UserCoupon::getEndTime, LocalDateTime.now()) |
| | | .eq(UserCoupon::getAppUserId, userid).page(Page.of(pageNum, pageSize)); |
| | | .isNull(status!=null&&(status==1||status==3),UserCoupon::getUseTime) |
| | | .isNotNull(status!=null&&status==2,UserCoupon::getUseTime) |
| | | .lt(status!=null&&status==3,UserCoupon::getEndTime, LocalDateTime.now()) |
| | | .eq(UserCoupon::getAppUserId, userid).page(Page.of(pageNum-1, pageSize)); |
| | | for (UserCoupon record : page.getRecords()) { |
| | | CouponInfo data = couponClient.detail(record.getCouponId()).getData(); |
| | | CouponInfoVo vo = new CouponInfoVo(); |
| | |
| | | } |
| | | |
| | | |
| | | @PostMapping("/get") |
| | | @GetMapping("/get") |
| | | @ApiOperation(value = "领取或者兑换优惠券", tags = {"小程序-个人中心-优惠劵"}) |
| | | public R<Page<UserCoupon>> get(@RequestParam Integer couponId) { |
| | | |
| | |
| | | // .eq(AppUser::getInviteUserId, loginUserApplet.getUserid()) |
| | | // .eq(AppUser::getVipId)); |
| | | |
| | | |
| | | return null; |
| | | } |
| | | |
| | | |
| | |
| | | walletVO.setAuditAmount(waitAuditList.stream() |
| | | .map(WithdrawalRequests::getWithdrawalAmount) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add)); |
| | | |
| | | walletVO.setBalance(appUser.getBalance()); |
| | | return walletVO; |
| | | } |
| | | |
| | |
| | | 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(null != data){ |
| | | 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(1 == couponInfo.getCouponType() && couponInfo.getConditionAmount().compareTo(goodsMoney) <= 0){ |
| | | couponInfo.setAvailable(true); |
| | | } |
| | | //代金券 |
| | | if(2 == couponInfo.getCouponType() || 3 == couponInfo.getCouponType()){ |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | for (ShoppingCart shoppingCart : list) { |
| | | Goods goods = goodsClient.getGoodsById(shoppingCart.getGoodsId()).getData(); |
| | | MyShoppingCartVo vo = new MyShoppingCartVo(); |
| | | vo.setId(shoppingCart.getId()); |
| | | vo.setId(shoppingCart.getId().toString()); |
| | | vo.setGoodsId(goods.getId()); |
| | | vo.setHomePicture(goods.getHomePagePicture()); |
| | | vo.setName(goods.getName()); |
| | |
| | | //获取支付价格 |
| | | Price price = getPrice(appUser, shoppingCart.getGoodsId(), shopId); |
| | | if(null == price){ |
| | | price = new Price(); |
| | | //使用商品的基础价格 |
| | | price.setCash(1 == goods.getCashPayment() ? goods.getSellingPrice() : null); |
| | | price.setPoint(1 == goods.getPointPayment() ? goods.getIntegral() : null); |
| | |
| | | } |
| | | } |
| | | //判断运费支付是否足够 |
| | | if(2 == shoppingCartPayment.getFreightPaymentType() && expressFee.compareTo(BigDecimal.ZERO) > 0){ |
| | | if(null != shoppingCartPayment.getFreightPaymentType() && 2 == shoppingCartPayment.getFreightPaymentType() && expressFee.compareTo(BigDecimal.ZERO) > 0){ |
| | | BigDecimal balance = appUser.getBalance(); |
| | | if(balance.compareTo(expressFee) < 0){ |
| | | return R.fail("账户余额不足"); |
| | |
| | | @ApiModel("购物车") |
| | | public class MyShoppingCartVo { |
| | | @ApiModelProperty("数据id") |
| | | private Long id; |
| | | private String id; |
| | | @ApiModelProperty("商品id") |
| | | private Integer goodsId; |
| | | @ApiModelProperty("封面图") |
| | |
| | | @Data |
| | | public class OrderVO { |
| | | @ApiModelProperty(value = "订单id") |
| | | private Integer id; |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "订单编号") |
| | | private String orderNumber; |
| | |
| | | @ApiModel |
| | | public class SetGoodsNumber { |
| | | @ApiModelProperty(value = "购物车数据id", required = true) |
| | | private Integer id; |
| | | private Long id; |
| | | @ApiModelProperty(value = "修改数量", required = true) |
| | | private Integer number; |
| | | } |
| | |
| | | <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.alibaba.cloud</groupId> |
| | | <artifactId>spring-cloud-starter-alibaba-seata</artifactId> |
| | | </dependency> |
| | | <!--<dependency>--> |
| | | <!--<groupId>com.alibaba.cloud</groupId>--> |
| | | <!--<artifactId>spring-cloud-starter-alibaba-seata</artifactId>--> |
| | | <!--</dependency>--> |
| | | |
| | | <!-- SpringBoot Actuator --> |
| | | <dependency> |
| | |
| | | } |
| | | |
| | | |
| | | @PostMapping("/gift/list") |
| | | @GetMapping("/gift/list") |
| | | @ApiOperation(value = "待领取列表", tags = {"小程序-个人中心-优惠劵"}) |
| | | public R<List<CouponInfo>> giftlist(){ |
| | | Long userid = tokenService.getLoginUserApplet().getUserid(); |
| | |
| | | @Resource |
| | | private VipGoodService vipGoodService; |
| | | |
| | | @GetMapping("/list") |
| | | public R<List<VipSetting>> list() { |
| | | @GetMapping("/info") |
| | | @ApiOperation(value = "获取各级会员信息", tags = {"小程序-个人中心首页", "小程序-会员中心"}) |
| | | public R<List<VipSetting>> info() { |
| | | List<VipSetting> list = vipSettingService.list(); |
| | | return R.ok(list); |
| | | } |