|
@@ -192,9 +192,9 @@ public class ResponseWechatPayHandler {
|
|
|
// 修改订单状态
|
|
|
int count = cartService.updateOrderStatus(order);
|
|
|
|
|
|
- /*计算使用优惠券优惠的金额*/
|
|
|
- Integer couponAmount = 0;
|
|
|
-
|
|
|
+ /*计算使用优惠券优惠的金额*/
|
|
|
+// Integer couponAmount = 0;
|
|
|
+ Integer couponTypeId = 0;
|
|
|
//修改优惠券状态
|
|
|
order = cartService.selectOrderInfoById(order);
|
|
|
String couponId = order.getCouponId();
|
|
@@ -206,47 +206,61 @@ public class ResponseWechatPayHandler {
|
|
|
couponItemService.updateCouponItemById(couponItem);
|
|
|
|
|
|
CouponItemDto couponItemDto = couponItemService.getCouponItemById(couponId);
|
|
|
- if (couponItemDto.getCouponType() == 1) { //按照金额
|
|
|
- couponAmount = couponItemDto.getCouponReduce() / 100;
|
|
|
- } else if (couponItemDto.getCouponType() == 2) { ////按照折扣
|
|
|
- couponAmount = or.getSalesAmount() - or.getSalesAmount() / (couponItemDto.getCouponReduce() / 100) / 100;
|
|
|
- }
|
|
|
+ couponTypeId = couponItemDto.getCouponId();
|
|
|
+// if (couponItemDto.getCouponType() == 1) { //按照金额
|
|
|
+// couponAmount = couponItemDto.getCouponReduce() / 100;
|
|
|
+// } else if (couponItemDto.getCouponType() == 2) { ////按照折扣
|
|
|
+// couponAmount = or.getSalesAmount() - or.getSalesAmount() / (couponItemDto.getCouponReduce() / 100) / 100;
|
|
|
+// }
|
|
|
}
|
|
|
|
|
|
+ //优惠金额
|
|
|
+ Integer offerAmount = (or.getSalesAmount() - or.getSalesYetAmount()) / 100;
|
|
|
+
|
|
|
/*-- 计算积分 ----*/
|
|
|
+ // 总积分 -- 牙刷总金额 -- 刷头金额 -- 组合套装优惠,返一倍积分
|
|
|
+ Integer allIntegral = 0, toothbrush = 0, brushHead = 0, combinationOffer = 0;
|
|
|
List<OrderItem> orderItemList = adminOrderService.getShopOrderItemByOrderId(orderIdMD5);
|
|
|
- Integer allIntegral = 0; //总积分
|
|
|
- Integer allBrushAmount = 0; //牙刷总金额与优惠券相减 -- 未乘以3
|
|
|
-
|
|
|
for (int i = 0; i < orderItemList.size(); i++) {
|
|
|
OrderItem orderItem = orderItemList.get(i);
|
|
|
- Integer amount = orderItem.getItemProductDiscount() / 100; //商品优惠价
|
|
|
- if (orderItem.getItemProductType() == 100) { //类型为电动牙刷
|
|
|
- Integer integral = amount * (orderItem.getItemNum() * 3 - orderItem.getItemNum()); //计算牙刷*2的金额
|
|
|
- allIntegral += integral;
|
|
|
- } else {
|
|
|
- //Integer integral = amount * (orderItem.getItemNum() * 3);
|
|
|
- allBrushAmount += amount * orderItem.getItemNum(); //加的是刷牙总金额
|
|
|
+ Integer amount = orderItem.getItemProductDiscount()*orderItem.getItemNum() / 100; //商品优惠价
|
|
|
+ if (orderItem.getItemProductType() == 100) { //类型为电动牙刷
|
|
|
+ toothbrush += amount;
|
|
|
+ }else {
|
|
|
+ if(310 == orderItem.getItemProductId()){
|
|
|
+ /*优惠套装组合*/
|
|
|
+ combinationOffer += amount;
|
|
|
+ }else{
|
|
|
+ brushHead += amount;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- if (couponAmount > 0) { //有优惠券减去优惠券的金额 -- 先用牙刷总金额减去优惠券
|
|
|
- allBrushAmount += -couponAmount;
|
|
|
+ if(20000 == couponTypeId|| 40000 == couponTypeId){
|
|
|
+ //刷头优惠券
|
|
|
+ brushHead -= offerAmount;
|
|
|
+ }else{
|
|
|
+ //牙刷优惠券
|
|
|
+ toothbrush -= offerAmount;
|
|
|
}
|
|
|
-
|
|
|
- /**
|
|
|
- * start
|
|
|
- * 两种情况:
|
|
|
- * 1) 刷头金额低于抵扣金额时:支付金额*2;
|
|
|
- * 2) 刷头金额高于等于抵扣金额时:399*2
|
|
|
- */
|
|
|
- if(allBrushAmount < 0){ //刷头金额低于抵扣金额 ==> 牙刷金额*2 + (刷头金额 - 优惠券)*2
|
|
|
- allIntegral += allBrushAmount * 2; //牙刷减去(优惠券减去刷头的金额)
|
|
|
- }else{ //刷头金额高于等于抵扣金额
|
|
|
- //allIntegral += allBrushAmount * 3; //----- 删除
|
|
|
+ if(or.getSalesPostage() > 0){
|
|
|
+ if(brushHead >= 10){
|
|
|
+ brushHead -= or.getSalesPostage()/100;
|
|
|
+ }else if(toothbrush >= 10){
|
|
|
+ toothbrush -= or.getSalesPostage()/100;
|
|
|
+ }
|
|
|
}
|
|
|
+ if(brushHead < 0){
|
|
|
+ brushHead = 0;
|
|
|
+ }
|
|
|
+ if(toothbrush < 0){
|
|
|
+ toothbrush = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ //后面的小数积分直接去掉,不需要四舍五入
|
|
|
+ allIntegral = (int)( toothbrush * 2 + brushHead * 1.5 + combinationOffer * 1);
|
|
|
/*-----end-----*/
|
|
|
|
|
|
- ratFWLogger.error(this, "订单:" + orderIdMD5 + "订单使用优惠卷金额:" + couponAmount + "所得积分为:" + allIntegral);
|
|
|
+ ratFWLogger.error(this, "订单:" + orderIdMD5 + "订单使用优惠金额:" + offerAmount + "所得积分为:" + allIntegral);
|
|
|
boolean flag = apparatusService.addStayIntegral(or.getSalesOpenid(), 3, allIntegral, or.getSalesOrderid(),null);
|
|
|
ratFWLogger.info("积分是否入账:" + flag);
|
|
|
/*----------计算积分-----------*/
|
|
@@ -385,7 +399,8 @@ public class ResponseWechatPayHandler {
|
|
|
int count = cartService.updateOrderStatus(order);
|
|
|
|
|
|
/*计算使用优惠券优惠的金额*/
|
|
|
- Integer couponAmount = 0;
|
|
|
+// Integer couponAmount = 0;
|
|
|
+ Integer couponTypeId = 0;
|
|
|
//修改优惠券状态
|
|
|
order = cartService.selectOrderInfoById(order);
|
|
|
String couponId = order.getCouponId();
|
|
@@ -397,47 +412,61 @@ public class ResponseWechatPayHandler {
|
|
|
couponItemService.updateCouponItemById(couponItem);
|
|
|
|
|
|
CouponItemDto couponItemDto = couponItemService.getCouponItemById(couponId);
|
|
|
- if (couponItemDto.getCouponType() == 1) { //按照金额
|
|
|
- couponAmount = couponItemDto.getCouponReduce() / 100;
|
|
|
- } else if (couponItemDto.getCouponType() == 2) { ////按照折扣
|
|
|
- couponAmount = or.getSalesAmount() - or.getSalesAmount() / (couponItemDto.getCouponReduce() / 100) / 100;
|
|
|
- }
|
|
|
+ couponTypeId = couponItemDto.getCouponId();
|
|
|
+// if (couponItemDto.getCouponType() == 1) { //按照金额
|
|
|
+// couponAmount = couponItemDto.getCouponReduce() / 100;
|
|
|
+// } else if (couponItemDto.getCouponType() == 2) { ////按照折扣
|
|
|
+// couponAmount = or.getSalesAmount() - or.getSalesAmount() / (couponItemDto.getCouponReduce() / 100) / 100;
|
|
|
+// }
|
|
|
}
|
|
|
|
|
|
+ //优惠金额
|
|
|
+ Integer offerAmount = (or.getSalesAmount() - or.getSalesYetAmount()) / 100;
|
|
|
+
|
|
|
/*-- 计算积分 ----*/
|
|
|
+ // 总积分 -- 牙刷总金额 -- 刷头金额 -- 组合套装优惠,返一倍积分
|
|
|
+ Integer allIntegral = 0, toothbrush = 0, brushHead = 0, combinationOffer = 0;
|
|
|
List<OrderItem> orderItemList = adminOrderService.getShopOrderItemByOrderId(orderIdMD5);
|
|
|
- Integer allIntegral = 0; //总积分
|
|
|
- Integer allBrushAmount = 0; //牙刷总金额与优惠券相减 -- 未乘以3
|
|
|
-
|
|
|
for (int i = 0; i < orderItemList.size(); i++) {
|
|
|
OrderItem orderItem = orderItemList.get(i);
|
|
|
- Integer amount = orderItem.getItemProductDiscount() / 100; //商品优惠价
|
|
|
- if (orderItem.getItemProductType() == 100) { //类型为电动牙刷
|
|
|
- Integer integral = amount * (orderItem.getItemNum() * 3 - orderItem.getItemNum()); //计算牙刷*2的金额
|
|
|
- allIntegral += integral;
|
|
|
- } else {
|
|
|
- //Integer integral = amount * (orderItem.getItemNum() * 3);
|
|
|
- allBrushAmount += amount * orderItem.getItemNum(); //加的是刷牙总金额
|
|
|
+ Integer amount = orderItem.getItemProductDiscount()*orderItem.getItemNum() / 100; //商品优惠价
|
|
|
+ if (orderItem.getItemProductType() == 100) { //类型为电动牙刷
|
|
|
+ toothbrush += amount;
|
|
|
+ }else {
|
|
|
+ if(310 == orderItem.getItemProductId()){
|
|
|
+ /*优惠套装组合*/
|
|
|
+ combinationOffer += amount;
|
|
|
+ }else{
|
|
|
+ brushHead += amount;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- if (couponAmount > 0) { //有优惠券减去优惠券的金额 -- 先用牙刷总金额减去优惠券
|
|
|
- allBrushAmount += -couponAmount;
|
|
|
+ if(20000 == couponTypeId|| 40000 == couponTypeId){
|
|
|
+ //刷头优惠券
|
|
|
+ brushHead -= offerAmount;
|
|
|
+ }else{
|
|
|
+ //牙刷优惠券
|
|
|
+ toothbrush -= offerAmount;
|
|
|
}
|
|
|
-
|
|
|
- /**
|
|
|
- * start
|
|
|
- * 两种情况:
|
|
|
- * 1) 刷头金额低于抵扣金额时:支付金额*2;
|
|
|
- * 2) 刷头金额高于等于抵扣金额时:399*2
|
|
|
- */
|
|
|
- if(allBrushAmount < 0){ //刷头金额低于抵扣金额 ==> 牙刷金额*2 + (刷头金额 - 优惠券)*2
|
|
|
- allIntegral += allBrushAmount * 2; //牙刷减去(优惠券减去刷头的金额)
|
|
|
- }else{ //刷头金额高于等于抵扣金额
|
|
|
- //allIntegral += allBrushAmount * 3; //----- 删除
|
|
|
+ if(or.getSalesPostage() > 0){
|
|
|
+ if(brushHead >= 10){
|
|
|
+ brushHead -= or.getSalesPostage()/100;
|
|
|
+ }else if(toothbrush >= 10){
|
|
|
+ toothbrush -= or.getSalesPostage()/100;
|
|
|
+ }
|
|
|
}
|
|
|
+ if(brushHead < 0){
|
|
|
+ brushHead = 0;
|
|
|
+ }
|
|
|
+ if(toothbrush < 0){
|
|
|
+ toothbrush = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ //后面的小数积分直接去掉,不需要四舍五入
|
|
|
+ allIntegral = (int)( toothbrush * 2 + brushHead * 1.5 + combinationOffer * 1);
|
|
|
/*-----end-----*/
|
|
|
|
|
|
- ratFWLogger.error(this, "订单:" + orderIdMD5 + "订单使用优惠卷金额:" + couponAmount + "所得积分为:" + allIntegral);
|
|
|
+ ratFWLogger.error(this, "订单:" + orderIdMD5 + "订单使用优惠金额:" + offerAmount + "所得积分为:" + allIntegral);
|
|
|
boolean flag = apparatusService.addStayIntegral(or.getSalesOpenid(), 3, allIntegral, or.getSalesOrderid(),null);
|
|
|
ratFWLogger.info("积分是否入账:" + flag);
|
|
|
/*----------计算积分-----------*/
|