This commit is contained in:
齐天大圣 2024-03-13 16:16:05 +08:00
parent 854a3242bb
commit 503632e769
8 changed files with 86 additions and 2 deletions

View File

@ -174,5 +174,13 @@ public class CardFuelRecordController extends BaseController {
return getSuccessResult(this.cardFuelRecordService.selectFuelRecordCount(cardFuelRecord));
}
/**
* 统计接口
*/
@GetMapping("testss")
public ResponseObject test() {
this.cardFuelRecordService.expireOilToBalance();
return getSuccessResult("11");
}
}

View File

@ -47,6 +47,9 @@ public class CardFuelDiesel extends Model<CardFuelDiesel> {
//活动开始时间
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" , timezone = "GMT+8")
private Date startTime;
//活动到期时间
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" , timezone = "GMT+8")
private Date expireTime;
//活动结束时间
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" , timezone = "GMT+8")
private Date endTime;

View File

@ -111,6 +111,9 @@ public class CardFuelRecord extends BaseEntity {
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" , timezone = "GMT+8")
private Date updateTime;
//活动到期时间
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" , timezone = "GMT+8")
private Date expireTime;
/**
* 支付状态
*/

View File

@ -1,7 +1,9 @@
package com.fuint.business.marketingActivity.cardFule.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fuint.business.marketingActivity.activeApplet.entity.ActiveApplet;
import com.fuint.business.marketingActivity.cardFule.dto.CardFuelRecordDTO;
import com.fuint.business.marketingActivity.cardFule.entity.CardFuelRecord;
import com.fuint.business.marketingActivity.cardFule.vo.CardFuelRecordCount;
@ -16,7 +18,7 @@ import java.util.Map;
* @author wangh
* @since 2023-11-13 18:53:32
*/
public interface CardFuelRecordMapper {
public interface CardFuelRecordMapper extends BaseMapper<CardFuelRecord> {
/**
* 通过ID查询单条数据

View File

@ -110,4 +110,5 @@ public interface CardFuelRecordService {
* @return
*/
List<CardFuelRecordCount> selectFuelRecordCount(CardFuelRecord cardFuelRecord);
public void expireOilToBalance();
}

View File

@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
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.fasterxml.jackson.core.JsonProcessingException;
@ -38,6 +39,7 @@ import com.fuint.business.storeInformation.entity.LJStore;
import com.fuint.business.storeInformation.service.ILJStoreService;
import com.fuint.business.userManager.entity.UserBalance;
import com.fuint.business.userManager.mapper.LJUserMapper;
import com.fuint.business.userManager.mapper.UserBalanceMapper;
import com.fuint.business.userManager.service.UserBalanceService;
import com.fuint.business.userManager.vo.LJUserVo;
import com.fuint.common.util.RedisLock;
@ -53,6 +55,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.*;
import java.util.concurrent.TimeUnit;
@ -469,6 +472,7 @@ public class CardFuelRecordServiceImpl implements CardFuelRecordService {
//查询囤油卡信息
CardFuelDiesel cardFuelDiesel = cardFuelDieselService.getById(cardFuelRecordDTO.getId());
cardFuleOrders.setCardFuleId(cardFuelDiesel.getId());
cardFuleOrders.setExpireTime(cardFuelDiesel.getExpireTime());
cardFuleOrders.setAmount(cardFuelDiesel.getRechargeBalance());
cardFuleOrders.setPayAmount(cardFuelDiesel.getRechargeBalance());
cardFuleOrders.setPoints(cardFuelDiesel.getPoints());
@ -658,9 +662,70 @@ public class CardFuelRecordServiceImpl implements CardFuelRecordService {
cardFuelRecord.setType(cardFuleOrders.getType());
cardFuelRecord.setOilType(cardFuleOrders.getOilType()+ cardFuleOrders.getOilName());
cardFuelRecord.setOilName(cardFuleOrders.getOilName());
cardFuelRecord.setExpireTime(cardFuleOrders.getExpireTime());
cardFuelRecordMapper.insert(cardFuelRecord);
}
@Override
public void expireOilToBalance() {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date date = new Date();
String format = simpleDateFormat.format(date);
//余额
List<UserBalance> list = userBalanceService.list();
for (UserBalance userBalance : list) {
String refuelMoney = userBalance.getRefuelMoney();
Double cardBalance = userBalance.getCardBalance();
if (ObjectUtils.isNotEmpty(userBalance.getStoreId()) && ObjectUtils.isNotEmpty(refuelMoney)) {
List<JSONObject> jsonObjectList = JSONArray.parseArray(refuelMoney, JSONObject.class);
for (JSONObject jsonObject : jsonObjectList) {
String oilType = jsonObject.getString("oilType");
String type = jsonObject.getString("type");
Integer refuelMoney1 = jsonObject.getInteger("refuelMoney");
if (ObjectUtils.isNotEmpty(oilType)) {
LambdaQueryWrapper<CardFuelRecord> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(CardFuelRecord::getStoreId, userBalance.getStoreId())
.eq(CardFuelRecord::getMtUserId, userBalance.getMtUserId())
.eq(CardFuelRecord::getOilType, oilType)
.orderByAsc(CardFuelRecord::getCreateTime);
List<CardFuelRecord> cardFuelRecords = cardFuelRecordMapper.selectList(queryWrapper);
Double oil = 0.0;
for (CardFuelRecord cardFuelRecord : cardFuelRecords) {
if(refuelMoney1 > oil){
oil += cardFuelRecord.getPayAmount()/cardFuelRecord.getLockupPrice();
}else {
if (ObjectUtils.isNotEmpty(cardFuelRecord.getExpireTime())){
String format1 = simpleDateFormat.format(cardFuelRecord.getExpireTime());
//如果到期 这次充值囤油的钱转到余额
if (format1.equals(format)){
double restOil = cardFuelRecord.getPayAmount() - (oil - refuelMoney1);
//升数对应减少
Double lockupPrice = cardFuelRecord.getLockupPrice();
double restMoney = oil * lockupPrice;
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("type", type);
jsonObject1.put("oilType", oilType);
jsonObject1.put("refuelMoney", refuelMoney1-restOil);
jsonObjectList.add(jsonObject1);
String userBnlancce = jsonObjectList.toString();
userBalance.setRefuelMoney(userBnlancce);
userBalance.setCardBalance(cardBalance + restMoney);
}
}
}
}
}
}
}
}
}
/**
* 统计接口
* @param cardFuelRecord

View File

@ -80,5 +80,8 @@ public class CardFuleOrders extends Model<CardFuleOrders> {
//更新时间
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" , timezone = "GMT+8")
private Date updateTime;
//活动到期时间
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" , timezone = "GMT+8")
private Date expireTime;
}

View File

@ -2,7 +2,6 @@ package com.fuint.business.marketingActivity.cardValue.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fuint.business.marketingActivity.activeConsumption.entity.ActiveConsumption;
import com.fuint.business.marketingActivity.cardValue.dto.CardValueDTO;
import com.fuint.business.marketingActivity.cardValue.entity.CardValue;
import com.fuint.business.marketingActivity.cardValue.service.CardValueService;