金额修改
This commit is contained in:
@ -56,6 +56,14 @@ public class OrderDetailsRespVO {
|
||||
@ExcelProperty("金额")
|
||||
private BigDecimal totalMoney;
|
||||
|
||||
@Schema(description = "现金金额")
|
||||
@ExcelProperty("现金金额")
|
||||
private BigDecimal cashAmount;
|
||||
|
||||
@Schema(description = "微信金额")
|
||||
@ExcelProperty("微信金额")
|
||||
private BigDecimal wxAmount;
|
||||
|
||||
@Schema(description = "支付方式", example = "钱包")
|
||||
private String payMethods;
|
||||
|
||||
|
@ -63,15 +63,10 @@ public class AppMemberUserController {
|
||||
UserExpandDO userExpandByuserId = userExpandService.getUserExpandByuserId(getLoginUserId());
|
||||
AppMemberUserInfoRespVO convert = MemberUserConvert.INSTANCE.convert(user, level);
|
||||
convert.setUserExpandDO(userExpandByuserId);
|
||||
if(carteenId!=null){
|
||||
MoneyDO moneyDO = moneyService.getMoney(user.getId(), carteenId);
|
||||
if(ObjectUtil.isNotEmpty(moneyDO)){
|
||||
convert.setCashAmount(moneyDO.getCashAmount());
|
||||
convert.setDebtAmount(moneyDO.getDebtAmount());
|
||||
}else {
|
||||
convert.setCashAmount(BigDecimal.ZERO);
|
||||
convert.setCashAmount(user.getCashAmount());
|
||||
convert.setDebtAmount(BigDecimal.ZERO);
|
||||
}
|
||||
if(user.getMoney().compareTo(BigDecimal.ZERO) < 0 ){
|
||||
convert.setDebtAmount(user.getMoney());
|
||||
|
||||
}
|
||||
return success(convert);
|
||||
|
@ -49,6 +49,8 @@ public class OrderStatusConverter implements Converter<String> {
|
||||
value = "待付款";
|
||||
} else if ("1".equals(value)) {
|
||||
value = "已完成";
|
||||
}else {
|
||||
value = "未完成";
|
||||
}
|
||||
|
||||
return new WriteCellData<>(value);
|
||||
|
@ -6,8 +6,10 @@ import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.business.vo.BusinessPageReqVO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.business.BusinessDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -39,4 +41,8 @@ public interface BusinessMapper extends BaseMapperX<BusinessDO> {
|
||||
@Select("select id from t_carteen where deleted = false")
|
||||
List<Long> getAllStoreId();
|
||||
|
||||
|
||||
@Select("select * from t_business where carteen_id = #{carteenId} and create_time between #{startOfDay} and #{endOfDay} limit 1 for update")
|
||||
BusinessDO getTodayBusiness(@Param("carteenId") Long carteenId, @Param("startOfDay") LocalDateTime startOfDay, @Param("endOfDay") LocalDateTime endOfDay);
|
||||
|
||||
}
|
@ -62,8 +62,10 @@ public interface CardMapper extends BaseMapperX<CardDO> {
|
||||
|
||||
@Select("select IFNULL(sum(change_money),0) as money,count(*) as count FROM member_card where user_id = #{userId} and flag = #{flag} and create_time BETWEEN #{startTime} and #{endTime}")
|
||||
AppCardMonthVO selectMonth(@Param("userId") Long userId,@Param("flag") String flag, @Param("startTime") LocalDateTime startTime, @Param("endTime")LocalDateTime endTime);
|
||||
@Select("select SUM(change_money) from member_card where user_id= #{userId} and flag= #{flag} and carteen_id = #{carteenId}")
|
||||
BigDecimal selectAddMoney(@Param("userId") Long userId,@Param("flag") String flag,@Param("carteenId") Long carteenId);
|
||||
@Select("select SUM(change_money) from member_card where user_id= #{userId} and flag= #{flag} and type= '5'")
|
||||
BigDecimal selectAddMoney(@Param("userId") Long userId,@Param("flag") String flag);
|
||||
@Select("select SUM(change_money) from member_card where user_id= #{userId} and flag= #{flag}")
|
||||
BigDecimal selectReduceMoney(@Param("userId") Long userId,@Param("flag") String flag);
|
||||
@Select("select sum(change_money) from member_card where user_id= #{userId} and type= '1'")
|
||||
BigDecimal selectWxMoney(@Param("userId") Long userId);
|
||||
|
||||
|
@ -21,6 +21,7 @@ public enum CostTypeEnum {
|
||||
WITHDRAW("7","微信提现"),
|
||||
CASH_WITHDRAW("8","现金提现"),
|
||||
SHOPPING("9","购物"),
|
||||
SPACE("10","太空舱"),
|
||||
;
|
||||
|
||||
/**
|
||||
|
@ -91,10 +91,11 @@ public class CashRechargeServiceImpl implements CashRechargeService {
|
||||
memberUserDO.setCashAmount(memberUserDO.getCashAmount().add(money));
|
||||
}
|
||||
}
|
||||
|
||||
userMapper.updateById(memberUserDO);
|
||||
wxNewMoney = memberUserDO.getWxAmount();
|
||||
cashNewAmount = memberUserDO.getCashAmount();
|
||||
name = memberUserDO.getNickname();
|
||||
|
||||
}
|
||||
|
||||
//记录明细
|
||||
@ -107,6 +108,7 @@ public class CashRechargeServiceImpl implements CashRechargeService {
|
||||
add.setWxAmount(wxNewMoney);
|
||||
add.setCarteenId(storeId);
|
||||
add.setGroupId(groupId);
|
||||
add.setMoney(newMoney);
|
||||
add.setGroupName(ObjectUtil.isNotEmpty(memberGroupDO)?memberGroupDO.getName():null);
|
||||
addList.add(add);
|
||||
|
||||
|
@ -176,6 +176,7 @@ public class DeductionServiceImpl implements DeductionService {
|
||||
cardDO.setCashAmount(cashNewMoney);
|
||||
cardDO.setWxAmount(wxNewMoney);
|
||||
cardDO.setCarteenId(dishOrderDO.getStoreId());
|
||||
cardDO.setMoney(newMoney);
|
||||
|
||||
cardService.insertOne(cardDO);
|
||||
|
||||
@ -233,6 +234,7 @@ public class DeductionServiceImpl implements DeductionService {
|
||||
cardDO.setWxAmount(wxNewMoney);
|
||||
cardDO.setCashAmount(cashNewMoney);
|
||||
cardDO.setCarteenId(storeId);
|
||||
cardDO.setMoney(newMoney);
|
||||
cardService.insertOne(cardDO);
|
||||
|
||||
//更新redis
|
||||
@ -269,6 +271,7 @@ public class DeductionServiceImpl implements DeductionService {
|
||||
cardDO.setType("7");
|
||||
cardDO.setWxAmount(wxNewMoney);
|
||||
cardDO.setCashAmount(cashNewMoney);
|
||||
cardDO.setMoney(newMoney);
|
||||
cardService.insertOne(cardDO);
|
||||
|
||||
//更新redis
|
||||
@ -335,6 +338,7 @@ public class DeductionServiceImpl implements DeductionService {
|
||||
cardDO.setWxAmount(wxNewMoney);
|
||||
cardDO.setCashAmount(cashNewMoney);
|
||||
cardDO.setCarteenId(dishOrderDO.getStoreId());
|
||||
cardDO.setMoney(newTotalMoney);
|
||||
cardService.insertOne(cardDO);
|
||||
|
||||
//更新redis
|
||||
@ -370,6 +374,7 @@ public class DeductionServiceImpl implements DeductionService {
|
||||
cardDO.setWxAmount(wxNewAmount);
|
||||
cardDO.setCashAmount(cashNewAmount);
|
||||
cardDO.setCarteenId(storeId);
|
||||
cardDO.setMoney(newAmount);
|
||||
cardService.insertOne(cardDO);
|
||||
|
||||
//更新redis
|
||||
@ -403,8 +408,8 @@ public class DeductionServiceImpl implements DeductionService {
|
||||
}
|
||||
|
||||
//扣除金额
|
||||
if (judge) {
|
||||
user.setMoney(money.subtract(total));
|
||||
if (judge) {
|
||||
user.setWxAmount(wxAmount.subtract(total));
|
||||
} else {
|
||||
if (total.compareTo(cashAmount) <= 0) {
|
||||
@ -432,6 +437,7 @@ public class DeductionServiceImpl implements DeductionService {
|
||||
cardDO.setWxAmount(wxNewMoney);
|
||||
cardDO.setCashAmount(cashNewMoney);
|
||||
cardDO.setCarteenId(storeId);
|
||||
cardDO.setMoney(newMoney);
|
||||
cardService.insertOne(cardDO);
|
||||
|
||||
|
||||
@ -504,6 +510,7 @@ public class DeductionServiceImpl implements DeductionService {
|
||||
cardDO.setWxAmount(wxNewMoney);
|
||||
cardDO.setCashAmount(cashNewMoney);
|
||||
cardDO.setCarteenId(storeId);
|
||||
cardDO.setMoney(newMoney);
|
||||
cardService.insertOne(cardDO);
|
||||
|
||||
//更新redis
|
||||
@ -551,7 +558,7 @@ public class DeductionServiceImpl implements DeductionService {
|
||||
userService.updateById(user);
|
||||
|
||||
wxNewMoney = user.getWxAmount();
|
||||
newMoney = user.getGiftAmount();
|
||||
newMoney = user.getMoney();
|
||||
cashNewMoney = user.getCashAmount();
|
||||
name = user.getNickname();
|
||||
}
|
||||
@ -564,6 +571,7 @@ public class DeductionServiceImpl implements DeductionService {
|
||||
cardDO.setWxAmount(wxNewMoney);
|
||||
cardDO.setCashAmount(cashNewMoney);
|
||||
cardDO.setCarteenId(storeId);
|
||||
cardDO.setMoney(newMoney);
|
||||
cardService.insertOne(cardDO);
|
||||
|
||||
//更新redis
|
||||
|
@ -62,6 +62,7 @@ public class WxRechargeServiceImpl implements WxRechargeService {
|
||||
|
||||
|
||||
BigDecimal wxNewMoney;
|
||||
BigDecimal cashNewMoney;
|
||||
BigDecimal newMoney;
|
||||
String name;
|
||||
|
||||
@ -88,6 +89,7 @@ public class WxRechargeServiceImpl implements WxRechargeService {
|
||||
|
||||
wxNewMoney = memberUserDO.getWxAmount();
|
||||
name = memberUserDO.getNickname();
|
||||
cashNewMoney = memberUserDO.getCashAmount();
|
||||
}
|
||||
|
||||
|
||||
@ -98,6 +100,8 @@ public class WxRechargeServiceImpl implements WxRechargeService {
|
||||
cardDO.setChangeMoney(money);
|
||||
cardDO.setType(CostTypeEnum.WX_PAY.getCode());
|
||||
cardDO.setWxAmount(wxNewMoney);
|
||||
cardDO.setCashAmount(cashNewMoney);
|
||||
cardDO.setMoney(newMoney);
|
||||
cardMapper.insert(cardDO);
|
||||
|
||||
|
||||
|
@ -28,6 +28,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
@ -109,8 +110,9 @@ public class BusinessServiceImpl implements BusinessService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void updateStatistics(StatisticsVo vo) {
|
||||
synchronized(getStoreLock(vo.getCarteenId())){
|
||||
|
||||
LocalDate now = LocalDate.now();
|
||||
if (vo.getTime() != null) {
|
||||
now = vo.getTime().toLocalDate();
|
||||
@ -120,12 +122,8 @@ public class BusinessServiceImpl implements BusinessService {
|
||||
// 获取今天的结束时间 (23:59:59.999)
|
||||
LocalDateTime endOfDay = LocalDateTime.of(now, LocalTime.MAX);
|
||||
|
||||
List<BusinessDO> businessDOS = businessMapper.selectList(Wrappers.<BusinessDO>lambdaQuery()
|
||||
.between(BusinessDO::getCreateTime, startOfDay, endOfDay)
|
||||
.eq(BusinessDO::getCarteenId, vo.getCarteenId()));
|
||||
if (CollectionUtil.isNotEmpty(businessDOS)) {
|
||||
BusinessDO businessDO = businessDOS.get(0);
|
||||
|
||||
BusinessDO businessDO = businessMapper.getTodayBusiness(vo.getCarteenId(), startOfDay, endOfDay);
|
||||
if (ObjectUtil.isNotEmpty(businessDO)) {
|
||||
//重量
|
||||
if (ObjectUtil.isNotEmpty(vo.getOrderId())) {
|
||||
List<OrderDetailDO> orderDetailDOS = orderDetailMapper.selectList(Wrappers.<OrderDetailDO>lambdaQuery().eq(OrderDetailDO::getOrderId, vo.getOrderId()));
|
||||
@ -177,7 +175,6 @@ public class BusinessServiceImpl implements BusinessService {
|
||||
|
||||
businessMapper.updateById(businessDO);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -374,9 +374,6 @@ public class OrderServiceImpl implements OrderService {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param userId
|
||||
* @param carteenId
|
||||
* @return
|
||||
* @Description: 根据会员编号,获得会员余额,充值金额,消费金额
|
||||
* @Author: qjq
|
||||
* @Date: 2024/4/24 上午9:52
|
||||
@ -385,13 +382,13 @@ public class OrderServiceImpl implements OrderService {
|
||||
public OrderMoneyRespVO getUserMeney(Long userId, Long carteenId) {
|
||||
OrderMoneyRespVO orderMoneyRespVO = new OrderMoneyRespVO();
|
||||
//获取充值的金额
|
||||
BigDecimal add = cardMapper.selectAddMoney(userId, CardDO.ADD,carteenId);
|
||||
BigDecimal add = cardMapper.selectAddMoney(userId, CardDO.ADD);
|
||||
if (add == null) {
|
||||
add = BigDecimal.ZERO;
|
||||
}
|
||||
orderMoneyRespVO.setRechargeMoney(add);
|
||||
//消费的金额
|
||||
BigDecimal minus = cardMapper.selectAddMoney(userId, CardDO.MINUS,carteenId);
|
||||
BigDecimal minus = cardMapper.selectReduceMoney(userId, CardDO.MINUS);
|
||||
if (minus == null) {
|
||||
minus = BigDecimal.ZERO;
|
||||
}
|
||||
@ -400,15 +397,11 @@ public class OrderServiceImpl implements OrderService {
|
||||
MemberUserDO memberUserDO = memberUserMapper.selectById(userId);
|
||||
orderMoneyRespVO.setCurrentMoney(memberUserDO.getWxAmount());
|
||||
orderMoneyRespVO.setUserId(userId);
|
||||
|
||||
MoneyDO moneyDO = moneyService.getMoney(userId, carteenId);
|
||||
orderMoneyRespVO.setCashMoney(BigDecimal.ZERO);
|
||||
orderMoneyRespVO.setCashMoney(memberUserDO.getCashAmount());
|
||||
orderMoneyRespVO.setDebtMoney(BigDecimal.ZERO);
|
||||
if(ObjectUtil.isNotEmpty(moneyDO)){
|
||||
orderMoneyRespVO.setCashMoney(moneyDO.getCashAmount());
|
||||
orderMoneyRespVO.setDebtMoney(moneyDO.getDebtAmount());
|
||||
if(memberUserDO.getMoney().compareTo(BigDecimal.ZERO)<0){
|
||||
orderMoneyRespVO.setDebtMoney(memberUserDO.getMoney());
|
||||
}
|
||||
|
||||
BigDecimal wxRechargeMoney = cardMapper.selectWxMoney(userId);
|
||||
orderMoneyRespVO.setWxRechargeMoney(wxRechargeMoney);
|
||||
return orderMoneyRespVO;
|
||||
|
@ -84,7 +84,7 @@ public class OrderSpaceCapsuleServiceImpl implements OrderSpaceCapsuleService {
|
||||
BigDecimal multiply = orderSpaceCapsule.getComboPrice().multiply(BigDecimal.valueOf(orderSpaceCapsule.getComboNum()));
|
||||
orderSpaceCapsule.setMoney(multiply);
|
||||
// 扣除余额
|
||||
deductionService.spaceDeduct(orderSpaceCapsule.getUserId(), orderSpaceCapsule.getMoney(), CostTypeEnum.SHOPPING.getCode(),createReqVO.getCarteenId());
|
||||
deductionService.spaceDeduct(orderSpaceCapsule.getUserId(), orderSpaceCapsule.getMoney(), CostTypeEnum.SPACE.getCode(),createReqVO.getCarteenId());
|
||||
// 设置变动后的余额
|
||||
orderSpaceCapsule.setEndMoney(initialMoney.subtract(orderSpaceCapsule.getMoney()));
|
||||
// 设置支付方式
|
||||
|
@ -234,13 +234,9 @@ public class StoreOrderServiceImpl implements StoreOrderService {
|
||||
BigDecimal totalMoney = BigDecimal.valueOf(sum);
|
||||
|
||||
MemberUserDO user = userService.getUser(Long.valueOf(s));
|
||||
MoneyDO moneyDO = moneyService.getMoney(user.getId(), storeId);
|
||||
BigDecimal cashAmount = BigDecimal.ZERO;
|
||||
if(ObjectUtil.isNotEmpty(moneyDO)){
|
||||
cashAmount = moneyDO.getCashAmount();
|
||||
}
|
||||
|
||||
dto.setUserId(user.getId());
|
||||
if(user.getWxAmount().add(cashAmount).compareTo(totalMoney) < 0){
|
||||
if(user.getMoney().compareTo(totalMoney) < 0){
|
||||
throw exception(AMOUNT_NOT_ENOUGH);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user