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 b21e9659b..b1bc222d4 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 @@ -178,5 +178,12 @@ public class CardFuelRecordController extends BaseController { public void test() { this.cardFuelRecordService.expireOilToBalance(); } + + +//查询锁价记录 + @GetMapping("/getRecordByUserId") + public ResponseObject queryById(@Param("cardFuelRecord") CardFuelRecord cardFuelRecord) { + return getSuccessResult(this.cardFuelRecordService.getRecordByUserId(cardFuelRecord)); + } } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/mapper/CardFuelRecordMapper.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/mapper/CardFuelRecordMapper.java index b57df1d93..7e1ac2b8c 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/mapper/CardFuelRecordMapper.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/mapper/CardFuelRecordMapper.java @@ -108,6 +108,8 @@ public interface CardFuelRecordMapper extends BaseMapper { IPage queryByPageApplet(@Param("page") Page page, @Param("cardFuelRecord") CardFuelRecord cardFuelRecord); List selectFuelRecordCount(CardFuelRecord cardFuelRecord); + + CardFuelRecord getRecordByUserId(@Param("cardFuelRecord") CardFuelRecord cardFuelRecord); } 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 8b9ca0be2..a02702972 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 @@ -415,5 +415,15 @@ where store_id = #{storeId} GROUP BY oil_type + + 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 b9f5c8285..4c2675368 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 @@ -112,4 +112,6 @@ public interface CardFuelRecordService { * @return */ List selectFuelRecordCount(CardFuelRecord cardFuelRecord); + + CardFuelRecord getRecordByUserId(CardFuelRecord cardFuelRecord); } 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 d10dd3b19..88a6f8a63 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 @@ -29,12 +29,17 @@ import com.fuint.business.marketingActivity.cardFule.service.CardFuelRecordServi import com.fuint.business.marketingActivity.cardFule.vo.CardFuelRecordCount; import com.fuint.business.marketingActivity.cardFuleOrders.entity.CardFuleOrders; import com.fuint.business.marketingActivity.cardFuleOrders.service.CardFuleOrdersService; +import com.fuint.business.marketingActivity.cardValue.entity.CardValueRecord; +import com.fuint.business.marketingActivity.cardValue.mapper.CardValueRecordMapper; +import com.fuint.business.marketingActivity.cardValue.service.CardValueRecordService; 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.CardBalanceChange; 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.CardBalanceChangeService; import com.fuint.business.order.service.OilBalanceChangeService; import com.fuint.business.petrolStationManagement.service.OilNameService; import com.fuint.business.storeInformation.entity.LJStore; @@ -497,8 +502,7 @@ public class CardFuelRecordServiceImpl implements CardFuelRecordService { cardFuleOrders.setPoints(cardFuelDiesel.getPoints()); cardFuleOrders.setType(cardFuelDiesel.getType()); cardFuleOrders.setOilType(cardFuelDiesel.getOilType()); - cardFuleOrders.setIncomeLitres(cardFuelDiesel.getIncomeLitres()); - cardFuleOrders.setLockupPrice(cardFuelDiesel.getLockupPrice()); + cardFuleOrders.setLockupPrice(cardFuelDiesel.getLockPrice()); //油品名称 cardFuleOrders.setOilName(oilNameService.getById(cardFuelDiesel.getOilType()).getOilName()); //订单号 @@ -560,11 +564,136 @@ public class CardFuelRecordServiceImpl implements CardFuelRecordService { return null; } + + @Resource + private CardBalanceChangeService cardBalanceChangeService; + + @Resource + private CardValueRecordService cardValueRecordService; /** * 屯油卡充值后续处理 * @param orderNo */ @Transactional + public void fuleRechargeFinallDeal(String orderNo) throws JsonProcessingException { + UserBalance userBalance1 = new UserBalance(); + CardValueRecord cardValueRecord = new CardValueRecord(); + CardFuelRecord cardFuelRecord = new CardFuelRecord(); + OilBalanceChange oilBalanceChange = new OilBalanceChange(); + CardBalanceChange cardBalanceChange = new CardBalanceChange(); + double afterLitres = 0.0; + double afterBalance = 0.0; + //订单详情 + CardFuleOrders cardFuleOrders = cardFuleOrdersService.getOneByOrderNo(orderNo); + //更新订单状态 + cardFuleOrders.setStatus("paid"); + cardFuleOrders.setPayTime(new Date()); + cardFuleOrdersService.updateById(cardFuleOrders); + //用户余额 + UserBalance userBalance = userBalanceService.selectUserBalance(cardFuleOrders.getMtUserId(),cardFuleOrders.getChainStoreId()); + //用户 (新用户新建 老用户叠加) + if (ObjectUtils.isNotEmpty(userBalance)){ + //积分 + if (ObjectUtils.isNotEmpty(userBalance.getPoints()) && ObjectUtils.isNotEmpty(cardFuleOrders.getPoints())){ + userBalance.setPoints(userBalance.getPoints() + cardFuleOrders.getPoints()); + } + //储值卡余额 + if (ObjectUtils.isNotEmpty(userBalance.getCardBalance()) && ObjectUtils.isNotEmpty(cardFuleOrders.getAmount())){ + BigDecimal add = BigDecimal.valueOf(userBalance.getCardBalance()).add(BigDecimal.valueOf(cardFuleOrders.getAmount())); + afterBalance = add.doubleValue(); + userBalance.setCardBalance(afterBalance); + } + userBalanceService.updateUserBalance(userBalance); + }else { + userBalance1.setMtUserId(cardFuleOrders.getMtUserId()); + userBalance1.setChainStoreId(cardFuleOrders.getChainStoreId()); + //积分 + if (ObjectUtils.isNotEmpty(cardFuleOrders.getPoints())){ + userBalance1.setPoints(cardFuleOrders.getPoints()); + } + //储值卡余额 + if (ObjectUtils.isNotEmpty(cardFuleOrders.getAmount())){ + afterBalance = cardFuleOrders.getAmount(); + userBalance1.setCardBalance(afterBalance); + } + userBalanceService.save(userBalance1); + } + //员工提成 + staffCommissionService.countStaffCommission(cardFuleOrders.getStaffId(),cardFuleOrders.getStoreId(),cardFuleOrders.getAmount(),cardFuleOrders.getPayAmount(),"4",cardFuleOrders.getOrderNo()); + + //积分表变动 + if (ObjectUtils.isNotEmpty(userBalance) && ObjectUtils.isNotEmpty(userBalance.getPoints()) && ObjectUtils.isNotEmpty(cardFuleOrders.getPoints())) { + IntegralDetail integralDetail = new IntegralDetail(); + integralDetail.setStoreId(cardFuleOrders.getStoreId()); + integralDetail.setChainStoreId(cardFuleOrders.getChainStoreId()); + integralDetail.setPointsChange(Double.valueOf(cardFuleOrders.getPoints())); + integralDetail.setCurrentPoints(userBalance.getPoints() + cardFuleOrders.getPoints()); + integralDetail.setChangeType("1"); + integralDetail.setChangeReason("囤油卡充值"); + integralDetail.setUserId(cardFuleOrders.getMtUserId()); + IntegralDetail integralDetail1 = integralDetailService.insert2(integralDetail); + } + + //用户余额变化记录 + cardBalanceChange.setUserId(cardFuleOrders.getMtUserId()); + cardBalanceChange.setStoreId(cardFuleOrders.getStoreId()); + cardBalanceChange.setChainStoreId(cardFuleOrders.getChainStoreId()); + cardBalanceChange.setChangeType("1"); + cardBalanceChange.setFromType("屯油卡锁价"+cardFuleOrders.getAmount()+"元!"); + cardBalanceChange.setBalance(cardFuleOrders.getAmount()); + cardBalanceChange.setAfterTheChange(afterBalance); + cardBalanceChange.setOrderNo(cardFuleOrders.getOrderNo()); + cardBalanceChangeService.save(cardBalanceChange); + + + //生成余额充值记录 + cardValueRecord.setMtUserId(cardFuleOrders.getMtUserId()); + cardValueRecord.setName(cardFuleOrders.getName()); + cardValueRecord.setMobile(cardFuleOrders.getMobile()); + cardValueRecord.setMtStaffId(cardFuleOrders.getStaffId()); + cardValueRecord.setRealName(cardFuleOrders.getRealName()); + cardValueRecord.setStaffMobile(cardFuleOrders.getStaffMobile()); + cardValueRecord.setCardValueId(cardFuleOrders.getCardFuleId()); + cardValueRecord.setBidBalance(cardFuleOrders.getAmount()); + cardValueRecord.setRechargeBalance(cardFuleOrders.getAmount()); + cardValueRecord.setPaymentType(cardFuleOrders.getPaymentType()); + cardValueRecord.setPoints(cardFuleOrders.getPoints()); + cardValueRecord.setPayStatus("paid"); + cardValueRecord.setStoreId(cardFuleOrders.getStoreId()); + cardValueRecord.setChainStoreId(cardFuleOrders.getChainStoreId()); + cardValueRecord.setPaymentNo(cardFuleOrders.getOrderNo()); + cardValueRecordService.save(cardValueRecord); + + + //生成充值记录 + cardFuelRecord.setMtUserId(cardFuleOrders.getMtUserId()); + cardFuelRecord.setName(cardFuleOrders.getName()); + cardFuelRecord.setMobile(cardFuleOrders.getMobile()); + cardFuelRecord.setMtStaffId(cardFuleOrders.getStaffId()); + cardFuelRecord.setRealName(cardFuleOrders.getRealName()); + cardFuelRecord.setStaffMobile(cardFuleOrders.getStaffMobile()); + cardFuelRecord.setCardFuelId(cardFuleOrders.getCardFuleId()); + cardFuelRecord.setRechargeBalance(cardFuleOrders.getPayAmount()); + cardFuelRecord.setLockupPrice(cardFuleOrders.getLockupPrice()); + cardFuelRecord.setPayAmount(cardFuleOrders.getPayAmount()); + cardFuelRecord.setPaymentType(cardFuleOrders.getPaymentType()); + cardFuelRecord.setPoints(cardFuleOrders.getPoints()); + cardFuelRecord.setPayStatus("paid"); + cardFuelRecord.setStoreId(cardFuleOrders.getStoreId()); + cardFuelRecord.setPaymentNo(cardFuleOrders.getOrderNo()); + cardFuelRecord.setType(cardFuleOrders.getType()); + cardFuelRecord.setOilType(cardFuleOrders.getOilType()); + cardFuelRecord.setOilName(cardFuleOrders.getOilName()); + cardFuelRecord.setExpireTime(cardFuleOrders.getExpireTime()); + cardFuelRecord.setChainStoreId(cardFuleOrders.getChainStoreId()); + cardFuelRecordMapper.insert(cardFuelRecord); + } + + + + + +/* @Transactional public void fuleRechargeFinallDeal(String orderNo) throws JsonProcessingException { UserBalance userBalance1 = new UserBalance(); CardFuelRecord cardFuelRecord = new CardFuelRecord(); @@ -699,7 +828,7 @@ public class CardFuelRecordServiceImpl implements CardFuelRecordService { cardFuelRecord.setExpireTime(cardFuleOrders.getExpireTime()); cardFuelRecord.setChainStoreId(cardFuleOrders.getChainStoreId()); cardFuelRecordMapper.insert(cardFuelRecord); - } + }*/ @Scheduled(cron = "0 0 1 * * ?") @@ -874,4 +1003,18 @@ public class CardFuelRecordServiceImpl implements CardFuelRecordService { List cardFuelRecordCounts = cardFuelRecordMapper.selectFuelRecordCount(cardFuelRecord); return cardFuelRecordCounts; } + + @Override + public CardFuelRecord getRecordByUserId(CardFuelRecord cardFuelRecord) { + + Integer storeId = 0; + if (ObjectUtils.isNotEmpty(cardFuelRecord.getStoreId())){ + storeId = cardFuelRecord.getStoreId(); + }else { + storeId= TokenUtil.getNowAccountInfo().getStoreId(); + } + cardFuelRecord.setStoreId(storeId); + CardFuelRecord recordByUserId = cardFuelRecordMapper.getRecordByUserId(cardFuelRecord); + return recordByUserId; + } } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/HandoverRecordServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/HandoverRecordServiceImpl.java index 275a40df5..741a93c4f 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/HandoverRecordServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/HandoverRecordServiceImpl.java @@ -3,26 +3,18 @@ package com.fuint.business.order.service.impl; import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.baomidou.mybatisplus.generator.config.IFileCreate; import com.fuint.business.member.entity.LJStaff; import com.fuint.business.member.service.ILJStaffService; import com.fuint.business.order.entity.HandoverRecord; import com.fuint.business.order.mapper.HandoverRecordMapper; import com.fuint.business.order.service.HandoverRecordService; import com.fuint.business.store.entity.MtStore; -import com.fuint.business.store.mapper.MtStoreMapper; import com.fuint.business.store.service.StoreService; import com.fuint.business.userManager.mapper.LJUserMapper; -import com.fuint.business.userManager.vo.LJUserVo; import com.fuint.common.util.TscLibDll; import com.fuint.framework.exception.BusinessCheckException; -import com.fuint.system.dict.entity.SysDictData; -import com.fuint.system.dict.entity.SysDictType; import com.fuint.system.dict.service.ISysDictDataService; -import com.fuint.system.dict.service.ISysDictTypeService; -import io.swagger.models.auth.In; import javafx.print.Printer; -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;