This commit is contained in:
shuo.wang
2025-04-01 15:38:13 +08:00
parent 00a57cc6e6
commit 4b59c1659e
23 changed files with 340 additions and 164 deletions

View File

@@ -236,6 +236,7 @@ public enum ErrorCodeEnum {
UPDATE_INVESTMENT_MANAGER_FAIL(131005,"当前用户已经为该门店招商经理",null), UPDATE_INVESTMENT_MANAGER_FAIL(131005,"当前用户已经为该门店招商经理",null),
CONFIRM_THE_APPROVER(131006,"您提交的铺位暂时找不到选址审批人,请联系系统管理员配置选址审批权限后再提交铺位审批",null), CONFIRM_THE_APPROVER(131006,"您提交的铺位暂时找不到选址审批人,请联系系统管理员配置选址审批权限后再提交铺位审批",null),
TALLY_BOOK_NOT_EXIST(180001, "记账本数据不存在", null)
; ;

View File

@@ -32,5 +32,12 @@ public class TallyBookDAO {
return tallyBookMapper.selectByExample(example); return tallyBookMapper.selectByExample(example);
} }
public TallyBookDO getById(Long id){
if(id == null){
return null;
}
return tallyBookMapper.selectByPrimaryKey(id);
}
} }

View File

@@ -0,0 +1,40 @@
package com.cool.store.dao;
import com.alibaba.excel.util.CollectionUtils;
import com.cool.store.entity.TallyBookDetailDO;
import com.cool.store.mapper.TallyBookDetailMapper;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.entity.Example;
import javax.annotation.Resource;
import java.util.List;
/**
* @Author: WangShuo
* @Date: 2025/04/01/13:38
* @Version 1.0
* @注释:
*/
@Repository
public class TallyBookDetailDAO {
@Resource
private TallyBookDetailMapper tallyBookDetailMapper;
public Integer batchInsert(List<TallyBookDetailDO> tallyBookDetailDOList) {
if (CollectionUtils.isEmpty(tallyBookDetailDOList)){
return null;
}
return tallyBookDetailMapper.batchInsert(tallyBookDetailDOList);
}
public Integer batchDeleteByTallyBookId(Long tallyBookId){
Example example = new Example(TallyBookDetailDO.class);
example.createCriteria().andEqualTo("tallyBookId",tallyBookId);
return tallyBookDetailMapper.deleteByExample(example);
}
public List<TallyBookDetailDO> getTallyBookDetailListByTallyBookId(Long tallyBookId){
Example example = new Example(TallyBookDetailDO.class);
example.createCriteria().andEqualTo("tallyBookId",tallyBookId);
return tallyBookDetailMapper.selectByExample(example);
}
}

View File

@@ -0,0 +1,18 @@
package com.cool.store.mapper;
import com.cool.store.entity.TallyBookDetailDO;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
/**
* @Author: WangShuo
* @Date: 2025/04/01/13:36
* @Version 1.0
* @注释:
*/
public interface TallyBookDetailMapper extends Mapper<TallyBookDetailDO> {
Integer batchInsert(@Param("list") List<TallyBookDetailDO> tallyBookDetailDOList);
}

View File

