|
|
@@ -1,6 +1,7 @@
|
|
|
package com.poteviohealth.ym.ipos.controller.feign;
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.poteviohealth.cgp.common.controller.BaseFeignController;
|
|
|
@@ -18,6 +19,7 @@ import com.poteviohealth.ym.ipos.service.*;
|
|
|
import com.poteviohealth.ym.ipos.utils.YmUtil;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.extern.log4j.Log4j2;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
@@ -39,6 +41,7 @@ import java.util.List;
|
|
|
@Controller
|
|
|
@RequestMapping("/ipos/feign")
|
|
|
@Api(tags = {"第三方-支付相关接口"})
|
|
|
+@Log4j2
|
|
|
public class IposFeignController extends BaseFeignController {
|
|
|
|
|
|
@Resource
|
|
|
@@ -109,6 +112,7 @@ public class IposFeignController extends BaseFeignController {
|
|
|
* 站长分账 = 剩余分账 * 分账比例
|
|
|
* 平台运营商分账 = 可分账 - 区域运营商分账 -团长分账 -站长分账
|
|
|
*/
|
|
|
+ log.info(JSON.toJSONString(list));
|
|
|
BigDecimal proportion = new BigDecimal(0.01);
|
|
|
List<SplitPay> returnList = Lists.newArrayList();
|
|
|
for (SplitInfo splitInfo : list) {
|
|
|
@@ -200,8 +204,8 @@ public class IposFeignController extends BaseFeignController {
|
|
|
|
|
|
}
|
|
|
}else if(detail.getBelong().equals(0)){
|
|
|
- //服务站
|
|
|
- if(StringUtils.isNotEmpty(detail.getServiceStationMerchantId()) && detail.getOrderType().equals(2)){
|
|
|
+ //服务商
|
|
|
+ if(StringUtils.isNotEmpty(detail.getServiceStationMerchantId()) && detail.getOrderType().equals(2) && !detail.getServiceStationId().equals(detail.getStationId())){
|
|
|
SplitRecordsDetail serviceStation = new SplitRecordsDetail();
|
|
|
serviceStation.setSplitId(records.getSplitId());
|
|
|
serviceStation.setSourceId(5);
|
|
|
@@ -223,30 +227,33 @@ public class IposFeignController extends BaseFeignController {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- }else if(StringUtils.isNotEmpty(detail.getSupplierMerchantId()) && detail.getOrderType().equals(1)){
|
|
|
+ }else if(StringUtils.isNotEmpty(detail.getSupplierMerchantId())){
|
|
|
//供应商
|
|
|
- boolean is_have = false;
|
|
|
- SplitRecordsDetail supplier = new SplitRecordsDetail();
|
|
|
- supplier.setSplitId(records.getSplitId());
|
|
|
- supplier.setSourceId(2);
|
|
|
- supplier.setMerchantId(detail.getSupplierMerchantId());
|
|
|
- for (SplitRecordsDetail splitRecordsDetail : details) {
|
|
|
- if(splitRecordsDetail.getMerchantId().equals(detail.getSupplierMerchantId())){
|
|
|
- supplier = splitRecordsDetail;
|
|
|
- is_have =true;
|
|
|
- break;
|
|
|
+ if(detail.getOrderType().equals(1) ||(detail.getOrderType().equals(2)&&detail.getStationId().equals(detail.getServiceStationId()))){
|
|
|
+ boolean is_have = false;
|
|
|
+ SplitRecordsDetail supplier = new SplitRecordsDetail();
|
|
|
+ supplier.setSplitId(records.getSplitId());
|
|
|
+ supplier.setSourceId(2);
|
|
|
+ supplier.setMerchantId(detail.getSupplierMerchantId());
|
|
|
+ for (SplitRecordsDetail splitRecordsDetail : details) {
|
|
|
+ if(splitRecordsDetail.getMerchantId().equals(detail.getSupplierMerchantId())){
|
|
|
+ supplier = splitRecordsDetail;
|
|
|
+ is_have =true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- supplierAmount = supplierAmount.add(new BigDecimal(detail.getSettlementPrice()));
|
|
|
- detail.setPrice(detail.getPrice()-detail.getSettlementPrice());
|
|
|
- if (supplierAmount.compareTo(BigDecimal.ZERO) == 1) {
|
|
|
- supplier.setDivAmt(supplierAmount.toString());
|
|
|
- if(!is_have){
|
|
|
- details.add(supplier);
|
|
|
+ supplierAmount = supplierAmount.add(new BigDecimal(detail.getSettlementPrice()));
|
|
|
+ detail.setPrice(detail.getPrice()-detail.getSettlementPrice());
|
|
|
+ if (supplierAmount.compareTo(BigDecimal.ZERO) == 1) {
|
|
|
+ supplier.setDivAmt(supplierAmount.toString());
|
|
|
+ if(!is_have){
|
|
|
+ details.add(supplier);
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
+ }
|
|
|
/**
|
|
|
* 3.分成
|
|
|
*/
|
|
|
@@ -275,7 +282,7 @@ public class IposFeignController extends BaseFeignController {
|
|
|
}
|
|
|
|
|
|
//团长
|
|
|
- if(detail.getGroupCommissionMoney() != null && detail.getGroupCommissionMoney()>0L){
|
|
|
+ if(detail.getGroupCommissionMoney() != null && detail.getGroupCommissionMoney()>0L &&StringUtils.isNotBlank(detail.getGroupLeaderMerchantId())){
|
|
|
SplitRecordsDetail tz = new SplitRecordsDetail();
|
|
|
tz.setSplitId(records.getSplitId());
|
|
|
tz.setSourceId(6);
|
|
|
@@ -298,12 +305,12 @@ public class IposFeignController extends BaseFeignController {
|
|
|
}
|
|
|
}
|
|
|
//站长
|
|
|
- if(detail.getStationmasterCommissionMoney() != null && detail.getStationmasterCommissionMoney()>0L){
|
|
|
+ if(detail.getStationmasterCommissionMoney() != null && detail.getStationmasterCommissionMoney()>0L&&StringUtils.isNotBlank(detail.getStationmasterMerchantId())){
|
|
|
SplitRecordsDetail station = new SplitRecordsDetail();
|
|
|
station.setSplitId(records.getSplitId());
|
|
|
station.setSourceId(5);
|
|
|
station.setMerchantId(detail.getStationmasterMerchantId());
|
|
|
- boolean is_have = false;
|
|
|
+ Boolean is_have = false;
|
|
|
for (SplitRecordsDetail splitRecordsDetail : details) {
|
|
|
if(splitRecordsDetail.getMerchantId().equals(detail.getStationmasterMerchantId())){
|
|
|
station = splitRecordsDetail;
|
|
|
@@ -325,7 +332,6 @@ public class IposFeignController extends BaseFeignController {
|
|
|
ptyysAmount = ptyysAmount.add(new BigDecimal(detail.getPrice()));
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
pt.setDivAmt(String.valueOf(ptAmount.longValue()));
|
|
|
details.add(pt);
|
|
|
|
|
|
@@ -336,10 +342,10 @@ public class IposFeignController extends BaseFeignController {
|
|
|
ptyys.setMerchantId(splitInfo.getOperatorMerchantId());
|
|
|
ptyys.setDivAmt(ptyysAmount.toString());
|
|
|
details.add(ptyys);
|
|
|
- /*VaultsResponse vaultsResponse = splitService.delayConfirm(records,details);
|
|
|
+ VaultsResponse vaultsResponse = splitService.delayConfirm(records,details);
|
|
|
if(!vaultsResponse.validate()){
|
|
|
records.setComment(vaultsResponse.getMessage());
|
|
|
- }*/
|
|
|
+ }
|
|
|
records.setStatus(2);
|
|
|
splitRecordsService.save(records);
|
|
|
splitRecordsDetailService.saveBatch(details);
|