ruoyi-api/ruoyi-api-order/src/main/java/model/ShoppingCart.java
@@ -24,7 +24,7 @@ private Long appUserId; @ApiModelProperty("商品id") @TableField("goods_id") private Long goodsId; private Integer goodsId; @ApiModelProperty("数量") private Integer number; } ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/GoodsArea.java
New file @@ -0,0 +1,128 @@ package com.ruoyi.other.api.domain; 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; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import java.io.Serializable; import java.math.BigDecimal; /** * <p> * * </p> * * @author luodangjia * @since 2024-11-20 */ @Data @EqualsAndHashCode(callSuper = false) @TableName("t_goods_area") @ApiModel(value="GoodsArea对象", description="") public class GoodsArea implements Serializable { private static final long serialVersionUID = 1L; @ApiModelProperty(value = "主键") @TableId(value = "id", type = IdType.NONE) private Long id; @ApiModelProperty(value = "商品id") @TableField("goods_id") private Integer goodsId; @ApiModelProperty(value = "省") @TableField("province") private String province; @ApiModelProperty(value = "省编号") @TableField("province_code") private String provinceCode; @ApiModelProperty(value = "市") @TableField("city") private String city; @ApiModelProperty(value = "市编号") @TableField("city_code") private String cityCode; @ApiModelProperty(value = "区") @TableField("districts") private String districts; @ApiModelProperty(value = "区编号") @TableField("districts_code") private String districtsCode; @ApiModelProperty(value = "会员级别(1=普通会员,2=黄金会员,3=钻石会员,4=准代理,5=代理,6=总代,7=合伙人)") @TableField("vip") private Integer vip; @ApiModelProperty(value = "现金支付(0=否,1=是)") @TableField("cash_payment") private Integer cashPayment; @ApiModelProperty(value = "积分支付(0=否,1=是)") @TableField("point_payment") private Integer pointPayment; @ApiModelProperty(value = "基础售价") @TableField("selling_price") private BigDecimal sellingPrice; @ApiModelProperty(value = "基础积分") @TableField("integral") private Integer integral; @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; } ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/GoodsAreaClientFallbackFactory.java
New file @@ -0,0 +1,25 @@ package com.ruoyi.other.api.factory; import com.ruoyi.common.core.domain.R; import com.ruoyi.other.api.domain.GoodsArea; import com.ruoyi.other.api.feignClient.GoodsAreaClient; import org.springframework.cloud.openfeign.FallbackFactory; /** * @author zhibing.pu * @Date 2024/11/27 20:29 */ public class GoodsAreaClientFallbackFactory implements FallbackFactory<GoodsAreaClient> { @Override public GoodsAreaClient create(Throwable cause) { return new GoodsAreaClient() { @Override public R<GoodsArea> getGoodsArea(GoodsArea area) { return R.fail("根据省市区获取地区价格配置失败:" + cause.getMessage()); } }; } } ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/GoodsShopClientFallbackFactory.java
New file @@ -0,0 +1,24 @@ package com.ruoyi.other.api.factory; import com.ruoyi.common.core.domain.R; import com.ruoyi.other.api.domain.GoodsShop; import com.ruoyi.other.api.feignClient.GoodsShopClient; import org.springframework.cloud.openfeign.FallbackFactory; /** * @author zhibing.pu * @Date 2024/11/27 20:29 */ public class GoodsShopClientFallbackFactory implements FallbackFactory<GoodsShopClient> { @Override public GoodsShopClient create(Throwable cause) { return new GoodsShopClient() { @Override public R<GoodsShop> getGoodsShop(GoodsShop goodsShop) { return R.fail("获取商品门店关系数据失败:" + cause.getMessage()); } }; } } ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/GoodsVipClientFallbackFactory.java
New file @@ -0,0 +1,27 @@ package com.ruoyi.other.api.factory; import com.ruoyi.common.core.domain.R; import com.ruoyi.other.api.domain.GoodsArea; import com.ruoyi.other.api.domain.GoodsVip; import com.ruoyi.other.api.feignClient.GoodsVipClient; import org.springframework.cloud.openfeign.FallbackFactory; /** * @author zhibing.pu * @Date 2024/11/27 20:29 */ public class GoodsVipClientFallbackFactory implements FallbackFactory<GoodsVipClient> { @Override public GoodsVipClient create(Throwable cause) { return new GoodsVipClient() { @Override public R<GoodsVip> getGoodsVip(Integer vip) { return R.fail("获取会员价格配置失败:" + cause.getMessage()); } }; } } ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/GoodsAreaClient.java
New file @@ -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.GoodsArea; import com.ruoyi.other.api.factory.GoodsAreaClientFallbackFactory; 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/11/28 9:38 */ @FeignClient(contextId = "GoodsAreaClient", value = ServiceNameConstants.OTHER_SERVICE, fallbackFactory = GoodsAreaClientFallbackFactory.class) public interface GoodsAreaClient { /** * 根据省市区获取地区价格配置 * @param area * @return */ @PostMapping("/goodsArea/getGoodsArea") R<GoodsArea> getGoodsArea(@RequestBody GoodsArea area); } ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/GoodsShopClient.java
New file @@ -0,0 +1,25 @@ 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.GoodsShop; import com.ruoyi.other.api.factory.GoodsShopClientFallbackFactory; 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/11/27 20:28 */ @FeignClient(contextId = "GoodsShopClient", value = ServiceNameConstants.OTHER_SERVICE, fallbackFactory = GoodsShopClientFallbackFactory.class) public interface GoodsShopClient { /** * 获取商品门店关系数据 * @param goodsShop * @return */ @PostMapping("/goods-shop/getGoodsShop") R<GoodsShop> getGoodsShop(@RequestBody GoodsShop goodsShop); } ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/GoodsVipClient.java
New file @@ -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.GoodsVip; import com.ruoyi.other.api.factory.GoodsVipClientFallbackFactory; 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/28 9:42 */ @FeignClient(contextId = "GoodsVipClient", value = ServiceNameConstants.OTHER_SERVICE, fallbackFactory = GoodsVipClientFallbackFactory.class) public interface GoodsVipClient { /** * 获取会员价格配置 * @param vip * @return */ @PostMapping("/goods-vip/getGoodsVip") R<GoodsVip> getGoodsVip(@RequestParam("vip") Integer vip); } ruoyi-api/ruoyi-api-other/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
@@ -1 +1,4 @@ com.ruoyi.other.api.factory.GoodsClientFallbackFactory com.ruoyi.other.api.factory.GoodsClientFallbackFactory com.ruoyi.other.api.factory.GoodsShopClientFallbackFactory com.ruoyi.other.api.factory.GoodsAreaClientFallbackFactory com.ruoyi.other.api.factory.GoodsVipClientFallbackFactory ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java
@@ -2,12 +2,20 @@ 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.AppUser; import com.ruoyi.common.security.service.TokenService; import com.ruoyi.order.mapper.ShoppingCartMapper; import com.ruoyi.order.service.ShoppingCartService; import com.ruoyi.order.vo.MyShoppingCartVo; import com.ruoyi.other.api.domain.Goods; import com.ruoyi.other.api.domain.GoodsArea; import com.ruoyi.other.api.domain.GoodsShop; import com.ruoyi.other.api.domain.GoodsVip; import com.ruoyi.other.api.feignClient.GoodsAreaClient; import com.ruoyi.other.api.feignClient.GoodsClient; import com.ruoyi.other.api.feignClient.GoodsShopClient; import com.ruoyi.other.api.feignClient.GoodsVipClient; import model.ShoppingCart; import org.springframework.stereotype.Service; @@ -25,6 +33,17 @@ @Resource private GoodsClient goodsClient; @Resource private GoodsShopClient goodsShopClient; @Resource private AppUserClient appUserClient; @Resource private GoodsAreaClient goodsAreaClient; @Resource private GoodsVipClient goodsVipClient; @@ -40,6 +59,7 @@ @Override public List<MyShoppingCartVo> getMyShoppingCart(Integer type, Integer shopId) { Long userid = tokenService.getLoginUserApplet().getUserid(); AppUser appUser = appUserClient.getAppUserById(userid); //获取对应类型的商品数据 List<Goods> data = goodsClient.getGoodsByType(type).getData(); if(null == data){ @@ -51,11 +71,32 @@ 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()); 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(); if(null == goodsArea){ GoodsVip goodsVip = goodsVipClient.getGoodsVip(appUser.getVipId()).getData(); } vo.setSellingPrice(goods); vo.setOriginalPrice(goods.getOriginalPrice().toString()); vo.setNumber(shoppingCart.getNumber()); vo.setEndTime(); 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); } return page; ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/MyShoppingCartVo.java
@@ -11,8 +11,8 @@ @Data @ApiModel public class MyShoppingCartVo { @ApiModelProperty("商品id") private Integer id; @ApiModelProperty("数据id") private Long id; @ApiModelProperty("封面图") private String homePicture; @ApiModelProperty("商品名称") ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsAreaController.java
New file @@ -0,0 +1,45 @@ package com.ruoyi.other.controller; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.ruoyi.common.core.domain.R; import com.ruoyi.other.api.domain.GoodsArea; import com.ruoyi.other.service.GoodsAreaService; 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/11/28 9:35 */ @RestController @RequestMapping("/goodsArea") public class GoodsAreaController { @Resource private GoodsAreaService goodsAreaService; /** * 根据省市区获取地区价格配置 * @param area * @return */ @PostMapping("/getGoodsArea") public R<GoodsArea> getGoodsArea(@RequestBody GoodsArea area){ GoodsArea one = goodsAreaService.getOne(new LambdaQueryWrapper<GoodsArea>().eq(GoodsArea::getDistrictsCode, area.getDistrictsCode()).eq(GoodsArea::getVip, area.getVip())); if(null == one){ one = goodsAreaService.getOne(new LambdaQueryWrapper<GoodsArea>().eq(GoodsArea::getCityCode, area.getCityCode()).eq(GoodsArea::getVip, area.getVip())); if(null == one){ one = goodsAreaService.getOne(new LambdaQueryWrapper<GoodsArea>().eq(GoodsArea::getProvinceCode, area.getProvinceCode()).eq(GoodsArea::getVip, area.getVip())); } } return R.ok(one); } } ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsShopController.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.GoodsShop; import com.ruoyi.other.service.GoodsShopService; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; /** * <p> @@ -16,5 +21,23 @@ @RequestMapping("/goods-shop") public class GoodsShopController { @Resource private GoodsShopService goodsShopService; /** * 获取商品门店关系数据 * @param goodsShop * @return */ @ResponseBody @PostMapping("/getGoodsShop") public R<GoodsShop> getGoodsShop(@RequestBody GoodsShop goodsShop){ GoodsShop one = goodsShopService.getOne(new LambdaQueryWrapper<GoodsShop>().eq(GoodsShop::getGoodsId, goodsShop.getGoodsId()) .eq(GoodsShop::getShopId, goodsShop.getShopId())); return R.ok(one); } } ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsVipController.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.GoodsVip; import com.ruoyi.other.service.GoodsVipService; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; /** * <p> @@ -16,5 +21,20 @@ @RequestMapping("/goods-vip") public class GoodsVipController { @Resource private GoodsVipService goodsVipService; /** * 获取会员价格配置 * @param vip * @return */ @PostMapping("/getGoodsVip") public R<GoodsVip> getGoodsVip(@RequestParam("vip") Integer vip){ GoodsVip one = goodsVipService.getOne(new LambdaQueryWrapper<GoodsVip>().eq(GoodsVip::getVip, vip)); return R.ok(one); } } ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/GoodsAreaMapper.java
New file @@ -0,0 +1,11 @@ package com.ruoyi.other.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ruoyi.other.api.domain.GoodsArea; /** * @author zhibing.pu * @Date 2024/11/28 9:34 */ public interface GoodsAreaMapper extends BaseMapper<GoodsArea> { } ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/GoodsAreaService.java
New file @@ -0,0 +1,11 @@ package com.ruoyi.other.service; import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.other.api.domain.GoodsArea; /** * @author zhibing.pu * @Date 2024/11/28 9:33 */ public interface GoodsAreaService extends IService<GoodsArea> { } ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsAreaServiceImpl.java
New file @@ -0,0 +1,15 @@ package com.ruoyi.other.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.other.api.domain.GoodsArea; import com.ruoyi.other.mapper.GoodsAreaMapper; import com.ruoyi.other.service.GoodsAreaService; import org.springframework.stereotype.Service; /** * @author zhibing.pu * @Date 2024/11/28 9:33 */ @Service public class GoodsAreaServiceImpl extends ServiceImpl<GoodsAreaMapper, GoodsArea> implements GoodsAreaService { } ruoyi-service/ruoyi-other/src/main/resources/mapper/other/GoodsAreaMapper.xml
New file @@ -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.other.mapper.GoodsAreaMapper"> </mapper>