更新9.19

This commit is contained in:
许允枞 2024-09-19 15:49:33 +08:00
parent d654a1cd10
commit ce15bf3895
7 changed files with 137 additions and 50 deletions

View File

@ -1,9 +1,9 @@
package com.fuint.business.marketingActivity.cardFavorable.service.impl; package com.fuint.business.marketingActivity.cardFavorable.service.impl;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fuint.business.marketingActivity.cardFavorable.dto.CardFavorableDTO; import com.fuint.business.marketingActivity.cardFavorable.dto.CardFavorableDTO;
@ -30,9 +30,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -130,6 +128,7 @@ public class CardFavorableServiceImpl extends ServiceImpl<CardFavorableMapper, C
IPage page1 = page(page, queryWrapper); IPage page1 = page(page, queryWrapper);
//本店所有的优惠券 //本店所有的优惠券
List<CardFavorable> records = page1.getRecords(); List<CardFavorable> records = page1.getRecords();
// log.info("本店所有的优惠券:"+records);
ArrayList<CardFavorable> cardFavorableArrayList = new ArrayList<>(); ArrayList<CardFavorable> cardFavorableArrayList = new ArrayList<>();
//登录人已领优惠券 //登录人已领优惠券
LambdaQueryWrapper<CardFavorableRecord> queryWrapper1 = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CardFavorableRecord> queryWrapper1 = new LambdaQueryWrapper<>();
@ -142,24 +141,43 @@ public class CardFavorableServiceImpl extends ServiceImpl<CardFavorableMapper, C
//所有领取列表的券ids //所有领取列表的券ids
ArrayList<Integer> carFavorbleRecordIds = new ArrayList<>(); ArrayList<Integer> carFavorbleRecordIds = new ArrayList<>();
//领取列表的券ids限领一张 //领取列表的券ids限领一张
ArrayList<Integer> carFavorbleIds = new ArrayList<>(); // ArrayList<Integer> carFavorbleIds = new ArrayList<>();
List<Integer> carFavorbleIds = records.stream().map(CardFavorable::getId).collect(Collectors.toList());
ArrayList<Integer> carFavorbleIds2 = new ArrayList<>(); ArrayList<Integer> carFavorbleIds2 = new ArrayList<>();
//领取列表的券ids
ArrayList<Integer> carFavorbleIds1 = new ArrayList<>(); //券的id 与规则
for (CardFavorableRecord cardFavorableRecord : list) { Map<Integer, String> map = new HashMap<>();
Integer cardFavorableId = cardFavorableRecord.getCardFavorableId();
carFavorbleRecordIds.add(cardFavorableId);
}
for (CardFavorable record : records) { for (CardFavorable record : records) {
map.put(record.getId(), record.getClaimRule());
if (record.getClaimRule().equals("0")){ if (record.getClaimRule().equals("0")){
Integer id = record.getId(); Integer id = record.getId();
carFavorbleIds.add(id); carFavorbleIds.add(id);
} }
} }
log.info("删除前的carFavorbleIds{}",carFavorbleIds);
//领取列表的券ids
ArrayList<Integer> carFavorbleIds1 = new ArrayList<>();
for (CardFavorableRecord cardFavorableRecord : list) {
Integer cardFavorableId = cardFavorableRecord.getCardFavorableId();
if (map.get(cardFavorableId).equals("0")) {
carFavorbleRecordIds.add(cardFavorableId);
}else {
//判断领取时间知否在今天
DateTime now = DateUtil.date();
DateTime start = DateUtil.beginOfDay(now);
DateTime end = DateUtil.endOfDay(now);
DateTime parse = DateUtil.date(cardFavorableRecord.getCreateTime());
boolean timeBetween = isTimeBetween(start, end, parse);
if (timeBetween) {
carFavorbleRecordIds.add(cardFavorableId);
}
}
}
// log.info("删除前的carFavorbleIds{}",carFavorbleIds);
//领取列表的券ids 减去 限领一张的 //领取列表的券ids 减去 限领一张的
carFavorbleIds.removeAll(carFavorbleRecordIds); carFavorbleIds.removeAll(carFavorbleRecordIds);
log.info("删除后的carFavorbleIds{}",carFavorbleIds); // log.info("删除后的carFavorbleIds{}",carFavorbleIds);
for (Integer carFavorbleId : carFavorbleIds) { for (Integer carFavorbleId : carFavorbleIds) {
CardFavorable one = getById(carFavorbleId); CardFavorable one = getById(carFavorbleId);
cardFavorableArrayList.add(one); cardFavorableArrayList.add(one);
@ -171,10 +189,10 @@ public class CardFavorableServiceImpl extends ServiceImpl<CardFavorableMapper, C
carFavorbleIds2.add(id); carFavorbleIds2.add(id);
} }
} }
log.info("删除前的carFavorbleIds2{}",carFavorbleIds2); // log.info("删除前的carFavorbleIds2{}",carFavorbleIds2);
//领取列表的券ids 减去 当前查询的券ids //领取列表的券ids 减去 当前查询的券ids
carFavorbleIds2.removeAll(carFavorbleIds1); carFavorbleIds2.removeAll(carFavorbleIds1);
log.info("删除后的carFavorbleIds2{}",carFavorbleIds2); // log.info("删除后的carFavorbleIds2{}",carFavorbleIds2);
for (Integer carFavorbleId : carFavorbleIds) { for (Integer carFavorbleId : carFavorbleIds) {
CardFavorable one = getById(carFavorbleId); CardFavorable one = getById(carFavorbleId);
cardFavorableArrayList.add(one); cardFavorableArrayList.add(one);
@ -204,15 +222,20 @@ public class CardFavorableServiceImpl extends ServiceImpl<CardFavorableMapper, C
} }
} }
}*/ }*/
if (cardFavorableArrayList.size()>3){ // if (cardFavorableArrayList.size()>3){
List<CardFavorable> cardFavorables = cardFavorableArrayList.subList(0, 3); // List<CardFavorable> cardFavorables = cardFavorableArrayList.subList(0, 3);
page1.setRecords(cardFavorables); // page1.setRecords(cardFavorables);
}else { // }else {
// page1.setRecords(cardFavorableArrayList);
// }
page1.setRecords(cardFavorableArrayList); page1.setRecords(cardFavorableArrayList);
}
return page1; return page1;
} }
public boolean isTimeBetween(DateTime todayStart, DateTime todayEnd, DateTime checkTime) {
return !checkTime.isBefore(todayStart) && !checkTime.isAfter(todayEnd);
}
/** /**
* 分页查询所有数据小程序端 * 分页查询所有数据小程序端
* @param page * @param page

View File

@ -2,6 +2,7 @@ package com.fuint.business.marketingActivity.cardFule.controller;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fuint.business.integral.entity.IntegralDetail;
import com.fuint.business.marketingActivity.cardFule.entity.CardFuelChange; import com.fuint.business.marketingActivity.cardFule.entity.CardFuelChange;
import com.fuint.business.marketingActivity.cardFule.service.CardFuelChangeService; import com.fuint.business.marketingActivity.cardFule.service.CardFuelChangeService;
import com.fuint.business.marketingActivity.cardFule.vo.CardFuelChangeVo; import com.fuint.business.marketingActivity.cardFule.vo.CardFuelChangeVo;
@ -11,6 +12,8 @@ import com.fuint.business.setting.entity.SysLog;
import com.fuint.business.setting.service.SysLogService; import com.fuint.business.setting.service.SysLogService;
import com.fuint.framework.web.BaseController; import com.fuint.framework.web.BaseController;
import com.fuint.framework.web.ResponseObject; import com.fuint.framework.web.ResponseObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import io.lettuce.core.dynamic.annotation.Param; import io.lettuce.core.dynamic.annotation.Param;
@ -27,6 +30,8 @@ import javax.annotation.Resource;
@RestController @RestController
@RequestMapping("business/marketingActivity/cardFuelChange") @RequestMapping("business/marketingActivity/cardFuelChange")
public class CardFuelChangeController extends BaseController { public class CardFuelChangeController extends BaseController {
private static final Logger log = LoggerFactory.getLogger(CardFuelChangeController.class);
/** /**
* 服务对象 * 服务对象
*/ */
@ -103,5 +108,22 @@ public class CardFuelChangeController extends BaseController {
return getSuccessResult(this.cardFuelChangeService.deleteById(id)); return getSuccessResult(this.cardFuelChangeService.deleteById(id));
} }
/**
* 囤油卡明细
* @param pageNo
* @param pageSize
* @param cardFuelChange
* @return
*/
@GetMapping("queryByPageUni")
public ResponseObject queryByPageUni(@RequestParam(value = "pageNo",defaultValue = "1") Integer pageNo,
@RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize,
@Param("cardFuelChange") CardFuelChange cardFuelChange) {
Page page = new Page(pageNo, pageSize);
log.info("cardFuelChange:{}",cardFuelChange);
IPage< CardFuelChange> iPageList = this.cardFuelChangeService.queryByPageUni(page, cardFuelChange);
return getSuccessResult(iPageList);
}
} }

