Bläddra i källkod

新增回收页面,修改档口内容

jin 6 månader sedan
förälder
incheckning
47a9ae9a91

+ 38 - 0
ruoyi-common/src/main/java/com/ruoyi/common/enums/RecycleEnum.java

@@ -0,0 +1,38 @@
+package com.ruoyi.common.enums;
+
+public enum RecycleEnum {
+    ONLINE(1, "线上交易平台"),
+    OFFLINE(2, "线下交易场所"),
+    OFFLINE_STALL(3, "线下回收门店/档口");
+
+    private Integer code;
+    private String value;
+
+    RecycleEnum(Integer code, String value) {
+        this.code = code;
+        this.value = value;
+    }
+
+    public Integer getCode() {
+        return code;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    /**
+     * 根据code获取去value
+     *
+     * @param code
+     * @return
+     */
+    public static String getValueByCode(Integer code) {
+        for (RecycleEnum recycleEnum : RecycleEnum.values()) {
+            if (code.equals(recycleEnum.getCode())) {
+                return recycleEnum.getValue();
+            }
+        }
+        return null;
+    }
+}

+ 18 - 6
ruoyi-framework/src/main/java/com/ruoyi/framework/recovery/domain/RecStall.java

@@ -26,7 +26,7 @@ public class RecStall extends BaseEntity
 
     /** 交易类型:1.线上交易平台,2.线下交易平台,3.线下回收门店/档口 */
     @Excel(name = "交易类型:1.线上交易平台,2.线下交易平台,3.线下回收门店/档口")
-    private Long tradeType;
+    private Integer tradeType;
 
     /** 档口名称 */
     @Excel(name = "档口名称")
@@ -70,7 +70,10 @@ public class RecStall extends BaseEntity
      * 档口城市
      */
     @Excel(name = "档口城市")
-    private String cityId;
+    private Long cityId;
+
+    @Excel(name = "城市")
+    private String city;
 
     public void setId(Long id)
     {
@@ -90,12 +93,12 @@ public class RecStall extends BaseEntity
     {
         return categoryId;
     }
-    public void setTradeType(Long tradeType)
+    public void setTradeType(Integer tradeType)
     {
         this.tradeType = tradeType;
     }
 
-    public Long getTradeType()
+    public Integer getTradeType()
     {
         return tradeType;
     }
@@ -181,14 +184,22 @@ public class RecStall extends BaseEntity
         return updateDate;
     }
 
-    public String getCityId() {
+    public Long getCityId() {
         return cityId;
     }
 
-    public void setCityId(String cityId) {
+    public void setCityId(Long cityId) {
         this.cityId = cityId;
     }
 
+    public String getCity() {
+        return city;
+    }
+
+    public void setCity(String city) {
+        this.city = city;
+    }
+
     @Override
     public String toString() {
         final StringBuffer sb = new StringBuffer("RecStall{");
@@ -205,6 +216,7 @@ public class RecStall extends BaseEntity
         sb.append(", createDate=").append(createDate);
         sb.append(", updateDate=").append(updateDate);
         sb.append(", cityId='").append(cityId).append('\'');
+        sb.append(", city='").append(city).append('\'');
         sb.append('}');
         return sb.toString();
     }

+ 27 - 8
ruoyi-framework/src/main/java/com/ruoyi/framework/recovery/mapper/RecStallMapper.java

@@ -1,20 +1,23 @@
 package com.ruoyi.framework.recovery.mapper;
 
 import java.util.List;
+import java.util.Map;
+
 import com.ruoyi.framework.recovery.domain.RecStall;
 import com.ruoyi.framework.recovery.domain.vo.GoodsVo;
+import org.apache.ibatis.annotations.MapKey;
 
 /**
  * 回收档口Mapper接口
- * 
+ *
  * @author jin
  * @date 2024-11-16
  */
-public interface RecStallMapper 
+public interface RecStallMapper
 {
     /**
      * 查询回收档口
-     * 
+     *
      * @param id 回收档口主键
      * @return 回收档口
      */
@@ -22,7 +25,7 @@ public interface RecStallMapper
 
     /**
      * 查询回收档口列表
-     * 
+     *
      * @param recStall 回收档口
      * @return 回收档口集合
      */
@@ -30,7 +33,7 @@ public interface RecStallMapper
 
     /**
      * 新增回收档口
-     * 
+     *
      * @param recStall 回收档口
      * @return 结果
      */
@@ -38,7 +41,7 @@ public interface RecStallMapper
 
     /**
      * 修改回收档口
-     * 
+     *
      * @param recStall 回收档口
      * @return 结果
      */
@@ -46,7 +49,7 @@ public interface RecStallMapper
 
     /**
      * 删除回收档口
-     * 
+     *
      * @param id 回收档口主键
      * @return 结果
      */
@@ -54,7 +57,7 @@ public interface RecStallMapper
 
     /**
      * 批量删除回收档口
-     * 
+     *
      * @param ids 需要删除的数据主键集合
      * @return 结果
      */
@@ -66,4 +69,20 @@ public interface RecStallMapper
      * @return 商品结果集
      */
     List<GoodsVo> selectAllGoods();
+
+    /**
+     * 查询最小Id
+     *
+     * @return
+     */
+    @MapKey("tradeType")
+    Map<Integer, Map> selectMinCityId();
+
+    /**
+     * 根据分类查询内容
+     *
+     * @param recStall 入参
+     * @return  结果集
+     */
+    List<RecStall> selectRecStallListByCategoryId(RecStall recStall);
 }

+ 26 - 1
ruoyi-system/src/main/resources/mapper/system/RecStallMapper.xml

@@ -23,7 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectRecStallVo">
-        select id, category_id, trade_type, stall_name, stall_desc, stall_address, stall_cont, stall_cont_wx, stall_cont_address, stall_icon, create_by, create_date, update_by, update_date from rec_stall
+        select id, category_id, trade_type, stall_name, stall_desc, stall_address, stall_cont, stall_cont_wx, stall_cont_address, stall_icon, create_by, create_date, update_by, update_date, city_id from rec_stall
     </sql>
 
     <select id="selectRecStallList" parameterType="RecStall" resultMap="RecStallResult">
@@ -123,4 +123,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         SELECT rb.brand as brand, rc.id as id, rc.model as model,rc.specs as specs
         FROM rec_commodity rc left join rec_brand rb on rb.id = rc.brand_id
     </select>
+    <select id="selectMinCityId" resultType="java.util.Map">
+        SELECT trade_type as tradeType, min(city_id) as cityId from rec_stall where city_id is not null GROUP BY trade_type
+    </select>
+    <select id="selectRecStallListByCategoryId" resultType="com.ruoyi.framework.recovery.domain.RecStall">
+        select rs.id, rs.category_id as categoryId, rs.trade_type as tradeType, rs.stall_name as stallName, rs.stall_desc as stallDesc,
+               rs.stall_address as stallAddress, rs.stall_cont as stallCont, rs.stall_cont_wx as stallContWx,
+               rs.stall_cont_address as stallContAddress, rs.stall_icon as stallIcon, rs.create_by as createBy, rs.create_date as createDate,
+               rs.update_by as updateBy, rs.update_date as updateDate, rs.city_id as cityId, rc.city as city
+        from rec_stall rs
+        left join rec_city rc on rc.id = rs.city_id
+        <where>
+            <if test="categoryId != null "> and category_id = #{categoryId}</if>
+            <if test="tradeType != null "> and trade_type = #{tradeType}</if>
+            <if test="stallName != null  and stallName != ''"> and stall_name like concat('%', #{stallName}, '%')</if>
+            <if test="stallDesc != null  and stallDesc != ''"> and stall_desc = #{stallDesc}</if>
+            <if test="stallAddress != null  and stallAddress != ''"> and stall_address = #{stallAddress}</if>
+            <if test="stallCont != null  and stallCont != ''"> and stall_cont = #{stallCont}</if>
+            <if test="stallContWx != null  and stallContWx != ''"> and stall_cont_wx = #{stallContWx}</if>
+            <if test="stallContAddress != null  and stallContAddress != ''"> and stall_cont_address = #{stallContAddress}</if>
+            <if test="stallIcon != null  and stallIcon != ''"> and stall_icon = #{stallIcon}</if>
+            <if test="createDate != null "> and create_date = #{createDate}</if>
+            <if test="updateDate != null "> and update_date = #{updateDate}</if>
+            <if test="cityId != null "> and city_id = #{cityId}</if>
+        </where>
+    </select>
 </mapper>

+ 55 - 0
ruoyi-wx/src/main/java/com/ruoyi/wx/web/controller/WxRecycleController.java

@@ -0,0 +1,55 @@
+package com.ruoyi.wx.web.controller;
+
+
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.framework.recovery.domain.RecStall;
+import com.ruoyi.wx.web.domain.dto.RecycleDto;
+import com.ruoyi.wx.web.domain.vo.RecycleVo;
+import com.ruoyi.wx.web.service.IWxRecycleService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 回收页服务
+ */
+@RestController
+@RequestMapping("/wx/recycle")
+@Slf4j
+public class WxRecycleController {
+    @Autowired
+    private IWxRecycleService wxRecycleService;
+
+    @GetMapping("/index")
+    public AjaxResult getIndex() {
+        try {
+            return wxRecycleService.getIndex();
+        } catch (Exception e) {
+            return AjaxResult.error();
+        }
+    }
+
+    // 首次查询3种类型
+    @GetMapping("/info/{id}")
+    public AjaxResult getInfo(@PathVariable("id") Long id) {
+        try {
+            List<RecycleVo> recycleVoList = wxRecycleService.getInfoList(id);
+            return AjaxResult.success(recycleVoList);
+        } catch (Exception e) {
+            return AjaxResult.error();
+        }
+    }
+
+    // 精确根据城市、类型和档口类型来查询
+    @PostMapping("/info")
+    public AjaxResult cityList(@RequestBody RecycleDto recycleDto) {
+        try {
+            List<RecStall> recycleVoList = wxRecycleService.getCityRecycle(recycleDto);
+            return AjaxResult.success(recycleVoList);
+        } catch (Exception e) {
+            return AjaxResult.error();
+        }
+    }
+}

+ 52 - 0
ruoyi-wx/src/main/java/com/ruoyi/wx/web/domain/dto/RecycleDto.java

@@ -0,0 +1,52 @@
+package com.ruoyi.wx.web.domain.dto;
+
+public class RecycleDto {
+    /**
+     * 回收类型id
+     */
+    private Long categoryId;
+
+    /**
+     *  交易类型
+     */
+    private Integer tradeType;
+
+    /**
+     * 城市id
+     */
+    private Long cityId;
+
+    public Long getCategoryId() {
+        return categoryId;
+    }
+
+    public void setCategoryId(Long categoryId) {
+        this.categoryId = categoryId;
+    }
+
+    public Integer getTradeType() {
+        return tradeType;
+    }
+
+    public void setTradeType(Integer tradeType) {
+        this.tradeType = tradeType;
+    }
+
+    public Long getCityId() {
+        return cityId;
+    }
+
+    public void setCityId(Long cityId) {
+        this.cityId = cityId;
+    }
+
+    @Override
+    public String toString() {
+        final StringBuffer sb = new StringBuffer("RecycleDto{");
+        sb.append("categoryId=").append(categoryId);
+        sb.append(", tradeType=").append(tradeType);
+        sb.append(", cityId=").append(cityId);
+        sb.append('}');
+        return sb.toString();
+    }
+}

+ 17 - 0
ruoyi-wx/src/main/java/com/ruoyi/wx/web/domain/vo/GoodsInfoVo.java

@@ -1,10 +1,13 @@
 package com.ruoyi.wx.web.domain.vo;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import com.ruoyi.common.annotation.Excel;
 import io.swagger.annotations.ApiModel;
 import io.swagger.v3.oas.annotations.media.Schema;
 
 import java.math.BigDecimal;
+import java.util.Date;
+
 @Schema(description = "用户实体")
 @ApiModel(value = "物品详情实体类")
 public class GoodsInfoVo {
@@ -43,6 +46,11 @@ public class GoodsInfoVo {
     @Schema(title = "价格差")
     private BigDecimal arbitrage;
 
+    /** 更新时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date updateDate;
+
     public Long getId() {
         return id;
     }
@@ -91,6 +99,14 @@ public class GoodsInfoVo {
         this.arbitrage = arbitrage;
     }
 
+    public Date getUpdateDate() {
+        return updateDate;
+    }
+
+    public void setUpdateDate(Date updateDate) {
+        this.updateDate = updateDate;
+    }
+
     @Override
     public String toString() {
         final StringBuffer sb = new StringBuffer("GoodsInfoVo{");
@@ -100,6 +116,7 @@ public class GoodsInfoVo {
         sb.append(", market=").append(market);
         sb.append(", specs='").append(specs).append('\'');
         sb.append(", arbitrage=").append(arbitrage);
+        sb.append(", updateDate=").append(updateDate);
         sb.append('}');
         return sb.toString();
     }

+ 56 - 0
ruoyi-wx/src/main/java/com/ruoyi/wx/web/domain/vo/RecycleVo.java

@@ -0,0 +1,56 @@
+package com.ruoyi.wx.web.domain.vo;
+
+import com.ruoyi.framework.recovery.domain.RecStall;
+
+import java.util.List;
+
+public class RecycleVo {
+    /**
+     * 档口类型
+     */
+    private Integer tradeType;
+
+    /**
+     * 档口类型名称
+     */
+    private String tradeName;
+
+    /**
+     * 当铺信息
+     */
+    private List<RecStall> recStallList;
+
+    public Integer getTradeType() {
+        return tradeType;
+    }
+
+    public void setTradeType(Integer tradeType) {
+        this.tradeType = tradeType;
+    }
+
+    public String getTradeName() {
+        return tradeName;
+    }
+
+    public void setTradeName(String tradeName) {
+        this.tradeName = tradeName;
+    }
+
+    public List<RecStall> getRecStallList() {
+        return recStallList;
+    }
+
+    public void setRecStallList(List<RecStall> recStallList) {
+        this.recStallList = recStallList;
+    }
+
+    @Override
+    public String toString() {
+        final StringBuffer sb = new StringBuffer("RecycleVo{");
+        sb.append("tradeType=").append(tradeType);
+        sb.append(", tradeName='").append(tradeName).append('\'');
+        sb.append(", recStallList=").append(recStallList);
+        sb.append('}');
+        return sb.toString();
+    }
+}

+ 33 - 0
ruoyi-wx/src/main/java/com/ruoyi/wx/web/service/IWxRecycleService.java

@@ -0,0 +1,33 @@
+package com.ruoyi.wx.web.service;
+
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.framework.recovery.domain.RecStall;
+import com.ruoyi.wx.web.domain.dto.RecycleDto;
+import com.ruoyi.wx.web.domain.vo.RecycleVo;
+
+import java.util.List;
+
+public interface IWxRecycleService {
+    /**
+     * 回收分类
+     *
+     * @return 返回结果
+     */
+    AjaxResult getIndex();
+
+    /**
+     * 根据回收分类查询内容
+     *
+     * @param id id
+     * @return 结果集
+     */
+    List<RecycleVo> getInfoList(Long id);
+
+    /**
+     * 精确根据城市、类型和档口类型来查询
+     *
+     * @param recycleDto 入参
+     * @return 结果集
+     */
+    List<RecStall> getCityRecycle(RecycleDto recycleDto);
+}

+ 0 - 2
ruoyi-wx/src/main/java/com/ruoyi/wx/web/service/impl/WxQuotationServiceImpl.java

@@ -1,13 +1,11 @@
 package com.ruoyi.wx.web.service.impl;
 
-import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.utils.bean.BeanUtils;
 import com.ruoyi.framework.recovery.domain.RecBrand;
 import com.ruoyi.framework.recovery.domain.RecCommodity;
 import com.ruoyi.framework.recovery.mapper.RecBrandMapper;
 import com.ruoyi.framework.recovery.mapper.RecCommodityMapper;
 import com.ruoyi.wx.web.domain.vo.GoodsInfoVo;
-import com.ruoyi.wx.web.mapper.WxQuotationMapper;
 import com.ruoyi.wx.web.service.IWxQuotationService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;

+ 73 - 0
ruoyi-wx/src/main/java/com/ruoyi/wx/web/service/impl/WxRecycleServiceImpl.java

@@ -0,0 +1,73 @@
+package com.ruoyi.wx.web.service.impl;
+
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.enums.RecycleEnum;
+import com.ruoyi.framework.recovery.domain.RecStall;
+import com.ruoyi.framework.recovery.domain.RecStallCategory;
+import com.ruoyi.framework.recovery.mapper.RecStallCategoryMapper;
+import com.ruoyi.framework.recovery.mapper.RecStallMapper;
+import com.ruoyi.wx.web.domain.dto.RecycleDto;
+import com.ruoyi.wx.web.domain.vo.RecycleVo;
+import com.ruoyi.wx.web.service.IWxRecycleService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+@Service
+@Slf4j
+public class WxRecycleServiceImpl implements IWxRecycleService {
+    @Autowired
+    private RecStallCategoryMapper stallCategoryMapper;
+
+    @Autowired
+    private RecStallMapper stallMapper;
+
+    @Override
+    public AjaxResult getIndex() {
+        return AjaxResult.success(stallCategoryMapper.selectRecStallCategoryList(new RecStallCategory()));
+    }
+
+    @Override
+    public List<RecycleVo> getInfoList(Long id) {
+        RecStall recStall = new RecStall();
+        recStall.setCategoryId(id);
+        // 查询所有内容
+        List<RecStall> recStalls = stallMapper.selectRecStallListByCategoryId(recStall);
+        // 查询最小城市Id
+        Map<Integer, Map> minCityMap = stallMapper.selectMinCityId();
+        Map<Integer, List<RecStall>> stallMap = recStalls.stream().collect(Collectors.groupingBy(RecStall::getTradeType));
+        Map<Integer, List<RecStall>> filteredStallMap = new HashMap<>();
+        stallMap.forEach((key, value) -> {
+            if (key != 1) {
+                Long minCityId = (Long) minCityMap.get(key).get("cityId");
+                List<RecStall> result = value.stream().filter(vo -> vo.getCityId().equals(String.valueOf(minCityId))).toList();
+                filteredStallMap.put(key, result);
+            }
+            filteredStallMap.put(key, value);
+        });
+        List<RecycleVo> list = new ArrayList<>();
+        filteredStallMap.forEach((key, value) -> {
+            RecycleVo recycleVo = new RecycleVo();
+            recycleVo.setTradeType(key);
+            recycleVo.setTradeName(RecycleEnum.getValueByCode(key));
+            recycleVo.setRecStallList(value);
+            list.add(recycleVo);
+        });
+        return list;
+    }
+
+    @Override
+    public List<RecStall> getCityRecycle(RecycleDto recycleDto) {
+        RecStall recStall = new RecStall();
+        recStall.setCategoryId(recycleDto.getCategoryId());
+        recStall.setCityId(recycleDto.getCityId());
+        recStall.setTradeType(recycleDto.getTradeType());
+        return stallMapper.selectRecStallListByCategoryId(recStall);
+    }
+}