diff --git a/order/src/main/java/com/order/controller/OrderPayController.java b/order/src/main/java/com/order/controller/OrderPayController.java index 34c589b..95a5a14 100644 --- a/order/src/main/java/com/order/controller/OrderPayController.java +++ b/order/src/main/java/com/order/controller/OrderPayController.java @@ -6,15 +6,20 @@ import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.SysCode; import com.hfkj.common.security.UserCenter; import com.hfkj.common.utils.ResponseMsgUtil; +import com.hfkj.entity.BsMerPayConfig; import com.hfkj.entity.BsUserCard; +import com.hfkj.mer.BsMerPayConfigService; import com.hfkj.model.ResponseData; import com.hfkj.model.UserSessionObject; +import com.hfkj.model.order.OrderChildModel; import com.hfkj.model.order.OrderModel; import com.hfkj.service.card.BsUserCardService; +import com.hfkj.service.order.BsOrderChildService; import com.hfkj.service.order.BsOrderService; import com.hfkj.service.order.OrderPayService; import com.hfkj.service.pay.HuiPayService; import com.hfkj.sysenum.UserCardTypeEnum; +import com.hfkj.sysenum.mer.PayPlatformEnum; import com.hfkj.sysenum.order.OrderPayChannelEnum; import com.hfkj.sysenum.order.OrderPayTypeEnum; import com.hfkj.sysenum.order.OrderStatusEnum; @@ -46,11 +51,15 @@ public class OrderPayController { @Resource private BsOrderService orderService; @Resource + private BsOrderChildService orderChildService; + @Resource private OrderPayService orderPayService; @Resource private UserCenter userCenter; @Resource private BsUserCardService userCardService; + @Resource + private BsMerPayConfigService merPayConfigService; @RequestMapping(value="/wechat",method = RequestMethod.POST) @ResponseBody @@ -73,8 +82,18 @@ public class OrderPayController { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "交易订单不处于待支付"); } order.setPayType(OrderPayTypeEnum.type1.getCode()); + Long merId = order.getOrderChildList().get(0).getMerId(); + // 查询平台 + BsMerPayConfig merPay = merPayConfigService.getMerPay(merId, PayPlatformEnum.type1); + if (merPay == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "商户未配置支付"); + } // 请求支付渠道 - Map preorder = HuiPayService.preorder(body.getString("openId"), order); + Map preorder = HuiPayService.preorder(merPay.getPayMerNo(), merPay.getPayMerKey(), body.getString("openId"), order); + for (OrderChildModel orderChild : order.getOrderChildList()) { + orderChild.setSettleAccount(merPay.getPayMerNo()); + orderChildService.editData(orderChild); + } return ResponseMsgUtil.success(preorder); } catch (Exception e) { @@ -103,8 +122,19 @@ public class OrderPayController { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "交易订单不处于待支付"); } order.setPayType(OrderPayTypeEnum.type2.getCode()); + Long merId = order.getOrderChildList().get(0).getMerId(); + // 查询平台 + BsMerPayConfig merPay = merPayConfigService.getMerPay(merId, PayPlatformEnum.type1); + if (merPay == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "商户未配置支付"); + } // 请求支付渠道 - Map preorder = HuiPayService.preorder(body.getString("userId"), order); + Map preorder = HuiPayService.preorder(merPay.getPayMerNo(), merPay.getPayMerKey(), body.getString("openId"), order); + for (OrderChildModel orderChild : order.getOrderChildList()) { + orderChild.setSettleAccount(merPay.getPayMerNo()); + orderChild.setSettleAccountKey(merPay.getPayMerKey()); + orderChildService.editData(orderChild); + } return ResponseMsgUtil.success(preorder); } catch (Exception e) { @@ -139,8 +169,20 @@ public class OrderPayController { if (!order.getOrderStatus().equals(OrderStatusEnum.status1.getCode())) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "支付失败!交易订单不处于待支付状态"); } + Long merId = order.getOrderChildList().get(0).getMerId(); + if (UserCardTypeEnum.type1.getCode() == card.getType()) { - return ResponseMsgUtil.success(orderPayService.hltCardPay(order, card)); + // 查询平台 + BsMerPayConfig merPay = merPayConfigService.getMerPay(merId, PayPlatformEnum.type2); + if (merPay == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "商户未配置支付"); + } + for (OrderChildModel orderChild : order.getOrderChildList()) { + orderChild.setSettleAccount(merPay.getPayMerNo()); + orderChild.setSettleAccountKey(merPay.getPayMerKey()); + orderChildService.editData(orderChild); + } + return ResponseMsgUtil.success(orderPayService.hltCardPay(merPay.getHltInstCode(),order, card)); } else { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的卡号类型"); diff --git a/service/src/main/java/com/hfkj/dao/BsOrderChildMapper.java b/service/src/main/java/com/hfkj/dao/BsOrderChildMapper.java index ff1695c..878dc1d 100644 --- a/service/src/main/java/com/hfkj/dao/BsOrderChildMapper.java +++ b/service/src/main/java/com/hfkj/dao/BsOrderChildMapper.java @@ -49,6 +49,7 @@ public interface BsOrderChildMapper extends BsOrderChildMapperExt { "integral_discount_price, product_actual_price, ", "surplus_refund_count, surplus_refund_price, ", "surplus_refund_integral, `status`, ", + "settle_account, settle_account_key, ", "create_time, update_time, ", "finish_time, ext_1, ", "ext_2, ext_3)", @@ -62,6 +63,7 @@ public interface BsOrderChildMapper extends BsOrderChildMapperExt { "#{integralDiscountPrice,jdbcType=DECIMAL}, #{productActualPrice,jdbcType=DECIMAL}, ", "#{surplusRefundCount,jdbcType=INTEGER}, #{surplusRefundPrice,jdbcType=DECIMAL}, ", "#{surplusRefundIntegral,jdbcType=BIGINT}, #{status,jdbcType=INTEGER}, ", + "#{settleAccount,jdbcType=VARCHAR}, #{settleAccountKey,jdbcType=VARCHAR}, ", "#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, ", "#{finishTime,jdbcType=TIMESTAMP}, #{ext1,jdbcType=VARCHAR}, ", "#{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" @@ -96,6 +98,8 @@ public interface BsOrderChildMapper extends BsOrderChildMapperExt { @Result(column="surplus_refund_price", property="surplusRefundPrice", jdbcType=JdbcType.DECIMAL), @Result(column="surplus_refund_integral", property="surplusRefundIntegral", jdbcType=JdbcType.BIGINT), @Result(column="status", property="status", jdbcType=JdbcType.INTEGER), + @Result(column="settle_account", property="settleAccount", jdbcType=JdbcType.VARCHAR), + @Result(column="settle_account_key", property="settleAccountKey", jdbcType=JdbcType.VARCHAR), @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="finish_time", property="finishTime", jdbcType=JdbcType.TIMESTAMP), @@ -111,7 +115,8 @@ public interface BsOrderChildMapper extends BsOrderChildMapperExt { "product_img, product_spec_id, product_spec_name, product_price, product_count, ", "product_total_price, total_deduction_price, coupon_discount_price, integral_discount_price, ", "product_actual_price, surplus_refund_count, surplus_refund_price, surplus_refund_integral, ", - "`status`, create_time, update_time, finish_time, ext_1, ext_2, ext_3", + "`status`, settle_account, settle_account_key, create_time, update_time, finish_time, ", + "ext_1, ext_2, ext_3", "from bs_order_child", "where id = #{id,jdbcType=BIGINT}" }) @@ -137,6 +142,8 @@ public interface BsOrderChildMapper extends BsOrderChildMapperExt { @Result(column="surplus_refund_price", property="surplusRefundPrice", jdbcType=JdbcType.DECIMAL), @Result(column="surplus_refund_integral", property="surplusRefundIntegral", jdbcType=JdbcType.BIGINT), @Result(column="status", property="status", jdbcType=JdbcType.INTEGER), + @Result(column="settle_account", property="settleAccount", jdbcType=JdbcType.VARCHAR), + @Result(column="settle_account_key", property="settleAccountKey", jdbcType=JdbcType.VARCHAR), @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="finish_time", property="finishTime", jdbcType=JdbcType.TIMESTAMP), @@ -177,6 +184,8 @@ public interface BsOrderChildMapper extends BsOrderChildMapperExt { "surplus_refund_price = #{surplusRefundPrice,jdbcType=DECIMAL},", "surplus_refund_integral = #{surplusRefundIntegral,jdbcType=BIGINT},", "`status` = #{status,jdbcType=INTEGER},", + "settle_account = #{settleAccount,jdbcType=VARCHAR},", + "settle_account_key = #{settleAccountKey,jdbcType=VARCHAR},", "create_time = #{createTime,jdbcType=TIMESTAMP},", "update_time = #{updateTime,jdbcType=TIMESTAMP},", "finish_time = #{finishTime,jdbcType=TIMESTAMP},", diff --git a/service/src/main/java/com/hfkj/dao/BsOrderChildSqlProvider.java b/service/src/main/java/com/hfkj/dao/BsOrderChildSqlProvider.java index 5721ada..74ad98b 100644 --- a/service/src/main/java/com/hfkj/dao/BsOrderChildSqlProvider.java +++ b/service/src/main/java/com/hfkj/dao/BsOrderChildSqlProvider.java @@ -108,6 +108,14 @@ public class BsOrderChildSqlProvider { sql.VALUES("`status`", "#{status,jdbcType=INTEGER}"); } + if (record.getSettleAccount() != null) { + sql.VALUES("settle_account", "#{settleAccount,jdbcType=VARCHAR}"); + } + + if (record.getSettleAccountKey() != null) { + sql.VALUES("settle_account_key", "#{settleAccountKey,jdbcType=VARCHAR}"); + } + if (record.getCreateTime() != null) { sql.VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}"); } @@ -162,6 +170,8 @@ public class BsOrderChildSqlProvider { sql.SELECT("surplus_refund_price"); sql.SELECT("surplus_refund_integral"); sql.SELECT("`status`"); + sql.SELECT("settle_account"); + sql.SELECT("settle_account_key"); sql.SELECT("create_time"); sql.SELECT("update_time"); sql.SELECT("finish_time"); @@ -269,6 +279,14 @@ public class BsOrderChildSqlProvider { sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); } + if (record.getSettleAccount() != null) { + sql.SET("settle_account = #{record.settleAccount,jdbcType=VARCHAR}"); + } + + if (record.getSettleAccountKey() != null) { + sql.SET("settle_account_key = #{record.settleAccountKey,jdbcType=VARCHAR}"); + } + if (record.getCreateTime() != null) { sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); } @@ -322,6 +340,8 @@ public class BsOrderChildSqlProvider { sql.SET("surplus_refund_price = #{record.surplusRefundPrice,jdbcType=DECIMAL}"); sql.SET("surplus_refund_integral = #{record.surplusRefundIntegral,jdbcType=BIGINT}"); sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); + sql.SET("settle_account = #{record.settleAccount,jdbcType=VARCHAR}"); + sql.SET("settle_account_key = #{record.settleAccountKey,jdbcType=VARCHAR}"); sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); sql.SET("update_time = #{record.updateTime,jdbcType=TIMESTAMP}"); sql.SET("finish_time = #{record.finishTime,jdbcType=TIMESTAMP}"); @@ -418,6 +438,14 @@ public class BsOrderChildSqlProvider { sql.SET("`status` = #{status,jdbcType=INTEGER}"); } + if (record.getSettleAccount() != null) { + sql.SET("settle_account = #{settleAccount,jdbcType=VARCHAR}"); + } + + if (record.getSettleAccountKey() != null) { + sql.SET("settle_account_key = #{settleAccountKey,jdbcType=VARCHAR}"); + } + if (record.getCreateTime() != null) { sql.SET("create_time = #{createTime,jdbcType=TIMESTAMP}"); } diff --git a/service/src/main/java/com/hfkj/dao/BsOrderRefundMapper.java b/service/src/main/java/com/hfkj/dao/BsOrderRefundMapper.java index 01f1ebe..a843efe 100644 --- a/service/src/main/java/com/hfkj/dao/BsOrderRefundMapper.java +++ b/service/src/main/java/com/hfkj/dao/BsOrderRefundMapper.java @@ -42,27 +42,29 @@ public interface BsOrderRefundMapper extends BsOrderRefundMapperExt { "insert into bs_order_refund (mer_id, order_no, ", "order_child_no, user_id, ", "user_phone, refund_order_no, ", - "account_merchant_no, refund_pay_channel, ", - "reufnd_pay_type, refund_serial_no, ", - "refund_pay_channel_order_no, refund_price, ", - "refund_integral, refund_remark, ", - "refund_status, refund_fail_reason, ", - "create_time, update_time, ", - "finish_time, op_user_type, ", - "op_user_id, op_user_name, ", - "ext_1, ext_2, ext_3)", + "account_merchant_no, account_merchant_key, ", + "refund_pay_channel, reufnd_pay_type, ", + "refund_serial_no, refund_pay_channel_order_no, ", + "refund_price, refund_integral, ", + "refund_remark, refund_status, ", + "refund_fail_reason, create_time, ", + "update_time, finish_time, ", + "op_user_type, op_user_id, ", + "op_user_name, ext_1, ", + "ext_2, ext_3)", "values (#{merId,jdbcType=BIGINT}, #{orderNo,jdbcType=VARCHAR}, ", "#{orderChildNo,jdbcType=VARCHAR}, #{userId,jdbcType=BIGINT}, ", "#{userPhone,jdbcType=VARCHAR}, #{refundOrderNo,jdbcType=VARCHAR}, ", - "#{accountMerchantNo,jdbcType=VARCHAR}, #{refundPayChannel,jdbcType=INTEGER}, ", - "#{reufndPayType,jdbcType=INTEGER}, #{refundSerialNo,jdbcType=VARCHAR}, ", - "#{refundPayChannelOrderNo,jdbcType=VARCHAR}, #{refundPrice,jdbcType=DECIMAL}, ", - "#{refundIntegral,jdbcType=BIGINT}, #{refundRemark,jdbcType=VARCHAR}, ", - "#{refundStatus,jdbcType=INTEGER}, #{refundFailReason,jdbcType=VARCHAR}, ", - "#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, ", - "#{finishTime,jdbcType=TIMESTAMP}, #{opUserType,jdbcType=INTEGER}, ", - "#{opUserId,jdbcType=BIGINT}, #{opUserName,jdbcType=VARCHAR}, ", - "#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" + "#{accountMerchantNo,jdbcType=VARCHAR}, #{accountMerchantKey,jdbcType=VARCHAR}, ", + "#{refundPayChannel,jdbcType=INTEGER}, #{reufndPayType,jdbcType=INTEGER}, ", + "#{refundSerialNo,jdbcType=VARCHAR}, #{refundPayChannelOrderNo,jdbcType=VARCHAR}, ", + "#{refundPrice,jdbcType=DECIMAL}, #{refundIntegral,jdbcType=BIGINT}, ", + "#{refundRemark,jdbcType=VARCHAR}, #{refundStatus,jdbcType=INTEGER}, ", + "#{refundFailReason,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, ", + "#{updateTime,jdbcType=TIMESTAMP}, #{finishTime,jdbcType=TIMESTAMP}, ", + "#{opUserType,jdbcType=INTEGER}, #{opUserId,jdbcType=BIGINT}, ", + "#{opUserName,jdbcType=VARCHAR}, #{ext1,jdbcType=VARCHAR}, ", + "#{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" }) @Options(useGeneratedKeys=true,keyProperty="id") int insert(BsOrderRefund record); @@ -81,6 +83,7 @@ public interface BsOrderRefundMapper extends BsOrderRefundMapperExt { @Result(column="user_phone", property="userPhone", jdbcType=JdbcType.VARCHAR), @Result(column="refund_order_no", property="refundOrderNo", jdbcType=JdbcType.VARCHAR), @Result(column="account_merchant_no", property="accountMerchantNo", jdbcType=JdbcType.VARCHAR), + @Result(column="account_merchant_key", property="accountMerchantKey", jdbcType=JdbcType.VARCHAR), @Result(column="refund_pay_channel", property="refundPayChannel", jdbcType=JdbcType.INTEGER), @Result(column="reufnd_pay_type", property="reufndPayType", jdbcType=JdbcType.INTEGER), @Result(column="refund_serial_no", property="refundSerialNo", jdbcType=JdbcType.VARCHAR), @@ -105,10 +108,10 @@ public interface BsOrderRefundMapper extends BsOrderRefundMapperExt { @Select({ "select", "id, mer_id, order_no, order_child_no, user_id, user_phone, refund_order_no, ", - "account_merchant_no, refund_pay_channel, reufnd_pay_type, refund_serial_no, ", - "refund_pay_channel_order_no, refund_price, refund_integral, refund_remark, refund_status, ", - "refund_fail_reason, create_time, update_time, finish_time, op_user_type, op_user_id, ", - "op_user_name, ext_1, ext_2, ext_3", + "account_merchant_no, account_merchant_key, refund_pay_channel, reufnd_pay_type, ", + "refund_serial_no, refund_pay_channel_order_no, refund_price, refund_integral, ", + "refund_remark, refund_status, refund_fail_reason, create_time, update_time, ", + "finish_time, op_user_type, op_user_id, op_user_name, ext_1, ext_2, ext_3", "from bs_order_refund", "where id = #{id,jdbcType=BIGINT}" }) @@ -121,6 +124,7 @@ public interface BsOrderRefundMapper extends BsOrderRefundMapperExt { @Result(column="user_phone", property="userPhone", jdbcType=JdbcType.VARCHAR), @Result(column="refund_order_no", property="refundOrderNo", jdbcType=JdbcType.VARCHAR), @Result(column="account_merchant_no", property="accountMerchantNo", jdbcType=JdbcType.VARCHAR), + @Result(column="account_merchant_key", property="accountMerchantKey", jdbcType=JdbcType.VARCHAR), @Result(column="refund_pay_channel", property="refundPayChannel", jdbcType=JdbcType.INTEGER), @Result(column="reufnd_pay_type", property="reufndPayType", jdbcType=JdbcType.INTEGER), @Result(column="refund_serial_no", property="refundSerialNo", jdbcType=JdbcType.VARCHAR), @@ -160,6 +164,7 @@ public interface BsOrderRefundMapper extends BsOrderRefundMapperExt { "user_phone = #{userPhone,jdbcType=VARCHAR},", "refund_order_no = #{refundOrderNo,jdbcType=VARCHAR},", "account_merchant_no = #{accountMerchantNo,jdbcType=VARCHAR},", + "account_merchant_key = #{accountMerchantKey,jdbcType=VARCHAR},", "refund_pay_channel = #{refundPayChannel,jdbcType=INTEGER},", "reufnd_pay_type = #{reufndPayType,jdbcType=INTEGER},", "refund_serial_no = #{refundSerialNo,jdbcType=VARCHAR},", diff --git a/service/src/main/java/com/hfkj/dao/BsOrderRefundSqlProvider.java b/service/src/main/java/com/hfkj/dao/BsOrderRefundSqlProvider.java index 8a99230..47ac8bd 100644 --- a/service/src/main/java/com/hfkj/dao/BsOrderRefundSqlProvider.java +++ b/service/src/main/java/com/hfkj/dao/BsOrderRefundSqlProvider.java @@ -56,6 +56,10 @@ public class BsOrderRefundSqlProvider { sql.VALUES("account_merchant_no", "#{accountMerchantNo,jdbcType=VARCHAR}"); } + if (record.getAccountMerchantKey() != null) { + sql.VALUES("account_merchant_key", "#{accountMerchantKey,jdbcType=VARCHAR}"); + } + if (record.getRefundPayChannel() != null) { sql.VALUES("refund_pay_channel", "#{refundPayChannel,jdbcType=INTEGER}"); } @@ -145,6 +149,7 @@ public class BsOrderRefundSqlProvider { sql.SELECT("user_phone"); sql.SELECT("refund_order_no"); sql.SELECT("account_merchant_no"); + sql.SELECT("account_merchant_key"); sql.SELECT("refund_pay_channel"); sql.SELECT("reufnd_pay_type"); sql.SELECT("refund_serial_no"); @@ -212,6 +217,10 @@ public class BsOrderRefundSqlProvider { sql.SET("account_merchant_no = #{record.accountMerchantNo,jdbcType=VARCHAR}"); } + if (record.getAccountMerchantKey() != null) { + sql.SET("account_merchant_key = #{record.accountMerchantKey,jdbcType=VARCHAR}"); + } + if (record.getRefundPayChannel() != null) { sql.SET("refund_pay_channel = #{record.refundPayChannel,jdbcType=INTEGER}"); } @@ -300,6 +309,7 @@ public class BsOrderRefundSqlProvider { sql.SET("user_phone = #{record.userPhone,jdbcType=VARCHAR}"); sql.SET("refund_order_no = #{record.refundOrderNo,jdbcType=VARCHAR}"); sql.SET("account_merchant_no = #{record.accountMerchantNo,jdbcType=VARCHAR}"); + sql.SET("account_merchant_key = #{record.accountMerchantKey,jdbcType=VARCHAR}"); sql.SET("refund_pay_channel = #{record.refundPayChannel,jdbcType=INTEGER}"); sql.SET("reufnd_pay_type = #{record.reufndPayType,jdbcType=INTEGER}"); sql.SET("refund_serial_no = #{record.refundSerialNo,jdbcType=VARCHAR}"); @@ -356,6 +366,10 @@ public class BsOrderRefundSqlProvider { sql.SET("account_merchant_no = #{accountMerchantNo,jdbcType=VARCHAR}"); } + if (record.getAccountMerchantKey() != null) { + sql.SET("account_merchant_key = #{accountMerchantKey,jdbcType=VARCHAR}"); + } + if (record.getRefundPayChannel() != null) { sql.SET("refund_pay_channel = #{refundPayChannel,jdbcType=INTEGER}"); } diff --git a/service/src/main/java/com/hfkj/entity/BsOrderChild.java b/service/src/main/java/com/hfkj/entity/BsOrderChild.java index bcddd2a..4738c68 100644 --- a/service/src/main/java/com/hfkj/entity/BsOrderChild.java +++ b/service/src/main/java/com/hfkj/entity/BsOrderChild.java @@ -125,6 +125,16 @@ public class BsOrderChild implements Serializable { */ private Integer status; + /** + * 结算账户key + */ + private String settleAccount; + + /** + * 结算账户 + */ + private String settleAccountKey; + /** * 创建时间 */ @@ -316,6 +326,22 @@ public class BsOrderChild implements Serializable { this.status = status; } + public String getSettleAccount() { + return settleAccount; + } + + public void setSettleAccount(String settleAccount) { + this.settleAccount = settleAccount; + } + + public String getSettleAccountKey() { + return settleAccountKey; + } + + public void setSettleAccountKey(String settleAccountKey) { + this.settleAccountKey = settleAccountKey; + } + public Date getCreateTime() { return createTime; } @@ -397,6 +423,8 @@ public class BsOrderChild implements Serializable { && (this.getSurplusRefundPrice() == null ? other.getSurplusRefundPrice() == null : this.getSurplusRefundPrice().equals(other.getSurplusRefundPrice())) && (this.getSurplusRefundIntegral() == null ? other.getSurplusRefundIntegral() == null : this.getSurplusRefundIntegral().equals(other.getSurplusRefundIntegral())) && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus())) + && (this.getSettleAccount() == null ? other.getSettleAccount() == null : this.getSettleAccount().equals(other.getSettleAccount())) + && (this.getSettleAccountKey() == null ? other.getSettleAccountKey() == null : this.getSettleAccountKey().equals(other.getSettleAccountKey())) && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime())) && (this.getFinishTime() == null ? other.getFinishTime() == null : this.getFinishTime().equals(other.getFinishTime())) @@ -430,6 +458,8 @@ public class BsOrderChild implements Serializable { result = prime * result + ((getSurplusRefundPrice() == null) ? 0 : getSurplusRefundPrice().hashCode()); result = prime * result + ((getSurplusRefundIntegral() == null) ? 0 : getSurplusRefundIntegral().hashCode()); result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode()); + result = prime * result + ((getSettleAccount() == null) ? 0 : getSettleAccount().hashCode()); + result = prime * result + ((getSettleAccountKey() == null) ? 0 : getSettleAccountKey().hashCode()); result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode()); result = prime * result + ((getFinishTime() == null) ? 0 : getFinishTime().hashCode()); @@ -466,6 +496,8 @@ public class BsOrderChild implements Serializable { sb.append(", surplusRefundPrice=").append(surplusRefundPrice); sb.append(", surplusRefundIntegral=").append(surplusRefundIntegral); sb.append(", status=").append(status); + sb.append(", settleAccount=").append(settleAccount); + sb.append(", settleAccountKey=").append(settleAccountKey); sb.append(", createTime=").append(createTime); sb.append(", updateTime=").append(updateTime); sb.append(", finishTime=").append(finishTime); diff --git a/service/src/main/java/com/hfkj/entity/BsOrderChildExample.java b/service/src/main/java/com/hfkj/entity/BsOrderChildExample.java index a57a17b..d39d3cd 100644 --- a/service/src/main/java/com/hfkj/entity/BsOrderChildExample.java +++ b/service/src/main/java/com/hfkj/entity/BsOrderChildExample.java @@ -1436,6 +1436,146 @@ public class BsOrderChildExample { return (Criteria) this; } + public Criteria andSettleAccountIsNull() { + addCriterion("settle_account is null"); + return (Criteria) this; + } + + public Criteria andSettleAccountIsNotNull() { + addCriterion("settle_account is not null"); + return (Criteria) this; + } + + public Criteria andSettleAccountEqualTo(String value) { + addCriterion("settle_account =", value, "settleAccount"); + return (Criteria) this; + } + + public Criteria andSettleAccountNotEqualTo(String value) { + addCriterion("settle_account <>", value, "settleAccount"); + return (Criteria) this; + } + + public Criteria andSettleAccountGreaterThan(String value) { + addCriterion("settle_account >", value, "settleAccount"); + return (Criteria) this; + } + + public Criteria andSettleAccountGreaterThanOrEqualTo(String value) { + addCriterion("settle_account >=", value, "settleAccount"); + return (Criteria) this; + } + + public Criteria andSettleAccountLessThan(String value) { + addCriterion("settle_account <", value, "settleAccount"); + return (Criteria) this; + } + + public Criteria andSettleAccountLessThanOrEqualTo(String value) { + addCriterion("settle_account <=", value, "settleAccount"); + return (Criteria) this; + } + + public Criteria andSettleAccountLike(String value) { + addCriterion("settle_account like", value, "settleAccount"); + return (Criteria) this; + } + + public Criteria andSettleAccountNotLike(String value) { + addCriterion("settle_account not like", value, "settleAccount"); + return (Criteria) this; + } + + public Criteria andSettleAccountIn(List values) { + addCriterion("settle_account in", values, "settleAccount"); + return (Criteria) this; + } + + public Criteria andSettleAccountNotIn(List values) { + addCriterion("settle_account not in", values, "settleAccount"); + return (Criteria) this; + } + + public Criteria andSettleAccountBetween(String value1, String value2) { + addCriterion("settle_account between", value1, value2, "settleAccount"); + return (Criteria) this; + } + + public Criteria andSettleAccountNotBetween(String value1, String value2) { + addCriterion("settle_account not between", value1, value2, "settleAccount"); + return (Criteria) this; + } + + public Criteria andSettleAccountKeyIsNull() { + addCriterion("settle_account_key is null"); + return (Criteria) this; + } + + public Criteria andSettleAccountKeyIsNotNull() { + addCriterion("settle_account_key is not null"); + return (Criteria) this; + } + + public Criteria andSettleAccountKeyEqualTo(String value) { + addCriterion("settle_account_key =", value, "settleAccountKey"); + return (Criteria) this; + } + + public Criteria andSettleAccountKeyNotEqualTo(String value) { + addCriterion("settle_account_key <>", value, "settleAccountKey"); + return (Criteria) this; + } + + public Criteria andSettleAccountKeyGreaterThan(String value) { + addCriterion("settle_account_key >", value, "settleAccountKey"); + return (Criteria) this; + } + + public Criteria andSettleAccountKeyGreaterThanOrEqualTo(String value) { + addCriterion("settle_account_key >=", value, "settleAccountKey"); + return (Criteria) this; + } + + public Criteria andSettleAccountKeyLessThan(String value) { + addCriterion("settle_account_key <", value, "settleAccountKey"); + return (Criteria) this; + } + + public Criteria andSettleAccountKeyLessThanOrEqualTo(String value) { + addCriterion("settle_account_key <=", value, "settleAccountKey"); + return (Criteria) this; + } + + public Criteria andSettleAccountKeyLike(String value) { + addCriterion("settle_account_key like", value, "settleAccountKey"); + return (Criteria) this; + } + + public Criteria andSettleAccountKeyNotLike(String value) { + addCriterion("settle_account_key not like", value, "settleAccountKey"); + return (Criteria) this; + } + + public Criteria andSettleAccountKeyIn(List values) { + addCriterion("settle_account_key in", values, "settleAccountKey"); + return (Criteria) this; + } + + public Criteria andSettleAccountKeyNotIn(List values) { + addCriterion("settle_account_key not in", values, "settleAccountKey"); + return (Criteria) this; + } + + public Criteria andSettleAccountKeyBetween(String value1, String value2) { + addCriterion("settle_account_key between", value1, value2, "settleAccountKey"); + return (Criteria) this; + } + + public Criteria andSettleAccountKeyNotBetween(String value1, String value2) { + addCriterion("settle_account_key not between", value1, value2, "settleAccountKey"); + return (Criteria) this; + } + public Criteria andCreateTimeIsNull() { addCriterion("create_time is null"); return (Criteria) this; diff --git a/service/src/main/java/com/hfkj/entity/BsOrderRefund.java b/service/src/main/java/com/hfkj/entity/BsOrderRefund.java index b2bee8b..422d862 100644 --- a/service/src/main/java/com/hfkj/entity/BsOrderRefund.java +++ b/service/src/main/java/com/hfkj/entity/BsOrderRefund.java @@ -54,6 +54,11 @@ public class BsOrderRefund implements Serializable { */ private String accountMerchantNo; + /** + * 退款入账商户key + */ + private String accountMerchantKey; + /** * 支付渠道 1:惠支付 2:微信合作商 3:贵州银行 */ @@ -204,6 +209,14 @@ public class BsOrderRefund implements Serializable { this.accountMerchantNo = accountMerchantNo; } + public String getAccountMerchantKey() { + return accountMerchantKey; + } + + public void setAccountMerchantKey(String accountMerchantKey) { + this.accountMerchantKey = accountMerchantKey; + } + public Integer getRefundPayChannel() { return refundPayChannel; } @@ -368,6 +381,7 @@ public class BsOrderRefund implements Serializable { && (this.getUserPhone() == null ? other.getUserPhone() == null : this.getUserPhone().equals(other.getUserPhone())) && (this.getRefundOrderNo() == null ? other.getRefundOrderNo() == null : this.getRefundOrderNo().equals(other.getRefundOrderNo())) && (this.getAccountMerchantNo() == null ? other.getAccountMerchantNo() == null : this.getAccountMerchantNo().equals(other.getAccountMerchantNo())) + && (this.getAccountMerchantKey() == null ? other.getAccountMerchantKey() == null : this.getAccountMerchantKey().equals(other.getAccountMerchantKey())) && (this.getRefundPayChannel() == null ? other.getRefundPayChannel() == null : this.getRefundPayChannel().equals(other.getRefundPayChannel())) && (this.getReufndPayType() == null ? other.getReufndPayType() == null : this.getReufndPayType().equals(other.getReufndPayType())) && (this.getRefundSerialNo() == null ? other.getRefundSerialNo() == null : this.getRefundSerialNo().equals(other.getRefundSerialNo())) @@ -400,6 +414,7 @@ public class BsOrderRefund implements Serializable { result = prime * result + ((getUserPhone() == null) ? 0 : getUserPhone().hashCode()); result = prime * result + ((getRefundOrderNo() == null) ? 0 : getRefundOrderNo().hashCode()); result = prime * result + ((getAccountMerchantNo() == null) ? 0 : getAccountMerchantNo().hashCode()); + result = prime * result + ((getAccountMerchantKey() == null) ? 0 : getAccountMerchantKey().hashCode()); result = prime * result + ((getRefundPayChannel() == null) ? 0 : getRefundPayChannel().hashCode()); result = prime * result + ((getReufndPayType() == null) ? 0 : getReufndPayType().hashCode()); result = prime * result + ((getRefundSerialNo() == null) ? 0 : getRefundSerialNo().hashCode()); @@ -435,6 +450,7 @@ public class BsOrderRefund implements Serializable { sb.append(", userPhone=").append(userPhone); sb.append(", refundOrderNo=").append(refundOrderNo); sb.append(", accountMerchantNo=").append(accountMerchantNo); + sb.append(", accountMerchantKey=").append(accountMerchantKey); sb.append(", refundPayChannel=").append(refundPayChannel); sb.append(", reufndPayType=").append(reufndPayType); sb.append(", refundSerialNo=").append(refundSerialNo); diff --git a/service/src/main/java/com/hfkj/entity/BsOrderRefundExample.java b/service/src/main/java/com/hfkj/entity/BsOrderRefundExample.java index 1ef729d..1fee9af 100644 --- a/service/src/main/java/com/hfkj/entity/BsOrderRefundExample.java +++ b/service/src/main/java/com/hfkj/entity/BsOrderRefundExample.java @@ -656,6 +656,76 @@ public class BsOrderRefundExample { return (Criteria) this; } + public Criteria andAccountMerchantKeyIsNull() { + addCriterion("account_merchant_key is null"); + return (Criteria) this; + } + + public Criteria andAccountMerchantKeyIsNotNull() { + addCriterion("account_merchant_key is not null"); + return (Criteria) this; + } + + public Criteria andAccountMerchantKeyEqualTo(String value) { + addCriterion("account_merchant_key =", value, "accountMerchantKey"); + return (Criteria) this; + } + + public Criteria andAccountMerchantKeyNotEqualTo(String value) { + addCriterion("account_merchant_key <>", value, "accountMerchantKey"); + return (Criteria) this; + } + + public Criteria andAccountMerchantKeyGreaterThan(String value) { + addCriterion("account_merchant_key >", value, "accountMerchantKey"); + return (Criteria) this; + } + + public Criteria andAccountMerchantKeyGreaterThanOrEqualTo(String value) { + addCriterion("account_merchant_key >=", value, "accountMerchantKey"); + return (Criteria) this; + } + + public Criteria andAccountMerchantKeyLessThan(String value) { + addCriterion("account_merchant_key <", value, "accountMerchantKey"); + return (Criteria) this; + } + + public Criteria andAccountMerchantKeyLessThanOrEqualTo(String value) { + addCriterion("account_merchant_key <=", value, "accountMerchantKey"); + return (Criteria) this; + } + + public Criteria andAccountMerchantKeyLike(String value) { + addCriterion("account_merchant_key like", value, "accountMerchantKey"); + return (Criteria) this; + } + + public Criteria andAccountMerchantKeyNotLike(String value) { + addCriterion("account_merchant_key not like", value, "accountMerchantKey"); + return (Criteria) this; + } + + public Criteria andAccountMerchantKeyIn(List values) { + addCriterion("account_merchant_key in", values, "accountMerchantKey"); + return (Criteria) this; + } + + public Criteria andAccountMerchantKeyNotIn(List values) { + addCriterion("account_merchant_key not in", values, "accountMerchantKey"); + return (Criteria) this; + } + + public Criteria andAccountMerchantKeyBetween(String value1, String value2) { + addCriterion("account_merchant_key between", value1, value2, "accountMerchantKey"); + return (Criteria) this; + } + + public Criteria andAccountMerchantKeyNotBetween(String value1, String value2) { + addCriterion("account_merchant_key not between", value1, value2, "accountMerchantKey"); + return (Criteria) this; + } + public Criteria andRefundPayChannelIsNull() { addCriterion("refund_pay_channel is null"); return (Criteria) this; diff --git a/service/src/main/java/com/hfkj/mer/BsMerPayConfigService.java b/service/src/main/java/com/hfkj/mer/BsMerPayConfigService.java index d391c8d..a63976e 100644 --- a/service/src/main/java/com/hfkj/mer/BsMerPayConfigService.java +++ b/service/src/main/java/com/hfkj/mer/BsMerPayConfigService.java @@ -1,6 +1,7 @@ package com.hfkj.mer; import com.hfkj.entity.BsMerPayConfig; +import com.hfkj.sysenum.mer.PayPlatformEnum; import java.util.List; import java.util.Map; @@ -26,6 +27,13 @@ public interface BsMerPayConfigService { */ void update(BsMerPayConfig merPayConfig); + /** + * 查询商户支付信息 + * @param merId + * @param payPlatform + */ + BsMerPayConfig getMerPay(Long merId, PayPlatformEnum payPlatform); + /** * @Author Sum1Dream * @Name delete diff --git a/service/src/main/java/com/hfkj/mer/impl/BsMerPayConfigServiceImpl.java b/service/src/main/java/com/hfkj/mer/impl/BsMerPayConfigServiceImpl.java index 0e3cff7..449e127 100644 --- a/service/src/main/java/com/hfkj/mer/impl/BsMerPayConfigServiceImpl.java +++ b/service/src/main/java/com/hfkj/mer/impl/BsMerPayConfigServiceImpl.java @@ -5,6 +5,7 @@ import com.hfkj.entity.BsMerPayConfig; import com.hfkj.entity.BsMerPayConfigExample; import com.hfkj.entity.GoodsMsg; import com.hfkj.mer.BsMerPayConfigService; +import com.hfkj.sysenum.mer.PayPlatformEnum; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; @@ -31,6 +32,20 @@ public class BsMerPayConfigServiceImpl implements BsMerPayConfigService { bsMerPayConfigMapper.updateByPrimaryKeySelective(merPayConfig); } + @Override + public BsMerPayConfig getMerPay(Long merId, PayPlatformEnum payPlatform) { + BsMerPayConfigExample example = new BsMerPayConfigExample(); + example.createCriteria() + .andMerIdEqualTo(merId) + .andPayPlatformEqualTo(payPlatform.getCode()) + .andStatusNotEqualTo(0); + List list = bsMerPayConfigMapper.selectByExample(example); + if (!list.isEmpty()) { + return list.get(0); + } + return null; + } + @Override public void delete(Long id, Boolean fullDelete) { if (fullDelete) { diff --git a/service/src/main/java/com/hfkj/service/order/OrderPayService.java b/service/src/main/java/com/hfkj/service/order/OrderPayService.java index 6376441..d1b38ee 100644 --- a/service/src/main/java/com/hfkj/service/order/OrderPayService.java +++ b/service/src/main/java/com/hfkj/service/order/OrderPayService.java @@ -17,5 +17,5 @@ public interface OrderPayService { * @return * @throws Exception */ - OrderModel hltCardPay(OrderModel order, BsUserCard userCard) throws Exception; + OrderModel hltCardPay(String instCode,OrderModel order, BsUserCard userCard) throws Exception; } diff --git a/service/src/main/java/com/hfkj/service/order/impl/BsOrderRefundServiceImpl.java b/service/src/main/java/com/hfkj/service/order/impl/BsOrderRefundServiceImpl.java index 2bd34d7..28d52ce 100644 --- a/service/src/main/java/com/hfkj/service/order/impl/BsOrderRefundServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/order/impl/BsOrderRefundServiceImpl.java @@ -8,15 +8,18 @@ import com.hfkj.common.exception.SysCode; import com.hfkj.common.utils.DateUtil; import com.hfkj.common.utils.RandomUtils; import com.hfkj.dao.BsOrderRefundMapper; +import com.hfkj.entity.BsMerPayConfig; import com.hfkj.entity.BsOrder; import com.hfkj.entity.BsOrderRefund; import com.hfkj.entity.BsOrderRefundExample; +import com.hfkj.mer.BsMerPayConfigService; import com.hfkj.model.order.OrderChildModel; import com.hfkj.model.order.OrderModel; import com.hfkj.service.order.BsOrderChildService; import com.hfkj.service.order.BsOrderRefundService; import com.hfkj.service.order.BsOrderService; import com.hfkj.service.pay.HuiPayService; +import com.hfkj.sysenum.mer.PayPlatformEnum; import com.hfkj.sysenum.order.*; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; @@ -46,6 +49,8 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService { private BsOrderService orderService; @Resource private BsOrderChildService orderChildService; + @Resource + private BsMerPayConfigService merPayConfigService; @Override public void editData(BsOrderRefund data) { data.setUpdateTime(new Date()); @@ -63,7 +68,7 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService { try { if (OrderPayChannelEnum.type1.getCode() == orderRefund.getRefundPayChannel()) { // 渠道退款 - JSONObject refund = HuiPayService.refund(HuiPayService.DEFAULT_MER_NO, orderRefund.getOrderNo(), orderRefund.getRefundOrderNo(), orderRefund.getRefundPrice()); + JSONObject refund = HuiPayService.refund(orderRefund.getAccountMerchantNo(), orderRefund.getAccountMerchantKey(), orderRefund.getOrderNo(), orderRefund.getRefundOrderNo(), orderRefund.getRefundPrice()); if (refund.getString("return_code").equals("000000")) { JSONObject data = refund.getJSONObject("return_data"); orderRefund.setRefundPayChannelOrderNo(data.getString("refundTradeNo")); @@ -171,6 +176,8 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService { } orderRefund.setRefundRemark(remark); orderRefund.setRefundStatus(OrderRefundStatusEnum.status1.getCode()); + orderRefund.setAccountMerchantNo(orderChild.getSettleAccount()); + orderRefund.setAccountMerchantNo(orderChild.getSettleAccountKey()); editData(orderRefund); // 资金退款 diff --git a/service/src/main/java/com/hfkj/service/order/impl/OrderPayServiceImpl.java b/service/src/main/java/com/hfkj/service/order/impl/OrderPayServiceImpl.java index 26e4840..973282e 100644 --- a/service/src/main/java/com/hfkj/service/order/impl/OrderPayServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/order/impl/OrderPayServiceImpl.java @@ -30,10 +30,9 @@ public class OrderPayServiceImpl implements OrderPayService { private BsOrderService orderService; @Override - public OrderModel hltCardPay(OrderModel order, BsUserCard userCard) throws Exception { + public OrderModel hltCardPay(String instCode,OrderModel order, BsUserCard userCard) throws Exception { String goodsDesc = ""; String tranDesc = ""; - String instCode = "11101527"; String businessType = "HiSen_phg_goods"; for (OrderChildModel orderChild : order.getOrderChildList()) { diff --git a/service/src/main/java/com/hfkj/service/pay/HuiPayService.java b/service/src/main/java/com/hfkj/service/pay/HuiPayService.java index 5b251b2..60a0253 100644 --- a/service/src/main/java/com/hfkj/service/pay/HuiPayService.java +++ b/service/src/main/java/com/hfkj/service/pay/HuiPayService.java @@ -31,11 +31,18 @@ public class HuiPayService { public final static String DEFAULT_MER_NO = "2023041916292112804"; private final static String DEFAULT_MER_KEY = "2jLO2WjXcSRSzTCaca0Kmv0OFrfYBbrA"; - public static Map preorder(String openId,OrderModel order) throws Exception { + /** + * JSAPI支付 + * @param openId + * @param order + * @return + * @throws Exception + */ + public static Map preorder(String merNo,String merKey,String openId,OrderModel order) throws Exception { try { log.info("=============== start 惠支付 start =================="); Map param = new HashMap<>(); - param.put("merchantNo", DEFAULT_MER_NO); + param.put("merchantNo", merNo); param.put("outTradeNo", order.getOrderNo()); param.put("transType", "JSAPI"); if (OrderPayTypeEnum.type1.getCode() == order.getPayType()) { @@ -48,7 +55,7 @@ public class HuiPayService { param.put("subject", "购买产品"); param.put("userId", openId); param.put("notifyUrl", CommonSysConst.getSysConfig().getHuiPayPreorderNotifyUrl()); - param.put("sign", SignatureUtil.createSign(param, DEFAULT_MER_KEY)); + param.put("sign", SignatureUtil.createSign(param, merKey)); log.info("请求地址:" + (REQUEST_URL + "trade/preorder")); log.info("请求参数:" + JSONObject.toJSONString(param)); @@ -79,15 +86,30 @@ public class HuiPayService { } } + /** + * 退款 + * @param merNo + * @param outTradeNo + * @param refundTradeNo + * @param refundAmount + * @return + * @throws Exception + */ + public static JSONObject refund(String merNo,String merKey,String outTradeNo,String refundTradeNo, BigDecimal refundAmount) { + try { + Map param = new HashMap<>(); + param.put("merchantNo", merNo); + param.put("outTradeNo", outTradeNo); + param.put("refundTradeNo", refundTradeNo); + param.put("refundAmount", refundAmount); + param.put("sign" , SignatureUtil.createSign(param, merKey)); + return HttpsUtils.doPost(REQUEST_URL + "trade/refund", param, new HashMap<>()); + } catch (Exception e) { + + } finally { + + } - public static JSONObject refund(String merchantNo,String outTradeNo,String refundTradeNo, BigDecimal refundAmount) throws Exception { - Map param = new HashMap<>(); - param.put("merchantNo", merchantNo); - param.put("outTradeNo", outTradeNo); - param.put("refundTradeNo", refundTradeNo); - param.put("refundAmount", refundAmount); - param.put("sign" , SignatureUtil.createSign(param, DEFAULT_MER_KEY)); - return HttpsUtils.doPost(REQUEST_URL + "trade/refund", param, new HashMap<>()); } }