feat:钱包二维码适配

This commit is contained in:
dzc committed 2025-01-15 15:42:57 +08:00
1 parent 395318b34f
commit c67f020a6a
5 files changed
+34 -4

No files matched your search

@@ -70,6 +70,9 @@ public class HardCreateOrderDto {
private Long deptId;
@Schema(description = "钱包id")
private Long walletId;
@Schema(description = "离线支付是否成功")
private Boolean offlinePaySuccess;
}
@@ -51,6 +51,7 @@ import com.bsd.pjcloud.wallet.api.entity.WalletTransactionEntity;
import com.bsd.pjcloud.wallet.api.feign.*;
import com.bsd.pjcloud.wallet.api.utils.WalletDataUtil;
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
import com.bsd.pjcloud.wallet.api.vo.WalletManageVo;
import com.bsd.pjcloud.wallet.api.vo.WalletSettingVo;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
@@ -251,8 +252,18 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
// 饭卡钱包
WalletManageEntity wallet = null;
if (isPay) {
R<WalletManageEntity> walletResult = remoteWalletService.getWallet(dto.getUserId(), WalletTypeEnum.EAT);
wallet = Optional.of(walletResult).map(R::getData).orElseThrow(() -> new RuntimeException("用户钱包不存在"));
if (ObjectUtil.equals(dto.getOrderPayType(), HardPayTypeEnum.WALLET_QR_CODE)) {
if (ObjectUtil.isEmpty(dto.getWalletId())) throw new RuntimeException("钱包二维码支付错误");
R<WalletManageVo> walletResult = remoteWalletService.getWalletById(dto.getWalletId());
WalletManageVo walletVo = Optional.of(walletResult).map(R::getData).orElseThrow(() -> new RuntimeException("用户钱包不存在"));
if (!ObjectUtil.equals(walletVo.getWalletTypeUniqueCode(), WalletTypeEnum.EAT.getCode())) {
throw new RuntimeException("请使用钱包二维码支付");
}
wallet = walletVo;
} else {
R<WalletManageEntity> walletResult = remoteWalletService.getWallet(dto.getUserId(), WalletTypeEnum.EAT);
wallet = Optional.of(walletResult).map(R::getData).orElseThrow(() -> new RuntimeException("用户钱包不存在"));
}
}
int totalPrice = 0, extraPrice = 0, payPrice = 0;
totalPrice = hardCarService.computerCarTotalPrice(dto.getSysType(), dto.getOrderType(), dto.getList());
@@ -6,6 +6,7 @@ import com.bsd.pjcloud.common.feign.annotation.NoToken;
import com.bsd.pjcloud.wallet.api.constant.WalletCodeBizEnum;
import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum;
import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
import com.bsd.pjcloud.wallet.api.vo.WalletManageVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
@@ -23,6 +24,10 @@ public interface RemoteWalletService {
@GetMapping("/wallet-manage/get-wallet")
R<WalletManageEntity> getWallet(@RequestParam Long userId, @RequestParam WalletTypeEnum walletTypeCode);
@NoToken
@GetMapping("/wallet-manage/get-wallet-by-id")
R<WalletManageVo> getWalletById(@RequestParam Long walletId);
@NoToken
@GetMapping("/wallet-manage/get-wallet-by-card-number")
R<WalletManageEntity> getWalletByCardNumber(@RequestParam String cardNumber);
@@ -14,6 +14,8 @@ import com.bsd.pjcloud.common.security.util.SecurityUtils;
import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum;
import com.bsd.pjcloud.wallet.api.dto.WalletManageDto;
import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
import com.bsd.pjcloud.wallet.api.vo.WalletManageVo;
import com.bsd.pjcloud.wallet.mapper.WalletManageMapper;
import com.bsd.pjcloud.wallet.service.WalletCodeUseService;
import com.bsd.pjcloud.wallet.service.WalletManageService;
import org.springframework.security.access.prepost.PreAuthorize;
@@ -42,9 +44,10 @@ import java.util.List;
public class WalletManageController {
private final WalletManageService walletManageService;
private final WalletCodeUseService walletCodeUseService;
private final WalletManageMapper walletManageMapper;
/* ************************************* start 远程调用 start ************************************* */
@Inner
@GetMapping("/get-or-create-wallet")
@@ -71,6 +74,14 @@ public class WalletManageController {
return R.ok(wallet);
}
@Inner
@GetMapping("/get-wallet-by-id")
public R getWalletById(@RequestParam Long walletId) {
WalletManageVo wallet = walletManageMapper.join(walletId);
if (ObjectUtil.isEmpty(wallet)) return R.failed("用户钱包不存在");
return R.ok(wallet);
}
@Inner
@GetMapping("/get-wallet-by-card-number")
public R getWalletByCardNumber(@RequestParam String cardNumber) {
@@ -90,7 +90,7 @@ public interface WalletManageService extends IService<WalletManageEntity> {
Page<WalletManageVo> scopePageList(Page page, WalletManageDto dto);
WalletManageVo join(Long id, Long walletId);
WalletManageVo join(Long user, Long walletId);
/**
* 生成钱包二维码参数