Эх сурвалжийг харах

app-二级市场根据分类查订单

linbl 1 жил өмнө
parent
commit
72c6897636

+ 2 - 0
sp-core/sp-api/src/main/java/com/pj/api/client/level_one_server/LevelOneServerInterface.java

@@ -94,6 +94,8 @@ public interface LevelOneServerInterface {
     @RequestMapping("/app/TbOrder/rpc/updateBeingOrder")
     public boolean updateBeingOrder(@RequestParam("id") Long levelOneOrderId);
 
+    @RequestMapping("/app/TbGoodsType/rpc/getGoodsIds")
+    public List<Long> getGoodsIds(@RequestParam("typeCode") String typeCode);
     /**
      * 远程调用: 根据电话查询外籍商户
      */

+ 5 - 0
sp-core/sp-api/src/main/java/com/pj/api/client/level_one_server/LevelOneServerInterfaceFallback.java

@@ -148,6 +148,11 @@ public class LevelOneServerInterfaceFallback implements FallbackFactory<LevelOne
             }
 
             @Override
+            public List<Long> getGoodsIds(String typeCode) {
+                return null;
+            }
+
+            @Override
             public List<EnterpriseDto> getEnterpriseDtoListByPhone(String phone) {
                 System.out.println(throwable.getMessage());
                 log.error("查询一级市场外籍商户错误,当前电话:{},错误信息是:{}",phone,throwable.getMessage());

+ 56 - 1
sp-core/sp-api/src/main/java/com/pj/api/dto/HtGoodsDto.java

@@ -23,6 +23,16 @@ public class HtGoodsDto {
 
     private String storageEnvm;
 
+    private String fieldCode;
+
+    private String goodsPrice;
+
+    private String opType;
+
+    private String thrItemCode;
+
+    private String thrItemName;
+
     public String getHsCode() {
         return hsCode;
     }
@@ -79,7 +89,47 @@ public class HtGoodsDto {
         this.storageEnvm = storageEnvm;
     }
 
-    public HtGoodsDto(String hsCode, String gName, String gUnit, String unit1, String unit2, String useTo, String storageEnvm) {
+    public String getFieldCode() {
+        return fieldCode;
+    }
+
+    public void setFieldCode(String fieldCode) {
+        this.fieldCode = fieldCode;
+    }
+
+    public String getGoodsPrice() {
+        return goodsPrice;
+    }
+
+    public void setGoodsPrice(String goodsPrice) {
+        this.goodsPrice = goodsPrice;
+    }
+
+    public String getOpType() {
+        return opType;
+    }
+
+    public void setOpType(String opType) {
+        this.opType = opType;
+    }
+
+    public String getThrItemCode() {
+        return thrItemCode;
+    }
+
+    public void setThrItemCode(String thrItemCode) {
+        this.thrItemCode = thrItemCode;
+    }
+
+    public String getThrItemName() {
+        return thrItemName;
+    }
+
+    public void setThrItemName(String thrItemName) {
+        this.thrItemName = thrItemName;
+    }
+
+    public HtGoodsDto(String hsCode, String gName, String gUnit, String unit1, String unit2, String useTo, String storageEnvm, String fieldCode, String goodsPrice, String opType, String thrItemCode, String thrItemName) {
         this.hsCode = hsCode;
         this.gName = gName;
         this.gUnit = gUnit;
@@ -87,6 +137,11 @@ public class HtGoodsDto {
         this.unit2 = unit2;
         this.useTo = useTo;
         this.storageEnvm = storageEnvm;
+        this.fieldCode = fieldCode;
+        this.goodsPrice = goodsPrice;
+        this.opType = opType;
+        this.thrItemCode = thrItemCode;
+        this.thrItemName = thrItemName;
     }
 
     public HtGoodsDto() {

+ 40 - 30
sp-service/level-one-server/src/main/java/com/pj/tb_goods/TbGoods.java

@@ -15,7 +15,7 @@ import lombok.experimental.Accessors;
 
 /**
  * Model: tb_goods -- 商品
- * @author qzy 
+ * @author qzy
  */
 @Data
 @Accessors(chain = true)
@@ -25,15 +25,15 @@ public class TbGoods extends Model<TbGoods> implements Serializable {
 
 	// ---------- 模块常量 ----------
 	/**
-	 * 序列化版本id 
+	 * 序列化版本id
 	 */
-	private static final long serialVersionUID = 1L;	
+	private static final long serialVersionUID = 1L;
 	/**
-	 * 此模块对应的表名 
+	 * 此模块对应的表名
 	 */
-	public static final String TABLE_NAME = "tb_goods";	
+	public static final String TABLE_NAME = "tb_goods";
 	/**
-	 * 此模块对应的权限码 
+	 * 此模块对应的权限码
 	 */
 	public static final String PERMISSION_CODE = "tb-goods";
 	public static final String PERMISSION_CODE_ADD = "tb-goods-add";
@@ -45,66 +45,71 @@ public class TbGoods extends Model<TbGoods> implements Serializable {
 
 	// ---------- 表中字段 ----------
 	/**
-	 * 主键 
+	 * 主键
 	 */
 	@TableId(type = IdType.AUTO)
 	@JsonSerialize(using = ToStringSerializer.class)
 	private Long id;
-
 	/**
-	 * 名称 
+	 * 互市区id
+	 */
+	private Long tradeAreaId;
+	/**
+	 *互市区名称
+	 */
+	private String tradeAreaName;
+	/**
+	 * 名称
 	 */
 	private String name;
 
 	/**
-	 * 主图 
+	 * 主图
 	 */
-	private String avatar;	
+	private String avatar;
 
 	/**
-	 * 分类ID 字符串(可多选) 
+	 * 分类ID 字符串(可多选)
 	 */
-	private String typeIds;	
+	private String typeIds;
 
 	/**
-	 * 分类名称 
+	 * 分类名称
 	 */
-	private String typeNames;	
+	private String typeNames;
 
 	/**
-	 * 编号 
+	 * 编号
 	 */
 	private String code;
 
 	/**
-	 * 备注 
+	 * 备注
 	 */
-	private String remark;	
+	private String remark;
 
 	/**
-	 * 原产地 
+	 * 原产地
 	 */
-	private String source;	
+	private String source;
 
 	/**
-	 * 状态(0=禁用,1=启用) 
+	 * 状态(0=禁用,1=启用)
 	 */
 	private int status;
 
-
-
 	/**
-	 *  
+	 * 商品单位
 	 */
 	private String unit;
 
 	/**
-	 *  
+	 * 维护价格
 	 */
-	private Double singlePrice;	
+	private Double singlePrice;
 
 	/**
-	 *  
+	 *
 	 */
 	private String taxNo;
 
@@ -162,8 +167,13 @@ public class TbGoods extends Model<TbGoods> implements Serializable {
 	 * 存储条件
 	 */
 	private String storageEnvm;
-
-
-
+	/**
+	 * 商品类目编码
+	 */
+	private String thrItemCode;
+	/**
+	 * 商品类目名称
+	 */
+	private String thrItemName;
 
 }

+ 34 - 1
sp-service/level-one-server/src/main/java/com/pj/tb_goods/TbGoodsService.java

@@ -11,10 +11,15 @@ import java.util.stream.Collectors;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.pj.api.dto.GoodsDto;
 import com.pj.api.dto.HtGoodsDto;
 import com.pj.enummj.DeleteStatus;
 import com.pj.enummj.Status;
+import com.pj.tb_goods_type.TbGoodsType;
+import com.pj.tb_goods_type.TbGoodsTypeMapper;
+import com.pj.tb_trade_area.TbTradeArea;
+import com.pj.tb_trade_area.TbTradeAreaService;
 import com.pj.utils.so.SoMap;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.hssf.usermodel.HSSFRow;
@@ -26,9 +31,9 @@ import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.transaction.annotation.Transactional;
-import com.pj.utils.sg.*;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.annotation.Resource;
 import javax.swing.filechooser.FileSystemView;
 
 /**
@@ -42,6 +47,10 @@ public class TbGoodsService extends ServiceImpl<TbGoodsMapper, TbGoods> implemen
 	/** 底层 Mapper 对象 */
 	@Autowired
 	TbGoodsMapper tbGoodsMapper;
+	@Autowired
+	TbGoodsTypeMapper tbGoodsTypeMapper;
+	@Resource
+	private TbTradeAreaService tbTradeAreaService;
 
 	@Autowired
 	private MethodGoodsService methodGoodsService;
@@ -81,6 +90,15 @@ public class TbGoodsService extends ServiceImpl<TbGoodsMapper, TbGoods> implemen
 
 	/** 远程调用: 同步航通海关监管商品信息 */
 	public boolean goodsDto(HtGoodsDto goodsDto){
+		//操作类型:01 新增,02,修改,03 删除
+		if("03".equals(goodsDto.getOpType())) {
+			boolean del = update(new LambdaUpdateWrapper<TbGoods>()
+					.set(TbGoods::getDeleteStatus,DeleteStatus.DELETE_STATUS_OFF.getCode())
+					.eq(TbGoods::getCode,goodsDto.getHsCode()));
+			return del;
+		}
+		TbTradeArea tbTradeArea = tbTradeAreaService.updateHandler(goodsDto.getFieldCode(), "");
+
 		TbGoods tbGoods = new TbGoods();
 		List<TbGoods> tbGoodsList = tbGoodsMapper.selectList(new LambdaQueryWrapper<TbGoods>().eq(TbGoods::getCode, goodsDto.getHsCode()));
 		//数据库没有就是新增
@@ -90,6 +108,8 @@ public class TbGoodsService extends ServiceImpl<TbGoodsMapper, TbGoods> implemen
 			tbGoods.setName(goodsDto.getgName());
 			tbGoods.setUnit(goodsDto.getgUnit());
 			tbGoods.setCode(goodsDto.getHsCode());
+			tbGoods.setTradeAreaId(tbTradeArea.getId());
+			tbGoods.setTradeAreaName(tbTradeArea.getName());
 			tbGoods.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode()); // 默认未删除
 			tbGoods.setStatus(Status.STATUS_ONE.getCode()); // 默认可用
 			tbGoods.setCreateTime(new Date());
@@ -102,6 +122,19 @@ public class TbGoodsService extends ServiceImpl<TbGoodsMapper, TbGoods> implemen
 		BeanUtils.copyProperties(goods,tbGoods);
 		BeanUtils.copyProperties(goodsDto,tbGoods);
 		int i = tbGoodsMapper.updateById(tbGoods);
+
+		//新增商品类目表
+		List<TbGoodsType> typeList = tbGoodsTypeMapper.selectList(new LambdaQueryWrapper<TbGoodsType>().eq(TbGoodsType::getNo, goodsDto.getThrItemCode()));
+		if(typeList.size() == 0) {
+			TbGoodsType goodsType = new TbGoodsType();
+			goodsType.setNo(goodsDto.getThrItemCode());
+			goodsType.setName(goodsDto.getThrItemName());
+			goodsType.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode()); // 默认未删除
+			goodsType.setCreateTime(new Date());
+			goodsType.setCreateName("航通");
+			tbGoodsTypeMapper.insert(goodsType);
+		}
+
 		return i == 1;
 	}
 

+ 17 - 3
sp-service/level-one-server/src/main/java/com/pj/tb_goods_type/TbGoodsTypeAppController.java

@@ -4,6 +4,7 @@ import com.pj.utils.sg.AjaxJson;
 import com.pj.utils.so.SoMap;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.util.List;
@@ -19,14 +20,27 @@ public class TbGoodsTypeAppController {
 
 	/** 查集合 (整个表数据转化为tree结构返回) */
 	@RequestMapping("getTree")
-	public AjaxJson getTree() { 
-		// 获取记录 
+	public AjaxJson getTree() {
+		// 获取记录
 		SoMap so = SoMap.getRequestSoMap();
 		List<TbGoodsType> list = tbGoodsTypeService.getList(so);
-		// 转为tree结构,并返回 
+		// 转为tree结构,并返回
 		List<SoMap> listMap = SoMap.getSoMapByList(list);
 		List<SoMap> listTree = SoMap.listToTree(listMap, "id", "parentId", "children");
 		return AjaxJson.getSuccessData(listTree);
 	}
 
+	/** 查集合 - 根据条件(参数为空时代表忽略指定条件) */
+	@RequestMapping("getAppList")
+	public AjaxJson getAppList() {
+		SoMap so = new SoMap();
+		so.set("deleteStatus", 1);
+		List<TbGoodsType> list = tbGoodsTypeService.getList(so);
+		return AjaxJson.getSuccessData(list);
+	}
+
+	@RequestMapping("rpc/getGoodsIds")
+	public List<Long> getGoodsIds(@RequestParam("typeCode") String typeCode) {
+		return tbGoodsTypeService.getGoodsIds(typeCode);
+	}
 }

+ 14 - 4
sp-service/level-one-server/src/main/java/com/pj/tb_goods_type/TbGoodsTypeService.java

@@ -3,7 +3,9 @@ package com.pj.tb_goods_type;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Objects;
+import java.util.stream.Collectors;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.pj.tb_goods.TbGoods;
 import com.pj.tb_goods.TbGoodsMapper;
 import com.pj.utils.so.SoMap;
@@ -15,7 +17,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 /**
  * Service: tb_goods_type -- 商品分类
- * @author qzy 
+ * @author qzy
  */
 @Service
 @Transactional(rollbackFor = Exception.class)
@@ -48,9 +50,9 @@ public class TbGoodsTypeService extends ServiceImpl<TbGoodsTypeMapper, TbGoodsTy
 		return super.getById(id);
 	}
 
-	/** 查集合 - 根据条件(参数为空时代表忽略指定条件) */  
-	List<TbGoodsType> getList(SoMap so) { 
-		return tbGoodsTypeMapper.getList(so);	
+	/** 查集合 - 根据条件(参数为空时代表忽略指定条件) */
+	List<TbGoodsType> getList(SoMap so) {
+		return tbGoodsTypeMapper.getList(so);
 	}
 
 	/**
@@ -112,4 +114,12 @@ public class TbGoodsTypeService extends ServiceImpl<TbGoodsTypeMapper, TbGoodsTy
 		return line;
 	}
 
+	public List<Long> getGoodsIds(String typeCode) {
+		LambdaQueryWrapper<TbGoods> wrapper = new LambdaQueryWrapper<>();
+		wrapper.eq(TbGoods::getThrItemCode, typeCode);
+		List<TbGoods> goodsList = tbGoodsMapper.selectList(wrapper);
+
+		List<Long> goodsIds = goodsList.stream().map(TbGoods::getId).collect(Collectors.toList());
+		return goodsIds;
+	}
 }

+ 13 - 1
sp-service/level-two-server/src/main/java/com/pj/tb_orders/TbOrdersService.java

@@ -43,6 +43,7 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * Service: tb_orders -- 订单表
@@ -245,7 +246,18 @@ public class TbOrdersService extends ServiceImpl<TbOrdersMapper, TbOrders> imple
      * 查集合 - 查二级市场订单(未被购买的订单)
      */
     List<TbOrders> getLevelTwoList(SoMap so) {
-        return tbOrdersMapper.getLevelTwoList(so);
+        List<TbOrders> levelTwoList = tbOrdersMapper.getLevelTwoList(so);
+
+        String typeCode = so.getString("typeCode");
+        if(StringUtils.isNotEmpty(typeCode)) {
+            List<TbOrders> collect = new ArrayList<>();
+            List<Long> goodsIds = levelOneServerInterface.getGoodsIds(typeCode);
+            goodsIds.forEach(goodsId -> {
+                collect.addAll(levelTwoList.stream().filter(map -> map.getGoodsId().equals(goodsId)).collect(Collectors.toList()));
+            });
+            return collect;
+        }
+        return levelTwoList;
     }
 
     /**