feat:线下支付
This commit is contained in:
1 parent
96dbde3943
commit
cd2179a7d5
9 files changed
+75
-9
No files matched your search
+10
-1
@@ -6,6 +6,7 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 硬件订单支付方式
|
||||
@@ -13,7 +14,7 @@ import java.util.Arrays;
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum HardPayTypeEnum {
|
||||
WALLET_DEFAULT("1", "普通钱包支付"),
|
||||
WALLET_DEFAULT("1", "钱包支付"),
|
||||
WALLET_QR_CODE("2", "钱包二维码支付"),
|
||||
WALLET_QR_CODE_SCAN("22", "钱包扫一扫支付"),
|
||||
WALLET_CARD("3", "钱包饭卡支付"),
|
||||
@@ -26,6 +27,14 @@ public enum HardPayTypeEnum {
|
||||
private final String type;
|
||||
private final String description;
|
||||
|
||||
public static final List<HardPayTypeEnum> payTypeTotalDisplayList = List.of(
|
||||
WALLET_DEFAULT,
|
||||
WALLET_QR_CODE,
|
||||
WALLET_QR_CODE_SCAN,
|
||||
FACE,
|
||||
CASH
|
||||
);
|
||||
|
||||
public static HardPayTypeEnum valueOfByType(String type) {
|
||||
if (ObjectUtil.isEmpty(type)) return null;
|
||||
return Arrays.stream(values()).filter(v -> ObjectUtil.equals(type, v.getType())).findFirst().get();
|
||||
|
||||
+3
-2
@@ -107,14 +107,15 @@ public class HardOrderController {
|
||||
|
||||
@Operation(summary = "app创建订单扫一扫", description = "app创建订单扫一扫")
|
||||
@PostMapping("/app/create-order-scan-qrcode")
|
||||
@Idempotent(expireTime = 10, info = "正在创建订单中,请勿重复操作")
|
||||
@Idempotent(expireTime = 5, info = "正在创建订单中,请勿重复操作")
|
||||
public R appCreateOrderScancode(@Validated @RequestBody HardAppCreateOrderScancode body) {
|
||||
PjcloudUser user = SecurityUtils.getUser();
|
||||
HardAppCreateOrderDto dto = HardAppCreateOrderDto.builder()
|
||||
.customPrice(body.getCustomPrice())
|
||||
.merchantId(body.getMerchantId())
|
||||
.userId(user.getId())
|
||||
.hardType(HardTypeEnum.MERCHANT_QR_CODE)
|
||||
.orderType(HardOrderTypeEnum.RESERVE)
|
||||
.orderType(HardOrderTypeEnum.BELOW)
|
||||
.walletType(WalletTypeEnum.EAT)
|
||||
.payType(HardPayTypeEnum.WALLET_QR_CODE_SCAN)
|
||||
.build();
|
||||
|
||||
+6
@@ -60,6 +60,12 @@ public class HardOrderTotalController {
|
||||
return R.ok(HardOrderTotalService.listCs(dto));
|
||||
}
|
||||
|
||||
@PostMapping("/page-list-payType")
|
||||
@Operation(summary = "支付方式交易记录")
|
||||
public R<List<HardDeptTotalVo>> pageListPayType(@RequestBody HardOrderDto dto) {
|
||||
return R.ok(HardOrderTotalService.listPayType(dto));
|
||||
}
|
||||
|
||||
@PostMapping("/page-list-dept")
|
||||
@Operation(summary = "部门交易记录")
|
||||
public R<List<HardDeptTotalVo>> pageListDept(@RequestBody HardDeptTotalDto dto) {
|
||||
|
||||
+17
-1
@@ -1,6 +1,5 @@
|
||||
package com.bsd.pjcloud.hard.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardDeptTotalDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.HardDeptTotalVo;
|
||||
@@ -12,11 +11,28 @@ import java.util.List;
|
||||
|
||||
public interface HardOrderTotalService {
|
||||
|
||||
/**
|
||||
* 设备交易记录
|
||||
*/
|
||||
List<HardOrderSbVo> listSb(HardOrderDto dto);
|
||||
|
||||
/**
|
||||
* 商户交易记录
|
||||
*/
|
||||
List<HardOrderCsVo> listCs(HardOrderDto dto);
|
||||
|
||||
/**
|
||||
* 部门交易记录
|
||||
*/
|
||||
List<HardDeptTotalVo> pageListDept(HardDeptTotalDto dto);
|
||||
|
||||
/**
|
||||
* 支付方式交易记录
|
||||
*/
|
||||
List<HardDeptTotalVo> listPayType(HardOrderDto dto);
|
||||
|
||||
/**
|
||||
* 正元统计交易数据同步
|
||||
*/
|
||||
HardZyCardSyncVo totalYearMonthDay(HardOrderDto dto);
|
||||
}
|
||||
+6
-2
@@ -341,22 +341,26 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
// @GlobalTransactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long appCreateOrderScancode(HardAppCreateOrderDto dto) {
|
||||
MchManageVo mch = remoteMchService.getById(dto.getMerchantId()).getData();
|
||||
if (ObjectUtil.isEmpty(mch)) {
|
||||
throw new RuntimeException("商户不存在");
|
||||
}
|
||||
// 钱包
|
||||
WalletManageEntity wallet = remoteWalletService.getWallet(dto.getUserId(), dto.getWalletType()).getData();
|
||||
if (ObjectUtil.isEmpty(wallet)) throw new RuntimeException("用户钱包不存在");
|
||||
Integer balance = wallet.getBalance();
|
||||
int totalPrice = dto.getCustomPrice();
|
||||
String subject = "未知商品 * ?";
|
||||
String subject = "未知商品x?";
|
||||
if (balance < totalPrice) {
|
||||
throw new RuntimeException("钱包余额不足");
|
||||
}
|
||||
// 添加硬件订单
|
||||
HardOrderEntity orderObj = HardOrderEntity.builder()
|
||||
.userId(dto.getUserId())
|
||||
.merchantId(mch.getId())
|
||||
.parentCarId(dto.getCarParentId())
|
||||
.sysType(dto.getHardType().getType())
|
||||
.orderStatus(HardOrderStatusEnum.CREATE.getType())
|
||||
.merchantId(null)
|
||||
.orderType(dto.getOrderType().getType())
|
||||
.payType(dto.getPayType().getType())
|
||||
.orderSourceTypeId(dto.getOrderSourceTypeId())
|
||||
|
||||
+30
@@ -9,6 +9,7 @@ import com.bsd.pjcloud.admin.api.entity.SysDept;
|
||||
import com.bsd.pjcloud.admin.api.feign.RemoteDeptService;
|
||||
import com.bsd.pjcloud.common.core.util.CollectionUtils;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardOrderStatusEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardPayTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.dto.HardManagerDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardDeptTotalDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
|
||||
@@ -33,6 +34,7 @@ import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Validated
|
||||
@Slf4j
|
||||
@@ -47,6 +49,9 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService {
|
||||
private final RemoteWalletTransactionService remoteWalletTransactionService;
|
||||
private final RemoteDeptService remoteDeptService;
|
||||
|
||||
/**
|
||||
* 设备交易记录
|
||||
*/
|
||||
@Override
|
||||
public List<HardOrderSbVo> listSb(HardOrderDto dto) {
|
||||
// 查询总流水
|
||||
@@ -112,6 +117,9 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService {
|
||||
return totalList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 商户交易记录
|
||||
*/
|
||||
@Override
|
||||
public List<HardOrderCsVo> listCs(HardOrderDto dto) {
|
||||
// 查询总流水
|
||||
@@ -167,6 +175,9 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService {
|
||||
return totalList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 部门交易记录
|
||||
*/
|
||||
@Override
|
||||
public List<HardDeptTotalVo> pageListDept(HardDeptTotalDto dto) {
|
||||
// 查询部门
|
||||
@@ -346,6 +357,25 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService {
|
||||
return resultListFuture.join();
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付方式交易记录
|
||||
*/
|
||||
@Override
|
||||
public List<HardDeptTotalVo> listPayType(HardOrderDto dto) {
|
||||
// 获取所有支付方式
|
||||
List<String> payTypeList = HardPayTypeEnum.payTypeTotalDisplayList.stream().map(HardPayTypeEnum::getType).toList();
|
||||
// 查询总流水
|
||||
CompletableFuture<List<HardOrderCsVo>> totalListFuture = CompletableFuture.supplyAsync(() -> {
|
||||
HardOrderDto totalDto = BeanUtil.toBean(dto, HardOrderDto.class);
|
||||
totalDto.setOrderStatusCodes(HardOrderStatusEnum.getPayPrice());
|
||||
return hardOrderMapper.listCs(totalDto);
|
||||
});
|
||||
return List.of();
|
||||
}
|
||||
|
||||
/**
|
||||
* 正元统计交易数据同步
|
||||
*/
|
||||
@Override
|
||||
public HardZyCardSyncVo totalYearMonthDay(HardOrderDto dto) {
|
||||
return hardOrderMapper.totalYearMonthDay(dto);
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ public class HardThirdZyServiceImpl implements HardThirdZyService {
|
||||
private final HardOrderTotalService hardOrderTotalService;
|
||||
|
||||
/**
|
||||
* 交易数据同步
|
||||
* 正元统计交易数据同步
|
||||
*/
|
||||
@Override
|
||||
public void syncNativeCardTradeInfo() {
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ public class MchCollectionCodeVo {
|
||||
/**
|
||||
* 商户Id
|
||||
*/
|
||||
private Long id;
|
||||
private String id;
|
||||
/**
|
||||
* 商户名
|
||||
*/
|
||||
|
||||
+1
-1
@@ -247,7 +247,7 @@ public class MchManageServiceImpl extends ServiceImpl<MchManageMapper, MchManage
|
||||
if (ObjectUtil.isEmpty(mchDetail)) return;
|
||||
try {
|
||||
MchCollectionCodeVo mchCollectionCode = new MchCollectionCodeVo();
|
||||
mchCollectionCode.setId(mchDetail.getId());
|
||||
mchCollectionCode.setId(String.valueOf(mchDetail.getId()));
|
||||
mchCollectionCode.setName(mchDetail.getName());
|
||||
String coeContent = Base64.encode(JSONUtil.toJsonStr(mchCollectionCode));
|
||||
byte[] bytes = QRCodeImageGenerator.generateQrCodeImage(coeContent, 1024);
|
||||
|
||||
Reference in new issue
Block a user