From 36ce1f3549df46609b4e3bc0bf0810bd0c85277e Mon Sep 17 00:00:00 2001 From: luodangjia <luodangjia> Date: 星期四, 28 十一月 2024 17:15:28 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserPointServiceImpl.java | 1 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/OrderVO.java | 17 ++- ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/OrderDetailVO.java | 3 ruoyi-service/ruoyi-other/src/main/resources/mapper/other/GoodsMapper.xml | 2 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/WalletServiceImpl.java | 2 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/SeckillActivityInfoServiceImpl.java | 13 ++ ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/GoodsMapper.java | 2 ruoyi-api/ruoyi-api-order/src/main/java/model/Order.java | 41 ++++++++ ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java | 11 + ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/OrderService.java | 2 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java | 63 +++++++++++- ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Goods.java | 5 ruoyi-service/ruoyi-other/src/main/resources/mapper/other/SeckillActivityInfoMapper.xml | 3 ruoyi-service/ruoyi-other/src/main/resources/mapper/other/ShopMapper.xml | 7 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/OrderMapper.java | 8 + ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsController.java | 11 - ruoyi-api/ruoyi-api-order/src/main/java/model/OrderGood.java | 9 + ruoyi-service/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml | 34 ++++++ ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java | 54 ++++++++-- 19 files changed, 239 insertions(+), 49 deletions(-) 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 fba67dd..c0bf9a7 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 @@ -56,9 +56,46 @@ @TableField("order_number") private String orderNumber; + @ApiModelProperty(value = "商品数量") + @TableField("num") + private Integer num; + + @ApiModelProperty(value = "商品封面(多张逗号隔开,最多三张))") + @TableField("good_pics") + private String goodPics; + + @ApiModelProperty(value = "商品名称(多个名称逗号隔开))") + @TableField("good_name") + private String goodName; + @ApiModelProperty(value = "订单总金额") @TableField("total_amount") private BigDecimal totalAmount; + + @ApiModelProperty(value = "满减金额") + @TableField("full_reduction_amount") + private BigDecimal fullReductionAmount; + + @ApiModelProperty(value = "代金券抵扣金额") + @TableField("money_amount") + private BigDecimal moneyAmount; + + @ApiModelProperty(value = "折扣券抵扣金额") + @TableField("discount_amount") + private BigDecimal discountAmount; + + @ApiModelProperty(value = "商品券抵扣总金额") + @TableField("good_amount") + private BigDecimal goodAmount; + + @ApiModelProperty(value = "活动优惠金额") + @TableField("activity_amount") + private BigDecimal activityAmount; + + @ApiModelProperty(value = "优惠总金额") + @TableField("discount_total_amount") + private BigDecimal discountTotalAmount; + @ApiModelProperty(value = "实际支付价格") @TableField("payment_amount") @@ -76,6 +113,10 @@ @TableField("coupon_json") private String couponJson; + @ApiModelProperty(value = "订单优惠活动的json快照") + @TableField("activity_json") + private String activityJson; + @ApiModelProperty(value = "运费") @TableField("express_amount") private BigDecimal expressAmount; 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 98aebed..01c601d 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 @@ -7,6 +7,7 @@ import lombok.EqualsAndHashCode; import java.io.Serializable; +import java.math.BigDecimal; import java.time.LocalDateTime; /** @@ -36,10 +37,18 @@ @TableField("order_id") private Integer orderId; + @ApiModelProperty(value = "商品券优惠金额") + @TableField("good_amount") + private BigDecimal goodsCouponAmount; + @ApiModelProperty(value = "购买商品的json快照") @TableField("good_json") private String goodJson; + @ApiModelProperty(value = "秒杀活动json快照") + @TableField("seckill_json") + private String seckillJson; + @ApiModelProperty(value = "数量") @TableField("num") private Integer num; 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 0cfa503..cd1e819 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 @@ -102,7 +102,7 @@ @TableField("sale_num") private Integer saleNum; - @ApiModelProperty(value = "商品权限JSON(0=全部,1=游客,2=普通会员,3=黄金会员,4=钻石会员,5=准代理,6=代理,7=总代,8=合伙人)") + @ApiModelProperty(value = "商品权限 逗号分隔(0=全部,1=游客,2=普通会员,3=黄金会员,4=钻石会员,5=准代理,6=代理,7=总代,8=合伙人)") @TableField("commodity_authority") private String commodityAuthority; @@ -119,5 +119,8 @@ @TableField("status") private Integer status; + @TableField(exist = false) + private Integer vipId; + } 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 0b091af..f010f2e 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 @@ -20,6 +20,7 @@ @Override public UserPointVO getUserPoint(Long userId) { + // TODO 待实现 return null; } } 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 4762e9b..ba74390 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 @@ -48,7 +48,7 @@ .eq(WithdrawalRequests::getAuditStatus, WithdrawalAuditStatus.WAIT_AUDIT)); WalletVO walletVO = new WalletVO(); - walletVO.setWithdrawalAmount(appUser.getWithdrawalAmount()); + walletVO.setWithdrawalAmount(appUser.getWithdrawableAmount()); walletVO.setWithdrawnAmount(appUser.getWithdrawnAmount()); walletVO.setVipWithdrawalMinAmount(data.getVipWithdrawalMinAmount()); walletVO.setTotalRechargeAmount(appUser.getTotalRechargeAmount()); 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 e424629..0602b91 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 @@ -2,9 +2,11 @@ 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 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; @@ -31,6 +33,8 @@ public class OrderController { @Resource private OrderService orderService; + @Resource + TokenService tokenService; /** @@ -40,9 +44,10 @@ @ApiImplicitParams({ @ApiImplicitParam(value = "订单状态", name = "status", required = true, dataType = "int"), }) - @GetMapping("/list/{status}") - public R<List<OrderVO>> list(@PathVariable("status") Integer status){ - return R.ok(orderService.getOrderList(status)); + @GetMapping("/getMyOrderList/{status}") + public R<List<OrderVO>> getMyOrderList(@PathVariable("status") Integer status){ + LoginUser loginUserApplet = tokenService.getLoginUserApplet(); + return R.ok(orderService.selectOrderListByUserId(status, loginUserApplet.getUserid())); } /** diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/OrderMapper.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/OrderMapper.java index 3ad28d4..ee18d39 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/OrderMapper.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/OrderMapper.java @@ -1,7 +1,10 @@ package com.ruoyi.order.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.order.vo.OrderVO; import model.Order; + +import java.util.List; /** * <p> @@ -12,5 +15,8 @@ * @since 2024-11-21 */ public interface OrderMapper extends BaseMapper<Order> { - + /** + * 查询用户id + */ + List<OrderVO> selectOrderListByUserId(Integer status, Long userId); } 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 0fb5308..cd40477 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 @@ -16,7 +16,7 @@ * @since 2024-11-21 */ public interface OrderService extends IService<Order> { - List<OrderVO> getOrderList(Integer status); + List<OrderVO> selectOrderListByUserId(Integer status,Long userId); OrderDetailVO getOrderDetail(Long orderId); 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 4cb9ffe..469a9a2 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 @@ -1,15 +1,21 @@ package com.ruoyi.order.service.impl; +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.model.UserAddress; +import com.ruoyi.common.core.exception.ServiceException; +import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.order.mapper.OrderMapper; import com.ruoyi.order.service.OrderService; import com.ruoyi.order.vo.OrderDetailVO; import com.ruoyi.order.vo.OrderVO; +import com.ruoyi.other.api.domain.CouponInfo; +import com.ruoyi.other.api.domain.OrderActivityInfo; import model.Order; import org.springframework.stereotype.Service; -import java.util.Collections; +import javax.annotation.Resource; import java.util.List; /** @@ -22,17 +28,62 @@ */ @Service public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements OrderService { + @Resource + private OrderMapper orderMapper; @Override - public List<OrderVO> getOrderList(Integer status) { - // TODO 待实现 - return Collections.emptyList(); + public List<OrderVO> selectOrderListByUserId(Integer status, Long userId) { + return orderMapper.selectOrderListByUserId(status, userId); } + + + @Override public OrderDetailVO getOrderDetail(Long orderId) { - // TODO 待实现 - return null; + Order order = orderMapper.selectById(orderId); + if (order == null){ + throw new ServiceException("订单不存在"); + } + // 收货地址 + String addressJson = order.getAddressJson(); + UserAddress userAddress = new UserAddress(); + if (StringUtils.isNotEmpty(addressJson)){ + userAddress = JSONObject.parseObject(addressJson, UserAddress.class); + + } + + // 优惠券 + String couponJson = order.getCouponJson(); + CouponInfo couponInfo = new CouponInfo(); + if (StringUtils.isNotEmpty(couponJson)){ + couponInfo = JSONObject.parseObject(couponJson, CouponInfo.class); + } + + // 参与活动 + String activityJson = order.getActivityJson(); + OrderActivityInfo orderActivityInfo = new OrderActivityInfo(); + if (StringUtils.isNotEmpty(activityJson)){ + orderActivityInfo = JSONObject.parseObject(activityJson, OrderActivityInfo.class); + } + + OrderDetailVO orderDetailVO = new OrderDetailVO(); + orderDetailVO.setId(order.getId()); + orderDetailVO.setPoint(order.getPoint()); + orderDetailVO.setAddressId(userAddress.getId()); + orderDetailVO.setRecieveName(userAddress.getRecieveName()); + orderDetailVO.setRecievePhone(userAddress.getRecievePhone()); + orderDetailVO.setRecieveAddress(userAddress.getRecieveAddress()); + orderDetailVO.setOrderNumber(order.getOrderNumber()); + orderDetailVO.setCreateTime(order.getCreateTime()); + orderDetailVO.setTotalAmount(order.getTotalAmount()); + orderDetailVO.setCouponName(couponInfo.getCouponName()); + orderDetailVO.setActivityName(orderActivityInfo.getActivityName()); + orderDetailVO.setCouponAmount(order.getDiscountTotalAmount()); + orderDetailVO.setExpressAmount(order.getExpressAmount()); + orderDetailVO.setPointAmount(order.getGetPoint()); + orderDetailVO.setPaymentAmount(order.getPaymentAmount()); + return orderDetailVO; } @Override diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/OrderDetailVO.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/OrderDetailVO.java index eef904e..2377c61 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/OrderDetailVO.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/OrderDetailVO.java @@ -5,6 +5,7 @@ import lombok.Data; import java.math.BigDecimal; +import java.time.LocalDateTime; import java.util.List; @Data @@ -35,7 +36,7 @@ private String orderNumber; @ApiModelProperty("下单时间") - private String createTime; + private LocalDateTime createTime; @ApiModelProperty(value = "订单总金额") private BigDecimal totalAmount; diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/OrderVO.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/OrderVO.java index 796f3d8..2e65707 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/OrderVO.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/vo/OrderVO.java @@ -1,5 +1,6 @@ package com.ruoyi.order.vo; +import com.baomidou.mybatisplus.annotation.TableField; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -9,7 +10,7 @@ @Data public class OrderVO { @ApiModelProperty(value = "订单id") - private Long id; + private Integer id; @ApiModelProperty(value = "订单编号") private String orderNumber; @@ -17,11 +18,14 @@ @ApiModelProperty(value = "1待发货2待收货3待使用4已完成待评论5已取消6已退款7售后中8已完成已评论") private Integer orderStatus; - @ApiModelProperty(value = "商品图片") - private List<String> goodsPics; + @ApiModelProperty(value = "商品封面(多张逗号隔开,最多三张))") + private String goodPics; - @ApiModelProperty(value = "商品名称") - private String goodsName; + @ApiModelProperty(value = "商品名称(多个名称逗号隔开))") + private String goodName; + + @ApiModelProperty(value = "商品数量") + private Integer num; @ApiModelProperty(value = "使用积分") private BigDecimal point; @@ -29,6 +33,5 @@ @ApiModelProperty(value = "实际支付价格") private BigDecimal paymentAmount; - @ApiModelProperty(value = "商品数量") - private Integer num; + } diff --git a/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml b/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml index 90a9985..54acfa5 100644 --- a/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml +++ b/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml @@ -1,7 +1,37 @@ <?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.OrderMapper"> +<mapper namespace="com.ruoyi.order.mapper.OrderMapper"> - + <select id="selectOrderListByUserId" resultType="com.ruoyi.order.vo.OrderVO"> + SELECT + o.id, + o.order_number, + o.order_status, + o.good_name, + o.good_pics, + o.num, + o.point, + o.payment_amount, + COUNT(o.id) AS order_count + FROM + t_order o + <where> + <if test="status != null"> + o.order_status = #{status} + </if> + <if test="userId != null"> + AND o.app_user_id = #{userId} + </if> + </where> + GROUP BY + o.id, + o.order_number, + o.order_status, + o.point, + o.payment_amount, + o.create_time + ORDER BY + o.create_time DESC + </select> </mapper> 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 7a6c1b9..aabd51b 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 @@ -4,8 +4,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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 com.ruoyi.other.api.domain.Goods; import com.ruoyi.other.service.GoodsService; import com.ruoyi.other.vo.GoodsVO; @@ -37,9 +35,9 @@ */ @GetMapping("/goodsList") @ApiOperation(value = "商品列表", tags = {"小程序-商城-首页-热门商品列表", "首页热门商品-小程序"}) - public TableDataInfo goodsList(Goods goods){ + public R<List<GoodsVO>> goodsList(Goods goods){ startPage(); - return getDataTable(goodsService.goodsList(goods)); + return R.ok(goodsService.goodsList(goods)); } @@ -48,10 +46,9 @@ */ @GetMapping("/getGoodsListByShopId") @ApiOperation(value = "商品列表", tags = {"小程序-首页-门店详情-商品购买列表"}) - public TableDataInfo getGoodsListByShopId(@ApiParam("门店id") @RequestParam Integer shopId) { + public R<List<Goods>> getGoodsListByShopId(@ApiParam("门店id") @RequestParam Integer shopId) { startPage(); - List<Goods> goods = goodsService.getGoodsListByShopId(shopId); - return getDataTable(goods); + return R.ok(goodsService.getGoodsListByShopId(shopId)); } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/GoodsMapper.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/GoodsMapper.java index 9c9f0bb..2058cb9 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/GoodsMapper.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/GoodsMapper.java @@ -14,5 +14,5 @@ * @since 2024-11-20 */ public interface GoodsMapper extends BaseMapper<Goods> { - List<Goods> selectListByShopId(Integer shopId, String vip); + List<Goods> selectListByShopId(Integer shopId, Integer vip); } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java index d5f42ee..4a4ff9d 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java @@ -3,10 +3,14 @@ import cn.hutool.json.JSONArray; 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.core.utils.StringUtils; import com.ruoyi.common.core.utils.bean.BeanUtils; import com.ruoyi.common.security.service.TokenService; import com.ruoyi.other.api.domain.Goods; +import com.ruoyi.other.api.domain.GoodsArea; +import com.ruoyi.other.api.domain.GoodsVip; import com.ruoyi.other.api.domain.VipSetting; import com.ruoyi.other.enums.GoodsStatus; import com.ruoyi.other.mapper.GoodsAreaMapper; @@ -19,6 +23,7 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -43,12 +48,14 @@ private GoodsAreaMapper goodsAreaMapper; @Resource private GoodsVipService goodsVipService; + @Resource + private AppUserClient appUserClient; @Override public List<GoodsVO> goodsList(Goods search) { List<Goods> goodsList = this.list(new LambdaQueryWrapper<Goods>() .eq(Goods::getStatus, GoodsStatus.UP) - .eq(Objects.nonNull(search.getGoodsCategoryId()) ,Goods::getGoodsCategoryId, search.getGoodsCategoryId()) + .eq(Objects.nonNull(search.getGoodsCategoryId()), Goods::getGoodsCategoryId, search.getGoodsCategoryId()) .like(StringUtils.isNotEmpty(search.getName()), Goods::getName, search.getName())); List<GoodsVO> result = new ArrayList<>(); @@ -62,27 +69,48 @@ @Override public GoodsVO goodsDetail(Long goodsId) { - // TODO 根据会员等级计算价格、积分 + if (goodsId == null || goodsId <= 0) { + throw new NullPointerException("商品ID不能为空"); + } + LoginUser loginUserApplet = tokenService.getLoginUserApplet(); - VipSetting vipSetting = vipSettingService.getVipSettingByUserId(loginUserApplet.getUserid()); - // ... + AppUser appUser = appUserClient.getAppUserById(loginUserApplet.getUserid()); + BigDecimal sellingPrice; + Integer integral; + + GoodsArea goodsArea = goodsAreaMapper.selectOne(new LambdaQueryWrapper<GoodsArea>() + .eq(GoodsArea::getGoodsId, goodsId) + .eq(GoodsArea::getProvinceCode, appUser.getProvinceCode()) + .eq(StringUtils.isNotEmpty(appUser.getCityCode()), GoodsArea::getCityCode, appUser.getCityCode()) + .eq(StringUtils.isNotEmpty(appUser.getDistrictCode()), GoodsArea::getDistrictsCode, appUser.getDistrictCode())); + + if (Objects.nonNull(goodsArea)){ + sellingPrice = goodsArea.getSellingPrice(); + integral = goodsArea.getIntegral(); + }else { + VipSetting vipSetting = vipSettingService.getVipSettingByUserId(loginUserApplet.getUserid()); + GoodsVip goodsVip = goodsVipService.getOne(new LambdaQueryWrapper<GoodsVip>() + .eq(GoodsVip::getVip, vipSetting.getId()) + .eq(GoodsVip::getGoodsId, goodsId)); + + sellingPrice = goodsVip.getSellingPrice(); + integral = goodsVip.getIntegral(); + } Goods goods = this.getById(goodsId); - if (Objects.nonNull(goods)){ - GoodsVO goodsVO = new GoodsVO(); - BeanUtils.copyBeanProp(goodsVO, goods); - return goodsVO; - } - return new GoodsVO(); + GoodsVO goodsVO = new GoodsVO(); + BeanUtils.copyBeanProp(goodsVO, goods); + goodsVO.setSellingPrice(sellingPrice); + goodsVO.setIntegral(integral); + return goodsVO; } + @Override public List<Goods> getGoodsListByShopId(Integer shopId) { LoginUser loginUserApplet = tokenService.getLoginUserApplet(); VipSetting vipSetting = vipSettingService.getVipSettingByUserId(loginUserApplet.getUserid()); - JSONArray array = new JSONArray(); - array.add(vipSetting.getId()); - return goodsMapper.selectListByShopId(shopId,array.toString()); + return goodsMapper.selectListByShopId(shopId, vipSetting.getId()); } } diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/SeckillActivityInfoServiceImpl.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/SeckillActivityInfoServiceImpl.java index bcb6b71..9a660fd 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/SeckillActivityInfoServiceImpl.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/SeckillActivityInfoServiceImpl.java @@ -2,6 +2,9 @@ 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.other.api.domain.Goods; import com.ruoyi.other.api.domain.GoodsShop; import com.ruoyi.other.api.domain.SeckillActivityInfo; @@ -12,6 +15,7 @@ import com.ruoyi.other.service.SeckillActivityInfoService; import com.ruoyi.other.vo.SeckillActivityDetailVO; import com.ruoyi.other.vo.SeckillActivityVO; +import com.ruoyi.system.api.model.LoginUser; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -20,7 +24,7 @@ /** * <p> - * 服务实现类 + * 服务实现类 * </p> * * @author luodangjia @@ -34,9 +38,16 @@ private GoodsShopMapper goodsShopMapper; @Resource private ShopMapper shopMapper; + @Resource + private TokenService tokenService; + @Resource + private AppUserClient appUserClient; @Override public List<SeckillActivityVO> listSeckillActivity(Goods goods) { + LoginUser loginUserApplet = tokenService.getLoginUserApplet(); + AppUser appUser = appUserClient.getAppUserById(loginUserApplet.getUserid()); + goods.setVipId(appUser.getVipId()); return seckillActivityInfoMapper.listSeckillActivity(goods); } diff --git a/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/GoodsMapper.xml b/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/GoodsMapper.xml index efe605c..3a5b1a3 100644 --- a/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/GoodsMapper.xml +++ b/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/GoodsMapper.xml @@ -18,7 +18,7 @@ LEFT JOIN t_goods tg ON tg.id = tgs.goods_id where ts.id = #{shopId} <if test="vip != null"> - and JSON_CONTAINS(commodity_authority, #{vip}) + and FIND_IN_SET(#{vip}, commodity_authority) > 0 </if> ORDER BY tg.sale_num DESC </select> 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 220571f..742f5e8 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 @@ -23,6 +23,9 @@ <if test="goodsCategoryId != null"> AND tg.goods_category_id = #{goodsCategoryId} </if> + <if test="vipId != null"> + AND find_in_set(#{vipId},tgs.vip) > 0 + </if> </select> <select id="selectDetail" resultType="com.ruoyi.other.vo.SeckillActivityDetailVO"> SELECT diff --git a/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/ShopMapper.xml b/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/ShopMapper.xml index a0589da..7187523 100644 --- a/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/ShopMapper.xml +++ b/ruoyi-service/ruoyi-other/src/main/resources/mapper/other/ShopMapper.xml @@ -13,11 +13,12 @@ radians(#{latitude})) * cos( radians(latitude)) * cos( radians(longitude) - radians(#{longitude})) + sin( - radians(#{latitude})) * sin( - radians(latitude)) + radians(#{latitude})) * sin( + radians(latitude)) )) AS distance FROM t_shop - where del_flag = 0 and status = 1 + where del_flag = 0 + and status = 1 ORDER BY distance </select> <select id="selectShopDetail" resultType="com.ruoyi.other.vo.ShopDetailVO"> -- Gitblit v1.7.1