|
|
@@ -1,6 +1,7 @@
|
|
|
package org.jeecg.modules.hlwpayment.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
@@ -49,6 +50,7 @@ import org.jeecg.modules.hlwtax.service.IHlwTaxService;
|
|
|
import org.jeecg.modules.hlwuser.entity.HlwUser;
|
|
|
import org.jeecg.modules.hlwuser.service.IHlwUserService;
|
|
|
import org.jeecg.modules.utils.HlwConstant;
|
|
|
+import org.jeecg.modules.utils.PayNbcbCommon;
|
|
|
import org.jeecg.modules.utils.PayRsaCommon;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -444,89 +446,10 @@ public class HlwPaymentServiceImpl extends ServiceImpl<HlwPaymentMapper, HlwPaym
|
|
|
*/
|
|
|
if (hlwSubcontractor.getBankType().equals(PayNbcbConst.bankType)) {
|
|
|
//宁波银行
|
|
|
+ result = nbPay(hlwPaymentDetailList, totalPaymenStr, hlwSubcontractor, hlwCompany, hlwPayment, hlwPaymentEntity, totalPayment);
|
|
|
} else {
|
|
|
//招商银行
|
|
|
- }
|
|
|
- //银行业务接口(代发工资)
|
|
|
- JSONObject jsonObjectBody = PayRsaCommon.NTAGCAPY(hlwPaymentDetailList, totalPaymenStr, hlwSubcontractor);
|
|
|
- if (jsonObjectBody != null) {
|
|
|
- //请求状态(对应payRecord表批次状态)(NTE: 银行处理中)
|
|
|
- String reqsta = jsonObjectBody.getString("reqsta");
|
|
|
- //流程实例号(对应payRecord表批次号)
|
|
|
- String reqnbr = jsonObjectBody.getString("reqnbr");
|
|
|
- //业务参考号
|
|
|
- String yurref = jsonObjectBody.getString("yurref");
|
|
|
- //银行处理返回成功
|
|
|
- if (PayConst.NTE.equals(reqsta) || PayConst.AUT.equals(reqsta)) {
|
|
|
- //获取当前登录用户
|
|
|
- LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
- for (int i = 0; i < hlwPaymentDetailList.size(); i++) {
|
|
|
- HlwPaymentDetail hlwPaymentDetail = hlwPaymentDetailList.get(i);
|
|
|
- //状态改为付款中
|
|
|
- if (hlwPaymentDetail.getStatus() == 1) {
|
|
|
- hlwPaymentDetail.setStatus(2);
|
|
|
- }
|
|
|
- hlwPaymentDetail.setPaymentTime(new Date());
|
|
|
- hlwPaymentDetail.setPaymentBy(sysUser.getUsername());
|
|
|
- hlwPaymentDetail.setUpdateTime(new Date());
|
|
|
- hlwPaymentDetailService.updateById(hlwPaymentDetail);
|
|
|
- //用户信息
|
|
|
- HlwUser hlwUser = hlwUserService.getByIdcardNumberAndApplicationId(hlwPaymentDetail.getIdcardNumber(), hlwPaymentEntity.getApplicationId());
|
|
|
- if (hlwUser != null) {
|
|
|
- hlwUser.setLastPaymentCompany(hlwCompany.getCompanyName());
|
|
|
- hlwUserService.updateById(hlwUser);
|
|
|
- }
|
|
|
- //订单信息
|
|
|
- HlwOrder hlwOrder = hlwOrderService.getById(hlwPaymentDetail.getOrderId());
|
|
|
- if (hlwOrder != null) {
|
|
|
- hlwOrder.setLastPaymentCompany(hlwCompany.getCompanyName());
|
|
|
- hlwOrderService.updateById(hlwOrder);
|
|
|
- }
|
|
|
- }
|
|
|
- //保存付款记录
|
|
|
- HlwPayRecord hlwPayRecord = new HlwPayRecord();
|
|
|
- hlwPayRecord.setPaymentId(hlwPaymentDetailList.get(0).getPaymentId());
|
|
|
- hlwPayRecord.setAgpseq(reqnbr);
|
|
|
- hlwPayRecord.setYurref(yurref);
|
|
|
- hlwPayRecord.setDetail(JSON.toJSONString(hlwPaymentDetailList));
|
|
|
- hlwPayRecord.setDelFlag("0");
|
|
|
- hlwPayRecordService.save(hlwPayRecord);
|
|
|
- //更新付款单信息
|
|
|
- //支付中
|
|
|
- hlwPayment.setPaymentTime(new Date());
|
|
|
- hlwPayment.setStatus(HlwConstant.PAYMENT_STATUS_PAY_ING);
|
|
|
- updateById(hlwPayment);
|
|
|
- /**
|
|
|
- * 是否通过平台
|
|
|
- */
|
|
|
- if (hlwPayment.getIsThroughPlatform() == HlwConstant.PAYMENT_THROUGH_PLATFORM_NO) {
|
|
|
- //更新企业账户信息
|
|
|
- updateAccount(hlwPayment);
|
|
|
- } else {
|
|
|
- //更新A-B-C账户信息
|
|
|
- updateAccountA_B(hlwPayment);
|
|
|
- }
|
|
|
- result.success("付款提交成功!等待银行返回结果");
|
|
|
- try {
|
|
|
- /**
|
|
|
- * 推送消息
|
|
|
- */
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
- String title = "付款单" + hlwPaymentEntity.getPaymentCode();
|
|
|
- String message = "共发放" + hlwPaymentDetailList.size() + "人,合计金额" + totalPayment + "元";
|
|
|
- jsonObject.put("userId", "e9ca23d68d884d4ebb19d07889727dae");
|
|
|
- jsonObject.put("title", title);
|
|
|
- jsonObject.put("message", message);
|
|
|
- sysBaseRemoteApi.sendUserByWebSocket(jsonObject);
|
|
|
- } catch (Exception e) {
|
|
|
- log.info("推送异常===,{}", e.getStackTrace());
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- } else {
|
|
|
- result.error500("付款提交失败!");
|
|
|
- }
|
|
|
- } else {
|
|
|
- result.error500("付款提交失败!");
|
|
|
+ result = zhPay(hlwPaymentDetailList, totalPaymenStr, hlwSubcontractor, hlwCompany, hlwPayment, hlwPaymentEntity, totalPayment);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
@@ -733,6 +656,36 @@ public class HlwPaymentServiceImpl extends ServiceImpl<HlwPaymentMapper, HlwPaym
|
|
|
|
|
|
//服务商信息
|
|
|
HlwSubcontractor hlwSubcontractor = hlwSubcontractorService.getById(hlwPayment.getSubcontractorId());
|
|
|
+ /**
|
|
|
+ * 银行通道(1:招商银行 2:宁波银行)
|
|
|
+ */
|
|
|
+ if (hlwSubcontractor.getBankType().equals(PayNbcbConst.bankType)) {
|
|
|
+ //宁波银行
|
|
|
+ result = nbPay(hlwPaymentDetailList, totalPaymenStr, hlwSubcontractor, hlwCompany, hlwPayment, hlwPaymentEntity, totalPayment);
|
|
|
+ } else {
|
|
|
+ //招商银行
|
|
|
+ result = zhPay(hlwPaymentDetailList, totalPaymenStr, hlwSubcontractor, hlwCompany, hlwPayment, hlwPaymentEntity, totalPayment);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 招商银行支付通道
|
|
|
+ *
|
|
|
+ * @param hlwPaymentDetailList
|
|
|
+ * @param totalPaymenStr
|
|
|
+ * @param hlwSubcontractor
|
|
|
+ * @param hlwCompany
|
|
|
+ * @param hlwPayment
|
|
|
+ * @param hlwPaymentEntity
|
|
|
+ * @param totalPayment
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Result<HlwPayment> zhPay(List<HlwPaymentDetail> hlwPaymentDetailList, String totalPaymenStr,
|
|
|
+ HlwSubcontractor hlwSubcontractor, HlwCompany hlwCompany,
|
|
|
+ HlwPayment hlwPayment, HlwPayment hlwPaymentEntity, Double totalPayment) {
|
|
|
+ Result<HlwPayment> result = new Result<>();
|
|
|
//银行业务接口(代发工资)
|
|
|
JSONObject jsonObjectBody = PayRsaCommon.NTAGCAPY(hlwPaymentDetailList, totalPaymenStr, hlwSubcontractor);
|
|
|
if (jsonObjectBody != null) {
|
|
|
@@ -818,20 +771,105 @@ public class HlwPaymentServiceImpl extends ServiceImpl<HlwPaymentMapper, HlwPaym
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 招商银行支付通道
|
|
|
- */
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
- public Result<HlwPayment> zhPay() {
|
|
|
- Result<HlwPayment> result = new Result<>();
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
* 宁波银行支付通道
|
|
|
+ *
|
|
|
+ * @param hlwPaymentDetailList
|
|
|
+ * @param totalPaymenStr
|
|
|
+ * @param hlwSubcontractor
|
|
|
+ * @param hlwCompany
|
|
|
+ * @param hlwPayment
|
|
|
+ * @param hlwPaymentEntity
|
|
|
+ * @param totalPayment
|
|
|
+ * @return
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public Result<HlwPayment> nbPay() {
|
|
|
+ public Result<HlwPayment> nbPay(List<HlwPaymentDetail> hlwPaymentDetailList, String totalPaymenStr,
|
|
|
+ HlwSubcontractor hlwSubcontractor, HlwCompany hlwCompany,
|
|
|
+ HlwPayment hlwPayment, HlwPayment hlwPaymentEntity, Double totalPayment) {
|
|
|
Result<HlwPayment> result = new Result<>();
|
|
|
+ //银行业务接口(代发工资)
|
|
|
+ JSONObject jsonObjectBody = PayNbcbCommon.NTAGCAPY(hlwPaymentDetailList, totalPaymenStr, hlwSubcontractor);
|
|
|
+ if (jsonObjectBody != null) {
|
|
|
+ //请求状态(对应payRecord表批次状态)(NTE: 银行处理中)
|
|
|
+ String retCode = jsonObjectBody.getString("retCode");
|
|
|
+ //流程实例号(对应payRecord表批次号)
|
|
|
+ JSONArray dtlSerialNoList = jsonObjectBody.getJSONArray("dtlSerialNoList");
|
|
|
+ //业务参考号
|
|
|
+ String yurref = jsonObjectBody.getString("yurref");
|
|
|
+ //银行处理返回成功
|
|
|
+ if (PayNbcbConst.SUCCESS.equals(retCode)) {
|
|
|
+ //获取当前登录用户
|
|
|
+ LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
+ for (int i = 0; i < hlwPaymentDetailList.size(); i++) {
|
|
|
+ HlwPaymentDetail hlwPaymentDetail = hlwPaymentDetailList.get(i);
|
|
|
+ //状态改为付款中
|
|
|
+ if (hlwPaymentDetail.getStatus() == 1) {
|
|
|
+ hlwPaymentDetail.setStatus(2);
|
|
|
+ }
|
|
|
+ hlwPaymentDetail.setPaymentTime(new Date());
|
|
|
+ hlwPaymentDetail.setPaymentBy(sysUser.getUsername());
|
|
|
+ hlwPaymentDetail.setUpdateTime(new Date());
|
|
|
+ hlwPaymentDetailService.updateById(hlwPaymentDetail);
|
|
|
+ //用户信息
|
|
|
+ HlwUser hlwUser = hlwUserService.getByIdcardNumberAndApplicationId(hlwPaymentDetail.getIdcardNumber(), hlwPaymentEntity.getApplicationId());
|
|
|
+ if (hlwUser != null) {
|
|
|
+ hlwUser.setLastPaymentCompany(hlwCompany.getCompanyName());
|
|
|
+ hlwUserService.updateById(hlwUser);
|
|
|
+ }
|
|
|
+ //订单信息
|
|
|
+ HlwOrder hlwOrder = hlwOrderService.getById(hlwPaymentDetail.getOrderId());
|
|
|
+ if (hlwOrder != null) {
|
|
|
+ hlwOrder.setLastPaymentCompany(hlwCompany.getCompanyName());
|
|
|
+ hlwOrderService.updateById(hlwOrder);
|
|
|
+ }
|
|
|
+ //付款明细增加明细流水号
|
|
|
+ hlwPaymentDetailList.get(i).setDtlSerialNo(dtlSerialNoList.getString(i));
|
|
|
+ }
|
|
|
+ //保存付款记录
|
|
|
+ HlwPayRecord hlwPayRecord = new HlwPayRecord();
|
|
|
+ hlwPayRecord.setPaymentId(hlwPaymentDetailList.get(0).getPaymentId());
|
|
|
+ hlwPayRecord.setAgpseq("");
|
|
|
+ hlwPayRecord.setYurref(yurref);
|
|
|
+ hlwPayRecord.setDetail(JSON.toJSONString(hlwPaymentDetailList));
|
|
|
+ hlwPayRecord.setDelFlag("0");
|
|
|
+ hlwPayRecordService.save(hlwPayRecord);
|
|
|
+ //更新付款单信息
|
|
|
+ //支付中
|
|
|
+ hlwPayment.setPaymentTime(new Date());
|
|
|
+ hlwPayment.setStatus(HlwConstant.PAYMENT_STATUS_PAY_ING);
|
|
|
+ updateById(hlwPayment);
|
|
|
+ /**
|
|
|
+ * 是否通过平台
|
|
|
+ */
|
|
|
+ if (hlwPayment.getIsThroughPlatform() == HlwConstant.PAYMENT_THROUGH_PLATFORM_NO) {
|
|
|
+ //更新企业账户信息
|
|
|
+ updateAccount(hlwPayment);
|
|
|
+ } else {
|
|
|
+ //更新A-B-C账户信息
|
|
|
+ updateAccountA_B(hlwPayment);
|
|
|
+ }
|
|
|
+ result.success("付款提交成功!等待银行返回结果");
|
|
|
+ try {
|
|
|
+ /**
|
|
|
+ * 推送消息
|
|
|
+ */
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ String title = "付款单" + hlwPaymentEntity.getPaymentCode();
|
|
|
+ String message = "共发放" + hlwPaymentDetailList.size() + "人,合计金额" + totalPayment + "元";
|
|
|
+ jsonObject.put("userId", "e9ca23d68d884d4ebb19d07889727dae");
|
|
|
+ jsonObject.put("title", title);
|
|
|
+ jsonObject.put("message", message);
|
|
|
+ sysBaseRemoteApi.sendUserByWebSocket(jsonObject);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.info("推送异常===,{}", e.getStackTrace());
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ result.error500("付款提交失败!");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ result.error500("付款提交失败!");
|
|
|
+ }
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
@@ -1119,6 +1157,25 @@ public class HlwPaymentServiceImpl extends ServiceImpl<HlwPaymentMapper, HlwPaym
|
|
|
|
|
|
//服务商信息
|
|
|
HlwSubcontractor hlwSubcontractor = hlwSubcontractorService.getById(hlwPayment.getSubcontractorId());
|
|
|
+ /**
|
|
|
+ * 银行通道(1:招商银行 2:宁波银行)
|
|
|
+ */
|
|
|
+ if (hlwSubcontractor.getBankType().equals(PayNbcbConst.bankType)) {
|
|
|
+ //宁波银行
|
|
|
+ result = nbPaySupplement(hlwPaymentDetailList, totalPaymenStr, hlwSubcontractor);
|
|
|
+ } else {
|
|
|
+ //招商银行
|
|
|
+ result = zhPaySupplement(hlwPaymentDetailList, totalPaymenStr, hlwSubcontractor);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 招商银行支付通道-补发
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Result<HlwPaymentDetail> zhPaySupplement(List<HlwPaymentDetail> hlwPaymentDetailList, String totalPaymenStr, HlwSubcontractor hlwSubcontractor) {
|
|
|
+ Result<HlwPaymentDetail> result = new Result<>();
|
|
|
//银行业务接口(代发工资)
|
|
|
JSONObject jsonObjectBody = PayRsaCommon.NTAGCAPY(hlwPaymentDetailList, totalPaymenStr, hlwSubcontractor);
|
|
|
if (jsonObjectBody != null) {
|
|
|
@@ -1162,6 +1219,58 @@ public class HlwPaymentServiceImpl extends ServiceImpl<HlwPaymentMapper, HlwPaym
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 宁波银行支付通道-补发
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Result<HlwPaymentDetail> nbPaySupplement(List<HlwPaymentDetail> hlwPaymentDetailList, String totalPaymenStr, HlwSubcontractor hlwSubcontractor) {
|
|
|
+ Result<HlwPaymentDetail> result = new Result<>();
|
|
|
+ //银行业务接口(代发工资)
|
|
|
+ JSONObject jsonObjectBody = PayNbcbCommon.NTAGCAPY(hlwPaymentDetailList, totalPaymenStr, hlwSubcontractor);
|
|
|
+ if (jsonObjectBody != null) {
|
|
|
+ //请求状态(对应payRecord表批次状态)(NTE: 银行处理中)
|
|
|
+ String retCode = jsonObjectBody.getString("retCode");
|
|
|
+ //流程实例号(对应payRecord表批次号)
|
|
|
+ JSONArray dtlSerialNoList = jsonObjectBody.getJSONArray("dtlSerialNoList");
|
|
|
+ //业务参考号
|
|
|
+ String yurref = jsonObjectBody.getString("yurref");
|
|
|
+ //银行处理返回成功
|
|
|
+ if (PayNbcbConst.SUCCESS.equals(retCode)) {
|
|
|
+ //获取当前登录用户
|
|
|
+ LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
+ for (int i = 0; i < hlwPaymentDetailList.size(); i++) {
|
|
|
+ HlwPaymentDetail hlwPaymentDetail = hlwPaymentDetailList.get(i);
|
|
|
+ //状态改为付款中
|
|
|
+ hlwPaymentDetail.setStatus(2);
|
|
|
+ hlwPaymentDetail.setIsSupplementPayment(1);
|
|
|
+ hlwPaymentDetail.setPaymentTime(new Date());
|
|
|
+ hlwPaymentDetail.setPaymentBy(sysUser.getUsername());
|
|
|
+ hlwPaymentDetail.setUpdateTime(new Date());
|
|
|
+ hlwPaymentDetailService.updateById(hlwPaymentDetail);
|
|
|
+
|
|
|
+ //付款明细增加明细流水号
|
|
|
+ hlwPaymentDetailList.get(i).setDtlSerialNo(dtlSerialNoList.getString(i));
|
|
|
+ }
|
|
|
+ //保存付款记录
|
|
|
+ HlwPayRecord hlwPayRecord = new HlwPayRecord();
|
|
|
+ hlwPayRecord.setPaymentId(hlwPaymentDetailList.get(0).getPaymentId());
|
|
|
+ hlwPayRecord.setPaymentDetailId(hlwPaymentDetailList.get(0).getId());
|
|
|
+ hlwPayRecord.setAgpseq("");
|
|
|
+ hlwPayRecord.setYurref(yurref);
|
|
|
+ hlwPayRecord.setDetail(JSON.toJSONString(hlwPaymentDetailList));
|
|
|
+ hlwPayRecord.setDelFlag("0");
|
|
|
+ hlwPayRecordService.save(hlwPayRecord);
|
|
|
+
|
|
|
+ result.success("提交成功!等待银行返回结果");
|
|
|
+ } else {
|
|
|
+ result.error500("付款提交失败!");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ result.error500("付款提交失败!");
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public Page<HlwPayment> companyBusinessDetailList(Page<HlwPayment> page, HlwPayment hlwPayment, QueryWrapper<HlwPayment> queryWrapper) {
|