This commit is contained in:
qjq
2024-12-02 11:40:08 +08:00
parent b82ddbd3a9
commit bb92c92506
3 changed files with 16 additions and 10 deletions

View File

@ -154,6 +154,7 @@ public interface ErrorCodeConstants {
ErrorCode BILLING_NOT_COMPLETE = new ErrorCode(1_004_023_00, "还有金额未开票"); ErrorCode BILLING_NOT_COMPLETE = new ErrorCode(1_004_023_00, "还有金额未开票");
ErrorCode BILLING_NOT_EXISTS = new ErrorCode(1_004_023_00, "开票记录不存在"); ErrorCode BILLING_NOT_EXISTS = new ErrorCode(1_004_023_00, "开票记录不存在");
ErrorCode BILLING_NOT_ORDER_EXISTS= new ErrorCode(1_004_023_00, "该时间段没有订单可开票"); ErrorCode BILLING_NOT_ORDER_EXISTS= new ErrorCode(1_004_023_00, "该时间段没有订单可开票");
ErrorCode BILLING_NOT_ORDER_MOENY= new ErrorCode(1_004_023_00, "27号(包含27号)以后才能开票");
ErrorCode BILLING_NOT_ORDER_REFUSE= new ErrorCode(1_004_024_00, "拒绝理由不能为空"); ErrorCode BILLING_NOT_ORDER_REFUSE= new ErrorCode(1_004_024_00, "拒绝理由不能为空");
ErrorCode BILLING_NOT_ORDER_SECURITY= new ErrorCode(1_004_023_41, "没有权限给单位统一开票"); ErrorCode BILLING_NOT_ORDER_SECURITY= new ErrorCode(1_004_023_41, "没有权限给单位统一开票");
ErrorCode CAROUSEL_NOT_EXISTS = new ErrorCode(1_004_025_00, "小程序轮播图不存在"); ErrorCode CAROUSEL_NOT_EXISTS = new ErrorCode(1_004_025_00, "小程序轮播图不存在");

View File

@ -69,7 +69,8 @@ public class AppBillingController {
@Operation(summary = "获得开票记录分页") @Operation(summary = "获得开票记录分页")
public CommonResult<PageResult<BillingRespVO>> getBillingPage(@Valid BillingPageReqVO pageReqVO) { public CommonResult<PageResult<BillingRespVO>> getBillingPage(@Valid BillingPageReqVO pageReqVO) {
Long userId = pageReqVO.getUserId(); Long userId = pageReqVO.getUserId();
pageReqVO.setUserPhone(billingService.getMemberId(userId)); // pageReqVO.setUserPhone(billingService.getMemberId(userId));
pageReqVO.setUserPhone(String.valueOf(userId));
pageReqVO.setUserId(null); pageReqVO.setUserId(null);
PageResult<BillingDO> pageResult = billingService.getBillingPage(pageReqVO); PageResult<BillingDO> pageResult = billingService.getBillingPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, BillingRespVO.class)); return success(BeanUtils.toBean(pageResult, BillingRespVO.class));

View File

@ -235,16 +235,19 @@ public class BillingServiceImpl implements BillingService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public String createBillingUnit(BillingSaveReqVO createReqVO) { public String createBillingUnit(BillingSaveReqVO createReqVO) {
DateTime date = DateUtil.date();
int i = date.dayOfMonth();
if(i<27) throw exception(BILLING_NOT_ORDER_MOENY);
// 插入 BillingDO 对象并生成唯一主键 // 插入 BillingDO 对象并生成唯一主键
BillingDO billing = BeanUtils.toBean(createReqVO, BillingDO.class); BillingDO billing = BeanUtils.toBean(createReqVO, BillingDO.class);
Set<Long> orderId = createReqVO.getOrderId(); Set<Long> orderId = createReqVO.getOrderId();
if(orderId==null){ if(orderId==null){
createReqVO.setOrderId(new HashSet<>(getMemberListByUserId(billing.getUserId()))) ; createReqVO.setOrderId(new HashSet<>(getMemberListByUserId(billing.getUserId()))) ;
} }
MemberGroupDO memberGroupDO = memberGroupDO(billing.getUserId()); // MemberGroupDO memberGroupDO = memberGroupDO(billing.getUserId());
billing.setId(IdUtil.getSnowflakeNextId() + ""); billing.setId(IdUtil.getSnowflakeNextId() + "");
billing.setUserName(memberGroupDO.getName()); // billing.setUserName(memberGroupDO.getName());
billing.setUserPhone(String.valueOf(memberGroupDO.getId())); // billing.setUserPhone(String.valueOf(memberGroupDO.getId()));
billing.setUserId(billing.getUserId()); billing.setUserId(billing.getUserId());
//查询单位充值的金额 //查询单位充值的金额
List<CardDO> moneyByUserIds = cardMapper.getMoneyByUserIds(createReqVO.getOrderId(), CardDO.ADD, CostTypeEnum.ADMIN_PAY.getCode(),BillingStatusEnum.BILLING_INVOICING_REJECTION.getCode()); List<CardDO> moneyByUserIds = cardMapper.getMoneyByUserIds(createReqVO.getOrderId(), CardDO.ADD, CostTypeEnum.ADMIN_PAY.getCode(),BillingStatusEnum.BILLING_INVOICING_REJECTION.getCode());
@ -261,7 +264,7 @@ public class BillingServiceImpl implements BillingService {
cardMapper.updateBatch(moneyByUserIds); cardMapper.updateBatch(moneyByUserIds);
billing.setBillingMoney(totalMoney); billing.setBillingMoney(totalMoney);
billing.setOrderId(JSONUtil.toJsonStr(createReqVO.getOrderId())); billing.setOrderId(JSONUtil.toJsonStr(createReqVO.getOrderId()));
billing.setBillingName(memberGroupDO.getName()+" 消费 "+totalMoney+""); billing.setBillingName(billing.getUserName()+" 消费 "+totalMoney+"");
billing.setRequestBillingTime(LocalDateTime.now()); billing.setRequestBillingTime(LocalDateTime.now());
billing.setStatus(BillingStatusEnum.BILLING_INVOICING.getCode()); billing.setStatus(BillingStatusEnum.BILLING_INVOICING.getCode());
// 插入 BillingDO 对象到数据库 // 插入 BillingDO 对象到数据库
@ -603,10 +606,10 @@ public class BillingServiceImpl implements BillingService {
@Override @Override
public Map<Integer, Integer> getBillingTypeTotal(Long carteenId, Long userId) { public Map<Integer, Integer> getBillingTypeTotal(Long carteenId, Long userId) {
Map<Integer,Integer> map= MapUtil.newHashMap(); Map<Integer,Integer> map= MapUtil.newHashMap();
MemberGroupDO memberGroupDO = memberGroupDO(userId); // MemberGroupDO memberGroupDO = memberGroupDO(userId);
Long id = memberGroupDO.getId(); // Long id = memberGroupDO.getId();
List<BillingDO> billingDOS = billingMapper.selectList(new LambdaQueryWrapperX<BillingDO>() List<BillingDO> billingDOS = billingMapper.selectList(new LambdaQueryWrapperX<BillingDO>()
.eq(BillingDO::getUserPhone, id) .eq(BillingDO::getUserPhone, userId)
.eqIfPresent(BillingDO::getCarteenId,carteenId) .eqIfPresent(BillingDO::getCarteenId,carteenId)
); );
Map<Integer, List<BillingDO>> collect = billingDOS.stream().collect(Collectors.groupingBy(BillingDO::getStatus)); Map<Integer, List<BillingDO>> collect = billingDOS.stream().collect(Collectors.groupingBy(BillingDO::getStatus));
@ -634,12 +637,13 @@ public class BillingServiceImpl implements BillingService {
*/ */
private List<Long> getMemberListByUserId(Long userId) { private List<Long> getMemberListByUserId(Long userId) {
// 获取当前单位下的所有成员 // 获取当前单位下的所有成员
return memberGroupMapper.getMemberList(memberGroupDO(userId).getId()); // return memberGroupMapper.getMemberList(memberGroupDO(userId).getId());
return memberGroupMapper.getMemberList(userId);
} }
private MemberGroupDO memberGroupDO(Long userId){ private MemberGroupDO memberGroupDO(Long userId){
// 校验是否为管理员 // 校验是否为管理员
MemberGroupDO memberGroupDO = memberGroupMapper.selectOne(new LambdaQueryWrapperX<MemberGroupDO>() MemberGroupDO memberGroupDO = memberGroupMapper.selectOne(new LambdaQueryWrapperX<MemberGroupDO>()
.eq(MemberGroupDO::getUserId, userId) .eq(MemberGroupDO::getId, userId)
.last(" limit 1")); .last(" limit 1"));
if (memberGroupDO == null) { if (memberGroupDO == null) {
throw exception(GROUP_NOT_EXISTS); throw exception(GROUP_NOT_EXISTS);