|
@@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.sql.Timestamp;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
|
@Controller
|
|
@@ -236,32 +237,41 @@ public class PayOrderController {
|
|
|
params.put("cardRuleFlagGroup", payOrderRequest.getCardRuleFlagGroup());
|
|
|
params.put("cardEnabledFlagGroup", payOrderRequest.getCardEnabledFlagGroup());
|
|
|
|
|
|
- CustomerLabel customerLabel = new CustomerLabel();
|
|
|
- customerLabel.setPhone(payOrderRequest.getCustomerPhone());
|
|
|
- customerLabel.setStationId(payOrderRequest.getStationId());
|
|
|
- //获取该用户是否在标签组内
|
|
|
- CustomerLabel customerLabelInfo = labelService.getCustomerLabel(customerLabel);
|
|
|
- if(payOrderRequest.getLabelFlag() !=null && payOrderRequest.getLabelFlag().equals("1") && customerLabelInfo !=null){
|
|
|
- //表示此用户为标签用户,计算标签用户优惠
|
|
|
- params.put("labelId", customerLabelInfo.getLabelId());
|
|
|
- payOrderResultInfo = this.calculateLabelDiscount(params);
|
|
|
- }else {
|
|
|
- //不为标签用户时
|
|
|
- switch (discountSetting){
|
|
|
- case "0": //不执营销方案时 计算等级优惠
|
|
|
- payOrderResultInfo = this.calculateGradeDiscount(params);
|
|
|
- break;
|
|
|
- case "1": //满减方案
|
|
|
- payOrderResultInfo = this.calculateManJianDiscount(params);
|
|
|
- break;
|
|
|
- case "2": //立减方案
|
|
|
- payOrderResultInfo = this.calculateLiJianDiscount(params);
|
|
|
- break;
|
|
|
- case "3": //独立直降
|
|
|
- payOrderResultInfo = this.calculateZhiJiangDiscount(params);
|
|
|
- break;
|
|
|
+// if(payOrderRequest.getLabelFlag() !=null && payOrderRequest.getLabelFlag().equals("1") && payOrderRequest.getLabelId() !=null && payOrderRequest.getLabelId() !=""){
|
|
|
+// //如果前端传来labelId 表示使用一码一标签:标签支付码
|
|
|
+// params.put("labelId", payOrderRequest.getLabelId());
|
|
|
+// payOrderResultInfo = this.calculateLabelDiscount(params);
|
|
|
+// }else {
|
|
|
+ //按照正常优惠计算
|
|
|
+ CustomerLabel customerLabel = new CustomerLabel();
|
|
|
+ customerLabel.setPhone(payOrderRequest.getCustomerPhone());
|
|
|
+ customerLabel.setStationId(payOrderRequest.getStationId());
|
|
|
+ CustomerLabel customerLabelInfo = labelService.getCustomerLabel(customerLabel); //获取该用户是否在标签组内
|
|
|
+ if(payOrderRequest.getLabelFlag() !=null && payOrderRequest.getLabelFlag().equals("1") && customerLabelInfo !=null){
|
|
|
+ //表示此用户为标签用户,计算标签用户优惠
|
|
|
+ params.put("labelId", customerLabelInfo.getLabelId());
|
|
|
+ payOrderResultInfo = this.calculateLabelDiscount(params);
|
|
|
+ }else {
|
|
|
+ //不为标签用户时
|
|
|
+ switch (discountSetting){
|
|
|
+ case "0": //不执营销方案时 计算等级优惠
|
|
|
+ payOrderResultInfo = this.calculateGradeDiscount(params);
|
|
|
+ break;
|
|
|
+ case "1": //满减方案
|
|
|
+ payOrderResultInfo = this.calculateManJianDiscount(params);
|
|
|
+ break;
|
|
|
+ case "2": //立减方案
|
|
|
+ payOrderResultInfo = this.calculateLiJianDiscount(params);
|
|
|
+ break;
|
|
|
+ case "3": //独立直降
|
|
|
+ payOrderResultInfo = this.calculateZhiJiangDiscount(params);
|
|
|
+ break;
|
|
|
+ case "4": //计算阶梯直降
|
|
|
+ payOrderResultInfo = this.calculateJieTiZhiJiangDiscount(params);
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
+ //}
|
|
|
return payOrderResultInfo;
|
|
|
}
|
|
|
|
|
@@ -375,6 +385,145 @@ public class PayOrderController {
|
|
|
return payOrderResultInfo;
|
|
|
}
|
|
|
|
|
|
+ //计算阶梯直降
|
|
|
+ public PayOrderResultInfo calculateJieTiZhiJiangDiscount(Map<String ,Object> params){
|
|
|
+ PayOrderResultInfo payOrderResultInfo = new PayOrderResultInfo(); //计算结果存放值
|
|
|
+ BigDecimal oilPrice = new BigDecimal(params.get("oilPrice").toString()); //油品价格
|
|
|
+ BigDecimal receivableAmt = new BigDecimal(params.get("receivableAmt").toString()); //应收金额
|
|
|
+ BigDecimal oilLiters = new BigDecimal("0.00"); //加油升数
|
|
|
+ BigDecimal discountAmt = new BigDecimal(0); //营销方案优惠金额
|
|
|
+ BigDecimal amt = new BigDecimal(0);
|
|
|
+ BigDecimal discountPrice = oilPrice;
|
|
|
+ BigDecimal gradeDiscountAmt = new BigDecimal(0); //等级优惠金额
|
|
|
+ BigDecimal dzkGradeDiscountAmt = new BigDecimal(0); //计算电子卡金额时所需等级优惠金额值
|
|
|
+ BigDecimal dzkDiscountAmt = new BigDecimal(0); //计算电子卡金额时所需营销优惠金额值
|
|
|
+
|
|
|
+ //加油升数
|
|
|
+ oilLiters = receivableAmt.divide(oilPrice,2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ if(!oilLiters.toString().substring(oilLiters.toString().indexOf(".") + 1).equals("00")){
|
|
|
+ oilLiters = receivableAmt.divide(oilPrice,2, BigDecimal.ROUND_UP);
|
|
|
+ }
|
|
|
+ //计算等级优惠
|
|
|
+ PayOrderResultInfo payOrderResultInfoGrade = this.calculateGradeDiscount(params);
|
|
|
+ gradeDiscountAmt = new BigDecimal(payOrderResultInfoGrade.getDiscountAmt());
|
|
|
+ dzkGradeDiscountAmt = gradeDiscountAmt; //同时给电子卡赋值等级优惠金额
|
|
|
+
|
|
|
+ params.put("discountPlanType", "4");
|
|
|
+ List<Map> customerMarkertPlanList = customerGradeServices.getCustomerMarkertPlanList(params);
|
|
|
+ if(customerMarkertPlanList !=null && customerMarkertPlanList.size() >0){
|
|
|
+ for(Map m : customerMarkertPlanList){
|
|
|
+ BigDecimal discountAmt_b = new BigDecimal(m.get("discountAmt").toString()); //条件金额
|
|
|
+ BigDecimal gasoilDiscountAmt_b = new BigDecimal(m.get("gasoilDiscountAmt").toString());
|
|
|
+ String discountTerm = m.get("discountTerm").toString();
|
|
|
+ if(discountTerm.equals("1")){
|
|
|
+ if(oilLiters.compareTo(discountAmt_b) ==1 || oilLiters.compareTo(discountAmt_b) ==0){
|
|
|
+ discountAmt = oilLiters.multiply(gasoilDiscountAmt_b);
|
|
|
+ discountAmt = discountAmt.setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ dzkDiscountAmt = discountAmt; //赋值电子卡优惠金额
|
|
|
+ String vipDiscountyPlus = m.get("vipDiscountyPlus").toString();
|
|
|
+ //该营销方案是否叠加等级优惠
|
|
|
+ if(vipDiscountyPlus.equals("1")){
|
|
|
+ //如果叠加等级优惠
|
|
|
+ discountAmt = discountAmt.add(gradeDiscountAmt);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }else if(discountTerm.equals("2")){
|
|
|
+ if(receivableAmt.compareTo(discountAmt_b) ==1 || receivableAmt.compareTo(discountAmt_b) ==0){
|
|
|
+ discountAmt = oilLiters.multiply(gasoilDiscountAmt_b);
|
|
|
+ discountAmt = discountAmt.setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ dzkDiscountAmt = discountAmt; //赋值电子卡优惠金额
|
|
|
+ String vipDiscountyPlus = m.get("vipDiscountyPlus").toString();
|
|
|
+ //该营销方案是否叠加等级优惠
|
|
|
+ if(vipDiscountyPlus.equals("1")){
|
|
|
+ //如果叠加等级优惠
|
|
|
+ discountAmt = discountAmt.add(gradeDiscountAmt);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ amt = receivableAmt.subtract(discountAmt); //应收金额
|
|
|
+ amt =amt.signum() == -1 ? new BigDecimal("0.01"): amt;
|
|
|
+ discountPrice = oilLiters.equals(new BigDecimal("0.00")) ? discountPrice : amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP); //优惠价格
|
|
|
+ payOrderResultInfo.setAmt(amt.toString());
|
|
|
+ payOrderResultInfo.setDiscountAmt(discountAmt.toString());
|
|
|
+ payOrderResultInfo.setDzkDiscountAmt(discountAmt.toString());
|
|
|
+ payOrderResultInfo.setDiscountPrice(discountPrice.toString());
|
|
|
+ payOrderResultInfo.setOilLiters(oilLiters.toString());
|
|
|
+ payOrderResultInfo.setReceivableAmt(receivableAmt.toString());
|
|
|
+ payOrderResultInfo.setOilPrice(oilPrice.toString());
|
|
|
+ payOrderResultInfo.setDzkAmt(amt.toString());
|
|
|
+ payOrderResultInfo.setOilsCardFlag("0");
|
|
|
+ if(params.get("cardRuleFlagGroup").toString().equals("1")){
|
|
|
+ //表示开启共享
|
|
|
+ if(params.get("cardEnabledFlagGroup").toString().equals("1")){ //表示开启电子卡功能
|
|
|
+ payOrderResultInfo.setCardEnabledFlag("1");
|
|
|
+ }else {
|
|
|
+ payOrderResultInfo.setCardEnabledFlag("0");
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ //不共享,则查看油站电子卡是否开启
|
|
|
+ if(params.get("cardEnabledFlag").toString().equals("1")){
|
|
|
+ payOrderResultInfo.setCardEnabledFlag("1");
|
|
|
+ }else {
|
|
|
+ payOrderResultInfo.setCardEnabledFlag("0");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ logger.info("油站是否开启电子会员卡功能: " +params.get("cardEnabledFlag").toString());
|
|
|
+ if(payOrderResultInfo.getCardEnabledFlag().equals("1")){
|
|
|
+ CustomerCardSetting customerCardSetting = new CustomerCardSetting();
|
|
|
+ customerCardSetting.setStationId(Integer.valueOf(params.get("stationId").toString()));
|
|
|
+ if(params.get("cardRuleFlagGroup").toString().equals("1")){
|
|
|
+ customerCardSetting.setStationId(Integer.valueOf(params.get("groupId").toString()));
|
|
|
+ }
|
|
|
+ List<CustomerCardSetting> cardRechargeSettingList = electronicMembershipCardService.getCardRechargeSettingList(customerCardSetting);
|
|
|
+ if(cardRechargeSettingList !=null && cardRechargeSettingList.size() >0){
|
|
|
+ String isGradeSetting = cardRechargeSettingList.get(0).getIsGradeSetting(); //是否叠加等级方案
|
|
|
+ String isMarket = cardRechargeSettingList.get(0).getIsMarket(); //等候否叠加营销方案
|
|
|
+ if(isMarket.equals("1")){
|
|
|
+ if(isGradeSetting.equals("1")){
|
|
|
+ BigDecimal dzkAmt = receivableAmt.subtract(dzkDiscountAmt).subtract(dzkGradeDiscountAmt);
|
|
|
+ dzkAmt =dzkAmt.signum() == -1 ? new BigDecimal("0.01"): dzkAmt;
|
|
|
+ payOrderResultInfo.setDzkAmt(dzkAmt.toString());
|
|
|
+ BigDecimal dzkDiscountAmtSum = dzkDiscountAmt.add(dzkGradeDiscountAmt); //电子卡优惠金额
|
|
|
+ payOrderResultInfo.setDzkDiscountAmt(dzkDiscountAmtSum.toString());
|
|
|
+ }else {
|
|
|
+ //如果电子卡设置执行营销方案不执行等级优惠 则 电子卡支付金额 =实收金额-营销优惠金额
|
|
|
+ BigDecimal dzkAmt = receivableAmt.subtract(dzkDiscountAmt);
|
|
|
+ dzkAmt =dzkAmt.signum() == -1 ? new BigDecimal("0.01"): dzkAmt;
|
|
|
+ payOrderResultInfo.setDzkAmt(dzkAmt.toString());
|
|
|
+ payOrderResultInfo.setDzkDiscountAmt(dzkDiscountAmt.toString());
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if(isGradeSetting.equals("1")){
|
|
|
+ //如果电子卡设置不执行营销方案执行等级优惠 则 电子卡支付金额 =应收金额-等级优惠金额
|
|
|
+ BigDecimal dzkAmt = receivableAmt.subtract(dzkGradeDiscountAmt);
|
|
|
+ dzkAmt =dzkAmt.signum() == -1 ? new BigDecimal("0.01"): dzkAmt;
|
|
|
+ payOrderResultInfo.setDzkAmt(dzkAmt.toString());
|
|
|
+ payOrderResultInfo.setDzkDiscountAmt(dzkGradeDiscountAmt.toString());
|
|
|
+ }else {
|
|
|
+ payOrderResultInfo.setDzkAmt(receivableAmt.toString());
|
|
|
+ payOrderResultInfo.setDzkDiscountAmt("0");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ CustomerElectronicCard customerElectronicCard = new CustomerElectronicCard();
|
|
|
+ customerElectronicCard.setStationId(Integer.valueOf(params.get("stationId").toString()));
|
|
|
+ customerElectronicCard.setCardOilsType(params.get("cardOilsType").toString());
|
|
|
+ customerElectronicCard.setUnionId(params.get("unionId").toString());
|
|
|
+ customerElectronicCard.setMobilePhone(params.get("userPhone").toString());
|
|
|
+ customerElectronicCard.setCustomerName(params.get("customerName").toString());
|
|
|
+ //查询客户余额和卡的类型
|
|
|
+ Map<String, String> map = this.selectCardBalance(customerElectronicCard, params);
|
|
|
+ payOrderResultInfo.setBalance(map.get("balance"));
|
|
|
+ payOrderResultInfo.setOilsCardFlag(map.get("oilsCardFlag"));
|
|
|
+ payOrderResultInfo.setCardOilsType(map.get("cardOilsType"));
|
|
|
+ }
|
|
|
+ return payOrderResultInfo;
|
|
|
+ }
|
|
|
+
|
|
|
//计算独立直降
|
|
|
public PayOrderResultInfo calculateZhiJiangDiscount(Map<String ,Object> params){
|
|
|
BigDecimal oilPrice = new BigDecimal(params.get("oilPrice").toString()); //油品价格
|
|
@@ -404,17 +553,47 @@ public class PayOrderController {
|
|
|
BigDecimal discountAmt_b = new BigDecimal(customerMarkertPlanList.get(0).get("discountAmt").toString()); //条件金额
|
|
|
BigDecimal gasoilDiscountAmt_b = new BigDecimal(customerMarkertPlanList.get(0).get("gasoilDiscountAmt").toString());
|
|
|
String discountTerm = customerMarkertPlanList.get(0).get("discountTerm").toString();
|
|
|
+ String discountSettingFlag = customerMarkertPlanList.get(0).get("discountSettingFlag").toString();
|
|
|
switch (discountTerm){
|
|
|
case "1": //按加油升数
|
|
|
if(oilLiters.compareTo(discountAmt_b) ==1 || oilLiters.compareTo(discountAmt_b) ==0){
|
|
|
discountAmt = oilLiters.multiply(gasoilDiscountAmt_b);
|
|
|
discountAmt = discountAmt.setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ //会员活动是否开启:1是;0否'
|
|
|
+ if(discountSettingFlag !=null && discountSettingFlag.equals("1")){
|
|
|
+ String discountType = customerMarkertPlanList.get(0).get("discountType").toString(); //会员日周期类型设置
|
|
|
+ String discountDate = customerMarkertPlanList.get(0).get("discountDate").toString(); //按固定日期
|
|
|
+ String discountActivityAmt = customerMarkertPlanList.get(0).get("discountActivityAmt").toString(); //会员日优惠金额
|
|
|
+ if(StringUtils.isNotBlank(discountType) && StringUtils.isNotBlank(discountDate) && StringUtils.isNotBlank(discountActivityAmt)){
|
|
|
+ //当前时间是否是活动会员日
|
|
|
+ boolean b = isActivityDay(discountType, discountDate);
|
|
|
+ if(b){
|
|
|
+ discountAmt = oilLiters.multiply(new BigDecimal(discountActivityAmt));
|
|
|
+ discountAmt = discountAmt.setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
break;
|
|
|
case "2": //按加油金额
|
|
|
if(receivableAmt.compareTo(discountAmt_b) ==1 || receivableAmt.compareTo(discountAmt_b) ==0){
|
|
|
discountAmt = oilLiters.multiply(gasoilDiscountAmt_b);
|
|
|
discountAmt = discountAmt.setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ //会员活动是否开启:1是;0否'
|
|
|
+ if(discountSettingFlag !=null && discountSettingFlag.equals("1")){
|
|
|
+ String discountType = customerMarkertPlanList.get(0).get("discountType").toString(); //会员日周期类型设置
|
|
|
+ String discountDate = customerMarkertPlanList.get(0).get("discountDate").toString(); //按固定日期
|
|
|
+ String discountActivityAmt = customerMarkertPlanList.get(0).get("discountActivityAmt").toString(); //会员日优惠金额
|
|
|
+ if(StringUtils.isNotBlank(discountType) && StringUtils.isNotBlank(discountDate) && StringUtils.isNotBlank(discountActivityAmt)){
|
|
|
+ //当前时间是否是活动会员日
|
|
|
+ boolean b = isActivityDay(discountType, discountDate);
|
|
|
+ if(b){
|
|
|
+ discountAmt = oilLiters.multiply(new BigDecimal(discountActivityAmt));
|
|
|
+ discountAmt = discountAmt.setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
@@ -538,6 +717,20 @@ public class PayOrderController {
|
|
|
BigDecimal gasoilDiscountAmt_b = new BigDecimal(customerMarkertPlanList.get(0).get("gasoilDiscountAmt").toString()); //享受的优惠
|
|
|
if(receivableAmt.compareTo(discountAmt_b) == 1 || receivableAmt.compareTo(discountAmt_b) == 0){
|
|
|
discountAmt = gasoilDiscountAmt_b;
|
|
|
+ //会员活动是否开启:1是;0否'
|
|
|
+ String discountSettingFlag = customerMarkertPlanList.get(0).get("discountSettingFlag").toString();
|
|
|
+ if(discountSettingFlag !=null && discountSettingFlag.equals("1")){
|
|
|
+ String discountType = customerMarkertPlanList.get(0).get("discountType").toString(); //会员日周期类型设置
|
|
|
+ String discountDate = customerMarkertPlanList.get(0).get("discountDate").toString(); //按固定日期
|
|
|
+ String discountActivityAmt = customerMarkertPlanList.get(0).get("discountActivityAmt").toString(); //会员日优惠金额
|
|
|
+ if(StringUtils.isNotBlank(discountType) && StringUtils.isNotBlank(discountDate) && StringUtils.isNotBlank(discountActivityAmt)){
|
|
|
+ //当前时间是否是会员日
|
|
|
+ boolean b = isActivityDay(discountType, discountDate);
|
|
|
+ if(b){
|
|
|
+ discountAmt = new BigDecimal(discountActivityAmt);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
dzkDiscountAmt = discountAmt;
|
|
|
String vipDiscountyPlus = customerMarkertPlanList.get(0).get("vipDiscountyPlus").toString();
|
|
@@ -628,7 +821,6 @@ public class PayOrderController {
|
|
|
|
|
|
//计算满减
|
|
|
public PayOrderResultInfo calculateManJianDiscount(Map<String ,Object> params){
|
|
|
-
|
|
|
BigDecimal oilPrice = new BigDecimal(params.get("oilPrice").toString()); //油品价格
|
|
|
BigDecimal receivableAmt = new BigDecimal(params.get("receivableAmt").toString()); //应收金额
|
|
|
BigDecimal oilLiters = new BigDecimal("0.00"); //加油升数
|
|
@@ -657,6 +849,22 @@ public class PayOrderController {
|
|
|
if(receivableAmt.compareTo(discountAmt_b) == 1 || receivableAmt.compareTo(discountAmt_b) == 0){
|
|
|
discountAmt = receivableAmt.divide(discountAmt_b, 2, BigDecimal.ROUND_HALF_UP).multiply(gasoilDiscountAmt_b); //优惠金额
|
|
|
discountAmt = discountAmt.setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ //会员活动是否开启:1是;0否'
|
|
|
+ String discountSettingFlag = customerMarkertPlanList.get(0).get("discountSettingFlag").toString();
|
|
|
+ if(discountSettingFlag !=null && discountSettingFlag.equals("1")){
|
|
|
+ String discountType = customerMarkertPlanList.get(0).get("discountType").toString(); //会员日周期类型设置
|
|
|
+ String discountDate = customerMarkertPlanList.get(0).get("discountDate").toString(); //按固定日期
|
|
|
+ String discountActivityAmt = customerMarkertPlanList.get(0).get("discountActivityAmt").toString(); //会员日优惠金额
|
|
|
+ //当前时间是否是会员日
|
|
|
+ if(StringUtils.isNotBlank(discountType) && StringUtils.isNotBlank(discountDate) && StringUtils.isNotBlank(discountActivityAmt)){
|
|
|
+ boolean b = isActivityDay(discountType, discountDate);
|
|
|
+ if(b){
|
|
|
+ discountAmt = receivableAmt.divide(discountAmt_b, 2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(discountActivityAmt)); //优惠金额
|
|
|
+ discountAmt = discountAmt.setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
dzkDiscountAmt = discountAmt;
|
|
|
//是否共享会员等级优惠叠加: 1 代表是; 2 代表否;
|
|
@@ -906,6 +1114,46 @@ public class PayOrderController {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /***
|
|
|
+ * //营销方案活动日优惠
|
|
|
+ * @param discountType 活动日时间类型
|
|
|
+ * @param discountDate 活动日时间字符串,格式:1,2,3,4
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public boolean isActivityDay(String discountType, String discountDate){
|
|
|
+ boolean boo= false;
|
|
|
+ if(discountDate !=null && discountDate !=""){
|
|
|
+ String currentTime = null; //当前时间
|
|
|
+ String[] discountDateArray = discountDate.split(",");
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTime(new Date()); //获取当前时间
|
|
|
+ switch (discountType){
|
|
|
+ case "1": // 1.按周来
|
|
|
+ int day_Week = calendar.get(Calendar.DAY_OF_WEEK);
|
|
|
+ day_Week= day_Week-1; //减一原因:数据库存的下标从零开始
|
|
|
+ currentTime = String.valueOf(day_Week);
|
|
|
+ break;
|
|
|
+ case "2": // 2.每月的 多少号
|
|
|
+ int day_month = calendar.get(Calendar.DAY_OF_MONTH);
|
|
|
+ day_month = day_month-1; //减一原因:数据库存的下标从零开始
|
|
|
+ currentTime = String.valueOf(day_month); //当前时间
|
|
|
+ break;
|
|
|
+ case "3": // 3.固定日期
|
|
|
+ currentTime =new SimpleDateFormat("yyyy-MM-dd").format(new Date()); //当前时间
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ //活动日优惠金额
|
|
|
+ for (String s : discountDateArray){
|
|
|
+ if(s.equals(currentTime)){
|
|
|
+ boo = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return boo;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 根据订单号获取订单信息
|
|
|
* produces="application/json;charset=UTF-8",consumes = "application/json",
|