Merge remote-tracking branch 'origin/master'

This commit is contained in:
zjf committed 2025-04-07 18:14:46 +08:00
commit cb1e069908
7 files changed
+66 -7

No files matched your search

@@ -21,8 +21,10 @@ public interface RemoteHardOrderService {
@GetMapping("/hard-order/get-by-ids")
R<List<HardOrderEntity>> getByIds(@RequestParam List<Long> ids);
@PostMapping("/hard-order/page")
R<Page<List<HardOrderEntity>>> getPage(@RequestParam Page page, @RequestBody HardOrderPreferencesDto hardOrderPreferencesDto);
@NoToken
@GetMapping("/hard-order/mch-count-by-id")
R<Long> getMchCountById(@RequestParam Long id);
}
@@ -88,6 +88,16 @@ public class HardOrderController {
dto.setOrderIds(ids);
return R.ok(hardOrderMapper.list(dto));
}
@Inner
@Operation(summary = "app查询订单列表", description = "app查询订单列表")
@GetMapping("/mch-count-by-id")
public R<Long> getMchCountById(@RequestParam Long id) {
LambdaQueryWrapper<HardOrderEntity> query = new LambdaQueryWrapper<HardOrderEntity>().eq(HardOrderEntity::getMerchantId, id);
Long count = hardOrderMapper.selectCount(query);
if (ObjectUtil.isEmpty(count)) count = 0L;
return R.ok(count);
}
/* ************************************* end 远程调用 ************************************* */
/* ************************************* start app start ************************************* */
@@ -26,9 +26,12 @@ import com.bsd.pjcloud.hard.mapper.order.HardAfterSaleLogMapper;
import com.bsd.pjcloud.hard.service.HardAfterSaleService;
import com.bsd.pjcloud.hard.service.HardOrderService;
import com.bsd.pjcloud.hard.service.HardThirdSelfZyService;
import com.bsd.pjcloud.hard.zy.config.ZyCallbackConfig;
import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum;
import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
import com.bsd.pjcloud.wallet.api.feign.RemoteMchService;
import com.bsd.pjcloud.wallet.api.feign.RemoteWalletService;
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@@ -48,11 +51,14 @@ public class HardThirdSelfZyServiceImpl implements HardThirdSelfZyService {
private final RemoteWalletService remoteWalletService;
private final RemoteUserService remoteUserService;
private final RemoteMchService remoteMchService;
private final HardOrderService hardOrderService;
private final HardAfterSaleLogMapper hardAfterSaleLogMapper;
private final HardAfterSaleService hardAfterSaleService;
private final ZyCallbackConfig zyCallbackConfig;
/**
* 正元支付
*/
@@ -69,6 +75,9 @@ public class HardThirdSelfZyServiceImpl implements HardThirdSelfZyService {
// 用户
UserInfo user = remoteUserService.getByUserId(wallet.getUserId()).getData();
if (ObjectUtil.isEmpty(user)) throw new RuntimeException("用户不存在");
// 查询正元默认商户
MchManageVo zyDefaultMch = getZyDefaultMch();
if (ObjectUtil.isEmpty(zyDefaultMch)) throw new RuntimeException("默认商户不存在");
Integer balance = wallet.getBalance();
int totalPrice = dto.getPayPrice();
if (balance < totalPrice) {
@@ -81,6 +90,9 @@ public class HardThirdSelfZyServiceImpl implements HardThirdSelfZyService {
HardOrderEntity orderObj = HardOrderEntity.builder()
.orderNo(dto.getOrderNo())
.userId(dto.getUserId())
.merchantId(zyDefaultMch.getId())
.merchantType(zyDefaultMch.getTypes())
.merchantDeptId(zyDefaultMch.getDeptId())
.userDeptId(userDetail.getSysUser().getDeptId())
.parentCarId(null)
.sysType(null)
@@ -172,4 +184,11 @@ public class HardThirdSelfZyServiceImpl implements HardThirdSelfZyService {
}
}
/**
* 查询正元默认商户信息
*/
private MchManageVo getZyDefaultMch() {
return remoteMchService.getById(zyCallbackConfig.getMchId()).getData();
}
}
@@ -0,0 +1,14 @@
package com.bsd.pjcloud.hard.zy.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Data
@ConfigurationProperties(prefix = "zy-callback")
@Component
public class ZyCallbackConfig {
private Long mchId;
}
@@ -16,3 +16,7 @@ spring:
import:
- optional:nacos:application-@profiles.active@.yml
- optional:nacos:${spring.application.name}-@profiles.active@.yml
# 正源回调配置
#zy-callback:
# mch-id: 1909168994551459842
@@ -301,14 +301,14 @@ public class WalletManageServiceImpl extends ServiceImpl<WalletManageMapper, Wal
if (ObjectUtil.isEmpty(walletTypeList)) return walletPage;
// 查询所有钱包类型的流水记录
for (WalletTypeEntity i : walletTypeList) {
dto.setWalletTypeId(i.getId());
if (ObjectUtil.isEmpty(dto.getUserId())) {
dto.setUserIds(userIds);
WalletManageBalanceDto walletBalanceDto = BeanUtils.toBean(dto, WalletManageBalanceDto.class);
walletBalanceDto.setWalletTypeId(i.getId());
if (ObjectUtil.isEmpty(walletBalanceDto.getUserId())) {
walletBalanceDto.setUserIds(userIds);
}
List<WalletManageBalanceVo> itemList = baseMapper.selectBalance(dto);
List<WalletManageBalanceVo> itemList = baseMapper.selectBalance(walletBalanceDto);
if (ObjectUtil.isEmpty(itemList)) continue;
for (WalletManageBalanceVo j : itemList) {
// j.setWalletTypeName(i.getName());
walletPage.getRecords().stream().filter(v -> ObjectUtil.equals(i.getId(), v.getWalletTypeId()) && ObjectUtil.equals(v.getUserId(), j.getUserId())).findFirst().ifPresent(v -> {
if (ObjectUtil.isNotEmpty(j.getBalance())) {
v.setBalance(j.getBalance());
@@ -20,6 +20,7 @@ import com.bsd.pjcloud.common.core.util.CollectionUtils;
import com.bsd.pjcloud.common.core.util.QRCodeImageGenerator;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.hard.api.feign.RemoteHardOrderService;
import com.bsd.pjcloud.hard.api.utils.Drawing2D;
import com.bsd.pjcloud.wallet.api.constant.mch.WalletMchSupType;
import com.bsd.pjcloud.wallet.api.dto.MchManageDto;
@@ -67,6 +68,7 @@ public class MchManageServiceImpl extends ServiceImpl<MchManageMapper, MchManage
private final RemoteUserService remoteUserService;
private final RemoteDeptService remoteDeptService;
private final RemoteFileService remoteFileService;
private final RemoteHardOrderService remoteHardOrderService;
@Lazy
private final WalletThirdZyService walletThirdZyService;
@@ -152,6 +154,14 @@ public class MchManageServiceImpl extends ServiceImpl<MchManageMapper, MchManage
@Override
public void delByIds(ArrayList<Long> list) {
if (ObjectUtil.isEmpty(list)) return;
// 判断下面是否有订单
List<MchManageVo> mchList = baseMapper.list(MchManageDto.builder().ids(list).build());
for (MchManageVo v : mchList) {
Long count = remoteHardOrderService.getMchCountById(v.getId()).getData();
if (ObjectUtil.isNotEmpty(count) && count > 0) {
throw new RuntimeException("该商户<" + v.getName() + ">有订单交易记录,不能删除");
}
}
// 删除缓存
list.forEach(v -> {
redisTemplate.opsForValue().getAndDelete(CacheConstants.WALLET_MCH + v);