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; 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; 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; } 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; } } 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())); } /** @@ -74,7 +79,7 @@ */ @ApiOperation(value = "订单核销", tags = {"小程序-个人中心-门店管理-扫码核销"}) @ApiImplicitParams({ @ApiImplicitParam(value = "核销码", name = "code", required = true, dataType = "String"), @ApiImplicitParam(value = "订单号", name = "code", required = true, dataType = "String"), }) @GetMapping("/writeOff/{code}") public R<Void> writeOff(@PathVariable("code") String code){ 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); } 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); ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java
@@ -1,15 +1,26 @@ 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.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 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 model.Order; import model.OrderGood; import org.springframework.stereotype.Service; import java.util.Collections; import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; /** @@ -22,17 +33,85 @@ */ @Service public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements OrderService { @Resource private OrderMapper orderMapper; private OrderGoodMapper orderGoodMapper; @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("订单不存在"); } // 商品 List<OrderGood> orderGoods = orderGoodMapper.selectList(new LambdaQueryWrapper<OrderGood>() .eq(OrderGood::getOrderId, orderId)); List<OrderGoodsVO> goodsList = new ArrayList<>(); for (OrderGood orderGood : orderGoods) { String goodJson = orderGood.getGoodJson(); Goods goods = JSONObject.parseObject(goodJson, Goods.class); OrderGoodsVO orderGoodsVO = new OrderGoodsVO(); orderGoodsVO.setGoodsId(orderGood.getGoodsId()); orderGoodsVO.setGoodsName(goods.getName()); orderGoodsVO.setType(goods.getType()); orderGoodsVO.setNum(orderGood.getNum()); orderGoodsVO.setGoodsPic(goods.getHomePagePicture()); orderGoodsVO.setSellingPrice(goods.getSellingPrice()); orderGoodsVO.setOriginalPrice(goods.getOriginalPrice()); goodsList.add(orderGoodsVO); } // 收货地址 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()); orderDetailVO.setGoodsList(goodsList); return orderDetailVO; } @Override 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; 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; } 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> 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)); } 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); } 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()); } } 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); } 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> 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 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">