Browse Source

复购价bugfix

zhijiezhao 2 years ago
parent
commit
ef9943f257

+ 4 - 2
src/main/java/com/caimei/modules/order/web/NewOrderController.java

@@ -446,7 +446,7 @@ public class NewOrderController extends BaseController {
                             o.setShouldPayTotalTax(o.getTotalAddedValueTax());
                             o.setShouldPayTotalTax(o.getTotalAddedValueTax());
                         }
                         }
                     } else {
                     } else {
-                        if(null==o.getSkuId()){
+                        if (null == o.getSkuId()) {
                             //赠品
                             //赠品
                             o.setSkuId(productDao.findSkuIdByPromotionsId(o.getPromotionsId()));
                             o.setSkuId(productDao.findSkuIdByPromotionsId(o.getPromotionsId()));
                         }
                         }
@@ -707,10 +707,11 @@ public class NewOrderController extends BaseController {
                             String flag = "0";
                             String flag = "0";
                             if (StringUtils.isNotBlank(costPrice) && buyPrice > Double.valueOf(costPrice)) {
                             if (StringUtils.isNotBlank(costPrice) && buyPrice > Double.valueOf(costPrice)) {
                                 // 查询复购价格库 比较复购价格库中的购买价格与这一次的购买价格
                                 // 查询复购价格库 比较复购价格库中的购买价格与这一次的购买价格
-                                RepeatPurchasePrice p = repeatPurchasePriceService.getLastBuyPrice(clubID, uID, product.getProductID());
+                                RepeatPurchasePrice p = repeatPurchasePriceService.getLastBuyPrice(clubID, uID, op.getSkuId());
                                 if (p == null) {
                                 if (p == null) {
                                     NewCmShop shop = newCmShopService.get(product.getShopID().toString());
                                     NewCmShop shop = newCmShopService.get(product.getShopID().toString());
                                     p = new RepeatPurchasePrice();
                                     p = new RepeatPurchasePrice();
+                                    p.setSkuId(product.getSkuId());
                                     p.setClubId(clubID);
                                     p.setClubId(clubID);
                                     p.setUserId(u.getUserID());
                                     p.setUserId(u.getUserID());
                                     p.setCurrentPrice(buyPrice.toString());
                                     p.setCurrentPrice(buyPrice.toString());
@@ -731,6 +732,7 @@ public class NewOrderController extends BaseController {
                             }
                             }
                             RepeatPurchasePriceHistory r = new RepeatPurchasePriceHistory();
                             RepeatPurchasePriceHistory r = new RepeatPurchasePriceHistory();
                             r.setClubId(clubID);
                             r.setClubId(clubID);
+                            r.setSkuId(op.getSkuId());
                             r.setUserId(u.getUserID());
                             r.setUserId(u.getUserID());
                             r.setPrice(buyPrice.toString());
                             r.setPrice(buyPrice.toString());
                             r.setOrderId(orderID);
                             r.setOrderId(orderID);

+ 1 - 1
src/main/java/com/caimei/modules/product/dao/RepeatPurchasePriceDao.java

@@ -22,5 +22,5 @@ public interface RepeatPurchasePriceDao extends CrudDao<RepeatPurchasePrice> {
 
 
     RepeatPurchasePrice getRepeatPurchasePrice(@Param("repeatPurchasePriceId") Integer repeatPurchasePriceId);
     RepeatPurchasePrice getRepeatPurchasePrice(@Param("repeatPurchasePriceId") Integer repeatPurchasePriceId);
 
 
-    RepeatPurchasePrice getLastBuyPrice(@Param("clubId") Integer clubID, @Param("userId") Integer uID, @Param("productId") Integer productID);
+    RepeatPurchasePrice getLastBuyPrice(@Param("clubId") Integer clubID, @Param("userId") Integer uID, @Param("skuId") Integer skuId);
 }
 }

+ 9 - 0
src/main/java/com/caimei/modules/product/entity/RepeatPurchasePrice.java

@@ -12,6 +12,7 @@ import com.thinkgem.jeesite.common.persistence.DataEntity;
 public class RepeatPurchasePrice extends DataEntity<RepeatPurchasePrice> {
 public class RepeatPurchasePrice extends DataEntity<RepeatPurchasePrice> {
 	
 	
 	private static final long serialVersionUID = 1L;
 	private static final long serialVersionUID = 1L;
+	private Integer skuId;
 	private Integer userId;		// 用户id
 	private Integer userId;		// 用户id
 	private Integer productId;		// 商品ID
 	private Integer productId;		// 商品ID
 	private Integer shopId;		// 供应商ID
 	private Integer shopId;		// 供应商ID
@@ -30,6 +31,14 @@ public class RepeatPurchasePrice extends DataEntity<RepeatPurchasePrice> {
 	private String delFlag;   //删除标记 0否 其余是
 	private String delFlag;   //删除标记 0否 其余是
 	private String unit;  //规格
 	private String unit;  //规格
 
 
+	public Integer getSkuId() {
+		return skuId;
+	}
+
+	public void setSkuId(Integer skuId) {
+		this.skuId = skuId;
+	}
+
 	public String getUnit() {
 	public String getUnit() {
 		return unit;
 		return unit;
 	}
 	}

+ 9 - 0
src/main/java/com/caimei/modules/product/entity/RepeatPurchasePriceHistory.java

@@ -12,6 +12,7 @@ import com.thinkgem.jeesite.common.persistence.DataEntity;
 public class RepeatPurchasePriceHistory extends DataEntity<RepeatPurchasePriceHistory> {
 public class RepeatPurchasePriceHistory extends DataEntity<RepeatPurchasePriceHistory> {
 	
 	
 	private static final long serialVersionUID = 1L;
 	private static final long serialVersionUID = 1L;
+	private Integer skuId;
 	private Integer userId;		// 用户id
 	private Integer userId;		// 用户id
 	private Integer productId;		// 商品ID
 	private Integer productId;		// 商品ID
 	private Integer clubId;		//
 	private Integer clubId;		//
@@ -23,6 +24,14 @@ public class RepeatPurchasePriceHistory extends DataEntity<RepeatPurchasePriceHi
 	private String valid;	//当前记录是否存在于价格库(是否有效)(0:无效,1:有效)
 	private String valid;	//当前记录是否存在于价格库(是否有效)(0:无效,1:有效)
 	private String delFlag; //删除标记 0否 其余是
 	private String delFlag; //删除标记 0否 其余是
 
 
+	public Integer getSkuId() {
+		return skuId;
+	}
+
+	public void setSkuId(Integer skuId) {
+		this.skuId = skuId;
+	}
+
 	public String getDelFlag() {
 	public String getDelFlag() {
 		return delFlag;
 		return delFlag;
 	}
 	}

+ 2 - 2
src/main/java/com/caimei/modules/product/service/RepeatPurchasePriceService.java

@@ -95,8 +95,8 @@ public class RepeatPurchasePriceService extends CrudService<RepeatPurchasePriceD
         return bean;
         return bean;
     }
     }
 
 
-    public RepeatPurchasePrice getLastBuyPrice(Integer clubID, Integer uID, Integer productID) {
-        return repeatPurchasePriceDao.getLastBuyPrice(clubID, uID, productID);
+    public RepeatPurchasePrice getLastBuyPrice(Integer clubID, Integer uID, Integer skuId) {
+        return repeatPurchasePriceDao.getLastBuyPrice(clubID, uID, skuId);
     }
     }
 
 
     @Transactional(readOnly = false)
     @Transactional(readOnly = false)

+ 2 - 0
src/main/resources/mappings/modules/product/RepeatPurchasePriceHistoryMapper.xml

@@ -59,6 +59,7 @@
 	
 	
 	<insert id="insert" parameterType="RepeatPurchasePriceHistory"  keyProperty="id" useGeneratedKeys="true">
 	<insert id="insert" parameterType="RepeatPurchasePriceHistory"  keyProperty="id" useGeneratedKeys="true">
 		INSERT INTO repeat_purchase_price_history(
 		INSERT INTO repeat_purchase_price_history(
+		    skuId,
 			id,
 			id,
 			userId,
 			userId,
 			productId,
 			productId,
@@ -68,6 +69,7 @@
 			orderId,
 			orderId,
 			clubId
 			clubId
 		) VALUES (
 		) VALUES (
+		    #{skuId},
 			#{id},
 			#{id},
 			#{userId},
 			#{userId},
 			#{productId},
 			#{productId},

+ 5 - 2
src/main/resources/mappings/modules/product/RepeatPurchasePriceMapper.xml

@@ -10,7 +10,8 @@
 		a.shopName AS "shopName",
 		a.shopName AS "shopName",
 		a.taxRate AS "taxRate",
 		a.taxRate AS "taxRate",
 		a.currentPrice AS "currentPrice",
 		a.currentPrice AS "currentPrice",
-		a.createTime AS "createTime"
+		a.createTime AS "createTime",
+		a.skuId as "skuId"
 	</sql>
 	</sql>
 
 
 	<sql id="repeatPurchasePriceJoins">
 	<sql id="repeatPurchasePriceJoins">
@@ -143,6 +144,7 @@
 
 
 	<insert id="insert" parameterType="RepeatPurchasePrice"  keyProperty="id" useGeneratedKeys="true">
 	<insert id="insert" parameterType="RepeatPurchasePrice"  keyProperty="id" useGeneratedKeys="true">
 		INSERT INTO repeat_purchase_price(
 		INSERT INTO repeat_purchase_price(
+			skuId,
 			id,
 			id,
 			userId,
 			userId,
 			productId,
 			productId,
@@ -154,6 +156,7 @@
 			orderId,
 			orderId,
 			clubId
 			clubId
 		) VALUES (
 		) VALUES (
+		    #{skuId},
 			#{id},
 			#{id},
 			#{userId},
 			#{userId},
 			#{productId},
 			#{productId},
@@ -196,7 +199,7 @@
 				and a.clubId = #{clubId}
 				and a.clubId = #{clubId}
 			</if>
 			</if>
 			<if test="productId != null and productId != ''">
 			<if test="productId != null and productId != ''">
-				and a.productId = #{productId}
+				and a.skuId = #{skuId}
 			</if>
 			</if>
 			AND a.delFlag = 0
 			AND a.delFlag = 0
 		</where>
 		</where>