This commit is contained in:
cun-nan 2024-03-14 09:21:48 +08:00
parent ea966e084b
commit 5a42f4efa0
4 changed files with 77 additions and 38 deletions

View File

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

View File

@ -216,8 +216,15 @@
<!--新增所有列-->
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
insert into card_fuel_record(mt_user_id, name, mobile, mt_staff_id, real_name, staff_mobile, card_fuel_id, recharge_balance,lockup_price, income_litres,pay_amount, payment_type, remark, points, growth_value, royalty_type, percentage_commissions, amount_commission, create_by, create_time, update_by, update_time, pay_status, store_id, payment_no, type, oil_type,oil_name,chain_store_id,actual_payment,make_change)
values (#{mtUserId}, #{name}, #{mobile}, #{mtStaffId}, #{realName}, #{staffMobile}, #{cardFuelId}, #{rechargeBalance}, #{lockupPrice}, #{incomeLitres}, #{payAmount}, #{paymentType}, #{remark}, #{points}, #{growthValue}, #{royaltyType}, #{percentageCommissions}, #{amountCommission}, #{createBy}, #{createTime}, #{updateBy}, #{createTime}, #{payStatus}, #{storeId}, #{paymentNo}, #{type}, #{oilType},#{oilName}, #{chainStoreId}, #{actualPayment}, #{makeChange})
insert into card_fuel_record(mt_user_id, name, mobile, mt_staff_id, real_name, staff_mobile, card_fuel_id,
recharge_balance,lockup_price, income_litres,pay_amount, payment_type, remark, points,
growth_value, royalty_type, percentage_commissions, amount_commission, create_by, create_time,
update_by, update_time, pay_status, store_id, payment_no, type, oil_type,oil_name,chain_store_id,
actual_payment,make_change,expire_time)
values (#{mtUserId}, #{name}, #{mobile}, #{mtStaffId}, #{realName}, #{staffMobile}, #{cardFuelId}, #{rechargeBalance},
#{lockupPrice}, #{incomeLitres}, #{payAmount}, #{paymentType}, #{remark}, #{points}, #{growthValue}, #{royaltyType},
#{percentageCommissions}, #{amountCommission}, #{createBy}, #{createTime}, #{updateBy}, #{createTime}, #{payStatus},
#{storeId}, #{paymentNo}, #{type}, #{oilType},#{oilName}, #{chainStoreId}, #{actualPayment}, #{makeChange}, #{expireTime})
</insert>
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">

View File

@ -104,11 +104,12 @@ public interface CardFuelRecordService {
IPage<CardFuelRecordDTO> test(Page page, String cardFuelRecord) throws JsonProcessingException;
void fuleRechargeFinallDeal(String orderNo) throws JsonProcessingException;
void expireOilToBalance();
/**
* 统计接口
* @param cardFuelRecord
* @return
*/
List<CardFuelRecordCount> selectFuelRecordCount(CardFuelRecord cardFuelRecord);
public void expireOilToBalance();
}

View File

@ -1,5 +1,6 @@
package com.fuint.business.marketingActivity.cardFule.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
@ -32,6 +33,7 @@ import com.fuint.business.member.entity.LJStaff;
import com.fuint.business.member.service.ILJStaffService;
import com.fuint.business.order.entity.AllOrderInfo;
import com.fuint.business.order.entity.OilBalanceChange;
import com.fuint.business.order.entity.RefuelMoney;
import com.fuint.business.order.service.AllOrderInfoService;
import com.fuint.business.order.service.OilBalanceChangeService;
import com.fuint.business.petrolStationManagement.service.OilNameService;
@ -45,6 +47,7 @@ import com.fuint.business.userManager.vo.LJUserVo;
import com.fuint.common.util.RedisLock;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import com.fuint.common.util.TokenUtil;
import io.lettuce.core.dynamic.annotation.Param;
@ -665,7 +668,7 @@ public class CardFuelRecordServiceImpl implements CardFuelRecordService {
}
@Override
@Scheduled(cron = "0 0 1 * * ?")
public void expireOilToBalance() {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date date = new Date();
@ -673,11 +676,11 @@ public class CardFuelRecordServiceImpl implements CardFuelRecordService {
//余额
List<UserBalance> list = userBalanceService.list();
UserBalance byIdsdsdsdsdsdsdsd = userBalanceService.getById(130);
//for (UserBalance userBalance : list) {
String refuelMoney = byIdsdsdsdsdsdsdsd.getRefuelMoney();
Double cardBalance = byIdsdsdsdsdsdsdsd.getCardBalance();
if (ObjectUtils.isNotEmpty(byIdsdsdsdsdsdsdsd.getChainStoreId()) && ObjectUtils.isNotEmpty(refuelMoney)) {
// UserBalance userBalance = userBalanceService.getById(130);
for (UserBalance userBalance : list) {
String refuelMoney = userBalance.getRefuelMoney();
Double cardBalance = userBalance.getCardBalance();
if (ObjectUtils.isNotEmpty(userBalance.getChainStoreId()) && ObjectUtils.isNotEmpty(refuelMoney)) {
List<JSONObject> jsonObjectList = JSONArray.parseArray(refuelMoney, JSONObject.class);
for (JSONObject jsonObject : jsonObjectList) {
@ -686,42 +689,79 @@ public class CardFuelRecordServiceImpl implements CardFuelRecordService {
Integer refuelMoney1 = jsonObject.getInteger("refuelMoney");
if (ObjectUtils.isNotEmpty(oilType)) {
LambdaQueryWrapper<CardFuelRecord> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(CardFuelRecord::getChainStoreId, byIdsdsdsdsdsdsdsd.getChainStoreId())
.eq(CardFuelRecord::getMtUserId, byIdsdsdsdsdsdsdsd.getMtUserId())
queryWrapper.eq(CardFuelRecord::getChainStoreId, userBalance.getChainStoreId())
.eq(CardFuelRecord::getMtUserId, userBalance.getMtUserId())
.eq(CardFuelRecord::getOilType, oilType)
.orderByAsc(CardFuelRecord::getCreateTime);
List<CardFuelRecord> cardFuelRecords = cardFuelRecordMapper.selectList(queryWrapper);
Double oil = 0.0;
Integer index = -1;
for (CardFuelRecord cardFuelRecord : cardFuelRecords) {
if(refuelMoney1 > oil){
if(refuelMoney1 >= oil){
oil += cardFuelRecord.getPayAmount()/cardFuelRecord.getLockupPrice();
index += 1;
}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;
// 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);
// }
// }
}
}
if (CollectionUtil.isNotEmpty(cardFuelRecords) &&
ObjectUtils.isNotEmpty(cardFuelRecords.get(index).getExpireTime())){
String format1 = simpleDateFormat.format(cardFuelRecords.get(index).getExpireTime());
//如果到期 这次充值囤油的钱转到余额
if (format1.equals(format)){
double restOil = cardFuelRecords.get(index).getIncomeLitres() - (oil - refuelMoney1);
//升数对应减少
Double lockupPrice = cardFuelRecords.get(index).getLockupPrice();
double restMoney = restOil * 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();
byIdsdsdsdsdsdsdsd.setRefuelMoney(userBnlancce);
byIdsdsdsdsdsdsdsd.setCardBalance(cardBalance + restMoney);
// JSONObject jsonObject1 = new JSONObject();
// jsonObject1.put("type", type);
// jsonObject1.put("oilType", oilType);
// jsonObject1.put("refuelMoney", refuelMoney1-restOil);
List<RefuelMoney> refuelMoneysList = new ArrayList<>();
for (JSONObject object : jsonObjectList) {
RefuelMoney refuelMoney2 = new RefuelMoney();
if (object.get("oilType").equals(oilType)){
refuelMoney2.setRefuelMoney(String.valueOf(refuelMoney1-restOil));
}else {
refuelMoney2.setRefuelMoney(object.get("refuelMoney").toString());
}
refuelMoney2.setType(object.get("type").toString());
refuelMoney2.setOilType(object.get("oilType").toString());
refuelMoneysList.add(refuelMoney2);
}
// jsonObjectList.add(jsonObject1);
String userBnlancce = jsonObjectList.toString();
userBalance.setRefuelMoney(com.alibaba.fastjson2.JSONObject.toJSONString(refuelMoneysList));
userBalance.setCardBalance(cardBalance + restMoney);
userBalanceService.updateUserBalance(userBalance);
}
}
}
}
}
// }
}
}
/**