提交代码

master
胡锐 5 months ago
parent f09e488857
commit f471728554
  1. 16
      cweb/src/main/java/com/cweb/controller/order/GasOrderController.java
  2. 14
      cweb/src/main/java/com/cweb/controller/order/OrderPayController.java
  3. 1
      cweb/src/main/java/com/cweb/controller/order/OrderPayNotifyController.java
  4. 4
      schedule/src/main/java/com/hfkj/consumer/OrderProfitSharingConsumer.java
  5. 57
      schedule/src/main/java/com/hfkj/schedule/OrderSettleSchedule.java
  6. 13
      service/src/main/java/com/hfkj/dao/BsGasOrderMapper.java
  7. 28
      service/src/main/java/com/hfkj/dao/BsGasOrderSqlProvider.java
  8. 36
      service/src/main/java/com/hfkj/dao/BsOrderSettleMapper.java
  9. 14
      service/src/main/java/com/hfkj/dao/BsOrderSettleSqlProvider.java
  10. 32
      service/src/main/java/com/hfkj/entity/BsGasOrder.java
  11. 140
      service/src/main/java/com/hfkj/entity/BsGasOrderExample.java
  12. 16
      service/src/main/java/com/hfkj/entity/BsOrderSettle.java
  13. 70
      service/src/main/java/com/hfkj/entity/BsOrderSettleExample.java
  14. 110
      service/src/main/java/com/hfkj/pay/HuiPayService.java
  15. 16
      service/src/main/java/com/hfkj/service/gas/BsGasOrderService.java
  16. 22
      service/src/main/java/com/hfkj/service/gas/impl/BsGasOrderServiceImpl.java
  17. 27
      service/src/main/java/com/hfkj/service/order/BsOrderSettleLedgerService.java
  18. 18
      service/src/main/java/com/hfkj/service/order/BsOrderSettleService.java
  19. 2
      service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java
  20. 18
      service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java
  21. 43
      service/src/main/java/com/hfkj/service/order/impl/BsOrderSettleLedgerServiceImpl.java
  22. 62
      service/src/main/java/com/hfkj/service/order/impl/BsOrderSettleServiceImpl.java