@@ -31,6 +31,9 @@
<result column="opportunity_point_code" jdbcType="VARCHAR" property="opportunityPointCode"/> <result column="opportunity_point_code" jdbcType="VARCHAR" property="opportunityPointCode"/>
<result column="opportunity_point_name" jdbcType="VARCHAR" property="opportunityPointName"/> <result column="opportunity_point_name" jdbcType="VARCHAR" property="opportunityPointName"/>
<result column="open_shop_name" jdbcType="VARCHAR" property="openShopName"/> <result column="open_shop_name" jdbcType="VARCHAR" property="openShopName"/>
<result column="province_code" jdbcType="VARCHAR" property="provinceCode"/>
<result column="city_code" jdbcType="VARCHAR" property="cityCode"/>
<result column="district_code" jdbcType="VARCHAR" property="districtCode"/>
</resultMap> </resultMap>
<sql id="allColumn"> <sql id="allColumn">
@@ -38,7 +41,8 @@
development_manager, operate_user_id, development_manager, operate_user_id,
development_time, point_status, point_score, select_status, submit_audit_count, point_source, deleted, development_time, point_status, point_score, select_status, submit_audit_count, point_source, deleted,
create_time, update_time, create_time, update_time,
province, city, district, township, opportunity_point_code, opportunity_point_name,open_shop_name province, city, district, township, opportunity_point_code, opportunity_point_name,open_shop_name,
province_code, city_code, district_code
</sql> </sql>
<select id="getMyPointData" resultType="com.cool.store.vo.point.PointHomePageDataVO"> <select id="getMyPointData" resultType="com.cool.store.vo.point.PointHomePageDataVO">
@@ -107,6 +111,9 @@
#{regionId} #{regionId}
</foreach> </foreach>
</if> </if>
<if test="request.areaCode!=null and request.areaCode!=''">
and (province_code = #{request.areaCode} || city_code = #{request.areaCode} || county_code = #{request.areaCode})
</if>
order by id desc order by id desc
</select> </select>
<select id="getSelectedShopNum" resultType="com.cool.store.dto.point.LineCountDTO"> <select id="getSelectedShopNum" resultType="com.cool.store.dto.point.LineCountDTO">
@@ -205,6 +212,9 @@
<if test="request.storageStatus != null "> <if test="request.storageStatus != null ">
and storage_status = #{request.storageStatus} and storage_status = #{request.storageStatus}
</if> </if>
<if test="request.areaCode!=null and request.areaCode!=''">
and (province_code = #{request.areaCode} || city_code = #{request.areaCode} || county_code = #{request.areaCode})
</if>
order by id desc order by id desc
</select> </select>
<select id="getDataByShopIdAndLineId" resultType="com.cool.store.entity.PointInfoDO"> <select id="getDataByShopIdAndLineId" resultType="com.cool.store.entity.PointInfoDO">

View File

@@ -142,6 +142,10 @@
<if test="request.status != null and request.status == 3"> <if test="request.status != null and request.status == 3">
and pr.status in (5, 6) and pr.status in (5, 6)
</if> </if>
<if test="request.areaCode!=null and request.areaCode 1=''">
and (p.province_code = #{request.areaCode} or p.city_code = #{request.areaCode} or p.area_code = #{request.areaCode})
</if>
</select> </select>
<update id="updateStatusByPointIdAndLineId"> <update id="updateStatusByPointIdAndLineId">

View File

@@ -0,0 +1,25 @@
<?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.TallyBookDetailMapper">
<resultMap id="BaseResultMap" type="com.cool.store.entity.TallyBookDetailDO">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="tally_book_id" property="tallyBookId" jdbcType="BIGINT"/>
<result column="field_name" property="fieldName" jdbcType="VARCHAR"/>
<result column="field_value" property="fieldValue" jdbcType="DECIMAL"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
</resultMap>
<insert id="batchInsert">
insert into xfsg_tally_book_detail (tally_book_id, field_name, field_value, create_time, update_time)
values
<foreach collection="tallyBookDetailDOList" item="item" separator=",">
(#{item.tallyBookId,jdbcType=BIGINT},
#{item.fieldName,jdbcType=VARCHAR},
#{item.fieldValue,jdbcType=DECIMAL},
#{item.createTime,jdbcType=TIMESTAMP},
#{item.updateTime,jdbcType=TIMESTAMP})
</foreach>
</insert>
</mapper>

View File

@@ -12,19 +12,12 @@
<result property="shopId" column="shop_id" jdbcType="BIGINT" /> <result property="shopId" column="shop_id" jdbcType="BIGINT" />
<result property="year" column="year" jdbcType="INTEGER" /> <result property="year" column="year" jdbcType="INTEGER" />
<result property="month" column="month" 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="createTime" column="create_time" jdbcType="TIMESTAMP" />
<result property="createUser" column="create_user" jdbcType="VARCHAR" /> <result property="createUser" column="create_user" jdbcType="VARCHAR" />
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP" /> <result property="updateTime" column="update_time" jdbcType="TIMESTAMP" />
<result property="updateUser" column="update_user" jdbcType="VARCHAR" /> <result property="updateUser" column="update_user" jdbcType="VARCHAR" />
<result property="status" column="status" jdbcType="TINYINT"/> <result property="status" column="status" jdbcType="TINYINT"/>
<result property="total" column="total" jdbcType="DECIMAL"/>
<result property="operatorName" column="operator_name" jdbcType="VARCHAR"/>
</resultMap> </resultMap>
</mapper> </mapper>

View File

@@ -1,13 +1,17 @@
package com.cool.store.dto; package com.cool.store.dto;
import com.alibaba.excel.util.CollectionUtils;
import com.cool.store.entity.TallyBookDO; import com.cool.store.entity.TallyBookDO;
import com.cool.store.entity.TallyBookDetailDO;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size; import javax.validation.constraints.Size;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List;
@Data @Data
public class TallyBookDTO { public class TallyBookDTO {
@@ -31,60 +35,13 @@ public class TallyBookDTO {
@NotNull(message = "月不能为空") @NotNull(message = "月不能为空")
private Integer month; 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 = "成本合计") @ApiModelProperty(value = "成本合计")
@NotNull(message = "成本合计不能为空") private BigDecimal total;
private BigDecimal totalCost;
public TallyBookDO toTallyBookDO() { @ApiModelProperty(value = "提交时间")
TallyBookDO tallyBookDO = new TallyBookDO(); private Date updateTime;
tallyBookDO.setPartnerId(partnerId);
tallyBookDO.setShopId(shopId); @ApiModelProperty("操作人")
tallyBookDO.setYear(year); private String operatorName;
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,14 @@
package com.cool.store.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class TallyBookDetailDTO {
@ApiModelProperty(value = "字段名称")
private String fieldName;
@ApiModelProperty(value = "字段值")
private BigDecimal fieldValue;
}

View File

@@ -163,4 +163,13 @@ public class PointInfoDO {
@Column(name = "open_shop_name") @Column(name = "open_shop_name")
private String openShopName; private String openShopName;
@Column(name = "province_code")
private String provinceCode;
@Column(name = "city_code")
private String cityCode;
@Column(name = "district_code")
private String districtCode;
} }

View File

@@ -28,45 +28,24 @@ public class TallyBookDO {
@Column(name = "`month`") @Column(name = "`month`")
private Integer 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") @Column(name = "create_time")
private Date createTime; private Date createTime;
@Column(name = "create_user", length = 255) @Column(name = "create_user")
private String createUser; private String createUser;
@Column(name = "update_time") @Column(name = "update_time")
private Date updateTime; private Date updateTime;
@Column(name = "update_user", length = 255) @Column(name = "update_user")
private String updateUser; private String updateUser;
@Column(name = "status") @Column(name = "status")
private Integer status; private Integer status;
@Column(name = "total")
private BigDecimal total;
@Column(name = "operator_name")
private String operatorName;
} }

View File

@@ -0,0 +1,29 @@
package com.cool.store.entity;
import lombok.Data;
import javax.persistence.Column;
import java.math.BigDecimal;
import java.util.Date;
/**
* @Author: WangShuo
* @Date: 2025/04/01/13:32
* @Version 1.0
* @注释:
*/
@Data
public class TallyBookDetailDO {
@Column(name = "id")
private Long id;
@Column(name = "tally_book_id")
private Long tallyBookId;
@Column(name = "field_name")
private String fieldName;
@Column(name = "field_value")
private BigDecimal fieldValue;
@Column(name = "create_time")
private Date createTime;
@Column(name = "update_time")
private Date updateTime;
}

View File

@@ -45,4 +45,7 @@ public class AllPointPageRequest extends PageBasicInfo {
@ApiModelProperty(value = "是否入库1已入库 2暂未入库") @ApiModelProperty(value = "是否入库1已入库 2暂未入库")
private Integer storageStatus; private Integer storageStatus;
@ApiModelProperty("省市区编码,传最后一级")
private String areaCode;
} }

View File

@@ -86,14 +86,20 @@ public class MiniAddPointRequest {
@ApiModelProperty("街道") @ApiModelProperty("街道")
private String township; private String township;
@NotBlank
@ApiModelProperty("机会点编号") @ApiModelProperty("机会点编号")
private String opportunityPointCode; private String opportunityPointCode;
@NotBlank
@ApiModelProperty("机会点名称") @ApiModelProperty("机会点名称")
private String opportunityPointName; private String opportunityPointName;
@ApiModelProperty("省编码")
private String provinceCode;
@ApiModelProperty("市编码")
private String cityCode;
@ApiModelProperty("区/县编码")
private String districtCode;
public static PointDetailInfoDO convertDO(MiniAddPointRequest request) { public static PointDetailInfoDO convertDO(MiniAddPointRequest request) {
PointDetailInfoDO result = new PointDetailInfoDO(); PointDetailInfoDO result = new PointDetailInfoDO();
@@ -108,6 +114,11 @@ public class MiniAddPointRequest {
public static PointInfoDO convertPointDO(MiniAddPointRequest request) { public static PointInfoDO convertPointDO(MiniAddPointRequest request) {
PointInfoDO result = new PointInfoDO(); PointInfoDO result = new PointInfoDO();
result.setOpportunityPointName(request.getOpportunityPointName());
result.setOpportunityPointCode(request.getOpportunityPointCode());
result.setProvinceCode(request.getProvinceCode());
result.setCityCode(request.getCityCode());
result.setDistrictCode(request.getDistrictCode());
result.setPointName(request.getPointName()); result.setPointName(request.getPointName());
result.setRegionId(request.getRegionId()); result.setRegionId(request.getRegionId());
result.setPointArea(request.getPointArea()); result.setPointArea(request.getPointArea());

View File

@@ -32,4 +32,7 @@ public class MiniPointPageRequest extends PageBasicInfo {
private Long lineId; private Long lineId;
private String partnerId; private String partnerId;
@ApiModelProperty("省市区编码,传最后一级")
private String areaCode;
} }

View File

@@ -54,6 +54,9 @@ public class PointPageRequest extends PageBasicInfo {
@ApiModelProperty(value = "铺位状态列表", hidden = true) @ApiModelProperty(value = "铺位状态列表", hidden = true)
private List<Integer> pointStatusList; private List<Integer> pointStatusList;
@ApiModelProperty("省市区编码,传最后一级")
private String areaCode;
public List<Integer> getPointStatusList() { public List<Integer> getPointStatusList() {
List<Integer> pointStatusList = new ArrayList<>(); List<Integer> pointStatusList = new ArrayList<>();
if (pointStatus != null) { if (pointStatus != null) {

View File

@@ -1,18 +1,25 @@
package com.cool.store.request; package com.cool.store.request;
import com.cool.store.dto.TallyBookDetailDTO;
import com.cool.store.entity.TallyBookDO; import com.cool.store.entity.TallyBookDO;
import com.cool.store.entity.TallyBookDetailDO;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import org.apache.commons.collections4.CollectionUtils;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size; import javax.validation.constraints.Size;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@Data @Data
public class TallyBookRequest { public class TallyBookRequest {
@ApiModelProperty(value = "主键id修改时候传") @ApiModelProperty(value = "主键id修改时候传")
@NotNull(message = "主键id不能为空")
private Long id; private Long id;
@ApiModelProperty(value = "加盟商ID") @ApiModelProperty(value = "加盟商ID")
@@ -30,58 +37,40 @@ public class TallyBookRequest {
@NotNull(message = "月不能为空") @NotNull(message = "月不能为空")
private Integer month; private Integer month;
@ApiModelProperty(value = "员工工资", required = true) @ApiModelProperty(value = "成本总计", required = true)
@NotNull(message = "员工工资不能为空") @NotNull(message = "成本总计")
private BigDecimal employeeSalary; private BigDecimal total;
@ApiModelProperty(value = "办公费", required = true) @ApiModelProperty(value = "明细")
@NotNull(message = "办公费不能为空") @NotBlank(message = "明细不能为空")
private BigDecimal administrativeExpenses; private List<TallyBookDetailDTO> tallyBookDetailDTOList;
@ApiModelProperty(value = "差旅费", required = true) @ApiModelProperty(value = "操作人",hidden = true)
@NotNull(message = "差旅费不能为空") private String operatorName;
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() { public TallyBookDO toTallyBookDO() {
TallyBookDO tallyBookDO = new TallyBookDO(); TallyBookDO tallyBookDO = new TallyBookDO();
tallyBookDO.setPartnerId(partnerId); tallyBookDO.setPartnerId(partnerId);
tallyBookDO.setShopId(shopId); tallyBookDO.setShopId(shopId);
tallyBookDO.setTotal(total);
tallyBookDO.setYear(year); tallyBookDO.setYear(year);
tallyBookDO.setMonth(month); 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);
return tallyBookDO; return tallyBookDO;
} }
public List<TallyBookDetailDO> toTallyBookDetailDOList(Long tallyBookId) {
if (tallyBookId==null || CollectionUtils.isEmpty(tallyBookDetailDTOList))
{
return null;
}
return tallyBookDetailDTOList.stream().map(tallyBookDetailDTO -> {
TallyBookDetailDO tallyBookDetailDO = new TallyBookDetailDO();
tallyBookDetailDO.setTallyBookId(tallyBookId);
tallyBookDetailDO.setFieldName(tallyBookDetailDTO.getFieldName());
tallyBookDetailDO.setFieldValue(tallyBookDetailDTO.getFieldValue());
tallyBookDetailDO.setCreateTime(new Date());
return tallyBookDetailDO;
}).collect(Collectors.toList());
}
} }

View File

@@ -0,0 +1,42 @@
package com.cool.store.response;
import com.alibaba.excel.util.CollectionUtils;
import com.cool.store.dto.TallyBookDetailDTO;
import com.cool.store.entity.TallyBookDetailDO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
import java.util.stream.Collectors;
/**
* @Author: WangShuo
* @Date: 2025/04/01/14:07
* @Version 1.0
* @注释:
*/
@Data
public class TallyBookDetailResponse {
@ApiModelProperty(value = "明细")
private List<TallyBookDetailDTO> list;
@ApiModelProperty(value = "成本总计")
private BigDecimal total;
@ApiModelProperty(value = "")
private Integer year;
@ApiModelProperty(value = "")
private Integer month;
public List<TallyBookDetailDTO> toDTO(List<TallyBookDetailDO> list){
if (CollectionUtils.isEmpty(list)){
return null;
}
return list.stream().map(item -> {
TallyBookDetailDTO dto = new TallyBookDetailDTO();
dto.setFieldName(item.getFieldName());
dto.setFieldValue(item.getFieldValue());
return dto;
}).collect(Collectors.toList());
}
}

View File

@@ -1,8 +1,11 @@
package com.cool.store.service; package com.cool.store.service;
import com.cool.store.dto.TallyBookDTO; import com.cool.store.dto.TallyBookDTO;
import com.cool.store.dto.TallyBookDetailDTO;
import com.cool.store.entity.TallyBookDO; import com.cool.store.entity.TallyBookDO;
import com.cool.store.request.TallyBookRequest; import com.cool.store.request.TallyBookRequest;
import com.cool.store.response.TallyBookDetailResponse;
import com.cool.store.vo.PartnerUserInfoVO;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@@ -15,9 +18,11 @@ import java.util.List;
*/ */
public interface TallyBookService { public interface TallyBookService {
Long insertOrUpdateSelective(TallyBookRequest request, String userId); Long insertOrUpdateSelective(TallyBookRequest request, PartnerUserInfoVO user);
List<TallyBookDTO> getTallyBookListByShopIdAndYear(Long shopId, Integer year); List<TallyBookDTO> getTallyBookListByShopIdAndYear(Long shopId, Integer year);
Long initData( Long shopId, String partnerId); Long initData( Long shopId, String partnerId);
TallyBookDetailResponse getTallyBookDetailByTallyBookId(Long tallyBookId);
} }

View File

@@ -861,8 +861,6 @@ public class PointServiceImpl implements PointService {
pointInfo.setDevelopmentTime(new Date()); pointInfo.setDevelopmentTime(new Date());
pointInfo.setPointSource(PointSourceEnum.POINT_SOURCE_2.getCode()); pointInfo.setPointSource(PointSourceEnum.POINT_SOURCE_2.getCode());
pointInfo.setPointCode(generateCode()); pointInfo.setPointCode(generateCode());
pointInfo.setOpportunityPointName(request.getOpportunityPointName());
pointInfo.setOpportunityPointCode(request.getOpportunityPointCode());
Long pointId = pointInfoDAO.addPointInfo(pointInfo); Long pointId = pointInfoDAO.addPointInfo(pointInfo);
pointDetailInfo.setPointId(pointId); pointDetailInfo.setPointId(pointId);
pointDetailInfoDAO.addPointDetailInfo(pointDetailInfo); pointDetailInfoDAO.addPointDetailInfo(pointDetailInfo);

View File

@@ -2,19 +2,26 @@ package com.cool.store.service.impl;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.cool.store.dao.TallyBookDAO; import com.cool.store.dao.TallyBookDAO;
import com.cool.store.dao.TallyBookDetailDAO;
import com.cool.store.dto.TallyBookDTO; import com.cool.store.dto.TallyBookDTO;
import com.cool.store.dto.TallyBookDetailDTO;
import com.cool.store.entity.TallyBookDO; import com.cool.store.entity.TallyBookDO;
import com.cool.store.entity.TallyBookDetailDO;
import com.cool.store.enums.ErrorCodeEnum; import com.cool.store.enums.ErrorCodeEnum;
import com.cool.store.enums.TallyBookStatusEnum; import com.cool.store.enums.TallyBookStatusEnum;
import com.cool.store.exception.ServiceException; import com.cool.store.exception.ServiceException;
import com.cool.store.request.TallyBookRequest; import com.cool.store.request.TallyBookRequest;
import com.cool.store.response.TallyBookDetailResponse;
import com.cool.store.service.TallyBookService; import com.cool.store.service.TallyBookService;
import com.cool.store.vo.PartnerUserInfoVO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId; import java.time.ZoneId;
import java.util.*; import java.util.*;
@@ -33,46 +40,49 @@ public class TallyBookServiceImpl implements TallyBookService {
@Resource @Resource
private TallyBookDAO tallyBookDAO; private TallyBookDAO tallyBookDAO;
@Resource
private TallyBookDetailDAO tallyBookDetailDAO;
@Override @Override
public Long insertOrUpdateSelective(TallyBookRequest request, String partnerId) { @Transactional(rollbackFor = Exception.class)
TallyBookDO tallyBookDO = request.toTallyBookDO(); public Long insertOrUpdateSelective(TallyBookRequest request, PartnerUserInfoVO user) {
tallyBookDO.setStatus(TallyBookStatusEnum.IS_SUBMIT.getCode()); TallyBookDO tallyBookDO = new TallyBookDO();
if (request.getId()==null){ tallyBookDO.setId(request.getId());
tallyBookDO.setCreateUser(partnerId); tallyBookDO.setStatus(TallyBookStatusEnum.IS_SUBMIT.getCode());;
tallyBookDO.setCreateTime(new Date()); tallyBookDO.setUpdateUser(user.getPartnerId());
tallyBookDO.setPartnerId(partnerId); tallyBookDO.setUpdateTime(new Date());tallyBookDAO.updateByPrimaryKeySelective(tallyBookDO);
return tallyBookDAO.insertSelective(tallyBookDO); tallyBookDO.setOperatorName(request.getOperatorName());
}else{ tallyBookDetailDAO.batchDeleteByTallyBookId(request.getId());
tallyBookDO.setUpdateUser(partnerId); List<TallyBookDetailDO> tallyBookDetailDOList = request.toTallyBookDetailDOList(request.getId());
tallyBookDO.setUpdateTime(new Date()); tallyBookDetailDAO.batchInsert(tallyBookDetailDOList);
return tallyBookDAO.updateByPrimaryKeySelective(tallyBookDO); return request.getId();
}
} }
@Override @Override
public List<TallyBookDTO> getTallyBookListByShopIdAndYear(Long shopId, Integer year) { public List<TallyBookDTO> getTallyBookListByShopIdAndYear(Long shopId, Integer year) {
List<TallyBookDO> list = tallyBookDAO.getTallyBookListByShopIdAndYear(shopId,year); List<TallyBookDO> list = tallyBookDAO.getTallyBookListByShopIdAndYear(shopId, year);
if (CollectionUtils.isEmpty(list)){ if (CollectionUtils.isEmpty(list)) {
return null; return null;
} }
List<TallyBookDO> sortList = list.stream().sorted(Comparator.comparing(TallyBookDO::getMonth)).collect(Collectors.toList()); List<TallyBookDO> sortList = list.stream().sorted(Comparator.comparing(TallyBookDO::getMonth)).collect(Collectors.toList());
List<TallyBookDTO> result= new ArrayList<>(); List<TallyBookDTO> result = new ArrayList<>();
for(TallyBookDO tallyBookDO : sortList){ for (TallyBookDO tallyBookDO : sortList) {
TallyBookDTO tallyBookDTO = new TallyBookDTO(); TallyBookDTO tallyBookDTO = new TallyBookDTO();
BeanUtils.copyProperties(tallyBookDO,tallyBookDTO); BeanUtils.copyProperties(tallyBookDO, tallyBookDTO);
result.add(tallyBookDTO); result.add(tallyBookDTO);
} }
return result; return result;
} }
@Override @Override
public Long initData(Long shopId, String partnerId){ public Long initData(Long shopId, String partnerId) {
Date date = new Date(); Date date = new Date();
LocalDate localDate = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); LocalDate localDate = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
// 获取年份 // 获取年份
int year = localDate.getYear(); int year = localDate.getYear();
// 获取月份 // 获取月份
int month = localDate.getMonthValue(); int month = localDate.getMonthValue();
List<TallyBookDO> list = tallyBookDAO.getTallyBookListByShopIdAndYear(shopId,year); List<TallyBookDO> list = tallyBookDAO.getTallyBookListByShopIdAndYear(shopId, year);
TallyBookDO tallyBookDO = new TallyBookDO(); TallyBookDO tallyBookDO = new TallyBookDO();
tallyBookDO.setShopId(shopId); tallyBookDO.setShopId(shopId);
tallyBookDO.setPartnerId(partnerId); tallyBookDO.setPartnerId(partnerId);
@@ -81,13 +91,29 @@ public class TallyBookServiceImpl implements TallyBookService {
tallyBookDO.setCreateTime(new Date()); tallyBookDO.setCreateTime(new Date());
tallyBookDO.setStatus(TallyBookStatusEnum.NOT_SUBMIT.getCode()); tallyBookDO.setStatus(TallyBookStatusEnum.NOT_SUBMIT.getCode());
log.info("initData记账本DO:{}", JSONObject.toJSONString(tallyBookDO)); log.info("initData记账本DO:{}", JSONObject.toJSONString(tallyBookDO));
if(CollectionUtils.isEmpty(list)){ if (CollectionUtils.isEmpty(list)) {
return tallyBookDAO.insertSelective(tallyBookDO); return tallyBookDAO.insertSelective(tallyBookDO);
} }
List<Integer> monthList = list.stream().map(TallyBookDO::getMonth).collect(Collectors.toList()); List<Integer> monthList = list.stream().map(TallyBookDO::getMonth).collect(Collectors.toList());
if (!monthList.contains(month)){ if (!monthList.contains(month)) {
return tallyBookDAO.insertSelective(tallyBookDO); return tallyBookDAO.insertSelective(tallyBookDO);
} }
return null; return null;
} }
@Override
public TallyBookDetailResponse getTallyBookDetailByTallyBookId(Long tallyBookId) {
TallyBookDetailResponse response = new TallyBookDetailResponse();
TallyBookDO tallyBookDO = tallyBookDAO.getById(tallyBookId);
if (tallyBookDO == null){
throw new ServiceException(ErrorCodeEnum.TALLY_BOOK_NOT_EXIST);
}
List<TallyBookDetailDO> tallyBookDetailList = tallyBookDetailDAO.getTallyBookDetailListByTallyBookId(tallyBookId);
List<TallyBookDetailDTO> dto = response.toDTO(tallyBookDetailList);
response.setTotal(tallyBookDO.getTotal());
response.setYear(tallyBookDO.getYear());
response.setMonth(tallyBookDO.getMonth());
response.setList(dto);
return response;
}
} }

View File

@@ -4,6 +4,7 @@ import com.cool.store.context.PartnerUserHolder;
import com.cool.store.dto.TallyBookDTO; import com.cool.store.dto.TallyBookDTO;
import com.cool.store.request.TallyBookRequest; import com.cool.store.request.TallyBookRequest;
import com.cool.store.response.ResponseResult; import com.cool.store.response.ResponseResult;
import com.cool.store.response.TallyBookDetailResponse;
import com.cool.store.service.TallyBookService; import com.cool.store.service.TallyBookService;
import com.cool.store.vo.PartnerUserInfoVO; import com.cool.store.vo.PartnerUserInfoVO;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
@@ -32,7 +33,8 @@ public class TallyBookController {
@ApiOperation(value = "新增或修改记账本") @ApiOperation(value = "新增或修改记账本")
public ResponseResult insertOrUpdateSelective(@RequestBody @Validated TallyBookRequest request) { public ResponseResult insertOrUpdateSelective(@RequestBody @Validated TallyBookRequest request) {
PartnerUserInfoVO user = PartnerUserHolder.getUser(); PartnerUserInfoVO user = PartnerUserHolder.getUser();
return ResponseResult.success(tallyBookService.insertOrUpdateSelective(request, user.getPartnerId())); request.setOperatorName(user.getUsername());
return ResponseResult.success(tallyBookService.insertOrUpdateSelective(request, user));
} }
@GetMapping("/getTallyBookListByShopIdAndYear") @GetMapping("/getTallyBookListByShopIdAndYear")
@@ -41,4 +43,12 @@ public class TallyBookController {
PartnerUserInfoVO user = PartnerUserHolder.getUser(); PartnerUserInfoVO user = PartnerUserHolder.getUser();
return ResponseResult.success(tallyBookService.getTallyBookListByShopIdAndYear(shopId,year)); return ResponseResult.success(tallyBookService.getTallyBookListByShopIdAndYear(shopId,year));
} }
@GetMapping("/getDetail")
@ApiOperation(value = "查询明细")
public ResponseResult<TallyBookDetailResponse> getTallyBookDetailByTallyBookId(@RequestParam("tallyBookId") Long tallyBookId) {
PartnerUserInfoVO user = PartnerUserHolder.getUser();
return ResponseResult.success(tallyBookService.getTallyBookDetailByTallyBookId(tallyBookId));
}
} }