Commit bb37bd5b authored by shiyu's avatar shiyu

数据看板

parent 8fd606a3
......@@ -6,13 +6,17 @@ import com.wwdz.ch.admin.entity.request.DataPanelRequestDto;
import com.wwdz.ch.admin.entity.vo.DataPanelVo;
import com.wwdz.ch.admin.service.AdminDashbordService;
import com.wwdz.ch.core.api.WxAppletApi;
import com.wwdz.ch.core.consts.DistributionEnum;
import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.db.bean.OrderDataStat;
import com.wwdz.ch.db.dao.ItemDao;
import com.wwdz.ch.db.dao.distribution.DistributionOrderDao;
import com.wwdz.ch.db.dao.distribution.DistributorProfitDao;
import com.wwdz.ch.db.dao.distribution.SupplierItemDao;
import com.wwdz.ch.db.dao.dts.DtsUserDao;
import com.wwdz.ch.db.dto.request.distribution.CollectionShareRecordRequestDto;
import com.wwdz.ch.db.dto.request.distribution.DistributionOrderRequestDto;
import com.wwdz.ch.db.dto.request.distribution.DistributorProfitRequestDto;
import com.wwdz.ch.db.dto.request.distribution.SupplierItemRequestDto;
import com.xxdxxs.utils.DateUtils;
import io.swagger.models.auth.In;
......@@ -26,10 +30,7 @@ import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.TimeZone;
import java.util.*;
@Service
......@@ -52,6 +53,9 @@ public class AdminDashbordServiceImpl implements AdminDashbordService {
@Autowired
DistributionOrderDao distributionOrderDao;
@Autowired
DistributorProfitDao distributorProfitDao;
@Override
public Object info() {
......@@ -89,11 +93,18 @@ public class AdminDashbordServiceImpl implements AdminDashbordService {
long count = supplierItemDao.countNewItem(supplierItemRequestDto);
dataPanelVo.setNewItemNum((int) count);
//查询藏品订单数据
DistributionOrderRequestDto collectRequestDto = new DistributionOrderRequestDto();
collectRequestDto.setType(3);
collectRequestDto.setStartCreateTime(startTime);
collectRequestDto.setEndCreateTime(endTime);
//distributionOrderDao.
DistributorProfitRequestDto collectOrderDto = new DistributorProfitRequestDto();
collectOrderDto.setType(DistributionEnum.DistributionTypeEnum.COLLECT.getCode());
collectOrderDto.setStartCreateTime(startTime);
collectOrderDto.setEndCreateTime(endTime);
OrderDataStat collectOrderDataStat = distributorProfitDao.countOrderData(collectOrderDto);
//统计分销订单数据
DistributorProfitRequestDto distirbutionOrderDto = new DistributorProfitRequestDto();
distirbutionOrderDto.setTypeList(Arrays.asList(DistributionEnum.DistributionTypeEnum.FIXED_PRICE.getCode(), DistributionEnum.DistributionTypeEnum.AUCTION.getCode()));
distirbutionOrderDto.setStartCreateTime(startTime);
distirbutionOrderDto.setEndCreateTime(endTime);
OrderDataStat distirbutionOrderDataStat = distributorProfitDao.countOrderData(distirbutionOrderDto);
} catch (Exception e) {
logger.error("查询数据看板 error:{}", e);
}
......
package com.wwdz.ch.db.bean;
import com.xxdxxs.entity.Entity;
import lombok.Data;
@Data
public class OrderDataStat implements Entity {
/**
* 订单总金额
*/
private Long totalAmount;
/**
* 订单总数
*/
private Long totalOrderNum;
/**
* 分销商的总利润
*/
private Long totalProfit;
}
package com.wwdz.ch.db.dao.distribution;
import com.wwdz.ch.db.bean.OrderDataStat;
import com.wwdz.ch.db.domain.distribution.DistributorProfit;
import com.wwdz.ch.db.dto.request.distribution.DistributorProfitRequestDto;
public interface DistributorProfitDao {
......@@ -68,4 +70,11 @@ public interface DistributorProfitDao {
* @return
*/
Long countProfit(long distributorId);
/**
* 统计订单数据
* @param dto
* @return
*/
OrderDataStat countOrderData(DistributorProfitRequestDto dto);
}
package com.wwdz.ch.db.domain.distribution;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import com.xxdxxs.entity.Entity;
import lombok.Data;
/**
* @author shiyu
* @date 2024/04/11
* @date 2024/05/14
*/
@Data
public class DistributorProfit implements Entity {
......@@ -64,6 +66,11 @@ public class DistributorProfit implements Entity {
*/
private Date createTime;
/**
* 订单类型1一口价2竞拍3藏馆订单4促销订单
*/
private Integer type;
/**
* 是否有效
*/
......@@ -88,6 +95,7 @@ public class DistributorProfit implements Entity {
sb.append(", introduceCost=").append(introduceCost);
sb.append(", profit=").append(profit);
sb.append(", createTime=").append(createTime);
sb.append(", type=").append(type);
sb.append(", isValid=").append(isValid);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
......@@ -117,6 +125,7 @@ public class DistributorProfit implements Entity {
&& (this.getIntroduceCost() == null ? other.getIntroduceCost() == null : this.getIntroduceCost().equals(other.getIntroduceCost()))
&& (this.getProfit() == null ? other.getProfit() == null : this.getProfit().equals(other.getProfit()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
&& (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType()))
&& (this.getIsValid() == null ? other.getIsValid() == null : this.getIsValid().equals(other.getIsValid()));
}
......@@ -135,6 +144,7 @@ public class DistributorProfit implements Entity {
result = prime * result + ((getIntroduceCost() == null) ? 0 : getIntroduceCost().hashCode());
result = prime * result + ((getProfit() == null) ? 0 : getProfit().hashCode());
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
result = prime * result + ((getType() == null) ? 0 : getType().hashCode());
result = prime * result + ((getIsValid() == null) ? 0 : getIsValid().hashCode());
return result;
}
......@@ -158,6 +168,7 @@ public class DistributorProfit implements Entity {
introduceCost("introduce_cost", "introduceCost", "BIGINT", false),
profit("profit", "profit", "BIGINT", false),
createTime("create_time", "createTime", "TIMESTAMP", false),
type("type", "type", "INTEGER", true),
isValid("is_valid", "isValid", "BIT", false);
/**
......
......@@ -1610,6 +1610,138 @@ public class DistributorProfitExample {
return (Criteria) this;
}
public Criteria andTypeIsNull() {
addCriterion("`type` is null");
return (Criteria) this;
}
public Criteria andTypeIsNotNull() {
addCriterion("`type` is not null");
return (Criteria) this;
}
public Criteria andTypeEqualTo(Integer value) {
addCriterion("`type` =", value, "type");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table distributor_profit
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andTypeEqualToColumn(DistributorProfit.Column column) {
addCriterion(new StringBuilder("`type` = ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andTypeNotEqualTo(Integer value) {
addCriterion("`type` <>", value, "type");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table distributor_profit
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andTypeNotEqualToColumn(DistributorProfit.Column column) {
addCriterion(new StringBuilder("`type` <> ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andTypeGreaterThan(Integer value) {
addCriterion("`type` >", value, "type");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table distributor_profit
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andTypeGreaterThanColumn(DistributorProfit.Column column) {
addCriterion(new StringBuilder("`type` > ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andTypeGreaterThanOrEqualTo(Integer value) {
addCriterion("`type` >=", value, "type");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table distributor_profit
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andTypeGreaterThanOrEqualToColumn(DistributorProfit.Column column) {
addCriterion(new StringBuilder("`type` >= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andTypeLessThan(Integer value) {
addCriterion("`type` <", value, "type");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table distributor_profit
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andTypeLessThanColumn(DistributorProfit.Column column) {
addCriterion(new StringBuilder("`type` < ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andTypeLessThanOrEqualTo(Integer value) {
addCriterion("`type` <=", value, "type");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table distributor_profit
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andTypeLessThanOrEqualToColumn(DistributorProfit.Column column) {
addCriterion(new StringBuilder("`type` <= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andTypeIn(List<Integer> values) {
addCriterion("`type` in", values, "type");
return (Criteria) this;
}
public Criteria andTypeNotIn(List<Integer> values) {
addCriterion("`type` not in", values, "type");
return (Criteria) this;
}
public Criteria andTypeBetween(Integer value1, Integer value2) {
addCriterion("`type` between", value1, value2, "type");
return (Criteria) this;
}
public Criteria andTypeNotBetween(Integer value1, Integer value2) {
addCriterion("`type` not between", value1, value2, "type");
return (Criteria) this;
}
public Criteria andIsValidIsNull() {
addCriterion("is_valid is null");
return (Criteria) this;
......
package com.wwdz.ch.db.dto.request.distribution;
import com.xxdxxs.entity.Entity;
import lombok.Data;
import java.util.Date;
import java.util.List;
@Data
public class DistributorProfitRequestDto implements Entity {
private Long id;
/**
* 分销单号
*/
private String distributionOrderId;
/**
* 分销商id
*/
private Long distributorId;
/**
* 商品id
*/
private Long itemId;
/**
* 商品数量
*/
private Integer itemNum;
/**
* 订单金额
*/
private Long amount;
/**
* 商品成本,供货价
*/
private Long itemCost;
/**
* 通道费
*/
private Long channelCost;
/**
* 介绍人佣金
*/
private Long introduceCost;
/**
* 利润
*/
private Long profit;
/**
* 创建时间
*/
private Date createTime;
private Date startCreateTime;
private Date endCreateTime;
/**
* 订单类型1一口价2竞拍3藏馆订单4促销订单
*/
private Integer type;
private List<Integer> typeList;
/**
* 是否有效
*/
private Boolean isValid;
}
package com.wwdz.ch.db.impl.distribution;
import com.wwdz.ch.db.bean.OrderDataStat;
import com.wwdz.ch.db.dao.distribution.DistributorProfitDao;
import com.wwdz.ch.db.domain.distribution.DistributorProfit;
import com.wwdz.ch.db.domain.distribution.DistributorProfitExample;
import com.wwdz.ch.db.dto.request.distribution.DistributorProfitRequestDto;
import com.wwdz.ch.db.mapper.distribution.DistributorProfitMapper;
import com.xxdxxs.db.component.JdbcHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
......@@ -70,4 +73,17 @@ public class DistributorProfitDaoImpl implements DistributorProfitDao {
Long num = distributorProfitMapper.countProfit(distributorId);
return num == null ? 0 : num;
}
@Override
public OrderDataStat countOrderData(DistributorProfitRequestDto dto) {
DistributorProfitExample example = new DistributorProfitExample();
DistributorProfitExample.Criteria criteria = example.createCriteria();
JdbcHelper.ifPresent(dto.getStartCreateTime(), criteria::andCreateTimeGreaterThanOrEqualTo);
JdbcHelper.ifPresent(dto.getEndCreateTime(), criteria::andCreateTimeLessThanOrEqualTo);
JdbcHelper.ifPresent(dto.getType(), criteria::andTypeEqualTo);
JdbcHelper.ifPresent(dto.getTypeList(), criteria::andTypeIn);
criteria.andIsValidEqualTo(true);
OrderDataStat orderDataStat = distributorProfitMapper.countOrderData(example);
return orderDataStat;
}
}
package com.wwdz.ch.db.mapper.distribution;
import com.wwdz.ch.db.bean.OrderDataStat;
import com.wwdz.ch.db.domain.distribution.DistributorProfit;
import com.wwdz.ch.db.domain.distribution.DistributorProfitExample;
import java.util.List;
......@@ -88,5 +89,12 @@ public interface DistributorProfitMapper {
*/
Long countProfit(@Param("distributorId")Long distributorId);
/**
* 统计订单数据
* @param example
* @return
*/
OrderDataStat countOrderData( @Param("example") DistributorProfitExample example);
}
\ No newline at end of file
......@@ -13,8 +13,10 @@
<result column="introduce_cost" jdbcType="BIGINT" property="introduceCost" />
<result column="profit" jdbcType="BIGINT" property="profit" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="type" jdbcType="INTEGER" property="type" />
<result column="is_valid" jdbcType="BIT" property="isValid" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
......@@ -75,7 +77,7 @@
</sql>
<sql id="Base_Column_List">
id, distribution_order_id, distributor_id, item_id, item_num, amount, item_cost,
channel_cost, introduce_cost, profit, create_time, is_valid
channel_cost, introduce_cost, profit, create_time, `type`, is_valid
</sql>
<select id="selectByExample" parameterType="com.wwdz.ch.db.domain.distribution.DistributorProfitExample" resultMap="BaseResultMap">
select
......@@ -111,7 +113,7 @@
</when>
<otherwise>
id, distribution_order_id, distributor_id, item_id, item_num, amount, item_cost,
channel_cost, introduce_cost, profit, create_time, is_valid
channel_cost, introduce_cost, profit, create_time, `type`, is_valid
</otherwise>
</choose>
from distributor_profit
......@@ -143,7 +145,7 @@
</when>
<otherwise>
id, distribution_order_id, distributor_id, item_id, item_num, amount, item_cost,
channel_cost, introduce_cost, profit, create_time, is_valid
channel_cost, introduce_cost, profit, create_time, `type`, is_valid
</otherwise>
</choose>
from distributor_profit
......@@ -166,13 +168,13 @@
insert into distributor_profit (distribution_order_id, distributor_id,
item_id, item_num, amount,
item_cost, channel_cost, introduce_cost,
profit, create_time, is_valid
)
profit, create_time, `type`,
is_valid)
values (#{distributionOrderId,jdbcType=VARCHAR}, #{distributorId,jdbcType=BIGINT},
#{itemId,jdbcType=BIGINT}, #{itemNum,jdbcType=INTEGER}, #{amount,jdbcType=BIGINT},
#{itemCost,jdbcType=BIGINT}, #{channelCost,jdbcType=BIGINT}, #{introduceCost,jdbcType=BIGINT},
#{profit,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP}, #{isValid,jdbcType=BIT}
)
#{profit,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP}, #{type,jdbcType=INTEGER},
#{isValid,jdbcType=BIT})
</insert>
<insert id="insertSelective" parameterType="com.wwdz.ch.db.domain.distribution.DistributorProfit">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
......@@ -210,6 +212,9 @@
<if test="createTime != null">
create_time,
</if>
<if test="type != null">
`type`,
</if>
<if test="isValid != null">
is_valid,
</if>
......@@ -245,6 +250,9 @@
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="type != null">
#{type,jdbcType=INTEGER},
</if>
<if test="isValid != null">
#{isValid,jdbcType=BIT},
</if>
......@@ -292,6 +300,9 @@
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=TIMESTAMP},
</if>
<if test="record.type != null">
`type` = #{record.type,jdbcType=INTEGER},
</if>
<if test="record.isValid != null">
is_valid = #{record.isValid,jdbcType=BIT},
</if>
......@@ -313,6 +324,7 @@
introduce_cost = #{record.introduceCost,jdbcType=BIGINT},
profit = #{record.profit,jdbcType=BIGINT},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
`type` = #{record.type,jdbcType=INTEGER},
is_valid = #{record.isValid,jdbcType=BIT}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
......@@ -351,6 +363,9 @@
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="type != null">
`type` = #{type,jdbcType=INTEGER},
</if>
<if test="isValid != null">
is_valid = #{isValid,jdbcType=BIT},
</if>
......@@ -369,6 +384,7 @@
introduce_cost = #{introduceCost,jdbcType=BIGINT},
profit = #{profit,jdbcType=BIGINT},
create_time = #{createTime,jdbcType=TIMESTAMP},
`type` = #{type,jdbcType=INTEGER},
is_valid = #{isValid,jdbcType=BIT}
where id = #{id,jdbcType=BIGINT}
</update>
......@@ -406,7 +422,7 @@
</when>
<otherwise>
id, distribution_order_id, distributor_id, item_id, item_num, amount, item_cost,
channel_cost, introduce_cost, profit, create_time, is_valid
channel_cost, introduce_cost, profit, create_time, `type`, is_valid
</otherwise>
</choose>
from distributor_profit
......@@ -430,4 +446,12 @@
<select id="countProfit" parameterType="java.lang.Long" resultType="java.lang.Long">
select sum(profit) from distributor_profit where distributor_id = #{distributorId} and is_valid = 1
</select>
<select id="countOrderData" parameterType="com.wwdz.ch.db.domain.distribution.DistributorProfitExample" resultType="com.wwdz.ch.db.bean.OrderDataStat">
select IFNULL(sum(amount), 0) as totalAmount, count(distribution_order_id) as totalOrderNum, IFNULL(sum(profit), 0) from distributor_profit
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
</mapper>
\ No newline at end of file
......@@ -72,7 +72,7 @@
<javaClientGenerator type="XMLMAPPER" targetPackage="com.wwdz.ch.db.mapper.distribution"
targetProject="ch-dao/src/main/java"/>
<table tableName="identify_order" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true">
<table tableName="distributor_profit" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true">
<generatedKey column="id" sqlStatement="Mysql" identity="true" />
</table>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment