费用管理
parent
779324080b
commit
cf79cb6cab
|
|
@ -22,6 +22,8 @@ public interface StationMapper extends BaseMapper<StationEntity> {
|
||||||
StationResult detail(@Param("id") Long id);
|
StationResult detail(@Param("id") Long id);
|
||||||
|
|
||||||
List<StationResult> listAll(@Param("ew") QueryWrapper<?> ew);
|
List<StationResult> listAll(@Param("ew") QueryWrapper<?> ew);
|
||||||
|
|
||||||
|
boolean isManager(@Param("userId") Long userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,11 @@ public class StationService extends ServiceImpl<StationMapper, StationEntity> im
|
||||||
List<Long> stationIds = memberEntityList.stream().map(StationMemberEntity::getStationId).toList();
|
List<Long> stationIds = memberEntityList.stream().map(StationMemberEntity::getStationId).toList();
|
||||||
return baseMapper.listAll(Wrappers.query().in("a.id", stationIds));
|
return baseMapper.listAll(Wrappers.query().in("a.id", stationIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isManager() {
|
||||||
|
Long userId = SecurityUtil.currentUserId();
|
||||||
|
return baseMapper.isManager(userId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,6 @@
|
||||||
package com.njzscloud.dispose.finance.pojo.entity;
|
package com.njzscloud.dispose.finance.pojo.entity;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.njzscloud.dispose.common.pojo.entity.BaseEntity;
|
|
||||||
import com.njzscloud.dispose.finance.constant.ExpenseItemCategory;
|
import com.njzscloud.dispose.finance.constant.ExpenseItemCategory;
|
||||||
import com.njzscloud.dispose.finance.constant.ExpenseStrategy;
|
import com.njzscloud.dispose.finance.constant.ExpenseStrategy;
|
||||||
import com.njzscloud.dispose.finance.constant.Unit;
|
import com.njzscloud.dispose.finance.constant.Unit;
|
||||||
|
|
@ -13,6 +10,7 @@ import lombok.ToString;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 收费项目
|
* 收费项目
|
||||||
|
|
@ -24,7 +22,7 @@ import java.math.BigDecimal;
|
||||||
@ToString
|
@ToString
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
@TableName(value = "fin_expense_item", autoResultMap = true)
|
@TableName(value = "fin_expense_item", autoResultMap = true)
|
||||||
public class ExpenseItemEntity extends BaseEntity {
|
public class ExpenseItemEntity {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Id
|
* Id
|
||||||
|
|
@ -95,6 +93,7 @@ public class ExpenseItemEntity extends BaseEntity {
|
||||||
/**
|
/**
|
||||||
* 站点 Id
|
* 站点 Id
|
||||||
*/
|
*/
|
||||||
|
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
||||||
private Long stationId;
|
private Long stationId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -109,5 +108,34 @@ public class ExpenseItemEntity extends BaseEntity {
|
||||||
|
|
||||||
private Long goodsId;
|
private Long goodsId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建人 Id;sys_user.id
|
||||||
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT)
|
||||||
|
private Long creatorId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改人 Id; sys_user.id
|
||||||
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||||
|
private Long modifierId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT)
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改时间
|
||||||
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||||
|
private LocalDateTime modifyTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否删除; 0-->未删除、1-->已删除
|
||||||
|
*/
|
||||||
|
@TableLogic
|
||||||
|
private Boolean deleted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,10 @@ import java.math.BigDecimal;
|
||||||
@ToString
|
@ToString
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
public class AddExpenseItemParam {
|
public class AddExpenseItemParam {
|
||||||
|
private Long userId;
|
||||||
|
private Long customerId;
|
||||||
|
private Long orgId;
|
||||||
|
private Long stationId;
|
||||||
/**
|
/**
|
||||||
* 收费项目类型,QiTa-->其他、ChanPin-->产品、YunFei-->运费
|
* 收费项目类型,QiTa-->其他、ChanPin-->产品、YunFei-->运费
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ public class ModifyExpenseItemParam {
|
||||||
* Id
|
* Id
|
||||||
*/
|
*/
|
||||||
private Long id;
|
private Long id;
|
||||||
|
private Long stationId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 收费项目类型,QiTa-->其他、ChanPin-->产品、YunFei-->运费
|
* 收费项目类型,QiTa-->其他、ChanPin-->产品、YunFei-->运费
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
package com.njzscloud.dispose.finance.service;
|
package com.njzscloud.dispose.finance.service;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.njzscloud.common.mp.support.PageParam;
|
import com.njzscloud.common.mp.support.PageParam;
|
||||||
|
|
@ -10,6 +12,7 @@ import com.njzscloud.dispose.finance.mapper.ExpenseItemMapper;
|
||||||
import com.njzscloud.dispose.finance.pojo.entity.ExpenseItemEntity;
|
import com.njzscloud.dispose.finance.pojo.entity.ExpenseItemEntity;
|
||||||
import com.njzscloud.dispose.finance.pojo.param.AddExpenseItemParam;
|
import com.njzscloud.dispose.finance.pojo.param.AddExpenseItemParam;
|
||||||
import com.njzscloud.dispose.finance.pojo.param.ModifyExpenseItemParam;
|
import com.njzscloud.dispose.finance.pojo.param.ModifyExpenseItemParam;
|
||||||
|
import com.njzscloud.dispose.sys.auth.pojo.result.IdentityInfo;
|
||||||
import com.njzscloud.dispose.sys.auth.pojo.result.MyResult;
|
import com.njzscloud.dispose.sys.auth.pojo.result.MyResult;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
@ -65,6 +68,16 @@ public class ExpenseItemService extends ServiceImpl<ExpenseItemMapper, ExpenseIt
|
||||||
* 分页查询
|
* 分页查询
|
||||||
*/
|
*/
|
||||||
public PageResult<ExpenseItemEntity> paging(PageParam pageParam, ExpenseItemEntity expenseItemEntity) {
|
public PageResult<ExpenseItemEntity> paging(PageParam pageParam, ExpenseItemEntity expenseItemEntity) {
|
||||||
return PageResult.of(this.page(pageParam.toPage(), Wrappers.query(expenseItemEntity)));
|
String expenseItemName = expenseItemEntity.getExpenseItemName();
|
||||||
|
MyResult userDetail = SecurityUtil.loginUser();
|
||||||
|
List<IdentityInfo> identities = userDetail.getIdentities();
|
||||||
|
List<Long> orgIds = null;
|
||||||
|
if (CollUtil.isNotEmpty(identities)) {
|
||||||
|
orgIds = identities.stream().map(IdentityInfo::getOrgId).toList();
|
||||||
|
}
|
||||||
|
return PageResult.of(this.page(pageParam.toPage(), Wrappers.<ExpenseItemEntity>lambdaQuery()
|
||||||
|
.like(StrUtil.isNotBlank(expenseItemName), ExpenseItemEntity::getExpenseItemName, expenseItemName)
|
||||||
|
.in(CollUtil.isNotEmpty(orgIds), ExpenseItemEntity::getOrgId, orgIds)
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,10 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.njzscloud.common.mp.support.PageParam;
|
import com.njzscloud.common.mp.support.PageParam;
|
||||||
import com.njzscloud.common.mp.support.PageResult;
|
import com.njzscloud.common.mp.support.PageResult;
|
||||||
|
import com.njzscloud.common.security.util.SecurityUtil;
|
||||||
import com.njzscloud.common.sn.support.SnUtil;
|
import com.njzscloud.common.sn.support.SnUtil;
|
||||||
|
import com.njzscloud.dispose.cst.station.pojo.result.StationResult;
|
||||||
|
import com.njzscloud.dispose.cst.station.service.StationService;
|
||||||
import com.njzscloud.dispose.finance.constant.ExpenseItemCategory;
|
import com.njzscloud.dispose.finance.constant.ExpenseItemCategory;
|
||||||
import com.njzscloud.dispose.finance.pojo.entity.ExpenseItemEntity;
|
import com.njzscloud.dispose.finance.pojo.entity.ExpenseItemEntity;
|
||||||
import com.njzscloud.dispose.finance.pojo.param.AddExpenseItemParam;
|
import com.njzscloud.dispose.finance.pojo.param.AddExpenseItemParam;
|
||||||
|
|
@ -25,6 +28,7 @@ import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 产品
|
* 产品
|
||||||
|
|
@ -37,6 +41,7 @@ import java.util.List;
|
||||||
public class GoodsService extends ServiceImpl<GoodsMapper, GoodsEntity> {
|
public class GoodsService extends ServiceImpl<GoodsMapper, GoodsEntity> {
|
||||||
|
|
||||||
private final ExpenseItemService expenseItemService;
|
private final ExpenseItemService expenseItemService;
|
||||||
|
private final StationService stationService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增
|
* 新增
|
||||||
|
|
@ -69,12 +74,36 @@ public class GoodsService extends ServiceImpl<GoodsMapper, GoodsEntity> {
|
||||||
this.updateById(goodsEntity);
|
this.updateById(goodsEntity);
|
||||||
// 付费项
|
// 付费项
|
||||||
ModifyGoodsParam.ExpenseItem expenseItem = modifyGoodsParam.getExpenseItem();
|
ModifyGoodsParam.ExpenseItem expenseItem = modifyGoodsParam.getExpenseItem();
|
||||||
|
if (expenseItem == null) return;
|
||||||
|
Long userId = SecurityUtil.currentUserId();
|
||||||
|
List<StationResult> stationResults = stationService.listAll();
|
||||||
|
Optional<StationResult> stationResultOpt = stationResults.stream().filter(it -> it.getCustomer().getManager()).findFirst();
|
||||||
|
if (stationResultOpt.isEmpty()) return;
|
||||||
|
StationResult stationResult = stationResultOpt.get();
|
||||||
|
Long customerId = stationResult.getCustomer().getId();
|
||||||
|
Long orgId = stationResult.getOrgId();
|
||||||
|
Long stationId = stationResult.getId();
|
||||||
|
Long goodsId = goodsEntity.getId();
|
||||||
String goodsName = modifyGoodsParam.getGoodsName();
|
String goodsName = modifyGoodsParam.getGoodsName();
|
||||||
ModifyExpenseItemParam modifyExpenseItemParam = BeanUtil.copyProperties(expenseItem, ModifyExpenseItemParam.class)
|
ExpenseItemEntity expenseItemEntity = expenseItemService.getOne(Wrappers.<ExpenseItemEntity>lambdaQuery().eq(ExpenseItemEntity::getStationId, stationId).eq(ExpenseItemEntity::getGoodsId, goodsId));
|
||||||
.setExpenseItemName(goodsName)
|
if (expenseItemEntity == null) {
|
||||||
.setMemo(goodsName + "费用配置");
|
AddExpenseItemParam addExpenseItemParam = BeanUtil.copyProperties(expenseItem, AddExpenseItemParam.class)
|
||||||
expenseItemService.modify(modifyExpenseItemParam);
|
.setUserId(userId)
|
||||||
|
.setCustomerId(customerId)
|
||||||
|
.setOrgId(orgId)
|
||||||
|
.setStationId(stationId)
|
||||||
|
.setGoodsId(goodsId)
|
||||||
|
.setExpenseItemName(goodsName)
|
||||||
|
.setExpenseItemCategory(ExpenseItemCategory.ChanPin)
|
||||||
|
.setMemo(goodsName + "费用配置");
|
||||||
|
expenseItemService.add(addExpenseItemParam);
|
||||||
|
} else {
|
||||||
|
ModifyExpenseItemParam modifyExpenseItemParam = BeanUtil.copyProperties(expenseItem, ModifyExpenseItemParam.class)
|
||||||
|
.setId(expenseItemEntity.getId())
|
||||||
|
.setExpenseItemName(goodsName)
|
||||||
|
.setMemo(goodsName + "费用配置");
|
||||||
|
expenseItemService.modify(modifyExpenseItemParam);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,8 @@
|
||||||
e.idcard_front,
|
e.idcard_front,
|
||||||
e.idcard_back
|
e.idcard_back
|
||||||
FROM cst_station a
|
FROM cst_station a
|
||||||
INNER JOIN cst_customer b ON b.org_id = a.org_id AND b.manager = 1 AND b.deleted = 0
|
INNER JOIN cst_station_member f ON f.station_id = a.id
|
||||||
|
INNER JOIN cst_customer b ON b.org_id = a.org_id AND b.id = f.customer_id AND b.deleted = 0
|
||||||
INNER JOIN sys_user c ON c.id = b.user_id AND c.deleted = 0
|
INNER JOIN sys_user c ON c.id = b.user_id AND c.deleted = 0
|
||||||
INNER JOIN sys_user_account d ON d.user_id = c.id AND d.deleted = 0
|
INNER JOIN sys_user_account d ON d.user_id = c.id AND d.deleted = 0
|
||||||
INNER JOIN cst_org e ON e.id = a.org_id AND e.deleted = 0
|
INNER JOIN cst_org e ON e.id = a.org_id AND e.deleted = 0
|
||||||
|
|
@ -80,4 +81,10 @@
|
||||||
${ew.customSqlSegment}
|
${ew.customSqlSegment}
|
||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
<select id="isManager" resultType="java.lang.Boolean">
|
||||||
|
SELECT *
|
||||||
|
FROM cst_station_member a
|
||||||
|
INNER JOIN cst_customer b ON b.id = a.customer_id AND b.deleted = 0 AND b.manager = 1 AND b.org_id = a.org_id
|
||||||
|
WHERE a.user_id = #{userId}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue