瀏覽代碼

上朵分销系统

wangxiaoming 6 年之前
父節點
當前提交
84f01cd3ab

+ 7 - 0
tooth-common-core/src/main/java/com/iamberry/wechat/core/entity/channel/BalanceLog.java

@@ -1,5 +1,8 @@
 package com.iamberry.wechat.core.entity.channel;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+
 import  java.util.Date;
 import  java.io.Serializable;
 /**
@@ -23,8 +26,12 @@ public class BalanceLog  implements  Serializable{
     //金额
     private Integer balanceLogAmount;
     //创建时间
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern="yyyy-MM-dd",timezone = "GMT+8")
     private Date balanceLogCreateTime;
     //修改时间'
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern="yyyy-MM-dd",timezone = "GMT+8")
     private Date balanceLogUpdateTime;
 
     public Integer getBalanceLogId(){

+ 8 - 1
tooth-common-core/src/main/java/com/iamberry/wechat/core/entity/channel/ChannelPrice.java

@@ -1,4 +1,7 @@
 package com.iamberry.wechat.core.entity.channel;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+
 import  java.util.Date;
 import  java.io.Serializable;
 /**
@@ -26,8 +29,12 @@ public class ChannelPrice  implements  Serializable{
     //状态:1使用中 2:未使用
     private Integer channelPriceStatus;
     //创建时间
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern="yyyy-MM-dd",timezone = "GMT+8")
     private Date channelPriceCreateTime;
-    //修改时间'
+    //修改时间
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern="yyyy-MM-dd",timezone = "GMT+8")
     private Date channelPriceUpdateTime;
 
     public Integer getChannelPriceId(){

+ 8 - 0
tooth-common-core/src/main/java/com/iamberry/wechat/core/entity/channel/ChannelRebate.java

@@ -28,11 +28,19 @@ public class ChannelRebate  implements  Serializable{
     private Integer rebackAmount;
     //返利状态 1:待返利 2:已返利入账 3:已取消
     private Integer rebackStatus;
+
     //返利时间
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern="yyyy-MM-dd",timezone = "GMT+8")
     private Date rebackTime;
+
     //创建时间
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern="yyyy-MM-dd",timezone = "GMT+8")
     private Date rebackCreateTime;
     //修改时间'
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern="yyyy-MM-dd",timezone = "GMT+8")
     private Date rebackUpdateTime;
 
     private String salesOrderid;//订单编号/ID

+ 8 - 1
tooth-common-core/src/main/java/com/iamberry/wechat/core/entity/channel/ChildChannel.java

@@ -1,5 +1,8 @@
 package com.iamberry.wechat.core.entity.channel;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+
 import  java.util.Date;
 import  java.io.Serializable;
 /**
@@ -37,8 +40,12 @@ public class ChildChannel  implements  Serializable{
     //备注
     private String childChannelDesc;
     //创建时间
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern="yyyy-MM-dd",timezone = "GMT+8")
     private Date childChannelCreateTime;
-    //修改时间'
+    //修改时间
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern="yyyy-MM-dd",timezone = "GMT+8")
     private Date childChannelUpdateTime;
 
     public Integer getChildChannelId(){

+ 8 - 1
tooth-common-core/src/main/java/com/iamberry/wechat/core/entity/channel/MainChannel.java

@@ -1,5 +1,8 @@
 package com.iamberry.wechat.core.entity.channel;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+
 import  java.util.Date;
 import  java.io.Serializable;
 /**
@@ -35,8 +38,12 @@ public class MainChannel  implements  Serializable{
     //备注
     private String mainChannelDesc;
     //创建时间
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern="yyyy-MM-dd",timezone = "GMT+8")
     private Date mainChannelCreateTime;
-    //修改时间'
+    //修改时间
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern="yyyy-MM-dd",timezone = "GMT+8")
     private Date mainChannelUpdateTime;
 
     public Integer getMainChannelId(){

+ 7 - 0
tooth-wechat-interface/src/main/java/com/iamberry/wechat/face/channel/ChannelPriceService.java

@@ -16,6 +16,13 @@ public interface ChannelPriceService {
      * @return List
      */
     List<ChannelPrice> getChannelPriceList(ChannelPrice  channelPrice);