@ -12,6 +12,7 @@ import com.hfkj.model.UserSessionObject;
import com.hfkj.service.gas.BsGasOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
@ -60,11 +61,22 @@ public class GasOrderController {
@RequestMapping(value="/queryOilOrder",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询加油订单详情")
public ResponseData queryOilOrder(@RequestParam(name = "orderNo", required = true) String orderNo) {
public ResponseData queryOilOrder(@RequestParam(name = "orderNo", required = false) String orderNo,
@RequestParam(name = "paySerialNo", required = false) String paySerialNo,
@RequestParam(name = "payChannelOrderNo", required = false) String payChannelOrderNo) {
try {
if (StringUtils.isNotBlank(orderNo)) {
return ResponseMsgUtil.success(gasOrderService.getDetailByOrderNo(orderNo));
} else if (StringUtils.isNotBlank(paySerialNo)) {
return ResponseMsgUtil.success(gasOrderService.getDetailByPaySerialNo(paySerialNo));
} else if (StringUtils.isNotBlank(payChannelOrderNo)) {
return ResponseMsgUtil.success(gasOrderService.getDetailByPayChannelOrderNo(payChannelOrderNo));
}
return ResponseMsgUtil.success(null);
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);

@ -5,6 +5,8 @@ import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.common.security.UserCenter;
import com.hfkj.common.utils.DateUtil;
import com.hfkj.common.utils.RandomUtils;
import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.entity.BsMerchantPayConfig;
import com.hfkj.entity.BsOrderSettle;
@ -18,6 +20,7 @@ import com.hfkj.service.order.BsOrderChildService;
import com.hfkj.service.order.BsOrderService;
import com.hfkj.service.order.BsOrderSettleService;
import com.hfkj.sysenum.order.OrderPayTypeEnum;
import com.hfkj.sysenum.order.OrderSettleLedgerStatusEnum;
import com.hfkj.sysenum.order.OrderStatusEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -31,6 +34,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.Date;
import java.util.Map;
/**
@ -90,6 +94,11 @@ public class OrderPayController {
orderSettle.setSettleMerKey(merPay.getChannelMerKey());
orderSettle.setSettleAmount(order.getPayRealPrice());
orderSettle.setLedgerFlag(merPay.getLedgerAccountFlag());
if (orderSettle.getLedgerFlag()) {
orderSettle.setLedgerAmount(order.getPayRealPrice());
orderSettle.setLedgerOrderNo("L"+ DateUtil.date2String(new Date(), "yyMMddHHmmss") + RandomUtils.number(3, false));
orderSettle.setLedgerStatus(OrderSettleLedgerStatusEnum.status0.getCode());
}
orderSettleService.editData(orderSettle);
return ResponseMsgUtil.success(preorder);
@ -139,6 +148,11 @@ public class OrderPayController {
orderSettle.setSettleMerKey(merPay.getChannelMerKey());
orderSettle.setSettleAmount(order.getPayRealPrice());
orderSettle.setLedgerFlag(merPay.getLedgerAccountFlag());
if (orderSettle.getLedgerFlag()) {
orderSettle.setLedgerAmount(order.getPayRealPrice());
orderSettle.setLedgerOrderNo("L"+ DateUtil.date2String(new Date(), "yyMMddHHmmss") + RandomUtils.number(3, false));
orderSettle.setLedgerStatus(OrderSettleLedgerStatusEnum.status0.getCode());
}
orderSettleService.editData(orderSettle);
return ResponseMsgUtil.success(preorder);

@ -59,6 +59,7 @@ public class OrderPayNotifyController {
order.setPayChannel(OrderPayChannelEnum.type1.getCode());
order.setPayTime(new Date(dataObject.getLong("payTime")));
order.setPaySerialNo(dataObject.getString("accTradeNo"));
order.setPayChannelOrderNo(dataObject.getString("platformTradeNo"));
orderService.orderPaySuccessHandle(order);
}
log.info("处理业务完成");

@ -2,6 +2,7 @@ package com.hfkj.consumer;
import com.hfkj.model.order.OrderModel;
import com.hfkj.service.order.BsOrderService;
import com.hfkj.service.order.BsOrderSettleService;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
@ -15,10 +16,11 @@ import javax.annotation.Resource;
public class OrderProfitSharingConsumer implements RocketMQListener<OrderModel> {
@Resource
private BsOrderService orderService;
private BsOrderSettleService orderSettleService;
@Override
public void onMessage(OrderModel order) {
orderSettleService.separate(orderSettleService.getData(order.getOrderNo()));
}
}

@ -0,0 +1,57 @@
package com.hfkj.schedule;
import com.alibaba.fastjson.JSONObject;
import com.hfkj.entity.BsOrderSettle;
import com.hfkj.entity.BsOrderSettleLedger;
import com.hfkj.pay.HuiPayService;
import com.hfkj.service.order.BsOrderSettleLedgerService;
import com.hfkj.service.order.BsOrderSettleService;
import com.hfkj.sysenum.order.OrderSettleLedgerStatusEnum;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 订单结算业务
* @className: OrderSettleService
* @author: HuRui
* @date: 2024/6/25
**/
@Component
public class OrderSettleSchedule {
@Resource
private BsOrderSettleService orderSettleService;
@Resource
private BsOrderSettleLedgerService orderSettleLedgerService;
@Scheduled(cron="0 0/3 * * * ?") //每3分钟执行一次
public void getBlxCoupon() {
Map<String,Object> param = new HashMap<>();
param.put("ledgerStatus", OrderSettleLedgerStatusEnum.status2.getCode());
List<BsOrderSettle> orderSettleList = orderSettleService.getList(param);
for (BsOrderSettle orderSettle : orderSettleList) {
// 查询分账处理结果
JSONObject obj = HuiPayService.profitSharingQuery(orderSettle);
if (obj.getString("return_code").equals("000000")) {
// 1:已完成 2:处理中 3:已受理 4:失败
if (obj.getInteger("status") == 1) {
orderSettle.setLedgerStatus(OrderSettleLedgerStatusEnum.status1.getCode());
orderSettleService.editData(orderSettle);
// 分账接收方
List<BsOrderSettleLedger> ledgerList = orderSettleLedgerService.getListBySettleId(orderSettle.getId());
for (BsOrderSettleLedger ledger : ledgerList) {
ledger.setStatus(1);
orderSettleLedgerService.editData(ledger);
}
} else if (obj.getInteger("status") == 4) {
orderSettle.setLedgerStatus(OrderSettleLedgerStatusEnum.status4.getCode());
orderSettleService.editData(orderSettle);
}
}
}
}
}

@ -58,6 +58,7 @@ public interface BsGasOrderMapper extends BsGasOrderMapperExt {
"gas_class_group_id, gas_class_group_name, ",
"gas_class_group_task_id, gas_staff_id, ",
"gas_staff_name, pay_type, ",
"pay_serial_no, pay_channel_order_no, ",
"`status`, create_time, ",
"cancel_time, pay_time, ",
"refund_time, refund_remarks, ",
@ -82,6 +83,7 @@ public interface BsGasOrderMapper extends BsGasOrderMapperExt {
"#{gasClassGroupId,jdbcType=BIGINT}, #{gasClassGroupName,jdbcType=VARCHAR}, ",
"#{gasClassGroupTaskId,jdbcType=BIGINT}, #{gasStaffId,jdbcType=BIGINT}, ",
"#{gasStaffName,jdbcType=VARCHAR}, #{payType,jdbcType=INTEGER}, ",
"#{paySerialNo,jdbcType=VARCHAR}, #{payChannelOrderNo,jdbcType=VARCHAR}, ",
"#{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, ",
"#{cancelTime,jdbcType=TIMESTAMP}, #{payTime,jdbcType=TIMESTAMP}, ",
"#{refundTime,jdbcType=TIMESTAMP}, #{refundRemarks,jdbcType=VARCHAR}, ",
@ -137,6 +139,8 @@ public interface BsGasOrderMapper extends BsGasOrderMapperExt {
@Result(column="gas_staff_id", property="gasStaffId", jdbcType=JdbcType.BIGINT),
@Result(column="gas_staff_name", property="gasStaffName", jdbcType=JdbcType.VARCHAR),
@Result(column="pay_type", property="payType", jdbcType=JdbcType.INTEGER),
@Result(column="pay_serial_no", property="paySerialNo", jdbcType=JdbcType.VARCHAR),
@Result(column="pay_channel_order_no", property="payChannelOrderNo", jdbcType=JdbcType.VARCHAR),
@Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="cancel_time", property="cancelTime", jdbcType=JdbcType.TIMESTAMP),
@ -161,8 +165,9 @@ public interface BsGasOrderMapper extends BsGasOrderMapperExt {
"gas_gun_no, gas_oil_type, gas_price_official, gas_price_gun, gas_price_vip, ",
"gas_price_platform, gas_oil_liters, gas_discount, gas_oil_subsidy, gas_liters_preferences, ",
"gas_price_preferences, gas_class_group_id, gas_class_group_name, gas_class_group_task_id, ",
"gas_staff_id, gas_staff_name, pay_type, `status`, create_time, cancel_time, ",
"pay_time, refund_time, refund_remarks, ext_1, ext_2, ext_3, ext_4, ext_5, ext_6",
"gas_staff_id, gas_staff_name, pay_type, pay_serial_no, pay_channel_order_no, ",
"`status`, create_time, cancel_time, pay_time, refund_time, refund_remarks, ext_1, ",
"ext_2, ext_3, ext_4, ext_5, ext_6",
"from bs_gas_order",
"where id = #{id,jdbcType=BIGINT}"
})
@ -207,6 +212,8 @@ public interface BsGasOrderMapper extends BsGasOrderMapperExt {
@Result(column="gas_staff_id", property="gasStaffId", jdbcType=JdbcType.BIGINT),
@Result(column="gas_staff_name", property="gasStaffName", jdbcType=JdbcType.VARCHAR),
@Result(column="pay_type", property="payType", jdbcType=JdbcType.INTEGER),
@Result(column="pay_serial_no", property="paySerialNo", jdbcType=JdbcType.VARCHAR),
@Result(column="pay_channel_order_no", property="payChannelOrderNo", jdbcType=JdbcType.VARCHAR),
@Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="cancel_time", property="cancelTime", jdbcType=JdbcType.TIMESTAMP),
@ -272,6 +279,8 @@ public interface BsGasOrderMapper extends BsGasOrderMapperExt {
"gas_staff_id = #{gasStaffId,jdbcType=BIGINT},",
"gas_staff_name = #{gasStaffName,jdbcType=VARCHAR},",
"pay_type = #{payType,jdbcType=INTEGER},",
"pay_serial_no = #{paySerialNo,jdbcType=VARCHAR},",
"pay_channel_order_no = #{payChannelOrderNo,jdbcType=VARCHAR},",
"`status` = #{status,jdbcType=INTEGER},",
"create_time = #{createTime,jdbcType=TIMESTAMP},",
"cancel_time = #{cancelTime,jdbcType=TIMESTAMP},",

@ -184,6 +184,14 @@ public class BsGasOrderSqlProvider {
sql.VALUES("pay_type", "#{payType,jdbcType=INTEGER}");
}
if (record.getPaySerialNo() != null) {
sql.VALUES("pay_serial_no", "#{paySerialNo,jdbcType=VARCHAR}");
}
if (record.getPayChannelOrderNo() != null) {
sql.VALUES("pay_channel_order_no", "#{payChannelOrderNo,jdbcType=VARCHAR}");
}
if (record.getStatus() != null) {
sql.VALUES("`status`", "#{status,jdbcType=INTEGER}");
}
@ -281,6 +289,8 @@ public class BsGasOrderSqlProvider {
sql.SELECT("gas_staff_id");
sql.SELECT("gas_staff_name");
sql.SELECT("pay_type");
sql.SELECT("pay_serial_no");
sql.SELECT("pay_channel_order_no");
sql.SELECT("`status`");
sql.SELECT("create_time");
sql.SELECT("cancel_time");
@ -470,6 +480,14 @@ public class BsGasOrderSqlProvider {
sql.SET("pay_type = #{record.payType,jdbcType=INTEGER}");
}
if (record.getPaySerialNo() != null) {
sql.SET("pay_serial_no = #{record.paySerialNo,jdbcType=VARCHAR}");
}
if (record.getPayChannelOrderNo() != null) {
sql.SET("pay_channel_order_no = #{record.payChannelOrderNo,jdbcType=VARCHAR}");
}
if (record.getStatus() != null) {
sql.SET("`status` = #{record.status,jdbcType=INTEGER}");
}
@ -566,6 +584,8 @@ public class BsGasOrderSqlProvider {
sql.SET("gas_staff_id = #{record.gasStaffId,jdbcType=BIGINT}");
sql.SET("gas_staff_name = #{record.gasStaffName,jdbcType=VARCHAR}");
sql.SET("pay_type = #{record.payType,jdbcType=INTEGER}");
sql.SET("pay_serial_no = #{record.paySerialNo,jdbcType=VARCHAR}");
sql.SET("pay_channel_order_no = #{record.payChannelOrderNo,jdbcType=VARCHAR}");
sql.SET("`status` = #{record.status,jdbcType=INTEGER}");
sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}");
sql.SET("cancel_time = #{record.cancelTime,jdbcType=TIMESTAMP}");
@ -744,6 +764,14 @@ public class BsGasOrderSqlProvider {
sql.SET("pay_type = #{payType,jdbcType=INTEGER}");
}
if (record.getPaySerialNo() != null) {
sql.SET("pay_serial_no = #{paySerialNo,jdbcType=VARCHAR}");
}
if (record.getPayChannelOrderNo() != null) {
sql.SET("pay_channel_order_no = #{payChannelOrderNo,jdbcType=VARCHAR}");
}
if (record.getStatus() != null) {
sql.SET("`status` = #{status,jdbcType=INTEGER}");
}

@ -39,18 +39,20 @@ public interface BsOrderSettleMapper extends BsOrderSettleMapperExt {
int deleteByPrimaryKey(Long id);
@Insert({
"insert into bs_order_settle (order_no, settle_mer_no, ",
"settle_mer_key, settle_amount, ",
"ledger_flag, ledger_order_no, ",
"ledger_amount, ledger_status, ",
"create_time, update_time, ",
"ext_1, ext_2, ext_3)",
"values (#{orderNo,jdbcType=VARCHAR}, #{settleMerNo,jdbcType=VARCHAR}, ",
"#{settleMerKey,jdbcType=VARCHAR}, #{settleAmount,jdbcType=DECIMAL}, ",
"#{ledgerFlag,jdbcType=BIT}, #{ledgerOrderNo,jdbcType=VARCHAR}, ",
"#{ledgerAmount,jdbcType=DECIMAL}, #{ledgerStatus,jdbcType=INTEGER}, ",
"#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, ",
"#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})"
"insert into bs_order_settle (mer_no, order_no, ",
"settle_mer_no, settle_mer_key, ",
"settle_amount, ledger_flag, ",
"ledger_order_no, ledger_amount, ",
"ledger_status, create_time, ",
"update_time, ext_1, ",
"ext_2, ext_3)",
"values (#{merNo,jdbcType=VARCHAR}, #{orderNo,jdbcType=VARCHAR}, ",
"#{settleMerNo,jdbcType=VARCHAR}, #{settleMerKey,jdbcType=VARCHAR}, ",
"#{settleAmount,jdbcType=DECIMAL}, #{ledgerFlag,jdbcType=BIT}, ",
"#{ledgerOrderNo,jdbcType=VARCHAR}, #{ledgerAmount,jdbcType=DECIMAL}, ",
"#{ledgerStatus,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, ",
"#{updateTime,jdbcType=TIMESTAMP}, #{ext1,jdbcType=VARCHAR}, ",
"#{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})"
})
@Options(useGeneratedKeys=true,keyProperty="id")
int insert(BsOrderSettle record);
@ -62,6 +64,7 @@ public interface BsOrderSettleMapper extends BsOrderSettleMapperExt {
@SelectProvider(type=BsOrderSettleSqlProvider.class, method="selectByExample")
@Results({
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
@Result(column="mer_no", property="merNo", jdbcType=JdbcType.VARCHAR),
@Result(column="order_no", property="orderNo", jdbcType=JdbcType.VARCHAR),
@Result(column="settle_mer_no", property="settleMerNo", jdbcType=JdbcType.VARCHAR),
@Result(column="settle_mer_key", property="settleMerKey", jdbcType=JdbcType.VARCHAR),
@ -80,13 +83,15 @@ public interface BsOrderSettleMapper extends BsOrderSettleMapperExt {
@Select({
"select",
"id, order_no, settle_mer_no, settle_mer_key, settle_amount, ledger_flag, ledger_order_no, ",
"ledger_amount, ledger_status, create_time, update_time, ext_1, ext_2, ext_3",
"id, mer_no, order_no, settle_mer_no, settle_mer_key, settle_amount, ledger_flag, ",
"ledger_order_no, ledger_amount, ledger_status, create_time, update_time, ext_1, ",
"ext_2, ext_3",
"from bs_order_settle",
"where id = #{id,jdbcType=BIGINT}"
})
@Results({
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
@Result(column="mer_no", property="merNo", jdbcType=JdbcType.VARCHAR),
@Result(column="order_no", property="orderNo", jdbcType=JdbcType.VARCHAR),
@Result(column="settle_mer_no", property="settleMerNo", jdbcType=JdbcType.VARCHAR),
@Result(column="settle_mer_key", property="settleMerKey", jdbcType=JdbcType.VARCHAR),
@ -114,7 +119,8 @@ public interface BsOrderSettleMapper extends BsOrderSettleMapperExt {
@Update({
"update bs_order_settle",
"set order_no = #{orderNo,jdbcType=VARCHAR},",
"set mer_no = #{merNo,jdbcType=VARCHAR},",
"order_no = #{orderNo,jdbcType=VARCHAR},",
"settle_mer_no = #{settleMerNo,jdbcType=VARCHAR},",
"settle_mer_key = #{settleMerKey,jdbcType=VARCHAR},",
"settle_amount = #{settleAmount,jdbcType=DECIMAL},",

@ -28,6 +28,10 @@ public class BsOrderSettleSqlProvider {
SQL sql = new SQL();
sql.INSERT_INTO("bs_order_settle");
if (record.getMerNo() != null) {
sql.VALUES("mer_no", "#{merNo,jdbcType=VARCHAR}");
}
if (record.getOrderNo() != null) {
sql.VALUES("order_no", "#{orderNo,jdbcType=VARCHAR}");
}
@ -90,6 +94,7 @@ public class BsOrderSettleSqlProvider {
} else {
sql.SELECT("id");
}
sql.SELECT("mer_no");
sql.SELECT("order_no");
sql.SELECT("settle_mer_no");
sql.SELECT("settle_mer_key");
@ -124,6 +129,10 @@ public class BsOrderSettleSqlProvider {
sql.SET("id = #{record.id,jdbcType=BIGINT}");
}
if (record.getMerNo() != null) {
sql.SET("mer_no = #{record.merNo,jdbcType=VARCHAR}");
}
if (record.getOrderNo() != null) {
sql.SET("order_no = #{record.orderNo,jdbcType=VARCHAR}");
}
@ -185,6 +194,7 @@ public class BsOrderSettleSqlProvider {
sql.UPDATE("bs_order_settle");
sql.SET("id = #{record.id,jdbcType=BIGINT}");
sql.SET("mer_no = #{record.merNo,jdbcType=VARCHAR}");
sql.SET("order_no = #{record.orderNo,jdbcType=VARCHAR}");
sql.SET("settle_mer_no = #{record.settleMerNo,jdbcType=VARCHAR}");
sql.SET("settle_mer_key = #{record.settleMerKey,jdbcType=VARCHAR}");
@ -208,6 +218,10 @@ public class BsOrderSettleSqlProvider {
SQL sql = new SQL();
sql.UPDATE("bs_order_settle");
if (record.getMerNo() != null) {
sql.SET("mer_no = #{merNo,jdbcType=VARCHAR}");
}
if (record.getOrderNo() != null) {
sql.SET("order_no = #{orderNo,jdbcType=VARCHAR}");
}

@ -214,6 +214,16 @@ public class BsGasOrder implements Serializable {
*/
private Integer payType;
/**
* 客户支付流水号
*/
private String paySerialNo;
/**
* 支付渠道流水号
*/
private String payChannelOrderNo;
/**
* 订单状态
1. 待支付
@ -584,6 +594,22 @@ public class BsGasOrder implements Serializable {
this.payType = payType;
}
public String getPaySerialNo() {
return paySerialNo;
}
public void setPaySerialNo(String paySerialNo) {
this.paySerialNo = paySerialNo;
}
public String getPayChannelOrderNo() {
return payChannelOrderNo;
}
public void setPayChannelOrderNo(String payChannelOrderNo) {
this.payChannelOrderNo = payChannelOrderNo;
}
public Integer getStatus() {
return status;
}
@ -732,6 +758,8 @@ public class BsGasOrder implements Serializable {
&& (this.getGasStaffId() == null ? other.getGasStaffId() == null : this.getGasStaffId().equals(other.getGasStaffId()))
&& (this.getGasStaffName() == null ? other.getGasStaffName() == null : this.getGasStaffName().equals(other.getGasStaffName()))
&& (this.getPayType() == null ? other.getPayType() == null : this.getPayType().equals(other.getPayType()))
&& (this.getPaySerialNo() == null ? other.getPaySerialNo() == null : this.getPaySerialNo().equals(other.getPaySerialNo()))
&& (this.getPayChannelOrderNo() == null ? other.getPayChannelOrderNo() == null : this.getPayChannelOrderNo().equals(other.getPayChannelOrderNo()))
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
&& (this.getCancelTime() == null ? other.getCancelTime() == null : this.getCancelTime().equals(other.getCancelTime()))
@ -790,6 +818,8 @@ public class BsGasOrder implements Serializable {
result = prime * result + ((getGasStaffId() == null) ? 0 : getGasStaffId().hashCode());
result = prime * result + ((getGasStaffName() == null) ? 0 : getGasStaffName().hashCode());
result = prime * result + ((getPayType() == null) ? 0 : getPayType().hashCode());
result = prime * result + ((getPaySerialNo() == null) ? 0 : getPaySerialNo().hashCode());
result = prime * result + ((getPayChannelOrderNo() == null) ? 0 : getPayChannelOrderNo().hashCode());
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
result = prime * result + ((getCancelTime() == null) ? 0 : getCancelTime().hashCode());
@ -851,6 +881,8 @@ public class BsGasOrder implements Serializable {
sb.append(", gasStaffId=").append(gasStaffId);
sb.append(", gasStaffName=").append(gasStaffName);
sb.append(", payType=").append(payType);
sb.append(", paySerialNo=").append(paySerialNo);
sb.append(", payChannelOrderNo=").append(payChannelOrderNo);
sb.append(", status=").append(status);
sb.append(", createTime=").append(createTime);
sb.append(", cancelTime=").append(cancelTime);

@ -2656,6 +2656,146 @@ public class BsGasOrderExample {
return (Criteria) this;
}
public Criteria andPaySerialNoIsNull() {
addCriterion("pay_serial_no is null");
return (Criteria) this;
}
public Criteria andPaySerialNoIsNotNull() {
addCriterion("pay_serial_no is not null");
return (Criteria) this;
}
public Criteria andPaySerialNoEqualTo(String value) {
addCriterion("pay_serial_no =", value, "paySerialNo");
return (Criteria) this;
}
public Criteria andPaySerialNoNotEqualTo(String value) {
addCriterion("pay_serial_no <>", value, "paySerialNo");
return (Criteria) this;
}
public Criteria andPaySerialNoGreaterThan(String value) {
addCriterion("pay_serial_no >", value, "paySerialNo");
return (Criteria) this;
}
public Criteria andPaySerialNoGreaterThanOrEqualTo(String value) {
addCriterion("pay_serial_no >=", value, "paySerialNo");
return (Criteria) this;
}
public Criteria andPaySerialNoLessThan(String value) {
addCriterion("pay_serial_no <", value, "paySerialNo");
return (Criteria) this;
}
public Criteria andPaySerialNoLessThanOrEqualTo(String value) {
addCriterion("pay_serial_no <=", value, "paySerialNo");
return (Criteria) this;
}
public Criteria andPaySerialNoLike(String value) {
addCriterion("pay_serial_no like", value, "paySerialNo");
return (Criteria) this;
}
public Criteria andPaySerialNoNotLike(String value) {
addCriterion("pay_serial_no not like", value, "paySerialNo");
return (Criteria) this;
}
public Criteria andPaySerialNoIn(List<String> values) {
addCriterion("pay_serial_no in", values, "paySerialNo");
return (Criteria) this;
}
public Criteria andPaySerialNoNotIn(List<String> values) {
addCriterion("pay_serial_no not in", values, "paySerialNo");
return (Criteria) this;
}
public Criteria andPaySerialNoBetween(String value1, String value2) {
addCriterion("pay_serial_no between", value1, value2, "paySerialNo");
return (Criteria) this;
}
public Criteria andPaySerialNoNotBetween(String value1, String value2) {
addCriterion("pay_serial_no not between", value1, value2, "paySerialNo");
return (Criteria) this;
}
public Criteria andPayChannelOrderNoIsNull() {
addCriterion("pay_channel_order_no is null");
return (Criteria) this;
}
public Criteria andPayChannelOrderNoIsNotNull() {
addCriterion("pay_channel_order_no is not null");
return (Criteria) this;
}
public Criteria andPayChannelOrderNoEqualTo(String value) {
addCriterion("pay_channel_order_no =", value, "payChannelOrderNo");
return (Criteria) this;
}
public Criteria andPayChannelOrderNoNotEqualTo(String value) {
addCriterion("pay_channel_order_no <>", value, "payChannelOrderNo");
return (Criteria) this;
}
public Criteria andPayChannelOrderNoGreaterThan(String value) {
addCriterion("pay_channel_order_no >", value, "payChannelOrderNo");
return (Criteria) this;
}
public Criteria andPayChannelOrderNoGreaterThanOrEqualTo(String value) {
addCriterion("pay_channel_order_no >=", value, "payChannelOrderNo");
return (Criteria) this;
}
public Criteria andPayChannelOrderNoLessThan(String value) {
addCriterion("pay_channel_order_no <", value, "payChannelOrderNo");
return (Criteria) this;
}
public Criteria andPayChannelOrderNoLessThanOrEqualTo(String value) {
addCriterion("pay_channel_order_no <=", value, "payChannelOrderNo");
return (Criteria) this;
}
public Criteria andPayChannelOrderNoLike(String value) {
addCriterion("pay_channel_order_no like", value, "payChannelOrderNo");
return (Criteria) this;
}
public Criteria andPayChannelOrderNoNotLike(String value) {
addCriterion("pay_channel_order_no not like", value, "payChannelOrderNo");
return (Criteria) this;
}
public Criteria andPayChannelOrderNoIn(List<String> values) {
addCriterion("pay_channel_order_no in", values, "payChannelOrderNo");
return (Criteria) this;
}
public Criteria andPayChannelOrderNoNotIn(List<String> values) {
addCriterion("pay_channel_order_no not in", values, "payChannelOrderNo");
return (Criteria) this;
}
public Criteria andPayChannelOrderNoBetween(String value1, String value2) {
addCriterion("pay_channel_order_no between", value1, value2, "payChannelOrderNo");
return (Criteria) this;
}
public Criteria andPayChannelOrderNoNotBetween(String value1, String value2) {
addCriterion("pay_channel_order_no not between", value1, value2, "payChannelOrderNo");
return (Criteria) this;
}
public Criteria andStatusIsNull() {
addCriterion("`status` is null");
return (Criteria) this;

@ -19,6 +19,11 @@ public class BsOrderSettle implements Serializable {
*/
private Long id;
/**
* 商户号
*/
private String merNo;
/**
* 订单号
*/
@ -85,6 +90,14 @@ public class BsOrderSettle implements Serializable {
this.id = id;
}
public String getMerNo() {
return merNo;
}
public void setMerNo(String merNo) {
this.merNo = merNo;
}
public String getOrderNo() {
return orderNo;
}
@ -202,6 +215,7 @@ public class BsOrderSettle implements Serializable {
}
BsOrderSettle other = (BsOrderSettle) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getMerNo() == null ? other.getMerNo() == null : this.getMerNo().equals(other.getMerNo()))
&& (this.getOrderNo() == null ? other.getOrderNo() == null : this.getOrderNo().equals(other.getOrderNo()))
&& (this.getSettleMerNo() == null ? other.getSettleMerNo() == null : this.getSettleMerNo().equals(other.getSettleMerNo()))
&& (this.getSettleMerKey() == null ? other.getSettleMerKey() == null : this.getSettleMerKey().equals(other.getSettleMerKey()))
@ -222,6 +236,7 @@ public class BsOrderSettle implements Serializable {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getMerNo() == null) ? 0 : getMerNo().hashCode());
result = prime * result + ((getOrderNo() == null) ? 0 : getOrderNo().hashCode());
result = prime * result + ((getSettleMerNo() == null) ? 0 : getSettleMerNo().hashCode());
result = prime * result + ((getSettleMerKey() == null) ? 0 : getSettleMerKey().hashCode());
@ -245,6 +260,7 @@ public class BsOrderSettle implements Serializable {
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", merNo=").append(merNo);
sb.append(", orderNo=").append(orderNo);
sb.append(", settleMerNo=").append(settleMerNo);
sb.append(", settleMerKey=").append(settleMerKey);

@ -186,6 +186,76 @@ public class BsOrderSettleExample {
return (Criteria) this;
}
public Criteria andMerNoIsNull() {
addCriterion("mer_no is null");
return (Criteria) this;
}
public Criteria andMerNoIsNotNull() {
addCriterion("mer_no is not null");
return (Criteria) this;
}
public Criteria andMerNoEqualTo(String value) {
addCriterion("mer_no =", value, "merNo");
return (Criteria) this;
}
public Criteria andMerNoNotEqualTo(String value) {
addCriterion("mer_no <>", value, "merNo");
return (Criteria) this;
}
public Criteria andMerNoGreaterThan(String value) {
addCriterion("mer_no >", value, "merNo");
return (Criteria) this;
}
public Criteria andMerNoGreaterThanOrEqualTo(String value) {
addCriterion("mer_no >=", value, "merNo");
return (Criteria) this;
}
public Criteria andMerNoLessThan(String value) {
addCriterion("mer_no <", value, "merNo");
return (Criteria) this;
}
public Criteria andMerNoLessThanOrEqualTo(String value) {
addCriterion("mer_no <=", value, "merNo");
return (Criteria) this;
}
public Criteria andMerNoLike(String value) {
addCriterion("mer_no like", value, "merNo");
return (Criteria) this;
}
public Criteria andMerNoNotLike(String value) {
addCriterion("mer_no not like", value, "merNo");
return (Criteria) this;
}
public Criteria andMerNoIn(List<String> values) {
addCriterion("mer_no in", values, "merNo");
return (Criteria) this;
}
public Criteria andMerNoNotIn(List<String> values) {
addCriterion("mer_no not in", values, "merNo");
return (Criteria) this;
}
public Criteria andMerNoBetween(String value1, String value2) {
addCriterion("mer_no between", value1, value2, "merNo");
return (Criteria) this;
}
public Criteria andMerNoNotBetween(String value1, String value2) {
addCriterion("mer_no not between", value1, value2, "merNo");
return (Criteria) this;
}
public Criteria andOrderNoIsNull() {
addCriterion("order_no is null");
return (Criteria) this;

@ -1,22 +1,24 @@
package com.hfkj.pay;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.common.pay.util.SignatureUtil;
import com.hfkj.common.utils.DateUtil;
import com.hfkj.common.utils.HttpsUtils;
import com.hfkj.common.utils.RandomUtils;
import com.hfkj.config.CommonSysConst;
import com.hfkj.entity.BsOrderSettle;
import com.hfkj.entity.BsOrderSettleLedger;
import com.hfkj.model.order.OrderModel;
import com.hfkj.sysenum.order.OrderPayTypeEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.*;
/**
* @className: HuiPayService
@ -27,8 +29,6 @@ public class HuiPayService {
static Logger log = LoggerFactory.getLogger(HuiPayService.class);
// 请求地址
private final static String REQUEST_URL = "https://pay.dctpay.com/openApi/v1/";
public final static String DEFAULT_MER_NO = "2023041916292112804";
private final static String DEFAULT_MER_KEY = "2jLO2WjXcSRSzTCaca0Kmv0OFrfYBbrA";
/**
* JSAPI支付
@ -102,7 +102,7 @@ public class HuiPayService {
param.put("refundTradeNo", refundTradeNo);
param.put("refundAmount", refundAmount);
param.put("sign" , SignatureUtil.createSign(param, merKey));
log.info("请求地址:" + (REQUEST_URL + "trade/preorder"));
log.info("请求地址:" + (REQUEST_URL + "trade/refund"));
log.info("请求参数:" + JSONObject.toJSONString(param));
JSONObject response = HttpsUtils.doPost(REQUEST_URL + "trade/refund", param, new HashMap<>());
@ -115,4 +115,100 @@ public class HuiPayService {
log.info("=============== end 惠支付退款 end ==================");
}
}
/**
* 发起分账
* @param orderSettle
* @param settleLedgerList
* @return
*/
public static JSONObject profitSharingSeparate(BsOrderSettle orderSettle, List<BsOrderSettleLedger> settleLedgerList) {
try {
log.info("=============== start 惠支付分账 start ==================");
Map<String,Object> param = new HashMap<>();
param.put("merchantNo", orderSettle.getSettleMerNo());
param.put("outTradeNo", orderSettle.getOrderNo());
param.put("outSeparateNo", orderSettle.getLedgerOrderNo());
param.put("totalAmount", orderSettle.getLedgerAmount());
JSONArray recvDatas = new JSONArray();
for (BsOrderSettleLedger settleLedger : settleLedgerList) {
JSONObject obj = new JSONObject();
obj.put("recvMerchantNo", settleLedger.getReceiverMerNo());
obj.put("separateAmount", settleLedger.getReceiverAmount());
recvDatas.add(obj);
}
param.put("recvDatas", recvDatas);
param.put("sign" , SignatureUtil.createSign(param, orderSettle.getSettleMerKey()));
log.info("请求地址:" + (REQUEST_URL + "profitSharing/separate"));
log.info("请求参数:" + JSONObject.toJSONString(param));
JSONObject response = HttpsUtils.doPost(REQUEST_URL + "profitSharing/separate", param, new HashMap<>());
log.info("响应参数:" + response.toJSONString());
return response;
} catch (Exception e) {
log.info("出现异常"+ e.getMessage());
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "分账异常");
} finally {
log.info("=============== end 惠支付分账 end ==================");
}
}
/**
* 分账查询
* @param orderSettle
* @return
*/
public static JSONObject profitSharingQuery(BsOrderSettle orderSettle) {
try {
log.info("=============== start 惠支付分账查询 start ==================");
Map<String,Object> param = new HashMap<>();
param.put("merchantNo", orderSettle.getSettleMerNo());
param.put("outSeparateNo", orderSettle.getLedgerOrderNo());
param.put("sign" , SignatureUtil.createSign(param, orderSettle.getSettleMerKey()));
log.info("请求地址:" + (REQUEST_URL + "profitSharing/query"));
log.info("请求参数:" + JSONObject.toJSONString(param));
JSONObject response = HttpsUtils.doPost(REQUEST_URL + "profitSharing/query", param, new HashMap<>());
log.info("响应参数:" + response.toJSONString());
return response;
} catch (Exception e) {
log.info("出现异常"+ e.getMessage());
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "分账查询异常");
} finally {
log.info("=============== end 惠支付分账查询 end ==================");
}
}
/**
* 分账撤销
* @param orderSettle
* @return
*/
public static JSONObject profitSharingCancel(BsOrderSettle orderSettle) {
try {
log.info("=============== start 惠支付分账撤销 start ==================");
Map<String,Object> param = new HashMap<>();
param.put("merchantNo", orderSettle.getSettleMerNo());
param.put("originOutSeparateNo", orderSettle.getLedgerOrderNo());
param.put("outSeparateNo", "LC"+ DateUtil.date2String(new Date(), "yyMMddHHmmss") + RandomUtils.number(3, false));
param.put("totalAmount", orderSettle.getLedgerAmount());
param.put("sign" , SignatureUtil.createSign(param, orderSettle.getSettleMerKey()));
log.info("请求地址:" + (REQUEST_URL + "profitSharing/cancel"));
log.info("请求参数:" + JSONObject.toJSONString(param));
JSONObject response = HttpsUtils.doPost(REQUEST_URL + "profitSharing/cancel", param, new HashMap<>());
log.info("响应参数:" + response.toJSONString());
return response;
} catch (Exception e) {
log.info("出现异常"+ e.getMessage());
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "退款异常");
} finally {
log.info("=============== end 惠支付分账撤销 end ==================");
}
}
}

@ -33,12 +33,26 @@ public interface BsGasOrderService {
BsGasOrder getDetailByOrderChildNo(String orderChildNo);
/**
* 查询交易订单号获取详情
* 查询详情
* @param orderNo
* @return
*/
BsGasOrder getDetailByOrderNo(String orderNo);
/**
* 查询详情
* @param paySerialNo
* @return
*/
BsGasOrder getDetailByPaySerialNo(String paySerialNo);
/**
* 查询详情
* @param payChannelOrderNo
* @return
*/
BsGasOrder getDetailByPayChannelOrderNo(String payChannelOrderNo);
/**
* 查询油站订单列表
* @param param

@ -60,6 +60,28 @@ public class BsGasOrderServiceImpl implements BsGasOrderService {
return null;
}
@Override
public BsGasOrder getDetailByPaySerialNo(String paySerialNo) {
BsGasOrderExample example = new BsGasOrderExample();
example.createCriteria().andPaySerialNoEqualTo(paySerialNo);
List<BsGasOrder> list = gasOrderMapper.selectByExample(example);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
@Override
public BsGasOrder getDetailByPayChannelOrderNo(String payChannelOrderNo) {
BsGasOrderExample example = new BsGasOrderExample();
example.createCriteria().andPayChannelOrderNoEqualTo(payChannelOrderNo);
List<BsGasOrder> list = gasOrderMapper.selectByExample(example);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
@Override
public List<BsGasOrder> getGasOrderList(Map<String, Object> param) {
BsGasOrderExample example = new BsGasOrderExample();

@ -0,0 +1,27 @@
package com.hfkj.service.order;
import com.hfkj.entity.BsOrderSettleLedger;
import java.util.List;
/**
* 分账接收方
* @className: BsOrderSettleLedgerService
* @author: HuRui
* @date: 2024/6/25
**/
public interface BsOrderSettleLedgerService {
/**
* 编辑数据
* @param data
*/
void editData(BsOrderSettleLedger data);
/**
* 查询数据列表
* @param orderSettleId
* @return
*/
List<BsOrderSettleLedger> getListBySettleId(Long orderSettleId);
}

@ -2,7 +2,11 @@ package com.hfkj.service.order;
import com.hfkj.entity.BsOrderSettle;
import java.util.List;
import java.util.Map;
/**
* 订单结算
* @className: BsOrderSettleService
* @author: HuRui
* @date: 2024/6/24
@ -21,4 +25,18 @@ public interface BsOrderSettleService {
* @return
*/
BsOrderSettle getData(String orderNo);
/**
* 发起分账
* @param orderSettle
*/
void separate(BsOrderSettle orderSettle);
/**
* 查询列表
* @param param
* @return
*/
List<BsOrderSettle> getList(Map<String, Object> param);
}

@ -65,6 +65,8 @@ public class OrderPaySuccessService {
gasOrder.setPayType(order.getPayType());
gasOrder.setPayTime(order.getPayTime());
gasOrder.setStatus(OrderOilStatus.STATUS2.getNumber());
gasOrder.setPaySerialNo(order.getPaySerialNo());
gasOrder.setPayChannelOrderNo(order.getPayChannelOrderNo());
gasOrderService.updateGasOrder(gasOrder);
if (StringUtils.isNotBlank(gasOrder.getUserPhone())) {

@ -52,8 +52,8 @@ public class BsOrderServiceImpl implements BsOrderService {
private RedisUtil redisUtil;
@Resource
private RocketMQTemplate rocketMQTemplate;
@Autowired
private RedisTemplate redisTemplate;
@Resource
private BsOrderSettleService orderSettleService;
@Resource
private BsOrderMapper orderMapper;
@Resource
@ -361,8 +361,22 @@ public class BsOrderServiceImpl implements BsOrderService {
orderChildService.editData(childOrder);
}
cache(order);
// 处理业务
try {
orderPaySuccessService.orderBusHandle(order);
} catch (Exception e) {
System.out.println("业务处理异常");
}
// 分账业务
try {
Message<OrderModel> rocketMsg = MessageBuilder.withPayload(order).build();
rocketMQTemplate.syncSend(OrderTopic.ORDER_TOPIC_PROFIT_SHARING.getTopic(), rocketMsg,1000);
} catch (Exception e) {
System.out.println("分账处理异常");
}
}
@Override

@ -0,0 +1,43 @@
package com.hfkj.service.order.impl;
import com.hfkj.dao.BsOrderSettleLedgerMapper;
import com.hfkj.dao.BsOrderSettleMapper;
import com.hfkj.entity.BsOrderSettle;
import com.hfkj.entity.BsOrderSettleLedger;
import com.hfkj.entity.BsOrderSettleLedgerExample;
import com.hfkj.service.order.BsOrderSettleLedgerService;
import com.hfkj.service.order.BsOrderSettleService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
/**
* @className: BsOrderSettleLedgerServiceImpl
* @author: HuRui
* @date: 2024/6/25
**/
@Service("orderSettleLedgerService")
public class BsOrderSettleLedgerServiceImpl implements BsOrderSettleLedgerService {
@Resource
private BsOrderSettleLedgerMapper orderSettleLedgerMapper;
@Override
public void editData(BsOrderSettleLedger data) {
if (data.getId() == null) {
data.setCreateTime(new Date());
orderSettleLedgerMapper.insert(data);
} else {
orderSettleLedgerMapper.updateByPrimaryKey(data);
}
}
@Override
public List<BsOrderSettleLedger> getListBySettleId(Long orderSettleId) {
BsOrderSettleLedgerExample example = new BsOrderSettleLedgerExample();
example.createCriteria().andOrderSettleIdEqualTo(orderSettleId);
return orderSettleLedgerMapper.selectByExample(example);
}
}

@ -1,14 +1,27 @@
package com.hfkj.service.order.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hfkj.dao.BsOrderSettleMapper;
import com.hfkj.entity.BsMerchantPayConfig;
import com.hfkj.entity.BsOrderSettle;
import com.hfkj.entity.BsOrderSettleExample;
import com.hfkj.entity.BsOrderSettleLedger;
import com.hfkj.pay.HuiPayService;
import com.hfkj.service.BsMerchantPayConfigService;
import com.hfkj.service.order.BsOrderSettleLedgerService;
import com.hfkj.service.order.BsOrderSettleService;
import com.hfkj.sysenum.order.OrderSettleLedgerStatusEnum;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* @className: BsOrderSettleServiceImpl
@ -19,6 +32,10 @@ import java.util.List;
public class BsOrderSettleServiceImpl implements BsOrderSettleService {
@Resource
private BsOrderSettleMapper orderSettleMapper;
@Resource
private BsOrderSettleLedgerService orderSettleLedgerService;
@Resource
private BsMerchantPayConfigService merchantPayConfigService;
@Override
public void editData(BsOrderSettle data) {
@ -41,4 +58,49 @@ public class BsOrderSettleServiceImpl implements BsOrderSettleService {
}
return null;
}
@Override
public void separate(BsOrderSettle orderSettle) {
// 查询商户配置
BsMerchantPayConfig payConfig = merchantPayConfigService.getConfig(orderSettle.getMerNo());
if (payConfig != null && StringUtils.isNotBlank(payConfig.getLedgerAccountData())) {
List<BsOrderSettleLedger> settleLedgerList = new ArrayList<>();
// 分账接收方数据
JSONArray ledgerAccountData = JSONArray.parseArray(payConfig.getLedgerAccountData());
for (Object obj : ledgerAccountData) {
JSONObject ledgerAccount = (JSONObject) obj;
BsOrderSettleLedger settleLedger = new BsOrderSettleLedger();
settleLedger.setOrderSettleId(orderSettle.getId());
settleLedger.setSharingAmount(orderSettle.getSettleAmount());
settleLedger.setRatio(ledgerAccount.getBigDecimal("receiverRatio"));
settleLedger.setReceiverMerNo(ledgerAccount.getString("receiverMerNo"));
settleLedger.setReceiverMerName(ledgerAccount.getString("receiverMerName"));
settleLedger.setReceiverAmount(settleLedger.getSharingAmount().multiply(settleLedger.getRatio().divide(new BigDecimal("100"))));
settleLedger.setStatus(0);
orderSettleLedgerService.editData(settleLedger);
settleLedgerList.add(settleLedger);
}
// 请求分账
JSONObject separate = HuiPayService.profitSharingSeparate(orderSettle, settleLedgerList);
if (separate.getString("return_code").equals("000000")) {
orderSettle.setLedgerStatus(OrderSettleLedgerStatusEnum.status2.getCode());
editData(orderSettle);
}
}
}
@Override
public List<BsOrderSettle> getList(Map<String, Object> param) {
BsOrderSettleExample example = new BsOrderSettleExample();
BsOrderSettleExample.Criteria criteria = example.createCriteria();
if (MapUtils.getInteger(param, "ledgerStatus") != null) {
criteria.andLedgerStatusEqualTo(MapUtils.getInteger(param, "ledgerStatus"));
}
return orderSettleMapper.selectByExample(example);
}
}

Loading…
Cancel
Save