Commit 34d290d2c9daa432cff80cbd2ab3ca35ac799abd
1 parent
aab77929
feat scan order
Showing
8 changed files
with
112 additions
and
26 deletions
cashier-mall/src/main/java/com/diligrp/cashier/mall/domain/rtmall/co/OrderCO.java
| @@ -39,7 +39,7 @@ public class OrderCO extends RtMarkBaseCO { | @@ -39,7 +39,7 @@ public class OrderCO extends RtMarkBaseCO { | ||
| 39 | @NotNull(message = "total_amount is required") | 39 | @NotNull(message = "total_amount is required") |
| 40 | private Long totalAmount; | 40 | private Long totalAmount; |
| 41 | 41 | ||
| 42 | - @NotNull(message = "freight_fee is required") | 42 | + // @NotNull(message = "freight_fee is required") |
| 43 | private Long freightFee; | 43 | private Long freightFee; |
| 44 | 44 | ||
| 45 | private Long discountFee; | 45 | private Long discountFee; |
cashier-mall/src/main/java/com/diligrp/cashier/mall/domain/rtmall/co/RefundCO.java
| @@ -28,7 +28,7 @@ public class RefundCO extends RtMarkBaseCO { | @@ -28,7 +28,7 @@ public class RefundCO extends RtMarkBaseCO { | ||
| 28 | /** | 28 | /** |
| 29 | * 业务侧退款单号 | 29 | * 业务侧退款单号 |
| 30 | */ | 30 | */ |
| 31 | - @NotBlank(message = "refund bn is required") | 31 | +// @NotBlank(message = "refund bn is required") |
| 32 | private String refundBn; | 32 | private String refundBn; |
| 33 | 33 | ||
| 34 | /** | 34 | /** |
| @@ -40,7 +40,7 @@ public class RefundCO extends RtMarkBaseCO { | @@ -40,7 +40,7 @@ public class RefundCO extends RtMarkBaseCO { | ||
| 40 | /** | 40 | /** |
| 41 | * 退款金额 | 41 | * 退款金额 |
| 42 | */ | 42 | */ |
| 43 | - @NotNull(message = "refund fee is required") | 43 | +// @NotNull(message = "refund fee is required") |
| 44 | private Long refundFee; | 44 | private Long refundFee; |
| 45 | 45 | ||
| 46 | /** | 46 | /** |
cashier-mall/src/main/java/com/diligrp/cashier/mall/model/MallBizPayment.java
| 1 | package com.diligrp.cashier.mall.model; | 1 | package com.diligrp.cashier.mall.model; |
| 2 | 2 | ||
| 3 | +import com.diligrp.cashier.mall.context.MallInitializeContext; | ||
| 3 | import com.diligrp.cashier.mall.domain.rtmall.vo.OrderPaymentVO; | 4 | import com.diligrp.cashier.mall.domain.rtmall.vo.OrderPaymentVO; |
| 4 | import com.diligrp.cashier.mall.property.RtMallDynamicProperty; | 5 | import com.diligrp.cashier.mall.property.RtMallDynamicProperty; |
| 5 | import com.diligrp.cashier.mall.type.OrderType; | 6 | import com.diligrp.cashier.mall.type.OrderType; |
| @@ -376,11 +377,8 @@ public class MallBizPayment extends BaseDO { | @@ -376,11 +377,8 @@ public class MallBizPayment extends BaseDO { | ||
| 376 | public void payCallBack(PaymentResultBO event) { | 377 | public void payCallBack(PaymentResultBO event) { |
| 377 | this.setPayState(event.getState()); | 378 | this.setPayState(event.getState()); |
| 378 | this.setPayTime(event.getWhen()); | 379 | this.setPayTime(event.getWhen()); |
| 379 | - // TODO 2026/1/6: 先固定 | ||
| 380 | - this.setUsername("人工"); | ||
| 381 | this.setExt(event.getPayerId()); | 380 | this.setExt(event.getPayerId()); |
| 382 | this.setChannelId(event.getOutPayType()); | 381 | this.setChannelId(event.getOutPayType()); |
| 383 | - | ||
| 384 | - // TODO 2026/1/6: 其它信息 | 382 | + MallInitializeContext.getByPayChannel(this.getChannelId()).fill(this, event); |
| 385 | } | 383 | } |
| 386 | } | 384 | } |
cashier-mall/src/main/java/com/diligrp/cashier/mall/service/biz/impl/MallBizOrderServiceImpl.java
| @@ -19,7 +19,7 @@ import com.diligrp.cashier.mall.service.biz.MallBizPaymentService; | @@ -19,7 +19,7 @@ import com.diligrp.cashier.mall.service.biz.MallBizPaymentService; | ||
| 19 | import com.diligrp.cashier.mall.type.OrderState; | 19 | import com.diligrp.cashier.mall.type.OrderState; |
| 20 | import com.diligrp.cashier.mall.type.OrderType; | 20 | import com.diligrp.cashier.mall.type.OrderType; |
| 21 | import com.diligrp.cashier.mall.type.RtMarkErrorCode; | 21 | import com.diligrp.cashier.mall.type.RtMarkErrorCode; |
| 22 | -import com.diligrp.cashier.shared.exception.PlatformServiceException; | 22 | +import com.diligrp.cashier.shared.domain.BaseDO; |
| 23 | import com.diligrp.cashier.shared.spi.ICashierDeskManager; | 23 | import com.diligrp.cashier.shared.spi.ICashierDeskManager; |
| 24 | import com.diligrp.cashier.shared.spi.domain.CashierOrderBO; | 24 | import com.diligrp.cashier.shared.spi.domain.CashierOrderBO; |
| 25 | import com.diligrp.cashier.shared.spi.domain.PaymentUrlBO; | 25 | import com.diligrp.cashier.shared.spi.domain.PaymentUrlBO; |
| @@ -35,8 +35,10 @@ import org.springframework.stereotype.Service; | @@ -35,8 +35,10 @@ import org.springframework.stereotype.Service; | ||
| 35 | import org.springframework.transaction.annotation.Transactional; | 35 | import org.springframework.transaction.annotation.Transactional; |
| 36 | 36 | ||
| 37 | import java.util.List; | 37 | import java.util.List; |
| 38 | +import java.util.Map; | ||
| 38 | import java.util.Objects; | 39 | import java.util.Objects; |
| 39 | import java.util.Optional; | 40 | import java.util.Optional; |
| 41 | +import java.util.stream.Collectors; | ||
| 40 | 42 | ||
| 41 | /** | 43 | /** |
| 42 | * @ClassName MallBizOrderServiceImpl.java | 44 | * @ClassName MallBizOrderServiceImpl.java |
| @@ -156,24 +158,24 @@ public class MallBizOrderServiceImpl implements MallBizOrderService { | @@ -156,24 +158,24 @@ public class MallBizOrderServiceImpl implements MallBizOrderService { | ||
| 156 | batchUpdate(mallBizOrders, existOrders); | 158 | batchUpdate(mallBizOrders, existOrders); |
| 157 | 159 | ||
| 158 | // mall_biz_order_item | 160 | // mall_biz_order_item |
| 159 | - List<MallBizOrderItem> orderItems = mallBizOrders.stream().flatMap(vo -> vo.getMallBizOrderItems().stream()).toList(); | ||
| 160 | - Optional.of(orderItems) | ||
| 161 | - .ifPresent(mallBizOrderItems -> { | ||
| 162 | - mallBizOrderItemDao.batchInsert(mallBizOrderItems); | ||
| 163 | - }); | 161 | + List<MallBizOrderItem> orderItems = mallBizOrders.stream() |
| 162 | + .filter(vo -> CollectionUtils.isNotEmpty(vo.getMallBizOrderItems())) | ||
| 163 | + .flatMap(vo -> vo.getMallBizOrderItems().stream()).toList(); | ||
| 164 | + if (CollectionUtils.isNotEmpty(orderItems)) { | ||
| 165 | + mallBizOrderItemDao.batchInsert(orderItems); | ||
| 166 | + } | ||
| 164 | 167 | ||
| 165 | // mall_biz_payment | 168 | // mall_biz_payment |
| 166 | Optional.ofNullable(mallBizPayment).ifPresent(mallBizPaymentService::save); | 169 | Optional.ofNullable(mallBizPayment).ifPresent(mallBizPaymentService::save); |
| 167 | 170 | ||
| 168 | // mall_biz_payment_order | 171 | // mall_biz_payment_order |
| 169 | List<MallBizPaymentOrder> bizPaymentOrders = mallBizOrders.stream().flatMap(vo -> vo.getMallBizPaymentOrders().stream()).toList(); | 172 | List<MallBizPaymentOrder> bizPaymentOrders = mallBizOrders.stream().flatMap(vo -> vo.getMallBizPaymentOrders().stream()).toList(); |
| 170 | - Optional.of(bizPaymentOrders) | ||
| 171 | - .ifPresent(paymentOrders -> { | ||
| 172 | - paymentOrders.forEach(vo -> { | ||
| 173 | - vo.setPayTradeId(mallBizPayment.getPayTradeId()); | ||
| 174 | - }); | ||
| 175 | - mallBizPaymentOrderDao.batchInsert(paymentOrders); | ||
| 176 | - }); | 173 | + if (CollectionUtils.isNotEmpty(bizPaymentOrders)) { |
| 174 | + bizPaymentOrders.forEach(vo -> { | ||
| 175 | + vo.setPayTradeId(mallBizPayment.getPayTradeId()); | ||
| 176 | + }); | ||
| 177 | + mallBizPaymentOrderDao.batchInsert(bizPaymentOrders); | ||
| 178 | + } | ||
| 177 | } | 179 | } |
| 178 | 180 | ||
| 179 | /** | 181 | /** |
| @@ -210,11 +212,13 @@ public class MallBizOrderServiceImpl implements MallBizOrderService { | @@ -210,11 +212,13 @@ public class MallBizOrderServiceImpl implements MallBizOrderService { | ||
| 210 | mallBizOrderDao.batchInsert(saveOrders); | 212 | mallBizOrderDao.batchInsert(saveOrders); |
| 211 | 213 | ||
| 212 | // mall_biz_order_address | 214 | // mall_biz_order_address |
| 213 | - List<MallBizOrderAddress> mallBizOrderAddresses = mallBizOrders.stream().map(MallBizOrder::getMallBizOrderAddress).toList(); | ||
| 214 | - Optional.of(mallBizOrderAddresses) | ||
| 215 | - .ifPresent(mallBizOrderAddress -> { | ||
| 216 | - mallBizOrderAddressDao.batchInsert(mallBizOrderAddress); | ||
| 217 | - }); | 215 | + List<MallBizOrderAddress> mallBizOrderAddresses = mallBizOrders.stream() |
| 216 | + .map(MallBizOrder::getMallBizOrderAddress) | ||
| 217 | + .filter(Objects::nonNull) | ||
| 218 | + .toList(); | ||
| 219 | + if (CollectionUtils.isNotEmpty(mallBizOrderAddresses)) { | ||
| 220 | + mallBizOrderAddressDao.batchInsert(mallBizOrderAddresses); | ||
| 221 | + } | ||
| 218 | } | 222 | } |
| 219 | } | 223 | } |
| 220 | 224 | ||
| @@ -223,8 +227,17 @@ public class MallBizOrderServiceImpl implements MallBizOrderService { | @@ -223,8 +227,17 @@ public class MallBizOrderServiceImpl implements MallBizOrderService { | ||
| 223 | */ | 227 | */ |
| 224 | private void batchUpdate(final List<MallBizOrder> mallBizOrders, | 228 | private void batchUpdate(final List<MallBizOrder> mallBizOrders, |
| 225 | final List<MallBizOrder> existOrders) { | 229 | final List<MallBizOrder> existOrders) { |
| 230 | + if (CollectionUtils.isEmpty(existOrders)) { | ||
| 231 | + return; | ||
| 232 | + } | ||
| 233 | + | ||
| 234 | + Map<String, Long> orderIdMap = existOrders.stream().collect(Collectors.toMap(MallBizOrder::getOrderId, BaseDO::getId)); | ||
| 226 | List<String> existOrderIds = existOrders.stream().map(MallBizOrder::getOrderId).toList(); | 235 | List<String> existOrderIds = existOrders.stream().map(MallBizOrder::getOrderId).toList(); |
| 227 | 236 | ||
| 237 | + // 还原id | ||
| 238 | + mallBizOrders.forEach(vo -> { | ||
| 239 | + vo.setId(orderIdMap.getOrDefault(vo.getOrderId(), vo.getId())); | ||
| 240 | + }); | ||
| 228 | List<MallBizOrder> updateOrders = mallBizOrders.stream().filter(vo -> existOrderIds.contains(vo.getOrderId())).toList(); | 241 | List<MallBizOrder> updateOrders = mallBizOrders.stream().filter(vo -> existOrderIds.contains(vo.getOrderId())).toList(); |
| 229 | if (CollectionUtils.isNotEmpty(updateOrders)) { | 242 | if (CollectionUtils.isNotEmpty(updateOrders)) { |
| 230 | mallBizOrderDao.batchUpdate(updateOrders, mallBizOrders.getFirst().getSource()); | 243 | mallBizOrderDao.batchUpdate(updateOrders, mallBizOrders.getFirst().getSource()); |
| @@ -248,7 +261,7 @@ public class MallBizOrderServiceImpl implements MallBizOrderService { | @@ -248,7 +261,7 @@ public class MallBizOrderServiceImpl implements MallBizOrderService { | ||
| 248 | cashierOrderBO.setSource(mallBizOrders.getFirst().getSource()); | 261 | cashierOrderBO.setSource(mallBizOrders.getFirst().getSource()); |
| 249 | cashierOrderBO.setGoods( | 262 | cashierOrderBO.setGoods( |
| 250 | SourceType.getName(mallBizOrders.getFirst().getSource()) + | 263 | SourceType.getName(mallBizOrders.getFirst().getSource()) + |
| 251 | - OrderType.getDescription(mallBizOrders.getFirst().getOrderType()) + "支付!" | 264 | + OrderType.getDescription(mallBizOrders.getFirst().getOrderType()) + "支付" |
| 252 | ); | 265 | ); |
| 253 | cashierOrderBO.setDescription(cashierOrderBO.getGoods()); | 266 | cashierOrderBO.setDescription(cashierOrderBO.getGoods()); |
| 254 | cashierOrderBO.setAttach(cashierOrderBO.getGoods()); | 267 | cashierOrderBO.setAttach(cashierOrderBO.getGoods()); |
cashier-mall/src/main/java/com/diligrp/cashier/mall/service/paychannel/AbstractPayChannel.java
| 1 | package com.diligrp.cashier.mall.service.paychannel; | 1 | package com.diligrp.cashier.mall.service.paychannel; |
| 2 | 2 | ||
| 3 | +import com.diligrp.cashier.mall.model.MallBizPayment; | ||
| 4 | +import com.diligrp.cashier.shared.spi.domain.PaymentResultBO; | ||
| 3 | import org.slf4j.Logger; | 5 | import org.slf4j.Logger; |
| 4 | import org.slf4j.LoggerFactory; | 6 | import org.slf4j.LoggerFactory; |
| 5 | 7 | ||
| @@ -14,4 +16,6 @@ public abstract class AbstractPayChannel { | @@ -14,4 +16,6 @@ public abstract class AbstractPayChannel { | ||
| 14 | protected final Logger LOG = LoggerFactory.getLogger(getClass()); | 16 | protected final Logger LOG = LoggerFactory.getLogger(getClass()); |
| 15 | 17 | ||
| 16 | public abstract Integer getPayChannel(); | 18 | public abstract Integer getPayChannel(); |
| 19 | + | ||
| 20 | + public abstract void fill(MallBizPayment mallBizPayment, PaymentResultBO event); | ||
| 17 | } | 21 | } |
cashier-mall/src/main/java/com/diligrp/cashier/mall/service/paychannel/CardPayChannel.java
| 1 | package com.diligrp.cashier.mall.service.paychannel; | 1 | package com.diligrp.cashier.mall.service.paychannel; |
| 2 | 2 | ||
| 3 | +import com.diligrp.cashier.mall.model.MallBizPayment; | ||
| 3 | import com.diligrp.cashier.pipeline.type.ChannelType; | 4 | import com.diligrp.cashier.pipeline.type.ChannelType; |
| 5 | +import com.diligrp.cashier.shared.spi.domain.PaymentResultBO; | ||
| 6 | +import com.diligrp.cashier.shared.util.JsonUtils; | ||
| 7 | +import com.fasterxml.jackson.core.type.TypeReference; | ||
| 8 | +import org.slf4j.Logger; | ||
| 9 | +import org.slf4j.LoggerFactory; | ||
| 4 | import org.springframework.stereotype.Component; | 10 | import org.springframework.stereotype.Component; |
| 5 | 11 | ||
| 12 | +import java.util.Map; | ||
| 13 | +import java.util.Optional; | ||
| 14 | + | ||
| 6 | /** | 15 | /** |
| 7 | * @ClassName CardPayChannel.java | 16 | * @ClassName CardPayChannel.java |
| 8 | * @author dengwei | 17 | * @author dengwei |
| @@ -12,6 +21,25 @@ import org.springframework.stereotype.Component; | @@ -12,6 +21,25 @@ import org.springframework.stereotype.Component; | ||
| 12 | */ | 21 | */ |
| 13 | @Component | 22 | @Component |
| 14 | public class CardPayChannel extends AbstractPayChannel { | 23 | public class CardPayChannel extends AbstractPayChannel { |
| 24 | + protected final Logger LOG = LoggerFactory.getLogger(getClass()); | ||
| 25 | + | ||
| 26 | + @Override | ||
| 27 | + public void fill(MallBizPayment mallBizPayment, PaymentResultBO event) { | ||
| 28 | + String payerId = event.getPayerId(); | ||
| 29 | + try { | ||
| 30 | + Map<String, Object> payer = JsonUtils.fromJsonString(payerId, new TypeReference<>() { | ||
| 31 | + }); | ||
| 32 | + Optional.ofNullable(payer).ifPresent(user -> { | ||
| 33 | + mallBizPayment.setCardNo((String) user.get("cardNo")); | ||
| 34 | + mallBizPayment.setUsername((String) user.get("name")); | ||
| 35 | + mallBizPayment.setUserId((Long) user.get("customerId")); | ||
| 36 | + mallBizPayment.setAccountId((Long) user.get("accountId")); | ||
| 37 | + }); | ||
| 38 | + } catch (Exception e) { | ||
| 39 | + LOG.warn("parse payerId json error, tradeId={} outTradeNo={}", event.getTradeId(), event.getOutTradeNo(), e); | ||
| 40 | + } | ||
| 41 | + } | ||
| 42 | + | ||
| 15 | @Override | 43 | @Override |
| 16 | public Integer getPayChannel() { | 44 | public Integer getPayChannel() { |
| 17 | return ChannelType.DILIPAY.getCode(); | 45 | return ChannelType.DILIPAY.getCode(); |
cashier-mall/src/main/java/com/diligrp/cashier/mall/service/paychannel/RcbPayChannel.java
0 → 100644
| 1 | +package com.diligrp.cashier.mall.service.paychannel; | ||
| 2 | + | ||
| 3 | +import com.diligrp.cashier.mall.model.MallBizPayment; | ||
| 4 | +import com.diligrp.cashier.pipeline.type.ChannelType; | ||
| 5 | +import com.diligrp.cashier.shared.spi.domain.PaymentResultBO; | ||
| 6 | +import org.slf4j.Logger; | ||
| 7 | +import org.slf4j.LoggerFactory; | ||
| 8 | +import org.springframework.stereotype.Component; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * @ClassName RcbPayChannel.java | ||
| 12 | + * @author dengwei | ||
| 13 | + * @version 1.0.0 | ||
| 14 | + * @Description RcbPayChannel | ||
| 15 | + * 农商行支付渠道 | ||
| 16 | + */ | ||
| 17 | +@Component | ||
| 18 | +public class RcbPayChannel extends AbstractPayChannel { | ||
| 19 | + protected final Logger LOG = LoggerFactory.getLogger(getClass()); | ||
| 20 | + | ||
| 21 | + @Override | ||
| 22 | + public void fill(MallBizPayment mallBizPayment, PaymentResultBO event) { | ||
| 23 | + mallBizPayment.setOpenId(event.getPayerId()); | ||
| 24 | + mallBizPayment.setUsername(event.getPayerId()); | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + @Override | ||
| 28 | + public Integer getPayChannel() { | ||
| 29 | + return ChannelType.RCB.getCode(); | ||
| 30 | + } | ||
| 31 | +} |
cashier-mall/src/main/java/com/diligrp/cashier/mall/service/paychannel/WeChatPayChannel.java
| 1 | package com.diligrp.cashier.mall.service.paychannel; | 1 | package com.diligrp.cashier.mall.service.paychannel; |
| 2 | 2 | ||
| 3 | +import com.diligrp.cashier.mall.model.MallBizPayment; | ||
| 3 | import com.diligrp.cashier.pipeline.type.ChannelType; | 4 | import com.diligrp.cashier.pipeline.type.ChannelType; |
| 5 | +import com.diligrp.cashier.shared.spi.domain.PaymentResultBO; | ||
| 6 | +import org.slf4j.Logger; | ||
| 7 | +import org.slf4j.LoggerFactory; | ||
| 4 | import org.springframework.stereotype.Component; | 8 | import org.springframework.stereotype.Component; |
| 5 | 9 | ||
| 6 | /** | 10 | /** |
| @@ -12,6 +16,14 @@ import org.springframework.stereotype.Component; | @@ -12,6 +16,14 @@ import org.springframework.stereotype.Component; | ||
| 12 | */ | 16 | */ |
| 13 | @Component | 17 | @Component |
| 14 | public class WeChatPayChannel extends AbstractPayChannel { | 18 | public class WeChatPayChannel extends AbstractPayChannel { |
| 19 | + protected final Logger LOG = LoggerFactory.getLogger(getClass()); | ||
| 20 | + | ||
| 21 | + @Override | ||
| 22 | + public void fill(MallBizPayment mallBizPayment, PaymentResultBO event) { | ||
| 23 | + mallBizPayment.setOpenId(event.getPayerId()); | ||
| 24 | + mallBizPayment.setUsername(event.getPayerId()); | ||
| 25 | + } | ||
| 26 | + | ||
| 15 | @Override | 27 | @Override |
| 16 | public Integer getPayChannel() { | 28 | public Integer getPayChannel() { |
| 17 | return ChannelType.WXPAY.getCode(); | 29 | return ChannelType.WXPAY.getCode(); |