+
+    /**
+     * 获取集合
+     * @return List
+     */
+   ChannelPrice getChannelPriceByChannel(Integer channelId,Integer channelType,Integer colorId);
+
     /**
      * 查询单条数据
      * @param  id

+ 16 - 0
tooth-wechat-service/src/main/java/com/iamberry/wechat/service/channel/ChannelPriceServiceImpl.java

@@ -26,6 +26,22 @@ public class ChannelPriceServiceImpl  implements ChannelPriceService {
     public List<ChannelPrice> getChannelPriceList(ChannelPrice  channelPrice){
         return  channelPriceMapper.getChannelPriceList(channelPrice);
     }
+
+    @Override
+    public ChannelPrice getChannelPriceByChannel(Integer channelId, Integer channelType, Integer colorId) {
+        if(channelId>0 &&  channelType>0 && colorId > 0){
+            ChannelPrice channelPrice = new ChannelPrice();
+            channelPrice.setChannelId(channelId);
+            channelPrice.setChannelType(channelType);
+            channelPrice.setColorId(colorId);
+            List<ChannelPrice> channelPriceList = channelPriceMapper.getChannelPriceList(channelPrice);
+            if(channelPriceList.size() > 0){
+                return channelPriceList.get(0);
+            }
+        }
+        return null;
+    }
+
     /**
      * 查询单条数据
      * @param  id

+ 18 - 15
tooth-wechat-web/src/main/java/com/iamberry/wechat/handles/cart/CartHandlers.java

@@ -10,10 +10,12 @@ import java.util.Map;
 
 import javax.servlet.http.HttpServletRequest;
 
+import com.iamberry.wechat.core.entity.channel.ChannelPrice;
 import com.iamberry.wechat.core.entity.product.Product;
 import com.iamberry.wechat.core.entity.product.ProductColor;
 import com.iamberry.wechat.core.entity.product.QrcodeGift;
 import com.iamberry.wechat.face.apparatus.ApparatusService;
+import com.iamberry.wechat.face.channel.ChannelPriceService;
 import com.iamberry.wechat.face.order.CodeService;
 import com.iamberry.wechat.service.ImberryConfig;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -60,33 +62,26 @@ public class CartHandlers {
 
 	@Autowired
 	private CartService cartService;
-
 	@Autowired
 	private SystemService systemService;
-
 	@Autowired
 	private AdminOrderService adminOrderService;
-
 	@Autowired
 	private PayService payService;
-
 	@Autowired
 	private MQServiceProxy mQservice;
-
 	@Autowired
 	private MemberService memberService;
-
 	@Autowired
 	private CouponItemService couponItemService;
-
 	@Autowired
 	private ProductInfoService productInfoService;
-
 	@Autowired
 	private CodeService codeService;
-
 	@Autowired
 	private ApparatusService apparatusService;
+	@Autowired
+	private ChannelPriceService channelPriceService;
 
 	/**
 	 * 进入购物车页面
@@ -96,16 +91,28 @@ public class CartHandlers {
 	 */
 	@ResponseBody
 	@RequestMapping(value = "/selectCartByOpenId",method = RequestMethod.POST)
