|
@@ -7,7 +7,6 @@ import com.rongwe.zhsw.system.domain.SwBillingRecordDo;
|
|
|
import com.rongwe.zhsw.system.domain.SwUserManagementDo;
|
|
|
import com.rongwe.zhsw.system.vo.CreatePaymentRecordVo;
|
|
|
import com.rongwe.zhsw.system.vo.PaymentRocordVo;
|
|
|
-import com.rongwei.commonservice.service.impl.RedisServiceImpl;
|
|
|
import com.rongwei.rwcommon.base.BaseDo;
|
|
|
import com.rongwei.rwcommon.base.R;
|
|
|
import com.rongwei.rwcommon.base.exception.CustomException;
|
|
@@ -129,7 +128,9 @@ public class PaymentRecordServiceImpl implements PaymentRecordService {
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
+ @Transactional
|
|
|
public R createRecord(CreatePaymentRecordVo createPaymentRecordVo) {
|
|
|
+ try {
|
|
|
// 微信的openId
|
|
|
String currentWeChatOpenId = WeChatUtils.getCurrentWeChatOpenId();
|
|
|
String userNUMBER = createPaymentRecordVo.getUserNumber();
|
|
@@ -145,29 +146,36 @@ public class PaymentRecordServiceImpl implements PaymentRecordService {
|
|
|
if (StringUtils.isNotBlank(zdId)) {
|
|
|
unpaidDoList = swBillManagementUnpaidService.getBaseMapper().selectBatchIds(Arrays.asList(zdId.split(",")));
|
|
|
}
|
|
|
- // 生成缴费记录
|
|
|
- SwBillingRecordDo swBillingRecordDo = generateRecord(swUserManagementDo, unpaidDoList, createPaymentRecordVo.getPaymentAmount(),
|
|
|
- createPaymentRecordVo.getOrderNo(), currentWeChatOpenId);
|
|
|
|
|
|
- // 待缴账单转为已缴账单
|
|
|
- List<SwBillManagementPaidDo> bills = swBillingRecordService.createBills(unpaidDoList, swBillingRecordDo);
|
|
|
- dataUpdate(swBillingRecordDo,swUserManagementDo,bills,unpaidDoList);
|
|
|
+
|
|
|
+
|
|
|
+ // 生成缴费记录
|
|
|
+ SwBillingRecordDo swBillingRecordDo = generateRecord(swUserManagementDo, unpaidDoList, createPaymentRecordVo.getPaymentAmount(),
|
|
|
+ createPaymentRecordVo.getOrderNo(), currentWeChatOpenId);
|
|
|
+ // 待缴账单转为已缴账单
|
|
|
+ List<SwBillManagementPaidDo> bills = swBillingRecordService.createBills(unpaidDoList, swBillingRecordDo);
|
|
|
+ dataUpdate(swBillingRecordDo, swUserManagementDo, bills, unpaidDoList);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ log.error("缴费记录生成失败原因为:{}",e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
return R.ok();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 数据更新
|
|
|
*/
|
|
|
- @Transactional
|
|
|
- public void dataUpdate(SwBillingRecordDo swBillingRecordDo,SwUserManagementDo swUserManagementDo,List<SwBillManagementPaidDo> bills,
|
|
|
- List<SwBillManagementUnpaidDo> unpaidDoList){
|
|
|
+
|
|
|
+ public void dataUpdate(SwBillingRecordDo swBillingRecordDo, SwUserManagementDo swUserManagementDo, List<SwBillManagementPaidDo> bills,
|
|
|
+ List<SwBillManagementUnpaidDo> unpaidDoList) {
|
|
|
BigDecimal balanceChange = swBillingRecordDo.getAfterpaymentbalance().subtract(swUserManagementDo.getAccountbalance());
|
|
|
swUserManagementService.balanceAdd(swUserManagementDo.getId(), balanceChange);
|
|
|
swBillingRecordService.save(swBillingRecordDo);
|
|
|
- if(!bills.isEmpty()){
|
|
|
+ if (!bills.isEmpty()) {
|
|
|
swBillManagementPaidService.saveBatch(bills);
|
|
|
}
|
|
|
- if(!unpaidDoList.isEmpty()){
|
|
|
+ if (!unpaidDoList.isEmpty()) {
|
|
|
swBillManagementUnpaidService.getBaseMapper().deleteByIds(unpaidDoList.stream().map(SwBillManagementUnpaidDo::getId).collect(Collectors.toList()));
|
|
|
}
|
|
|
|
|
@@ -175,7 +183,7 @@ public class PaymentRecordServiceImpl implements PaymentRecordService {
|
|
|
|
|
|
|
|
|
public SwBillingRecordDo generateRecord(SwUserManagementDo swUserManagementDo, List<SwBillManagementUnpaidDo> unpaidDoList,
|
|
|
- BigDecimal paymentAmount,String orderNo,String openId) {
|
|
|
+ BigDecimal paymentAmount, String orderNo, String openId) {
|
|
|
Date now = new Date();
|
|
|
Calendar instance = Calendar.getInstance();
|
|
|
instance.setTime(now);
|
|
@@ -198,7 +206,7 @@ public class PaymentRecordServiceImpl implements PaymentRecordService {
|
|
|
swBillingRecordDo.setUsertype(swUserManagementDo.getUsertypeid());
|
|
|
/******************实缴******************/
|
|
|
swBillingRecordDo.setPaidin(paymentAmount);
|
|
|
- swBillingRecordService.calculateFees(unpaidDoList, swBillingRecordDo,swUserManagementDo);
|
|
|
+ swBillingRecordService.calculateFees(unpaidDoList, swBillingRecordDo, swUserManagementDo);
|
|
|
swBillingRecordDo.setPaymentmethod("微信");
|
|
|
// 微信支付
|
|
|
swBillingRecordDo.setDatasource("3");
|