This commit is contained in:
sw 2024-11-14 09:16:39 +08:00
parent 6907e0b430
commit 28d72ff386
10 changed files with 309 additions and 147 deletions

View File

@ -185,5 +185,9 @@ public class OilOrder extends BaseEntity implements Serializable {
private Long deptId;
@TableField(exist = false)
private List<Long> storeIds;
/**
* 储值卡赠送金额消费
*/
private Double balanceGiftAmount;
}

View File

@ -636,7 +636,7 @@ public class OilOrderServiceImpl extends ServiceImpl<OilOrderMapper, OilOrder> i
order.setBalanceAmount(Double.valueOf(balanceAmount));
order.setOilCardAmount(Double.valueOf(oilCardAmount));
order.setActiveAmount(activeAmount);
order.setBalanceGiftAmount( this.countCardBalance(Double.valueOf(balanceAmount), userId, storeId, orderNo));
order.setStoreId(storeId);
order.setUserId(userId);
order.setStaffId(staffId);
@ -1935,20 +1935,35 @@ public class OilOrderServiceImpl extends ServiceImpl<OilOrderMapper, OilOrder> i
LJStore store = storeService.selectStoreByStoreId(storeId);
UserBalance balance = userBalanceService.selectUserBalance(userId, store.getChainStoreId());
if (ObjectUtil.isNotEmpty(balance)) {
// 修改余额信息
Double beforeBalance = balance.getCardBalance();
Double afterBalance = beforeBalance - amount;
if ((beforeBalance - amount) < 0.0) {
//计算余额
//消费金额
BigDecimal num1 = new BigDecimal(amount.toString());
//总余额
BigDecimal num2 = new BigDecimal(balance.getCardBalance().toString());
//赠送余额
BigDecimal num3 = new BigDecimal(balance.getGiveAmount().toString());
//总本金
BigDecimal num4 = num2.subtract(num3);
//赠送余额比例金额
BigDecimal num5 =num3.divide(num4,2,BigDecimal.ROUND_DOWN).multiply(num1).setScale(2,BigDecimal.ROUND_DOWN);
//剩余赠送余额
BigDecimal num6 =num3.subtract(num5);
//修改余额信息
BigDecimal num7 =num2.subtract(num1);
if (num7.doubleValue() < 0.0) {
return false;
}
cardBalanceChange.setAfterTheChange(afterBalance);
balance.setCardBalance(afterBalance);
cardBalanceChange.setAfterTheChange(num7.doubleValue());
balance.setCardBalance(num7.doubleValue());
balance.setGiveAmount(num6.doubleValue());
// 修改加油次数
Integer consumeNum = balance.getConsumeNum();
balance.setConsumeNum(consumeNum + 1);
userBalanceService.updateUserBalance(balance);
}
// 添加余额记录信息
cardBalanceChange.setUserId(userId);
cardBalanceChange.setChangeType("0");
@ -1956,7 +1971,6 @@ public class OilOrderServiceImpl extends ServiceImpl<OilOrderMapper, OilOrder> i
cardBalanceChange.setBalance(amount);
cardBalanceChange.setOrderNo(orderNo);
cardBalanceChange.setStoreId(storeId);
cardBalanceChangeService.insertCardBalance(cardBalanceChange);
return true;
}
@ -2416,4 +2430,31 @@ public class OilOrderServiceImpl extends ServiceImpl<OilOrderMapper, OilOrder> i
}
return baseMapper.selectList(queryWrapper);
}
/**
* 计算储值赠送金额的话费
*
* @param amount
* @param userId
* @param storeId
*/
private Double countCardBalance(Double amount, Integer userId, Integer storeId, String orderNo) {
// 根据用户id查询用户余额信息
LJStore store = storeService.selectStoreByStoreId(storeId);
UserBalance balance = userBalanceService.selectUserBalance(userId, store.getChainStoreId());
//消费金额
BigDecimal num1 = new BigDecimal(amount.toString());
//总余额
BigDecimal num2 = new BigDecimal(balance.getCardBalance().toString());
//赠送余额
BigDecimal num3 = new BigDecimal(balance.getGiveAmount().toString());
//总本金
BigDecimal num4 = num2.subtract(num3);
//赠送余额比例金额
BigDecimal num5 = num3.divide(num4, 2, BigDecimal.ROUND_DOWN).multiply(num1).setScale(2, BigDecimal.ROUND_DOWN);
return num5.doubleValue();
}
}

