Browse Source

Merge remote-tracking branch 'origin/release-201816-wangcz' into release-201816-wangcz

dongbw 7 years ago
parent
commit
efb8216f0c

+ 1 - 1
src/main/java/com/uas/platform/b2c/advertise/ad/api/StoreRecommendController.java

@@ -47,7 +47,7 @@ public class StoreRecommendController {
 	/**
 	 * 当卖家新增或修改产品推荐时,创建或更新产品推荐信息
 	 */
-	@RequestMapping(method = RequestMethod.POST, value = "/products//update_batch")
+	@RequestMapping(method = RequestMethod.POST, value = "/products/update_batch")
 	public List<RecommendProduct> saveProductsWhenSellerUpdate(String uuid,
    			@RequestBody List<RecommendProduct> productList) {
 		return recommendProductService.saveProductsWhenSellerUpdate(uuid, productList);

+ 20 - 0
src/main/java/com/uas/platform/b2c/advertise/ad/dao/AdvantageCommodityRepository.java

@@ -0,0 +1,20 @@
+package com.uas.platform.b2c.advertise.ad.dao;
+
+import com.uas.platform.b2c.advertise.ad.model.AdvantageCommodity;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+
+@Repository
+public interface AdvantageCommodityRepository extends JpaSpecificationExecutor<AdvantageCommodity>,JpaRepository<AdvantageCommodity, Long> {
+
+	/**
+	 * 根据店铺UUID获取优势库存信息
+	 *
+	 * @param storeUuid		店铺UUID
+	 */
+	List<AdvantageCommodity> findByStoreUuid(String storeUuid);
+}

+ 36 - 0
src/main/java/com/uas/platform/b2c/advertise/ad/dao/RecommendProductDao.java

@@ -0,0 +1,36 @@
+package com.uas.platform.b2c.advertise.ad.dao;
+
+import com.uas.platform.b2c.advertise.ad.model.RecommendProduct;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+import java.util.Set;
+
+@Repository
+public interface RecommendProductDao extends JpaRepository<RecommendProduct, Long>,JpaSpecificationExecutor<RecommendProduct> {
+
+	/**
+	 * 根据店铺企业UU获取产品推荐信息
+	 *
+	 * @param storeEnUU		店铺企业UU
+	 */
+	List<RecommendProduct> findByStoreEnUUOrderByOrderAsc(Long storeEnUU);
+
+	/**
+	 * 根据店铺UUID获取产品推荐信息
+	 *
+	 * @param storeUuid		店铺UUID
+	 */
+	List<RecommendProduct> findByStoreUuidOrderByOrderAsc(String storeUuid);
+
+	/**
+	 * 根据店铺和商品批次号获取产品推荐信息列表
+	 *
+	 * @param storeUuid		店铺UUID
+	 * @param batchCodes	商品批次号集合
+	 * @return	产品推荐信息列表
+	 */
+	List<RecommendProduct> findByStoreUuidAndBatchCodeIn(String storeUuid, Set<String> batchCodes);
+}

+ 26 - 155
src/main/java/com/uas/platform/b2c/advertise/ad/model/AdvantageCommodity.java

@@ -1,5 +1,7 @@
 package com.uas.platform.b2c.advertise.ad.model;
 
+import javax.persistence.*;
+import java.io.Serializable;
 import java.util.Date;
 
 /**
@@ -8,12 +10,16 @@ import java.util.Date;
  * @author huxz
  * @version 2017-03-03 10:44:16 创建文件
  */
-public class AdvantageCommodity {
+@Entity
+@Table(name = "store$advantagecommodity")
+public class AdvantageCommodity implements Serializable {
 
 	/**
 	 * 主键UUID
 	 */
-	private String id;
+	@Id
+	@GeneratedValue(strategy = GenerationType.AUTO)
+	private Long id;
 
 	/*=========================================================================
 	 * 基础信息
@@ -22,64 +28,77 @@ public class AdvantageCommodity {
 	/**
 	 * 创建时间
 	 */
+	@Column(name ="ad_create_time")
 	private Date createTime;
 
 	/**
 	 * 修改时间
 	 */
+	@Column(name = "ad_update_time")
 	private Date updateTime;
 
 	/**
 	 * 排序
 	 */
-	private int order;
+	@Column(name = "ad_order")
+	private Integer order;
 
 	/*=========================================================================
 	 * 商品基础信息
 	 *=========================================================================*/
+
 	/**
 	 * 商品批次号
 	 */
+	@Column(name = "ad_com_batchCode")
 	private String batchCode;
 
 	/**
 	 * 对应的器件uuid
 	 */
+	@Column(name = "ad_com_uuid")
 	private String comUuid;
 
 	/**
 	 * 原厂型号
 	 */
+	@Column(name = "ad_com_code")
 	private String comCode;
 
 	/**
 	 * 图片path
 	 */
+	@Column(name = "ad_com_img")
 	private String comImg;
 
 	/**
 	 * 类名UUID
 	 */
+	@Column(name = "ad_kind_uuid")
 	private String kindUuid;
 
 	/**
 	 * 类目的名称
 	 */
+	@Column(name = "ad_kind_name_cn")
 	private String kindNameCn;
 
 	/**
 	 * 品牌中文名称
 	 */
+	@Column(name = "ad_brand_name_cn")
 	private String brandNameCn;
 
 	/**
 	 * 本批次的最低人民币价格
 	 */
+	@Column(name = "ad_min_price_rmb")
 	private Double minPriceRMB;
 
 	/**
 	 * 本批次的最低美元价格
 	 */
+	@Column(name = "ad_min_price_usd")
 	private Double minPriceUSD;
 
 	/*=========================================================================
@@ -89,282 +108,134 @@ public class AdvantageCommodity {
 	/**
 	 * 店铺所属公司
 	 */
+	@Column(name = "ad_store_enuu")
 	private Long storeEnUU;
 
 	/**
 	 * 店铺UUID
 	 */
+	@Column(name = "ad_store_uuid")
 	private String storeUuid;
 
 	public AdvantageCommodity() {
 	}
 
-	/**
-	 * Gets id.
-	 *
-	 * @return the id
-	 */
-	public String getId() {
+	public Long getId() {
 		return id;
 	}
 
-	/**
-	 * Sets id.
-	 *
-	 * @param id the id
-	 */
-	public void setId(String id) {
+	public void setId(Long id) {
 		this.id = id;
 	}
 
-	/**
-	 * Gets create time.
-	 *
-	 * @return the create time
-	 */
 	public Date getCreateTime() {
 		return createTime;
 	}
 
-	/**
-	 * Sets create time.
-	 *
-	 * @param createTime the create time
-	 */
 	public void setCreateTime(Date createTime) {
 		this.createTime = createTime;
 	}
 
-	/**
-	 * Gets update time.
-	 *
-	 * @return the update time
-	 */
 	public Date getUpdateTime() {
 		return updateTime;
 	}
 
-	/**
-	 * Sets update time.
-	 *
-	 * @param updateTime the update time
-	 */
 	public void setUpdateTime(Date updateTime) {
 		this.updateTime = updateTime;
 	}
 
-	/**
-	 * Gets order.
-	 *
-	 * @return the order
-	 */
 	public int getOrder() {
 		return order;
 	}
 
-	/**
-	 * Sets order.
-	 *
-	 * @param order the order
-	 */
 	public void setOrder(int order) {
 		this.order = order;
 	}
 
-	/**
-	 * Gets batch code.
-	 *
-	 * @return the batch code
-	 */
 	public String getBatchCode() {
 		return batchCode;
 	}
 
-	/**
-	 * Sets batch code.
-	 *
-	 * @param batchCode the batch code
-	 */
 	public void setBatchCode(String batchCode) {
 		this.batchCode = batchCode;
 	}
 
-	/**
-	 * Gets com uuid.
-	 *
-	 * @return the com uuid
-	 */
 	public String getComUuid() {
 		return comUuid;
 	}
 
-	/**
-	 * Sets com uuid.
-	 *
-	 * @param comUuid the com uuid
-	 */
 	public void setComUuid(String comUuid) {
 		this.comUuid = comUuid;
 	}
 
-	/**
-	 * Gets com code.
-	 *
-	 * @return the com code
-	 */
 	public String getComCode() {
 		return comCode;
 	}
 
-	/**
-	 * Sets com code.
-	 *
-	 * @param comCode the com code
-	 */
 	public void setComCode(String comCode) {
 		this.comCode = comCode;
 	}
 
-	/**
-	 * Gets com img.
-	 *
-	 * @return the com img
-	 */
 	public String getComImg() {
 		return comImg;
 	}
 
-	/**
-	 * Sets com img.
-	 *
-	 * @param comImg the com img
-	 */
 	public void setComImg(String comImg) {
 		this.comImg = comImg;
 	}
 
-	/**
-	 * Gets kind uuid.
-	 *
-	 * @return the kind uuid
-	 */
 	public String getKindUuid() {
 		return kindUuid;
 	}
 
-	/**
-	 * Sets kind uuid.
-	 *
-	 * @param kindUuid the kind uuid
-	 */
 	public void setKindUuid(String kindUuid) {
 		this.kindUuid = kindUuid;
 	}
 
-	/**
-	 * Gets kind name cn.
-	 *
-	 * @return the kind name cn
-	 */
 	public String getKindNameCn() {
 		return kindNameCn;
 	}
 
-	/**
-	 * Sets kind name cn.
-	 *
-	 * @param kindNameCn the kind name cn
-	 */
 	public void setKindNameCn(String kindNameCn) {
 		this.kindNameCn = kindNameCn;
 	}
 
-	/**
-	 * Gets brand name cn.
-	 *
-	 * @return the brand name cn
-	 */
 	public String getBrandNameCn() {
 		return brandNameCn;
 	}
 
-	/**
-	 * Sets brand name cn.
-	 *
-	 * @param brandNameCn the brand name cn
-	 */
 	public void setBrandNameCn(String brandNameCn) {
 		this.brandNameCn = brandNameCn;
 	}
 
-	/**
-	 * Gets min price rmb.
-	 *
-	 * @return the min price rmb
-	 */
 	public Double getMinPriceRMB() {
 		return minPriceRMB;
 	}
 
-	/**
-	 * Sets min price rmb.
-	 *
-	 * @param minPriceRMB the min price rmb
-	 */
 	public void setMinPriceRMB(Double minPriceRMB) {
 		this.minPriceRMB = minPriceRMB;
 	}
 
-	/**
-	 * Gets min price usd.
-	 *
-	 * @return the min price usd
-	 */
 	public Double getMinPriceUSD() {
 		return minPriceUSD;
 	}
 
-	/**
-	 * Sets min price usd.
-	 *
-	 * @param minPriceUSD the min price usd
-	 */
 	public void setMinPriceUSD(Double minPriceUSD) {
 		this.minPriceUSD = minPriceUSD;
 	}
 
-	/**
-	 * Gets store en uu.
-	 *
-	 * @return the store en uu
-	 */
 	public Long getStoreEnUU() {
 		return storeEnUU;
 	}
 
-	/**
-	 * Sets store en uu.
-	 *
-	 * @param storeEnUU the store en uu
-	 */
 	public void setStoreEnUU(Long storeEnUU) {
 		this.storeEnUU = storeEnUU;
 	}
 
-	/**
-	 * Gets store uuid.
-	 *
-	 * @return the store uuid
-	 */
 	public String getStoreUuid() {
 		return storeUuid;
 	}
 
-	/**
-	 * Sets store uuid.
-	 *
-	 * @param storeUuid the store uuid
-	 */
 	public void setStoreUuid(String storeUuid) {
 		this.storeUuid = storeUuid;
 	}

+ 49 - 23
src/main/java/com/uas/platform/b2c/advertise/ad/model/RecommendProduct.java

@@ -1,5 +1,8 @@
 package com.uas.platform.b2c.advertise.ad.model;
 
+
+import javax.persistence.*;
+import java.io.Serializable;
 import java.util.Date;
 
 /**
@@ -8,12 +11,16 @@ import java.util.Date;
  * history:
  * Created by huxz on 2017-3-3 10:44:16
  */
-public class RecommendProduct {
+@Entity
+@Table(name = "store$recommendproduct")
+public class RecommendProduct implements Serializable {
 
 	/**
 	 * 主键UUID
 	 */
-	private String id;
+	@Id
+	@GeneratedValue(strategy = GenerationType.AUTO)
+	private Long id;
 
 	/*=========================================================================
 	 * 基础信息
@@ -22,17 +29,20 @@ public class RecommendProduct {
 	/**
 	 * 创建时间
 	 */
+	@Column(name = "create_time")
 	private Date createTime;
 
 	/**
 	 * 修改时间
 	 */
+	@Column(name = "update_time")
 	private Date updateTime;
 
 	/**
 	 * 排序
 	 */
-	private int order;
+	@Column(name = "recommend_order")
+	private Integer order = 1;
 
 	/*=========================================================================
 	 * 商品基础信息
@@ -41,67 +51,80 @@ public class RecommendProduct {
 	/**
 	 * 商品批次号
 	 */
-	private String batchCode;
+	@Column(name = "batch_code")
+	private String batchCode = "";
 
 	/**
 	 * 对应的器件uuid
 	 */
-	private String comUuid;
+	@Column(name = "com_uuid")
+	private String comUuid = "";
 
 	/**
 	 * 原厂型号
 	 */
-	private String comCode;
+	@Column(name = "com_code")
+	private String comCode = "";
 
 	/**
 	 * 图片path
 	 */
-	private String comImg;
+	@Column(name = "com_img")
+	private String comImg = "";
 
 	/**
 	 * 类名UUID
 	 */
-	private String kindUuid;
+	@Column(name = "kind_uuid")
+	private String kindUuid = "";
 
 	/**
 	 * 类目的名称
 	 */
-	private String kindNameCn;
+	@Column(name = "kind_name_cn")
+	private String kindNameCn = "";
 
 	/**
 	 * 品牌中文名称
 	 */
-	private String brandNameCn;
+	@Column(name = "brand_name_cn")
+	private String brandNameCn = "";
 
 	/**
 	 * 本批次的最低人民币价格
 	 */
-	private Double minPriceRMB;
+	@Column(name = "min_price_rmb")
+	private Double minPriceRMB = 0.0;
 
 	/**
 	 * 本批次的最低美元价格
 	 */
-	private Double minPriceUSD;
+	@Column(name = "min_price_usd")
+	private Double minPriceUSD = 0.0;
 
 	/**
 	 * 商品库存量
 	 */
-	private Double reserve;
+	@Column(name = "reserve")
+	private Double reserve = 0.0;
 
 	/**
 	 * 最小起订量
 	 */
-	private Double minBuyQty;
+	@Column(name = "min_buy_qty")
+	private Double minBuyQty = 0.0;
 
 	/**
 	 * 币别
 	 */
-	private String currency;
+	@Column(name = "currency")
+	private String currency = "";
 
 	/**
 	 * 产品上架的店铺的UUID
 	 */
-	private String storeId;
+	@Column(name = "store_second_id")
+	private String storeId = "";
 
 	/*=========================================================================
 	 * 店铺信息
@@ -110,17 +133,20 @@ public class RecommendProduct {
 	/**
 	 * 产品推荐拥有者所属公司UU
 	 */
-	private Long storeEnUU;
+	@Column(name = "store_enuu")
+	private Long storeEnUU = 0l;
 
 	/**
 	 * 产品推荐拥有者的店铺UUID
 	 */
-	private String storeUuid;
+	@Column(name = "store_uuid")
+	private String storeUuid = "";
 
 	/**
 	 * 售罄状态
 	 */
-	private Integer status;
+	@Column(name = "status")
+	private Integer status = 601;
 
 	public RecommendProduct() {
 	}
@@ -133,11 +159,11 @@ public class RecommendProduct {
 		this.status = status;
 	}
 
-	public String getId() {
+	public Long getId() {
 		return id;
 	}
 
-	public void setId(String id) {
+	public void setId(Long id) {
 		this.id = id;
 	}
 
@@ -157,11 +183,11 @@ public class RecommendProduct {
 		this.updateTime = updateTime;
 	}
 
-	public int getOrder() {
+	public Integer getOrder() {
 		return order;
 	}
 
-	public void setOrder(int order) {
+	public void setOrder(Integer order) {
 		this.order = order;
 	}
 

+ 8 - 9
src/main/java/com/uas/platform/b2c/advertise/ad/service/impl/AdvantageCommodityServiceImpl.java

@@ -1,11 +1,11 @@
 package com.uas.platform.b2c.advertise.ad.service.impl;
 
+import com.uas.platform.b2c.advertise.ad.dao.AdvantageCommodityRepository;
 import com.uas.platform.b2c.advertise.ad.model.AdvantageCommodity;
 import com.uas.platform.b2c.advertise.ad.service.AdvantageCommodityService;
 import com.uas.platform.b2c.core.config.MicroServicesConf;
 import com.uas.platform.b2c.core.config.MicroServicesConfMulti;
 import com.uas.platform.b2c.core.config.SysConf;
-import com.uas.platform.b2c.core.utils.JacksonUtils;
 import com.uas.platform.b2c.trade.support.CodeType;
 import com.uas.platform.b2c.trade.support.ResultMap;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -33,24 +33,23 @@ public class AdvantageCommodityServiceImpl implements AdvantageCommodityService
 
 	private final SysConf sysConf;
 
+	private final AdvantageCommodityRepository advantageCommodityRepository;
+
 	@Autowired
-	public AdvantageCommodityServiceImpl(MicroServicesConf conf, RestTemplate restTemplate, SysConf sysConf, MicroServicesConfMulti confMulti) {
+	public AdvantageCommodityServiceImpl(MicroServicesConf conf, RestTemplate restTemplate, SysConf sysConf, MicroServicesConfMulti confMulti, AdvantageCommodityRepository advantageCommodityRepository) {
 		this.conf = conf;
 		this.restTemplate = restTemplate;
 		this.sysConf = sysConf;
 		this.confMulti = confMulti;
+		this.advantageCommodityRepository = advantageCommodityRepository;
 	}
 
 	@Override
 	public List<AdvantageCommodity> findByStoreUuid(String storeUuid) {
-		if (StringUtils.hasText(storeUuid)) {
-			String url = confMulti.getRecommendUrl( "/store-cms/advantages?storeUuid=" + storeUuid);
-			String result = restTemplate.getForEntity(url, String.class).getBody();
-			if (StringUtils.hasText(result)) {
-				return JacksonUtils.fromJsonArray(result, AdvantageCommodity.class);
-			}
+		if (StringUtils.isEmpty(storeUuid)) {
+			return Collections.emptyList();
 		}
-		return Collections.emptyList();
+		return advantageCommodityRepository.findByStoreUuid(storeUuid);
 	}
 
 	/**

+ 40 - 47
src/main/java/com/uas/platform/b2c/advertise/ad/service/impl/RecommendProductServiceImpl.java

@@ -1,11 +1,10 @@
 package com.uas.platform.b2c.advertise.ad.service.impl;
 
-import com.uas.platform.b2c.advertise.ad.model.Message;
+import com.uas.platform.b2c.advertise.ad.dao.RecommendProductDao;
 import com.uas.platform.b2c.advertise.ad.model.RecommendProduct;
 import com.uas.platform.b2c.advertise.ad.service.RecommendProductService;
 import com.uas.platform.b2c.advertise.ad.utils.RecommendProductsUtils;
 import com.uas.platform.b2c.core.config.MicroServicesConfMulti;
-import com.uas.platform.b2c.core.utils.JacksonUtils;
 import com.uas.platform.b2c.prod.commodity.dao.GoodsDao;
 import com.uas.platform.b2c.prod.commodity.model.Goods;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -16,12 +15,7 @@ import org.springframework.util.CollectionUtils;
 import org.springframework.util.StringUtils;
 import org.springframework.web.client.RestTemplate;
 
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 
 /**
  * 产品推荐业务实现类
@@ -43,51 +37,39 @@ public class RecommendProductServiceImpl implements RecommendProductService {
 
 	private final MicroServicesConfMulti conf;
 
+	private final RecommendProductDao recommendProductDao;
+
 	@Autowired
-	public RecommendProductServiceImpl(RestTemplate restTemplate, GoodsDao goodsDao, KafkaTemplate<String, String> kafkaTemplate, MicroServicesConfMulti conf) {
+	public RecommendProductServiceImpl(RestTemplate restTemplate, GoodsDao goodsDao, KafkaTemplate<String, String> kafkaTemplate, MicroServicesConfMulti conf, RecommendProductDao recommendProductDao) {
 		this.restTemplate = restTemplate;
 		this.goodsDao = goodsDao;
 		this.kafkaTemplate = kafkaTemplate;
 		this.conf = conf;
+		this.recommendProductDao = recommendProductDao;
 	}
 
 	@Override
 	public void deleteProductsWhenSellerUpdateReserve(String storeUuid, Set<String> batchCodes) {
-		if (StringUtils.isEmpty(storeUuid) || CollectionUtils.isEmpty(batchCodes)) {
-			return;
-		}
-
-		if (StringUtils.isEmpty(profile)) {
-			throw new IllegalStateException("无法获取配置文件属性值");
-		}
-
-		Date date = new Date();
-
-		Message message = new Message();
-		message.setId(date.getTime());
-		message.setSendTime(date);
-		message.setUuid(storeUuid);
-		message.setBatchCodes(batchCodes);
-		System.out.println(JacksonUtils.toJson(message));
-
-		/*String topic = "recommend-products-delete" + "-" + ("prod".equals(profile) ? "prod" : "test");
-		kafkaTemplate.send(topic, "batchCode", JacksonUtils.toJson(message));*/
-		String url = conf.getRecommendUrl("/api/recommend/products/delete");
-		restTemplate.postForObject(url, JacksonUtils.toJson(message), String.class);
+        if (StringUtils.isEmpty(storeUuid) || CollectionUtils.isEmpty(batchCodes)) {
+            return ;
+        }
+        List<RecommendProduct> products = recommendProductDao.findByStoreUuidAndBatchCodeIn(storeUuid, batchCodes);
+
+        // 如果查询到了产品推荐信息,则删除对应的推荐产品
+        if (!CollectionUtils.isEmpty(products)) {
+            recommendProductDao.delete(products);
+        }
 	}
 
 	@Override
 	public List<RecommendProduct> findProductsWhenUserVisitStore(String uuid) {
-		Map<String, String> map = new HashMap<>();
-		map.put("uuid", uuid);
-		String url = conf.getRecommendUrl("/api/recommend/products?condition=store_uuid&uuid={uuid}");
-		String content = restTemplate.getForObject(url, String.class, map);
-		if (StringUtils.isEmpty(content)) {
+		if (StringUtils.isEmpty(uuid)) {
 			return Collections.emptyList();
 		}
-
-		List<RecommendProduct> recommendProducts = JacksonUtils.fromJsonArray(content, RecommendProduct.class);
-
+		List<RecommendProduct> recommendProducts = recommendProductDao.findByStoreUuidOrderByOrderAsc(uuid);
+		if (org.apache.commons.collections.CollectionUtils.isEmpty(recommendProducts)) {
+			recommendProducts = new ArrayList<>();
+		}
 		for (RecommendProduct product : recommendProducts) {
 			Goods commodity = goodsDao.findByBatchCode(product.getBatchCode());
 			if (commodity != null) {
@@ -107,24 +89,35 @@ public class RecommendProductServiceImpl implements RecommendProductService {
 			productList = Collections.emptyList();
 		}
 
-		String url = conf.getRecommendUrl("/api/recommend/products?uuid=" + uuid);
+		if (StringUtils.isEmpty(uuid)) {
+			return Collections.emptyList();
+		}
 
-		String content;
-		try {
-			content = restTemplate.postForObject(url, productList, String.class);
-		} catch (Exception e) {
-			content = "[]";
+		List<RecommendProduct> products = recommendProductDao.findByStoreUuidOrderByOrderAsc(uuid);
+		if (!CollectionUtils.isEmpty(products)) {
+			recommendProductDao.delete(products);
 		}
 
-		List<RecommendProduct> recommendProducts = JacksonUtils.fromJsonArray(content, RecommendProduct.class);
+		if (CollectionUtils.isEmpty(productList)) {
+			return Collections.emptyList();
+		}
 
-		for (RecommendProduct product : recommendProducts) {
+		for (RecommendProduct product : productList) {
+			Date nowDate = new Date();
+
+			product.setStoreUuid(uuid);
+			product.setCreateTime(nowDate);
+			product.setUpdateTime(nowDate);
+		}
+		recommendProductDao.save(productList);
+
+		for (RecommendProduct product : productList) {
 			Goods commodity = goodsDao.findByBatchCode(product.getBatchCode());
 			if (commodity != null) {
 				RecommendProductsUtils.fillCommodityInfo(product, commodity);
 			}
 		}
-		return recommendProducts;
+		return productList;
 	}
 
 

+ 15 - 0
src/main/java/com/uas/platform/b2c/prod/commodity/model/ReleaseProductByBatch.java

@@ -548,6 +548,12 @@ public class ReleaseProductByBatch implements Serializable {
 	@Column(name = "rel_attach")
 	private String attach;
 
+	/***
+	 * 在售的数量
+	 */
+	@Column(name = "rel_goods_count")
+	private Integer goodsCount = 0;
+
 //	private Short repeat;
 
 	@Override
@@ -1808,4 +1814,13 @@ public class ReleaseProductByBatch implements Serializable {
 		this.attach = attach;
 		return this;
 	}
+
+	public Integer getGoodsCount() {
+		return goodsCount;
+	}
+
+	public ReleaseProductByBatch setGoodsCount(Integer goodsCount) {
+		this.goodsCount = goodsCount;
+		return this;
+	}
 }

+ 1 - 1
src/main/resources/spring/context.xml

@@ -112,7 +112,7 @@
 
 	<bean id="entityManagerFactory"
 		  class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
-		<property name="persistenceUnitName" value="persistenceUnit" />
+		<!--<property name="persistenceUnitName" value="persistenceUnit" />-->
 		<property name="persistenceXmlLocation" value="classpath*:META-INF/persistence.xml"/>
 		<property name="packagesToScan" value="com.uas.platform" />
 		<property name="dataSource" ref="dataSource" />