mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2025-10-02 02:06:38 +08:00
解决未到生效时间优惠券显示的问题
This commit is contained in:
parent
b9361b8eea
commit
57f05da254
@ -56,13 +56,19 @@ public class CouponService {
|
||||
JSONObject jsonObjectResult = JSONObject.parseObject(result);
|
||||
com.alibaba.fastjson.JSONArray jsonArray = JSONObject.parseArray(jsonObjectResult.getString("data"));
|
||||
com.alibaba.fastjson.JSONArray afterFilterArrary = new JSONArray();
|
||||
Date nowDate =SmartDateUtil.parseYMD(SmartDateUtil.formatYMD(new Date()));
|
||||
for(int i = 0;i < jsonArray.size();i ++){
|
||||
JSONObject jsonResult = (JSONObject)jsonArray.get(i);
|
||||
if(jsonResult.getString("udf2") != null) {
|
||||
//优惠券有效过期时间
|
||||
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);
|
||||
}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++) {
|
||||
if ((jsonResult.get("productCodes") != null ? jsonResult.get("productCodes").toString().indexOf(productCode[g]) : "".indexOf(productCode[g])) != -1 || jsonResult.get("productCodes") == null) {
|
||||
afterFilterArrary.add(jsonResult);
|
||||
|
@ -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.conf.AlipayConfig;
|
||||
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.good.constant.OrderResponseCodeConst;
|
||||
import net.lab1024.smartadmin.module.system.royalcanin.good.model.OrderAddress;
|
||||
@ -115,6 +116,13 @@ public class OrderController {
|
||||
ordersEntity.setCouponName(jsonObjectData.getString("couponName"));
|
||||
ordersEntity.setCouponId(jsonObjectData.getString("couponId"));
|
||||
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());
|
||||
} else {
|
||||
total_fee = total_fee + Double.parseDouble(goodsObject.getString("ecPrice")) * ordersEntitys.getBuyCount();
|
||||
@ -220,6 +228,14 @@ public class OrderController {
|
||||
ordersEntity.setCouponName(jsonObjectData.getString("couponName"));
|
||||
ordersEntity.setCouponId(jsonObjectData.getString("couponId"));
|
||||
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());
|
||||
} else {
|
||||
total_fee = total_fee + Double.parseDouble(goodsObject.getString("ecPrice")) * ordersEntitys.getBuyCount();
|
||||
@ -323,6 +339,13 @@ public class OrderController {
|
||||
ordersEntity.setCouponName(jsonObjectData.getString("couponName"));
|
||||
ordersEntity.setCouponId(jsonObjectData.getString("couponId"));
|
||||
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());
|
||||
} else {
|
||||
total_fee = total_fee + Double.parseDouble(goodsObject.getString("ecPrice")) * ordersEntitys.getBuyCount();
|
||||
|
Loading…
Reference in New Issue
Block a user