Просмотр исходного кода

求购大厅、列表逻辑修改

yzc 2 лет назад
Родитель
Сommit
a4b71a1692

+ 7 - 1
sckw-modules/sckw-order/src/main/java/com/sckw/order/model/vo/req/WantBuySelectParam.java

@@ -47,7 +47,7 @@ public class WantBuySelectParam extends PageRequest {
     /**
      * 地区级别
      */
-    private String areaLevel;
+    private Integer areaLevel;
 
     /**
      * 商品类型
@@ -67,4 +67,10 @@ public class WantBuySelectParam extends PageRequest {
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date endCreateTime;
 
+    /**
+     * 企业id
+     */
+    private Long entId;
+    private List<Long> entIds;
+
 }

+ 6 - 1
sckw-modules/sckw-order/src/main/java/com/sckw/order/model/vo/res/WantBuySelectRes.java

@@ -1,7 +1,6 @@
 package com.sckw.order.model.vo.res;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
-import com.sckw.order.model.KwoWantBuyTrading;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -48,12 +47,18 @@ public class WantBuySelectRes {
      * 地址信息
      */
     private String addressName;
+    private String cityName;
+    private String detailAddress;
 
     /**
      * 支付方式
      */
     private String tradings;
 
+    private String contacts;
+
+    private String phone;
+
     /**
      * 求购单价
      */

+ 49 - 43
sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwpWantBuyService.java

@@ -9,6 +9,9 @@ import com.sckw.core.common.enums.enums.DictTypeEnum;
 import com.sckw.core.exception.BusinessException;
 import com.sckw.core.model.constant.Global;
 import com.sckw.core.model.page.PageRes;
+import com.sckw.core.model.vo.TableBottom;
+import com.sckw.core.model.vo.TableStatisticRes;
+import com.sckw.core.model.vo.TableTop;
 import com.sckw.core.utils.BeanUtils;
 import com.sckw.core.utils.CollectionUtils;
 import com.sckw.core.utils.StringUtils;
@@ -20,7 +23,6 @@ import com.sckw.order.model.KwoWantBuy;
 import com.sckw.order.model.KwoWantBuyAddress;
 import com.sckw.order.model.KwoWantBuyTrading;
 import com.sckw.order.model.vo.req.*;
-import com.sckw.order.model.vo.res.TableTopRes;
 import com.sckw.order.model.vo.res.WantBuyAddressDetailRes;
 import com.sckw.order.model.vo.res.WantBuyDetailRes;
 import com.sckw.order.model.vo.res.WantBuySelectRes;
@@ -57,8 +59,8 @@ public class KwpWantBuyService {
      * @desc: 求购大厅列表查询
      * @author lt
      * @Date 11:50 2023/8/1 0001
-    **/
-    public PageRes<WantBuySelectRes> buyHallList(WantBuySelectParam wantBuySelectParam){
+     **/
+    public PageRes<WantBuySelectRes> buyHallList(WantBuySelectParam wantBuySelectParam) {
         // 如果有求购方式的查询条件,需要先查询出求购方式的id
         if (StringUtils.isNotBlank(wantBuySelectParam.getTrading())) {
             List<String> longList = stringToLongList(wantBuySelectParam.getTrading());
@@ -69,6 +71,26 @@ public class KwpWantBuyService {
             List<String> goodsTypes = goodsTypeHandle(wantBuySelectParam);
             wantBuySelectParam.setGoodsTypeValueSearch(goodsTypes);
         }
+        //区域筛选
+        String cityCode = wantBuySelectParam.getCityCode();
+        Integer areaLevel = wantBuySelectParam.getAreaLevel();
+        if (StringUtils.isNotBlank(cityCode) && Objects.nonNull(areaLevel)) {
+            if (Objects.equals(1, areaLevel)) {
+                cityCode = cityCode.substring(0, 2);
+            } else if (Objects.equals(2, areaLevel)) {
+                cityCode = cityCode.substring(0, 4);
+            }
+            wantBuySelectParam.setCityCode(cityCode);
+        }
+        //关键字模糊匹配
+        if (StringUtils.isNotBlank(wantBuySelectParam.getKeywords())) {
+            List<EntCacheResDto> entList = remoteSystemService.queryEntCacheByName(wantBuySelectParam.getKeywords());
+            List<Long> entIds = entList.stream().map(EntCacheResDto::getId).toList();
+            if (CollectionUtils.isNotEmpty(entIds)) {
+                wantBuySelectParam.setEntIds(entIds);
+            }
+        }
+        wantBuySelectParam.setStatus(Integer.valueOf(DictEnum.WANT_BUY_STATUS_1.getValue()));
 
         // 分页查询求购列表
         PageHelper.startPage(wantBuySelectParam.getPage(), wantBuySelectParam.getPageSize());
@@ -105,7 +127,7 @@ public class KwpWantBuyService {
      * @desc 求购列表查询
      * @author lt
      * @Date 11:50 2023/8/1 0001
-    **/
+     **/
     public PageRes<WantBuySelectRes> select(WantBuySelectParam wantBuySelectParam) {
 
         if (StringUtils.isNotBlank(wantBuySelectParam.getTrading())) {
@@ -121,6 +143,7 @@ public class KwpWantBuyService {
             List<String> goodsTypes = goodsTypeHandle(wantBuySelectParam);
             wantBuySelectParam.setGoodsTypeValueSearch(goodsTypes);
         }
+        wantBuySelectParam.setEntId(LoginUserHolder.getEntId());
         PageHelper.startPage(wantBuySelectParam.getPage(), wantBuySelectParam.getPageSize());
         List<WantBuySelectRes> wantBuyDto = kwpWantBuyMapper.pageSelect(wantBuySelectParam);
         if (CollectionUtils.isEmpty(wantBuyDto)) {
@@ -417,7 +440,8 @@ public class KwpWantBuyService {
      * @return
      * @Desc: 查询求购角标统计数量
      */
-    public Map statistic(WantBuySelectParam params) {
+    public TableStatisticRes statistic(WantBuySelectParam params) {
+        TableStatisticRes res = new TableStatisticRes();
         if (StringUtils.isNotBlank(params.getTrading())) {
             List<String> longList = stringToLongList(params.getTrading());
             params.setTradings(longList);
@@ -430,43 +454,25 @@ public class KwpWantBuyService {
             List<String> goodsTypes = goodsTypeHandle(params);
             params.setGoodsTypeValueSearch(goodsTypes);
         }
-        /**统计数据**/
-        List<TableTopRes> counts = kwpWantBuyMapper.statisticsCount(params);
-        long tatol = counts.size();
-        System.out.println(counts);
-
-        /**全部数据-处理**/
-        List<TableTopRes> countList = new ArrayList();
-        TableTopRes allCount = new TableTopRes();
-//        allCount.setValue(String.valueOf(DictEnum.GOODS_STATUS_0));
-        allCount.setTotal(tatol);
-        allCount.setName("全部");
-        countList.add(allCount);
-
-        /**数据处理**/
-        Map<String, Integer> statusMap = new HashMap<>();
-        statusMap.put("保存", Integer.valueOf(DictEnum.GOODS_STATUS_0.getValue()));
-        statusMap.put("下架", Integer.valueOf(DictEnum.GOODS_STATUS_2.getValue()));
-        statusMap.put("上架", Integer.valueOf(DictEnum.GOODS_STATUS_1.getValue()));
-        for (Map.Entry<String, Integer> entry : statusMap.entrySet()) {
-            System.out.println(entry.getKey() + "--->" + entry.getValue());
-            TableTopRes count = new TableTopRes();
-            int smlTotal = 0;
-            for (TableTopRes topCount : counts) {
-                if (topCount.getValue() != null && !topCount.getValue().isEmpty() && Integer.parseInt(topCount.getValue()) == entry.getValue()) {
-                    smlTotal++;
-                }
-            }
-            count.setName(entry.getKey());
-            count.setValue(String.valueOf(entry.getValue()));
-            count.setTotal(smlTotal);
-            countList.add(count);
-        }
-
-        /**数据组装**/
-        Map tableCount = new HashMap();
-        tableCount.put("tableTop", countList);
-        tableCount.put("tableBottom", tatol);
-        return tableCount;
+        params.setEntId(LoginUserHolder.getEntId());
+        List<WantBuySelectRes> result = kwpWantBuyMapper.pageSelect(params);
+        Map<Integer, List<WantBuySelectRes>> map = result.stream().collect(Collectors.groupingBy(WantBuySelectRes::getStatus));
+        List<TableTop> tableTops = new ArrayList<>();
+        TableTop all = new TableTop();
+        all.setName("全部").setTotal(CollectionUtils.isEmpty(result) ? 0 : result.size());
+        tableTops.add(all);
+        List<DictEnum> enums = DictEnum.getEnumsByType(DictTypeEnum.WANT_BUY_STATUS.getType());
+        enums.forEach(e -> {
+            Integer value = Integer.valueOf(e.getValue());
+            List<WantBuySelectRes> list = map.get(value);
+            int total = CollectionUtils.isEmpty(list) ? 0 : list.size();
+            TableTop tableTop = new TableTop();
+            tableTop.setName(e.getLabel()).setValue(value).setTotal(total);
+            tableTops.add(tableTop);
+        });
+        TableBottom tableBottom = new TableBottom();
+        tableBottom.setTotal(CollectionUtils.isEmpty(result) ? 0 : result.size());
+        res.setTableTops(tableTops).setTableBottom(tableBottom);
+        return res;
     }
 }

+ 27 - 10
sckw-modules/sckw-order/src/main/resources/mapper/KwoWantBuyMapper.xml

@@ -10,12 +10,16 @@
         , kb.spec
         , kb.price
         , kb.amount
+        , kb.contacts
+        , kb.phone
         , kb.status
         , kb.remark
         , kb.create_time createTime
         , kt.want_buy_id wantBuyId
         , kt.trading trading
         , kba.name addressName
+        , kba.city_name cityName
+        , kba.detail_address detailAddress
     </sql>
 
     <resultMap id="wangBuyResultMap" type="com.sckw.order.model.vo.res.WantBuySelectRes">
@@ -25,6 +29,8 @@
         <result column="spec" property="spec"/>
         <result column="price" property="price"/>
         <result column="amount" property="amount"/>
+        <result column="contacts" property="contacts"/>
+        <result column="phone" property="phone"/>
         <result column="status" property="status"/>
         <result column="remark" property="remark"/>
         <result column="createTime" property="createTime"/>
@@ -36,7 +42,7 @@
     </resultMap>
 
     <sql id="where">
-        kb.del_flag = 0 and kt.del_flag = 0 and kba.del_flag = 0
+        kb.del_flag = 0 and kt.del_flag = 0
         <if test="wantBuyReq.startCreateTime != null">
             and kb.create_time &gt;= #{wantBuyReq.startCreateTime,jdbcType=TIMESTAMP}
         </if>
@@ -52,10 +58,21 @@
         <if test="wantBuyReq.status != null and wantBuyReq.status != ''">
             and kb.status = #{wantBuyReq.status}
         </if>
+        <if test="wantBuyReq.entId != null ">
+            and kb.ent_id = #{wantBuyReq.entId}
+        </if>
         <if test="wantBuyReq.keywords != null and wantBuyReq.keywords != ''">
-            and (
-            kb.`name` like concat('%', #{wantBuyReq.keywords,jdbcType=VARCHAR}, '%')
-            )
+            <if test="wantBuyReq.entIds != null and wantBuyReq.entIds.size() > 0">
+                and (kb.ent_id in
+                <foreach collection="wantBuyReq.entIds" item="item" open="(" close=")" separator=",">
+                    #{item,jdbcType=BIGINT}
+                </foreach>
+                    or kb.`name` like concat('%', #{wantBuyReq.keywords,jdbcType=VARCHAR}, '%')
+                )
+            </if>
+            <if test="wantBuyReq.entIds == null or wantBuyReq.entIds.size() == 0">
+                and (kb.`name` like concat('%', #{wantBuyReq.keywords,jdbcType=VARCHAR}, '%'))
+            </if>
         </if>
         <if test="wantBuyReq.goodsTypeValueSearch != null and wantBuyReq.goodsTypeValueSearch.size() > 0">
             and kb.goods_type in
@@ -64,15 +81,15 @@
             </foreach>
         </if>
         <if test="wantBuyReq.cityCode != null and wantBuyReq.cityCode != ''">
-            and kba.city_code = #{wantBuyReq.cityCode}
+            and (kba.`city_code` like concat(#{wantBuyReq.cityCode,jdbcType=VARCHAR}, '%'))
         </if>
     </sql>
 
     <select id="pageSelect" resultMap="wangBuyResultMap" resultType="com.sckw.order.model.vo.res.WantBuySelectRes">
         select
         <include refid="Base_Column_List" />
-        from kwo_want_buy kb left join kwo_want_buy_trading kt on kb.id = kt.want_buy_id
-        join kwo_want_buy_address kba on kb.id = kba.want_buy_id
+        from kwo_want_buy kb left join kwo_want_buy_address kba on kb.id = kba.want_buy_id and kba.del_flag = 0
+            left join kwo_want_buy_trading kt on kb.id = kt.want_buy_id and kt.del_flag = 0
         <where>
             <include refid="where" />
         </where>
@@ -90,7 +107,7 @@
     <select id="tradingSql" resultMap="tradIngMap">
         select want_buy_id wantBuyId, trading
         from kwo_want_buy_trading
-        where want_buy_id = #{wantBuyId}
+        where want_buy_id = #{wantBuyId} and del_flag = 0
     </select>
 
 
@@ -109,8 +126,8 @@
     <select id="queryBuyHallList"  resultMap="wangBuyResultMap" resultType="com.sckw.order.model.vo.res.WantBuySelectRes">
         select
             <include refid="Base_Column_List" />
-        from kwo_want_buy kb left join kwo_want_buy_trading kt on kb.id = kt.want_buy_id
-        join kwo_want_buy_address kba on kb.id = kba.want_buy_id
+        from kwo_want_buy kb left join kwo_want_buy_address kba on kb.id = kba.want_buy_id and kba.del_flag = 0
+        left join kwo_want_buy_trading kt on kb.id = kt.want_buy_id and kt.del_flag = 0
         <where>
             <include refid="where" />
         </where>