Przeglądaj źródła

优惠券修改

wangxiaoming 6 lat temu
rodzic
commit
0df955d7df

+ 1 - 1
watero-common-core/src/main/java/com/iamberry/wechat/core/entity/WechatUtils.java

@@ -70,7 +70,7 @@ public class WechatUtils {
 	 * @Time   2016年11月24日
 	 */
 	public static Member getUserBySession(HttpServletRequest request) {
-
+//
 //		Member m = new Member();
 //		m.setUserId(1);
 //		m.setUserOpenid("o3G6nww8FoM08HSbwpJqrhGu8V6Q");

+ 10 - 0
watero-common-core/src/main/java/com/iamberry/wechat/core/entity/cart/TempOrderDto.java

@@ -38,6 +38,8 @@ public class TempOrderDto implements java.io.Serializable{
 	
 	private int balancePayAmount ; //账户余额支付额度
 
+	private int exchangeColorId ; //需要兑换的颜色id
+
 	public String getOrderAddressInfo() {
 		return orderAddressInfo;
 	}
@@ -110,6 +112,14 @@ public class TempOrderDto implements java.io.Serializable{
 		this.balancePayAmount = balancePayAmount;
 	}
 
+	public int getExchangeColorId() {
+		return exchangeColorId;
+	}
+
+	public void setExchangeColorId(int exchangeColorId) {
+		this.exchangeColorId = exchangeColorId;
+	}
+
 	@Override
 	public String toString() {
 		return "TempOrderDto [orderAddressInfo=" + orderAddressInfo

+ 42 - 0
watero-wechat-web/src/main/java/com/iamberry/wechat/handles/cart/CartHandlers.java

@@ -9,6 +9,11 @@ import java.util.Map;
 
 import javax.servlet.http.HttpServletRequest;
 
+import com.iamberry.wechat.core.entity.coupon.Exchange;
+import com.iamberry.wechat.core.entity.coupon.ExchangeItem;
+import com.iamberry.wechat.core.entity.product.ProductColor;
+import com.iamberry.wechat.face.coupon.ExchangeService;
+import com.iamberry.wechat.face.porduct.ProductColorService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -72,6 +77,11 @@ public class CartHandlers {
 	
 	@Autowired
 	private ProductInfoService productInfoService;
+	@Autowired
+	private ProductColorService productColorService;
+
+	@Autowired
+	ExchangeService exchangeService;
 	
 	/**
 	 * 进入购物车页面
@@ -813,4 +823,36 @@ public class CartHandlers {
 		}
 		return remsg;
 	}
+
+
+
+	/**
+	 * 获取T1/T2滤芯
+	 * @param request
+	 * @return
+	 */
+	@ResponseBody
+	@RequestMapping("/get_exchange")
+	public ResultMsg getExchange(HttpServletRequest request,Integer couponId) throws Exception{
+		ResultMsg remsg=new ResultMsg();
+
+		if(couponId == null){
+			return remsg;
+		}
+
+		List<ProductColor> productColorList = new ArrayList<>();
+		
+		Exchange exchange = new Exchange();
+		exchange.setCouponId(couponId);
+		List<Exchange>  exchangeList = exchangeService.getExchangeList(exchange);
+		for (Exchange ex : exchangeList) {
+			List<ExchangeItem> exchangeItemList = ex.getExchangeItemList();
+			for (ExchangeItem exchangeItem:exchangeItemList) {
+				ProductColor productColor = productColorService.selectProductColorById(exchangeItem.getColorId());
+				productColorList.add(productColor);
+			}
+		}
+		remsg.setData(productColorList);
+		return remsg;
+	}
 }

+ 22 - 1
watero-wechat-web/src/main/java/com/iamberry/wechat/handles/order/OrderHandler.java

@@ -11,7 +11,9 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import com.iamberry.wechat.core.entity.coupon.*;
+import com.iamberry.wechat.core.entity.product.ProductColor;
 import com.iamberry.wechat.face.coupon.ExchangeService;
+import com.iamberry.wechat.face.porduct.ProductColorService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -95,6 +97,8 @@ public class OrderHandler {
 	private ProductInfoService productInfoService;
 	@Autowired
 	private TemporaryQrcodeService temporaryQrcodeService;
+	@Autowired
+	private ProductColorService productColorService;
 	/**
 	 * 支付前,调用方法
 	 * @param request
@@ -337,7 +341,24 @@ public class OrderHandler {
 			msg.setMessage(ResultInfo.cartEmptyError);
 			return msg;
 		}
-		
+
+		if(Integer.valueOf(temp.getExchangeColorId()) != null && Integer.valueOf(temp.getExchangeColorId())!=0){
+			ProductColor productColor = productColorService.selectProductColorById(temp.getExchangeColorId());
+			CartDto cartDto = new CartDto();
+			cartDto.setCartProductId(productColor.getColorProductId());
+			cartDto.setCartColorId(productColor.getColorId());
+			cartDto.setCartNum(1);
+			cartDto.setProductName(productColor.getColorProductName());
+			cartDto.setProductType(productColor.getColorProductType());	//colorProductType
+			cartDto.setProductPrice(productColor.getColorDiscount());
+			cartDto.setProductDiscount(productColor.getColorPrice());
+			cartDto.setProductStatus(1);
+			cartDto.setTotal(productColor.getColorDiscount());
+			cartDto.setProductColor(productColor.getColorName());
+			cartDto.setColorImg(productColor.getColorProductPic());
+			cartDtos.add(cartDto);
+		}
+
 		//根据openid查询该用户是否购买过订单
 		ShopSalesOrderDto shopSalesOrderDto = new ShopSalesOrderDto();
 		shopSalesOrderDto.setSalesOpenid(member.getUserOpenid());