|
@@ -23,6 +23,7 @@ import com.iamberry.wechat.face.admin.SystemService;
|
|
import com.iamberry.wechat.face.cart.CartService;
|
|
import com.iamberry.wechat.face.cart.CartService;
|
|
import com.iamberry.wechat.face.cart.ProductInfoService;
|
|
import com.iamberry.wechat.face.cart.ProductInfoService;
|
|
import com.iamberry.wechat.face.channel.ChannelPriceService;
|
|
import com.iamberry.wechat.face.channel.ChannelPriceService;
|
|
|
|
+import com.iamberry.wechat.face.channel.ChannelRebateService;
|
|
import com.iamberry.wechat.face.coupon.CouponItemService;
|
|
import com.iamberry.wechat.face.coupon.CouponItemService;
|
|
import com.iamberry.wechat.face.coupon.CouponTypeService;
|
|
import com.iamberry.wechat.face.coupon.CouponTypeService;
|
|
import com.iamberry.wechat.face.customized.CustomizedToothService;
|
|
import com.iamberry.wechat.face.customized.CustomizedToothService;
|
|
@@ -110,6 +111,8 @@ public class OrderHandler {
|
|
private AdminOrderService adminOrderService;
|
|
private AdminOrderService adminOrderService;
|
|
@Autowired
|
|
@Autowired
|
|
private ChannelPriceService channelPriceService;
|
|
private ChannelPriceService channelPriceService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ChannelRebateService channelRebateService;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 支付前,调用方法
|
|
* 支付前,调用方法
|
|
@@ -425,18 +428,6 @@ public class OrderHandler {
|
|
return msg;
|
|
return msg;
|
|
}
|
|
}
|
|
cartDtos = cartService.selectCartItemByListId(cartId);
|
|
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())){
|
|
}else if("2".equals(temp.getIsCustomize())){
|
|
Integer id = Integer.valueOf(temp.getCartIdStr());
|
|
Integer id = Integer.valueOf(temp.getCartIdStr());
|
|
CustomizedTooth customizedTooth = customizedToothService.getCustomizedToothById(id);
|
|
CustomizedTooth customizedTooth = customizedToothService.getCustomizedToothById(id);
|
|
@@ -480,6 +471,7 @@ public class OrderHandler {
|
|
int brushelCouponTotal = 0; //优惠总价
|
|
int brushelCouponTotal = 0; //优惠总价
|
|
|
|
|
|
int total = 0; // 需要支付的总额, 单位为分
|
|
int total = 0; // 需要支付的总额, 单位为分
|
|
|
|
+ int channelTotal = 0; // 如果有分销,此值为分销总额,没有就与total值等同
|
|
/** 提前准备订单项数据 */
|
|
/** 提前准备订单项数据 */
|
|
/** 准备数据 */
|
|
/** 准备数据 */
|
|
Order order = new Order();
|
|
Order order = new Order();
|
|
@@ -491,7 +483,19 @@ public class OrderHandler {
|
|
if (cartDto.getProductStatus() != null && cartDto.getProductStatus().intValue() == 1) {
|
|
if (cartDto.getProductStatus() != null && cartDto.getProductStatus().intValue() == 1) {
|
|
cartIds.add(cartDto.getCartId());
|
|
cartIds.add(cartDto.getCartId());
|
|
Integer subTotal = cartDto.getCartNum() * cartDto.getProductPrice(); // 小计
|
|
Integer subTotal = cartDto.getCartNum() * cartDto.getProductPrice(); // 小计
|
|
- total += subTotal;
|
|
|
|
|
|
+
|
|
|
|
+ total += subTotal;
|
|
|
|
+
|
|
|
|
+ /*上朵分销,*/
|
|
|
|
+ if(channelType > 0 && channelId > 0){
|
|
|
|
+ ChannelPrice channelPrice = channelPriceService.getChannelPriceByChannel(channelId,channelType,cartDto.getCartColorId());
|
|
|
|
+ if(channelPrice != null){
|
|
|
|
+ subTotal = cartDto.getCartNum() * channelPrice.getChannelPriceOffer();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ channelTotal += subTotal;
|
|
|
|
+ /*上朵分销,*/
|
|
|
|
+
|
|
OrderItem item = new OrderItem();
|
|
OrderItem item = new OrderItem();
|
|
item.setItemNum(cartDto.getCartNum());
|
|
item.setItemNum(cartDto.getCartNum());
|
|
item.setItemProductDiscount(cartDto.getProductPrice());
|
|
item.setItemProductDiscount(cartDto.getProductPrice());
|
|
@@ -531,6 +535,10 @@ public class OrderHandler {
|
|
order.setSalesOpenid(member.getUserOpenid()); // openid
|
|
order.setSalesOpenid(member.getUserOpenid()); // openid
|
|
order.setSalesAmount(total); // 订单金额
|
|
order.setSalesAmount(total); // 订单金额
|
|
|
|
|
|
|
|
+ if(total > channelTotal && channelType > 0 && channelId > 0){ //如果有分销优惠,将直接使用分销优惠价
|
|
|
|
+ total = channelTotal;
|
|
|
|
+ }
|
|
|
|
+
|
|
int mustPay=0;
|
|
int mustPay=0;
|
|
|
|
|
|
String couponId=temp.getCouponId();
|
|
String couponId=temp.getCouponId();
|
|
@@ -646,22 +654,34 @@ public class OrderHandler {
|
|
|
|
|
|
/*分销添加返利 -- start */
|
|
/*分销添加返利 -- start */
|
|
List<OrderItem> orderItemList = adminOrderService.getShopOrderItemByOrderId(order.getSalesOrderid());
|
|
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();
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ try{
|
|
|
|
+ for (OrderItem oi:orderItemList) {
|
|
|
|
+ if(channelType > 0 && channelId > 0){
|
|
|
|
+ ChannelPrice channelPrice = channelPriceService.getChannelPriceByChannel(channelId,channelType,oi.getItemColorId());
|
|
|
|
+ if(channelPrice != null){
|
|
|
|
+ Integer rebateAmount = channelPrice.getChannelRebateAmount(); //channelRebateAmount 返利金额
|
|
|
|
+ rebateAmount = rebateAmount * oi.getItemNum();
|
|
|
|
+
|
|
|
|
+ ChannelRebate channelRebate = new ChannelRebate();
|
|
|
|
+ channelRebate.setRebateSalesOrderId(order.getSalesOrderid());
|
|
|
|
+ channelRebate.setRebackFromOpenId(member.getUserOpenid());
|
|
|
|
+ channelRebate.setRebateItemId(oi.getItemId());
|
|
|
|
+ channelRebate.setRebackChannelType(channelType);
|
|
|
|
+ channelRebate.setRebackChannelId(channelId);
|
|
|
|
+ channelRebate.setRebackAmount(rebateAmount);
|
|
|
|
+ channelRebate.setRebackStatus(1); //1:待返利
|
|
|
|
+ Integer fl = channelRebateService.save(channelRebate);
|
|
|
|
+ if(fl < 1){
|
|
|
|
+ ratFWLogger.info("返利生成失败!失败订单号:"+order.getSalesOrderid());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ ratFWLogger.info("返利生成错误!失败订单号:"+order.getSalesOrderid());
|
|
|
|
+ e.printStackTrace();
|
|
}
|
|
}
|
|
/*分销添加返利 -- end */
|
|
/*分销添加返利 -- end */
|
|
-
|
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
flag = false;
|
|
flag = false;
|
|
System.out.println("====插入订单列表信息失败====");
|
|
System.out.println("====插入订单列表信息失败====");
|
|
@@ -690,21 +710,6 @@ public class OrderHandler {
|
|
return msg;
|
|
return msg;
|
|
}
|
|
}
|
|
} else if(flag && mustPay==0){
|
|
} else if(flag && mustPay==0){
|
|
-
|
|
|
|
- // 给百胜推送信息
|
|
|
|
- /*try {
|
|
|
|
- MQMessage message = new MQMessage();
|
|
|
|
- message.setServiceToMessage(order.getSalesOrderid());
|
|
|
|
- message.setServiceOtherMessage("efast.trade.new.add");
|
|
|
|
- message.setServiceIsSend(2); // 没有推送的信息
|
|
|
|
- message.setServiceStatus(1); // 推送成功
|
|
|
|
- message.setServiceType(1); // 添加订单信息
|
|
|
|
- message.setServiceHandlerObjectName("efastOrderServiceImpl");
|
|
|
|
- message.setServiceHandlerMethodName("addOrderInfoToEfast");
|
|
|
|
- mQservice.insertMQMessage(message);
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- }*/
|
|
|
|
-
|
|
|
|
dto.setInfo("isOK");
|
|
dto.setInfo("isOK");
|
|
dto.setSuccess(true);
|
|
dto.setSuccess(true);
|
|
dto.setOrderId(order.getSalesOrderid());
|
|
dto.setOrderId(order.getSalesOrderid());
|