解决未到生效时间优惠券显示的问题

This commit is contained in:
602090531@qq.com 2022-03-17 15:26:05 +08:00
parent b9361b8eea
commit 57f05da254
2 changed files with 31 additions and 2 deletions

View File

@ -56,13 +56,19 @@ public class CouponService {
JSONObject jsonObjectResult = JSONObject.parseObject(result); JSONObject jsonObjectResult = JSONObject.parseObject(result);
com.alibaba.fastjson.JSONArray jsonArray = JSONObject.parseArray(jsonObjectResult.getString("data")); com.alibaba.fastjson.JSONArray jsonArray = JSONObject.parseArray(jsonObjectResult.getString("data"));
com.alibaba.fastjson.JSONArray afterFilterArrary = new JSONArray(); com.alibaba.fastjson.JSONArray afterFilterArrary = new JSONArray();
Date nowDate =SmartDateUtil.parseYMD(SmartDateUtil.formatYMD(new Date()));
for(int i = 0;i < jsonArray.size();i ++){ for(int i = 0;i < jsonArray.size();i ++){
JSONObject jsonResult = (JSONObject)jsonArray.get(i); JSONObject jsonResult = (JSONObject)jsonArray.get(i);
if(jsonResult.getString("udf2") != null) { if(jsonResult.getString("udf2") != null) {
//优惠券有效过期时间
Date compareDate = SmartDateUtil.parseYMD(jsonResult.get("fValidTo").toString()); Date compareDate = SmartDateUtil.parseYMD(jsonResult.get("fValidTo").toString());
if ("H5".equals(jsonResult.getString("udf2"))&&"".equals(productCode)&&compareDate.compareTo(currentDate)!=-1) { //优惠券有效开始时间
Date startDate = SmartDateUtil.parseYMD(jsonResult.get("fValidFrom").toString());
if ("H5".equals(jsonResult.getString("udf2"))&&"".equals(productCode)&&compareDate.compareTo(currentDate)!=-1
&& startDate.compareTo(nowDate) != 1) {
afterFilterArrary.add(jsonResult); afterFilterArrary.add(jsonResult);
}else if ("H5".equals(jsonResult.getString("udf2"))&&!"".equals(productCode)&&compareDate.compareTo(currentDate)!=-1){ }else if ("H5".equals(jsonResult.getString("udf2"))&&!"".equals(productCode)&&compareDate.compareTo(currentDate)!=-1
&& startDate.compareTo(nowDate) != 1){
for(int g = 0 ;g<productCode.length;g++) { for(int g = 0 ;g<productCode.length;g++) {
if ((jsonResult.get("productCodes") != null ? jsonResult.get("productCodes").toString().indexOf(productCode[g]) : "".indexOf(productCode[g])) != -1 || jsonResult.get("productCodes") == null) { if ((jsonResult.get("productCodes") != null ? jsonResult.get("productCodes").toString().indexOf(productCode[g]) : "".indexOf(productCode[g])) != -1 || jsonResult.get("productCodes") == null) {
afterFilterArrary.add(jsonResult); afterFilterArrary.add(jsonResult);

View File

@ -13,6 +13,7 @@ import net.lab1024.smartadmin.module.system.alipay.AliPayService;
import net.lab1024.smartadmin.module.system.alipay.alipayModel.AliPayEntity; import net.lab1024.smartadmin.module.system.alipay.alipayModel.AliPayEntity;
import net.lab1024.smartadmin.module.system.alipay.conf.AlipayConfig; import net.lab1024.smartadmin.module.system.alipay.conf.AlipayConfig;
import net.lab1024.smartadmin.module.system.royalcanin.CouponService; import net.lab1024.smartadmin.module.system.royalcanin.CouponService;
import net.lab1024.smartadmin.module.system.royalcanin.coupon.CouponCosumeEntity;
import net.lab1024.smartadmin.module.system.royalcanin.coupon.CouponGetAllEntity; import net.lab1024.smartadmin.module.system.royalcanin.coupon.CouponGetAllEntity;
import net.lab1024.smartadmin.module.system.royalcanin.good.constant.OrderResponseCodeConst; import net.lab1024.smartadmin.module.system.royalcanin.good.constant.OrderResponseCodeConst;
import net.lab1024.smartadmin.module.system.royalcanin.good.model.OrderAddress; import net.lab1024.smartadmin.module.system.royalcanin.good.model.OrderAddress;
@ -115,6 +116,13 @@ public class OrderController {
ordersEntity.setCouponName(jsonObjectData.getString("couponName")); ordersEntity.setCouponName(jsonObjectData.getString("couponName"));
ordersEntity.setCouponId(jsonObjectData.getString("couponId")); ordersEntity.setCouponId(jsonObjectData.getString("couponId"));
ordersEntity.setCouponTypeId(jsonObjectData.getString("couponTypeId")); ordersEntity.setCouponTypeId(jsonObjectData.getString("couponTypeId"));
CouponCosumeEntity couponCosumeEntity = new CouponCosumeEntity();
couponCosumeEntity.setCouponCode(jsonObjectData.getString("couponCode"));
String result = couponService.couponCosume(couponCosumeEntity);
JSONObject couponJsonResult = JSONObject.parseObject(result);
if(!"0".equals(couponJsonResult.getString("code"))){
return ResponseDTO.wrap(OrderResponseCodeConst.COUPON_USE_FAIL);
}
total_fee = total_fee + orderService.couponTotal(ordersEntity.getCouponTypeId(), Double.parseDouble(ordersEntity.getCouponAmount()), Double.parseDouble(goodsObject.getString("ecPrice")), ordersEntitys.getBuyCount()); total_fee = total_fee + orderService.couponTotal(ordersEntity.getCouponTypeId(), Double.parseDouble(ordersEntity.getCouponAmount()), Double.parseDouble(goodsObject.getString("ecPrice")), ordersEntitys.getBuyCount());
} else { } else {
total_fee = total_fee + Double.parseDouble(goodsObject.getString("ecPrice")) * ordersEntitys.getBuyCount(); total_fee = total_fee + Double.parseDouble(goodsObject.getString("ecPrice")) * ordersEntitys.getBuyCount();
@ -220,6 +228,14 @@ public class OrderController {
ordersEntity.setCouponName(jsonObjectData.getString("couponName")); ordersEntity.setCouponName(jsonObjectData.getString("couponName"));
ordersEntity.setCouponId(jsonObjectData.getString("couponId")); ordersEntity.setCouponId(jsonObjectData.getString("couponId"));
ordersEntity.setCouponTypeId(jsonObjectData.getString("couponTypeId")); ordersEntity.setCouponTypeId(jsonObjectData.getString("couponTypeId"));
CouponCosumeEntity couponCosumeEntity = new CouponCosumeEntity();
//通过传优惠券码锁定优惠券
couponCosumeEntity.setCouponCode(jsonObjectData.getString("couponCode"));
String result = couponService.couponCosume(couponCosumeEntity);
JSONObject couponJsonResult = JSONObject.parseObject(result);
if(!"0".equals(couponJsonResult.getString("code"))){
return ResponseDTO.wrap(OrderResponseCodeConst.COUPON_USE_FAIL);
}
total_fee = total_fee + orderService.couponTotal(ordersEntity.getCouponTypeId(), Double.parseDouble(ordersEntity.getCouponAmount()), Double.parseDouble(goodsObject.getString("ecPrice")), ordersEntitys.getBuyCount()); total_fee = total_fee + orderService.couponTotal(ordersEntity.getCouponTypeId(), Double.parseDouble(ordersEntity.getCouponAmount()), Double.parseDouble(goodsObject.getString("ecPrice")), ordersEntitys.getBuyCount());
} else { } else {
total_fee = total_fee + Double.parseDouble(goodsObject.getString("ecPrice")) * ordersEntitys.getBuyCount(); total_fee = total_fee + Double.parseDouble(goodsObject.getString("ecPrice")) * ordersEntitys.getBuyCount();
@ -323,6 +339,13 @@ public class OrderController {
ordersEntity.setCouponName(jsonObjectData.getString("couponName")); ordersEntity.setCouponName(jsonObjectData.getString("couponName"));
ordersEntity.setCouponId(jsonObjectData.getString("couponId")); ordersEntity.setCouponId(jsonObjectData.getString("couponId"));
ordersEntity.setCouponTypeId(jsonObjectData.getString("couponTypeId")); ordersEntity.setCouponTypeId(jsonObjectData.getString("couponTypeId"));
CouponCosumeEntity couponCosumeEntity = new CouponCosumeEntity();
couponCosumeEntity.setCouponCode(jsonObjectData.getString("couponCode"));
String result = couponService.couponCosume(couponCosumeEntity);
JSONObject couponJsonResult = JSONObject.parseObject(result);
if(!"0".equals(couponJsonResult.getString("code"))){
return ResponseDTO.wrap(OrderResponseCodeConst.COUPON_USE_FAIL);
}
total_fee = total_fee + orderService.couponTotal(ordersEntity.getCouponTypeId(), Double.parseDouble(ordersEntity.getCouponAmount()), Double.parseDouble(goodsObject.getString("ecPrice")), ordersEntitys.getBuyCount()); total_fee = total_fee + orderService.couponTotal(ordersEntity.getCouponTypeId(), Double.parseDouble(ordersEntity.getCouponAmount()), Double.parseDouble(goodsObject.getString("ecPrice")), ordersEntitys.getBuyCount());
} else { } else {
total_fee = total_fee + Double.parseDouble(goodsObject.getString("ecPrice")) * ordersEntitys.getBuyCount(); total_fee = total_fee + Double.parseDouble(goodsObject.getString("ecPrice")) * ordersEntitys.getBuyCount();