From 4fa7be30bd4bba2fb7e2912524392e2bb432e992 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BD=90=E5=A4=A9=E5=A4=A7=E5=9C=A3?= <17615834396@163.com> Date: Wed, 3 Jan 2024 18:45:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EventMarketing/storeOilBlock/index.vue | 6 +- .../controller/CardFuelDieselController.java | 15 ++++ .../controller/CardFuelRecordController.java | 2 - .../cardFule/dto/CardFuelRecordDTO.java | 4 + .../service/CardFuelDieselService.java | 2 + .../impl/CardFuelDieselServiceImpl.java | 44 ++++++++++ .../impl/CardFuelRecordServiceImpl.java | 63 +++++++++------ .../pagesHome/oilRecharge/oilRecharge.vue | 81 ++++++++++++++++--- 8 files changed, 175 insertions(+), 42 deletions(-) diff --git a/fuintAdmin/src/views/EventMarketing/storeOilBlock/index.vue b/fuintAdmin/src/views/EventMarketing/storeOilBlock/index.vue index 2e5dd2e7f..dda9860f3 100644 --- a/fuintAdmin/src/views/EventMarketing/storeOilBlock/index.vue +++ b/fuintAdmin/src/views/EventMarketing/storeOilBlock/index.vue @@ -14,9 +14,9 @@ + :value="dict.id"> @@ -167,10 +167,8 @@ diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/controller/CardFuelDieselController.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/controller/CardFuelDieselController.java index 5c932fa6c..7512a18af 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/controller/CardFuelDieselController.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/controller/CardFuelDieselController.java @@ -50,6 +50,21 @@ public class CardFuelDieselController extends BaseController { return getSuccessResult(this.cardFuelDieselService.select(page, cardFuelDiesel)); } + /** + * 分页查询所有数据(小程序端) + * @param pageNo + * @param pageSize + * @param cardFuelDiesel + * @return + */ + @GetMapping("selectAllApplet") + public ResponseObject selectAllApplet(@RequestParam(value = "pageNo",defaultValue = "1") Integer pageNo, + @RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize, + @Param("cardFuelDiesel") CardFuelDiesel cardFuelDiesel) { + Page page = new Page(pageNo, pageSize); + return getSuccessResult(this.cardFuelDieselService.selectAllApplet(page, cardFuelDiesel)); + } + /** * 通过主键查询单条数据 * 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 ea95aa713..70917eeb7 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 @@ -165,7 +165,5 @@ public class CardFuelRecordController extends BaseController { return getSuccessResult(iPageList); } - - } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/dto/CardFuelRecordDTO.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/dto/CardFuelRecordDTO.java index e406939b5..a6374ba15 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/dto/CardFuelRecordDTO.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/dto/CardFuelRecordDTO.java @@ -11,5 +11,9 @@ public class CardFuelRecordDTO extends CardFuelRecord { private Double realyPayBills; //付款类型 1.微信 2.支付宝 private String payType; + //优惠券id + private Integer cardFavorableId; + //卡券领取记录id + private Integer cardRecordId; } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/service/CardFuelDieselService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/service/CardFuelDieselService.java index ed3c331e5..206b88730 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/service/CardFuelDieselService.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/service/CardFuelDieselService.java @@ -24,5 +24,7 @@ public interface CardFuelDieselService extends IService { * @return */ IPage select(Page page, CardFuelDiesel cardFuelDiesel); + + IPage selectAllApplet(Page page, CardFuelDiesel cardFuelDiesel); } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/service/impl/CardFuelDieselServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/service/impl/CardFuelDieselServiceImpl.java index c1dc35254..9c61dc7c7 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/service/impl/CardFuelDieselServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/service/impl/CardFuelDieselServiceImpl.java @@ -80,5 +80,49 @@ public class CardFuelDieselServiceImpl extends ServiceImpl queryWrapper = new LambdaQueryWrapper<>(); + if(ObjectUtils.isNotEmpty(cardFuelDiesel.getOilType())){ + queryWrapper.eq(CardFuelDiesel::getOilType,cardFuelDiesel.getOilType()); + } + queryWrapper.eq(CardFuelDiesel::getStoreId,cardFuelDiesel.getStoreId()); + if (ObjectUtils.isNotEmpty(cardFuelDiesel.getActiveStatus())){ + queryWrapper.eq(CardFuelDiesel::getActiveStatus,cardFuelDiesel.getActiveStatus()); + } + if(ObjectUtils.isNotEmpty(cardFuelDiesel.getType())) { + queryWrapper.eq(CardFuelDiesel::getType,cardFuelDiesel.getType()); + } + queryWrapper.orderByDesc(CardFuelDiesel::getCreateTime); + IPage page1 = page(page, queryWrapper); + List records = page1.getRecords(); + //返回囤油卡状态 + for (CardFuelDiesel record : records) { + record.setOilType(oilNameService.selectOilNameById(Integer.parseInt(record.getOilType())).getOilName()); + record.setStatus(record.getStatus().equals("1") ? "true" : "false"); + if(ObjectUtils.isNotEmpty(record.getActiveTime()) && "1".equals(record.getActiveTime())){ + record.setActivityProgress("1"); + } + //活动进度状态 + if (ObjectUtils.isNotEmpty(record.getStartTime()) && + ObjectUtils.isNotEmpty(record.getEndTime()) && + record.getActiveTime().equals("2")){ + record.setActivityProgress(record.getStartTime().getTime() > new Date().getTime() ? "0" : ""); + if(ObjectUtils.isEmpty(record.getActivityProgress())){ + record.setActivityProgress(record.getEndTime().getTime() > new Date().getTime() ? "1" : "2"); + } + } + } + return page1; + } } 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 f30ebe18f..7246cda4c 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 @@ -370,6 +370,7 @@ public class CardFuelRecordServiceImpl implements CardFuelRecordService { * @return */ @Override + @Transactional public ReturnParameter addFuleCarRecords(CardFuelRecordDTO cardFuelRecordDTO) throws Exception { Double cardFavorableValue = 0.0; Map map = new HashMap<>(); @@ -399,7 +400,7 @@ public class CardFuelRecordServiceImpl implements CardFuelRecordService { //付款类型 cardFuleOrders.setPayType(cardFuelRecordDTO.getPayType()); //用户信息 - cardFuleOrders.setStoreId(ljUserVo.getStoreId()); + cardFuleOrders.setStoreId(cardFuelRecordDTO.getStoreId()); cardFuleOrders.setMtUserId(ljUserVo.getId()); cardFuleOrders.setName(ljUserVo.getName()); cardFuleOrders.setMobile(ljUserVo.getMobile()); @@ -426,7 +427,7 @@ public class CardFuelRecordServiceImpl implements CardFuelRecordService { //封装支付参数 receiveParameter.setOrderNo(orderNo); receiveParameter.setType("5"); - receiveParameter.setStoreId(nowAccountInfo.getStoreId()); + receiveParameter.setStoreId(cardFuelRecordDTO.getStoreId()); receiveParameter.setGoodsMoney(cardFuleOrders.getPayAmount()); receiveParameter.setPayType(cardFuleOrders.getPayType()); receiveParameter.setUserId(nowAccountInfo.getId()); @@ -457,7 +458,6 @@ public class CardFuelRecordServiceImpl implements CardFuelRecordService { */ @Transactional public void fuleRechargeFinallDeal(String orderNo) throws JsonProcessingException { - AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); UserBalance userBalance1 = new UserBalance(); CardFuelRecord cardFuelRecord = new CardFuelRecord(); OilBalanceChange oilBalanceChange = new OilBalanceChange(); @@ -469,7 +469,7 @@ public class CardFuelRecordServiceImpl implements CardFuelRecordService { cardFuleOrders.setPayTime(new Date()); cardFuleOrdersService.updateById(cardFuleOrders); //用户余额 - UserBalance userBalance = userBalanceService.selectUserBalance(cardFuleOrders.getMtUserId()); + UserBalance userBalance = userBalanceService.selectUserBalanceByStorId(cardFuleOrders.getMtUserId(),cardFuleOrders.getStoreId()); //用户 (新用户新建 老用户叠加) if (ObjectUtils.isNotEmpty(userBalance)){ //积分 @@ -477,45 +477,61 @@ public class CardFuelRecordServiceImpl implements CardFuelRecordService { userBalance.setPoints(userBalance.getPoints() + cardFuleOrders.getPoints()); } //屯油卡余油 - if (ObjectUtils.isNotEmpty(userBalance.getRefuelMoney()) && ObjectUtils.isNotEmpty(cardFuleOrders.getIncomeLitres()) + if (ObjectUtils.isNotEmpty(cardFuleOrders.getIncomeLitres()) && ObjectUtils.isNotEmpty(cardFuleOrders.getType()) && ObjectUtils.isNotEmpty(cardFuleOrders.getOilType())){ String refuelMoney = userBalance.getRefuelMoney(); - List jsonObjectList = JSONArray.parseArray(refuelMoney, JSONObject.class); - for (JSONObject jsonObject : jsonObjectList) { - if (cardFuleOrders.getOilType().equals(jsonObject.getString("oilType"))){ - double refuelMoney1 = jsonObject.getDouble("refuelMoney"); - refuelMoney1 = (cardFuleOrders.getIncomeLitres() + refuelMoney1); - jsonObject.put("refuelMoney", refuelMoney1).toString(); - - }else { + if (ObjectUtils.isNotEmpty(refuelMoney)){ + List jsonObjectList = JSONArray.parseArray(refuelMoney, JSONObject.class); + ArrayList oilTypeList= new ArrayList<>(); + for (JSONObject jsonObject : jsonObjectList) { + String oilType = jsonObject.getString("oilType"); + if (ObjectUtils.isNotEmpty(oilType)){ + oilTypeList.add(oilType); + } + } + //如果油品类型包括所加的油品,叠加,不包括,新增 + if (oilTypeList.contains(cardFuleOrders.getOilType())){ + for (JSONObject jsonObject : jsonObjectList) { + if (cardFuleOrders.getOilType().equals(jsonObject.getString("oilType"))){ + double incomeLitres = jsonObject.getDouble("incomeLitres"); + incomeLitres = (cardFuleOrders.getIncomeLitres() + incomeLitres); + jsonObject.put("incomeLitres", incomeLitres); + String userBnlancce = jsonObjectList.toString(); + userBalance.setRefuelMoney(userBnlancce); + break; + } + } + }else { JSONObject jsonObject1 = new JSONObject(); jsonObject1.put("type",cardFuleOrders.getType()); jsonObject1.put("oilType",cardFuleOrders.getOilType()); jsonObject1.put("incomeLitres",cardFuleOrders.getIncomeLitres()); jsonObjectList.add(jsonObject1); + String userBnlancce = jsonObjectList.toString(); + userBalance.setRefuelMoney(userBnlancce); } + } + }else { + ArrayList jsonObjects = new ArrayList<>(); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("type",cardFuleOrders.getType()); + jsonObject.put("oilType",cardFuleOrders.getOilType()); + jsonObject.put("incomeLitres",cardFuleOrders.getIncomeLitres()); + jsonObjects.add(jsonObject); + userBalance.setRefuelMoney(jsonObjects.toString()); } - String userBnlancce = jsonObjectList.toString(); - userBalance.setRefuelMoney(userBnlancce); - } userBalanceService.updateUserBalance(userBalance); }else { userBalance1.setMtUserId(cardFuleOrders.getMtUserId()); userBalance1.setStoreId(cardFuleOrders.getStoreId()); - userBalance1.setChainStoreId(nowAccountInfo.getChainStoreId()); //积分 if (ObjectUtils.isNotEmpty(cardFuleOrders.getPoints())){ userBalance1.setPoints(cardFuleOrders.getPoints()); } - //油量 - /*if (ObjectUtils.isNotEmpty(userBalance.getRefuelMoney()) && ObjectUtils.isNotEmpty(cardValueOrders.getAmount())){ - userBalance.setCardBalance(userBalance.getCardBalance() + cardValueOrders.getAmount()); - }*/ userBalanceService.save(userBalance1); } - //用户余额变化记录 + //用户余油变化记录 oilBalanceChange.setUserId(cardFuleOrders.getMtUserId()); - oilBalanceChange.setChainStoreId(nowAccountInfo.getChainStoreId()); oilBalanceChange.setStoreId(cardFuleOrders.getStoreId()); oilBalanceChange.setChangeType("1"); oilBalanceChange.setFromType("囤油卡充值"); @@ -541,7 +557,6 @@ public class CardFuelRecordServiceImpl implements CardFuelRecordService { cardFuelRecord.setPayStatus("paid"); cardFuelRecord.setStoreId(cardFuleOrders.getStoreId()); cardFuelRecord.setPaymentNo(cardFuleOrders.getOrderNo()); - cardFuelRecord.setChainStoreId(nowAccountInfo.getChainStoreId()); cardFuelRecord.setType(cardFuleOrders.getType()); cardFuelRecord.setOilType(cardFuleOrders.getOilType()); cardFuelRecordMapper.insert(cardFuelRecord); diff --git a/gasStation-uni/pagesHome/oilRecharge/oilRecharge.vue b/gasStation-uni/pagesHome/oilRecharge/oilRecharge.vue index 368752d8e..f61b3a27d 100644 --- a/gasStation-uni/pagesHome/oilRecharge/oilRecharge.vue +++ b/gasStation-uni/pagesHome/oilRecharge/oilRecharge.vue @@ -64,7 +64,7 @@ + :key="index" @click="fuleindex(index,item.rechargeBalance,item.points,item.id)"> 油品:{{item.type}} 油号:{{item.oilType}} @@ -93,7 +93,7 @@ - + 立即充值 @@ -154,6 +154,7 @@ storeId: '', staffId: '', carValueId: '', + cardFuleId: '', shows: false, money: '', message: '', @@ -194,9 +195,7 @@ actinput: 0, } }, - components: { - - }, + components: {}, onLoad(option) { this.storeId = uni.getStorageSync("storeId") this.actinput = option.id @@ -209,12 +208,67 @@ if (option.id == 1) { console.log("囤油"); this.getFuelCars(); - } this.getStaffList() }, methods: { + //囤油卡充值 + addFuleCarRecords() { + if (this.staffId == '') { + uni.showToast({ + title: "员工为必填项", + icon: Error + }) + return + } + console.log("2222222222", this.carValueId) + if (this.carValueId == '') { + uni.showToast({ + title: "囤油卡为必填项", + icon: Error + }) + return + } + + + request({ + url: 'business/marketingActivity/cardFuelRecord/addFuleCarRecords', + method: 'post', + data: { + payType: 'WECHAT', + mtStaffId: this.staffId, + id: this.carValueId, + storeId: this.storeId, + cardFavorableId: this.cardFavorableId, + cardRecordId: this.cardRecordId + }, + }).then(res => { + if (res.code === 200) { + let _this = this + console.log(res) + let payProvider = "wxpay" + _this.orderInfo = JSON.parse(res.data.reservedPayInfo); + uni.requestPayment({ + // 微信支付provider: 'wxpay' 支付宝支付 'alipay' + provider: payProvider, + timeStamp: _this.orderInfo.timeStamp, + nonceStr: _this.orderInfo.nonceStr, + package: _this.orderInfo.package, + signType: 'MD5', + paySign: _this.orderInfo.paySign, + success: function(res) { + console.log('success:', res); + uni.reLaunch({ + url: '/pagesRefuel/orderSuccess/index' + }) + }, + fail: function(err) {} + }); + } + + }) + }, //储值卡充值 addValueCarRecords() { if (this.staffId == '') { @@ -321,8 +375,10 @@ } this.actindex = index }, - fuleindex(index, text, points, ) { - this.shuomingFList = [] + fuleindex(index, text, points, id) { + this.shuomingFList = []; + this.carValueId = id; + console.log("1111111111", this.carValueId) console.log(this.shuomingFList); if (text) { this.text = text @@ -368,17 +424,18 @@ //囤油卡 getFuelCars() { request({ - url: 'business/marketingActivity/cardFuelDiesel', + url: 'business/marketingActivity/cardFuelDiesel/selectAllApplet', method: 'get', data: { - activeStatus: '1' + activeStatus: '1', + storeId: this.storeId, }, }).then(res => { this.cardValueList = [] if (res.code == 200) { this.cardFuleList = res.data.records - - this.fuleindex(0, res.data.records[0].rechargeBalance, res.data.records[0].points) + this.fuleindex(0, res.data.records[0].rechargeBalance, res.data.records[0].points, res.data + .records[0].id) } }) },