退款提现

This commit is contained in:
zengtao01
2024-07-26 16:25:49 +08:00
parent 1de2f8a6b7
commit 3bd4199bf5
2 changed files with 42 additions and 12 deletions

View File

@ -1,12 +1,11 @@
package cn.iocoder.yudao.module.member.controller.admin.appup.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import java.util.*;
import org.springframework.format.annotation.DateTimeFormat;
import lombok.Data;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - app更新 Response VO")
@Data
@ -41,8 +40,8 @@ public class AppUpRespVO {
@ExcelProperty("文件路径")
private String fileUrl;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
@Schema(description = "更改时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("更改时间")
private LocalDateTime updateTime;
}

View File

@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.member.service.card;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.exception.ErrorCode;
import cn.iocoder.yudao.framework.common.exception.ServiceException;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
@ -23,6 +22,7 @@ import cn.iocoder.yudao.module.member.util.MemberConstants;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
@ -140,7 +140,18 @@ public class CardServiceImpl implements CardService {
cardDO.setGiftAmount(giftOldMoney.add(giftMoney).setScale(2, BigDecimal.ROUND_HALF_UP));
wxAmount = wxAmount.subtract(giftMoney);
}
cardDO.setWxAmount(wxOldMoney.add(wxAmount).setScale(2, BigDecimal.ROUND_HALF_UP));
if(oldMoney.compareTo(BigDecimal.ZERO)<0){
updateOrderStatus(cardDO.getUserId());
if(wxAmount.add(oldMoney).compareTo(BigDecimal.ZERO)>=0){
cardDO.setWxAmount(wxAmount.add(oldMoney));
}else{
BigDecimal left = wxAmount.add(oldMoney);
cardDO.setWxAmount(BigDecimal.ZERO);
cardDO.setGiftAmount(giftMoney.add(left));
}
}else{
cardDO.setWxAmount(wxOldMoney.add(wxAmount).setScale(2, BigDecimal.ROUND_HALF_UP));
}
}
int i =cardMapper.insert(cardDO);
return i > 0;
@ -221,6 +232,7 @@ public class CardServiceImpl implements CardService {
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean rechargeByAdmin(RechargeVO vo) {
List<Long> memberList = new ArrayList<>();
if (vo.getGroupId() != null) {
@ -249,13 +261,18 @@ public class CardServiceImpl implements CardService {
BigDecimal oldMoney = cardDO.getMoney();
add.setMoney(oldMoney.add(vo.getMoney()).setScale(2, BigDecimal.ROUND_HALF_UP));
if(cardDO.getMoney().compareTo(BigDecimal.ZERO) >0){
if(add.getMoney().compareTo(BigDecimal.ZERO) >0){
BigDecimal cashOldMoney = cardDO.getCashAmount();
add.setCashAmount(cashOldMoney.add(vo.getMoney()).setScale(2, BigDecimal.ROUND_HALF_UP));
add.setCashAmount(cashOldMoney.add(add.getMoney()).setScale(2, BigDecimal.ROUND_HALF_UP));
add.setWxAmount(cardDO.getWxAmount());
add.setGiftAmount(cardDO.getGiftAmount());
if(oldMoney.compareTo(BigDecimal.ZERO)<0){
updateOrderStatus(cardDO.getUserId());
}
}
addList.add(add);
}
//添加新的用户金额
@ -380,4 +397,18 @@ public class CardServiceImpl implements CardService {
int insert = cardMapper.insert(cardDO);
return insert>0;
}
void updateOrderStatus(Long userId){
LambdaQueryWrapper<DishOrderDO> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(DishOrderDO::getUserId,userId);
wrapper.eq(DishOrderDO::getOrderStatus,DishOrderDO.TOCOMPLETE);
List<DishOrderDO> dishOrderDOS = dishOrderMapper.selectList(wrapper);
if(CollectionUtil.isNotEmpty(dishOrderDOS)){
dishOrderDOS.forEach(vo -> vo.setOrderStatus(DishOrderDO.COMPLETE));
dishOrderMapper.updateBatch(dishOrderDOS);
}
}
}