This commit is contained in:
wangh 2024-01-10 15:43:57 +08:00
parent 8c857bebe3
commit 48ce157316
4 changed files with 488 additions and 426 deletions

File diff suppressed because it is too large Load Diff

View File

@ -203,10 +203,10 @@ public class CardFuelRecordServiceImpl implements CardFuelRecordService {
// 支付
if (flag) {
Integer allAmount1 = (int) (theAmountToBePaid*100);
System.out.println("allAmount1:"+allAmount1);
Integer allAmount = (int) (theAmountToBePaid*100);
System.out.println("allAmount1:"+allAmount);
Integer allAmount = (int) (0.01 * 100);
// Integer allAmount = (int) (0.01 * 100);
MerchantConfig merchantConfig = merchantConfigService.selectMeChByIdIsUse(nowAccountInfo.getStoreId());
// 处理支付需要的数据

View File

@ -77,5 +77,7 @@ public class CardValueRecord extends Model<CardValueRecord> {
//连锁店id
private Integer chainStoreId;
private String status;
}

View File

@ -46,6 +46,8 @@ import com.fuint.business.userManager.mapper.LJUserMapper;
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.RedisLock;
import com.fuint.common.util.RedisUtil;
import com.fuint.common.util.RocketUtil;
import com.fuint.common.util.TokenUtil;
import com.fuint.repository.mapper.MtStaffMapper;
@ -53,6 +55,7 @@ import com.fuint.repository.model.MtStaff;
import io.lettuce.core.dynamic.annotation.Param;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.redisson.api.RLock;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -62,6 +65,7 @@ import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
/**
* 储值充值表(CardValueRecord)表服务实现类
@ -304,6 +308,9 @@ public class CardValueRecordServiceImpl extends ServiceImpl<CardValueRecordMappe
bigDecimal = bigDecimal.add(new BigDecimal(cardValueRecordDTO.getGiftBalance()).add(new BigDecimal(cardValueRecordDTO.getRechargeBalance().toString())));
cardValueRecordDTO.setBidBalance(bigDecimal.doubleValue());
}
if (ObjectUtils.isEmpty(cardValueRecordDTO.getMtStaffId())) {
cardValueRecordDTO.setMtStaffId(nowAccountInfo.getStaffId());
}
baseMapper.insert(cardValueRecordDTO);
double epsilon = 1e-10; // 阈值
@ -322,9 +329,9 @@ public class CardValueRecordServiceImpl extends ServiceImpl<CardValueRecordMappe
}
// todo
if (flag) {
Integer allAmount1 = (int) (theAmountToBePaid*100);
System.out.println("allAmount1:"+allAmount1);
Integer allAmount = (int) (0.01*100);
Integer allAmount = (int) (theAmountToBePaid*100);
System.out.println("allAmount1:"+allAmount);
// Integer allAmount = (int) (0.01*100);
MerchantConfig merchantConfig = merchantConfigService.selectMeChByIdIsUse(nowAccountInfo.getStoreId());
// 处理支付需要的数据
@ -368,6 +375,9 @@ public class CardValueRecordServiceImpl extends ServiceImpl<CardValueRecordMappe
// 支付 payment_type
return cardValueRecordDTO;
}
@Autowired
private RedisLock redisLock;
/**
* 查询支付状态 修改相关关联表
@ -378,9 +388,13 @@ public class CardValueRecordServiceImpl extends ServiceImpl<CardValueRecordMappe
@Transactional
public CardValueRecord checkTheStatusOfYourPayment(Integer id) {
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
CardValueRecord cardValueRecord = baseMapper.selectById(id);
String lockKey = "CardValueRecord"+nowAccountInfo.getStoreId()+id;
Boolean isLock = redisLock.tryLock(lockKey, 5000, TimeUnit.MILLISECONDS);
// 支付成功之后
if ("paid".equals(cardValueRecord.getPayStatus())){
if (isLock && "paid".equals(cardValueRecord.getPayStatus()) && "0".equals(cardValueRecord.getStatus())){
// 查询用户信息
LJUserVo ljUserVos = ljUserMapper.selectAllInfoById2(cardValueRecord.getMtUserId(), cardValueRecord.getChainStoreId());
@ -398,6 +412,7 @@ public class CardValueRecordServiceImpl extends ServiceImpl<CardValueRecordMappe
cardBalanceChange.setBalance(cardValueRecord.getGiftBalance());
cardBalanceChange.setStoreId(cardValueRecord.getStoreId());
cardBalanceChange.setChainStoreId(cardValueRecord.getChainStoreId());
cardBalanceChange.setCreateBy(cardValueRecord.getMtStaffId().toString());
cardBalanceChangeService.insertCardBalance2(cardBalanceChange);
}
@ -417,6 +432,11 @@ public class CardValueRecordServiceImpl extends ServiceImpl<CardValueRecordMappe
commissionRecordService.insert2(commissionRecord);
}
// 修改订单的处理状态 (避免二次执行)
CardValueRecord updateCardValueRecord = new CardValueRecord();
updateCardValueRecord.setId(id);
updateCardValueRecord.setStatus("1");
baseMapper.updateById(updateCardValueRecord);
} else {
return cardValueRecord;
}