-	public ResultMsg selectCartByOpenId(HttpServletRequest request) throws Exception {
+	public ResultMsg selectCartByOpenId(HttpServletRequest request,
+										@RequestParam(value = "channelType",defaultValue = "0") Integer channelType,
+										@RequestParam(value = "channelId",defaultValue = "0") Integer channelId
+	) throws Exception {
+
 		ResultMsg remsg = new ResultMsg();
 		Member member =  WechatUtils.getUserBySession(request);
-
 		List<CartDto> cartList = cartService.selectCartByOpenId(member.getUserOpenid());
 
 		/*金额统计*/
 		Integer total = 0;
 		if (null != cartList && cartList.size() > 0) {
 			for (CartDto cartDto : cartList) {
+
+				if(channelType > 0 && channelId > 0){
+					ChannelPrice channelPrice = channelPriceService.getChannelPriceByChannel(channelId,channelType,cartDto.getCartColorId());
+					if(channelPrice != null){
+						cartDto.setProductPrice(channelPrice.getChannelOriginalPrice());
+						cartDto.setProductDiscount(channelPrice.getChannelPriceOffer());
+					}
+				}
+
 				if (cartDto.getProductStatus() != null && cartDto.getProductStatus() == 1  && (cartDto.getColorAllNum()>cartDto.getColorSoldNum())) { 	// 产品状态:在售
 					total += cartDto.getCartNum() * cartDto.getProductDiscount();
 				}
@@ -116,10 +123,6 @@ public class CartHandlers {
 		map.put("cartList", cartList);
 		map.put("total", total);
 
-//		map.put("isShow", ResultInfo.ISSHOW);
-//		map.put("cartDesc", ResultInfo.CARTDESC);
-//		map.put("cart_url", ResultInfo.CART_URL);
-
 		remsg.setMessage(NameUtils.getConfig("SUCCESSINFO"));
 		remsg.setResultCode(ResultInfo.SUCCESSCODE);
 		remsg.setStatus(true);

+ 11 - 111
tooth-wechat-web/src/main/java/com/iamberry/wechat/handles/cart/ProductInfoHandler.java

@@ -24,6 +24,7 @@ import com.iamberry.wechat.tools.NameUtils;
 import com.iamberry.wechat.tools.QrCodeUtil;
 import com.iamberry.wechat.tools.ResultInfo;
 import com.iamberry.wechat.tools.StaticInfo;
+import com.iamberry.wechat.utils.Result;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
@@ -68,10 +69,6 @@ public class ProductInfoHandler {
 	@Autowired
 	private AccessFlowService accessFlowService;
 	@Autowired
-	private MainChannelService mainChannelService;
-	@Autowired
-	private ChildChannelService childChannelService;
-	@Autowired
 	private ChannelPriceService channelPriceService;
 
 
@@ -203,14 +200,6 @@ public class ProductInfoHandler {
 										   @RequestParam(value = "channelId",defaultValue = "0") Integer channelId,
 										   @RequestParam("colorId") Integer colorId
 	) throws Exception {
-		if(channelType > 0 && channelId > 0){
-			ChannelPrice channelPrice = new ChannelPrice();
-			channelPrice.setChannelId(channelId);
-			channelPrice.setChannelType(channelType);
-			channelPrice.setColorId(colorId);
-			List<ChannelPrice> channelPriceList = channelPriceService.getChannelPriceList(channelPrice);
-		}
-
 		ResultMsg remsg = new ResultMsg();
 		Member member =  WechatUtils.getUserBySession(request);
 		Map<String, Object> map=null;
@@ -250,90 +239,24 @@ public class ProductInfoHandler {
 			}
 
 			//如果用户是扫描二维码进入,则显示优惠价
-			String userQrcodeType = request.getParameter("userQrcodeType");
-			if (userQrcodeType != null && !"".equals(userQrcodeType) && !"null".equals(userQrcodeType)) {
-				QrcodeGift gift = new QrcodeGift();
-				gift.setQrcodeStatus(1);
-				List<QrcodeGift> giftList = productInfoService.listQrcodeGift(gift);
-				if (giftList != null && giftList.size() > 0 && product != null) {
-					for (QrcodeGift qrcodeGift : giftList) {
-						if (product.getColorId().intValue() == qrcodeGift.getQrcodeColorId()) {
-							switch (userQrcodeType) {
-								case "1":
-									if (qrcodeGift.getQrcodePreDiscount() != null && qrcodeGift.getQrcodePreDiscount() > 0) {
-										product.setProductDiscount(qrcodeGift.getQrcodePreDiscount());
-									}
-									break;
-								case "2":
-									if (qrcodeGift.getQrcodeSalesDiscount() != null && qrcodeGift.getQrcodeSalesDiscount() > 0) {
-										product.setProductDiscount(qrcodeGift.getQrcodeSalesDiscount());
-									}
-									break;
-							}
-
-						}
+			if(channelType > 0 && channelId > 0){
+				for (ProductColor productColor:colorList) {
+					ChannelPrice channelPrice = channelPriceService.getChannelPriceByChannel(channelId,channelType,productColor.getColorId());
+					if(channelPrice != null){
+						productColor.setColorPrice(channelPrice.getChannelOriginalPrice());
+						productColor.setColorDiscount(channelPrice.getChannelPriceOffer());
 					}
 				}
 			}
 
-			//判断是否为金牌会员下线,如果是,则以优惠价显示,如果不是则按原价显示
-			//查询金牌会员模板id
-			int templateId = systemService.selectOneShopRuleById(114).getRuleNum().intValue();
-			//查询用户信息
-			Member user= memberService.getMemberByUserOpenId(member.getUserOpenid());
-			if (user == null) {
-				remsg.setMessage(ResultInfo.loginOutError);
-				remsg.setStatus(false);
-				remsg.setMessage(ResultInfo.loginOutError);
-				return remsg;
-			}
-			//如果模板id等于金牌会模板id,则该用户为金牌会员下线
-			if (user.getUserDealers() != null && user.getTemplateId() != null
-					&& templateId == user.getTemplateId().intValue() && user.getUserResType().intValue() == 3) {
-				//若果是金牌会员下线,产品的价格就以优惠价显示
-				UserGiftDto userGiftDto = new UserGiftDto();
-				userGiftDto.setUserLevel(2);
-				userGiftDto.setUserProductId(product.getProductId());
-				userGiftDto.setUserColorId(product.getColorId());
-				//根据商品id和会员等级查询礼品信息
-				userGiftDto = productInfoService.selectUserGift(userGiftDto);
-				if (userGiftDto != null) {
-					product.setProductDiscount(userGiftDto.getUserDiscount());
-				}
-
-			}
-
-			//根据openid查询该用户是否购买过订单
-			ShopSalesOrderDto shopSalesOrderDto = new ShopSalesOrderDto();
-			shopSalesOrderDto.setSalesOpenid(member.getUserOpenid());
-			shopSalesOrderDto.setSalesStatus("2");
-			//如果购买过订单,则滤芯的价格可按折扣价购买
-			if (product != null) {
-				if (product.getProductType().getTypeId().intValue() == 2) {
-					//若果是金牌会员下线,产品的价格就以优惠价显示
-					UserGiftDto userGiftDto = new UserGiftDto();
-					userGiftDto.setUserLevel(3);
-					userGiftDto.setUserProductId(product.getProductId());
-					userGiftDto.setUserColorId(product.getColorId());
-					//根据商品id和会员等级查询礼品信息
-					userGiftDto = productInfoService.selectUserGift(userGiftDto);
-					if (userGiftDto != null) {
-						product.setProductDiscount(userGiftDto.getUserDiscount());
-					}
-				}
-			}
+			/*banner图*/
 			List<ProductPicture> pictureList = productPictureService.getProductPictureByproductId(Integer.parseInt(productId));
 			product.setPictureList(pictureList);
+			/*查询详情*/
 			ProductImageText productImageText=productInfoService.selectProductImagetext(Integer.parseInt(productId));
 			product.setProductImageText(productImageText);
-			/*
-			 * 组装数据
-			 */
 
-			/*if ((boolean)qrCodeMap.get("flag")) {
-				map.put("qrCode", qrCodeMap.get("qrCode"));
-				map.put("shopQrCode", qrCodeMap.get("shopQrCode"));
-			}*/map = new HashMap<String, Object>();
+			map = new HashMap<String, Object>();
 
 			map.put("flag", false);	//判断是否有商户个人二维码
 			map.put("isShow", ResultInfo.ISSHOW);
@@ -348,30 +271,7 @@ public class ProductInfoHandler {
 			remsg.setStatus(true);
 			return remsg;
 		}
-
-		try {
-			String productIdString = StaticInfo.md5.decrypt(productId);
-			Product product = this.productInfoService.getProductByProductId(Integer.parseInt(productIdString),colorId);
-			List<ProductPicture> pictureList = productPictureService.getProductPictureByproductId(Integer.parseInt(productIdString));
-			product.setPictureList(pictureList);
-			/*
-			 * 组装数据
-			 */
-			map = new HashMap<String, Object>();
-			map.put("isShow", ResultInfo.ISSHOW);
-			map.put("cartDesc", ResultInfo.CARTDESC);
-			map.put("cart_url", ResultInfo.CART_URL);
-			map.put("product", product);
-			map.put("shareOpenid", member.getUserOpenid());
-			remsg.setData(map);
-			remsg.setMessage(NameUtils.getConfig("SUCCESSINFO"));
-			remsg.setResultCode(ResultInfo.SUCCESSCODE);
-		} catch (Exception e) {
-			remsg.setMessage(NameUtils.getConfig("ERRORINFO"));
-			remsg.setResultCode(ResultInfo.ERRORCODE);
-			remsg.setStatus(false);
-		}
-		return remsg;
+		return ResultMsg.getError();
 	}
 
 	/**

+ 56 - 4
tooth-wechat-web/src/main/java/com/iamberry/wechat/handles/order/OrderHandler.java

@@ -7,6 +7,8 @@ import com.iamberry.wechat.core.entity.cart.CartDto;
 import com.iamberry.wechat.core.entity.cart.OrderPayDto;
 import com.iamberry.wechat.core.entity.cart.SendPayDto;
 import com.iamberry.wechat.core.entity.cart.TempOrderDto;
+import com.iamberry.wechat.core.entity.channel.ChannelPrice;
+import com.iamberry.wechat.core.entity.channel.ChannelRebate;
 import com.iamberry.wechat.core.entity.coupon.CouponItem;
 import com.iamberry.wechat.core.entity.coupon.CouponItemDto;
 import com.iamberry.wechat.core.entity.coupon.CouponType;
@@ -20,6 +22,7 @@ import com.iamberry.wechat.core.entity.product.ProductColor;
 import com.iamberry.wechat.face.admin.SystemService;
 import com.iamberry.wechat.face.cart.CartService;
 import com.iamberry.wechat.face.cart.ProductInfoService;
+import com.iamberry.wechat.face.channel.ChannelPriceService;
 import com.iamberry.wechat.face.coupon.CouponItemService;
 import com.iamberry.wechat.face.coupon.CouponTypeService;
 import com.iamberry.wechat.face.customized.CustomizedToothService;
@@ -97,17 +100,16 @@ public class OrderHandler {
 	private TemporaryQrcodeService temporaryQrcodeService;
 	@Autowired
 	private ProductColorService productColorService;
-
 	@Autowired
 	private UseIntegralService useIntegralService;
-
 	@Autowired
 	private EfastOrderService efastOrderService;
-
 	@Autowired
 	private CustomizedToothService customizedToothService;
 	@Autowired
 	private AdminOrderService adminOrderService;
+	@Autowired
+	private ChannelPriceService channelPriceService;
 
 	/**
 	 * 支付前,调用方法
@@ -117,7 +119,10 @@ public class OrderHandler {
 	 */
 	@ResponseBody
 	@RequestMapping(value = "/payBefore")
-	public ResultMsg payBefore(HttpServletRequest request) throws Exception {
+	public ResultMsg payBefore(HttpServletRequest request,
+							   @RequestParam(value = "channelType",defaultValue = "0") Integer channelType,
+							   @RequestParam(value = "channelId",defaultValue = "0") Integer channelId
+	) throws Exception {
 
 		ResultMsg msg = new ResultMsg();
 		msg.setResultCode(ResultInfo.ERRORCODE);
@@ -167,6 +172,20 @@ public class OrderHandler {
 				msg.setMessage(ResultInfo.cartEmptyError);
 				return msg;
 			}
+
+			/*上朵分销,查看是否为分销*/
+			for (CartDto cd : cartDtos) {
+				Integer price = 0,discount=0;
+				if(channelType > 0 && channelId > 0){
+					ChannelPrice channelPrice = channelPriceService.getChannelPriceByChannel(channelId,channelType,cd.getCartColorId());
+					if(channelPrice != null){
+						cd.setProductPrice( channelPrice.getChannelPriceOffer());	//因结算页面都是去price,所以都赋值优惠价
+						cd.setProductDiscount( channelPrice.getChannelPriceOffer());
+					}
+
+				}
+			}
+
 		}else if("2".equals(isCustomize)){
 			Integer id = Integer.valueOf(cartIds);
 			CustomizedTooth customizedTooth = customizedToothService.getCustomizedToothById(id);
@@ -329,6 +348,8 @@ public class OrderHandler {
 	@RequestMapping(value = "/pay", method = RequestMethod.POST)
 	public ResultMsg requestPay(
 			TempOrderDto temp,
+			@RequestParam(value = "channelType",defaultValue = "0") Integer channelType,
+			@RequestParam(value = "channelId",defaultValue = "0") Integer channelId,
 			HttpServletRequest request
 	) throws Exception {
 
@@ -404,6 +425,18 @@ public class OrderHandler {
 				return msg;
 			}
 			cartDtos = cartService.selectCartItemByListId(cartId);
+
+			/*上朵分销,查看是否为分销*/
+			for (CartDto cd : cartDtos) {
+				Integer price = 0,discount=0;
+				if(channelType > 0 && channelId > 0){
+					ChannelPrice channelPrice = channelPriceService.getChannelPriceByChannel(channelId,channelType,cd.getCartColorId());
+					if(channelPrice != null){
+						cd.setProductPrice(channelPrice.getChannelPriceOffer());	//因结算页面都是去price,所以都赋值优惠价
+						cd.setProductDiscount(channelPrice.getChannelPriceOffer());
+					}
+				}
+			}
 		}else if("2".equals(temp.getIsCustomize())){
 			Integer id = Integer.valueOf(temp.getCartIdStr());
 			CustomizedTooth customizedTooth = customizedToothService.getCustomizedToothById(id);
@@ -610,6 +643,25 @@ public class OrderHandler {
 				couponItem.setCouponUseStatus(7);
 				couponItemService.updateCouponItemById(couponItem);
 			}
+
+			/*分销添加返利 -- start */
+			List<OrderItem> orderItemList = adminOrderService.getShopOrderItemByOrderId(order.getSalesOrderid());
+			for (OrderItem oi:orderItemList) {
+				Integer price = 0,discount=0;
+				if(channelType > 0 && channelId > 0){
+					ChannelPrice channelPrice = channelPriceService.getChannelPriceByChannel(channelId,channelType,oi.getItemColorId());
+					if(channelPrice != null){
+						price = channelPrice.getChannelOriginalPrice();
+						discount = channelPrice.getChannelPriceOffer();
+
+						ChannelRebate channelRebate = new ChannelRebate();
+						
+
+					}
+				}
+			}
+			/*分销添加返利 -- end */
+
 		} catch (Exception e) {
 			flag = false;
 			System.out.println("====插入订单列表信息失败====");