View File

@ -2,6 +2,7 @@ package com.fuint.business.marketingActivity.cardFule.entity;
import java.util.Date; import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.fuint.repository.model.base.BaseEntity; import com.fuint.repository.model.base.BaseEntity;
import lombok.Data; import lombok.Data;
@ -83,6 +84,15 @@ public class CardFuelChange extends BaseEntity {
*/ */
private String orderNo; private String orderNo;
@TableField(exist = false)
private String storeName;
@TableField(exist = false)
private String endTime;
@TableField(exist = false)
private String startTime;

View File

@ -31,7 +31,7 @@ public interface CardFuelChangeMapper {
* @param page 分页对象 * @param page 分页对象
* @return 对象列表 * @return 对象列表
*/ */
IPage<CardFuelChange> queryAllByLimit(@Param("page") Page page, CardFuelChange cardFuelChange); IPage<CardFuelChange> queryAllByLimit(@Param("page") Page page,@Param("cardFuelChange") CardFuelChange cardFuelChange);
IPage<CardFuelChangeVo> getFuelRecordList(@Param("page") Page page,@Param("cardFuelChange") CardFuelChange cardFuelChange); IPage<CardFuelChangeVo> getFuelRecordList(@Param("page") Page page,@Param("cardFuelChange") CardFuelChange cardFuelChange);
/** /**

View File

@ -33,48 +33,52 @@
id, user_id, chain_store_id, store_id, change_type, from_type, balance, create_time, create_by, update_time, update_by, type, oil_type, unit id, user_id, chain_store_id, store_id, change_type, from_type, balance, create_time, create_by, update_time, update_by, type, oil_type, unit
from card_fuel_change from card_fuel_change
<where> <where>
<if test="id != null"> <if test="cardFuelChange.id != null">
and id = #{id} and id = #{cardFuelChange.id}
</if> </if>
<if test="userId != null"> <if test="cardFuelChange.userId != null">
and user_id = #{userId} and user_id = #{cardFuelChange.userId}
</if> </if>
<if test="chainStoreId != null"> <if test="cardFuelChange.chainStoreId != null">
and chain_store_id = #{chainStoreId} and chain_store_id = #{cardFuelChange.chainStoreId}
</if> </if>
<if test="storeId != null"> <if test="cardFuelChange.storeId != null">
and store_id = #{storeId} and store_id = #{cardFuelChange.storeId}
</if> </if>
<if test="changeType != null and changeType != ''"> <if test="cardFuelChange.changeType != null and changeType != ''">
and change_type = #{changeType} and change_type = #{cardFuelChange.changeType}
</if> </if>
<if test="fromType != null and fromType != ''"> <if test="cardFuelChange.fromType != null and cardFuelChange.fromType != ''">
and from_type = #{fromType} and from_type = #{cardFuelChange.fromType}
</if> </if>
<if test="balance != null"> <if test="cardFuelChange.balance != null">
and balance = #{balance} and balance = #{cardFuelChange.balance}
</if> </if>
<if test="createTime != null"> <if test="cardFuelChange.createTime != null">
and create_time = #{createTime} and create_time = #{cardFuelChange.createTime}
</if> </if>
<if test="createBy != null and createBy != ''"> <if test="cardFuelChange.createBy != null and cardFuelChange.createBy != ''">
and create_by = #{createBy} and create_by = #{cardFuelChange.createBy}
</if> </if>
<if test="updateTime != null"> <if test="cardFuelChange.updateTime != null">
and update_time = #{updateTime} and update_time = #{cardFuelChange.updateTime}
</if> </if>
<if test="updateBy != null and updateBy != ''"> <if test="cardFuelChange.updateBy != null and cardFuelChange.updateBy != ''">
and update_by = #{updateBy} and update_by = #{cardFuelChange.updateBy}
</if> </if>
<if test="type != null and type != ''"> <if test="cardFuelChange.type != null and cardFuelChange.type != ''">
and type = #{type} and type = #{cardFuelChange.type}
</if> </if>
<if test="oilType != null and oilType != ''"> <if test="cardFuelChange.oilType != null and cardFuelChange.oilType != ''">
and oil_type = #{oilType} and oil_type = #{cardFuelChange.oilType}
</if> </if>
<if test="unit != null and unit != ''"> <if test="cardFuelChange.unit != null and cardFuelChange.unit != ''">
and unit = #{unit} and unit = #{cardFuelChange.unit}
</if> </if>
<if test="cardFuelChange.startTime != null and cardFuelChange.unit != ''">
and create_time between #{cardFuelChange.startTime} and #{cardFuelChange.endTime}
</if>
</where> </where>
</select> </select>

View File

@ -2,6 +2,7 @@ package com.fuint.business.marketingActivity.cardFule.service;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fuint.business.integral.entity.IntegralDetail;
import com.fuint.business.marketingActivity.cardFule.entity.CardFuelChange; import com.fuint.business.marketingActivity.cardFule.entity.CardFuelChange;
import com.fuint.business.marketingActivity.cardFule.vo.CardFuelChangeVo; import com.fuint.business.marketingActivity.cardFule.vo.CardFuelChangeVo;
import io.lettuce.core.dynamic.annotation.Param; import io.lettuce.core.dynamic.annotation.Param;
@ -60,4 +61,5 @@ public interface CardFuelChangeService {
*/ */
boolean deleteById(Integer id); boolean deleteById(Integer id);
IPage<CardFuelChange> queryByPageUni(Page page, CardFuelChange cardFuelChange);
} }

