Commit 01f6a2ee120a0f8e4849da936e0fc483e25a0803
1 parent
5037436e
feat rtmart payment
Showing
5 changed files
with
41 additions
and
6 deletions
cashier-mall/src/main/java/com/diligrp/cashier/mall/dao/MallBizPaymentOrderDao.java
| ... | ... | @@ -33,4 +33,6 @@ public interface MallBizPaymentOrderDao extends MybatisMapperSupport { |
| 33 | 33 | void updateByPayment(MallBizPayment mallBizPayment); |
| 34 | 34 | |
| 35 | 35 | List<MallBizPaymentOrder> listPaymentOrderByBizOrderId(@Param("bizOrderId") Long bizOrderId); |
| 36 | + | |
| 37 | + List<MallBizPaymentOrder> listPaymentOrderByBizOrderIds(@Param("bizOrderIds") List<Long> bizOrderIds); | |
| 36 | 38 | } | ... | ... |
cashier-mall/src/main/java/com/diligrp/cashier/mall/service/biz/MallBizPaymentService.java
| ... | ... | @@ -45,4 +45,6 @@ public interface MallBizPaymentService { |
| 45 | 45 | void cancel(MallBizPaymentOrder mallBizPaymentOrder); |
| 46 | 46 | |
| 47 | 47 | List<MallBizPaymentOrder> listPaymentOrderByBizOrderId(Long bizOrderId); |
| 48 | + | |
| 49 | + List<MallBizPaymentOrder> listPaymentOrderByBizOrderIds(List<Long> bizOrderIds); | |
| 48 | 50 | } | ... | ... |
cashier-mall/src/main/java/com/diligrp/cashier/mall/service/biz/impl/MallBizPaymentServiceImpl.java
| ... | ... | @@ -259,12 +259,11 @@ public class MallBizPaymentServiceImpl implements MallBizPaymentService { |
| 259 | 259 | */ |
| 260 | 260 | @Override |
| 261 | 261 | public void cancel(MallBizPaymentOrder mallBizPaymentOrder) { |
| 262 | - mallBizPaymentOrder.cancel(); | |
| 263 | 262 | mallBizPaymentOrderDao.updateByPrimaryKeySelective(mallBizPaymentOrder); |
| 264 | 263 | } |
| 265 | 264 | |
| 266 | 265 | /** |
| 267 | - * return List.of(); | |
| 266 | + * listPaymentOrderByBizOrderId | |
| 268 | 267 | */ |
| 269 | 268 | @Override |
| 270 | 269 | public List<MallBizPaymentOrder> listPaymentOrderByBizOrderId(Long bizOrderId) { |
| ... | ... | @@ -272,6 +271,15 @@ public class MallBizPaymentServiceImpl implements MallBizPaymentService { |
| 272 | 271 | } |
| 273 | 272 | |
| 274 | 273 | /** |
| 274 | + * listPaymentOrderByBizOrderIds | |
| 275 | + */ | |
| 276 | + @Override | |
| 277 | + public List<MallBizPaymentOrder> listPaymentOrderByBizOrderIds(List<Long> bizOrderIds) { | |
| 278 | + return mallBizPaymentOrderDao.listPaymentOrderByBizOrderIds(bizOrderIds); | |
| 279 | + } | |
| 280 | + | |
| 281 | + | |
| 282 | + /** | |
| 275 | 283 | * 处理单个支付流水的分摊通知 |
| 276 | 284 | * 1. 调用大润发订单详情接口获取商品信息 |
| 277 | 285 | * 2. 更新订单状态 | ... | ... |
cashier-mall/src/main/java/com/diligrp/cashier/mall/service/sourcechannel/AbstractSourceChannel.java
| ... | ... | @@ -97,14 +97,13 @@ public abstract class AbstractSourceChannel { |
| 97 | 97 | @Transactional(rollbackFor = {Exception.class}) |
| 98 | 98 | public void paymentOnEvent(PaymentResultBO event, MallBizPayment mallBizPayment) { |
| 99 | 99 | LOG.info("paymentOnEvent event: {} mallBizPayment: {}", JsonUtils.toJsonString(event), JsonUtils.toJsonString(mallBizPayment)); |
| 100 | - // update mall_biz_order | |
| 101 | - List<Long> bizOrderIds = Arrays.stream(mallBizPayment.getBizOrderId().split(",")).map(Long::valueOf).toList(); | |
| 102 | - mallBizOrderDao.updateByIds(bizOrderIds, OrderState.PAYED.code); | |
| 103 | - | |
| 104 | 100 | // update mall_biz_payment |
| 105 | 101 | mallBizPayment.payCallBack(event); |
| 106 | 102 | mallBizPaymentService.updateByPay(mallBizPayment); |
| 107 | 103 | |
| 104 | + // check all refund state | |
| 105 | + updateOrder(mallBizPayment); | |
| 106 | + | |
| 108 | 107 | // notify other channel |
| 109 | 108 | payCallBack(event, mallBizPayment); |
| 110 | 109 | } |
| ... | ... | @@ -138,6 +137,18 @@ public abstract class AbstractSourceChannel { |
| 138 | 137 | } |
| 139 | 138 | |
| 140 | 139 | /** |
| 140 | + * updateOrder | |
| 141 | + */ | |
| 142 | + private void updateOrder(MallBizPayment mallBizPayment) { | |
| 143 | + List<Long> bizOrderIds = Arrays.stream(mallBizPayment.getBizOrderId().split(",")).map(Long::valueOf).toList(); | |
| 144 | + List<MallBizPaymentOrder> paymentOrderList = mallBizPaymentService.listPaymentOrderByBizOrderIds(bizOrderIds); | |
| 145 | + boolean success = paymentOrderList.stream().allMatch(vo -> Objects.equals(vo.getPayState(), PaymentState.SUCCESS.getCode())); | |
| 146 | + if (success) { | |
| 147 | + mallBizOrderDao.updateByIds(bizOrderIds, OrderState.PAYED.code); | |
| 148 | + } | |
| 149 | + } | |
| 150 | + | |
| 151 | + /** | |
| 141 | 152 | * 渠道 |
| 142 | 153 | */ |
| 143 | 154 | public abstract Integer source(); | ... | ... |
cashier-mall/src/main/resources/com/diligrp/cashier/dao/mapper/MallBizPaymentOrderDao.xml
| ... | ... | @@ -122,6 +122,9 @@ |
| 122 | 122 | <if test="payFee != null"> |
| 123 | 123 | pay_fee = #{payFee,jdbcType=BIGINT}, |
| 124 | 124 | </if> |
| 125 | + <if test="payState != null"> | |
| 126 | + pay_state = #{payState,jdbcType=INTEGER}, | |
| 127 | + </if> | |
| 125 | 128 | <if test="payTime != null"> |
| 126 | 129 | pay_time = #{payTime,jdbcType=TIMESTAMP}, |
| 127 | 130 | </if> |
| ... | ... | @@ -189,4 +192,13 @@ |
| 189 | 192 | where biz_payment_id = #{id} |
| 190 | 193 | </update> |
| 191 | 194 | |
| 195 | + <select id="listPaymentOrderByBizOrderIds" resultType="com.diligrp.cashier.mall.model.MallBizPaymentOrder"> | |
| 196 | + select | |
| 197 | + <include refid="Base_Column_List" /> | |
| 198 | + from mall_biz_payment_order | |
| 199 | + where biz_order_id in | |
| 200 | + <foreach collection="bizOrderIds" item="bizOrderId" index="index" open="(" close=")" separator=","> | |
| 201 | + #{bizOrderId} | |
| 202 | + </foreach> | |
| 203 | + </select> | |
| 192 | 204 | </mapper> | ... | ... |