Răsfoiți Sursa

Merge branch 'dev-lt' into dev

# Conflicts:
#	sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwoTradeOrderService.java
ltt 2 ani în urmă
părinte
comite
37740d1a5e
16 a modificat fișierele cu 1099 adăugiri și 27 ștergeri
  1. 73 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/controller/KwpWantBuyController.java
  2. 11 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/dao/KwpWantBuyMapper.java
  3. 5 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/dao/KwpWantBuyTradingMapper.java
  4. 78 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/model/vo/req/UpdateWantBuyParam.java
  5. 24 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/model/vo/req/WantBuyDels.java
  6. 75 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/model/vo/req/WantBuySelectParam.java
  7. 30 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/model/vo/res/TableTopRes.java
  8. 5 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/model/vo/res/WantBuyDetailRes.java
  9. 93 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/model/vo/res/WantBuySelectRes.java
  10. 20 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/model/vo/res/WantBuyTradingRes.java
  11. 8 24
      sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwoTradeOrderService.java
  12. 22 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwoWantBuyAddressService.java
  13. 33 0
      sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwoWantBuyTradingService.java
  14. 468 3
      sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwpWantBuyService.java
  15. 118 0
      sckw-modules/sckw-order/src/main/resources/mapper/KwoWantBuyMapper.xml
  16. 36 0
      sckw-modules/sckw-order/src/main/resources/mapper/KwoWantBuyTradingMapper.xml

+ 73 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/controller/KwpWantBuyController.java

@@ -3,12 +3,17 @@ package com.sckw.order.controller;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.order.model.vo.req.AddWantBuyParam;
 import com.sckw.order.model.vo.req.UpdateWantBuyParam;
+import com.sckw.order.model.vo.req.WantBuyDels;
+import com.sckw.order.model.vo.req.WantBuySelectParam;
 import com.sckw.order.serivce.KwpWantBuyService;
 import lombok.RequiredArgsConstructor;
 import org.springframework.http.MediaType;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.HashMap;
+import java.util.List;
+
 /**
  * @desc: 求购controller
  * @author: yzc
@@ -21,6 +26,26 @@ public class KwpWantBuyController {
 
     private final KwpWantBuyService kwpWantBuyService;
 
+    /**
+     * @desc: 求购分页查询
+     * @author lt
+     * @Date 15:34 2023/7/26 0026
+    **/
+    @PostMapping(value = "/select", produces = MediaType.APPLICATION_JSON_VALUE)
+    public HttpResult select(@RequestBody WantBuySelectParam wantBuySelectParam) {
+        return HttpResult.ok(kwpWantBuyService.select(wantBuySelectParam));
+    }
+
+    /**
+     * @desc: 求购大厅
+     * @author lt
+     * @Date 15:34 2023/7/26 0026
+    **/
+    @PostMapping(value = "/buyHallList", produces = MediaType.APPLICATION_JSON_VALUE)
+    public HttpResult buyHallList(@RequestBody WantBuySelectParam wantBuySelectParam) {
+        return HttpResult.ok(kwpWantBuyService.buyHallList(wantBuySelectParam));
+    }
+
     /**
      * @desc: 新增求购草稿
      * @author: yzc
@@ -47,6 +72,39 @@ public class KwpWantBuyController {
         return HttpResult.ok("新增求购上架成功");
     }
 
+    /**
+     * @desc: 求购上架
+     * @Author: lt
+     * @Date: 13:39 2023/7/25 0025
+    **/
+    @GetMapping(value = "/putOnShelves", produces = MediaType.APPLICATION_JSON_VALUE)
+    public HttpResult putOnShelves(@RequestParam Long id) {
+        kwpWantBuyService.putOnShelves(id);
+        return HttpResult.ok("求购上架成功");
+    }
+
+    /**
+     * @desc: 求购批量下架
+     * @Author: lt
+     * @Date: 13:39 2023/7/25 0025
+    **/
+    @PostMapping(value = "/batchTakeOffShelves", produces = MediaType.APPLICATION_JSON_VALUE)
+    public HttpResult batchTakeOffShelves(@RequestBody WantBuyDels ids) {
+        kwpWantBuyService.batchTakeOffShelves(ids);
+        return HttpResult.ok("批量下架成功");
+    }
+
+    /**
+     * @desc: 求购批量删除
+     * @Author: lt
+     * @Date: 13:39 2023/7/25 0025
+    **/
+    @DeleteMapping(value = "/dels", produces = MediaType.APPLICATION_JSON_VALUE)
+    public HttpResult dels(@RequestBody WantBuyDels ids) {
+        kwpWantBuyService.dels(ids);
+        return HttpResult.ok("批量删除成功");
+    }
+
     /**
      * @desc: 求购详情
      * @author: yzc
@@ -59,10 +117,25 @@ public class KwpWantBuyController {
         return HttpResult.ok(kwpWantBuyService.detail(id));
     }
 
+    /**
+     * @desc: 求购编辑
+     * @author lt
+     * @Date 15:22 2023/7/26 0026
+    **/
     @PostMapping(value = "/update", produces = MediaType.APPLICATION_JSON_VALUE)
     public HttpResult update(@RequestBody @Validated UpdateWantBuyParam updateWantBuyParam) {
         kwpWantBuyService.update(updateWantBuyParam);
         return HttpResult.ok("求购修改成功!");
     }
 
+    /**
+     * @desc 求购角标统计
+     * @author lt
+     * @Date 15:23 2023/7/26 0026
+    **/
+    @PostMapping(value = "/statistic", produces = MediaType.APPLICATION_JSON_VALUE)
+    public HttpResult statistic(@RequestBody WantBuySelectParam params)
+    {
+        return HttpResult.ok(kwpWantBuyService.statistic(params));
+    }
 }

+ 11 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/dao/KwpWantBuyMapper.java

@@ -2,7 +2,13 @@ package com.sckw.order.dao;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.sckw.order.model.KwoWantBuy;
+import com.sckw.order.model.vo.req.WantBuySelectParam;
+import com.sckw.order.model.vo.res.TableTopRes;
+import com.sckw.order.model.vo.res.WantBuySelectRes;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * @desc: 求购mapper
@@ -12,4 +18,9 @@ import org.apache.ibatis.annotations.Mapper;
 @Mapper
 public interface KwpWantBuyMapper extends BaseMapper<KwoWantBuy> {
 
+    List<WantBuySelectRes> queryBuyHallList(@Param("wantBuyReq") WantBuySelectParam wantBuyReq);
+
+    List<WantBuySelectRes> pageSelect(@Param("wantBuyReq") WantBuySelectParam wantBuyReq);
+
+    List<TableTopRes> statisticsCount(@Param("wantBuyReq") WantBuySelectParam wantBuyReq);
 }

