feat:硬件查询用户
This commit is contained in:
1 parent
f4a229f4f9
commit
08373b91cd
18 files changed
+299
-31
No files matched your search
+47
@@ -0,0 +1,47 @@
|
||||
package com.bsd.pjcloud.hard.api.vo.android;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class HardAdUserVo {
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private Long userId;
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String username;
|
||||
/**
|
||||
* 手机号码
|
||||
*/
|
||||
private String userMobile;
|
||||
/**
|
||||
* 用户头像
|
||||
*/
|
||||
private String userAvatar;
|
||||
/**
|
||||
* 部门ID
|
||||
*/
|
||||
private Long deptId;
|
||||
/**
|
||||
* 钱包卡号
|
||||
*/
|
||||
private String walletCardNumber;
|
||||
/**
|
||||
* 钱包id
|
||||
*/
|
||||
private Long walletId;
|
||||
/**
|
||||
* 钱包类型id
|
||||
*/
|
||||
private Long walletTypeId;
|
||||
/**
|
||||
* 钱包余额
|
||||
*/
|
||||
private Integer walletBalance;
|
||||
/**
|
||||
* 是否冻结饭卡
|
||||
*/
|
||||
private Boolean walletIsFreeze;
|
||||
}
|
||||
+7
-1
@@ -6,7 +6,13 @@ import lombok.Data;
|
||||
@Data
|
||||
public class HardCarVo extends HardCarEntity {
|
||||
|
||||
// 商品id【超市的商品存的是 sku id】
|
||||
// 商品id【超市特有】
|
||||
private Long spuId;
|
||||
|
||||
// 商品规格【超市特有】
|
||||
private String spec;
|
||||
|
||||
// 商品规格【超市特有】
|
||||
private String unit;
|
||||
|
||||
}
|
||||
+14
-1
@@ -1,14 +1,17 @@
|
||||
package com.bsd.pjcloud.hard.controller.hard;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.bsd.pjcloud.common.core.util.BeanUtils;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.idempotent.annotation.Idempotent;
|
||||
import com.bsd.pjcloud.hard.api.constant.HardTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.dto.async.SyncOfflineReqVo;
|
||||
import com.bsd.pjcloud.hard.api.dto.hard.HandCancelCodeDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.hard.HardBindDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.hard.HardCreateOrderDto;
|
||||
import com.bsd.pjcloud.hard.api.vo.HardInvoiceVo;
|
||||
import com.bsd.pjcloud.hard.api.vo.HardManagerVo;
|
||||
import com.bsd.pjcloud.hard.api.vo.android.HardAdUserVo;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.HardCarVo;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.HardOrderVo;
|
||||
import com.bsd.pjcloud.hard.service.*;
|
||||
@@ -24,7 +27,7 @@ import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/hard-api")
|
||||
@RequestMapping("/hard-api/ad")
|
||||
@Tag(description = "hard-api", name = "硬件")
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class HardApiController {
|
||||
@@ -34,6 +37,7 @@ public class HardApiController {
|
||||
private final HardCarService hardCarService;
|
||||
private final HardOrderService hardwareOrderService;
|
||||
private final HardOrderSyncService hardOrderSyncService;
|
||||
private final HardApiService hardApiService;
|
||||
|
||||
@PostMapping("/bind")
|
||||
@Operation(summary = "绑定服务端设备")
|
||||
@@ -93,4 +97,13 @@ public class HardApiController {
|
||||
return R.ok(hardOrderSyncService.syncOfflineOrder(dto));
|
||||
}
|
||||
|
||||
@GetMapping("/get-user")
|
||||
@Operation(summary = "获取用户和钱包")
|
||||
public R<HardAdUserVo> getUserById(@RequestParam Long id, @RequestParam(required = false) HardTypeEnum type) {
|
||||
if (ObjectUtil.isEmpty(type)) {
|
||||
type = HardTypeEnum.CANTEEN;
|
||||
}
|
||||
return R.ok(hardApiService.getUserById(id, type));
|
||||
}
|
||||
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package com.bsd.pjcloud.hard.service;
|
||||
|
||||
import com.bsd.pjcloud.hard.api.constant.HardTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.vo.android.HardAdUserVo;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface HardApiService {
|
||||
|
||||
HardAdUserVo getUserById(Long userId, HardTypeEnum type);
|
||||
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
package com.bsd.pjcloud.hard.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.bsd.pjcloud.admin.api.dto.UserInfo;
|
||||
import com.bsd.pjcloud.admin.api.entity.SysUser;
|
||||
import com.bsd.pjcloud.admin.api.feign.RemoteUserService;
|
||||
import com.bsd.pjcloud.hard.api.constant.HardTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.vo.android.HardAdUserVo;
|
||||
import com.bsd.pjcloud.hard.service.HardApiService;
|
||||
import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
|
||||
import com.bsd.pjcloud.wallet.api.feign.RemoteWalletService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@Validated
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class HardApiServiceImpl implements HardApiService {
|
||||
|
||||
private final RemoteUserService userService;
|
||||
private final RemoteWalletService remoteWalletService;
|
||||
|
||||
@Override
|
||||
public HardAdUserVo getUserById(Long userId, HardTypeEnum type) {
|
||||
HardAdUserVo result = new HardAdUserVo();
|
||||
// 查询用户
|
||||
UserInfo user = userService.getByUserId(userId).getData();
|
||||
if (ObjectUtil.isEmpty(user)) return null;
|
||||
// 查询钱包
|
||||
WalletTypeEnum walletType = ObjectUtil.equals(HardTypeEnum.CANTEEN, type) ? WalletTypeEnum.EAT : WalletTypeEnum.PAY;
|
||||
WalletManageEntity wallet = remoteWalletService.getWallet(userId, walletType).getData();
|
||||
if (ObjectUtil.isEmpty(wallet)) return null;
|
||||
SysUser sysUser = user.getSysUser();
|
||||
result.setUserId(sysUser.getUserId());
|
||||
result.setUsername(sysUser.getUsername());
|
||||
result.setUserAvatar(sysUser.getAvatar());
|
||||
result.setUserMobile(sysUser.getPhone());
|
||||
result.setDeptId(sysUser.getDeptId());
|
||||
result.setWalletCardNumber(wallet.getCardNumber());
|
||||
result.setWalletId(wallet.getId());
|
||||
result.setWalletTypeId(wallet.getWalletTypeId());
|
||||
result.setWalletBalance(wallet.getBalance());
|
||||
result.setWalletIsFreeze(wallet.getIsFreeze());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+19
-3
@@ -23,6 +23,7 @@ import com.bsd.pjcloud.hard.mapper.order.HardParentCarMapper;
|
||||
import com.bsd.pjcloud.hard.service.HardCarService;
|
||||
import com.bsd.pjcloud.supermarket.api.feign.RemoteSupermarketUnitSkuService;
|
||||
import com.bsd.pjcloud.supermarket.vo.SupermarketUnitWithSpuVo;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -74,6 +75,8 @@ public class HardCarServiceImpl extends ServiceImpl<HardCarMapper, HardCarEntity
|
||||
for (HardCarVo v : resultList) {
|
||||
supList.stream().filter(i -> ObjectUtil.equals(i.getId(), v.getProductId())).findFirst().ifPresent(spu -> {
|
||||
v.setSpuId(spu.getSpuId());
|
||||
v.setSpec(spu.getSpec());
|
||||
v.setUnit(spu.getUnit());
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -141,7 +144,8 @@ public class HardCarServiceImpl extends ServiceImpl<HardCarMapper, HardCarEntity
|
||||
List<SupermarketUnitWithSpuVo> supList = supermarketUnitSkuService.getSupermarketUnits(productIds).getData();
|
||||
for (HardCreateCarDto v : list) {
|
||||
supList.stream().filter(i -> ObjectUtil.equals(i.getId(), v.getProductId())).findFirst().ifPresent(spu -> {
|
||||
int itemTotalPrice = v.getProductCount() * spu.getPromotionPrice();
|
||||
Integer price = getSupermarket(spu);
|
||||
int itemTotalPrice = v.getProductCount() * price;
|
||||
supermarketTotalPrice.addAndGet(itemTotalPrice);
|
||||
});
|
||||
}
|
||||
@@ -192,10 +196,11 @@ public class HardCarServiceImpl extends ServiceImpl<HardCarMapper, HardCarEntity
|
||||
for (HardCreateCarDto v : productList) {
|
||||
HardCarEntity item = HardCarEntity.builder().parentCarId(parentCarId).build();
|
||||
supList.stream().filter(i -> ObjectUtil.equals(i.getId(), v.getProductId())).findFirst().ifPresent(spu -> {
|
||||
int totalPrice = v.getProductCount() * spu.getPromotionPrice();
|
||||
Integer price = getSupermarket(spu);
|
||||
int totalPrice = v.getProductCount() * price;
|
||||
item.setProductId(spu.getId());
|
||||
item.setProductName(spu.getProductName());
|
||||
item.setProductPrice(spu.getPromotionPrice());
|
||||
item.setProductPrice(price);
|
||||
item.setProductPic(spu.getPicUrl());
|
||||
item.setTotalPrice((long) totalPrice);
|
||||
item.setProductCount(v.getProductCount());
|
||||
@@ -241,6 +246,17 @@ public class HardCarServiceImpl extends ServiceImpl<HardCarMapper, HardCarEntity
|
||||
);
|
||||
}
|
||||
|
||||
private Integer getSupermarket(SupermarketUnitWithSpuVo vo) {
|
||||
if (ObjectUtil.isEmpty(vo)) return 0;
|
||||
if (ObjectUtil.isNotEmpty(vo.getPromotionPrice()) && !ObjectUtil.equals(vo.getPromotionPrice(), 0)) {
|
||||
return vo.getPromotionPrice();
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(vo.getRetailPrice())) {
|
||||
return vo.getRetailPrice();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private HardCarServiceImpl getSelf() {
|
||||
return SpringUtil.getBean(getClass());
|
||||
}
|
||||
|
||||
+2
-2
@@ -308,8 +308,8 @@ public class HardwareOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardO
|
||||
log.error("|{}|支付配置不存在", TAG);
|
||||
return extraPrice;
|
||||
}
|
||||
if (setting.getPayAmountMealTimes().compareTo(new BigDecimal(1)) <= 0) {
|
||||
log.error("|{}|每一餐的倍数必须大于1", TAG);
|
||||
if (setting.getPayAmountMealTimes().compareTo(new BigDecimal(0)) <= 0) {
|
||||
log.error("|{}|每一餐的倍数必须大于0", TAG);
|
||||
return extraPrice;
|
||||
}
|
||||
if (ObjectUtil.equals(setting.getPayAmountEnable(), YesNoEnum.NO.getCode())) return extraPrice;
|
||||
|
||||
Reference in new issue
Block a user