View File

@ -1,12 +1,18 @@
package com.fuint.business.marketingActivity.cardFule.service.impl; package com.fuint.business.marketingActivity.cardFule.service.impl;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fuint.business.marketingActivity.cardFule.entity.CardFuelChange; import com.fuint.business.marketingActivity.cardFule.entity.CardFuelChange;
import com.fuint.business.marketingActivity.cardFule.mapper.CardFuelChangeMapper; import com.fuint.business.marketingActivity.cardFule.mapper.CardFuelChangeMapper;
import com.fuint.business.marketingActivity.cardFule.service.CardFuelChangeService; import com.fuint.business.marketingActivity.cardFule.service.CardFuelChangeService;
import com.fuint.business.marketingActivity.cardFule.vo.CardFuelChangeVo; import com.fuint.business.marketingActivity.cardFule.vo.CardFuelChangeVo;
import com.fuint.business.store.entity.MtStore;
import com.fuint.business.store.mapper.MtStoreMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.fuint.common.util.TokenUtil; import com.fuint.common.util.TokenUtil;
import io.lettuce.core.dynamic.annotation.Param; import io.lettuce.core.dynamic.annotation.Param;
@ -26,6 +32,8 @@ import javax.annotation.Resource;
public class CardFuelChangeServiceImpl implements CardFuelChangeService { public class CardFuelChangeServiceImpl implements CardFuelChangeService {
@Resource @Resource
private CardFuelChangeMapper cardFuelChangeMapper; private CardFuelChangeMapper cardFuelChangeMapper;
@Autowired
private MtStoreMapper mtStoreMapper;
/** /**
* 通过ID查询单条数据 * 通过ID查询单条数据
@ -104,4 +112,22 @@ public class CardFuelChangeServiceImpl implements CardFuelChangeService {
public boolean deleteById(Integer id) { public boolean deleteById(Integer id) {
return this.cardFuelChangeMapper.deleteById(id) > 0; return this.cardFuelChangeMapper.deleteById(id) > 0;
} }
public IPage<CardFuelChange> queryByPageUni(@Param("page") Page page, CardFuelChange cardFuelChange) {
if (ObjectUtil.isNotEmpty(cardFuelChange.getStartTime())) {
DateTime parse = DateUtil.parse(cardFuelChange.getStartTime());
cardFuelChange.setStartTime(DateUtil.beginOfMonth(parse).toString());
cardFuelChange.setEndTime(DateUtil.endOfMonth(parse).toString());
}
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
cardFuelChange.setUserId(nowAccountInfo.getId());
IPage<CardFuelChange> cardFuelChangeIPage = this.cardFuelChangeMapper.queryAllByLimit(page, cardFuelChange);
LambdaQueryWrapper<MtStore> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(MtStore::getId, cardFuelChange.getStoreId());
MtStore mtStore = mtStoreMapper.selectOne(queryWrapper);
cardFuelChangeIPage.getRecords().forEach(item -> {
item.setStoreName(mtStore.getName());
});
return cardFuelChangeIPage;
}
} }