This commit is contained in:
齐天大圣 2024-04-26 13:42:56 +08:00
parent 8dcffd19a4
commit f0d00a61e1
3 changed files with 101 additions and 28 deletions

View File

@ -29,6 +29,7 @@ public class ActiveDiscountPayVO implements Serializable {
private String participationCondition;
//优惠券id
private Integer couponId;
private Integer limitAcount;
//优惠券金额
private BigDecimal cardFavorableAmount;
//优惠券信息

View File

@ -23,6 +23,8 @@ import com.fuint.business.marketingActivity.activeDiscount.vo.ActiveConsumptionV
import com.fuint.business.marketingActivity.activeDiscount.vo.ActiveDiscountAppletVO;
import com.fuint.business.marketingActivity.activeDiscount.vo.ActiveDiscountPayVO;
import com.fuint.business.marketingActivity.activeDiscount.vo.ActiveDiscountVO;
import com.fuint.business.marketingActivity.activeDiscountRecords.entity.ActiveDiscountRecords;
import com.fuint.business.marketingActivity.activeDiscountRecords.service.ActiveDiscountRecordsService;
import com.fuint.business.marketingActivity.activeExchange.dto.ActiveExchangeRecordDTO;
import com.fuint.business.marketingActivity.activeExchange.dto.PaymentActiveDTO;
import com.fuint.business.marketingActivity.activeExchange.dto.TransferDTO;
@ -31,6 +33,8 @@ import com.fuint.business.marketingActivity.activeExchange.vo.*;
import com.fuint.business.marketingActivity.activeFullminus.entity.ActiveFullminus;
import com.fuint.business.marketingActivity.activeFullminus.service.ActiveFullminusService;
import com.fuint.business.marketingActivity.activeFullminus.vo.ActiveFullminusAppletVO;
import com.fuint.business.marketingActivity.activeFullminusRecords.entity.ActiveFullminusRecords;
import com.fuint.business.marketingActivity.activeFullminusRecords.service.ActiveFullminusRecordsService;
import com.fuint.business.marketingActivity.activeNewlyweds.controller.vo.ActiveNewlywedsAppletVO;
import com.fuint.business.marketingActivity.activeNewlyweds.service.ActiveNewlywedsService;
import com.fuint.business.marketingActivity.activeRecommend.service.ActiveRecommendService;
@ -72,6 +76,7 @@ import com.fuint.business.userManager.service.UserBalanceService;
import com.fuint.business.userManager.vo.LJUserVo;
import com.fuint.common.dto.AccountInfo;
import com.fuint.common.util.TokenUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
@ -91,6 +96,7 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
@Service
@Slf4j
public class ActiveExchangeServiceImpl implements ActiveExchangeService {
@Resource
@ -138,6 +144,10 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService {
private ActiveConsumptionChildService activeConsumptionChildService;
@Resource
private CardFuelDieselService cardFuelDieselService;
@Resource
private ActiveFullminusRecordsService activeFullminusRecordsService;
@Resource
private ActiveDiscountRecordsService activeDiscountRecordsService;
/**
* 分页查询所有
@ -490,21 +500,52 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService {
//获取今日是周几
DayOfWeek dayOfWeek = LocalDate.now().getDayOfWeek();
String displayName = dayOfWeek.getDisplayName(TextStyle.FULL, Locale.getDefault());
if (displayName.equals("Friday")){
displayName = "星期五";
}else if (displayName.equals("Saturday")){
displayName = "星期六";
}else if (displayName.equals("Sunday")){
displayName = "星期日";
}else if (displayName.equals("Monday")){
displayName = "星期一";
}else if (displayName.equals("Tuesday")){
displayName = "星期二";
}else if (displayName.equals("Wednesday")){
displayName = "星期三";
}else if (displayName.equals("Thursday")){
displayName = "星期四";
}
log.info("504:获取今日是周几:"+displayName);
//获取今天是几号
LocalDate now = LocalDate.now();
String day = now.getDayOfMonth()+"";
ArrayList<ActiveDiscountPayVO> activeDiscountVOList = new ArrayList<>();
ArrayList<ActiveDiscountPayVO> activeDiscountVOListss = new ArrayList<>();
//折扣有限制
List<ActiveDiscountPayVO> activeDiscountVOListss = oilOrderMapper.selectActiveDiscount(storeId, paymentActiveDTO.getAmount(), paymentActiveDTO.getOilId(), paymentActiveDTO.getMtUserLevel(),paymentActiveDTO.getUserId());
List<ActiveDiscountPayVO> activeDiscountVOListssss = oilOrderMapper.selectActiveDiscount(storeId, paymentActiveDTO.getAmount(), paymentActiveDTO.getOilId(), paymentActiveDTO.getMtUserLevel(),paymentActiveDTO.getUserId());
for (ActiveDiscountPayVO discountV : activeDiscountVOListssss) {
Integer activeId = discountV.getActiveId();
LambdaQueryWrapper<ActiveDiscountRecords> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(ActiveDiscountRecords::getActiveDiscountId, activeId);
queryWrapper.eq(ActiveDiscountRecords::getUserId, paymentActiveDTO.getUserId());
List<ActiveDiscountRecords> list = activeDiscountRecordsService.list(queryWrapper);
if (list.size() <discountV.getLimitAcount()){
activeDiscountVOListss.add(discountV);
}
}
//会员日筛选
for (ActiveDiscountPayVO activeDiscountPayVO : activeDiscountVOListss) {
//
log.info("527:"+activeDiscountPayVO.getMemberDayType());
if (ObjectUtil.isNotEmpty(activeDiscountPayVO.getMemberDayType()) && activeDiscountPayVO.getMemberDayType().equals("2")) {
String weekDay = activeDiscountPayVO.getWeekDay();
log.info("530:"+activeDiscountPayVO.getWeekDay());
if (weekDay.contains(displayName)) {
activeDiscountVOList.add(activeDiscountPayVO);
}
} else if (ObjectUtil.isNotEmpty(activeDiscountPayVO.getMemberDayType()) && activeDiscountPayVO.getMemberDayType().equals("1")) {
String[] split = activeDiscountPayVO.getMonthDay().split(",");
for (String s : split) {
@ -512,18 +553,33 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService {
activeDiscountVOList.add(activeDiscountPayVO);
}
}
} else {
} else if (ObjectUtil.isNotEmpty(activeDiscountPayVO.getMemberDayType()) && activeDiscountPayVO.getMemberDayType().equals("0")){
activeDiscountVOList.add(activeDiscountPayVO);
}
}
}
List<ActiveDiscountPayVO> activeDiscountVOLists = new ArrayList<>();
//折扣无限制
List<ActiveDiscountPayVO> activeDiscountVOLists = oilOrderMapper.selectActiveDiscounts(storeId, paymentActiveDTO.getAmount(), paymentActiveDTO.getOilId(), paymentActiveDTO.getMtUserLevel(),paymentActiveDTO.getUserId());
List<ActiveDiscountPayVO> activeDiscountVOLis = oilOrderMapper.selectActiveDiscounts(storeId, paymentActiveDTO.getAmount(), paymentActiveDTO.getOilId(), paymentActiveDTO.getMtUserLevel(),paymentActiveDTO.getUserId());
for (ActiveDiscountPayVO discountV : activeDiscountVOLis) {
Integer activeId = discountV.getActiveId();
LambdaQueryWrapper<ActiveDiscountRecords> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(ActiveDiscountRecords::getActiveDiscountId, activeId);
queryWrapper.eq(ActiveDiscountRecords::getUserId, paymentActiveDTO.getUserId());
List<ActiveDiscountRecords> list = activeDiscountRecordsService.list(queryWrapper);
if (list.size() <discountV.getLimitAcount()){
activeDiscountVOLists.add(discountV);
}
}
//会员日筛选
for (ActiveDiscountPayVO activeDiscountPayVO : activeDiscountVOLists) {
//
log.info("564:"+activeDiscountPayVO.getMemberDayType());
if (ObjectUtil.isNotEmpty(activeDiscountPayVO.getMemberDayType()) && activeDiscountPayVO.getMemberDayType().equals("2")) {
String weekDay = activeDiscountPayVO.getWeekDay();
log.info("567:"+weekDay);
if (weekDay.contains(displayName)) {
activeDiscountVOList.add(activeDiscountPayVO);
}
@ -541,8 +597,19 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService {
}
//activeDiscountVOList.addAll(activeDiscountVOLists);
ArrayList<ActiveDiscountPayVO> activeFuletVOList = new ArrayList<>();
ArrayList<ActiveDiscountPayVO> activeFuletVOListss = new ArrayList<>();
//满减有限制
List<ActiveDiscountPayVO> activeFuletVOListss = oilOrderMapper.selectActiveFule(storeId, paymentActiveDTO.getAmount(), paymentActiveDTO.getOilId(), paymentActiveDTO.getMtUserLevel(),paymentActiveDTO.getUserId());
List<ActiveDiscountPayVO> activeFuletVOListsss = oilOrderMapper.selectActiveFule(storeId, paymentActiveDTO.getAmount(), paymentActiveDTO.getOilId(), paymentActiveDTO.getMtUserLevel(),paymentActiveDTO.getUserId());
for (ActiveDiscountPayVO fuletVOListss : activeFuletVOListsss) {
Integer activeId = fuletVOListss.getActiveId();
LambdaQueryWrapper<ActiveFullminusRecords> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(ActiveFullminusRecords::getActiveFullminusId, activeId);
queryWrapper.eq(ActiveFullminusRecords::getUserId, paymentActiveDTO.getUserId());
List<ActiveFullminusRecords> list = activeFullminusRecordsService.list(queryWrapper);
if (list.size() <fuletVOListss.getLimitAcount()){
activeFuletVOListss.add(fuletVOListss);
}
}
//会员日筛选
for (ActiveDiscountPayVO activeDiscountPayVO : activeFuletVOListss) {
//
@ -563,8 +630,22 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService {
activeFuletVOList.add(activeDiscountPayVO);
}
}
List<ActiveDiscountPayVO> activeFuletVOLists = new ArrayList<>();
//满减无限制
List<ActiveDiscountPayVO> activeFuletVOLists = oilOrderMapper.selectActiveFules(storeId, paymentActiveDTO.getAmount(), paymentActiveDTO.getOilId(), paymentActiveDTO.getMtUserLevel(),paymentActiveDTO.getUserId());
List<ActiveDiscountPayVO> activeFuletVOListssss = oilOrderMapper.selectActiveFules(storeId, paymentActiveDTO.getAmount(), paymentActiveDTO.getOilId(), paymentActiveDTO.getMtUserLevel(),paymentActiveDTO.getUserId());
for (ActiveDiscountPayVO fuletVOList : activeFuletVOListssss) {
Integer activeId = fuletVOList.getActiveId();
LambdaQueryWrapper<ActiveFullminusRecords> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(ActiveFullminusRecords::getActiveFullminusId, activeId);
queryWrapper.eq(ActiveFullminusRecords::getUserId, paymentActiveDTO.getUserId());
List<ActiveFullminusRecords> list = activeFullminusRecordsService.list(queryWrapper);
if (list.size() <fuletVOList.getLimitAcount()){
activeFuletVOLists.add(fuletVOList);
}
}
//会员日筛选
for (ActiveDiscountPayVO activeDiscountPayVO : activeFuletVOLists) {
//
@ -747,7 +828,6 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService {
cardAndComPays.add(activeDiscountPayVO1);
}
}
}
}
}
@ -863,6 +943,7 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService {
jsonObjects1.add(jsonObject);
}
}
if (ObjectUtils.isNotEmpty(jsonObjects1)){
JSONObject jsonObject = jsonObjects1.stream().max(Comparator.comparingDouble(o -> o.getDouble("gasolineRule2"))).get();
BigDecimal gasolineRule1 = jsonObject.getBigDecimal("gasolineRule1");
if (paymentActiveDTO.getAmount().compareTo(gasolineRule1) >= 0) {
@ -873,6 +954,7 @@ public class ActiveExchangeServiceImpl implements ActiveExchangeService {
}
}
}
}
if (oilTypebyId.equals("柴油")) {
if (ljUserGrade.getGasolineDiscount().equals("无优惠")) {

View File

@ -367,8 +367,7 @@
ad.month_day monthDay,
ad.member_day_type memberDayType,
max((case ad.store_id when ${storeId} then adc.amount * (1-(adc.discount * 0.1))
end)) as discount,
count( adr.id ) sidsss
end)) as discount
FROM
active_discount ad
LEFT JOIN active_discount_child adc ON ad.id = adc.active_discount_id
@ -382,7 +381,6 @@
AND concat(',',ad.adapt_oil,',') like concat('%',#{oilId},'%')
AND concat(',',ad.diesel_user_level,',') like concat('%',#{levelId},'%')
GROUP BY ad.id
HAVING sidsss <![CDATA[ < ]]> limitAcount
</select>
<select id="selectActiveDiscounts" resultType="com.fuint.business.marketingActivity.activeDiscount.vo.ActiveDiscountPayVO">
SELECT
@ -396,8 +394,7 @@
ad.month_day monthDay,
ad.member_day_type memberDayType,
max((case ad.store_id when ${storeId} then adc.amount * (1-(adc.discount * 0.1))
end)) as discount,
count( adr.id ) sidsss
end)) as discount
FROM
active_discount ad
LEFT JOIN active_discount_child adc ON ad.id = adc.active_discount_id
@ -411,7 +408,6 @@
AND concat(',',ad.adapt_oil,',') like concat('%',#{oilId},'%')
AND concat(',',ad.diesel_user_level,',') like concat('%',#{levelId},'%')
GROUP BY ad.id
HAVING sidsss <![CDATA[ < ]]> limitAcount
</select>
<select id="selectActiveFule" resultType="com.fuint.business.marketingActivity.activeDiscount.vo.ActiveDiscountPayVO">
@ -425,8 +421,7 @@
af.week_day weekDay,
af.month_day monthDay,
af.member_day_type memberDayType,
max(adc.deduction_amount) discount,
count( afr.id ) sidsss
max(adc.deduction_amount) discount
FROM
active_fullminus af
LEFT JOIN active_discount_child adc ON af.id = adc.active_fullminus_id
@ -439,9 +434,7 @@
AND af.STATUS = 0
AND concat(',',af.adapt_oil,',') like concat('%',#{oilId},'%')
AND concat(',',af.diesel_user_level,',') like concat('%',#{levelId},'%')
AND afr.user_id = #{userId}
GROUP BY af.id
HAVING sidsss <![CDATA[ < ]]> limitAcount
</select>
<select id="selectActiveFules" resultType="com.fuint.business.marketingActivity.activeDiscount.vo.ActiveDiscountPayVO">
SELECT
@ -454,8 +447,7 @@
af.week_day weekDay,
af.month_day monthDay,
af.member_day_type memberDayType,
max(adc.deduction_amount) discount,
count( afr.id ) sidsss
max(adc.deduction_amount) discount
FROM
active_fullminus af
LEFT JOIN active_discount_child adc ON af.id = adc.active_fullminus_id
@ -468,9 +460,7 @@
AND af.STATUS = 0
AND concat(',',af.adapt_oil,',') like concat('%',#{oilId},'%')
AND concat(',',af.diesel_user_level,',') like concat('%',#{levelId},'%')
AND afr.user_id = #{userId}
GROUP BY af.id
HAVING sidsss <![CDATA[ < ]]> limitAcount
</select>
<select id="selectActiveConsumption" resultType="com.fuint.business.marketingActivity.activeDiscount.vo.ActiveConsumptionVO">