礼品卡兑换记录
This commit is contained in:
parent
e7f8a5bfc9
commit
e7299b6613
@ -61,14 +61,14 @@ public class CardValueRecordController extends BaseController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
* 储值卡充值
|
||||
*
|
||||
* @param cardValueRecord 实体对象
|
||||
* @return 新增结果
|
||||
*/
|
||||
@PostMapping
|
||||
public ResponseObject insert(@RequestBody CardValueRecord cardValueRecord) {
|
||||
return getSuccessResult(this.cardValueRecordService.insert(cardValueRecord));
|
||||
public ResponseObject insert(@RequestBody CardValueRecordDTO cardValueRecordDTO) {
|
||||
return getSuccessResult(this.cardValueRecordService.insert(cardValueRecordDTO));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -23,7 +23,7 @@ public interface CardValueRecordService extends IService<CardValueRecord> {
|
||||
* @param cardValueRecord
|
||||
* @return
|
||||
*/
|
||||
boolean insert(CardValueRecord cardValueRecord);
|
||||
boolean insert(CardValueRecordDTO cardValueRecordDTO);
|
||||
|
||||
/**
|
||||
* 余额充值
|
||||
|
@ -72,12 +72,64 @@ public class CardValueRecordServiceImpl extends ServiceImpl<CardValueRecordMappe
|
||||
|
||||
/**
|
||||
* 储值卡充值(新增)
|
||||
* @param cardValueRecord
|
||||
* @param cardValueRecordDTO
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean insert(CardValueRecord cardValueRecord) {
|
||||
return false;
|
||||
public boolean insert(CardValueRecordDTO cardValueRecordDTO) {
|
||||
|
||||
boolean pay = false;
|
||||
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
|
||||
// 添加储存充值
|
||||
cardValueRecordDTO.setPayStatus("unpaid");
|
||||
// 根据日期生成支付编号
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
String timestamp = dateFormat.format(new Date());
|
||||
String randomString = UUID.randomUUID().toString().replace("-","").substring(0,6);
|
||||
String orderNo = timestamp+randomString;
|
||||
cardValueRecordDTO.setPaymentNo(orderNo);
|
||||
cardValueRecordDTO.setStoreId(nowAccountInfo.getStoreId());
|
||||
if (ObjectUtil.isEmpty(cardValueRecordDTO.getBidBalance())) cardValueRecordDTO.setBidBalance(0.0);
|
||||
if (cardValueRecordDTO.getBidBalance() <= 0.0) {
|
||||
BigDecimal bigDecimal = new BigDecimal(cardValueRecordDTO.getBidBalance());
|
||||
bigDecimal = bigDecimal.add(new BigDecimal(cardValueRecordDTO.getGiftBalance()).add(new BigDecimal(cardValueRecordDTO.getRechargeBalance())));
|
||||
cardValueRecordDTO.setBidBalance(bigDecimal.doubleValue());
|
||||
}
|
||||
baseMapper.insert(cardValueRecordDTO);
|
||||
|
||||
double epsilon = 1e-10; // 阈值
|
||||
|
||||
Double theAmountToBePaid = 0.0;
|
||||
|
||||
|
||||
Integer allAmount1 = (int) (theAmountToBePaid*100);
|
||||
System.out.println("allAmount1:"+allAmount1);
|
||||
Integer allAmount = (int) (0.01*100);
|
||||
|
||||
MerchantConfig merchantConfig = merchantConfigService.selectMeChByIsUse("1");
|
||||
// 处理支付需要的数据
|
||||
Map<String,String> 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.applet(map);
|
||||
pay = true;
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
// 支付 payment_type
|
||||
return pay;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user