+ 5 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/dao/KwpWantBuyTradingMapper.java

@@ -3,6 +3,9 @@ package com.sckw.order.dao;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.sckw.order.model.KwoWantBuyTrading;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * @desc: 求购支付方式mapper
@@ -12,4 +15,6 @@ import org.apache.ibatis.annotations.Mapper;
 @Mapper
 public interface KwpWantBuyTradingMapper extends BaseMapper<KwoWantBuyTrading> {
 
+    void insertBatch(@Param(value = "list") List<KwoWantBuyTrading> list);
+
 }

+ 78 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/model/vo/req/UpdateWantBuyParam.java

@@ -1,8 +1,15 @@
 package com.sckw.order.model.vo.req;
 
+import jakarta.validation.Valid;
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.NotNull;
+import jakarta.validation.constraints.Pattern;
 import lombok.Getter;
 import lombok.Setter;
 import lombok.ToString;
+import org.hibernate.validator.constraints.Length;
+
+import java.util.List;
 
 /**
  * @desc: 修改求购请求参数
@@ -13,4 +20,75 @@ import lombok.ToString;
 @Setter
 @ToString
 public class UpdateWantBuyParam {
+
+    /**
+     * 求购单id
+     */
+    @NotNull(message = "求购单id不能为空")
+    private Long id;
+
+    /**
+     * 商品名称
+     */
+    @NotBlank(message = "商品名称不能为空")
+    @Length(max = 50, message = "商品名称最多支持50字")
+    private String name;
+
+    /**
+     * 商品分类
+     */
+    @Length(max = 32, message = "商品分类最多支持32字")
+    private String goodsType;
+
+    /**
+     * 商品规格
+     */
+    @Length(max = 20, message = "商品规格最多支持20字")
+    private String spec;
+
+    /**
+     * 支付方式集合
+     */
+    private List<String> tradings;
+
+    /**
+     * 求购单价
+     */
+    @NotBlank(message = "求购单价不能为空")
+    @Length(max = 20, message = "求购单价最多支持20字")
+    private String price;
+
+    /**
+     * 求购总量
+     */
+    @NotBlank(message = "求购总量不能为空")
+    @Length(max = 20, message = "求购总量最多支持20字")
+    private String amount;
+
+    /**
+     * 联系人姓名
+     */
+    @NotBlank(message = "联系人姓名不能为空")
+    @Length(max = 32, message = "联系人姓名最多支持32字")
+    private String contacts;
+
+    /**
+     * 联系电话
+     */
+    @NotBlank(message = "联系电话不能为空")
+    @Pattern(regexp = "^1[3456789]\\d{9}$", message = "非法手机号格式")
+    private String phone;
+
+    /**
+     * 地址信息
+     */
+    @Valid
+    private WantBuyAddressParam addressInfo;
+
+    @Length(max = 200, message = "备注最多支持200字")
+    private String remark;
+
+
+
+
 }

+ 24 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/model/vo/req/WantBuyDels.java

@@ -0,0 +1,24 @@
+package com.sckw.order.model.vo.req;
+
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.NotEmpty;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.sckw.core.utils.LongToStringUtils;
+import java.util.List;
+
+/**
+ * @Description:
+ * @Author: lt
+ * @Date: 2023-07-25-15:10
+ */
+@Getter
+@Setter
+@ToString
+public class WantBuyDels {
+
+    @NotBlank(message = "ids不能为空")
+    private String ids;
+}

+ 75 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/model/vo/req/WantBuySelectParam.java

@@ -0,0 +1,75 @@
+package com.sckw.order.model.vo.req;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.sckw.core.model.page.PageRequest;
+import jakarta.validation.constraints.NotNull;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.io.Serial;
+import java.time.LocalDateTime;
+import java.util.List;
+
+/**
+ * @Description:
+ * @Author: lt
+ * @Date: 2023-07-26-15:43
+ */
+@Getter
+@Setter
+public class WantBuySelectParam extends PageRequest {
+
+    @Serial
+    private static final long serialVersionUID = 1881051859375157819L;
+
+    /**
+     * 关键字搜索
+     */
+    private String keywords;
+
+    /**
+     * 状态 来自com.sckw.core.common.enums.enums.DictEnum.GOODS_STATUS_0
+     */
+    private String status;
+
+    /**
+     * 支付集合字符串
+     */
+    private String trading;
+
+    /**
+     * 字符串转集合进行筛选
+     */
+    private List<String> tradings;
+
+    /**
+     * 地区编码
+     */
+    private String areaCode;
+
+    /**
+     * 地区级别
+     */
+    private String areaLevel;
+
+    /**
+     * 商品类型
+     */
+    private String goodsType;
+
+    /**
+     * 商品类型type值
+     */
+    private String goodsTypeValue;
+
+    private List<String> goodsTypeValueSearch;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @NotNull(message = "生成开始时间不能为空")
+    private LocalDateTime startCreateTime;
+
+    @NotNull(message = "生成结束时间不能为空")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private LocalDateTime endCreateTime;
+
+}

+ 30 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/model/vo/res/TableTopRes.java

@@ -0,0 +1,30 @@
+package com.sckw.order.model.vo.res;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+/**
+ * @Description:
+ * @Author: lt
+ * @Date: 2023-07-27-10:57
+ */
+@Getter
+@Setter
+@ToString
+public class TableTopRes {
+    /**
+     * tab名称
+     */
+    private String name;
+
+    /**
+     * 状态值
+     */
+    private String value;
+
+    /**
+     * 统计值
+     */
+    private long total;
+}

+ 5 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/model/vo/res/WantBuyDetailRes.java

