This commit is contained in:
linfso 2025-05-20 17:07:21 +08:00
parent 500c5373d0
commit 2e030c5bd1
5 changed files with 114 additions and 5 deletions

View File

@ -240,6 +240,23 @@ public class EmisSettleBillController extends BaseController
}
}
/**
* 微信小程序支付
* @param emisSettleBill
* @return
*/
@GetMapping(value = "/genWxPayFromWxApp")
public AjaxResult genWxPayFromWxApp(EmisSettleBill emisSettleBill)
{
try {
String qrPicUrl=emisSettleBillPayLogService.genWxPayFromWxApp(emisSettleBill.getSettleBillNo(),emisSettleBill.getOpenId());
return AjaxResult.success("成功",qrPicUrl);
} catch (EmisBizError emisBizError) {
emisBizError.printStackTrace();
return AjaxResult.error(emisBizError.getMessage());
}
}
@PostMapping(value = "/sumbitWxPay")
public AjaxResult sumbitWxPay(@RequestBody EmisSettleBill emisSettleBill)

View File

@ -59,10 +59,13 @@ public class EmisTmsCostProfitController extends BaseController
public TableDataInfo list(EmisTmsCostProfit emisTmsCostProfit)
{
startPage();
emisTmsCostProfit.setBillCode(WaybillHelper.formatQueryValue(emisTmsCostProfit.getBillCode()));
String[] billCodeSortList = emisTmsCostProfit.getBillCode().split(",");
if(billCodeSortList.length>1){
emisTmsCostProfit.getParams().put("billCodeSortList", Arrays.asList(billCodeSortList));
if(!StringUtils.isEmpty(emisTmsCostProfit.getBillCode())) {
emisTmsCostProfit.setBillCode(WaybillHelper.formatQueryValue(emisTmsCostProfit.getBillCode()));
String[] billCodeSortList = emisTmsCostProfit.getBillCode().split(",");
if (billCodeSortList.length > 1) {
emisTmsCostProfit.getParams().put("billCodeSortList", Arrays.asList(billCodeSortList));
}
}
List<EmisTmsCostProfit> list = emisTmsCostProfitService.selectEmisTmsCostProfitList(emisTmsCostProfit);

View File

@ -193,7 +193,8 @@ public class EmisSettleBill extends BaseEntity
// 支付二维码图片
private String qrCodePayPicUrl;
// 支付人openId
private String openId;
List<EmisSettleSubBill> subBillList;

View File

@ -87,6 +87,16 @@ public interface IEmisSettleBillPayLogService
public String genWxPayQR(String settleBillNo) throws EmisBizError;
/**
* 公众号/小程序支付
* @param settleBillNo
* @param openId
* @return
* @throws EmisBizError
*/
public String genWxPayFromWxApp(String settleBillNo,String openId) throws EmisBizError;
/**
* 检查支付状态
* @param orderNo

View File

@ -228,6 +228,84 @@ public class EmisSettleBillPayLogServiceImpl implements IEmisSettleBillPayLogSer
}
}
/**
* 微信小程序支付
* @param settleBillNo
* @return
* @throws EmisBizError
*/
@Override
public String genWxPayFromWxApp(String settleBillNo,String openId) throws EmisBizError {
EmisSettleBill emisSettleBill=emisSettleBillMapper.selectSettleBillBySettleBillNo(settleBillNo);
BigDecimal thisPayMoney=emisSettleBill.getRecMoney().subtract(emisSettleBill.getRecedMoney());
int amount= (int) (thisPayMoney.floatValue()*100.0f);
String merId="1";
float feeRate=0.0065f;
int fee= (int) (thisPayMoney.floatValue()*feeRate);
String authCode="";
String payId= WaybillHelper.genPayId();
// 产生支付订单
EmisSettleBillPayLog emisSettleBillPayLog = new EmisSettleBillPayLog();
emisSettleBillPayLog.setPayId(payId);
emisSettleBillPayLog.setSettleBillNo(settleBillNo);
emisSettleBillPayLog.setAmount(amount);
emisSettleBillPayLog.setPayType("wx");
emisSettleBillPayLog.setStatus(0);
emisSettleBillPayLog.setStatusDesc("初始");
emisSettleBillPayLog.setFee(fee);
emisSettleBillPayLog.setCurrency("CNY");
emisSettleBillPayLog.setSubject("账单支付");
emisSettleBillPayLog.setBody("账单支付");
emisSettleBillPayLog.setRemark("账单支付");
emisSettleBillPayLogMapper.insertEmisSettleBillPayLog(emisSettleBillPayLog);
// 公众号及小程序支付
String channel="wxpay_pub";
String appId="";
String notifyUrl= Config.ERP_API_PAY_NOTIFY_URL;
ApiRes res= null;
EmisSettleBillPayLog emisSettleBillPayLogUpd = new EmisSettleBillPayLog();
emisSettleBillPayLogUpd.setId(emisSettleBillPayLog.getId());
try {
res = VitePayOnlineSdk.onlinePay(channel,payId,merId,amount,fee,notifyUrl,appId,authCode,openId,"运费",emisSettleBill.getSettleBillName()+"-运费");
log.info("支付代码生成==>{}",JSONObject.toJSONString(res));
emisSettleBillPayLogUpd.setResponseExtra(JSON.toJSONString(res));
if(res.isSuccess()){
String payCode=((Map)res.getData().get("credential")).get("qr_image_url").toString();
emisSettleBillPayLogUpd.setCredential(JSON.toJSONString(res.getData().get("credential")));
emisSettleBillPayLogUpd.setStatus(10);
emisSettleBillPayLogUpd.setStatusDesc("支付中");
emisSettleBillPayLogMapper.updateEmisSettleBillPayLog(emisSettleBillPayLogUpd);
return payCode;
}
else{
emisSettleBillPayLogUpd.setStatus(40);
emisSettleBillPayLogUpd.setStatusDesc(res.getMessage());
emisSettleBillPayLogMapper.updateEmisSettleBillPayLog(emisSettleBillPayLogUpd);
throw new EmisBizError(EmisBizErrorType.FAIL,res.getMessage());
}
} catch (Exception e) {
e.printStackTrace();
emisSettleBillPayLogUpd.setStatus(40);
emisSettleBillPayLogUpd.setStatusDesc("exception:"+e.getMessage());
emisSettleBillPayLogMapper.updateEmisSettleBillPayLog(emisSettleBillPayLogUpd);
throw new EmisBizError(EmisBizErrorType.FAIL,"支付异常");
}
}
/**
* 检查支付订单
* @param payId