View File

@ -0,0 +1,24 @@
package com.fuint.business.userManager.dto;
import lombok.Data;
import java.io.Serializable;
@Data
public class LJUserDto implements Serializable {
private static final long serialVersionUID = 1L;
//会员人数
private Integer userNum ;
// 注销会员人数
private Integer logOffUserNum ;
// 会员总积分
private Integer allPoints ;
// 消耗积分
private Integer consumePoints ;
// 会员累计充值
private Double accumulateRecharge ;
// 会员总余额
private Double allBalance ;
}

View File

@ -0,0 +1,40 @@
package com.fuint.business.userManager.dto;
import lombok.Data;
import java.io.Serializable;
@Data
public class LJUserStaticesDto implements Serializable {
private static final long serialVersionUID = 1L;
// 充值总额
private Double rechargeAmount;
// 充值本金
private Double rechargePrincipal;
// 充值赠送
private Double rechargeGive;
// 消费总额
private Double consumeAmount;
// 消费本金
private Double consumePrincipal ;
// 消费赠送
private Double consumeGive;
// 退款总额
private Double refundAmount;
// 退款本金
private Double refundPrincipal;
// 退款赠送
private Double refundGive0;
// 注销总额
private Double logOffAmount;
// 注销本金
private Double logOffPrincipal;
// 注销赠送
private Double logOffGive;
// 会员总余额
private Double userBalance;
// 剩余本金
private Double residuePrincipal;
// 剩余赠送
private Double residueGive;
}

View File

@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fuint.business.userGroup.entity.UserGroup;
import com.fuint.business.userManager.dto.LJUserDto;
import com.fuint.business.userManager.dto.LJUserStaticesDto;
import com.fuint.business.userManager.entity.LJUser;
import com.fuint.business.userManager.vo.LJUserVo;
import org.apache.ibatis.annotations.Param;
@ -112,4 +114,8 @@ public interface LJUserMapper extends BaseMapper<LJUser> {
Integer selectUserCountByChainStoreId(@Param("chainStoreId") Integer chainStoreId);
List<LJUserVo> findUserList(@Param("user") LJUserVo user);
LJUserDto queryUserMsg(@Param("storeId") Integer storeId);
LJUserStaticesDto selectAmountStatistics(@Param("storeId") Integer storeId);
}

View File

@ -310,7 +310,8 @@
mub.card_balance cardBalance,
mub.points,
mub.growth_value growthValue,
mub.refuel_money refuelMoney
mub.refuel_money refuelMoney,
mub.give_amount giveAmount
from mt_user mu
left join mt_user_balance mub on mu.id = mub.mt_user_id
where mu.id = #{userId}
@ -419,6 +420,33 @@
</where>
</select>
<select id="queryUserMsg" resultType="com.fuint.business.userManager.dto.LJUserDto">
select (SELECT count(id) from mt_user_balance where user_status = 0) as userNum,
sum(CASE WHEN mub.user_status = 1 THEN 1 ELSE 0 END) as logOffUserNum,
sum(mub.points) as allPoints,
sum(mub.used_points) as consumePoints,
sum(CASE WHEN cbc.change_type = 1 THEN cbc.balance ELSE 0 END) as accumulateRecharge,
sum(mub.card_balance) as allBalance
FROM mt_user mu
LEFT JOIN mt_user_balance mub ON mu.id = mub.mt_user_id
left join card_balance_change cbc on cbc.user_id=mu.id
</select>
<select id="selectAmountStatistics" resultType="com.fuint.business.userManager.dto.LJUserStaticesDto">
select (SELECT count(id) from mt_user_balance where user_status = 0) as userNum,
sum(CASE WHEN mub.user_status = 1 THEN 1 ELSE 0 END) as logOffUserNum,
sum(mub.points) as allPoints,
sum(mub.used_points) as consumePoints,
sum(CASE WHEN cbc.change_type = 1 THEN cbc.balance ELSE 0 END) as accumulateRecharge,
sum(mub.card_balance) as allBalance
FROM mt_user mu
LEFT JOIN mt_user_balance mub ON mu.id = mub.mt_user_id
left join card_balance_change cbc on cbc.user_id=mu.id
</select>
<select id="findUserList" resultType="com.fuint.business.userManager.vo.LJUserVo">
SELECT
mu.*

