Commit dfffe8a7a56190ea041e6e7c7581c46477c13161
1 parent
a213767f
feat get redirectUrl
Showing
11 changed files
with
281 additions
and
10 deletions
cashier-mall/src/main/java/com/diligrp/cashier/mall/api/ManualHandlerApi.java
| @@ -5,8 +5,8 @@ import com.diligrp.cashier.mall.dao.MallBizRefundDao; | @@ -5,8 +5,8 @@ import com.diligrp.cashier.mall.dao.MallBizRefundDao; | ||
| 5 | import com.diligrp.cashier.mall.model.MallBizPayment; | 5 | import com.diligrp.cashier.mall.model.MallBizPayment; |
| 6 | import com.diligrp.cashier.mall.model.MallBizRefund; | 6 | import com.diligrp.cashier.mall.model.MallBizRefund; |
| 7 | import com.diligrp.cashier.mall.service.biz.MallBizPaymentService; | 7 | import com.diligrp.cashier.mall.service.biz.MallBizPaymentService; |
| 8 | +import com.diligrp.cashier.mall.service.biz.PayNotifyService; | ||
| 8 | import com.diligrp.cashier.shared.domain.Message; | 9 | import com.diligrp.cashier.shared.domain.Message; |
| 9 | -import com.diligrp.cashier.shared.spi.IPaymentEventListener; | ||
| 10 | import com.diligrp.cashier.shared.spi.domain.PaymentResultBO; | 10 | import com.diligrp.cashier.shared.spi.domain.PaymentResultBO; |
| 11 | import com.diligrp.cashier.shared.spi.domain.RefundResultBO; | 11 | import com.diligrp.cashier.shared.spi.domain.RefundResultBO; |
| 12 | import jakarta.annotation.Resource; | 12 | import jakarta.annotation.Resource; |
| @@ -24,7 +24,7 @@ import org.springframework.web.bind.annotation.*; | @@ -24,7 +24,7 @@ import org.springframework.web.bind.annotation.*; | ||
| 24 | @Validated | 24 | @Validated |
| 25 | public class ManualHandlerApi { | 25 | public class ManualHandlerApi { |
| 26 | @Resource | 26 | @Resource |
| 27 | - private IPaymentEventListener payNotifyServiceImpl; | 27 | + private PayNotifyService payNotifyServiceImpl; |
| 28 | @Resource | 28 | @Resource |
| 29 | private MallBizPaymentService mallBizPaymentService; | 29 | private MallBizPaymentService mallBizPaymentService; |
| 30 | @Resource | 30 | @Resource |
| @@ -58,4 +58,8 @@ public class ManualHandlerApi { | @@ -58,4 +58,8 @@ public class ManualHandlerApi { | ||
| 58 | return Message.success(); | 58 | return Message.success(); |
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | + @GetMapping("/refund/event") | ||
| 62 | + public Message<?> handlePaymentEvent(String tradeId) { | ||
| 63 | + return Message.success(payNotifyServiceImpl.redirectUrl(tradeId)); | ||
| 64 | + } | ||
| 61 | } | 65 | } |
cashier-mall/src/main/java/com/diligrp/cashier/mall/domain/rtmall/co/AuthLoginCO.java
| @@ -70,6 +70,11 @@ public class AuthLoginCO { | @@ -70,6 +70,11 @@ public class AuthLoginCO { | ||
| 70 | */ | 70 | */ |
| 71 | private String latitude; | 71 | private String latitude; |
| 72 | 72 | ||
| 73 | + /** | ||
| 74 | + * 登录凭证 | ||
| 75 | + */ | ||
| 76 | + private String token; | ||
| 77 | + | ||
| 73 | public String getLatitude() { | 78 | public String getLatitude() { |
| 74 | return latitude; | 79 | return latitude; |
| 75 | } | 80 | } |
| @@ -149,4 +154,12 @@ public class AuthLoginCO { | @@ -149,4 +154,12 @@ public class AuthLoginCO { | ||
| 149 | public void setUsername(String username) { | 154 | public void setUsername(String username) { |
| 150 | this.username = username; | 155 | this.username = username; |
| 151 | } | 156 | } |
| 157 | + | ||
| 158 | + public String getToken() { | ||
| 159 | + return token; | ||
| 160 | + } | ||
| 161 | + | ||
| 162 | + public void setToken(String token) { | ||
| 163 | + this.token = token; | ||
| 164 | + } | ||
| 152 | } | 165 | } |
cashier-mall/src/main/java/com/diligrp/cashier/mall/model/MallBizPayment.java
| @@ -165,10 +165,10 @@ public class MallBizPayment extends BaseDO { | @@ -165,10 +165,10 @@ public class MallBizPayment extends BaseDO { | ||
| 165 | RtMallDynamicProperty.AppSecretDynamicProperty property = rtMallDynamicProperty.getBySourceAndType(mallBizOrder.getFirst().getSource(), mallBizOrder.getFirst().getOrderType()); | 165 | RtMallDynamicProperty.AppSecretDynamicProperty property = rtMallDynamicProperty.getBySourceAndType(mallBizOrder.getFirst().getSource(), mallBizOrder.getFirst().getOrderType()); |
| 166 | mallBizPayment.setPaymentCallback(property.getCallbackDomain()); | 166 | mallBizPayment.setPaymentCallback(property.getCallbackDomain()); |
| 167 | 167 | ||
| 168 | - // 大润发只支持一个订单单独结算 后期如何支持多订单组合支付 | ||
| 169 | - if (Objects.equals(mallBizOrder.getFirst().getOrderType(), OrderType.MINI_PROGRAM.code)) { | ||
| 170 | - mallBizPayment.setCashierResultUrl(String.format(property.getCashierResultUrl(), mallBizOrder.getFirst().getOrderId())); | ||
| 171 | - } | 168 | + // 大润发只支持一个订单单独结算 后期如何支持多订单组合支付 修改为支付成功返回 |
| 169 | + // if (Objects.equals(mallBizOrder.getFirst().getOrderType(), OrderType.MINI_PROGRAM.code)) { | ||
| 170 | + // mallBizPayment.setCashierResultUrl(String.format(property.getCashierResultUrl(), mallBizOrder.getFirst().getOrderId())); | ||
| 171 | + // } | ||
| 172 | 172 | ||
| 173 | // 完善mall_biz_payment_order | 173 | // 完善mall_biz_payment_order |
| 174 | List<MallBizPaymentOrder> bizPaymentOrders = mallBizOrder.stream() | 174 | List<MallBizPaymentOrder> bizPaymentOrders = mallBizOrder.stream() |
cashier-mall/src/main/java/com/diligrp/cashier/mall/service/biz/PayNotifyService.java
| @@ -9,4 +9,5 @@ import com.diligrp.cashier.shared.spi.IPaymentEventListener; | @@ -9,4 +9,5 @@ import com.diligrp.cashier.shared.spi.IPaymentEventListener; | ||
| 9 | * @Description PayNotifyService | 9 | * @Description PayNotifyService |
| 10 | */ | 10 | */ |
| 11 | public interface PayNotifyService extends IPaymentEventListener { | 11 | public interface PayNotifyService extends IPaymentEventListener { |
| 12 | + String redirectUrl(String tradeId); | ||
| 12 | } | 13 | } |
cashier-mall/src/main/java/com/diligrp/cashier/mall/service/biz/impl/MallBizOrderServiceImpl.java
| @@ -266,6 +266,7 @@ public class MallBizOrderServiceImpl implements MallBizOrderService { | @@ -266,6 +266,7 @@ public class MallBizOrderServiceImpl implements MallBizOrderService { | ||
| 266 | ); | 266 | ); |
| 267 | cashierOrderBO.setDescription(cashierOrderBO.getGoods()); | 267 | cashierOrderBO.setDescription(cashierOrderBO.getGoods()); |
| 268 | cashierOrderBO.setAttach(cashierOrderBO.getGoods()); | 268 | cashierOrderBO.setAttach(cashierOrderBO.getGoods()); |
| 269 | + LOG.info("submitOrder param: {}", JsonUtils.toJsonString(cashierOrderBO)); | ||
| 269 | PaymentUrlBO paymentUrlBO = cashierDeskManager.submitOrder(cashierOrderBO); | 270 | PaymentUrlBO paymentUrlBO = cashierDeskManager.submitOrder(cashierOrderBO); |
| 270 | Optional.ofNullable(paymentUrlBO).ifPresent(vo -> { | 271 | Optional.ofNullable(paymentUrlBO).ifPresent(vo -> { |
| 271 | mallBizPayment.setCashierUrl(vo.paymentUrl()); | 272 | mallBizPayment.setCashierUrl(vo.paymentUrl()); |
cashier-mall/src/main/java/com/diligrp/cashier/mall/service/biz/impl/MallBizRefundServiceImpl.java
| @@ -121,6 +121,7 @@ public class MallBizRefundServiceImpl implements MallBizRefundService { | @@ -121,6 +121,7 @@ public class MallBizRefundServiceImpl implements MallBizRefundService { | ||
| 121 | */ | 121 | */ |
| 122 | private RefundResultBO doRefund(MallBizRefund refund) { | 122 | private RefundResultBO doRefund(MallBizRefund refund) { |
| 123 | CashierRefundBO cashierRefundBO = new CashierRefundBO(refund.getPayTradeId(), refund.getRefundFee(), null, "用户主动取消!"); | 123 | CashierRefundBO cashierRefundBO = new CashierRefundBO(refund.getPayTradeId(), refund.getRefundFee(), null, "用户主动取消!"); |
| 124 | + LOG.info("doRefund cashierRefundBO: {}", JsonUtils.toJsonString(cashierRefundBO)); | ||
| 124 | RefundResultBO refundResultBO = cashierDeskManager.doRefund(cashierRefundBO); | 125 | RefundResultBO refundResultBO = cashierDeskManager.doRefund(cashierRefundBO); |
| 125 | refund.setRefundTradeId(refundResultBO.getRefundId()); | 126 | refund.setRefundTradeId(refundResultBO.getRefundId()); |
| 126 | return refundResultBO; | 127 | return refundResultBO; |
cashier-mall/src/main/java/com/diligrp/cashier/mall/service/biz/impl/PayNotifyServiceImpl.java
| @@ -73,4 +73,17 @@ public class PayNotifyServiceImpl implements PayNotifyService { | @@ -73,4 +73,17 @@ public class PayNotifyServiceImpl implements PayNotifyService { | ||
| 73 | MallBizOrder mallBizOrder = mallBizOrderService.getById(mallBizRefund.getBizOrderId()); | 73 | MallBizOrder mallBizOrder = mallBizOrderService.getById(mallBizRefund.getBizOrderId()); |
| 74 | MallInitializeContext.getBySource(mallBizOrder.getSource()).refundOnEvent(event, mallBizRefund); | 74 | MallInitializeContext.getBySource(mallBizOrder.getSource()).refundOnEvent(event, mallBizRefund); |
| 75 | } | 75 | } |
| 76 | + | ||
| 77 | + /** | ||
| 78 | + * redirectUrl | ||
| 79 | + */ | ||
| 80 | + @Override | ||
| 81 | + public String redirectUrl(String tradeId) { | ||
| 82 | + MallBizPayment mallBizPayment = mallBizPaymentService.getByPayTradeId(tradeId); | ||
| 83 | + | ||
| 84 | + Long bizOrderId = Long.valueOf(mallBizPayment.getBizOrderId().split(",")[0]); | ||
| 85 | + MallBizOrder mallBizOrder = mallBizOrderService.getById(bizOrderId); | ||
| 86 | + | ||
| 87 | + return MallInitializeContext.getBySource(mallBizOrder.getSource()).redirectUrl(mallBizPayment); | ||
| 88 | + } | ||
| 76 | } | 89 | } |
cashier-mall/src/main/java/com/diligrp/cashier/mall/service/sourcechannel/AbstractSourceChannel.java
| @@ -5,6 +5,8 @@ import com.diligrp.cashier.mall.MallConstants; | @@ -5,6 +5,8 @@ import com.diligrp.cashier.mall.MallConstants; | ||
| 5 | import com.diligrp.cashier.mall.dao.MallBizOrderDao; | 5 | import com.diligrp.cashier.mall.dao.MallBizOrderDao; |
| 6 | import com.diligrp.cashier.mall.domain.rtmall.co.AuthLoginCO; | 6 | import com.diligrp.cashier.mall.domain.rtmall.co.AuthLoginCO; |
| 7 | import com.diligrp.cashier.mall.domain.rtmall.vo.UserInfoVO; | 7 | import com.diligrp.cashier.mall.domain.rtmall.vo.UserInfoVO; |
| 8 | +import com.diligrp.cashier.mall.exception.RtMartMallException; | ||
| 9 | +import com.diligrp.cashier.mall.model.MallBizOrder; | ||
| 8 | import com.diligrp.cashier.mall.model.MallBizPayment; | 10 | import com.diligrp.cashier.mall.model.MallBizPayment; |
| 9 | import com.diligrp.cashier.mall.model.MallBizPaymentOrder; | 11 | import com.diligrp.cashier.mall.model.MallBizPaymentOrder; |
| 10 | import com.diligrp.cashier.mall.model.MallBizRefund; | 12 | import com.diligrp.cashier.mall.model.MallBizRefund; |
| @@ -12,6 +14,8 @@ import com.diligrp.cashier.mall.property.RtMallDynamicProperty; | @@ -12,6 +14,8 @@ import com.diligrp.cashier.mall.property.RtMallDynamicProperty; | ||
| 12 | import com.diligrp.cashier.mall.service.biz.MallBizPaymentService; | 14 | import com.diligrp.cashier.mall.service.biz.MallBizPaymentService; |
| 13 | import com.diligrp.cashier.mall.service.biz.MallBizRefundService; | 15 | import com.diligrp.cashier.mall.service.biz.MallBizRefundService; |
| 14 | import com.diligrp.cashier.mall.type.OrderState; | 16 | import com.diligrp.cashier.mall.type.OrderState; |
| 17 | +import com.diligrp.cashier.mall.type.OrderType; | ||
| 18 | +import com.diligrp.cashier.mall.type.RtMarkErrorCode; | ||
| 15 | import com.diligrp.cashier.pipeline.type.PaymentState; | 19 | import com.diligrp.cashier.pipeline.type.PaymentState; |
| 16 | import com.diligrp.cashier.shared.spi.domain.PaymentResultBO; | 20 | import com.diligrp.cashier.shared.spi.domain.PaymentResultBO; |
| 17 | import com.diligrp.cashier.shared.spi.domain.RefundResultBO; | 21 | import com.diligrp.cashier.shared.spi.domain.RefundResultBO; |
| @@ -117,6 +121,10 @@ public abstract class AbstractSourceChannel { | @@ -117,6 +121,10 @@ public abstract class AbstractSourceChannel { | ||
| 117 | public void refundOnEvent(RefundResultBO event, MallBizRefund mallBizRefund) { | 121 | public void refundOnEvent(RefundResultBO event, MallBizRefund mallBizRefund) { |
| 118 | LOG.info("refundOnEvent event: {} mallBizRefund: {}", JsonUtils.toJsonString(event), JsonUtils.toJsonString(mallBizRefund)); | 122 | LOG.info("refundOnEvent event: {} mallBizRefund: {}", JsonUtils.toJsonString(event), JsonUtils.toJsonString(mallBizRefund)); |
| 119 | 123 | ||
| 124 | + // update mall_biz_refund | ||
| 125 | + mallBizRefund.payCallBack(event); | ||
| 126 | + mallBizRefundService.updateByPay(mallBizRefund); | ||
| 127 | + | ||
| 120 | // check all refund state | 128 | // check all refund state |
| 121 | List<MallBizPaymentOrder> paymentOrderList = mallBizPaymentService.listPaymentOrderByBizOrderId(mallBizRefund.getBizOrderId()); | 129 | List<MallBizPaymentOrder> paymentOrderList = mallBizPaymentService.listPaymentOrderByBizOrderId(mallBizRefund.getBizOrderId()); |
| 122 | boolean success = paymentOrderList.stream().allMatch(vo -> Objects.equals(vo.getPayState(), PaymentState.SUCCESS.getCode())); | 130 | boolean success = paymentOrderList.stream().allMatch(vo -> Objects.equals(vo.getPayState(), PaymentState.SUCCESS.getCode())); |
| @@ -128,10 +136,6 @@ public abstract class AbstractSourceChannel { | @@ -128,10 +136,6 @@ public abstract class AbstractSourceChannel { | ||
| 128 | } | 136 | } |
| 129 | } | 137 | } |
| 130 | 138 | ||
| 131 | - // update mall_biz_refund | ||
| 132 | - mallBizRefund.payCallBack(event); | ||
| 133 | - mallBizRefundService.updateByPay(mallBizRefund); | ||
| 134 | - | ||
| 135 | // notify other channel | 139 | // notify other channel |
| 136 | refundCallBack(event, mallBizRefund); | 140 | refundCallBack(event, mallBizRefund); |
| 137 | } | 141 | } |
| @@ -144,11 +148,41 @@ public abstract class AbstractSourceChannel { | @@ -144,11 +148,41 @@ public abstract class AbstractSourceChannel { | ||
| 144 | List<MallBizPaymentOrder> paymentOrderList = mallBizPaymentService.listPaymentOrderByBizOrderIds(bizOrderIds); | 148 | List<MallBizPaymentOrder> paymentOrderList = mallBizPaymentService.listPaymentOrderByBizOrderIds(bizOrderIds); |
| 145 | boolean success = paymentOrderList.stream().allMatch(vo -> Objects.equals(vo.getPayState(), PaymentState.SUCCESS.getCode())); | 149 | boolean success = paymentOrderList.stream().allMatch(vo -> Objects.equals(vo.getPayState(), PaymentState.SUCCESS.getCode())); |
| 146 | if (success) { | 150 | if (success) { |
| 151 | + LOG.info("订单全部支付完成,orderIds:{}", bizOrderIds); | ||
| 147 | mallBizOrderDao.updateByIds(bizOrderIds, OrderState.PAYED.code); | 152 | mallBizOrderDao.updateByIds(bizOrderIds, OrderState.PAYED.code); |
| 148 | } | 153 | } |
| 149 | } | 154 | } |
| 150 | 155 | ||
| 151 | /** | 156 | /** |
| 157 | + * redirectUrl | ||
| 158 | + */ | ||
| 159 | + public String redirectUrl(MallBizPayment mallBizPayment) { | ||
| 160 | + Long bizOrderId = Long.valueOf(mallBizPayment.getBizOrderId().split(",")[0]); | ||
| 161 | + MallBizOrder mallBizOrder = mallBizOrderDao.selectByPrimaryKey(bizOrderId); | ||
| 162 | + if (Objects.isNull(mallBizOrder)) { | ||
| 163 | + throw new RtMartMallException(RtMarkErrorCode.E5004); | ||
| 164 | + } | ||
| 165 | + | ||
| 166 | + String redirectUrl = redirectUrl(mallBizOrder, mallBizPayment); | ||
| 167 | + LOG.info("redirectUrl: {}", redirectUrl); | ||
| 168 | + return redirectUrl; | ||
| 169 | + } | ||
| 170 | + | ||
| 171 | + /** | ||
| 172 | + * getAuthLogin from db | ||
| 173 | + * userCode = userCode + "_" + channel + "_" + orderType | ||
| 174 | + */ | ||
| 175 | + public AuthLoginCO getAuthLogin(String userCode, String channel, Integer orderType) { | ||
| 176 | + Object cache = redisTemplate.opsForValue().get(MallConstants.MALL_USER_INFO + userCode + "_" + channel + "_" + orderType); | ||
| 177 | + if (Objects.isNull(cache)) { | ||
| 178 | + throw new RtMartMallException(RtMarkErrorCode.E5001); | ||
| 179 | + } | ||
| 180 | + AuthLoginCO authLogin = JsonUtils.fromJsonString(Objects.requireNonNull(cache).toString(), AuthLoginCO.class); | ||
| 181 | + LOG.info("get auth login info: {}", JsonUtils.toJsonString(authLogin)); | ||
| 182 | + return authLogin; | ||
| 183 | + } | ||
| 184 | + | ||
| 185 | + /** | ||
| 152 | * 渠道 | 186 | * 渠道 |
| 153 | */ | 187 | */ |
| 154 | public abstract Integer source(); | 188 | public abstract Integer source(); |
| @@ -174,6 +208,11 @@ public abstract class AbstractSourceChannel { | @@ -174,6 +208,11 @@ public abstract class AbstractSourceChannel { | ||
| 174 | public abstract void refundCallBack(RefundResultBO event, MallBizRefund mallBizRefund); | 208 | public abstract void refundCallBack(RefundResultBO event, MallBizRefund mallBizRefund); |
| 175 | 209 | ||
| 176 | /** | 210 | /** |
| 211 | + * redirectUrl | ||
| 212 | + */ | ||
| 213 | + public abstract String redirectUrl(MallBizOrder mallBizOrder, MallBizPayment mallBizPayment); | ||
| 214 | + | ||
| 215 | + /** | ||
| 177 | * sendDelayMessage | 216 | * sendDelayMessage |
| 178 | */ | 217 | */ |
| 179 | protected void sendDelayMessage(String load) { | 218 | protected void sendDelayMessage(String load) { |
cashier-mall/src/main/java/com/diligrp/cashier/mall/service/sourcechannel/RtMallChannel.java
| @@ -23,6 +23,7 @@ import com.diligrp.cashier.shared.util.UrlParamParserUtils; | @@ -23,6 +23,7 @@ import com.diligrp.cashier.shared.util.UrlParamParserUtils; | ||
| 23 | import com.fasterxml.jackson.core.type.TypeReference; | 23 | import com.fasterxml.jackson.core.type.TypeReference; |
| 24 | import com.google.common.collect.Maps; | 24 | import com.google.common.collect.Maps; |
| 25 | import org.apache.commons.collections4.CollectionUtils; | 25 | import org.apache.commons.collections4.CollectionUtils; |
| 26 | +import org.apache.commons.lang3.StringUtils; | ||
| 26 | import org.slf4j.Logger; | 27 | import org.slf4j.Logger; |
| 27 | import org.slf4j.LoggerFactory; | 28 | import org.slf4j.LoggerFactory; |
| 28 | import org.springframework.stereotype.Component; | 29 | import org.springframework.stereotype.Component; |
| @@ -48,6 +49,7 @@ public class RtMallChannel extends AbstractSourceChannel { | @@ -48,6 +49,7 @@ public class RtMallChannel extends AbstractSourceChannel { | ||
| 48 | RtMallDynamicProperty.AppSecretDynamicProperty property = rtMallDynamicProperty.getBySourceAndType(authLogin.getSource(), authLogin.getOrderType()); | 49 | RtMallDynamicProperty.AppSecretDynamicProperty property = rtMallDynamicProperty.getBySourceAndType(authLogin.getSource(), authLogin.getOrderType()); |
| 49 | LOG.info("authUrl property: {}", JsonUtils.toJsonString(property)); | 50 | LOG.info("authUrl property: {}", JsonUtils.toJsonString(property)); |
| 50 | authLogin.setMchId(property.getMchId()); | 51 | authLogin.setMchId(property.getMchId()); |
| 52 | + authLogin.setToken(token); | ||
| 51 | 53 | ||
| 52 | // 替换参数 | 54 | // 替换参数 |
| 53 | String authUrl = property.getAuthUrl(); | 55 | String authUrl = property.getAuthUrl(); |
| @@ -160,6 +162,35 @@ public class RtMallChannel extends AbstractSourceChannel { | @@ -160,6 +162,35 @@ public class RtMallChannel extends AbstractSourceChannel { | ||
| 160 | } | 162 | } |
| 161 | 163 | ||
| 162 | /** | 164 | /** |
| 165 | + * redirectUrl | ||
| 166 | + */ | ||
| 167 | + @Override | ||
| 168 | + public String redirectUrl(final MallBizOrder mallBizOrder, | ||
| 169 | + final MallBizPayment mallBizPayment) { | ||
| 170 | + RtMallDynamicProperty.AppSecretDynamicProperty property = rtMallDynamicProperty.getBySourceAndType(mallBizOrder.getSource(), mallBizOrder.getOrderType()); | ||
| 171 | + String cashierResultUrl = property.getCashierResultUrl(); | ||
| 172 | + if (StringUtils.isBlank(cashierResultUrl)) { | ||
| 173 | + return null; | ||
| 174 | + } | ||
| 175 | + | ||
| 176 | + long timestamp = DateUtils.timestampInSeconds(); | ||
| 177 | + // 换取token | ||
| 178 | + AuthLoginCO authLogin = getAuthLogin(mallBizOrder.getUserCode(), mallBizOrder.getChannel(), mallBizOrder.getOrderType()); | ||
| 179 | + cashierResultUrl = String.format(cashierResultUrl, authLogin.getToken(), timestamp, mallBizOrder.getOrderId()); | ||
| 180 | + LOG.info("cashierResultUrl: {}", cashierResultUrl); | ||
| 181 | + | ||
| 182 | + // 获取参数 | ||
| 183 | + Map<String, String> queryParams = UrlParamParserUtils.parseQueryParams(cashierResultUrl); | ||
| 184 | + LOG.info("cashierResultUrl queryParams: {}", JsonUtils.toJsonString(queryParams)); | ||
| 185 | + | ||
| 186 | + // 验签 | ||
| 187 | + String sign = RtMallSignMd5Utils.generateSign(queryParams, property.getAppSecret()); | ||
| 188 | + LOG.info("cashierResultUrl sign: {}", sign); | ||
| 189 | + cashierResultUrl = cashierResultUrl.concat("&sign=").concat(sign); | ||
| 190 | + return cashierResultUrl; | ||
| 191 | + } | ||
| 192 | + | ||
| 193 | + /** | ||
| 163 | * getProperty | 194 | * getProperty |
| 164 | */ | 195 | */ |
| 165 | private RtMallDynamicProperty.AppSecretDynamicProperty getProperty(MallBizOrder mallBizOrder) { | 196 | private RtMallDynamicProperty.AppSecretDynamicProperty getProperty(MallBizOrder mallBizOrder) { |
cashier-mall/src/main/java/com/diligrp/cashier/mall/service/sourcechannel/SamMallChannel.java
| @@ -2,6 +2,7 @@ package com.diligrp.cashier.mall.service.sourcechannel; | @@ -2,6 +2,7 @@ package com.diligrp.cashier.mall.service.sourcechannel; | ||
| 2 | 2 | ||
| 3 | import com.diligrp.cashier.mall.domain.rtmall.co.AuthLoginCO; | 3 | import com.diligrp.cashier.mall.domain.rtmall.co.AuthLoginCO; |
| 4 | import com.diligrp.cashier.mall.domain.rtmall.vo.UserInfoVO; | 4 | import com.diligrp.cashier.mall.domain.rtmall.vo.UserInfoVO; |
| 5 | +import com.diligrp.cashier.mall.model.MallBizOrder; | ||
| 5 | import com.diligrp.cashier.mall.model.MallBizPayment; | 6 | import com.diligrp.cashier.mall.model.MallBizPayment; |
| 6 | import com.diligrp.cashier.mall.model.MallBizRefund; | 7 | import com.diligrp.cashier.mall.model.MallBizRefund; |
| 7 | import com.diligrp.cashier.mall.property.RtMallDynamicProperty; | 8 | import com.diligrp.cashier.mall.property.RtMallDynamicProperty; |
| @@ -43,6 +44,11 @@ public class SamMallChannel extends AbstractSourceChannel { | @@ -43,6 +44,11 @@ public class SamMallChannel extends AbstractSourceChannel { | ||
| 43 | } | 44 | } |
| 44 | 45 | ||
| 45 | @Override | 46 | @Override |
| 47 | + public String redirectUrl(MallBizOrder mallBizOrder, MallBizPayment mallBizPayment) { | ||
| 48 | + return ""; | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + @Override | ||
| 46 | public Integer source() { | 52 | public Integer source() { |
| 47 | return 20; | 53 | return 20; |
| 48 | } | 54 | } |
scripts/dili-cashier-mall.sql
0 → 100644
| 1 | +# 订单数据 | ||
| 2 | +CREATE TABLE `mall_biz_order` ( | ||
| 3 | + `id` bigint unsigned NOT NULL, | ||
| 4 | + `order_no` varchar(50) NOT NULL COMMENT '订单单号-系统生成', | ||
| 5 | + `order_id` varchar(64) NOT NULL COMMENT '业务侧订单号', | ||
| 6 | + `trade_id` varchar(64) DEFAULT NULL COMMENT '业务侧支付单号', | ||
| 7 | + `channel` varchar(20) NOT NULL COMMENT 'dili侧渠道(中瑞 地利)', | ||
| 8 | + `firm_id` bigint DEFAULT NULL COMMENT '市场id', | ||
| 9 | + `mch_id` varchar(20) DEFAULT NULL COMMENT 'dili商户code', | ||
| 10 | + `source` tinyint unsigned NOT NULL COMMENT '订单来源(10大润发 2山姆)-换取回调地址', | ||
| 11 | + `order_type` tinyint NOT NULL DEFAULT '3' COMMENT '支付单类型: 1线下扫码购,2 接口扫码购,3小程序', | ||
| 12 | + `user_code` varchar(64) NOT NULL COMMENT '用户编号', | ||
| 13 | + `username` varchar(64) NOT NULL COMMENT '用户名称', | ||
| 14 | + `company_code` varchar(64) DEFAULT NULL COMMENT '企业组编号', | ||
| 15 | + `shop_code` varchar(32) DEFAULT NULL COMMENT '门店编号', | ||
| 16 | + `shop_name` varchar(100) DEFAULT NULL COMMENT '门店名称', | ||
| 17 | + `total_amount` bigint unsigned NOT NULL COMMENT '总金额分', | ||
| 18 | + `freight_fee` bigint unsigned DEFAULT NULL COMMENT '运费分', | ||
| 19 | + `discount_fee` bigint DEFAULT NULL COMMENT '优惠金额, 单位:分', | ||
| 20 | + `state` tinyint unsigned NOT NULL DEFAULT '0' COMMENT '订单状态(0-notpay-未支付 1-payed-已支付 2-notpaycancel-已取消 3-payedcancel-已退款 4-done-订单完成 5-buyer_confirm-待用户收货)', | ||
| 21 | + `rtmart_state` tinyint DEFAULT NULL COMMENT '配送状态(1-transfer-转单 2-package-打包 3-collect-揽件 4-delivery-配达)', | ||
| 22 | + `order_time` datetime NOT NULL COMMENT '下单时间', | ||
| 23 | + `order_expire` int DEFAULT '10' COMMENT '订单有效期分钟-超时自动取消', | ||
| 24 | + `version` int unsigned NOT NULL DEFAULT '1' COMMENT '版本号', | ||
| 25 | + `created_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', | ||
| 26 | + `modifier_name` varchar(50) DEFAULT NULL COMMENT '修改人', | ||
| 27 | + `modified_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', | ||
| 28 | + `deleted` tinyint unsigned NOT NULL DEFAULT '0' COMMENT '是否删除0未删', | ||
| 29 | + PRIMARY KEY (`id`) USING BTREE, | ||
| 30 | + UNIQUE KEY `unq_order_id` (`order_id`) USING BTREE, | ||
| 31 | + KEY `idx_user_code` (`user_code`) USING BTREE, | ||
| 32 | + KEY `idx_order_time` (`order_time`) USING BTREE | ||
| 33 | +) ENGINE=InnoDB COMMENT='业务-订单'; | ||
| 34 | + | ||
| 35 | +CREATE TABLE `mall_biz_order_address` ( | ||
| 36 | + `id` bigint unsigned NOT NULL COMMENT '订单主单id', | ||
| 37 | + `receiver_name` varchar(100) DEFAULT NULL COMMENT '接收名称', | ||
| 38 | + `receiver_mobile` varchar(20) DEFAULT NULL COMMENT '接收电话', | ||
| 39 | + `receiver_address` varchar(250) DEFAULT NULL COMMENT '接收地址', | ||
| 40 | + PRIMARY KEY (`id`) USING BTREE | ||
| 41 | +) ENGINE=InnoDB COMMENT='业务-订单地址'; | ||
| 42 | + | ||
| 43 | +CREATE TABLE `mall_biz_order_item` ( | ||
| 44 | + `id` bigint unsigned NOT NULL, | ||
| 45 | + `biz_order_id` bigint NOT NULL COMMENT '订单主单id', | ||
| 46 | + `sub_order_id` varchar(64) NOT NULL COMMENT '业务侧子订单号', | ||
| 47 | + `order_id` varchar(64) NOT NULL COMMENT '业务侧订单号', | ||
| 48 | + `trade_id` varchar(64) DEFAULT NULL COMMENT '业务侧支付单号', | ||
| 49 | + `shop_code` varchar(32) DEFAULT NULL COMMENT '门店编号', | ||
| 50 | + `shop_name` varchar(100) DEFAULT NULL COMMENT '门店名称', | ||
| 51 | + `item_bn` varchar(100) NOT NULL COMMENT '商品SKU编号', | ||
| 52 | + `item_name` varchar(255) NOT NULL COMMENT '商品名称', | ||
| 53 | + `num` int unsigned NOT NULL COMMENT '数量', | ||
| 54 | + `price` bigint NOT NULL COMMENT '单价分', | ||
| 55 | + `amount` bigint NOT NULL COMMENT '小计金额分', | ||
| 56 | + `discount_fee` bigint DEFAULT NULL COMMENT '优惠金额分', | ||
| 57 | + `pic` varchar(500) DEFAULT NULL COMMENT '商品图片', | ||
| 58 | + `tax_output_rate` varchar(10) DEFAULT NULL COMMENT '销项税率', | ||
| 59 | + `tax_classification_code` varchar(50) DEFAULT NULL COMMENT '税则分类编码', | ||
| 60 | + `tax_classification_name` varchar(100) DEFAULT NULL COMMENT '税则分类名称', | ||
| 61 | + PRIMARY KEY (`id`) USING BTREE, | ||
| 62 | + UNIQUE KEY `unq_sub_order_id` (`sub_order_id`,`trade_id`) USING BTREE, | ||
| 63 | + KEY `idx_order_id` (`order_id`) USING BTREE, | ||
| 64 | + KEY `idx_biz_order_id` (`biz_order_id`) USING BTREE | ||
| 65 | +) ENGINE=InnoDB COMMENT='业务-订单商品明细'; | ||
| 66 | + | ||
| 67 | +CREATE TABLE `mall_biz_payment` ( | ||
| 68 | + `id` bigint unsigned NOT NULL, | ||
| 69 | + `pay_trade_no` varchar(50) NOT NULL COMMENT '支付单号-系统生成', | ||
| 70 | + `biz_order_id` varchar(250) NOT NULL COMMENT '订单id集合(mall_biz_order.id)', | ||
| 71 | + `order_id` varchar(500) NOT NULL COMMENT '业务侧订单号(多个)', | ||
| 72 | + `trade_id` varchar(500) NOT NULL COMMENT '业务侧支付单号(多个)', | ||
| 73 | + `user_code` varchar(50) NOT NULL COMMENT '用户code', | ||
| 74 | + `pay_trade_id` varchar(50) NOT NULL COMMENT 'dili交易流水号', | ||
| 75 | + `firm_id` bigint DEFAULT NULL COMMENT '市场id', | ||
| 76 | + `mch_id` varchar(20) NOT NULL COMMENT 'dili商户code', | ||
| 77 | + `card_no` varchar(50) DEFAULT NULL COMMENT 'dili卡号', | ||
| 78 | + `username` varchar(100) DEFAULT NULL COMMENT 'dili用户名', | ||
| 79 | + `user_id` bigint DEFAULT NULL COMMENT 'dili用户id', | ||
| 80 | + `account_id` bigint DEFAULT NULL COMMENT 'dili账户id', | ||
| 81 | + `fund_account_id` bigint DEFAULT NULL COMMENT 'dili资金账户id', | ||
| 82 | + `open_id` varchar(50) DEFAULT NULL COMMENT '第三方openId', | ||
| 83 | + `pay_fee` bigint NOT NULL COMMENT '支付金额分', | ||
| 84 | + `pay_state` tinyint unsigned NOT NULL DEFAULT '1' COMMENT '1:待支付 2:支付中 4:支付成功 6:支付失败', | ||
| 85 | + `pay_time` datetime DEFAULT NULL COMMENT 'dili支付成功时间', | ||
| 86 | + `channel_id` tinyint unsigned DEFAULT NULL COMMENT '支付渠道(微信 园区卡)', | ||
| 87 | + `cashier_url` varchar(500) DEFAULT NULL COMMENT '收银台跳转链接-创建订单时返回', | ||
| 88 | + `payment_callback` varchar(255) DEFAULT NULL COMMENT '支付成功回调业务侧接口', | ||
| 89 | + `ext` varchar(1000) DEFAULT NULL COMMENT '扩展json', | ||
| 90 | + `version` int unsigned NOT NULL DEFAULT '1' COMMENT '版本号', | ||
| 91 | + `created_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', | ||
| 92 | + `modified_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '变更时间', | ||
| 93 | + PRIMARY KEY (`id`) USING BTREE, | ||
| 94 | + UNIQUE KEY `unq_pay_trade_no` (`pay_trade_no`) USING BTREE, | ||
| 95 | + UNIQUE KEY `unq_pay_trade_id` (`pay_trade_id`) USING BTREE | ||
| 96 | +) ENGINE=InnoDB COMMENT='业务-结算(N订单:1)'; | ||
| 97 | + | ||
| 98 | + | ||
| 99 | +CREATE TABLE `mall_biz_payment_order` ( | ||
| 100 | + `id` bigint unsigned NOT NULL, | ||
| 101 | + `biz_payment_id` bigint NOT NULL COMMENT '结算id(mall_biz_paymen.id)', | ||
| 102 | + `pay_trade_no` varchar(50) NOT NULL COMMENT '支付单号(mall_biz_paymen.pay_trade_no)', | ||
| 103 | + `biz_order_id` bigint NOT NULL COMMENT '订单id(mall_biz_order.id)', | ||
| 104 | + `order_id` varchar(64) NOT NULL COMMENT '业务侧订单号', | ||
| 105 | + `trade_id` varchar(64) NOT NULL COMMENT '业务侧支付单号', | ||
| 106 | + `pay_trade_id` varchar(50) NOT NULL COMMENT 'dili交易流水号(mall_biz_payment.pay_trade_id)', | ||
| 107 | + `pay_fee` bigint NOT NULL COMMENT '支付金额分', | ||
| 108 | + `pay_state` tinyint NOT NULL DEFAULT '1' COMMENT '1:待支付 2:支付中 4:支付成功 6:支付失败', | ||
| 109 | + `pay_time` datetime DEFAULT NULL COMMENT 'dili支付成功时间', | ||
| 110 | + PRIMARY KEY (`id`) USING BTREE, | ||
| 111 | + UNIQUE KEY `unq_order_id` (`order_id`,`trade_id`) USING BTREE, | ||
| 112 | + KEY `idx_biz_order_id` (`biz_order_id`) USING BTREE, | ||
| 113 | + KEY `idx_pay_trade_id` (`pay_trade_id`) USING BTREE, | ||
| 114 | + KEY `idx_pay_trade_no` (`pay_trade_no`) USING BTREE | ||
| 115 | +) ENGINE=InnoDB COMMENT='业务-结算订单(N:N)'; | ||
| 116 | + | ||
| 117 | +CREATE TABLE `mall_biz_refund` ( | ||
| 118 | + `id` bigint unsigned NOT NULL AUTO_INCREMENT, | ||
| 119 | + `biz_payment_id` bigint NOT NULL COMMENT '结算id(mall_biz_payment.id)', | ||
| 120 | + `biz_order_id` bigint NOT NULL COMMENT '订单id(mall_biz_order.id)', | ||
| 121 | + `refund_trade_no` varchar(50) NOT NULL COMMENT '退款单号-系统生成', | ||
| 122 | + `refund_bn` varchar(64) DEFAULT NULL COMMENT '业务侧退款单号', | ||
| 123 | + `order_id` varchar(64) NOT NULL COMMENT '业务侧订单号', | ||
| 124 | + `trade_id` varchar(64) DEFAULT NULL COMMENT '业务侧流水号', | ||
| 125 | + `firm_id` bigint DEFAULT NULL COMMENT '市场id', | ||
| 126 | + `mch_id` varchar(20) NOT NULL COMMENT '商户id', | ||
| 127 | + `pay_trade_no` varchar(50) DEFAULT NULL COMMENT '支付单号(mall_biz_payment.pay_trade_no)', | ||
| 128 | + `refund_trade_id` varchar(50) NOT NULL COMMENT 'dili退款流水号', | ||
| 129 | + `pay_trade_id` varchar(50) DEFAULT NULL COMMENT 'dili交易流水号(mall_biz_payment.pay_trade_id)', | ||
| 130 | + `refund_card_no` varchar(255) DEFAULT NULL COMMENT 'dili卡号', | ||
| 131 | + `refund_user_id` bigint DEFAULT NULL COMMENT 'dili用户id', | ||
| 132 | + `refund_username` varchar(50) DEFAULT NULL COMMENT 'dili用户名称', | ||
| 133 | + `refund_account_id` bigint DEFAULT NULL COMMENT 'dili账号id', | ||
| 134 | + `refund_time` datetime DEFAULT NULL COMMENT 'dili退款成功时间', | ||
| 135 | + `refund_fee` bigint NOT NULL COMMENT '退款金额分', | ||
| 136 | + `freight_fee` bigint DEFAULT '0' COMMENT '退运费分', | ||
| 137 | + `refund_state` tinyint unsigned NOT NULL DEFAULT '1' COMMENT '1:待支付 2:支付中 4:支付成功 6:支付失败', | ||
| 138 | + `refund_reason` varchar(255) DEFAULT NULL COMMENT '退款原因', | ||
| 139 | + `refund_callback` varchar(255) DEFAULT NULL COMMENT '退款成功回调业务侧接口', | ||
| 140 | + `version` int unsigned NOT NULL DEFAULT '1' COMMENT '版本号', | ||
| 141 | + `creater_name` varchar(50) NOT NULL COMMENT '申请人', | ||
| 142 | + `created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '退款申请时间', | ||
| 143 | + `refuse_reason` varchar(500) DEFAULT NULL COMMENT '失败原因', | ||
| 144 | + PRIMARY KEY (`id`) USING BTREE, | ||
| 145 | + UNIQUE KEY `unq_refund_trade_id` (`refund_trade_id`) USING BTREE, | ||
| 146 | + UNIQUE KEY `unq_refund_bn` (`refund_bn`) USING BTREE, | ||
| 147 | + KEY `idx_order_id` (`order_id`) USING BTREE, | ||
| 148 | + KEY `idx_refund_trarde_no` (`refund_trade_no`) USING BTREE | ||
| 149 | +) ENGINE=InnoDB COMMENT='业务-退款'; | ||
| 150 | + | ||
| 151 | +CREATE TABLE `mall_biz_refund_item` ( | ||
| 152 | + `id` bigint unsigned NOT NULL AUTO_INCREMENT, | ||
| 153 | + `biz_refund_id` bigint unsigned NOT NULL COMMENT '退款主单id', | ||
| 154 | + `sub_order_id` bigint unsigned NOT NULL COMMENT '业务子订单ID', | ||
| 155 | + `item_bn` varchar(100) DEFAULT NULL COMMENT '商品SKU编号', | ||
| 156 | + `item_name` varchar(255) DEFAULT NULL COMMENT '商品名称', | ||
| 157 | + `num` int unsigned DEFAULT NULL COMMENT '退货数量', | ||
| 158 | + `refund_fee` bigint DEFAULT NULL COMMENT '退款金额分', | ||
| 159 | + PRIMARY KEY (`id`) USING BTREE, | ||
| 160 | + UNIQUE KEY `unq_sub_order_id` (`sub_order_id`) USING BTREE, | ||
| 161 | + KEY `idx_biz_refund_id` (`biz_refund_id`) USING BTREE | ||
| 162 | +) ENGINE=InnoDB COMMENT='业务-退款商品明细'; |