From f2a65be97fa0537bfd3d3f7f5b0ca7bdbb7182ca Mon Sep 17 00:00:00 2001 From: wangh <9483> Date: Mon, 13 Nov 2023 18:58:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=98=E6=B2=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fuintAdmin/src/api/EventMarketing/cardSet.js | 9 + fuintAdmin/src/views/member/userInfo.vue | 25 +- .../fuyou/service/impl/FyPayServiceImpl.java | 30 +- .../integral/entity/IntegralDetail.java | 19 +- .../mapper/xml/IntegralDetailMapper.xml | 10 +- .../controller/CardFuelChangeController.java | 93 +++++ .../controller/CardFuelRecordController.java | 93 +++++ .../cardFule/entity/CardFuelChange.java | 89 +++++ .../cardFule/entity/CardFuelRecord.java | 149 ++++++++ .../cardFule/mapper/CardFuelChangeMapper.java | 85 +++++ .../cardFule/mapper/CardFuelRecordMapper.java | 85 +++++ .../mapper/xml/CardFuelChangeMapper.xml | 220 +++++++++++ .../mapper/xml/CardFuelRecordMapper.xml | 352 ++++++++++++++++++ .../service/CardFuelChangeService.java | 58 +++ .../service/CardFuelRecordService.java | 58 +++ .../impl/CardFuelChangeServiceImpl.java | 89 +++++ .../impl/CardFuelRecordServiceImpl.java | 89 +++++ .../controller/CardValueRecordController.java | 23 +- .../cardValue/dto/CardValueRecordDTO.java | 29 +- .../cardValue/entity/CardValueRecord.java | 43 +++ .../mapper/CardValueRecordMapper.java | 1 + .../service/CardValueRecordService.java | 15 +- .../impl/CardValueRecordServiceImpl.java | 211 +++++++++++ .../userManager/mapper/LJUserMapper.java | 5 + .../userManager/mapper/xml/LJUserMapper.xml | 11 + 25 files changed, 1855 insertions(+), 36 deletions(-) create mode 100644 fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/controller/CardFuelChangeController.java create mode 100644 fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/controller/CardFuelRecordController.java create mode 100644 fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/entity/CardFuelChange.java create mode 100644 fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/entity/CardFuelRecord.java create mode 100644 fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/mapper/CardFuelChangeMapper.java create mode 100644 fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/mapper/CardFuelRecordMapper.java create mode 100644 fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/mapper/xml/CardFuelChangeMapper.xml create mode 100644 fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/mapper/xml/CardFuelRecordMapper.xml create mode 100644 fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/service/CardFuelChangeService.java create mode 100644 fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/service/CardFuelRecordService.java create mode 100644 fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/service/impl/CardFuelChangeServiceImpl.java create mode 100644 fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/service/impl/CardFuelRecordServiceImpl.java diff --git a/fuintAdmin/src/api/EventMarketing/cardSet.js b/fuintAdmin/src/api/EventMarketing/cardSet.js index cc8c072c3..4333cd375 100644 --- a/fuintAdmin/src/api/EventMarketing/cardSet.js +++ b/fuintAdmin/src/api/EventMarketing/cardSet.js @@ -25,4 +25,13 @@ export function getPrepaidCardTopUpApi(query) { method: 'post', data: query }) +} + +// 余额插入订单 +export function getCheckTheStatusOfYourPaymentApi(query) { + return request({ + url: 'business/marketingActivity/cardValueRecord/checkTheStatusOfYourPayment?id='+query, + method: 'post', + data: query + }) } \ No newline at end of file diff --git a/fuintAdmin/src/views/member/userInfo.vue b/fuintAdmin/src/views/member/userInfo.vue index c759ec833..22e606174 100644 --- a/fuintAdmin/src/views/member/userInfo.vue +++ b/fuintAdmin/src/views/member/userInfo.vue @@ -863,6 +863,8 @@ export default { authCode:'', // 支付码 + timer: null, + rechargeBalance:0, @@ -1171,30 +1173,29 @@ export default { async collection(){ if (this.flag === 1) { - - - /** - * 插入订单表,返回订单信息id 并调用支付接口 - * - * - * - * 查询支付是否完成(支付完成则修改) - * - */ - - // 余额信息 // 会员id 会员名字会员手机号码 this.cardValueForm.mtUserId = userForm.id this.cardValueForm.name = userForm.name this.cardValueForm.mobile = userForm.mobile // 支付码 this.cardValueForm.authCode = this.authCode + + let id ; await getPrepaidCardTopUpApi(this.cardValueForm).then(res=> { console.log("返回数据",res) }); + this.timer = setInterval(async () => { + await getCheckTheStatusOfYourPaymentApi(id).then(res => { + console.log("ddd", res) + }) + }, 500); + + + }else if (this.flag === 2){ + } console.log("88888888888888888888",this.flag) diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/impl/FyPayServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/impl/FyPayServiceImpl.java index 9b8a03a3a..1d635e436 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/impl/FyPayServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/impl/FyPayServiceImpl.java @@ -10,16 +10,19 @@ import com.fuint.api.fuyou.entity.Message; import com.fuint.api.fuyou.service.FyPayService; import com.fuint.api.fuyou.service.MerchantConfigService; import com.fuint.api.fuyou.util.Utils; +import com.fuint.business.marketingActivity.cardValue.service.CardValueRecordService; import com.fuint.business.order.entity.CashierOrder; import com.fuint.business.order.entity.LJOrder; import com.fuint.business.order.entity.OilOrder; import com.fuint.business.order.service.CashierOrderService; import com.fuint.business.order.service.LJOrderService; import com.fuint.business.order.service.OilOrderService; +import io.swagger.models.auth.In; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import javax.annotation.Resource; import java.util.*; @Service @@ -31,7 +34,8 @@ public class FyPayServiceImpl implements FyPayService { private OilOrderService oilOrderService; @Autowired private CashierOrderService cashierOrderService; - + @Resource + private CardValueRecordService cardValueRecordService; /** * 条码支付 * @param map1 @@ -110,6 +114,13 @@ public class FyPayServiceImpl implements FyPayService { map.put("ins_cd", insCd); map.put("mchnt_cd", mchntCd); + // 余额新增 + String type = ""; + String payStates=""; + if (!ObjectUtil.isEmpty(map1.get("type"))) { + type = map1.get("type"); + } + // 请求报文 String reqBody = Message.requestMsg(map); // 响应报文 @@ -143,6 +154,12 @@ public class FyPayServiceImpl implements FyPayService { oilOrderService.updateOilOrder(order); } } + if ("CRV".equals(type)) { + payStates = "paid"; + if (!ObjectUtil.isEmpty(map1.get("orderId"))) { + + } + } // 修改商户账号余额信息 Double amount = merchantConfig.getAmount(); merchantConfig.setAmount(amount+allAmount); @@ -166,6 +183,12 @@ public class FyPayServiceImpl implements FyPayService { oilOrderService.updateOilOrder(order); } } + if ("CRV".equals(type)) { + payStates = "payFail"; + if (!ObjectUtil.isEmpty(map1.get("orderId"))) { + + } + } } if (!ObjectUtil.isEmpty(oilOrder)){ oilOrderService.updateOilOrder(oilOrder); @@ -176,6 +199,11 @@ public class FyPayServiceImpl implements FyPayService { if (!ObjectUtil.isEmpty(cashierOrder)){ cashierOrderService.updateCashierOrder(cashierOrder); } + if ("CRV".equals(type) && !ObjectUtil.isEmpty(map1.get("orderId"))) { + payStates = "payFail"; + Integer id = Integer.parseInt(map1.get("orderId")); + cardValueRecordService.editPayStatus(id, payStates); + } } }catch (Exception e){ log.error(e.getMessage()); diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/integral/entity/IntegralDetail.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/integral/entity/IntegralDetail.java index 94dd8dc45..ff62a8b78 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/integral/entity/IntegralDetail.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/integral/entity/IntegralDetail.java @@ -37,27 +37,12 @@ public class IntegralDetail extends BaseEntity { * 积分变动的原因,用于记录变动的具体原因或业务场景 */ private String changeReason; + + private String changeType; /** * 店铺ID */ private Integer storeId; - /** - * 创建时间 - */ - private Date createTime; - /** - * 更新时间 - */ - private Date updateTime; - /** - * 创建人 - */ - private String createBy; - /** - * 更新人 - */ - private String updateBy; - diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/integral/mapper/xml/IntegralDetailMapper.xml b/fuintBackend/fuint-application/src/main/java/com/fuint/business/integral/mapper/xml/IntegralDetailMapper.xml index 5c7ebbc8c..a4e6e71ed 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/integral/mapper/xml/IntegralDetailMapper.xml +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/integral/mapper/xml/IntegralDetailMapper.xml @@ -14,6 +14,7 @@ + @@ -27,7 +28,7 @@ + select + id, user_id, chain_store_id, store_id, change_type, from_type, balance, create_time, create_by, update_time, update_by, type, oil_type, unit + from card_fuel_change + where id = #{id} + + + + + + + + + + + insert into card_fuel_change(user_id, chain_store_id, store_id, change_type, from_type, balance, create_time, create_by, update_time, update_by, type, oil_type, unit) + values (#{userId}, #{chainStoreId}, #{storeId}, #{changeType}, #{fromType}, #{balance}, #{createTime}, #{createBy}, #{updateTime}, #{updateBy}, #{type}, #{oilType}, #{unit}) + + + + insert into card_fuel_change(user_id, chain_store_id, store_id, change_type, from_type, balance, create_time, create_by, update_time, update_by, type, oil_type, unit) + values + + (#{entity.userId}, #{entity.chainStoreId}, #{entity.storeId}, #{entity.changeType}, #{entity.fromType}, #{entity.balance}, #{entity.createTime}, #{entity.createBy}, #{entity.updateTime}, #{entity.updateBy}, #{entity.type}, #{entity.oilType}, #{entity.unit}) + + + + + insert into card_fuel_change(user_id, chain_store_id, store_id, change_type, from_type, balance, create_time, create_by, update_time, update_by, type, oil_type, unit) + values + + (#{entity.userId}, #{entity.chainStoreId}, #{entity.storeId}, #{entity.changeType}, #{entity.fromType}, #{entity.balance}, #{entity.createTime}, #{entity.createBy}, #{entity.updateTime}, #{entity.updateBy}, #{entity.type}, #{entity.oilType}, #{entity.unit}) + + on duplicate key update + user_id = values(user_id), + chain_store_id = values(chain_store_id), + store_id = values(store_id), + change_type = values(change_type), + from_type = values(from_type), + balance = values(balance), + create_time = values(create_time), + create_by = values(create_by), + update_time = values(update_time), + update_by = values(update_by), + type = values(type), + oil_type = values(oil_type), + unit = values(unit) + + + + + update card_fuel_change + + + user_id = #{userId}, + + + chain_store_id = #{chainStoreId}, + + + store_id = #{storeId}, + + + change_type = #{changeType}, + + + from_type = #{fromType}, + + + balance = #{balance}, + + + create_time = #{createTime}, + + + create_by = #{createBy}, + + + update_time = #{updateTime}, + + + update_by = #{updateBy}, + + + type = #{type}, + + + oil_type = #{oilType}, + + + unit = #{unit}, + + + where id = #{id} + + + + + delete from card_fuel_change where id = #{id} + + + + 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 new file mode 100644 index 000000000..8ce4083ae --- /dev/null +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/mapper/xml/CardFuelRecordMapper.xml @@ -0,0 +1,352 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + insert into card_fuel_record(mt_user_id, name, mobile, mt_staff_id, real_name, staff_mobile, card_fuel_id, recharge_balance, income_litres, 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) + values (#{mtUserId}, #{name}, #{mobile}, #{mtStaffId}, #{realName}, #{staffMobile}, #{cardFuelId}, #{rechargeBalance}, #{incomeLitres}, #{paymentType}, #{remark}, #{points}, #{growthValue}, #{royaltyType}, #{percentageCommissions}, #{amountCommission}, #{createBy}, #{createTime}, #{updateBy}, #{updateTime}, #{payStatus}, #{storeId}, #{paymentNo}, #{type}, #{oilType}) + + + + insert into card_fuel_record(mt_user_id, name, mobile, mt_staff_id, real_name, staff_mobile, card_fuel_id, recharge_balance, income_litres, 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) + values + + (#{entity.mtUserId}, #{entity.name}, #{entity.mobile}, #{entity.mtStaffId}, #{entity.realName}, #{entity.staffMobile}, #{entity.cardFuelId}, #{entity.rechargeBalance}, #{entity.incomeLitres}, #{entity.paymentType}, #{entity.remark}, #{entity.points}, #{entity.growthValue}, #{entity.royaltyType}, #{entity.percentageCommissions}, #{entity.amountCommission}, #{entity.createBy}, #{entity.createTime}, #{entity.updateBy}, #{entity.updateTime}, #{entity.payStatus}, #{entity.storeId}, #{entity.paymentNo}, #{entity.type}, #{entity.oilType}) + + + + + insert into card_fuel_record(mt_user_id, name, mobile, mt_staff_id, real_name, staff_mobile, card_fuel_id, recharge_balance, income_litres, 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) + values + + (#{entity.mtUserId}, #{entity.name}, #{entity.mobile}, #{entity.mtStaffId}, #{entity.realName}, #{entity.staffMobile}, #{entity.cardFuelId}, #{entity.rechargeBalance}, #{entity.incomeLitres}, #{entity.paymentType}, #{entity.remark}, #{entity.points}, #{entity.growthValue}, #{entity.royaltyType}, #{entity.percentageCommissions}, #{entity.amountCommission}, #{entity.createBy}, #{entity.createTime}, #{entity.updateBy}, #{entity.updateTime}, #{entity.payStatus}, #{entity.storeId}, #{entity.paymentNo}, #{entity.type}, #{entity.oilType}) + + on duplicate key update + mt_user_id = values(mt_user_id), + name = values(name), + mobile = values(mobile), + mt_staff_id = values(mt_staff_id), + real_name = values(real_name), + staff_mobile = values(staff_mobile), + card_fuel_id = values(card_fuel_id), + recharge_balance = values(recharge_balance), + income_litres = values(income_litres), + payment_type = values(payment_type), + remark = values(remark), + points = values(points), + growth_value = values(growth_value), + royalty_type = values(royalty_type), + percentage_commissions = values(percentage_commissions), + amount_commission = values(amount_commission), + create_by = values(create_by), + create_time = values(create_time), + update_by = values(update_by), + update_time = values(update_time), + pay_status = values(pay_status), + store_id = values(store_id), + payment_no = values(payment_no), + type = values(type), + oil_type = values(oil_type) + + + + + update card_fuel_record + + + mt_user_id = #{mtUserId}, + + + name = #{name}, + + + mobile = #{mobile}, + + + mt_staff_id = #{mtStaffId}, + + + real_name = #{realName}, + + + staff_mobile = #{staffMobile}, + + + card_fuel_id = #{cardFuelId}, + + + recharge_balance = #{rechargeBalance}, + + + income_litres = #{incomeLitres}, + + + payment_type = #{paymentType}, + + + remark = #{remark}, + + + points = #{points}, + + + growth_value = #{growthValue}, + + + royalty_type = #{royaltyType}, + + + percentage_commissions = #{percentageCommissions}, + + + amount_commission = #{amountCommission}, + + + create_by = #{createBy}, + + + create_time = #{createTime}, + + + update_by = #{updateBy}, + + + update_time = #{updateTime}, + + + pay_status = #{payStatus}, + + + store_id = #{storeId}, + + + payment_no = #{paymentNo}, + + + type = #{type}, + + + oil_type = #{oilType}, + + + where id = #{id} + + + + + delete from card_fuel_record where id = #{id} + + + + diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/service/CardFuelChangeService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/service/CardFuelChangeService.java new file mode 100644 index 000000000..299764613 --- /dev/null +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/service/CardFuelChangeService.java @@ -0,0 +1,58 @@ +package com.fuint.business.marketingActivity.cardFule.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.fuint.business.marketingActivity.cardFule.entity.CardFuelChange; +import io.lettuce.core.dynamic.annotation.Param; + + +/** + * 燃油变化记录表(CardFuelChange)表服务接口 + * + * @author wangh + * @since 2023-11-13 18:53:47 + */ +public interface CardFuelChangeService { + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + CardFuelChange queryById(Integer id); + + /** + * 分页查询 + * + * @param cardFuelChange 筛选条件 + * @param page 分页对象 + * @return 查询结果 + */ + IPage queryByPage(@Param("page") Page page, CardFuelChange cardFuelChange); + + /** + * 新增数据 + * + * @param cardFuelChange 实例对象 + * @return 实例对象 + */ + CardFuelChange insert(CardFuelChange cardFuelChange); + + /** + * 修改数据 + * + * @param cardFuelChange 实例对象 + * @return 实例对象 + */ + CardFuelChange update(CardFuelChange cardFuelChange); + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 是否成功 + */ + boolean deleteById(Integer id); + +} 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 new file mode 100644 index 000000000..375cc001f --- /dev/null +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/service/CardFuelRecordService.java @@ -0,0 +1,58 @@ +package com.fuint.business.marketingActivity.cardFule.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.fuint.business.marketingActivity.cardFule.entity.CardFuelRecord; +import io.lettuce.core.dynamic.annotation.Param; + + +/** + * 燃油充值表(CardFuelRecord)表服务接口 + * + * @author wangh + * @since 2023-11-13 18:53:47 + */ +public interface CardFuelRecordService { + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + CardFuelRecord queryById(Integer id); + + /** + * 分页查询 + * + * @param cardFuelRecord 筛选条件 + * @param page 分页对象 + * @return 查询结果 + */ + IPage queryByPage(@Param("page") Page page, CardFuelRecord cardFuelRecord); + + /** + * 新增数据 + * + * @param cardFuelRecord 实例对象 + * @return 实例对象 + */ + CardFuelRecord insert(CardFuelRecord cardFuelRecord); + + /** + * 修改数据 + * + * @param cardFuelRecord 实例对象 + * @return 实例对象 + */ + CardFuelRecord update(CardFuelRecord cardFuelRecord); + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 是否成功 + */ + boolean deleteById(Integer id); + +} diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/service/impl/CardFuelChangeServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/service/impl/CardFuelChangeServiceImpl.java new file mode 100644 index 000000000..bc3d9b562 --- /dev/null +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/service/impl/CardFuelChangeServiceImpl.java @@ -0,0 +1,89 @@ +package com.fuint.business.marketingActivity.cardFule.service.impl; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.fuint.business.marketingActivity.cardFule.entity.CardFuelChange; +import com.fuint.business.marketingActivity.cardFule.mapper.CardFuelChangeMapper; +import com.fuint.business.marketingActivity.cardFule.service.CardFuelChangeService; +import org.springframework.stereotype.Service; +import com.fuint.common.util.TokenUtil; +import io.lettuce.core.dynamic.annotation.Param; +import com.fuint.common.dto.AccountInfo; + + + +import javax.annotation.Resource; + +/** + * 燃油变化记录表(CardFuelChange)表服务实现类 + * + * @author wangh + * @since 2023-11-13 18:53:47 + */ +@Service("cardFuelChangeService") +public class CardFuelChangeServiceImpl implements CardFuelChangeService { + @Resource + private CardFuelChangeMapper cardFuelChangeMapper; + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + @Override + public CardFuelChange queryById(Integer id) { + return this.cardFuelChangeMapper.queryById(id); + } + + /** + * 分页查询 + * + * @param cardFuelChange 筛选条件 + * @param page 分页对象 + * @return 查询结果 + */ + @Override + public IPage queryByPage(@Param("page") Page page, CardFuelChange cardFuelChange) { + AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); + cardFuelChange.setStoreId(nowAccountInfo.getStoreId()); + return this.cardFuelChangeMapper.queryAllByLimit(page, cardFuelChange); + } + + /** + * 新增数据 + * + * @param cardFuelChange 实例对象 + * @return 实例对象 + */ + @Override + public CardFuelChange insert(CardFuelChange cardFuelChange) { + AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); + cardFuelChange.setStoreId(nowAccountInfo.getStoreId()); + this.cardFuelChangeMapper.insert(cardFuelChange); + return cardFuelChange; + } + + /** + * 修改数据 + * + * @param cardFuelChange 实例对象 + * @return 实例对象 + */ + @Override + public CardFuelChange update(CardFuelChange cardFuelChange) { + this.cardFuelChangeMapper.update(cardFuelChange); + return this.queryById(cardFuelChange.getId()); + } + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 是否成功 + */ + @Override + public boolean deleteById(Integer id) { + return this.cardFuelChangeMapper.deleteById(id) > 0; + } +} 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 new file mode 100644 index 000000000..fd347c890 --- /dev/null +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardFule/service/impl/CardFuelRecordServiceImpl.java @@ -0,0 +1,89 @@ +package com.fuint.business.marketingActivity.cardFule.service.impl; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.fuint.business.marketingActivity.cardFule.entity.CardFuelRecord; +import com.fuint.business.marketingActivity.cardFule.mapper.CardFuelRecordMapper; +import com.fuint.business.marketingActivity.cardFule.service.CardFuelRecordService; +import org.springframework.stereotype.Service; +import com.fuint.common.util.TokenUtil; +import io.lettuce.core.dynamic.annotation.Param; +import com.fuint.common.dto.AccountInfo; + + + +import javax.annotation.Resource; + +/** + * 燃油充值表(CardFuelRecord)表服务实现类 + * + * @author wangh + * @since 2023-11-13 18:53:47 + */ +@Service("cardFuelRecordService") +public class CardFuelRecordServiceImpl implements CardFuelRecordService { + @Resource + private CardFuelRecordMapper cardFuelRecordMapper; + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + @Override + public CardFuelRecord queryById(Integer id) { + return this.cardFuelRecordMapper.queryById(id); + } + + /** + * 分页查询 + * + * @param cardFuelRecord 筛选条件 + * @param page 分页对象 + * @return 查询结果 + */ + @Override + public IPage queryByPage(@Param("page") Page page, CardFuelRecord cardFuelRecord) { + AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); + cardFuelRecord.setStoreId(nowAccountInfo.getStoreId()); + return this.cardFuelRecordMapper.queryAllByLimit(page, cardFuelRecord); + } + + /** + * 新增数据 + * + * @param cardFuelRecord 实例对象 + * @return 实例对象 + */ + @Override + public CardFuelRecord insert(CardFuelRecord cardFuelRecord) { + AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); + cardFuelRecord.setStoreId(nowAccountInfo.getStoreId()); + this.cardFuelRecordMapper.insert(cardFuelRecord); + return cardFuelRecord; + } + + /** + * 修改数据 + * + * @param cardFuelRecord 实例对象 + * @return 实例对象 + */ + @Override + public CardFuelRecord update(CardFuelRecord cardFuelRecord) { + this.cardFuelRecordMapper.update(cardFuelRecord); + return this.queryById(cardFuelRecord.getId()); + } + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 是否成功 + */ + @Override + public boolean deleteById(Integer id) { + return this.cardFuelRecordMapper.deleteById(id) > 0; + } +} diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardValue/controller/CardValueRecordController.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardValue/controller/CardValueRecordController.java index 60fcf8310..ae63debbc 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardValue/controller/CardValueRecordController.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardValue/controller/CardValueRecordController.java @@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.api.ApiController; import com.baomidou.mybatisplus.extension.api.R; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.fuint.business.marketingActivity.cardValue.dto.CardValueRecordDTO; import com.fuint.business.marketingActivity.cardValue.entity.CardValue; import com.fuint.business.marketingActivity.cardValue.entity.CardValueRecord; import com.fuint.business.marketingActivity.cardValue.service.CardValueRecordService; @@ -25,7 +26,7 @@ import java.util.List; * @since 2023-10-31 11:30:09 */ @RestController -@RequestMapping("cardValueRecord") +@RequestMapping("business/marketingActivity/cardValueRecord") public class CardValueRecordController extends BaseController { /** * 服务对象 @@ -91,5 +92,25 @@ public class CardValueRecordController extends BaseController { public ResponseObject delete(@RequestParam("idList") List idList) { return getSuccessResult(this.cardValueRecordService.removeByIds(idList)); } + + /** + * 余额充值 + * @param cardValueRecordDTO + * @return + */ + @PostMapping("prepaidCardTopUp") + public ResponseObject prepaidCardTopUp(@RequestBody CardValueRecordDTO cardValueRecordDTO) { + return getSuccessResult(this.cardValueRecordService.prepaidCardTopUp(cardValueRecordDTO)); + } + + /** + * 查询支付状态 修改相关关联表 + * @param id + * @return + */ + @GetMapping("checkTheStatusOfYourPayment") + public ResponseObject checkTheStatusOfYourPayment(Integer id) { + return getSuccessResult(this.cardValueRecordService.checkTheStatusOfYourPayment(id)); + } } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardValue/dto/CardValueRecordDTO.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardValue/dto/CardValueRecordDTO.java index 120d73719..6b767f486 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardValue/dto/CardValueRecordDTO.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardValue/dto/CardValueRecordDTO.java @@ -1,2 +1,29 @@ -package com.fuint.business.marketingActivity.cardValue.dto;public class CardValueRecordDTO { +package com.fuint.business.marketingActivity.cardValue.dto; + +import com.fuint.business.marketingActivity.cardValue.entity.CardValueRecord; +import lombok.Data; + +/** + * + */ +@Data +public class CardValueRecordDTO extends CardValueRecord { + private String authCode; + +// /** +// * 会员id +// */ +// private Integer userId; +// /** +// * 员工id +// */ +// +// /** +// * 员工真实名称 +// */ +// private String realName; +// /** +// * 员工电话 +// */ +// private String staffMobile; } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardValue/entity/CardValueRecord.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardValue/entity/CardValueRecord.java index 630a190ad..1ba77d386 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardValue/entity/CardValueRecord.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardValue/entity/CardValueRecord.java @@ -20,6 +20,10 @@ public class CardValueRecord extends Model { //主键id @TableId(type = IdType.AUTO) private Integer id; + + + + private Integer storeId; //会员id private Integer mtUserId; //会员名字 @@ -70,6 +74,38 @@ public class CardValueRecord extends Model { private Date updateTime; + + // 支付状态 + private String payStatus; + // 支付方式 + private String paymentType; + // 支付编号 + private String paymentNo; + + public String getPaymentNo() { + return paymentNo; + } + + public void setPaymentNo(String paymentNo) { + this.paymentNo = paymentNo; + } + + public String getPaymentType() { + return paymentType; + } + + public void setPaymentType(String paymentType) { + this.paymentType = paymentType; + } + + public Integer getStoreId() { + return storeId; + } + + public void setStoreId(Integer storeId) { + this.storeId = storeId; + } + public Integer getId() { return id; } @@ -262,6 +298,13 @@ public class CardValueRecord extends Model { this.updateTime = updateTime; } + public String getPayStatus() { + return payStatus; + } + + public void setPayStatus(String payStatus) { + this.payStatus = payStatus; + } /** * 获取主键值 * diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardValue/mapper/CardValueRecordMapper.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardValue/mapper/CardValueRecordMapper.java index 0c84eb565..a5a19382f 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardValue/mapper/CardValueRecordMapper.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardValue/mapper/CardValueRecordMapper.java @@ -2,6 +2,7 @@ package com.fuint.business.marketingActivity.cardValue.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.fuint.business.marketingActivity.cardValue.entity.CardValueRecord; +import org.apache.ibatis.annotations.Param; /** * 储值充值表(CardValueRecord)表数据库访问层 diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardValue/service/CardValueRecordService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardValue/service/CardValueRecordService.java index b80d0ce59..21d9f7134 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardValue/service/CardValueRecordService.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardValue/service/CardValueRecordService.java @@ -1,6 +1,7 @@ package com.fuint.business.marketingActivity.cardValue.service; import com.baomidou.mybatisplus.extension.service.IService; +import com.fuint.business.marketingActivity.cardValue.dto.CardValueRecordDTO; import com.fuint.business.marketingActivity.cardValue.entity.CardValueRecord; import com.fuint.business.petrolStationManagement.entity.OilGun; @@ -14,10 +15,22 @@ public interface CardValueRecordService extends IService { /** * 储值卡充值(新增) + * * @param cardValueRecord * @return */ boolean insert(CardValueRecord cardValueRecord); -} + /** + * 余额充值 + * + * @param cardValueRecordDTO + * @return + */ + CardValueRecordDTO prepaidCardTopUp(CardValueRecordDTO cardValueRecordDTO); + + CardValueRecord checkTheStatusOfYourPayment(Integer id); + + boolean editPayStatus(Integer id, String payStatus); +} diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardValue/service/impl/CardValueRecordServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardValue/service/impl/CardValueRecordServiceImpl.java index 0c4e6d346..5fc73540b 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardValue/service/impl/CardValueRecordServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardValue/service/impl/CardValueRecordServiceImpl.java @@ -1,11 +1,36 @@ package com.fuint.business.marketingActivity.cardValue.service.impl; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuint.api.fuyou.entity.MerchantConfig; +import com.fuint.api.fuyou.service.FyPayService; +import com.fuint.api.fuyou.service.MerchantConfigService; +import com.fuint.business.integral.entity.IntegralDetail; +import com.fuint.business.integral.service.IntegralDetailService; +import com.fuint.business.marketingActivity.cardValue.dto.CardValueRecordDTO; import com.fuint.business.marketingActivity.cardValue.mapper.CardValueRecordMapper; import com.fuint.business.marketingActivity.cardValue.entity.CardValueRecord; import com.fuint.business.marketingActivity.cardValue.service.CardValueRecordService; +import com.fuint.business.order.entity.CardBalanceChange; +import com.fuint.business.order.service.CardBalanceChangeService; +import com.fuint.business.userManager.entity.LJUser; +import com.fuint.business.userManager.entity.UserBalance; +import com.fuint.business.userManager.mapper.LJUserMapper; +import com.fuint.business.userManager.service.LJUserService; +import com.fuint.business.userManager.service.UserBalanceService; +import com.fuint.business.userManager.vo.LJUserVo; +import com.fuint.common.dto.AccountInfo; +import com.fuint.common.util.TokenUtil; +import org.apache.ibatis.annotations.Param; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.util.*; + /** * 储值充值表(CardValueRecord)表服务实现类 * @@ -15,6 +40,23 @@ import org.springframework.stereotype.Service; @Service("cardValueRecordService") public class CardValueRecordServiceImpl extends ServiceImpl implements CardValueRecordService { + @Resource + private LJUserMapper ljUserMapper; + + @Resource + private UserBalanceService userBalanceService; + + @Autowired + private MerchantConfigService merchantConfigService; + + @Autowired + private FyPayService fyPayService; + + @Resource + CardBalanceChangeService cardBalanceChangeService; + @Resource + IntegralDetailService integralDetailService; + /** * 储值卡充值(新增) * @param cardValueRecord @@ -24,5 +66,174 @@ public class CardValueRecordServiceImpl extends ServiceImpl epsilon + && "unpaid".equals(cardValueRecordDTO.getPayStatus())){ + theAmountToBePaid = cardValueRecordDTO.getAmount(); + flag = true; + } else if(!ObjectUtil.isEmpty(cardValueRecordDTO.getRechargeBalance()) + && cardValueRecordDTO.getRechargeBalance() > epsilon + && "unpaid".equals(cardValueRecordDTO.getPayStatus())) { + theAmountToBePaid = cardValueRecordDTO.getRechargeBalance(); + flag = true; + } + if (flag) { + Integer allAmount = (int) (theAmountToBePaid*100); + + MerchantConfig merchantConfig = merchantConfigService.selectMeChByIsUse("1"); + // 处理支付需要的数据 + Map map = new HashMap<>(); + map.put("authCode",cardValueRecordDTO.getAuthCode()); + map.put("allAmount",allAmount.toString()); + map.put("orderNo",orderNo); + map.put("payType",cardValueRecordDTO.getPaymentType()); + map.put("insCd",merchantConfig.getInsCd()); + map.put("mchntCd",merchantConfig.getMchntCd()); + map.put("goodsDes",merchantConfig.getMerchantName()); + map.put("publicKey",merchantConfig.getPublicKey()); + map.put("privateKey",merchantConfig.getPrivateKey()); + map.put("type","CVR"); + map.put("orderId",cardValueRecordDTO.getId().toString()); + + // 调用支付接口 + try { + fyPayService.pay(map); + } catch (Exception e){ + e.printStackTrace(); + } + } + // 支付 payment_type + return cardValueRecordDTO; + } + + /** + * 查询支付状态 修改相关关联表 + * @param id + * @return + */ + @Override + public CardValueRecord checkTheStatusOfYourPayment(Integer id) { + CardValueRecord cardValueRecord = baseMapper.selectById(id); + if (!"paid".equals(cardValueRecord.getPayStatus())) { + return cardValueRecord; + } else{ + // 查询用户信息 + LJUserVo ljUserVos = ljUserMapper.selectAllInfoById(cardValueRecord.getMtUserId()); + + // 修改用户的余额信息 + UserBalance userBalance = balanceCalculation(cardValueRecord); + userBalanceService.updateUserBalance(userBalance); + + // 添加余额充值纪录表 + CardBalanceChange cardBalanceChange = addCardBalance(cardValueRecord); + cardBalanceChangeService.insertCardBalance(cardBalanceChange); + double epsilon = 1e-10; // 阈值 + // 插入 余额赠送 + if (cardValueRecord.getGiftBalance()>epsilon) { + cardBalanceChange.setFromType("余额充值赠送"); + cardBalanceChange.setBalance(cardValueRecord.getGiftBalance()); + cardBalanceChangeService.insertCardBalance(cardBalanceChange); + } + // 积分表变动 + if (!ObjectUtil.isEmpty(cardValueRecord.getPoints()) && cardValueRecord.getPoints() != 0) { + IntegralDetail integralDetail = changesInPoints(cardValueRecord,ljUserVos); + integralDetailService.insert(integralDetail); + } + // 成长值变动明细 + } + + + return cardValueRecord; + } + //添加余额明细表 + private CardBalanceChange addCardBalance(CardValueRecord cardValueRecord) { + CardBalanceChange cardBalanceChange = new CardBalanceChange(); + cardBalanceChange.setUserId(cardValueRecord.getMtUserId()); + cardBalanceChange.setChangeType("1"); + cardBalanceChange.setFromType("余额充值"); + cardBalanceChange.setBalance(cardValueRecord.getRechargeBalance()); + + return cardBalanceChange; + } + //用户余额表计算 + private UserBalance balanceCalculation(CardValueRecord cardValueRecordDTO) { + LJUserVo ljUserVos = ljUserMapper.selectAllInfoById(cardValueRecordDTO.getMtUserId()); + + if (ObjectUtil.isEmpty(cardValueRecordDTO.getBidBalance())) cardValueRecordDTO.setBidBalance(0.00); + if (ObjectUtil.isEmpty(cardValueRecordDTO.getPoints())) cardValueRecordDTO.setPoints(0); + if (ObjectUtil.isEmpty(cardValueRecordDTO.getGrowthValue())) cardValueRecordDTO.setGrowthValue(0); + + // 计算之后修改对应余额 + BigDecimal bigBidBalance = new BigDecimal(cardValueRecordDTO.getBidBalance()); + BigDecimal addCardValance = bigBidBalance.add(new BigDecimal(ljUserVos.getCardBalance())); + + // 计算积分 + BigDecimal bigPoints = new BigDecimal(cardValueRecordDTO.getPoints()); + BigDecimal addPoints = bigPoints.add(new BigDecimal(ljUserVos.getPoints())); + + // 计算成长值 + BigDecimal bigGrowthValue = new BigDecimal(cardValueRecordDTO.getGrowthValue()); + BigDecimal addGrowthValue = bigGrowthValue.add(new BigDecimal(ljUserVos.getGrowthValue())); + + UserBalance userBalance = new UserBalance(); + userBalance.setId(ljUserVos.getBalanceId()); + userBalance.setCardBalance(addCardValance.doubleValue()); + userBalance.setPoints(addPoints.intValue()); + userBalance.setGrowthValue(addGrowthValue.intValue()); + + return userBalance; + } + // 积分变动 + private IntegralDetail changesInPoints(CardValueRecord cardValueRecordDTO,LJUserVo ljUserVos) { + IntegralDetail integralDetail = new IntegralDetail(); + integralDetail.setUserId(cardValueRecordDTO.getMtUserId()); + integralDetail.setPointsChange(cardValueRecordDTO.getPoints()); + + // 计算积分 + BigDecimal bigPoints = new BigDecimal(cardValueRecordDTO.getPoints()); + BigDecimal addPoints = bigPoints.add(new BigDecimal(ljUserVos.getPoints())); + + integralDetail.setCurrentPoints(addPoints.intValue()); + integralDetail.setChangeReason("余额充值赠送"); + return integralDetail; + } + + // 成长值变动 + + //支付 + public boolean editPayStatus(Integer id, String payStatus) { + CardValueRecord cardValueRecord = new CardValueRecord(); + cardValueRecord.setId(id); + cardValueRecord.setPayStatus(payStatus); + int i = baseMapper.updateById(cardValueRecord); + return i>0; + } } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/mapper/LJUserMapper.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/mapper/LJUserMapper.java index 9f1da86a3..3f9335b6e 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/mapper/LJUserMapper.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/mapper/LJUserMapper.java @@ -43,4 +43,9 @@ public interface LJUserMapper extends BaseMapper { */ public Double selectSumByStore(@Param("storeId") int storeId,@Param("sumValue") String sumValue); + + LJUserVo selectAllInfoById(@Param("userId") Integer userId); + + + } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/mapper/xml/LJUserMapper.xml b/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/mapper/xml/LJUserMapper.xml index 7bc2d2274..39109a25d 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/mapper/xml/LJUserMapper.xml +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/mapper/xml/LJUserMapper.xml @@ -58,4 +58,15 @@ mu.name like concat('%', #{name}, '%') + + \ No newline at end of file