From 5a42f4efa064c630607df429a016070787abb68f Mon Sep 17 00:00:00 2001
From: cun-nan <19819293608@163.com>
Date: Thu, 14 Mar 2024 09:21:48 +0800
Subject: [PATCH] bug
---
.../controller/CardFuelRecordController.java | 9 --
.../mapper/xml/CardFuelRecordMapper.xml | 11 ++-
.../service/CardFuelRecordService.java | 3 +-
.../impl/CardFuelRecordServiceImpl.java | 92 +++++++++++++------
4 files changed, 77 insertions(+), 38 deletions(-)
diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/controller/CardFuelRecordController.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/controller/CardFuelRecordController.java
index 216b3c774..c2dc3acfd 100644
--- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/controller/CardFuelRecordController.java
+++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/controller/CardFuelRecordController.java
@@ -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");
- }
}
diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/mapper/xml/CardFuelRecordMapper.xml b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/mapper/xml/CardFuelRecordMapper.xml
index 4f52c74c0..8b9ca0be2 100644
--- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/mapper/xml/CardFuelRecordMapper.xml
+++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/mapper/xml/CardFuelRecordMapper.xml
@@ -216,8 +216,15 @@
- 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})
diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/service/CardFuelRecordService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/service/CardFuelRecordService.java
index 4fd993ca7..b9f5c8285 100644
--- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/service/CardFuelRecordService.java
+++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/service/CardFuelRecordService.java
@@ -104,11 +104,12 @@ public interface CardFuelRecordService {
IPage test(Page page, String cardFuelRecord) throws JsonProcessingException;
void fuleRechargeFinallDeal(String orderNo) throws JsonProcessingException;
+ void expireOilToBalance();
+
/**
* 统计接口
* @param cardFuelRecord
* @return
*/
List selectFuelRecordCount(CardFuelRecord cardFuelRecord);
- public void expireOilToBalance();
}
diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/service/impl/CardFuelRecordServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/service/impl/CardFuelRecordServiceImpl.java
index df8ea4b1b..bb1246ad4 100644
--- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/service/impl/CardFuelRecordServiceImpl.java
+++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/service/impl/CardFuelRecordServiceImpl.java
@@ -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 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 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 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 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 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);
}
}
}
}
}
- // }
+ }
}
/**