账户门店
This commit is contained in:
@ -37,4 +37,7 @@ public class AppCardPageReqVO extends PageParam {
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
@Schema(description = "消费类型")
|
||||
private String carteenId;
|
||||
|
||||
}
|
@ -64,23 +64,23 @@ public class AppDiningPlatesController {
|
||||
@GetMapping("/checkBind")
|
||||
@Operation(summary = "验证餐盘绑定")
|
||||
public CommonResult<AppUserInfoCardVO> checkBind(String diningPlatesNum, Long storeId) {
|
||||
storeId = getCarteen(storeId);
|
||||
return success(diningPlatesService.appCheckBind(diningPlatesNum,storeId));
|
||||
Long newStoreId = getCarteen(storeId);
|
||||
return success(diningPlatesService.appCheckBind(diningPlatesNum,newStoreId));
|
||||
}
|
||||
|
||||
@GetMapping("/unbind")
|
||||
@Operation(summary = "餐盘解绑")
|
||||
public CommonResult<String> unbind(String diningPlatesNum,Long storeId) {
|
||||
storeId = getCarteen(storeId);
|
||||
diningPlatesService.unbind(diningPlatesNum,storeId);
|
||||
Long newStoreId = getCarteen(storeId);
|
||||
diningPlatesService.unbind(diningPlatesNum,newStoreId);
|
||||
return success(diningPlatesNum);
|
||||
}
|
||||
|
||||
@GetMapping("/getUserAndDish")
|
||||
@Operation(summary = "根据餐盘号获取当前余额")
|
||||
public CommonResult<AppUserInfo> getMoney(String cId, Long dishesId,Long storeId) {
|
||||
storeId = getCarteen(storeId);
|
||||
return success(diningPlatesService.getMoney(cId,dishesId,storeId));
|
||||
Long newStoreId = getCarteen(storeId);
|
||||
return success(diningPlatesService.getMoney(cId,dishesId,newStoreId));
|
||||
}
|
||||
|
||||
@GetMapping("/getBind")
|
||||
@ -92,8 +92,8 @@ public class AppDiningPlatesController {
|
||||
@GetMapping("/checkBindAndUnBind")
|
||||
@Operation(summary = "餐盘解绑")
|
||||
public CommonResult<String> checkBindAndUnBind(String diningPlatesNum,Long storeId) {
|
||||
storeId = getCarteen(storeId);
|
||||
Map<String, String> map = diningPlatesService.checkBindAndUnBind(diningPlatesNum, storeId);
|
||||
Long newStoreId = getCarteen(storeId);
|
||||
Map<String, String> map = diningPlatesService.checkBindAndUnBind(diningPlatesNum, newStoreId);
|
||||
CommonResult<String> result = new CommonResult<>();
|
||||
result.setCode(200);
|
||||
result.setData(map.get("data"));
|
||||
@ -109,7 +109,7 @@ public class AppDiningPlatesController {
|
||||
|
||||
|
||||
public Long getCarteen(Long storeId) {
|
||||
if (storeId != null){
|
||||
if (storeId != null && storeId != 0){
|
||||
return storeId;
|
||||
}
|
||||
try {
|
||||
|
@ -56,6 +56,7 @@ public interface CardMapper extends BaseMapperX<CardDO> {
|
||||
.eqIfPresent(CardDO::getFlag, reqVO.getFlag())
|
||||
.eqIfPresent(CardDO::getChangeMoney, reqVO.getChangeMoney())
|
||||
.betweenIfPresent(CardDO::getCreateTime, reqVO.getCreateTime())
|
||||
.eqIfPresent(CardDO::getCarteenId,reqVO.getCarteenId())
|
||||
.orderByDesc(CardDO::getId));
|
||||
}
|
||||
|
||||
|
@ -98,7 +98,10 @@ public class DeductionServiceImpl implements DeductionService {
|
||||
//当前金额
|
||||
BigDecimal wxAmount = user.getWxAmount();
|
||||
BigDecimal giftAmount = user.getGiftAmount();
|
||||
BigDecimal cashAmount = moneyDO.getCashAmount();
|
||||
BigDecimal cashAmount = BigDecimal.ZERO;
|
||||
if(ObjectUtil.isNotEmpty(moneyDO)){
|
||||
cashAmount = moneyDO.getCashAmount();
|
||||
}
|
||||
|
||||
BigDecimal money = wxAmount.add(giftAmount).add(cashAmount);
|
||||
// user.setMoney(money.subtract(total));
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cn.iocoder.yudao.module.member.service.diningplates;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||
@ -208,11 +209,10 @@ public class DiningPlatesServiceImpl implements DiningPlatesService {
|
||||
.last(MemberConstants.LIMIT_ONE));
|
||||
checkMemberUser(memberUserDO, false);
|
||||
//订单验证
|
||||
checkOrder(memberUserDO.getId());
|
||||
checkOrder(memberUserDO.getId(),diningPlatesDO.getStoreId());
|
||||
|
||||
//余额验证
|
||||
BigDecimal money = memberUserDO.getMoney();
|
||||
checkMoney(money);
|
||||
BigDecimal money = checkMoney(memberUserDO, storeId);
|
||||
|
||||
diningPlatesDO.setUserId(memberUserDO.getId());
|
||||
diningPlatesDO.setStatus(DiningPlatesDO.USE);
|
||||
@ -260,10 +260,9 @@ public class DiningPlatesServiceImpl implements DiningPlatesService {
|
||||
MemberUserDO memberUserDO = memberUserMapper.selectOne(wrapper);
|
||||
checkMemberUser(memberUserDO, true);
|
||||
//订单验证
|
||||
checkOrder(memberUserDO.getId());
|
||||
checkOrder(memberUserDO.getId(),diningPlatesDO.getStoreId());
|
||||
//余额验证
|
||||
BigDecimal money = memberUserDO.getMoney();
|
||||
checkMoney(money);
|
||||
BigDecimal money = checkMoney(memberUserDO,storeId);
|
||||
|
||||
diningPlatesDO.setUserId(memberUserDO.getId());
|
||||
diningPlatesDO.setStatus(DiningPlatesDO.USE);
|
||||
@ -363,19 +362,32 @@ public class DiningPlatesServiceImpl implements DiningPlatesService {
|
||||
//}
|
||||
}
|
||||
|
||||
public void checkMoney(BigDecimal money) {
|
||||
public BigDecimal checkMoney(MemberUserDO memberUserDO,Long storeId) {
|
||||
BigDecimal cashAmount = BigDecimal.ZERO;
|
||||
MoneyDO moneyDO = moneyService.getMoney(memberUserDO.getId(), storeId);
|
||||
|
||||
if (ObjectUtil.isNotEmpty(moneyDO)) {
|
||||
cashAmount = moneyDO.getCashAmount();
|
||||
}else {
|
||||
MoneyDO add = new MoneyDO();
|
||||
add.setUserId(memberUserDO.getId());
|
||||
add.setCarteenId(storeId);
|
||||
moneyService.insertOne(add);
|
||||
}
|
||||
BigDecimal money = memberUserDO.getWxAmount().add(cashAmount);
|
||||
if (money.compareTo(MemberConstants.ALARM_BALANCE) < 0) {
|
||||
throw exception(INSUFFICIENT_BALANCE);
|
||||
}
|
||||
return money;
|
||||
}
|
||||
|
||||
public void checkOrder(Long userId) {
|
||||
public void checkOrder(Long userId,Long carteenId) {
|
||||
|
||||
LambdaQueryWrapper<DishOrderDO> wrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
wrapper.eq(DishOrderDO::getUserId,userId);
|
||||
wrapper.eq(DishOrderDO::getOrderStatus,DishOrderDO.TOCOMPLETE);
|
||||
|
||||
wrapper.eq(DishOrderDO::getStoreId,carteenId);
|
||||
List<DishOrderDO> dishOrderDOS = dishOrderMapper.selectList(wrapper);
|
||||
ErrorCode code = new ErrorCode(1_004_099_008, "存在未支付完的订单");
|
||||
if(CollectionUtil.isNotEmpty(dishOrderDOS)){
|
||||
@ -481,12 +493,16 @@ public class DiningPlatesServiceImpl implements DiningPlatesService {
|
||||
DishesRespDto dish = dishesApi.getDish(dishId);
|
||||
|
||||
MoneyDO moneyDO = moneyService.getMoney(memberUserDO.getId(), storeId);
|
||||
BigDecimal cashAmount = BigDecimal.ZERO;
|
||||
if(ObjectUtil.isNotEmpty(moneyDO)){
|
||||
cashAmount = moneyDO.getCashAmount();
|
||||
}
|
||||
|
||||
AppUserInfo appUserInfo = new AppUserInfo();
|
||||
appUserInfo.setNickname(StrUtil.isNotBlank(memberUserDO.getName())?memberUserDO.getName():memberUserDO.getNickname())
|
||||
.setDishesName(dish.getDishesName())
|
||||
.setDishesBasePrice(dish.getDishesBasePrice()).setDishesSumPrice(dish.getDishesSumPrice())
|
||||
.setMoney(memberUserDO.getWxAmount().add(moneyDO.getCashAmount()))
|
||||
.setMoney(memberUserDO.getWxAmount().add(cashAmount))
|
||||
.setOrderMoney(new BigDecimal(stringRedisTemplate.opsForValue().get(diningPlatesNum+"-"+storeId)))
|
||||
.setReception(memberUserDO.getReception()).setLimitAmount(memberUserDO.getLimitAmount());
|
||||
return appUserInfo;
|
||||
|
@ -188,29 +188,13 @@ public class OrderServiceImpl implements OrderService {
|
||||
List<AppOrderRespVO> list = appOrderRespVOPageResult.getList();
|
||||
for (AppOrderRespVO dishOrderDO : list) {
|
||||
List<AppOrderDetailRespVO> appOrderDetailRespVOS = orderDetailService.selectListByOrderId(dishOrderDO.getId());
|
||||
// if (CollectionUtil.isNotEmpty(appOrderDetailRespVOS)) {
|
||||
// List<Long> dishIds = appOrderDetailRespVOS.stream().map(AppOrderDetailRespVO::getDishesId).collect(Collectors.toList());
|
||||
//
|
||||
// List<DishesRespDto> dishInfo = dishesApi.getDishInfo(dishIds);
|
||||
// Map<Long, DishesRespDto> dishMap = dishInfo.stream().collect(Collectors.toMap(DishesRespDto::getId, DishesRespDto -> DishesRespDto));
|
||||
//
|
||||
// appOrderDetailRespVOS.forEach(respVo -> {
|
||||
// DishesRespDto dishesRespDto = dishMap.get(respVo.getDishesId());
|
||||
// if (ObjectUtil.isNotEmpty(dishesRespDto)) {
|
||||
// respVo.setDishesBasePrice(dishesRespDto.getDishesBasePrice())
|
||||
// .setDishesSumPrice(ObjectUtil.isNotEmpty(respVo.getUnitPrice())?respVo.getUnitPrice():dishesRespDto.getDishesSumPrice())
|
||||
// .setDishesNumber(dishesRespDto.getDishesNumber());
|
||||
// }
|
||||
//
|
||||
// });
|
||||
//
|
||||
// }
|
||||
|
||||
for (AppOrderDetailRespVO respVo : appOrderDetailRespVOS) {
|
||||
respVo.setDishesSumPrice(respVo.getUnitPrice());
|
||||
}
|
||||
dishOrderDO.setRefundStatus(refundService.getRefundStatus(dishOrderDO.getId()));
|
||||
dishOrderDO.setDetailList(appOrderDetailRespVOS);
|
||||
dishOrderDO.setMoney(cardMapper.getMoneyByUsr(dishOrderDO.getUserId()));
|
||||
// dishOrderDO.setMoney(cardMapper.getMoneyByUsr(dishOrderDO.getUserId()));
|
||||
|
||||
}
|
||||
return appOrderRespVOPageResult;
|
||||
|
@ -8,7 +8,7 @@ spring:
|
||||
autoconfigure:
|
||||
exclude:
|
||||
- com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源
|
||||
- org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration # 默认 local 环境,不开启 Quartz 的自动配置
|
||||
# - org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration # 默认 local 环境,不开启 Quartz 的自动配置
|
||||
- de.codecentric.boot.admin.server.config.AdminServerAutoConfiguration # 禁用 Spring Boot Admin 的 Server 的自动配置
|
||||
- de.codecentric.boot.admin.server.ui.config.AdminServerUiAutoConfiguration # 禁用 Spring Boot Admin 的 Server UI 的自动配置
|
||||
- de.codecentric.boot.admin.client.config.SpringBootAdminClientAutoConfiguration # 禁用 Spring Boot Admin 的 Client 的自动配置
|
||||
|
Reference in New Issue
Block a user