|
@@ -15,6 +15,7 @@ import com.caimei365.order.model.bo.VipRecordBo;
|
|
|
import com.caimei365.order.model.dto.PayDto;
|
|
|
import com.caimei365.order.model.dto.PayLinkDto;
|
|
|
import com.caimei365.order.model.enums.OrderStatus;
|
|
|
+import com.caimei365.order.model.enums.ReceivablesType;
|
|
|
import com.caimei365.order.model.po.*;
|
|
|
import com.caimei365.order.model.vo.*;
|
|
|
import com.caimei365.order.service.PayOrderService;
|
|
@@ -293,6 +294,9 @@ public class PayOrderServiceImpl implements PayOrderService {
|
|
|
if (3 == discernReceipt.getReceiptStatus()) {
|
|
|
receiptAmount.set(MathUtil.add(receiptAmount.get(), discernReceipt.getAssociateAmount()).doubleValue());
|
|
|
}
|
|
|
+ if (null != discernReceipt.getPayType()) {
|
|
|
+ discernReceipt.setPayTypeStr(ReceivablesType.getReceivablesType(discernReceipt.getPayType()));
|
|
|
+ }
|
|
|
});
|
|
|
if (offlineFlag.get()) {
|
|
|
return ResponseJson.error("已经线下支付过,只能线下支付!", null);
|
|
@@ -339,18 +343,26 @@ public class PayOrderServiceImpl implements PayOrderService {
|
|
|
//能否线上判断付供应商是否大于订单金额
|
|
|
// orderCommonService.getDiscernReceiptAndSetOrder(order);
|
|
|
// boolean payButton = order.isPayButton();
|
|
|
- // 总成本>应付 不能线上
|
|
|
- //todo 判断线上/线下余额
|
|
|
- Double userMoney = orderCommonMapper.findUserMoney(orderId);
|
|
|
- Double onlineMoney = orderCommonMapper.findOnlineMoney(orderId);
|
|
|
- userMoney = userMoney == null ? 0 : userMoney;
|
|
|
- onlineMoney = onlineMoney == null ? 0 : onlineMoney;
|
|
|
- if (MathUtil.compare(totalCostPrice, order.getPayableAmount()) > 0 || order.getPayableAmount() <= 0.01) {
|
|
|
- map.put("onlinePay", 2);
|
|
|
- } else if (userMoney > 0 && onlineMoney > 0 && !"31".equals(order.getStatus())) {
|
|
|
- //当线上余额和线下余额两者都抵扣了但只抵扣了部分订单金额,订单只能走线下支付,点击提交订单,跳转到线下支付页面
|
|
|
+
|
|
|
+ //判断线上/线下余额
|
|
|
+// Double userMoney = orderCommonMapper.findUserMoney(orderId);
|
|
|
+// Double onlineMoney = orderCommonMapper.findOnlineMoney(orderId);
|
|
|
+// userMoney = userMoney == null ? 0 : userMoney;
|
|
|
+// onlineMoney = onlineMoney == null ? 0 : onlineMoney;
|
|
|
+// if (MathUtil.compare(totalCostPrice, order.getPayableAmount()) > 0 || order.getPayableAmount() <= 0.01) {
|
|
|
+// map.put("onlinePay", 2);
|
|
|
+// } else if (userMoney > 0 && onlineMoney > 0 && !"31".equals(order.getStatus())) {
|
|
|
+// //当线上余额和线下余额两者都抵扣了但只抵扣了部分订单金额,订单只能走线下支付,点击提交订单,跳转到线下支付页面
|
|
|
+// map.put("onlinePay", 2);
|
|
|
+// } else {
|
|
|
+// map.put("onlinePay", 1);
|
|
|
+// }
|
|
|
+ //线上支付优化,订单商品中有没设置分帐帐号的无法线上
|
|
|
+ Integer num = orderCommonMapper.findSplitCode(orderId);
|
|
|
+ if (num > 0) {
|
|
|
map.put("onlinePay", 2);
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ if (0 == num) {
|
|
|
map.put("onlinePay", 1);
|
|
|
}
|
|
|
return ResponseJson.success(map);
|
|
@@ -408,7 +420,7 @@ public class PayOrderServiceImpl implements PayOrderService {
|
|
|
Integer mouth = payOrderMapper.getVipPackageDurationById(record.getPackageId());
|
|
|
orderPayLink.setVipMonth(mouth);
|
|
|
orderPayLink.setUnpaidAmount(price);
|
|
|
- }else if (null != payLinkDto.getAuthVipRecordId()){
|
|
|
+ } else if (null != payLinkDto.getAuthVipRecordId()) {
|
|
|
// 获取认证通会员套餐记录
|
|
|
VipRecordBo record = payOrderMapper.getAuthVipRecord(payLinkDto.getAuthVipRecordId());
|
|
|
// 获取认证通会员套餐信息
|
|
@@ -622,14 +634,38 @@ public class PayOrderServiceImpl implements PayOrderService {
|
|
|
PayParamBo payParam = new PayParamBo();
|
|
|
// payDto -> payParam
|
|
|
BeanUtils.copyProperties(payDto, payParam);
|
|
|
- //支付宝支付
|
|
|
+ //银联支付
|
|
|
payParam.setPayWay("UNIONPAY");
|
|
|
+ //银联网关
|
|
|
payParam.setPayType("GATEWAY_UNIONPAY");
|
|
|
payParam.setNotifyUrl(notifyUrl);
|
|
|
log.info("【银联支付】>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>orderId:" + payParam.getOrderId());
|
|
|
return toPayOrder(payParam, headers);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 银联转账支付
|
|
|
+ *
|
|
|
+ * @param payDto {
|
|
|
+ * orderId 订单ID
|
|
|
+ * payAmount 支付金额,单位分,必须大于2
|
|
|
+ * }
|
|
|
+ * @param headers HttpHeaders
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResponseJson<JSONObject> payByUnion(PayDto payDto, HttpHeaders headers) {
|
|
|
+ PayParamBo payParam = new PayParamBo();
|
|
|
+ // payDto -> payParam
|
|
|
+ BeanUtils.copyProperties(payDto, payParam);
|
|
|
+ //银联支付
|
|
|
+ payParam.setPayWay("UNIONPAY");
|
|
|
+ //银联转账
|
|
|
+ payParam.setPayType("TRANSFER_UNIONPAY");
|
|
|
+ payParam.setNotifyUrl(notifyUrl);
|
|
|
+ log.info("【银联转账支付】>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>orderId:" + payParam.getOrderId());
|
|
|
+ return toPayOrder(payParam, headers);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 订单线上支付
|
|
|
*/
|
|
@@ -682,13 +718,13 @@ public class PayOrderServiceImpl implements PayOrderService {
|
|
|
json.put("userIp", userIp);
|
|
|
json.put("returnUrl", payParam.getReturnUrl());
|
|
|
json.put("notifyUrl", payParam.getNotifyUrl());
|
|
|
- if (org.apache.commons.lang.StringUtils.isNotBlank(payParam.getBankCode())) {
|
|
|
+ if (StringUtils.isNotBlank(payParam.getBankCode())) {
|
|
|
json.put("bankCode", payParam.getBankCode());
|
|
|
}
|
|
|
- if (org.apache.commons.lang.StringUtils.isNotBlank(payParam.getUserType())) {
|
|
|
+ if (StringUtils.isNotBlank(payParam.getUserType())) {
|
|
|
json.put("userType", payParam.getUserType());
|
|
|
}
|
|
|
- if (org.apache.commons.lang.StringUtils.isNotBlank(payParam.getOpenId())) {
|
|
|
+ if (StringUtils.isNotBlank(payParam.getOpenId())) {
|
|
|
json.put("openId", payParam.getOpenId());
|
|
|
}
|
|
|
String environment = "";
|
|
@@ -1035,18 +1071,18 @@ public class PayOrderServiceImpl implements PayOrderService {
|
|
|
*/
|
|
|
@Override
|
|
|
public void delayedSplitting(String callUrl) {
|
|
|
- log.info("【延时分账】>>>>>>>>>>延时分账,每一小时执行一次");
|
|
|
+// log.info("【延时分账】>>>>>>>>>>延时分账,每一小时执行一次");
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
calendar.setTime(new Date());
|
|
|
- //测试停掉
|
|
|
- calendar.add(Calendar.DAY_OF_MONTH, -1);
|
|
|
+// 自动分账切手动分账,不需要24小时之前的单
|
|
|
+// calendar.add(Calendar.DAY_OF_MONTH, -1);
|
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
String currentTime = format.format(calendar.getTime());
|
|
|
// 查询未分账已支付收款
|
|
|
List<OrderReceiptRelationPo> orderRelations = payOrderMapper.getUndividedPaidReceipt(currentTime);
|
|
|
// 上面过滤了余额抵扣, 把线上余额抵扣单补充到list里面,线上余额抵扣的金额视为正常收款金额进行分账
|
|
|
List<OrderReceiptRelationPo> onlineRelations = payOrderMapper.getOnlineBalance(currentTime);
|
|
|
- if (null != onlineRelations && orderRelations.size() > 0) {
|
|
|
+ if (null != onlineRelations && onlineRelations.size() > 0) {
|
|
|
// 过滤不足分账金额的单
|
|
|
onlineRelations.removeIf(o -> o.getAssociateAmount() < 0.01);
|
|
|
// 把线上余额抵扣订单加入分账
|
|
@@ -1063,6 +1099,9 @@ public class PayOrderServiceImpl implements PayOrderService {
|
|
|
// 网银支付
|
|
|
payParam.setPayWay("UNIONPAY");
|
|
|
}
|
|
|
+ if (20 == orderRelation.getPayType()) {
|
|
|
+ payParam.setPayWay("TRANSFER");
|
|
|
+ }
|
|
|
List<SplitAccountPo> splitBillDetail = setSplitAccountDetail(order, payParam);
|
|
|
List<Map<String, String>> maps = new ArrayList<>();
|
|
|
//供应商子商户金额
|
|
@@ -1154,7 +1193,7 @@ public class PayOrderServiceImpl implements PayOrderService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * todo 佣金要改进入采美网络
|
|
|
+ *
|
|
|
* 分账详情
|
|
|
*/
|
|
|
private List<SplitAccountPo> setSplitAccountDetail(OrderVo order, PayParamBo payParam) {
|
|
@@ -1167,6 +1206,9 @@ public class PayOrderServiceImpl implements PayOrderService {
|
|
|
double procedureFee;
|
|
|
if ("UNIONPAY".equals(payParam.getPayWay())) {
|
|
|
procedureFee = 8.00;
|
|
|
+ } else if ("TRANSFER".equals(payParam.getPayWay())) {
|
|
|
+ //银联转账12
|
|
|
+ procedureFee = 12.00;
|
|
|
} else {
|
|
|
//手续费
|
|
|
procedureFee = MathUtil.mul(payAmount, 0.0038, 2).doubleValue();
|
|
@@ -1211,28 +1253,30 @@ public class PayOrderServiceImpl implements PayOrderService {
|
|
|
// 该商品设置了商户号
|
|
|
splitAccount.setType(4);
|
|
|
splitAccount.setSubUserNo(orderProduct.getSplitCode());
|
|
|
- } else {
|
|
|
- //含税或者不含税看票
|
|
|
- if (0 == orderProduct.getIncludedTax() || 1 == orderProduct.getIncludedTax()) {
|
|
|
- if (1 == orderProduct.getInvoiceType()) {
|
|
|
- // 开增值税发票,则分账到公账-专票
|
|
|
- splitAccount.setType(1);
|
|
|
- splitAccount.setSubUserNo(PayUtil.publicAccountNo);
|
|
|
- } else if (2 == orderProduct.getInvoiceType()) {
|
|
|
- // 开普通发票,则分账到公账-普票
|
|
|
- splitAccount.setType(3);
|
|
|
- splitAccount.setSubUserNo(PayUtil.commonInvoiceNo);
|
|
|
- } else {
|
|
|
- // 不能开票,则分账到私账-无票
|
|
|
- splitAccount.setType(2);
|
|
|
- splitAccount.setSubUserNo(PayUtil.privateAccountNo);
|
|
|
- }
|
|
|
- } else {
|
|
|
- //未知或者其他直接私账
|
|
|
- splitAccount.setType(2);
|
|
|
- splitAccount.setSubUserNo(PayUtil.privateAccountNo);
|
|
|
- }
|
|
|
}
|
|
|
+ //支付优化放弃根据税票分账,只有商品有商户号才参与分账(先别删)
|
|
|
+// else {
|
|
|
+// //含税或者不含税看票
|
|
|
+// if (0 == orderProduct.getIncludedTax() || 1 == orderProduct.getIncludedTax()) {
|
|
|
+// if (1 == orderProduct.getInvoiceType()) {
|
|
|
+// // 开增值税发票,则分账到公账-专票
|
|
|
+// splitAccount.setType(1);
|
|
|
+// splitAccount.setSubUserNo(PayUtil.publicAccountNo);
|
|
|
+// } else if (2 == orderProduct.getInvoiceType()) {
|
|
|
+// // 开普通发票,则分账到公账-普票
|
|
|
+// splitAccount.setType(3);
|
|
|
+// splitAccount.setSubUserNo(PayUtil.commonInvoiceNo);
|
|
|
+// } else {
|
|
|
+// // 不能开票,则分账到私账-无票
|
|
|
+// splitAccount.setType(2);
|
|
|
+// splitAccount.setSubUserNo(PayUtil.privateAccountNo);
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// //未知或者其他直接私账
|
|
|
+// splitAccount.setType(2);
|
|
|
+// splitAccount.setSubUserNo(PayUtil.privateAccountNo);
|
|
|
+// }
|
|
|
+// }
|
|
|
log.info("成本分账参数------------->" + splitAccount);
|
|
|
list.add(splitAccount);
|
|
|
}
|
|
@@ -1266,11 +1310,13 @@ public class PayOrderServiceImpl implements PayOrderService {
|
|
|
//供应商拥有子商户号
|
|
|
splitAccount.setType(4);
|
|
|
splitAccount.setSubUserNo(commercialCode);
|
|
|
- } else {
|
|
|
- //私账
|
|
|
- splitAccount.setType(2);
|
|
|
- splitAccount.setSubUserNo(PayUtil.privateAccountNo);
|
|
|
}
|
|
|
+ //无分账号不参与分账,这里供应商可以有多个分帐号,取第一个
|
|
|
+// else {
|
|
|
+// //私账
|
|
|
+// splitAccount.setType(2);
|
|
|
+// splitAccount.setSubUserNo(PayUtil.privateAccountNo);
|
|
|
+// }
|
|
|
log.info("付供应商运费分账参数------------->" + splitAccount);
|
|
|
list.add(splitAccount);
|
|
|
}
|
|
@@ -1421,6 +1467,7 @@ public class PayOrderServiceImpl implements PayOrderService {
|
|
|
log.info("---------------优惠券商品兑换结束--------------------------->");
|
|
|
}
|
|
|
|
|
|
+
|
|
|
private void insertCoupon(CouponCheckVo check) {
|
|
|
Integer couponId = 7174 == check.getProductId() ? 44 : 49;
|
|
|
CouponRecordPo couponRecordPo = new CouponRecordPo();
|