6 changed files with 261 additions and 112 deletions
@ -0,0 +1,122 @@ |
|||||
|
package com.qs.serve.modules.third.util; |
||||
|
|
||||
|
import com.qs.serve.common.util.HttpUtil; |
||||
|
import com.qs.serve.common.util.IdUtil; |
||||
|
import com.qs.serve.common.util.JsonUtil; |
||||
|
import com.qs.serve.modules.bms.entity.BmsSubject; |
||||
|
import com.qs.serve.modules.bms.entity.BmsSupplier; |
||||
|
import com.qs.serve.modules.sys.entity.SysSyncLog; |
||||
|
import com.qs.serve.modules.third.entity.ThirtyVerification; |
||||
|
import com.qs.serve.modules.vtb.entity.VtbVerification; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.jetbrains.annotations.NotNull; |
||||
|
import org.jetbrains.annotations.Nullable; |
||||
|
|
||||
|
import java.math.BigDecimal; |
||||
|
import java.time.LocalDateTime; |
||||
|
import java.time.format.DateTimeFormatter; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/9/14 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
public class ThirtyVerificationUtil { |
||||
|
|
||||
|
/** |
||||
|
* 用于全过程生成 |
||||
|
* @param supplier |
||||
|
* @param subject |
||||
|
* @param totalAmount |
||||
|
* @param activityTitle |
||||
|
* @param verification |
||||
|
* @return |
||||
|
*/ |
||||
|
@Nullable |
||||
|
public static String buildJson(BmsSupplier supplier, BmsSubject subject, BigDecimal totalAmount, String activityTitle, VtbVerification verification) { |
||||
|
LocalDateTime nowTime = LocalDateTime.now(); |
||||
|
String timeString = nowTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
||||
|
ThirtyVerification tv = new ThirtyVerification(); |
||||
|
tv.setId(IdUtil.getSnowFlakeId()+""); |
||||
|
tv.setVerificationCode(verification.getVerificationCode()); |
||||
|
tv.setActivityTitle(activityTitle); |
||||
|
//tv.setActivityCode(activityCode);
|
||||
|
tv.setCreateDate(timeString); |
||||
|
tv.setStartDate(timeString); |
||||
|
tv.setEndDate(timeString); |
||||
|
tv.setSubjectCode(subject.getSubjectCode()); |
||||
|
tv.setSubjectName(subject.getSubjectName()); |
||||
|
tv.setMoney(totalAmount); |
||||
|
//tv.setCreateUser();
|
||||
|
tv.setCreateTime(timeString); |
||||
|
//tv.setCheckUser(user.getName());
|
||||
|
tv.setCheckTime(timeString); |
||||
|
tv.setCusCode(supplier.getCode()); |
||||
|
tv.setCusName(supplier.getName()); |
||||
|
tv.setRecId(verification.getVerificationCode()); |
||||
|
String json = JsonUtil.objectToJson(tv); |
||||
|
return json; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 用于全过程生成 |
||||
|
* @param supplier |
||||
|
* @param subject |
||||
|
* @param totalAmount |
||||
|
* @param activityTitle |
||||
|
* @param verification |
||||
|
* @return |
||||
|
*/ |
||||
|
@Nullable |
||||
|
public static String buildJson(BmsSupplier supplier, BmsSubject subject, BigDecimal totalAmount, String activityTitle, |
||||
|
LocalDateTime startTime,LocalDateTime endTime, VtbVerification verification) { |
||||
|
LocalDateTime nowTime = LocalDateTime.now(); |
||||
|
String timeString = nowTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
||||
|
String startTimeString = startTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
||||
|
String endTimeString = endTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
||||
|
ThirtyVerification tv = new ThirtyVerification(); |
||||
|
tv.setId(IdUtil.getSnowFlakeId()+""); |
||||
|
tv.setVerificationCode(verification.getVerificationCode()); |
||||
|
tv.setActivityTitle(activityTitle); |
||||
|
//tv.setActivityCode(activityCode);
|
||||
|
tv.setCreateDate(timeString); |
||||
|
tv.setStartDate(startTimeString); |
||||
|
tv.setEndDate(endTimeString); |
||||
|
tv.setSubjectCode(subject.getSubjectCode()); |
||||
|
tv.setSubjectName(subject.getSubjectName()); |
||||
|
tv.setMoney(totalAmount); |
||||
|
//tv.setCreateUser();
|
||||
|
tv.setCreateTime(timeString); |
||||
|
//tv.setCheckUser(user.getName());
|
||||
|
tv.setCheckTime(timeString); |
||||
|
tv.setCusCode(supplier.getCode()); |
||||
|
tv.setCusName(supplier.getName()); |
||||
|
tv.setRecId(verification.getVerificationCode()); |
||||
|
return JsonUtil.objectToJson(tv); |
||||
|
} |
||||
|
|
||||
|
@NotNull |
||||
|
public static SysSyncLog requestToPayment(String title,String keyCode, String api, String json) { |
||||
|
log.info("COST_TO_PAY_API 支付单信息:{} 数据:{}", keyCode, json); |
||||
|
String rs = null; |
||||
|
try { |
||||
|
rs = HttpUtil.doPost(api, json,null); |
||||
|
} catch (Exception e) { |
||||
|
rs = e.getMessage(); |
||||
|
} |
||||
|
SysSyncLog syncLog = new SysSyncLog(); |
||||
|
syncLog.setFrom(title); |
||||
|
syncLog.setUrl(api); |
||||
|
syncLog.setRequestJson(json); |
||||
|
if(rs==null||!rs.contains("200")){ |
||||
|
log.error("COST_TO_PAY_API \n 请求参数:{},\n 支付单信息:{},\n 结果:{}", json, keyCode,rs); |
||||
|
syncLog.setEntityClass("ThirtyVerification"); |
||||
|
syncLog.setFailReason(rs); |
||||
|
syncLog.setRemark("支付失败:["+ keyCode+"]"); |
||||
|
}else { |
||||
|
syncLog.setSuccessStatus(1); |
||||
|
syncLog.setRemark("支付完成:["+ keyCode+"]"); |
||||
|
} |
||||
|
return syncLog; |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue