huliguo
2025-04-02 85193ef9fceaac85f57dc531f80fcfdc204bfc23
商城
9个文件已修改
1个文件已删除
7个文件已添加
799 ■■■■ 已修改文件
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/vo/ConfirmOrder.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/vo/ConfirmOrderVo.java 48 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/vo/MyShoppingCartVo.java 96 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/vo/MyShoppingGoodsVo.java 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/GoodsEvaluate.java 104 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java 22 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/OrderService.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsController.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsEvaluateController.java 213 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/GoodsEvaluateMapper.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/GoodsEvaluateService.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/GoodsService.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsEvaluateServiceImpl.java 72 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java 100 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/GoodsEvaluateVO.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/resources/mapper/other/GoodsMapper.xml 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/vo/ConfirmOrder.java
@@ -11,16 +11,11 @@
@Data
@ApiModel
public class ConfirmOrder {
    @ApiModelProperty(value = "购买方式(1=购物车,2=商品详情)", required = true)
    private Integer position;
    @ApiModelProperty(value = "购物车数据id,数量 JSON[{id:1212,num:2,type:1}]", required = true, notes = "type值取值范围(1=普通商品,2=秒杀商品)")
    private String goodsJson;
    @ApiModelProperty(value = "商品id", required = true)
    private String goodsId;
    @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;
    @ApiModelProperty("优惠券id")
    private Long couponId;
}
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/vo/ConfirmOrderVo.java
@@ -15,32 +15,44 @@
@Data
@ApiModel
public class ConfirmOrderVo {
    @ApiModelProperty("商品列表")
    private List<MyShoppingCartVo> goodsList;
    @ApiModelProperty("商品id")
    private Integer goodId;
    @ApiModelProperty("商品名称")
    private Integer goodName;
    @ApiModelProperty("商品封面图")
    private String homePicture;
    @ApiModelProperty("售价现金")
    private BigDecimal cash;
    @ApiModelProperty("划线价格")
    private String originalPrice;
    @ApiModelProperty("购买数量")
    private Integer number;
    @ApiModelProperty("核销门店")
    private String shopName;
    @ApiModelProperty("核销门店id")
    private Integer shopId;
    @ApiModelProperty("订单金额")
    @ApiModelProperty("订单总金额")
    private BigDecimal orderMoney;
    @ApiModelProperty("优惠活动")
    private String activityName;
    @ApiModelProperty("优惠金额")
    private BigDecimal discountAmount;
    @ApiModelProperty("获得积分")
    private Integer earnPoint;
    @ApiModelProperty("支付金额")
    private BigDecimal payMoney;
/*    @ApiModelProperty("支付金额")
    private BigDecimal payMoney;*/
    @ApiModelProperty("订单总积分")
    private Integer orderPoint;
    @ApiModelProperty("剩余积分")
    private Integer residualPoint;
    @ApiModelProperty("快递费")
    private BigDecimal expressFee;
    @ApiModelProperty("支付方式(1=现金,2=积分)")
    @ApiModelProperty("售价积分")
    private Integer point;
    @ApiModelProperty("可抵扣金额")
    private BigDecimal deduction;
    @ApiModelProperty("支付方式(1=现金,2=积分,3=混合)")
    private Integer paymentType;
    @ApiModelProperty("活动是否可以和优惠券同时使用")
    private Boolean useSimultaneously;
    @ApiModelProperty("优惠券列表")
    private List<PaymentUserCouponVo> coupon;
}
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/vo/MyShoppingCartVo.java
File was deleted
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/vo/MyShoppingGoodsVo.java
New file
@@ -0,0 +1,45 @@
package com.ruoyi.order.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
/**
 * @author zhibing.pu
 * @Date 2024/11/25 11:51
 */
