记账本

This commit is contained in:
shuo.wang
2025-03-31 10:14:10 +08:00
parent 4e919f0172
commit ae381ea81a
14 changed files with 512 additions and 3 deletions

View File

@@ -234,7 +234,8 @@ public enum ErrorCodeEnum {
LICENSE_LEGAL_STAGE_FAIL(131001,"营业执照阶段未上传!",null),
GET_JURIDICAL_ID_CARD_NO_FAIL(131002,"获取法人身份证信息失败!",null),
UPDATE_INVESTMENT_MANAGER_FAIL(131005,"当前用户已经为该门店招商经理",null),
CONFIRM_THE_APPROVER(131006,"您提交的铺位暂时找不到选址审批人,请联系系统管理员配置选址审批权限后再提交铺位审批",null)
CONFIRM_THE_APPROVER(131006,"您提交的铺位暂时找不到选址审批人,请联系系统管理员配置选址审批权限后再提交铺位审批",null),
;

View File

@@ -0,0 +1,34 @@
package com.cool.store.enums;
/**
* @Author: WangShuo
* @Date: 2025/03/28/14:11
* @Version 1.0
* @注释:
*/
public enum TallyBookStatusEnum {
NOT_SUBMIT(0, "未提交"),
IS_SUBMIT(1, "已提交");
private Integer code;
private String desc;
TallyBookStatusEnum(Integer code, String desc) {
this.code = code;
this.desc = desc;
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {}
}

View File

@@ -0,0 +1,36 @@
package com.cool.store.dao;
import com.cool.store.entity.TallyBookDO;
import com.cool.store.mapper.TallyBookMapper;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.entity.Example;
import javax.annotation.Resource;
import java.util.List;
/**
* @Author: WangShuo
* @Date: 2025/03/28/09:50
* @Version 1.0
* @注释:
*/
@Repository
public class TallyBookDAO {
@Resource
private TallyBookMapper tallyBookMapper;
public Long insertSelective(TallyBookDO tallyBookDO) {
tallyBookMapper.insertSelective(tallyBookDO);
return tallyBookDO.getId();
}
public Long updateByPrimaryKeySelective(TallyBookDO tallyBookDO) {
tallyBookMapper.updateByPrimaryKeySelective(tallyBookDO);
return tallyBookDO.getId();
}
public List<TallyBookDO> getTallyBookListByShopIdAndYear(Long shopId,Integer year) {
Example example = new Example(TallyBookDO.class);
example.createCriteria().andEqualTo("shopId",shopId).andEqualTo("year",year);
return tallyBookMapper.selectByExample(example);
}
}

View File

@@ -0,0 +1,13 @@
package com.cool.store.mapper;
import com.cool.store.entity.TallyBookDO;
import tk.mybatis.mapper.common.Mapper;
/**
* @Author: WangShuo
* @Date: 2025/03/28/09:45
* @Version 1.0
* @注释:
*/
public interface TallyBookMapper extends Mapper<TallyBookDO> {
}

View File

@@ -28,6 +28,8 @@
<result column="district" jdbcType="VARCHAR" property="district" />
<result column="township" jdbcType="VARCHAR" property="township" />
<result column="storage_status" jdbcType="TINYINT" property="storageStatus" />
<result column="opportunity_point_code" jdbcType="VARCHAR" property="opportunityPointCode" />
<result column="opportunity_point_name" jdbcType="VARCHAR" property="opportunityPointName" />
</resultMap>
<sql id="allColumn">

View File

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!--mybatis-3-mapper.dtd:约束文件的名称限制和检查在当前文件中出现的标签和属性符合mybatis的要求-->
<!--namespace命名空间要有唯一的值要求使用dao接口的权限定名称一个dao接口对应一个mappernamespace指明对应哪个dao接口-->
<mapper namespace="com.cool.store.mapper.TallyBookMapper">
<!-- 所有的数据库操作都要写在mapper标签中可以使用特定的标签表示数据库中的特定操作 -->
<resultMap id="BaseResultMap" type="com.cool.store.entity.TallyBookDO">
<!-- 主键字段 -->
<id property="id" column="id" jdbcType="BIGINT" />
<!-- 普通字段 -->
<result property="partnerId" column="partner_id" jdbcType="VARCHAR" />
<result property="shopId" column="shop_id" jdbcType="BIGINT" />
<result property="year" column="year" jdbcType="INTEGER" />
<result property="month" column="month" jdbcType="INTEGER" />
<result property="employeeSalary" column="employee_salary" jdbcType="DECIMAL" />
<result property="administrativeExpenses" column="administrative_expenses" jdbcType="DECIMAL" />
<result property="travelExpense" column="travel_expense" jdbcType="DECIMAL" />
<result property="promotionExpense" column="promotion_expense" jdbcType="DECIMAL" />
<result property="utilities" column="utilities" jdbcType="DECIMAL" />
<result property="socialInsurancePremium" column="social_insurance_premium" jdbcType="DECIMAL" />
<result property="staffDormitoryFee" column="staff_dormitory_fee" jdbcType="DECIMAL" />
<result property="consumablesCost" column="consumables_cost" jdbcType="DECIMAL" />
<result property="totalCost" column="total_cost" jdbcType="DECIMAL" />
<result property="createTime" column="create_time" jdbcType="TIMESTAMP" />
<result property="createUser" column="create_user" jdbcType="VARCHAR" />
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP" />
<result property="updateUser" column="update_user" jdbcType="VARCHAR" />
<result property="status" column="status" jdbcType="TINYINT"/>
</resultMap>
</mapper>

View File

@@ -0,0 +1,90 @@
package com.cool.store.dto;
import com.cool.store.entity.TallyBookDO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.math.BigDecimal;
import java.util.Date;
@Data
public class TallyBookDTO {
private Long id;
@ApiModelProperty(value = "加盟商ID")
@NotNull(message = "加盟商ID不能为空")
@Size(max = 64, message = "加盟商ID长度不能超过64个字符")
private String partnerId;
@ApiModelProperty(value = "店铺ID")
@NotNull(message = "店铺ID不能为空")
private Long shopId;
@ApiModelProperty(value = "")
@NotNull(message = "年不能为空")
private Integer year;
@ApiModelProperty(value = "")
@NotNull(message = "月不能为空")
private Integer month;
@ApiModelProperty(value = "员工工资")
@NotNull(message = "员工工资不能为空")
private BigDecimal employeeSalary;
@ApiModelProperty(value = "办公费")
@NotNull(message = "办公费不能为空")
private BigDecimal administrativeExpenses;
@ApiModelProperty(value = "差旅费")
@NotNull(message = "差旅费不能为空")
private BigDecimal travelExpense;
@ApiModelProperty(value = "促销费")
@NotNull(message = "促销费不能为空")
private BigDecimal promotionExpense;
@ApiModelProperty(value = "水电费")
@NotNull(message = "水电费不能为空")
private BigDecimal utilities;
@ApiModelProperty(value = "社会保险费")
@NotNull(message = "社会保险费不能为空")
private BigDecimal socialInsurancePremium;
@ApiModelProperty(value = "员工宿舍费")
@NotNull(message = "员工宿舍费不能为空")
private BigDecimal staffDormitoryFee;
@ApiModelProperty(value = "低值易耗品摊销")
@NotNull(message = "低值易耗品摊销不能为空")
private BigDecimal consumablesCost;
@ApiModelProperty(value = "成本合计")
@NotNull(message = "成本合计不能为空")
private BigDecimal totalCost;
public TallyBookDO toTallyBookDO() {
TallyBookDO tallyBookDO = new TallyBookDO();
tallyBookDO.setPartnerId(partnerId);
tallyBookDO.setShopId(shopId);
tallyBookDO.setYear(year);
tallyBookDO.setMonth(month);
tallyBookDO.setEmployeeSalary(employeeSalary);
tallyBookDO.setAdministrativeExpenses(administrativeExpenses);
tallyBookDO.setTravelExpense(travelExpense);
tallyBookDO.setPromotionExpense(promotionExpense);
tallyBookDO.setUtilities(utilities);
tallyBookDO.setSocialInsurancePremium(socialInsurancePremium);
tallyBookDO.setStaffDormitoryFee(staffDormitoryFee);
tallyBookDO.setConsumablesCost(consumablesCost);
tallyBookDO.setTotalCost(totalCost);
tallyBookDO.setCreateTime(new Date());
tallyBookDO.setUpdateTime(new Date());
return tallyBookDO;
}
}

View File

@@ -154,5 +154,10 @@ public class PointInfoDO {
@Column(name = "storage_status")
private Integer storageStatus;
@Column(name = "opportunity_point_code")
private String opportunityPointCode;
@Column(name = "opportunity_point_name")
private String opportunityPointName;
}

View File

@@ -0,0 +1,72 @@
package com.cool.store.entity;
import lombok.Data;
import javax.persistence.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Date;
@Entity
@Table(name = "xfsg_tally_book")
@Data
public class TallyBookDO {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "partner_id")
private String partnerId;
@Column(name = "shop_id")
private Long shopId;
@Column(name = "`year`")
private Integer year;
@Column(name = "`month`")
private Integer month;
@Column(name = "employee_salary")
private BigDecimal employeeSalary;
@Column(name = "administrative_expenses", precision = 10, scale = 2)
private BigDecimal administrativeExpenses;
@Column(name = "travel_expense", precision = 10, scale = 2)
private BigDecimal travelExpense;
@Column(name = "promotion_expense", precision = 10, scale = 2)
private BigDecimal promotionExpense;
@Column(name = "utilities", precision = 10, scale = 2)
private BigDecimal utilities;
@Column(name = "social_insurance_premium", precision = 10, scale = 2)
private BigDecimal socialInsurancePremium;
@Column(name = "staff_dormitory_fee", precision = 10, scale = 2)
private BigDecimal staffDormitoryFee;
@Column(name = "consumables_cost", precision = 10, scale = 2)
private BigDecimal consumablesCost;
@Column(name = "total_cost", precision = 10, scale = 2)
private BigDecimal totalCost;
@Column(name = "create_time")
private Date createTime;
@Column(name = "create_user", length = 255)
private String createUser;
@Column(name = "update_time")
private Date updateTime;
@Column(name = "update_user", length = 255)
private String updateUser;
@Column(name = "status")
private Integer status;
}

View File

@@ -8,6 +8,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import javax.persistence.Column;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
@@ -85,6 +86,12 @@ public class MiniAddPointRequest {
@ApiModelProperty("街道")
private String township;
@ApiModelProperty("机会点编号")
private String opportunityPointCode;
@ApiModelProperty("机会点名称")
private String opportunityPointName;
public static PointDetailInfoDO convertDO(MiniAddPointRequest request) {
PointDetailInfoDO result = new PointDetailInfoDO();

View File

@@ -0,0 +1,89 @@
package com.cool.store.request;
import com.cool.store.entity.TallyBookDO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.math.BigDecimal;
import java.util.Date;
@Data
public class TallyBookRequest {
@ApiModelProperty(value = "主键id修改时候传")
private Long id;
@ApiModelProperty(value = "加盟商ID")
private String partnerId;
@ApiModelProperty(value = "店铺ID", required = true)
@NotNull(message = "店铺ID不能为空")
private Long shopId;
@ApiModelProperty(value = "", required = true)
@NotNull(message = "年不能为空")
private Integer year;
@ApiModelProperty(value = "", required = true)
@NotNull(message = "月不能为空")
private Integer month;
@ApiModelProperty(value = "员工工资", required = true)
@NotNull(message = "员工工资不能为空")
private BigDecimal employeeSalary;
@ApiModelProperty(value = "办公费", required = true)
@NotNull(message = "办公费不能为空")
private BigDecimal administrativeExpenses;
@ApiModelProperty(value = "差旅费", required = true)
@NotNull(message = "差旅费不能为空")
private BigDecimal travelExpense;
@ApiModelProperty(value = "促销费", required = true)
@NotNull(message = "促销费不能为空")
private BigDecimal promotionExpense;
@ApiModelProperty(value = "水电费", required = true)
@NotNull(message = "水电费不能为空")
private BigDecimal utilities;
@ApiModelProperty(value = "社会保险费", required = true)
@NotNull(message = "社会保险费不能为空")
private BigDecimal socialInsurancePremium;
@ApiModelProperty(value = "员工宿舍费", required = true)
@NotNull(message = "员工宿舍费不能为空")
private BigDecimal staffDormitoryFee;
@ApiModelProperty(value = "低值易耗品摊销", required = true)
@NotNull(message = "低值易耗品摊销不能为空")
private BigDecimal consumablesCost;
@ApiModelProperty(value = "成本合计", required = true)
@NotNull(message = "成本合计不能为空")
private BigDecimal totalCost;
public TallyBookDO toTallyBookDO() {
TallyBookDO tallyBookDO = new TallyBookDO();
tallyBookDO.setPartnerId(partnerId);
tallyBookDO.setShopId(shopId);
tallyBookDO.setYear(year);
tallyBookDO.setMonth(month);
tallyBookDO.setEmployeeSalary(employeeSalary);
tallyBookDO.setAdministrativeExpenses(administrativeExpenses);
tallyBookDO.setTravelExpense(travelExpense);
tallyBookDO.setPromotionExpense(promotionExpense);
tallyBookDO.setUtilities(utilities);
tallyBookDO.setSocialInsurancePremium(socialInsurancePremium);
tallyBookDO.setStaffDormitoryFee(staffDormitoryFee);
tallyBookDO.setConsumablesCost(consumablesCost);
tallyBookDO.setTotalCost(totalCost);
tallyBookDO.setCreateTime(new Date());
tallyBookDO.setUpdateTime(new Date());
return tallyBookDO;
}
}

View File

@@ -0,0 +1,23 @@
package com.cool.store.service;
import com.cool.store.dto.TallyBookDTO;
import com.cool.store.entity.TallyBookDO;
import com.cool.store.request.TallyBookRequest;
import java.util.Date;
import java.util.List;
/**
* @Author: WangShuo
* @Date: 2025/03/28/09:59
* @Version 1.0
* @注释:
*/
public interface TallyBookService {
Long insertOrUpdateSelective(TallyBookRequest request, String userId);
List<TallyBookDTO> getTallyBookListByShopIdAndYear(Long shopId, Integer year);
public TallyBookDO initData(Date date, Long shopId, String partnerId);
}

View File

@@ -0,0 +1,93 @@
package com.cool.store.service.impl;
import com.cool.store.dao.TallyBookDAO;
import com.cool.store.dto.TallyBookDTO;
import com.cool.store.entity.TallyBookDO;
import com.cool.store.enums.ErrorCodeEnum;
import com.cool.store.enums.TallyBookStatusEnum;
import com.cool.store.exception.ServiceException;
import com.cool.store.request.TallyBookRequest;
import com.cool.store.service.TallyBookService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Author: WangShuo
* @Date: 2025/03/28/09:59
* @Version 1.0
* @注释:
*/
@Service
public class TallyBookServiceImpl implements TallyBookService {
@Resource
private TallyBookDAO tallyBookDAO;
@Override
public Long insertOrUpdateSelective(TallyBookRequest request, String partnerId) {
TallyBookDO tallyBookDO = request.toTallyBookDO();
if (request.getId()==null){
tallyBookDO.setCreateUser(partnerId);
tallyBookDO.setPartnerId(partnerId);
tallyBookDO.setStatus(TallyBookStatusEnum.IS_SUBMIT.getCode());
return tallyBookDAO.insertSelective(tallyBookDO);
}else{
tallyBookDO.setUpdateUser(partnerId);
return tallyBookDAO.updateByPrimaryKeySelective(tallyBookDO);
}
}
@Override
public List<TallyBookDTO> getTallyBookListByShopIdAndYear(Long shopId, Integer year) {
List<TallyBookDO> list = tallyBookDAO.getTallyBookListByShopIdAndYear(shopId,year);
if (CollectionUtils.isEmpty(list)){
return null;
}
List<TallyBookDO> sortList = list.stream().sorted(Comparator.comparing(TallyBookDO::getMonth)).collect(Collectors.toList());
List<TallyBookDTO> result= new ArrayList<>();
for(TallyBookDO tallyBookDO : sortList){
TallyBookDTO tallyBookDTO = new TallyBookDTO();
BeanUtils.copyProperties(tallyBookDO,tallyBookDTO);
result.add(tallyBookDTO);
}
return result;
}
public TallyBookDO initData(Date date,Long shopId, String partnerId){
LocalDate localDate = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
// 获取年份
int year = localDate.getYear();
// 获取月份
int month = localDate.getMonthValue();
List<TallyBookDO> list = tallyBookDAO.getTallyBookListByShopIdAndYear(shopId,year);
if(CollectionUtils.isEmpty(list)){
TallyBookDO tallyBookDO = new TallyBookDO();
tallyBookDO.setShopId(shopId);
tallyBookDO.setPartnerId(partnerId);
tallyBookDO.setYear(year);
tallyBookDO.setMonth(month);
tallyBookDO.setCreateTime(new Date());
tallyBookDO.setStatus(TallyBookStatusEnum.NOT_SUBMIT.getCode());
return tallyBookDO;
}
List<Integer> monthList = list.stream().map(TallyBookDO::getMonth).collect(Collectors.toList());
if (!monthList.contains(month)){
TallyBookDO tallyBookDO = new TallyBookDO();
tallyBookDO.setShopId(shopId);
tallyBookDO.setPartnerId(partnerId);
tallyBookDO.setYear(year);
tallyBookDO.setMonth(month);
tallyBookDO.setCreateTime(new Date());
tallyBookDO.setStatus(TallyBookStatusEnum.NOT_SUBMIT.getCode());
return tallyBookDO;
}
return null;
}
}

View File

@@ -301,8 +301,22 @@ public class XxlJobHandler {
}
/**
* @Auther: wangshuo
* @Date: 2025/3/28
* @description:每个月为可以生成记账的门店生成初始化数据
*/
@XxlJob("initTallyBook")
public void initTallyBook() {
log.info("------start initTallyBook------");
boolean hasNext = true;
int pageNum = 1;
int pageSize = 10;
List<Long> shopIdList = new ArrayList<>();
while (hasNext) {
}
}
}