Helius
2020-12-29 7854eeda4763e0bd995226bc7c407fde5080e79c
modify
5 files modified
48 ■■■■ changed files
zq-erp/src/main/java/com/matrix/system/app/action/ApiRankingAction.java 12 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/app/dto/RankingDto.java 6 ●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/app/vo/RankingVo.java 2 ●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/hive/dao/AchieveNewDao.java 3 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/resources/mybatis/mapper/hive/AchieveNewDao.xml 25 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/app/action/ApiRankingAction.java
@@ -6,7 +6,9 @@
import com.matrix.system.app.vo.RankingVo;
import com.matrix.system.common.tools.DataAuthUtil;
import com.matrix.system.hive.action.util.QueryUtil;
import com.matrix.system.hive.bean.AchieveNew;
import com.matrix.system.hive.bean.SysOrder;
import com.matrix.system.hive.dao.AchieveNewDao;
import com.matrix.system.hive.service.AchieveNewService;
import com.matrix.system.hive.service.SysOrderService;
import io.swagger.annotations.Api;
@@ -36,6 +38,9 @@
    @Autowired
    private AchieveNewService achieveNewService;
    @Autowired
    private AchieveNewDao achieveNewDao;
    @ApiOperation(value = "顾问业绩排行榜", notes = "顾问业绩排行榜")
    @ApiResponses({
            @ApiResponse(code = 200, message = "ok", response = RankingVo.class)
@@ -60,7 +65,12 @@
            List<RankingVo> list = sysOrderService.findApiShopAchieveRanking(sysOrder);
            ajaxResult.setRows(list);
        } else {
            AchieveNew achieveNew = new AchieveNew();
            QueryUtil.setQueryLimitCom(achieveNew);
            achieveNew.setDatatime(DateUtil.stringToDate(rankingDto.getTime(), DateUtil.DATE_FORMAT_DD));
            achieveNew.setT1(rankingDto.getType());
            List<RankingVo> rankingVos = achieveNewDao.selectShopConsumeAchieveRanking(achieveNew);
            ajaxResult.setRows(rankingVos);
        }
        return ajaxResult;
    }
zq-erp/src/main/java/com/matrix/system/app/dto/RankingDto.java
@@ -19,13 +19,13 @@
    public static final String MONTH = "2";
    public static final String YEAR = "3";
    @ApiModelProperty(value = "数据类型 1-销售 2-消耗")
    @ApiModelProperty(value = "数据类型 1-销售 2-消耗", example = "1")
    private String dataType;
    @ApiModelProperty(value = "排行榜类型 1-日榜 2-月榜 3-年榜")
    @ApiModelProperty(value = "排行榜类型 1-日榜 2-月榜 3-年榜", example = "1")
    private String type;
    @ApiModelProperty(value = "时间")
    @ApiModelProperty(value = "时间", example = "2020-12-25")
    private String time;
    public String getDataType() {
zq-erp/src/main/java/com/matrix/system/app/vo/RankingVo.java
@@ -49,7 +49,7 @@
    }
    public BigDecimal getAmount() {
        return amount;
        return amount == null ? amount : amount.setScale(BigDecimal.ROUND_DOWN, 2);
    }
    public void setAmount(BigDecimal amount) {
zq-erp/src/main/java/com/matrix/system/hive/dao/AchieveNewDao.java
@@ -6,6 +6,7 @@
import com.matrix.core.pojo.PaginationVO;
import com.matrix.system.app.vo.OrderDetailAchieveItemVo;
import com.matrix.system.app.vo.RankingVo;
import com.matrix.system.app.vo.UserAchieveVo;
import com.matrix.system.hive.bean.AchieveNew;
import org.apache.ibatis.annotations.Param;
@@ -62,4 +63,6 @@
    UserAchieveVo selectUserAchieveByTime(@Param("startTime") Date startTime, @Param("endTime") Date endTime, @Param("userId") Long userId);
    List<OrderDetailAchieveItemVo> selectApiOrderItemAchieve(@Param("itemId") Long itemId);
    List<RankingVo> selectShopConsumeAchieveRanking(AchieveNew achieveNew);
}
zq-erp/src/main/resources/mybatis/mapper/hive/AchieveNewDao.xml
@@ -958,4 +958,29 @@
        inner join sys_users b on (a.beault_id=b.su_id or a.sale_id = b.su_id)
        where a.order_item_id=#{itemId} and order_type = '订单'
    </select>
    <select id="selectShopConsumeAchieveRanking" resultType="com.matrix.system.app.vo.RankingVo">
        select
            b.shop_short_name,
            b.SHOP_IMAG photo,
            sum(IFNULL(a.free_consume,0) + IFNULL(a.consume,0) + IFNULL(a.his_consume,0)) amount
        from achieve_new a
        left join sys_shop_info b on a.shop_id=b.ID
        <where>
            <if test="record.companyId != null">
                and a.company_id=#{record.companyId}
            </if>
            <if test='record.t1 == "1" and record.orderTime != null'>
                and date_format(datatime, '%Y-%m-%d') = date_format(#{record.datatime}, '%Y-%m-%d')
            </if>
            <if test='record.t1 == "2" and record.orderTime != null'>
                and date_format(datatime, '%Y-%m') = date_format(#{record.datatime}, '%Y-%m')
            </if>
            <if test='record.t1 == "3" and record.orderTime != null'>
                and date_format(datatime, '%Y') = date_format(#{record.datatime}, '%Y')
            </if>
        </where>
        group by a.shop_id
        order by amount desc, a.shop_id
    </select>
</mapper>