@Data
@ApiModel("购物车")
public class MyShoppingGoodsVo {
    @ApiModelProperty("数据id")
    private String id;
    @ApiModelProperty("商品id")
    private Integer goodsId;
    @ApiModelProperty("封面图")
    private String homePicture;
    @ApiModelProperty("商品名称")
    private String name;
    @ApiModelProperty("售价现金")
    private BigDecimal cash;
    @ApiModelProperty("售价积分")
    private Integer point;
    @ApiModelProperty("原价")
    private String originalPrice;
    @ApiModelProperty("购买数量")
    private Integer number;
    @ApiModelProperty("结束时间")
    private Long endTime;
    @ApiModelProperty("是否可核销(0=否,1=是)")
    private Boolean verifiable;
    @ApiModelProperty("是否超出限购数量")
    private Boolean purchaseLimit;
    @ApiModelProperty("限购数量")
    private Integer purchaseLimitNum;
    @ApiModelProperty("现金支付")
    private Boolean cashPayment;
    @ApiModelProperty("积分支付")
    private Boolean pointPayment;
}
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/GoodsEvaluate.java
New file
@@ -0,0 +1,104 @@
package com.ruoyi.other.api.domain;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
 * <p>
 *
 * </p>
 *
 * @author luodangjia
 * @since 2024-11-20
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("t_goods_evaluate")
@ApiModel(value="GoodsEvaluate对象", description="")
public class GoodsEvaluate implements Serializable {
    private static final long serialVersionUID = 1L;
    @ApiModelProperty(value = "主键")
    @TableId("id")
    private Long id;
    @ApiModelProperty(value = "商品id")
    @TableField("goods_id")
    private Integer goodsId;
    @ApiModelProperty(value = "用户id")
    @TableField("app_user_id")
    private Long appUserId;
    @ApiModelProperty(value = "订单id")
    @TableField("order_id")
    private Long orderId;
    @ApiModelProperty(value = "评分")
    @TableField("grade")
    private BigDecimal grade;
    @ApiModelProperty(value = "评价内容")
    @TableField("comment")
    private String comment;
    @ApiModelProperty(value = "评价图片")
    @TableField("images")
    private String images;
    @ApiModelProperty(value = "状态(1=下架,2=上架)")
    @TableField("status")
    private Integer status;
    @ApiModelProperty(value = "删除(0=否,1=是)")
    @TableField("del_flag")
    private Integer delFlag;
    @ApiModelProperty(value = "添加时间")
    @TableField("create_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private LocalDateTime createTime;
    @ApiModelProperty(value = "头像")
    @TableField(exist = false)
    private String avatar;
    @ApiModelProperty(value = "评价用户")
    @TableField(exist = false)
    private String userName;
    @ApiModelProperty(value = "联系电话")
    @TableField(exist = false)
    private String phone;
    @ApiModelProperty(value = "商品名字")
    @TableField(exist = false)
    private String goodsName;
    @ApiModelProperty(value = "商品图片")
    @TableField(exist = false)
    private String goodsImg;
    @TableField(exist = false)
    private String idStr;
    public void setId(Long id) {
        this.id = id;
        if (id != null){
            this.idStr = String.valueOf(id);
        }
    }
}
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java
@@ -70,6 +70,17 @@
    private AppUserClient appUserClient;
    @ResponseBody
    @PostMapping("/confirmOrder")
    @ApiOperation(value = "确定订单", tags = {"商城-订单-小程序"})
    public R<ConfirmOrderVo> confirmOrder(@ApiParam("商品id") Integer goodId,@ApiParam("支付类型")Integer type) {
        ConfirmOrderVo confirmOrderVo = orderService.confirmOrder(goodId,type);
        return R.ok(confirmOrderVo);
    }
    /**
     * 我的订单列表
     */
@@ -188,17 +199,6 @@
        return R.ok();
    }
    /**
     * 预约技师
     */
    @PostMapping("/subscribe")
    public R<Void> subscribe(@RequestParam(value = "id", required = false) Long id, @RequestParam(value = "technicianId", required = false) Integer technicianId) {
        Order order = orderService.getById(id);
        order.setTechnicianId(technicianId);
        orderService.updateById(order);
        return R.ok();
    }
    @PostMapping("/getLastOrder")
    public R<Order> getLastOrder(@RequestParam("appUserId") Long appUserId) {
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/OrderService.java
@@ -103,4 +103,6 @@
    Integer getShopSaleNum(Integer shopId, Integer type);
    Integer getShopSaleNumByShopIds(List<Integer> shopIds, Integer type);
    ConfirmOrderVo confirmOrder(Integer goodId,Integer type);
}
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java
@@ -4,11 +4,15 @@
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
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.*;
import com.ruoyi.account.api.model.*;
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.ExpressCompanyMap;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.exception.ServiceException;
@@ -608,4 +612,26 @@
    public List<OrderExport> getOrderExportList(OrderPageList orderPageList) {
        return Collections.emptyList();
    }
    /**
     * 确认订单
     */
    @Override
    public ConfirmOrderVo confirmOrder(Integer goodId,Integer type) {
        ConfirmOrderVo confirmOrderVo=new ConfirmOrderVo();
        //用户信息
        Long userid = tokenService.getLoginUserApplet().getUserid();
        AppUser appUser = appUserClient.getAppUserById(userid);
        //商品信息
        Goods good = goodsClient.getGoodsById(goodId).getData();
        if (null == good) {
            //商品不存在
        }
        //店铺信息
        //计算价格信息
        return confirmOrderVo;
    }
}
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsController.java
@@ -174,11 +174,8 @@
     */
    @GetMapping("/goodsDetail/{goodsId}")
    @ApiOperation(value = "商品详情", tags = {"小程序-商城-首页"})
    public R<GoodsVO> goodsDetail(@PathVariable("goodsId") Long goodsId,
                                  Integer shopId,
                                  String longitude,
                                  String latitude) {
        return R.ok(goodsService.goodsDetail(goodsId, shopId, longitude, latitude));
    public R<GoodsVO> goodsDetail(@PathVariable("goodsId") Long goodsId) {
        return R.ok(goodsService.goodsDetail(goodsId));
    }
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsEvaluateController.java
New file
@@ -0,0 +1,213 @@
package com.ruoyi.other.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.account.api.feignClient.AppUserClient;
import com.ruoyi.account.api.model.AppUser;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.web.page.PageInfo;
import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.order.feignClient.OrderClient;
import com.ruoyi.order.model.Order;
import com.ruoyi.other.api.domain.Goods;
import com.ruoyi.other.api.domain.GoodsEvaluate;
import com.ruoyi.other.service.GoodsEvaluateService;
import com.ruoyi.other.service.GoodsService;
import com.ruoyi.other.vo.GoodsEvaluateVO;
import com.ruoyi.system.api.model.LoginUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author luodangjia
 * @since 2024-11-20
 */
@RestController
@RequestMapping("/goods-evaluate")
@Api("评论")
public class GoodsEvaluateController {
    @Resource
    private GoodsEvaluateService goodsEvaluateService;
    @Resource
    private AppUserClient appUserClient;
    @Resource
    private GoodsService goodsService;
    @Resource
    private TokenService tokenService;
    @Resource
    private OrderClient orderClient;
    @GetMapping("/goodsList")
    @ApiOperation(value = "获取商品评价", tags = {"小程序-获取商品评价"})
    public R<PageInfo<GoodsEvaluate>> goodsList(@ApiParam("商品id") Integer goodsId, Integer pageNum, Integer pageSize){
        PageInfo<GoodsEvaluate> pageInfo = new PageInfo<>(pageNum, pageSize);
        PageInfo<GoodsEvaluate> page = goodsEvaluateService.lambdaQuery().eq(GoodsEvaluate::getGoodsId, goodsId).eq(GoodsEvaluate::getDelFlag, 0)
                .eq(GoodsEvaluate::getStatus, 2).isNotNull(GoodsEvaluate::getComment).ne(GoodsEvaluate::getComment, "")
                .orderByDesc(GoodsEvaluate::getCreateTime).page(pageInfo);
        for (GoodsEvaluate goodsEvaluate : page.getRecords()) {
            AppUser appUserById = appUserClient.getAppUserById(goodsEvaluate.getAppUserId());
            if(null != appUserById){
                goodsEvaluate.setUserName(appUserById.getName());
                goodsEvaluate.setAvatar(appUserById.getAvatar());
                goodsEvaluate.setIdStr(String.valueOf(goodsEvaluate.getId()));
            }
        }
        return R.ok(page);
    }
    /**
     * 发布商品评价
     */
    @PostMapping("/addGoodsEvaluate")
    @ApiOperation(value = "发布商品评价", tags = {"小程序-个人中心-我的订单"})
    public R<Void> addGoodsEvaluate(@RequestBody GoodsEvaluateVO goodsEvaluateVO){
        goodsEvaluateService.addGoodsEvaluate(goodsEvaluateVO);
        return R.ok();
    }
    /**
     * 评论详情
     */
    @GetMapping("/detail/{orderId}")
    @ApiOperation(value = "评论详情", tags = {"小程序-评论详情"})
    public R<List<GoodsEvaluate>> detail(@PathVariable("orderId") Long orderId){
        LoginUser loginUserApplet = tokenService.getLoginUserApplet();
        List<GoodsEvaluate> list = goodsEvaluateService.list(new LambdaQueryWrapper<GoodsEvaluate>()
                .eq(GoodsEvaluate::getStatus, 2)
                .eq(GoodsEvaluate::getAppUserId,loginUserApplet.getUserid())
                .eq(GoodsEvaluate::getDelFlag, 0)
                .eq(GoodsEvaluate::getOrderId, orderId));
        for (GoodsEvaluate goodsEvaluate : list) {
            Goods goods = goodsService.getById(goodsEvaluate.getGoodsId());
            goodsEvaluate.setGoodsName(goods.getName());
            goodsEvaluate.setGoodsImg(goods.getHomePagePicture());
        }
        return R.ok(list);
    }
    /**
     * 删除评论
     */
    @DeleteMapping("/delete/{id}")
    @ApiOperation(value = "删除评论", tags = {"管理后台-商品管理-评价管理"})
    public R<Void> delete(@PathVariable("id") Long id){
        GoodsEvaluate goodsEvaluate = goodsEvaluateService.getById(id);
        goodsEvaluate.setDelFlag(1);
        goodsEvaluateService.updateById(goodsEvaluate);
        //修改订单为待评价
        Order data = orderClient.getOrderById(goodsEvaluate.getOrderId()).getData();
        data.setOrderStatus(data.getOldOrderStatus());
        orderClient.editOrder(data);
        return R.ok();
    }
    /**
     * 评论列表
     */
    @GetMapping("/list")
    @ApiOperation(value = "评论列表", tags = {"管理后台-商品管理-评价管理"})
    public R<Page<GoodsEvaluate>> list(@ApiParam("页码") @RequestParam Integer pageNum,
                                       @ApiParam("每一页数据大小") Integer pageSize,
                                       GoodsEvaluate goodsEvaluate){
        List<Integer> goodsIds = new ArrayList<>();
        List<Long> usersNameList = new ArrayList<>();
        List<Long> usersPhoneList = new ArrayList<>();
        if (StringUtils.isNotEmpty(goodsEvaluate.getGoodsName())) {
            goodsIds = goodsService.lambdaQuery()
                    .like(Goods::getName, goodsEvaluate.getGoodsName())
                    .list().stream().map(Goods::getId).collect(Collectors.toList());
            if (goodsIds.isEmpty()) {
                return R.ok(new Page<>());
            }
        }
        if (StringUtils.isNotEmpty(goodsEvaluate.getUserName())) {
            usersNameList = appUserClient.getAppUserByName(goodsEvaluate.getUserName()).getData().stream().map(AppUser::getId).collect(Collectors.toList());
            if (usersNameList.isEmpty()) {
                return R.ok(new Page<>());
            }
        }
        if (StringUtils.isNotEmpty(goodsEvaluate.getPhone())) {
            usersPhoneList = appUserClient.getAppUserByPhoneNoFilter(goodsEvaluate.getPhone()).getData().stream().map(AppUser::getId).collect(Collectors.toList());
            if (usersPhoneList.isEmpty()) {
                return R.ok(new Page<>());
            }
        }
        if (StringUtils.isNotEmpty(goodsEvaluate.getPhone())&&StringUtils.isNotEmpty(goodsEvaluate.getUserName())){
            // 取交集
            usersNameList.retainAll(usersPhoneList);
            if (usersNameList.isEmpty())usersNameList.add(-1L);
        }else{
            usersNameList.addAll(usersPhoneList);
        }
        Page<GoodsEvaluate> page = goodsEvaluateService.page(Page.of(pageNum, pageSize), new LambdaQueryWrapper<GoodsEvaluate>()
                .in(!goodsIds.isEmpty(), GoodsEvaluate::getGoodsId, goodsIds)
                .in(!usersNameList.isEmpty(), GoodsEvaluate::getAppUserId, usersNameList)
                .eq(goodsEvaluate.getStatus() != null && !goodsEvaluate.getStatus().equals(0), GoodsEvaluate::getStatus, goodsEvaluate.getStatus())
                .eq(GoodsEvaluate::getDelFlag, 0)
                .orderByDesc(GoodsEvaluate::getCreateTime));
        page.getRecords().forEach(this::buildDetail);
        return R.ok(page);
    }
    private void buildDetail(GoodsEvaluate item) {
        AppUser appUser = appUserClient.getAppUserById(item.getAppUserId());
        if (appUser != null){
            item.setPhone(appUser.getPhone());
            item.setUserName(appUser.getName());
        }
        Goods goods = goodsService.getById(item.getGoodsId());
        if(null != goods){
            item.setGoodsName(goods.getName());
        }
    }
    /**
     * 评论详情
     */
    @GetMapping("/{id}")
    @ApiOperation(value = "评论详情", tags = {"管理后台-商品管理-评价管理"})
    public R<GoodsEvaluate> getDetail(@PathVariable("id") Long id){
        GoodsEvaluate goodsEvaluate = goodsEvaluateService.getById(id);
        buildDetail(goodsEvaluate);
        return R.ok(goodsEvaluate);
    }
    /**
     * 评论上/下架
     */
    @PutMapping("/changeStatus")
    @ApiOperation(value = "上/下架", tags = {"管理后台-商品管理-评价管理"})
    public R<Void> changeStatus(@RequestBody GoodsEvaluate goodsEvaluate){
        goodsEvaluateService.update(new LambdaUpdateWrapper<GoodsEvaluate>()
                .eq(GoodsEvaluate::getId, goodsEvaluate.getId())
                .set(GoodsEvaluate::getStatus, goodsEvaluate.getStatus()));
        return R.ok();
    }
}
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/GoodsEvaluateMapper.java
New file
@@ -0,0 +1,16 @@
package com.ruoyi.other.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.other.api.domain.GoodsEvaluate;
/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author luodangjia
 * @since 2024-11-20
 */
public interface GoodsEvaluateMapper extends BaseMapper<GoodsEvaluate> {
}
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/GoodsEvaluateService.java
New file
@@ -0,0 +1,18 @@
package com.ruoyi.other.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.other.api.domain.GoodsEvaluate;
import com.ruoyi.other.vo.GoodsEvaluateVO;
import org.springframework.web.bind.annotation.RequestBody;
/**
 * <p>
 *  服务类
 * </p>
 *
 * @author luodangjia
 * @since 2024-11-20
 */
public interface GoodsEvaluateService extends IService<GoodsEvaluate> {
    void addGoodsEvaluate(@RequestBody GoodsEvaluateVO goodsEvaluateVO);
}
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/GoodsService.java
@@ -21,7 +21,7 @@
    PageInfo<GoodsVO> goodsList(Goods goods);
    GoodsVO goodsDetail(Long goodsId, Integer shopId, String longitude, String latitude);
    GoodsVO goodsDetail(Long goodsId);
    List<GoodsVO> getGoodsListByShopId(PageInfo<GoodsVO> pageInfo, Integer shopId);
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsEvaluateServiceImpl.java
New file
@@ -0,0 +1,72 @@
package com.ruoyi.other.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.order.feignClient.OrderClient;
import com.ruoyi.order.feignClient.RemoteOrderGoodsClient;
import com.ruoyi.order.model.Order;
import com.ruoyi.other.api.domain.GoodsEvaluate;
import com.ruoyi.other.mapper.GoodsEvaluateMapper;
import com.ruoyi.other.service.GoodsEvaluateService;
import com.ruoyi.other.vo.GoodsEvaluateVO;
import com.ruoyi.system.api.model.LoginUser;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;
/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author luodangjia
 * @since 2024-11-20
 */
@Service
public class GoodsEvaluateServiceImpl extends ServiceImpl<GoodsEvaluateMapper, GoodsEvaluate> implements GoodsEvaluateService {
    @Resource
    private RemoteOrderGoodsClient remoteOrderGoodsClient;
    @Resource
    private TokenService tokenService;
    @Resource
    private OrderClient orderClient;
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void addGoodsEvaluate(GoodsEvaluateVO goodsEvaluateVO) {
        List<GoodsEvaluate> evaluates = goodsEvaluateVO.getEvaluates();
        for (GoodsEvaluate goodsEvaluate : evaluates) {
            goodsEvaluate.setStatus(2);
            if (StringUtils.isNotEmpty(goodsEvaluate.getIdStr())){
                goodsEvaluate.setId(Long.valueOf(goodsEvaluate.getIdStr()));
                updateById(goodsEvaluate);
            }else {
                LoginUser loginUserApplet = tokenService.getLoginUserApplet();
                goodsEvaluate.setAppUserId(loginUserApplet.getUserid());
                goodsEvaluate.setCreateTime(LocalDateTime.now());
                save(goodsEvaluate);
            }
        }
        if (CollectionUtil.isNotEmpty(evaluates)){
            Long orderId = goodsEvaluateVO.getEvaluates().get(0).getOrderId();
            Order data = orderClient.getOrderById(orderId).getData();
            Order order = new Order();
            order.setId(data.getId());
            order.setOldOrderStatus(data.getOrderStatus());
            order.setOrderStatus(8);
            R<Void> r = remoteOrderGoodsClient.updateOrderStatus(order);
            if (R.isError(r)){
                throw new RuntimeException("修改订单状态失败");
            }
        }
    }
}
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsServiceImpl.java
@@ -87,10 +87,10 @@
            List<NearbyShopVO> nearbyShopVOS = shopService.nearbyShopList(search.getLongitude(), search.getLatitude(), new Shop());
            shopIds = nearbyShopVOS.subList(0, 10).stream().map(NearbyShopVO::getId).collect(Collectors.toList());
        }
        List<GoodsVO> list = this.baseMapper.goodsList(search.getGoodsCategoryId(), search.getName(),shopIds);//查找所有商品
        //查找满足条件的商品  分类、名称、附近十家店
        List<GoodsVO> list = this.baseMapper.goodsList(search.getGoodsCategoryId(), search.getName(),shopIds);
        for (GoodsVO goods : list) {
            System.out.println(goods.getSellingPrice());
            //计算所需价格和积分
            Price price = getPrice( goods.getGoodsId(), 1);
            if(null != price){
@@ -100,13 +100,13 @@
                goods.setStartTime(price.getStartTime());
                goods.setEndTime(price.getEndTime());
            }
            //已售
            //已售数量
            Integer data = orderClient.getGoodsSaleNum(goods.getGoodsId(), 1).getData();
            goods.setSaleNum(data);
        }
        //手动排序
        if(StringUtils.isNotEmpty(search.getOrderByColumn())){
            if("tgs.selling_price".equals(search.getOrderByColumn())){
            if("tgs.selling_price".equals(search.getOrderByColumn())){//价格排序
                list.sort(new Comparator<GoodsVO>() {
                    @Override
                    public int compare(GoodsVO o1, GoodsVO o2) {
@@ -123,7 +123,7 @@
                    }
                });
            }
            /*if("integral".equals(search.getOrderByColumn())){
            if("integral".equals(search.getOrderByColumn())){//积分排序
                list.sort(new Comparator<GoodsVO>() {
                    @Override
                    public int compare(GoodsVO o1, GoodsVO o2) {
@@ -139,8 +139,8 @@
                        return 0;
                    }
                });
            }*/
            if("sale_num".equals(search.getOrderByColumn())){
            }
            if("sale_num".equals(search.getOrderByColumn())){//销量
                list.sort(new Comparator<GoodsVO>() {
                    @Override
                    public int compare(GoodsVO o1, GoodsVO o2) {
@@ -179,23 +179,9 @@
    }
    @Override
    public GoodsVO goodsDetail(Long goodsId, Integer shopId, String longitude, String latitude) {
        /*if (goodsId == null || goodsId <= 0) {
    public GoodsVO goodsDetail(Long goodsId) {
        if (goodsId == null || goodsId <= 0) {
            throw new NullPointerException("商品ID不能为空");
        }
        Integer vipId = 0;
        String provinceCode = null;
        String cityCode = null;
        String districtCode = null;
        String token = SecurityUtils.getToken(ServletUtils.getRequest());
        if(StringUtils.isNotEmpty(token)){
            Long userid = tokenService.getLoginUserApplet().getUserid();
            AppUser appUser = appUserClient.getAppUserById(userid);
            vipId = appUser.getVipId();
            provinceCode = appUser.getProvinceCode();
            cityCode = appUser.getCityCode();
            districtCode = appUser.getDistrictCode();
        }
        Goods goods = this.getById(goodsId);
@@ -205,59 +191,37 @@
        if(goods.getStatus() == 1){
            throw new RuntimeException("商品已被下架");
        }
        if(!goods.getCommodityAuthority().contains("-1") && !goods.getCommodityAuthority().contains(vipId.toString())){
            throw new RuntimeException("权限不足");
        }
        GoodsVO goodsVO = new GoodsVO();
        BeanUtils.copyBeanProp(goodsVO, goods);
        goodsVO.setGoodsId(goods.getId());
        goodsVO.setGoodsName(goods.getName());
        Price price = getPrice(vipId, goods.getId(), shopId, 1, provinceCode, cityCode, districtCode);
        //计算所需价格和积分
        Price price = getPrice( goods.getId(), 1);
        if(null != price){
            goodsVO.setPointPayment(price.getPointPayment() ? 1 : 0);
            goodsVO.setCashPayment(price.getCashPayment() ? 1 : 0);
            //秒杀活动
            goodsVO.setSellingPrice(price.getCash());
            goodsVO.setIntegral(price.getPoint());
            goodsVO.setStartTime(price.getStartTime());
            goodsVO.setEndTime(price.getEndTime());
        }
        if(goods.getType() == 1){
            if(goods.getAppointStore() == 2){
                List<Shop> shopList = shopMapper.selectList(new LambdaQueryWrapper<Shop>()
                        .in(Shop::getDelFlag, 0));
                goodsVO.setShopList(shopList);
            }else{
                List<GoodsShop> goodsShopList = goodsShopMapper.selectList(new LambdaQueryWrapper<GoodsShop>()
                        .eq(GoodsShop::getGoodsId, goodsId));
                if (!CollectionUtils.isEmpty(goodsShopList)){
                    List<Integer> shopIds = goodsShopList.stream().map(GoodsShop::getShopId).collect(Collectors.toList());
                    List<Shop> shopList = shopMapper.selectList(new LambdaQueryWrapper<Shop>()
                            .in(Shop::getId, shopIds));
                    goodsVO.setShopList(shopList);
                }
            }
        }else{
            List<Shop> shopList = shopMapper.selectList(new LambdaQueryWrapper<Shop>()
                    .in(Shop::getDelFlag, 0));
            goodsVO.setShopList(shopList);
        }
        if(StringUtils.isNotEmpty(longitude) && StringUtils.isNotEmpty(latitude)){
            List<Shop> shopList = goodsVO.getShopList();
            for (Shop shop : shopList) {
                Double wgs84 = GeodesyUtil.getDistance(longitude + "," + latitude, shop.getLongitude() + "," + shop.getLatitude()).get("WGS84");
                shop.setDistance(wgs84);
            }
            shopList.sort(new Comparator<Shop>() {
                @Override
                public int compare(Shop o1, Shop o2) {
                    return o1.getDistance().compareTo(o2.getDistance());
                }
            });
            goodsVO.setShopList(shopList);
        }
        //已售数量
        Integer data = orderClient.getGoodsSaleNum(goods.getId(), 1).getData();
        goodsVO.setSaleNum(data);
        //一个商品对应一个门店
        //查找门店
        GoodsShop goodsShop = goodsShopMapper.selectOne(new LambdaQueryWrapper<GoodsShop>()
                .eq(GoodsShop::getGoodsId, goodsId));
        Shop shop1 = shopMapper.selectById(goodsShop.getShopId());
        ArrayList<Shop> shops = new ArrayList<>();
        shops.add(shop1);
        goodsVO.setShopList(shops);
        //已售数量
        Integer integer = orderClient.getGoodsSaleNum(goods.getId(), 1).getData();
        goodsVO.setSaleNum(integer);
        return goodsVO;*/
        return null;
        return goodsVO;
    }
@@ -371,7 +335,7 @@
     * @return
     */
    public Price getPrice( Integer goodsId, Integer type){
        //判断是否有秒杀活动
        //判断是否有在秒杀活动时间中
        Price price = new Price();
        SeckillActivityInfo one = seckillActivityInfoService.getOne(new LambdaQueryWrapper<SeckillActivityInfo>().eq(SeckillActivityInfo::getGoodId, goodsId)
                .eq(SeckillActivityInfo::getIsShelves, 1).eq(SeckillActivityInfo::getDelFlag, 0)
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/vo/GoodsEvaluateVO.java
New file
@@ -0,0 +1,13 @@
package com.ruoyi.other.vo;
import com.ruoyi.other.api.domain.GoodsEvaluate;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import java.util.List;
@Data
@ApiModel(value = "商品评价")
public class GoodsEvaluateVO {
    private List<GoodsEvaluate> evaluates;
}
ruoyi-service/ruoyi-other/src/main/resources/mapper/other/GoodsMapper.xml
@@ -6,6 +6,7 @@
        SELECT
        tg.id as goodsId,
        tg.`name` as goodsName,
        tg.purchase_limit as purchaseLimit
        tg.integral,
        tg.introduction,
        tg.selling_price as sellingPrice,
@@ -63,9 +64,10 @@
                g.name as goodsName,
                g.purchase_limit as purchaseLimit,
                g.selling_price as sellingPrice,
                g.type,
                g.original_price as originalPrice,
                g.integral,
                g.introduction,
                g.detail,
                g.home_page_picture as homePagePicture,
                g.sale_num as saleNum
        from t_goods g