更新9.19
This commit is contained in:
parent
d654a1cd10
commit
ce15bf3895
@ -1,9 +1,9 @@
|
||||
package com.fuint.business.marketingActivity.cardFavorable.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
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.service.impl.ServiceImpl;
|
||||
import com.fuint.business.marketingActivity.cardFavorable.dto.CardFavorableDTO;
|
||||
@ -30,9 +30,7 @@ import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -130,6 +128,7 @@ public class CardFavorableServiceImpl extends ServiceImpl<CardFavorableMapper, C
|
||||
IPage page1 = page(page, queryWrapper);
|
||||
//本店所有的优惠券
|
||||
List<CardFavorable> records = page1.getRecords();
|
||||
// log.info("本店所有的优惠券:"+records);
|
||||
ArrayList<CardFavorable> cardFavorableArrayList = new ArrayList<>();
|
||||
//登录人已领优惠券
|
||||
LambdaQueryWrapper<CardFavorableRecord> queryWrapper1 = new LambdaQueryWrapper<>();
|
||||
@ -142,24 +141,43 @@ public class CardFavorableServiceImpl extends ServiceImpl<CardFavorableMapper, C
|
||||
//所有领取列表的券ids
|
||||
ArrayList<Integer> carFavorbleRecordIds = new ArrayList<>();
|
||||
//领取列表的券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<>();
|
||||
//领取列表的券ids
|
||||
ArrayList<Integer> carFavorbleIds1 = new ArrayList<>();
|
||||
for (CardFavorableRecord cardFavorableRecord : list) {
|
||||
Integer cardFavorableId = cardFavorableRecord.getCardFavorableId();
|
||||
carFavorbleRecordIds.add(cardFavorableId);
|
||||
}
|
||||
|
||||
//券的id 与规则
|
||||
Map<Integer, String> map = new HashMap<>();
|
||||
for (CardFavorable record : records) {
|
||||
map.put(record.getId(), record.getClaimRule());
|
||||
if (record.getClaimRule().equals("0")){
|
||||
Integer id = record.getId();
|
||||
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 减去 限领一张的
|
||||
carFavorbleIds.removeAll(carFavorbleRecordIds);
|
||||
log.info("删除后的carFavorbleIds:{}",carFavorbleIds);
|
||||
// log.info("删除后的carFavorbleIds:{}",carFavorbleIds);
|
||||
for (Integer carFavorbleId : carFavorbleIds) {
|
||||
CardFavorable one = getById(carFavorbleId);
|
||||
cardFavorableArrayList.add(one);
|
||||
@ -171,10 +189,10 @@ public class CardFavorableServiceImpl extends ServiceImpl<CardFavorableMapper, C
|
||||
carFavorbleIds2.add(id);
|
||||
}
|
||||
}
|
||||
log.info("删除前的carFavorbleIds2:{}",carFavorbleIds2);
|
||||
// log.info("删除前的carFavorbleIds2:{}",carFavorbleIds2);
|
||||
//领取列表的券ids 减去 当前查询的券ids
|
||||
carFavorbleIds2.removeAll(carFavorbleIds1);
|
||||
log.info("删除后的carFavorbleIds2:{}",carFavorbleIds2);
|
||||
// log.info("删除后的carFavorbleIds2:{}",carFavorbleIds2);
|
||||
for (Integer carFavorbleId : carFavorbleIds) {
|
||||
CardFavorable one = getById(carFavorbleId);
|
||||
cardFavorableArrayList.add(one);
|
||||
@ -204,15 +222,20 @@ public class CardFavorableServiceImpl extends ServiceImpl<CardFavorableMapper, C
|
||||
}
|
||||
}
|
||||
}*/
|
||||
if (cardFavorableArrayList.size()>3){
|
||||
List<CardFavorable> cardFavorables = cardFavorableArrayList.subList(0, 3);
|
||||
page1.setRecords(cardFavorables);
|
||||
}else {
|
||||
// if (cardFavorableArrayList.size()>3){
|
||||
// List<CardFavorable> cardFavorables = cardFavorableArrayList.subList(0, 3);
|
||||
// page1.setRecords(cardFavorables);
|
||||
// }else {
|
||||
// page1.setRecords(cardFavorableArrayList);
|
||||
// }
|
||||
page1.setRecords(cardFavorableArrayList);
|
||||
}
|
||||
return page1;
|
||||
}
|
||||
|
||||
public boolean isTimeBetween(DateTime todayStart, DateTime todayEnd, DateTime checkTime) {
|
||||
return !checkTime.isBefore(todayStart) && !checkTime.isAfter(todayEnd);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询所有数据(小程序端)
|
||||
* @param page
|
||||
|
@ -2,6 +2,7 @@ package com.fuint.business.marketingActivity.cardFule.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
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.service.CardFuelChangeService;
|
||||
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.framework.web.BaseController;
|
||||
import com.fuint.framework.web.ResponseObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import io.lettuce.core.dynamic.annotation.Param;
|
||||
@ -27,6 +30,8 @@ import javax.annotation.Resource;
|
||||
@RestController
|
||||
@RequestMapping("business/marketingActivity/cardFuelChange")
|
||||
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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 囤油卡明细
|
||||
* @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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package com.fuint.business.marketingActivity.cardFule.entity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fuint.repository.model.base.BaseEntity;
|
||||
import lombok.Data;
|
||||
@ -83,6 +84,15 @@ public class CardFuelChange extends BaseEntity {
|
||||
*/
|
||||
private String orderNo;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String storeName;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String endTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String startTime;
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -31,7 +31,7 @@ public interface CardFuelChangeMapper {
|
||||
* @param page 分页对象
|
||||
* @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);
|
||||
|
||||
/**
|
||||
|
@ -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
|
||||
from card_fuel_change
|
||||
<where>
|
||||
<if test="id != null">
|
||||
and id = #{id}
|
||||
<if test="cardFuelChange.id != null">
|
||||
and id = #{cardFuelChange.id}
|
||||
</if>
|
||||
<if test="userId != null">
|
||||
and user_id = #{userId}
|
||||
<if test="cardFuelChange.userId != null">
|
||||
and user_id = #{cardFuelChange.userId}
|
||||
</if>
|
||||
<if test="chainStoreId != null">
|
||||
and chain_store_id = #{chainStoreId}
|
||||
<if test="cardFuelChange.chainStoreId != null">
|
||||
and chain_store_id = #{cardFuelChange.chainStoreId}
|
||||
</if>
|
||||
<if test="storeId != null">
|
||||
and store_id = #{storeId}
|
||||
<if test="cardFuelChange.storeId != null">
|
||||
and store_id = #{cardFuelChange.storeId}
|
||||
</if>
|
||||
<if test="changeType != null and changeType != ''">
|
||||
and change_type = #{changeType}
|
||||
<if test="cardFuelChange.changeType != null and changeType != ''">
|
||||
and change_type = #{cardFuelChange.changeType}
|
||||
</if>
|
||||
<if test="fromType != null and fromType != ''">
|
||||
and from_type = #{fromType}
|
||||
<if test="cardFuelChange.fromType != null and cardFuelChange.fromType != ''">
|
||||
and from_type = #{cardFuelChange.fromType}
|
||||
</if>
|
||||
<if test="balance != null">
|
||||
and balance = #{balance}
|
||||
<if test="cardFuelChange.balance != null">
|
||||
and balance = #{cardFuelChange.balance}
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
and create_time = #{createTime}
|
||||
<if test="cardFuelChange.createTime != null">
|
||||
and create_time = #{cardFuelChange.createTime}
|
||||
</if>
|
||||
<if test="createBy != null and createBy != ''">
|
||||
and create_by = #{createBy}
|
||||
<if test="cardFuelChange.createBy != null and cardFuelChange.createBy != ''">
|
||||
and create_by = #{cardFuelChange.createBy}
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
and update_time = #{updateTime}
|
||||
<if test="cardFuelChange.updateTime != null">
|
||||
and update_time = #{cardFuelChange.updateTime}
|
||||
</if>
|
||||
<if test="updateBy != null and updateBy != ''">
|
||||
and update_by = #{updateBy}
|
||||
<if test="cardFuelChange.updateBy != null and cardFuelChange.updateBy != ''">
|
||||
and update_by = #{cardFuelChange.updateBy}
|
||||
</if>
|
||||
<if test="type != null and type != ''">
|
||||
and type = #{type}
|
||||
<if test="cardFuelChange.type != null and cardFuelChange.type != ''">
|
||||
and type = #{cardFuelChange.type}
|
||||
</if>
|
||||
<if test="oilType != null and oilType != ''">
|
||||
and oil_type = #{oilType}
|
||||
<if test="cardFuelChange.oilType != null and cardFuelChange.oilType != ''">
|
||||
and oil_type = #{cardFuelChange.oilType}
|
||||
</if>
|
||||
<if test="unit != null and unit != ''">
|
||||
and unit = #{unit}
|
||||
<if test="cardFuelChange.unit != null and cardFuelChange.unit != ''">
|
||||
and unit = #{cardFuelChange.unit}
|
||||
</if>
|
||||
<if test="cardFuelChange.startTime != null and cardFuelChange.unit != ''">
|
||||
and create_time between #{cardFuelChange.startTime} and #{cardFuelChange.endTime}
|
||||
</if>
|
||||
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
@ -2,6 +2,7 @@ package com.fuint.business.marketingActivity.cardFule.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
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.vo.CardFuelChangeVo;
|
||||
import io.lettuce.core.dynamic.annotation.Param;
|
||||
@ -60,4 +61,5 @@ public interface CardFuelChangeService {
|
||||
*/
|
||||
boolean deleteById(Integer id);
|
||||
|
||||
IPage<CardFuelChange> queryByPageUni(Page page, CardFuelChange cardFuelChange);
|
||||
}
|
||||
|
@ -1,12 +1,18 @@
|
||||
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 com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fuint.business.marketingActivity.cardFule.entity.CardFuelChange;
|
||||
import com.fuint.business.marketingActivity.cardFule.mapper.CardFuelChangeMapper;
|
||||
import com.fuint.business.marketingActivity.cardFule.service.CardFuelChangeService;
|
||||
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 com.fuint.common.util.TokenUtil;
|
||||
import io.lettuce.core.dynamic.annotation.Param;
|
||||
@ -26,6 +32,8 @@ import javax.annotation.Resource;
|
||||
public class CardFuelChangeServiceImpl implements CardFuelChangeService {
|
||||
@Resource
|
||||
private CardFuelChangeMapper cardFuelChangeMapper;
|
||||
@Autowired
|
||||
private MtStoreMapper mtStoreMapper;
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
@ -104,4 +112,22 @@ public class CardFuelChangeServiceImpl implements CardFuelChangeService {
|
||||
public boolean deleteById(Integer id) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user