@@ -31,6 +31,11 @@ public class WantBuyDetailRes implements Serializable {
      * 商品名称
      */
     private String name;
+
+    /**
+     * 求购企业name
+     */
+    private String entName;
     /**
      * 商品类型
      */

+ 93 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/model/vo/res/WantBuySelectRes.java

@@ -0,0 +1,93 @@
+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;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @Description:
+ * @Author: lt
+ * @Date: 2023-07-26-15:48
+ */
+@Getter
+@Setter
+public class WantBuySelectRes {
+
+    private Long id;
+
+    /**
+     * 商品名称
+     */
+    private String name;
+
+    private Long entId;
+
+
+    private String entName;
+
+    /**
+     * 商品分类
+     */
+    private String goodsType;
+
+    /**
+     * 商品分类label
+     */
+    private String goodsTypeLabel;
+
+    /**
+     * 规格
+     */
+    private String spec;
+
+    /**
+     * 地址信息
+     */
+    private String addressName;
+
+    /**
+     * 支付方式
+     */
+    private String tradings;
+
+    /**
+     * 求购单价
+     */
+    private String price;
+
+    /**
+     * 求购总量
+     */
+    private String amount;
+
+    /**
+     * 常见时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" ,timezone = "GMT+8")
+    private Date createTime;
+    /**
+     * 更新时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" ,timezone = "GMT+8")
+    private Date updateTime;
+
+    /**
+     * 状态
+     */
+    private Integer status;
+    private String statusLabel;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    //private List<KwoWantBuyTrading> wantBuyTradings;
+    private List<WantBuyTradingRes> wantBuyTradings;
+
+
+}

+ 20 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/model/vo/res/WantBuyTradingRes.java

@@ -0,0 +1,20 @@
+package com.sckw.order.model.vo.res;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @Author: lt
+ * @Date: 2023-07-26-20:26
+ */
+@Getter
+@Setter
+public class WantBuyTradingRes {
+
+    private Long wantBuyId;
+
+    private String trading;
+
+
+}

+ 8 - 24
sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwoTradeOrderService.java

@@ -128,12 +128,8 @@ public class KwoTradeOrderService {
             List<Long> entIds = unitInfos.stream().map(UnitInfo::getEntId).distinct().toList();
             Map<Long, EntCacheResDto> entMap = remoteSystemService.queryEntTreeByIds(entIds);
             unitInfos.forEach(e -> {
-                EntCacheResDto ent = entMap.get(e.getEntId());
-                if (Objects.isNull(ent)) {
-                    throw new BusinessException("企业:" + e.getFirmName() + "的一级企业信息不存在!");
-                }
                 KwoTradeOrderUnit unit = BeanUtils.copyProperties(e, KwoTradeOrderUnit.class);
-                unit.setTOrderId(id).setTOrderNo(tOrderNo).setTopEntId(ent.getId());
+                unit.setTOrderId(id).setTOrderNo(tOrderNo).setTopEntId(entMap.get(e.getEntId()).getId());
                 list.add(unit);
                 if (Objects.equals(e.getUnitType(), DictEnum.TORDER_UNIT_TYPE_1.getValue())) {
                     order.setProcureEntId(e.getEntId()).setProcureTopEntId(unit.getTopEntId()).setProcureFirmName(e.getFirmName())
@@ -227,14 +223,9 @@ public class KwoTradeOrderService {
      * @return: void
      */
     public void addPurchaseOrderSubmit(PurchaseOrderParam param) {
-        GoodsInfo goodsInfo = param.getGoodsInfo();
-        if (Objects.isNull(goodsInfo.getPriceRangeId())) {
-            throw new BusinessException("采购下单价格梯度信息不能为空!");
-        }
         OrderCheckDTO orderCheckDTO = BeanUtils.copyProperties(param, OrderCheckDTO.class);
         getTopEnt(orderCheckDTO, param.getUnitInfo());
-        orderCheckDTO.setGoodsId(goodsInfo.getGoodsId()).setUnitPrice(goodsInfo.getUnitPrice())
-                .setOrderSource(DictEnum.TORDER_SOURCE_1.getValue());
+        orderCheckDTO.setGoodsId(param.getGoodsInfo().getGoodsId()).setUnitPrice(param.getGoodsInfo().getUnitPrice());
         orderCheck(orderCheckDTO, false);
         KwoTradeOrder order = BeanUtils.copyProperties(param, KwoTradeOrder.class);
         order.setEntId(LoginUserHolder.getEntId()).setTOrderNo(OrderGenerateUtils.generateOrderNo(ORDER_NO_PREFIX))
@@ -261,11 +252,6 @@ public class KwoTradeOrderService {
         List<Long> entIds = unitInfo.stream().map(UnitInfo::getEntId).toList();
         Map<Long, EntCacheResDto> entMap = remoteSystemService.queryEntTreeByIds(entIds);
         unitInfo.forEach(e -> {
-            EntCacheResDto ent = entMap.get(e.getEntId());
-            if (Objects.isNull(ent)) {
-                log.error("企业:{}找不到对应一级企业信息", e.getEntId());
-                throw new BusinessException("一级企业信息不存在!");
-            }
             if (Objects.equals(e.getUnitType(), DictEnum.TORDER_UNIT_TYPE_1.getValue())) {
                 orderCheckDTO.setProcureTopEntId(entMap.get(e.getEntId()).getId());
             } else {
@@ -297,11 +283,11 @@ public class KwoTradeOrderService {
             throw new BusinessException("商品库存不足,请联系供应方!");
         }
         BigDecimal advancePrice = goods.getAdvancePrice().multiply(new BigDecimal("10000"));
-        //直接采购下单才校验预付款限额
-        if (Objects.equals(param.getOrderSource(), DictEnum.TORDER_SOURCE_1.getValue()) && trading.startsWith("1") && price.compareTo(advancePrice) < 0) {
+        //受理订单不校验预付款限额
+        if (!isAcceptanceOrder && trading.startsWith("0") && price.compareTo(advancePrice) < 0) {
             throw new BusinessException("您的订单总额未达到预付限额,请确认");
         }
-        if (trading.startsWith("1")) {
+        if (trading.startsWith("0")) {
             R<List<WalletDto>> wallet = payCenterDubboService.wallet(param.getProcureTopEntId(), ChannelEnum.getByCode(trading), param.getSupplyTopEntId());
             if (Objects.isNull(wallet) || Objects.equals(wallet.getCode(), 0)) {
                 throw new BusinessException("校验预付钱包异常,请联系管理员!");
@@ -311,7 +297,7 @@ public class KwoTradeOrderService {
                 throw new BusinessException("检测尚未创建对应预付款清单,请先创建!");
             }
             long money = data.get(0).getMoney();
-            if (money < advancePrice.multiply(new BigDecimal("100")).longValueExact()) {
+            if (money < advancePrice.multiply(new BigDecimal("10000")).longValueExact()) {
                 throw new BusinessException("您的预付清单可用余额不足,请先充值!");
             }
         }
@@ -328,8 +314,7 @@ public class KwoTradeOrderService {
     public void addValetOrderSubmit(ValetOrderParam param) {
         OrderCheckDTO orderCheck = BeanUtils.copyProperties(param, OrderCheckDTO.class);
         getTopEnt(orderCheck, param.getUnitInfo());
-        orderCheck.setGoodsId(param.getGoodsInfo().getGoodsId()).setUnitPrice(param.getGoodsInfo().getUnitPrice())
-                .setOrderSource(DictEnum.TORDER_SOURCE_2.getValue());
+        orderCheck.setGoodsId(param.getGoodsInfo().getGoodsId()).setUnitPrice(param.getGoodsInfo().getUnitPrice());
         orderCheck(orderCheck, false);
         KwoTradeOrder order = BeanUtils.copyProperties(param, KwoTradeOrder.class);
         order.setEntId(LoginUserHolder.getEntId()).setTOrderNo(OrderGenerateUtils.generateOrderNo(ORDER_NO_PREFIX))
@@ -465,8 +450,7 @@ public class KwoTradeOrderService {
             }
             OrderCheckDTO orderCheck = BeanUtils.copyProperties(param, OrderCheckDTO.class);
             getTopEnt(orderCheck, param.getUnitInfo());
-            orderCheck.setGoodsId(param.getGoodsInfo().getGoodsId()).setUnitPrice(param.getGoodsInfo().getUnitPrice())
-                    .setOrderSource(source);
+            orderCheck.setGoodsId(param.getGoodsInfo().getGoodsId()).setUnitPrice(param.getGoodsInfo().getUnitPrice());
             orderCheck(orderCheck, false);
             //扣减库存
             HttpResult updateResult = goodsInfoService.updateGoodsAmount(param.getGoodsInfo().getGoodsId(), param.getAmount());

+ 22 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwoWantBuyAddressService.java

@@ -1,10 +1,18 @@
 package com.sckw.order.serivce;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.sckw.core.model.constant.Global;
+import com.sckw.core.utils.CollectionUtils;
 import com.sckw.order.dao.KwpWantBuyAddressMapper;
+import com.sckw.order.model.KwoTradeOrderAddress;
+import com.sckw.order.model.KwoWantBuyAddress;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * @desc: 求购地址信息service
  * @author: yzc
@@ -17,4 +25,18 @@ public class KwoWantBuyAddressService {
 
     private final KwpWantBuyAddressMapper kwpWantBuyAddress;
 
+    public List<KwoWantBuyAddress> getByAddressId(Long addressId) {
+        LambdaQueryWrapper<KwoWantBuyAddress> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(KwoWantBuyAddress::getWantBuyId, addressId).eq(KwoWantBuyAddress::getDelFlag, Global.NO);
+        List<KwoWantBuyAddress> list = kwpWantBuyAddress.selectList(wrapper);
+        return CollectionUtils.emptyIfNull(list);
+    }
+
+    public void delAddressByWantBuyIds(List<String> wantBuyIds) {
+        LambdaUpdateWrapper<KwoWantBuyAddress> wrapper = new LambdaUpdateWrapper<>();
+        wrapper.in(KwoWantBuyAddress::getWantBuyId, wantBuyIds).eq(KwoWantBuyAddress::getDelFlag, Global.NO)
+                        .set(KwoWantBuyAddress::getDelFlag, Global.YES);
+        kwpWantBuyAddress.update(null,wrapper);
+    }
+
 }

+ 33 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwoWantBuyTradingService.java

@@ -1,10 +1,17 @@
 package com.sckw.order.serivce;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.sckw.core.model.constant.Global;
 import com.sckw.order.dao.KwpWantBuyTradingMapper;
+import com.sckw.order.model.KwoTradeOrderAddress;
+import com.sckw.order.model.KwoWantBuyTrading;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * @desc: 求购支付service
  * @author: yzc
@@ -17,6 +24,32 @@ public class KwoWantBuyTradingService {
 
     private final KwpWantBuyTradingMapper kwpWantBuyTradingMapper;
 
+    public void insertBatch(List<KwoWantBuyTrading> list) {
+        kwpWantBuyTradingMapper.insertBatch(list);
+    }
+
+    public List<KwoWantBuyTrading> getByWantBuyId(Long wantBuyId) {
+        LambdaQueryWrapper<KwoWantBuyTrading> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(KwoWantBuyTrading::getWantBuyId, wantBuyId).eq(KwoWantBuyTrading::getDelFlag, Global.NO);
+        List<KwoWantBuyTrading> list = kwpWantBuyTradingMapper.selectList(wrapper);
+        return list;
+    }
+
+    //根据wangtBuyId删除
+    public Integer deleteByWantBuyid(Long wantBuyid){
+        LambdaUpdateWrapper<KwoWantBuyTrading> wrapper = new LambdaUpdateWrapper<>();
+        wrapper.eq(KwoWantBuyTrading::getWantBuyId, wantBuyid).set(KwoWantBuyTrading::getDelFlag, Global.YES);
+        return kwpWantBuyTradingMapper.update(null,wrapper);
+    }
+
+    //根据wangtBuyIds批量删除
+    public void delTradingByWantBuyids(List<String> ids)
+    {
+        LambdaUpdateWrapper<KwoWantBuyTrading> wrapper = new LambdaUpdateWrapper<>();
+        wrapper.in(KwoWantBuyTrading::getWantBuyId, ids).eq(KwoWantBuyTrading::getDelFlag, Global.NO).set(KwoWantBuyTrading::getDelFlag, Global.YES);
+        kwpWantBuyTradingMapper.update(null,wrapper);
+    }
+
 
 
 }

+ 468 - 3
sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwpWantBuyService.java

@@ -1,12 +1,39 @@
 package com.sckw.order.serivce;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import com.sckw.core.common.enums.enums.DictEnum;
+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.utils.BeanUtils;
+import com.sckw.core.utils.CollectionUtils;
+import com.sckw.core.utils.IdWorker;
+import com.sckw.core.utils.StringUtils;
+import com.sckw.core.web.context.LoginUserHolder;
+import com.sckw.order.dao.KwpWantBuyAddressMapper;
 import com.sckw.order.dao.KwpWantBuyMapper;
+import com.sckw.order.dao.KwpWantBuyTradingMapper;
+import com.sckw.order.model.*;
 import com.sckw.order.model.vo.req.AddWantBuyParam;
 import com.sckw.order.model.vo.req.UpdateWantBuyParam;
-import com.sckw.order.model.vo.res.WantBuyDetailRes;
+import com.sckw.order.model.vo.req.WantBuyDels;
+import com.sckw.order.model.vo.req.WantBuySelectParam;
+import com.sckw.order.model.vo.res.*;
+import com.sckw.system.api.RemoteSystemService;
+import com.sckw.system.api.model.dto.res.EntCacheResDto;
+import com.sckw.system.api.model.dto.res.SysDictResDto;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.dubbo.config.annotation.DubboReference;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * @desc: 求购service
@@ -17,25 +44,463 @@ import org.springframework.stereotype.Service;
 @Slf4j
 @RequiredArgsConstructor
 public class KwpWantBuyService {
-
+    @DubboReference(version = "2.0.0", group = "design", check = false)
+    private RemoteSystemService remoteSystemService;
     private final KwpWantBuyMapper kwpWantBuyMapper;
+    private final KwpWantBuyTradingMapper kwpWantBuyTradingMapper;
+    private final KwpWantBuyAddressMapper kwpWantBuyAddressMapper;
     private final KwoWantBuyAddressService kwoWantBuyAddressService;
     private final KwoWantBuyTradingService kwoWantBuyTradingService;
 
+    /**
+     * @desc: 求购大厅列表查询
+     * @author lt
+     * @Date 11:50 2023/8/1 0001
+    **/
+    public PageRes<WantBuySelectRes> buyHallList(WantBuySelectParam wantBuySelectParam){
+        // 如果有求购方式的查询条件,需要先查询出求购方式的id
+        if (StringUtils.isNotBlank(wantBuySelectParam.getTrading())) {
+            List<String> longList = stringToLongList(wantBuySelectParam.getTrading());
+            wantBuySelectParam.setTradings(longList);
+        }
+        // 商品分类筛选处理
+        if (StringUtils.isNotBlank(wantBuySelectParam.getGoodsType()) && StringUtils.isNotBlank(wantBuySelectParam.getGoodsTypeValue())) {
+            List<String> goodsTypes = goodsTypeHandle(wantBuySelectParam);
+            wantBuySelectParam.setGoodsTypeValueSearch(goodsTypes);
+        }
+
+        // 分页查询求购列表
+        PageHelper.startPage(wantBuySelectParam.getPage(), wantBuySelectParam.getPageSize());
+        List<WantBuySelectRes> wantBuyDto = kwpWantBuyMapper.queryBuyHallList(wantBuySelectParam);
+
+        if (CollectionUtils.isEmpty(wantBuyDto)) {
+            return new PageRes<>();
+        }
+
+        // 获取供应企业信息
+        List<Long> supplyEntIds = wantBuyDto.stream()
+                .map(WantBuySelectRes::getEntId)
+                .collect(Collectors.toList());
+        // 通过企业id查询企业信息
+        List<EntCacheResDto> entList = remoteSystemService.queryEntCacheByIds(supplyEntIds);
+        Map<Long, String> entMap = entList.stream()
+                .collect(Collectors.toMap(EntCacheResDto::getId, EntCacheResDto::getFirmName, (k1, k2) -> k1));
+
+        // 对求购列表进行数据处理
+        wantBuyDto.forEach(wantBuySelectRes -> {
+            List<String> tradings = wantBuySelectRes.getWantBuyTradings().stream()
+                    .map(wantBuyTradingRes -> DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), wantBuyTradingRes.getTrading()))
+                    .collect(Collectors.toList());
+            wantBuySelectRes.setTradings(String.join(Global.COMMA, tradings));
+            wantBuySelectRes.setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), wantBuySelectRes.getGoodsType()));
+            wantBuySelectRes.setStatusLabel(DictEnum.getLabel(DictTypeEnum.GOODS_STATUS.getType(), String.valueOf(wantBuySelectRes.getStatus())));
+            wantBuySelectRes.setEntName(Objects.nonNull(entMap.get(wantBuySelectRes.getEntId())) ? entMap.get(wantBuySelectRes.getEntId()) : null);
+        });
+
+        return new PageRes<>(new PageInfo<>(wantBuyDto));
+    }
+
+    /**
+     * @desc 求购列表查询
+     * @author lt
+     * @Date 11:50 2023/8/1 0001
+    **/
+    public PageRes<WantBuySelectRes> select(WantBuySelectParam wantBuySelectParam) {
+
+        if (StringUtils.isNotBlank(wantBuySelectParam.getTrading())) {
+            List<String> longList = stringToLongList(wantBuySelectParam.getTrading());
+            wantBuySelectParam.setTradings(longList);
+        }
+        if (StringUtils.isNotBlank(wantBuySelectParam.getStatus())) {
+            wantBuySelectParam.setStatus(wantBuySelectParam.getStatus());
+        }
 
+        //商品分类筛选处理
+        if (StringUtils.isNotBlank(wantBuySelectParam.getGoodsType()) && StringUtils.isNotBlank(wantBuySelectParam.getGoodsTypeValue())) {
+            List<String> goodsTypes = goodsTypeHandle(wantBuySelectParam);
+            wantBuySelectParam.setGoodsTypeValueSearch(goodsTypes);
+        }
+        PageHelper.startPage(wantBuySelectParam.getPage(), wantBuySelectParam.getPageSize());
+        List<WantBuySelectRes> wantBuyDto = kwpWantBuyMapper.pageSelect(wantBuySelectParam);
+        System.out.println(wantBuyDto);
+        if (CollectionUtils.isEmpty(wantBuyDto)) {
+            return new PageRes<>();
+        }
+        // 获取供应企业信息
+        List<Long> supplyEntIds = wantBuyDto.stream()
+                .map(WantBuySelectRes::getEntId)
+                .collect(Collectors.toList());
+        // 通过企业id查询企业信息
+        List<EntCacheResDto> entList = remoteSystemService.queryEntCacheByIds(supplyEntIds);
+        Map<Long, String> entMap = entList.stream()
+                .collect(Collectors.toMap(EntCacheResDto::getId, EntCacheResDto::getFirmName, (k1, k2) -> k1));
+        //把查询出来的集合wantBuyTradings里面对的tranding 转成字符串放在String里面
+        wantBuyDto.forEach(wantBuySelectRes -> {
+            List<String> tradings = wantBuySelectRes.getWantBuyTradings().stream()
+                    .map(wantBuyTradingRes -> DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), wantBuyTradingRes.getTrading()))
+                    .collect(Collectors.toList());
+            wantBuySelectRes.setTradings(String.join(Global.COMMA, tradings));
+            wantBuySelectRes.setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), wantBuySelectRes.getGoodsType()));
+            wantBuySelectRes.setStatusLabel(DictEnum.getLabel(DictTypeEnum.GOODS_STATUS.getType(), String.valueOf(wantBuySelectRes.getStatus())));
+            wantBuySelectRes.setEntName(Objects.nonNull(entMap.get(wantBuySelectRes.getEntId())) ? entMap.get(wantBuySelectRes.getEntId()) : null);
+        });
+
+        return new PageRes<>(new PageInfo<>(wantBuyDto));
+    }
+
+    /**
+     * @Desc 求购列表查询
+     * @param wantBuySelectParam
+     * @return
+     */
+    private List<String> goodsTypeHandle(WantBuySelectParam wantBuySelectParam) {
+        List<SysDictResDto> goodsTypeList = remoteSystemService.queryDictBottom(wantBuySelectParam.getGoodsType(), wantBuySelectParam.getGoodsTypeValue());
+        if (CollectionUtils.isNotEmpty(goodsTypeList)) {
+            return  goodsTypeList.stream().map(SysDictResDto::getValue).toList();
+        }
+        return null;
+    }
+
+    /**
+     * @Desc 字符串转数组
+     * @return
+     */
+    private List<String> stringToLongList(String str) {
+        if (StringUtils.isBlank(str)) {
+            return null;
+        }
+// 使用逗号分隔字符串,并去除两端空格
+        String[] stringArray = str.split(Global.COMMA);
+        return Arrays.asList(stringArray);
+    }
+
+    /**
+     * @Desc 求购草稿新增
+     * @Author lt
+     * @Param
+     * @Return
+     * @Date 11:56 2023/7/25 0025
+     **/
     public void addDraft(AddWantBuyParam param) {
+        Integer status = Integer.valueOf(DictEnum.GOODS_STATUS_0.getValue());  //保存草稿
+        String message = "求购草稿";
+        addWantBuy(param, message, status);
 
     }
 
+    /**
+     * @Desc 求购上架新增
+     * @Author lt
+     * @Param
+     * @Return
+     * @Date 11:57 2023/7/25 0025
+     **/
     public void addShelves(AddWantBuyParam param) {
+        Integer status = Integer.valueOf(DictEnum.GOODS_STATUS_1.getValue());   //上架
+        String message = "求购上架";
+        addWantBuy(param, message, status);
+    }
 
+    /**
+     * @desc 新增求购统一方法
+     * @author lt
+     * @Date 11:52 2023/8/1 0001
+    **/
+    @Transactional(rollbackFor = Exception.class)
+    public void addWantBuy(AddWantBuyParam param, String message, Integer status) {
+        Date currentDate = new Date();
+        Long entId = LoginUserHolder.getEntId();
+        if (Objects.isNull(entId)) {
+            throw new BusinessException("企业ID不存在,请重新登录");
+        }
+//        KwoWantBuy kwoWantBuy = BeanUtils.copyProperties(param, KwoWantBuy.class);
+        KwoWantBuy kwoWantBuy = new KwoWantBuy();
+        Long userId = LoginUserHolder.getUserId();
+        kwoWantBuy.setEntId(LoginUserHolder.getEntId())
+                .setName(param.getName()).setGoodsType(param.getGoodsType())
+                .setSpec(param.getSpec()).setPrice(param.getPrice())
+                .setAmount(param.getAmount()).setContacts(param.getContacts())
+                .setPhone(param.getPhone()).setId(new IdWorker(1L).nextId())
+                .setRemark(param.getRemark()).setStatus(status).setCreateBy(userId)
+                .setCreateTime(currentDate).setUpdateBy(userId)
+                .setUpdateTime(currentDate).setDelFlag(Global.NO);
+        kwpWantBuyMapper.insert(kwoWantBuy);
+        if (Objects.isNull(kwoWantBuy.getId())) {
+            throw new BusinessException(message + "失败");
+        }
+        /*
+        支付方式添加
+         */
+        List<String> list = param.getTradings();
+        if (list != null && !list.isEmpty()) {
+            Date currentDateTime = new Date();
+            List<KwoWantBuyTrading> tradingList = list.stream()
+                    .map(item -> {
+                        KwoWantBuyTrading kwoWantBuyTrading = new KwoWantBuyTrading();
+                        kwoWantBuyTrading.setWantBuyId(kwoWantBuy.getId());
+                        kwoWantBuyTrading.setTrading(item);
+                        kwoWantBuyTrading.setCreateBy(userId);
+                        kwoWantBuyTrading.setCreateTime(currentDateTime);
+                        kwoWantBuyTrading.setUpdateTime(currentDateTime);
+                        kwoWantBuyTrading.setStatus(status);
+                        return kwoWantBuyTrading;
+                    })
+                    .collect(Collectors.toList());
+            kwoWantBuyTradingService.insertBatch(tradingList);
+        }
+        /*
+        地址信息添加,如果存在地址信息-新增入库
+         */
+        if (Objects.nonNull(param.getAddressInfo())) {
+            KwoWantBuyAddress address = new KwoWantBuyAddress();
+            Long idWorker = new IdWorker(1L).nextId();
+            address.setWantBuyId(kwoWantBuy.getId());
+            address.setName(param.getAddressInfo().getName());
+            address.setType(param.getAddressInfo().getType());
+            address.setContacts(param.getAddressInfo().getContacts());
+            address.setPhone(param.getAddressInfo().getPhone());
+            address.setCityCode(param.getAddressInfo().getCityCode());
+            address.setCityName(param.getAddressInfo().getCityName());
+            address.setDetailAddress(param.getAddressInfo().getDetailAddress());
+            address.setLat(param.getAddressInfo().getLat());
+            address.setLng(param.getAddressInfo().getLng());
+            address.setFence(param.getAddressInfo().getFence());
+            address.setId(idWorker);
+            address.setCreateBy(LoginUserHolder.getUserId());
+            address.setCreateTime(new Date());
+            address.setUpdateTime(new Date());
+            kwpWantBuyAddressMapper.insert(address);
+        }
     }
 
+    /**
+     * @Desc: 求购上架
+     * @Author: lt
+     * @Date: 13:38 2023/7/25 0025
+     **/
+    public void putOnShelves(Long id) {
+        KwoWantBuy kwoWantBuy = kwpWantBuyMapper.selectById(id);
+        if (Objects.isNull(kwoWantBuy)) {
+            throw new BusinessException("求购信息不存在");
+        }
+        if (kwoWantBuy.getStatus().equals(Integer.valueOf(DictEnum.GOODS_STATUS_1.getValue()))) {
+            throw new BusinessException("求购信息已上架");
+        }
+        kwoWantBuy.setStatus(Integer.valueOf(DictEnum.GOODS_STATUS_1.getValue()));
+        kwpWantBuyMapper.updateById(kwoWantBuy);
+    }
+
+    /**
+     * @desc 求购批量下架
+     * @author lt
+     * @Date 14:56 2023/7/25 0025
+     **/
+    public void batchTakeOffShelves(WantBuyDels param) {
+        if (BeanUtils.isEmpty(param)) {
+            throw new BusinessException("请提供需要下架的产品");
+        }
+        List<String> ids = List.of(param.getIds().split(Global.COMMA));
+        //1.查询ids所属产品只有status=1的才能下架,如果存在其它状态的则不能下架
+        LambdaUpdateWrapper<KwoWantBuy> updateWrapper = new LambdaUpdateWrapper<>();
+        updateWrapper.eq(KwoWantBuy::getDelFlag, Global.NO).in(KwoWantBuy::getId, ids);
+        updateWrapper.set(KwoWantBuy::getStatus, DictEnum.GOODS_STATUS_2.getValue())
+                .set(KwoWantBuy::getUpdateBy, LoginUserHolder.getUserId())
+                .set(KwoWantBuy::getUpdateTime, new Date());
+        kwpWantBuyMapper.update(null, updateWrapper);
+    }
+
+    /**
+     * @desc 求购删除
+     * @author lt
+     * @Date 10:15 2023/8/1 0001
+    **/
+    @Transactional(rollbackFor = Exception.class)
+    public void dels(WantBuyDels param) {
+        List<String> ids = List.of(param.getIds().split(","));
+        LambdaUpdateWrapper<KwoWantBuy> updateWrapper = new LambdaUpdateWrapper<>();
+        updateWrapper.in(KwoWantBuy::getId, ids).eq(KwoWantBuy::getDelFlag, Global.NO)
+                .set(KwoWantBuy::getDelFlag, Global.YES)
+                .set(KwoWantBuy::getUpdateBy, LoginUserHolder.getUserId())
+                .set(KwoWantBuy::getUpdateTime, new Date());
+        kwpWantBuyMapper.update(null, updateWrapper);
+        //删除地址信息
+        kwoWantBuyAddressService.delAddressByWantBuyIds(ids);
+        //删除支付方式
+        kwoWantBuyTradingService.delTradingByWantBuyids(ids);
+
+    }
+
+    /**
+     * @desc 求购详情查询
+     * @author lt
+     * @Date 10:15 2023/8/1 0001
+    **/
     public WantBuyDetailRes detail(Long id) {
-        return null;
+        //先判断求购订单是否存在
+        KwoWantBuy kwoWantBuy = kwpWantBuyMapper.selectById(id);
+        if (Objects.isNull(kwoWantBuy)) {
+            throw new BusinessException("求购信息不存在");
+        }
+        WantBuyDetailRes responseData = BeanUtils.copyProperties(kwoWantBuy, WantBuyDetailRes.class);
+        //TODO 还未定义好求购状态(从表里面拿还是enum)
+        responseData.setStatusLabel(DictEnum.getLabel(DictTypeEnum.GOODS_STATUS.getType(), String.valueOf(responseData.getStatus())));
+        //求购地址信息
+        KwoWantBuyAddress address = kwpWantBuyAddressMapper.selectOne(new LambdaQueryWrapper<KwoWantBuyAddress>()
+                .eq(KwoWantBuyAddress::getWantBuyId, id).eq(KwoWantBuyAddress::getDelFlag, Global.NO));
+        if (Objects.nonNull(address)) {
+            WantBuyAddressDetailRes wantBuyAddressInfo = BeanUtils.copyProperties(address, WantBuyAddressDetailRes.class);
+            wantBuyAddressInfo.setTypeLabel(DictEnum.getLabel(DictTypeEnum.TORDER_ADDRESS_TYPE.getType(), String.valueOf(wantBuyAddressInfo.getType())));
+            System.out.println(wantBuyAddressInfo);
+            responseData.setAddressInfo(wantBuyAddressInfo);
+        }
+        //获取求购企业信息
+        EntCacheResDto entCacheResDto = remoteSystemService.queryEntCacheById(kwoWantBuy.getEntId());
+        if (Objects.nonNull(entCacheResDto)) {
+            responseData.setEntName(entCacheResDto.getFirmName());
+        }
+        //求购支付方式集合
+        List<KwoWantBuyTrading> tradingList = kwoWantBuyTradingService.getByWantBuyId(id);
+        if (Objects.nonNull(tradingList) && !tradingList.isEmpty()) {
+            List<String> tradings = tradingList.stream().map(KwoWantBuyTrading::getTrading).collect(Collectors.toList());
+            responseData.setTradings(tradings);
+            //改成stream流的方式
+            List<String> result = tradings.stream()
+                    .map(trading -> DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), trading))
+                    .collect(Collectors.toList());
+            String tradingLabels = String.join(Global.COMMA, result);
+            //获取到的是一个集合,需要转换成字符串
+            responseData.setTradingLabels(tradingLabels);
+        }
+        return responseData;
     }
 
+    /**
+     * @desc: 更新求购信息
+     * @author lt
+     * @Date 15:20 2023/7/26 0026
+     **/
     public void update(UpdateWantBuyParam param) {
+        Long id = param.getId();
+        KwoWantBuy kwoWantBuy = selectOneById(id);
+        if (Objects.isNull(kwoWantBuy)) throw new BusinessException("求购信息不存在");
+        //1.更新求购信息
+        Date currentDate = new Date();
+        Long userId = LoginUserHolder.getUserId();
+        KwoWantBuy wantBuy = BeanUtils.copyProperties(param, KwoWantBuy.class);
+        wantBuy.setUpdateBy(userId);
+        wantBuy.setUpdateTime(currentDate);
+        kwpWantBuyMapper.updateById(wantBuy);
+        //int i = kwpWantBuyMapper.updateById(wantBuy);
+        //2.更新求购地址信息,判断是否存在地址信息
+
+        if (Objects.nonNull(param.getAddressInfo())) {
+            //判断是否存在地址信息
+            LambdaQueryWrapper<KwoWantBuyAddress> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.eq(KwoWantBuyAddress::getWantBuyId, id).eq(KwoWantBuyAddress::getDelFlag, Global.NO);
+            KwoWantBuyAddress kwoWantBuyAddress = kwpWantBuyAddressMapper.selectOne(queryWrapper);
+            //存在地址信息则更新,不存在则新增
+
+            KwoWantBuyAddress kwoWantBuyAddress1 = BeanUtils.copyProperties(param.getAddressInfo(), KwoWantBuyAddress.class);
+            kwoWantBuyAddress1.setUpdateTime(currentDate);
+            kwoWantBuyAddress1.setUpdateBy(userId);
+            if (Objects.nonNull(kwoWantBuyAddress)) {
+                kwoWantBuyAddress1.setId(kwoWantBuyAddress.getId());
+                kwpWantBuyAddressMapper.updateById(kwoWantBuyAddress1);
+            } else {
+                //不存在则新增地址信息
+                kwoWantBuyAddress1.setWantBuyId(id);
+                kwoWantBuyAddress1.setCreateTime(currentDate);
+                kwoWantBuyAddress1.setCreateBy(userId);
+                kwpWantBuyAddressMapper.insert(kwoWantBuyAddress1);
+            }
+        }
+        //3.更新求购支付方式
+        List<String> tradings = param.getTradings();
+        if (CollectionUtils.isNotEmpty(tradings)) {
+            kwoWantBuyTradingService.deleteByWantBuyid(id);
+            ArrayList<KwoWantBuyTrading> list = new ArrayList<>(param.getTradings().size());
+            for (String trading : tradings) {
+                KwoWantBuyTrading kwoWantBuyTrading = new KwoWantBuyTrading();
+                kwoWantBuyTrading.setWantBuyId(id);
+                kwoWantBuyTrading.setTrading(trading);
+                kwoWantBuyTrading.setCreateTime(currentDate);
+                kwoWantBuyTrading.setUpdateTime(currentDate);
+                kwoWantBuyTrading.setCreateBy(userId);
+                list.add(kwoWantBuyTrading);
+            }
+            kwpWantBuyTradingMapper.insertBatch(list);
+        }
+
+
+    }
+
+    /**
+     * @Desc: 根据id查询求购信息
+     * @param id
+     * @return
+     */
+    public KwoWantBuy selectOneById(Long id) {
+        LambdaQueryWrapper<KwoWantBuy> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(KwoWantBuy::getId, id)
+                .eq(KwoWantBuy::getDelFlag, Global.NO);
+        return kwpWantBuyMapper.selectOne(queryWrapper);
+    }
+
+    /**
+     * @Desc: 查询求购角标统计数量
+     * @param
+     * @return
+     */
+    public Map statistic(WantBuySelectParam params) {
+        if (StringUtils.isNotBlank(params.getTrading())) {
+            List<String> longList = stringToLongList(params.getTrading());
+            params.setTradings(longList);
+        }
+        if (StringUtils.isNotBlank(params.getStatus())) {
+            params.setStatus(params.getStatus());
+        }
+        //商品分类筛选处理
+        if (StringUtils.isNotBlank(params.getGoodsType()) && StringUtils.isNotBlank(params.getGoodsTypeValue())) {
+            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;
     }
 }

+ 118 - 0
sckw-modules/sckw-order/src/main/resources/mapper/KwoWantBuyMapper.xml

@@ -0,0 +1,118 @@
+<?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.sckw.order.dao.KwpWantBuyMapper">
+
+    <sql id="Base_Column_List">
+        kb.id
+        ,kb.`name`
+        ,kb.ent_id
+        , kb.goods_type goodsType
+        , kb.spec
+        , kb.price
+        , kb.amount
+        , kb.status
+        , kb.remark
+        , kb.create_time createTime
+        , kt.want_buy_id wantBuyId
+        , kt.trading trading
+        , kba.name addressName
+    </sql>
+
+    <resultMap id="wangBuyResultMap" type="com.sckw.order.model.vo.res.WantBuySelectRes">
+        <id column="id" property="id"/>
+        <result column="name" property="name"/>
+        <result column="goodsType" property="goodsType"/>
+        <result column="spec" property="spec"/>
+        <result column="price" property="price"/>
+        <result column="amount" property="amount"/>
+        <result column="status" property="status"/>
+        <result column="remark" property="remark"/>
+        <result column="createTime" property="createTime"/>
+        <result column="updateTime" property="updateTime"/>
+        <collection property="wantBuyTradings" column="id" ofType="com.sckw.order.model.vo.res.WantBuyTradingRes" javaType="java.util.List" select="tradingSql" >
+            <id column="wantBuyId" property="wantBuyId"/>
+            <result column="trading" property="trading"/>
+        </collection>
+    </resultMap>
+
+    <sql id="where">
+        kb.del_flag = 0 and kt.del_flag = 0
+        <if test="wantBuyReq.startCreateTime != null and wantBuyReq.endCreateTime != null">
+            and kb.create_time between #{wantBuyReq.startCreateTime,jdbcType=TIMESTAMP} and
+            #{wantBuyReq.endCreateTime,jdbcType=TIMESTAMP}
+        </if>
+        <if test="wantBuyReq.tradings != null and wantBuyReq.tradings.size() > 0">
+            and kt.trading in
+            <foreach collection="wantBuyReq.tradings" item="item" open="(" close=")" separator=",">
+                #{item,jdbcType=VARCHAR}
+            </foreach>
+        </if>
+        <if test="wantBuyReq.status != null and wantBuyReq.status != ''">
+            and kb.status = #{wantBuyReq.status}
+        </if>
+        <if test="wantBuyReq.keywords != null and wantBuyReq.keywords != ''">
+            and (
+            kb.`name` like concat('%', #{wantBuyReq.keywords,jdbcType=VARCHAR}, '%')
+            )
+        </if>
+        <if test="wantBuyReq.goodsTypeValueSearch != null and wantBuyReq.goodsTypeValueSearch.size() > 0">
+            and kb.goods_type in
+            <foreach collection="wantBuyReq.goodsTypeValueSearch" item="item" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        <if test="wantBuyReq.areaCode != null and wantBuyReq.areaCode != ''">
+            and kba.city_code = #{wantBuyReq.areaCode}
+        </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
+        <where>
+            <include refid="where" />
+        </where>
+        group by kb.id
+        order by kb.create_time desc
+    </select>
+
+<!--    <resultMap id="tradIngMap" type="com.sckw.order.model.KwoWantBuyTrading">-->
+    <resultMap id="tradIngMap" type="com.sckw.order.model.vo.res.WantBuyTradingRes">
+        <id column="wantBuyId" property="wantBuyId"/>
+        <result column="trading" property="trading"/>
+    </resultMap>
+
+
+    <select id="tradingSql" resultMap="tradIngMap">
+        select want_buy_id wantBuyId, trading
+        from kwo_want_buy_trading
+        where want_buy_id = #{wantBuyId}
+    </select>
+
+
+
+    <select id="statisticsCount"  resultType="com.sckw.order.model.vo.res.TableTopRes" parameterType="java.util.Map">
+        select kb.`status` value
+        from kwo_want_buy kb left join kwo_want_buy_trading kt on kb.id = kt.want_buy_id
+        <where>
+            <include refid="where" />
+        </where>
+        group by kb.id
+        order by kb.create_time desc
+    </select>
+
+
+    <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
+        <where>
+            <include refid="where" />
+        </where>
+        group by kb.id
+        order by kb.create_time desc
+    </select>
+</mapper>

+ 36 - 0
sckw-modules/sckw-order/src/main/resources/mapper/KwoWantBuyTradingMapper.xml

@@ -0,0 +1,36 @@
+<?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.sckw.order.dao.KwpWantBuyTradingMapper">
+
+    <insert id="insertBatch">
+        insert into kwo_want_buy_trading
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            id,
+            want_buy_id,
+            trading,
+            remark,
+            status,
+            create_by,
+            create_time,
+            update_by,
+            update_time,
+            del_flag
+        </trim>
+        values
+        <foreach collection="list" item="item" separator=",">
+            <trim prefix="(" suffix=")" suffixOverrides=",">
+                #{item.id,jdbcType=BIGINT},
+                #{item.wantBuyId,jdbcType=BIGINT},
+                #{item.trading,jdbcType=VARCHAR},
+                #{item.remark,jdbcType=VARCHAR},
+                #{item.status,jdbcType=VARCHAR},
+                #{item.createBy,jdbcType=VARCHAR},
+                #{item.createTime,jdbcType=VARCHAR},
+                #{item.updateBy,jdbcType=VARCHAR},
+                #{item.updateTime,jdbcType=VARCHAR},
+                #{item.delFlag,jdbcType=VARCHAR}
+            </trim>
+        </foreach>
+    </insert>
+
+</mapper>