Bläddra i källkod

7.26 一级市场 - app - 公共 - 商品列表

Mechrevo 1 år sedan
förälder
incheckning
9e04312b25

+ 3 - 1
sp-service/level-one-server/src/main/java/com/pj/tb_goods_cart/TbGoodsCart.java

@@ -67,6 +67,8 @@ public class TbGoodsCart extends Model<TbGoodsCart> implements Serializable {
 
 	private String goodsName;
 
+	private Integer buyNum;
+
 	/**
 	 *  
 	 */
@@ -83,7 +85,7 @@ public class TbGoodsCart extends Model<TbGoodsCart> implements Serializable {
 	private Long saleGoodsInfoId;	
 
 	/**
-	 * 购买数量 
+	 * 商品重量
 	 */
 	private Double buyWeight;	
 

+ 20 - 1
sp-service/level-one-server/src/main/java/com/pj/tb_goods_cart/TbGoodsCartService.java

@@ -8,6 +8,8 @@ import com.pj.api.dto.AppUserDto;
 import com.pj.current.satoken.StpUserUtil;
 import com.pj.enummj.DeleteStatus;
 import com.pj.tb_goods_cart.dto.GoodsCartInfoDto;
+import com.pj.tb_goods_transit.TbGoodsTransit;
+import com.pj.tb_goods_transit.TbGoodsTransitMapper;
 import com.pj.utils.so.SoMap;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -31,7 +33,9 @@ public class TbGoodsCartService extends ServiceImpl<TbGoodsCartMapper, TbGoodsCa
 
 	@Autowired
 	private AdminInterface adminInterface;
-
+	/** 已过审的商品 */
+	@Autowired
+	private TbGoodsTransitMapper tbGoodsTransitMapper;
 	/** 增 */
 	void add(TbGoodsCart t){
 		save(t);
@@ -64,11 +68,26 @@ public class TbGoodsCartService extends ServiceImpl<TbGoodsCartMapper, TbGoodsCa
 //		StpUserUtil.checkLogin();
 		//验证购买者
 		Long id = goodsCartInfoDto.getBuyUserId();
+		//获取购买者对象
 		AppUserDto appUser = adminInterface.getAppUserById(id);
 		if(appUser == null)return AjaxJson.getError("购买者账号异常");
+		//获取商品对象
+		Long infoId = goodsCartInfoDto.getSaleGoodsInfoId();
+		TbGoodsTransit tbGoodsTransit = tbGoodsTransitMapper.selectById(infoId);
+		if(tbGoodsTransit == null)return AjaxJson.getError("当前商品信息存在异常");
 		//创建保存对象
 		TbGoodsCart tbGoodsCart = new TbGoodsCart();
 		BeanUtils.copyProperties(goodsCartInfoDto,tbGoodsCart);
+		//购买的用户类型
+		tbGoodsCart.setBuyType(appUser.getUserType());
+		//购买方式,默认都是互助组进行购买
+		tbGoodsCart.setBuyType(2 + "");
+		//购买商品的重量
+		tbGoodsCart.setBuyWeight(Double.valueOf(goodsCartInfoDto.getBuyNum()));
+		//商品价格
+		tbGoodsCart.setTotalPrice((goodsCartInfoDto.getBuyNum() == null? 0 : goodsCartInfoDto.getBuyNum())
+				*
+				(tbGoodsTransit.getPrice() == null? 0 : tbGoodsTransit.getPrice()));
 		//设置基本属性
 		tbGoodsCart.setCreateTime(new Date());
 		tbGoodsCart.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode());

+ 9 - 9
sp-service/level-one-server/src/main/java/com/pj/tb_goods_cart/dto/GoodsCartInfoDto.java

@@ -21,20 +21,20 @@ public class GoodsCartInfoDto {
     private Long buyUserId;
     /** 商家ID */
     @NotNull(message = "商家ID必填")
-    private String merchantId;
+    private Long enterpriseId;
     /** 店铺ID */
     @NotNull(message = "店铺ID必填")
-    private String shopId;
+    private Long shopId;
     /** 购买地点ID */
     @NotNull(message = "区域ID必填")
-    private String tradeAreaId;
-    /** 购买总价 */
-    @NotNull(message = "必填")
-    @DecimalMin("0.0")
-    private Double totalPrice;
+    private Long tradeAreaId;
+//    /** 购买总价 */
+//    @NotNull(message = "必填")
+//    @DecimalMin("0.0")
+//    private Double totalPrice;
     /** 商品ID */
     @NotNull(message = "商品ID必填")
-    private Long goodsId;
+    private Long saleGoodsInfoId;
     /** 购买者类型(边民/...) */
     @NotNull(message = "购买者ID必填")
     private Integer buyUserType;
@@ -49,6 +49,6 @@ public class GoodsCartInfoDto {
     private String goodsName;
     /** 购买个数 */
     @NotNull(message = "购买个数必填")
-    private Integer buyWeight;
+    private Integer buyNum;
 
 }