View File

@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.fuint.business.userGroup.entity.UserGroup;
import com.fuint.business.userManager.dto.LJUserDto;
import com.fuint.business.userManager.dto.LJUserStaticesDto;
import com.fuint.business.userManager.entity.LJUser;
import com.fuint.business.userManager.vo.LJUserVo;
import org.springframework.transaction.annotation.Transactional;
@ -197,13 +199,13 @@ public interface LJUserService extends IService<LJUser> {
* 会员分析-会员统计-会员人数
* @return
*/
Map<String,Object> selectUserNum();
LJUserDto selectUserNum();
/**
* 会员分析-会员统计-会员金额统计
* @return
*/
Map<String,Object> selectAmountStatistics();
LJUserStaticesDto selectAmountStatistics();
/**
* 会员分析-会员统计-会员发放积分统计

View File

@ -104,4 +104,5 @@ public interface UserBalanceService extends IService<UserBalance> {
* @param orderNo 订单号
*/
void growthValue(Integer userId, Integer chainStoreId,Integer storeId, String consumptioType, Double money,String fromType, String orderNo);
}

View File

@ -23,6 +23,8 @@ import com.fuint.business.order.service.OilOrderService;
import com.fuint.business.storeInformation.entity.LJStore;
import com.fuint.business.storeInformation.service.ILJStoreService;
import com.fuint.business.userGroup.entity.UserGroup;
import com.fuint.business.userManager.dto.LJUserDto;
import com.fuint.business.userManager.dto.LJUserStaticesDto;
import com.fuint.business.userManager.entity.*;
import com.fuint.business.userManager.mapper.LJUserMapper;
import com.fuint.business.userManager.mapper.MtInvitationMapper;
@ -811,142 +813,149 @@ public class LJUserServiceImpl extends ServiceImpl<LJUserMapper, LJUser> impleme
}
@Override
public Map<String, Object> selectUserNum() {
Map<String, Object> map = new HashMap<>();
List<LJUserVo> ljUserVos = selectUsersList();
// 会员人数
Integer userNum = 0;
// 注销会员人数
Integer logOffUserNum = 0;
// 会员总积分
Integer allPoints = 0;
// 消耗积分
Integer consumePoints = 0;
// 会员累计充值
Double accumulateRecharge = 0.0;
// 会员总余额
Double allBalance = 0.0;
if (ObjectUtil.isNotEmpty(ljUserVos)){
userNum = ljUserVos.size();
Integer points = 0;
Double usedAmount = 0.0;
Double giveAmount = 0.0;
for (LJUserVo ljUserVo : ljUserVos) {
points += ljUserVo.getPoints();
if (ObjectUtil.isNotEmpty(ljUserVo.getUsedPoints())) consumePoints += ljUserVo.getUsedPoints();
allBalance += ljUserVo.getCardBalance();
if (ObjectUtil.isNotEmpty(ljUserVo.getUsedAmount())) usedAmount += ljUserVo.getUsedAmount();
if (ObjectUtil.isNotEmpty(ljUserVo.getGiveAmount())) giveAmount += ljUserVo.getGiveAmount();
if (ljUserVo.getUserStatus().equals("1")){
logOffUserNum += 1;
}
}
allPoints = points + consumePoints;
accumulateRecharge = allBalance + usedAmount + giveAmount;
allBalance += giveAmount;
}
map.put("userNum",userNum);
map.put("logOffUserNum",logOffUserNum);
map.put("allPoints",allPoints);
map.put("consumePoints",consumePoints);
map.put("accumulateRecharge",accumulateRecharge);
map.put("allBalance",allBalance);
return map;
public LJUserDto selectUserNum() {
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
LJUserDto ljUserDto = ljUserMapper.queryUserMsg(nowAccountInfo.getStoreId());
// Map<String, Object> map = new HashMap<>();
//
// List<LJUserVo> ljUserVos = selectUsersList();
//
//// 会员人数
// Integer userNum = 0;
//// 注销会员人数
// Integer logOffUserNum = 0;
//// 会员总积分
// Integer allPoints = 0;
//// 消耗积分
// Integer consumePoints = 0;
//// 会员累计充值
// Double accumulateRecharge = 0.0;
//// 会员总余额
// Double allBalance = 0.0;
//
// if (ObjectUtil.isNotEmpty(ljUserVos)){
// userNum = ljUserVos.size();
// Integer points = 0;
// Double usedAmount = 0.0;
// Double giveAmount = 0.0;
// for (LJUserVo ljUserVo : ljUserVos) {
// points += ljUserVo.getPoints();
// if (ObjectUtil.isNotEmpty(ljUserVo.getUsedPoints())) consumePoints += ljUserVo.getUsedPoints();
// allBalance += ljUserVo.getCardBalance();
// if (ObjectUtil.isNotEmpty(ljUserVo.getUsedAmount())) usedAmount += ljUserVo.getUsedAmount();
// if (ObjectUtil.isNotEmpty(ljUserVo.getGiveAmount())) giveAmount += ljUserVo.getGiveAmount();
// if (ljUserVo.getUserStatus().equals("1")){
// logOffUserNum += 1;
// }
// }
// allPoints = points + consumePoints;
// accumulateRecharge = allBalance + usedAmount + giveAmount;
// allBalance += giveAmount;
// }
//
// map.put("userNum",userNum);
// map.put("logOffUserNum",logOffUserNum);
// map.put("allPoints",allPoints);
// map.put("consumePoints",consumePoints);
// map.put("accumulateRecharge",accumulateRecharge);
// map.put("allBalance",allBalance);
return ljUserDto;
}
@Override
public Map<String, Object> selectAmountStatistics() {
Map<String, Object> map = new HashMap<>();
// 充值总额
Double rechargeAmount = 0.0;
// 充值本金
Double rechargePrincipal = 0.0;
// 充值赠送
Double rechargeGive = 0.0;
// 消费总额
Double consumeAmount = 0.0;
// 消费本金
Double consumePrincipal = 0.0;
// 消费赠送
Double consumeGive = 0.0;
// 退款总额
Double refundAmount = 0.0;
// 退款本金
Double refundPrincipal = 0.0;
// 退款赠送
Double refundGive = 0.0;
// 注销总额
Double logOffAmount = 0.0;
// 注销本金
Double logOffPrincipal = 0.0;
// 注销赠送
Double logOffGive = 0.0;
// 会员总余额
Double userBalance = 0.0;
// 剩余本金
Double residuePrincipal = 0.0;
// 剩余赠送
Double residueGive = 0.0;
BigDecimal bigDecimal = new BigDecimal("0");
List<CardBalanceChange> cardBalanceChanges1 = cardBalanceChangeService.selectList("1");
if (ObjectUtil.isNotEmpty(cardBalanceChanges1)) {
for (CardBalanceChange cardBalanceChange : cardBalanceChanges1) {
rechargePrincipal += cardBalanceChange.getBalance();
if (ObjectUtil.isNotEmpty(cardBalanceChange.getGiveBalance()))
rechargeGive += cardBalanceChange.getGiveBalance();
}
rechargeAmount += rechargePrincipal + rechargeGive;
}
List<CardBalanceChange> cardBalanceChanges = cardBalanceChangeService.selectList("0");
if (ObjectUtil.isNotEmpty(cardBalanceChanges)) {
for (CardBalanceChange cardBalanceChange : cardBalanceChanges) {
if (cardBalanceChange.getFromType().equals("油品订单消费")){
consumePrincipal += cardBalanceChange.getBalance();
if (ObjectUtil.isNotEmpty(cardBalanceChange.getGiveBalance()))
consumeGive += cardBalanceChange.getGiveBalance();
}else {
refundPrincipal += cardBalanceChange.getBalance();
if (ObjectUtil.isNotEmpty(cardBalanceChange.getGiveBalance()))
refundGive += cardBalanceChange.getGiveBalance();
}
}
consumeAmount = consumePrincipal + consumeGive;
refundAmount = refundPrincipal + refundGive;
}
public LJUserStaticesDto selectAmountStatistics() {
List<LJUserVo> ljUserVos = selectUsersList();
if (ObjectUtil.isNotEmpty(ljUserVos)){
for (LJUserVo ljUserVo : ljUserVos) {
residuePrincipal += ljUserVo.getCardBalance();
if (ObjectUtil.isNotEmpty(ljUserVo.getGiveAmount())) residueGive += ljUserVo.getGiveAmount();
if (ljUserVo.getUserStatus().equals("1")){
logOffPrincipal += ljUserVo.getCardBalance();
if (ObjectUtil.isNotEmpty(ljUserVo.getGiveAmount())) logOffGive += ljUserVo.getGiveAmount();
}
}
logOffAmount = logOffPrincipal + logOffGive;
userBalance = residuePrincipal + residueGive;
}
map.put("rechargeAmount",rechargeAmount);
map.put("rechargePrincipal",rechargePrincipal);
map.put("rechargeGive",rechargeGive);
map.put("consumeAmount",consumeAmount);
map.put("consumePrincipal",consumePrincipal);
map.put("consumeGive",consumeGive);
map.put("refundAmount",refundAmount);
map.put("refundPrincipal",refundPrincipal);
map.put("refundGive",refundGive);
map.put("logOffAmount",logOffAmount);
map.put("logOffPrincipal",logOffPrincipal);
map.put("logOffGive",logOffGive);
map.put("userBalance",userBalance);
map.put("residuePrincipal",residuePrincipal);
map.put("residueGive",residueGive);
return map;
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
LJUserStaticesDto ljUserStaticesDto = ljUserMapper.selectAmountStatistics(nowAccountInfo.getStoreId());
// Map<String, Object> map = new HashMap<>();
//// 充值总额
// Double rechargeAmount = 0.0;
//// 充值本金
// Double rechargePrincipal = 0.0;
//// 充值赠送
// Double rechargeGive = 0.0;
//// 消费总额
// Double consumeAmount = 0.0;
//// 消费本金
// Double consumePrincipal = 0.0;
//// 消费赠送
// Double consumeGive = 0.0;
//// 退款总额
// Double refundAmount = 0.0;
//// 退款本金
// Double refundPrincipal = 0.0;
//// 退款赠送
// Double refundGive = 0.0;
//// 注销总额
// Double logOffAmount = 0.0;
//// 注销本金
// Double logOffPrincipal = 0.0;
//// 注销赠送
// Double logOffGive = 0.0;
//// 会员总余额
// Double userBalance = 0.0;
//// 剩余本金
// Double residuePrincipal = 0.0;
//// 剩余赠送
// Double residueGive = 0.0;
// BigDecimal bigDecimal = new BigDecimal("0");
// List<CardBalanceChange> cardBalanceChanges1 = cardBalanceChangeService.selectList("1");
// if (ObjectUtil.isNotEmpty(cardBalanceChanges1)) {
// for (CardBalanceChange cardBalanceChange : cardBalanceChanges1) {
// rechargePrincipal += cardBalanceChange.getBalance();
// if (ObjectUtil.isNotEmpty(cardBalanceChange.getGiveBalance()))
// rechargeGive += cardBalanceChange.getGiveBalance();
// }
// rechargeAmount += rechargePrincipal + rechargeGive;
// }
// List<CardBalanceChange> cardBalanceChanges = cardBalanceChangeService.selectList("0");
// if (ObjectUtil.isNotEmpty(cardBalanceChanges)) {
// for (CardBalanceChange cardBalanceChange : cardBalanceChanges) {
// if (cardBalanceChange.getFromType().equals("油品订单消费")){
// consumePrincipal += cardBalanceChange.getBalance();
// if (ObjectUtil.isNotEmpty(cardBalanceChange.getGiveBalance()))
// consumeGive += cardBalanceChange.getGiveBalance();
// }else {
// refundPrincipal += cardBalanceChange.getBalance();
// if (ObjectUtil.isNotEmpty(cardBalanceChange.getGiveBalance()))
// refundGive += cardBalanceChange.getGiveBalance();
// }
// }
// consumeAmount = consumePrincipal + consumeGive;
// refundAmount = refundPrincipal + refundGive;
// }
//
// List<LJUserVo> ljUserVos = selectUsersList();
// if (ObjectUtil.isNotEmpty(ljUserVos)){
// for (LJUserVo ljUserVo : ljUserVos) {
// residuePrincipal += ljUserVo.getCardBalance();
// if (ObjectUtil.isNotEmpty(ljUserVo.getGiveAmount())) residueGive += ljUserVo.getGiveAmount();
//
// if (ljUserVo.getUserStatus().equals("1")){
// logOffPrincipal += ljUserVo.getCardBalance();
// if (ObjectUtil.isNotEmpty(ljUserVo.getGiveAmount())) logOffGive += ljUserVo.getGiveAmount();
// }
// }
// logOffAmount = logOffPrincipal + logOffGive;
// userBalance = residuePrincipal + residueGive;
// }
//
// map.put("rechargeAmount",rechargeAmount);
// map.put("rechargePrincipal",rechargePrincipal);
// map.put("rechargeGive",rechargeGive);
// map.put("consumeAmount",consumeAmount);
// map.put("consumePrincipal",consumePrincipal);
// map.put("consumeGive",consumeGive);
// map.put("refundAmount",refundAmount);
// map.put("refundPrincipal",refundPrincipal);
// map.put("refundGive",refundGive);
// map.put("logOffAmount",logOffAmount);
// map.put("logOffPrincipal",logOffPrincipal);
// map.put("logOffGive",logOffGive);
// map.put("userBalance",userBalance);
// map.put("residuePrincipal",residuePrincipal);
// map.put("residueGive",residueGive);
return ljUserStaticesDto;
}
@Override

View File

@ -568,6 +568,7 @@ export default {
dicts: ['CardCoupon_type'],
data() {
return {
orderNo:'',
disOil: 0.00,
disGoods: 0.00,
loadingPreferential: false,
@ -1053,6 +1054,7 @@ export default {
await getCheckTheStatusOfYourPaymentApi(id).then(async response => {
if (response.data != null) {
const payStatus = response.data.payStatus
this_.orderNo=response.data.paymentNo
if (payStatus === "unpaid") {
this_.isQuery = true;
} else if (payStatus === "paid") {
@ -1118,7 +1120,6 @@ export default {
this.$message.error('请选择输入充值本金');
return
}
console.log(selectCard,1122)
this.payForm.rechargeBalance = selectCard.rechargeBalance
this.payForm.lockupPrice = selectCard.lockupPrice
this.payForm.realyPayBills = selectCard.rechargeBalance
@ -1227,8 +1228,13 @@ export default {
console.log(1226)
let payTypeText = payTypeMap[this.payForm.paymentType]
let actualPay = this.payForm.paymentType == 'CASH' ? this.payForm.authCode:this.payForm.realyPayBills
let mm=[]
mm.push({
orderNo:this.orderNo,
payUser:this.chooseVipUser.mobile
})
let a = {
oilOrder:mm,
//
realyPayBills:this.payForm.realyPayBills,
//
@ -1430,10 +1436,11 @@ export default {
let isPaySuccess = false;
console.log(_this.payForm, 1089)
_this.payForm.cardCouponList=null
//
await addLJGoods(_this.payForm).then(async response => {
_this.orderNo = response.data.orderNo;
this.orderNo = response.data.orderNo;
//
console.log("支付成功", response)