Commit f2d5dbe5 authored by 廖旭伟's avatar 廖旭伟

用户、作品统计接口

parent 75a53265
......@@ -5,6 +5,11 @@ import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result;
import com.mortals.xhx.module.customer.model.CustomerEntity;
import com.mortals.xhx.module.customer.model.CustomerEntityExt;
import com.mortals.xhx.module.customer.model.vo.CustomerCensusVo;
import com.mortals.xhx.module.customer.model.vo.CustomerDesignCensusVo;
import java.util.List;
/**
* 客户管理Dao
* 客户管理 DAO接口
......@@ -15,4 +20,8 @@ import com.mortals.xhx.module.customer.model.CustomerEntityExt;
public interface CustomerDao extends ICRUDDao<CustomerEntity,Long>{
Result<CustomerEntityExt> getListExt(CustomerEntity params, PageInfo pageInfo);
List<CustomerCensusVo> getCensus();
CustomerDesignCensusVo getDesignCensus();
}
......@@ -5,6 +5,8 @@ import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.ParamDto;
import com.mortals.framework.model.Result;
import com.mortals.xhx.module.customer.model.CustomerEntityExt;
import com.mortals.xhx.module.customer.model.vo.CustomerCensusVo;
import com.mortals.xhx.module.customer.model.vo.CustomerDesignCensusVo;
import org.apache.ibatis.session.RowBounds;
import org.springframework.stereotype.Repository;
import com.mortals.xhx.module.customer.dao.CustomerDao;
......@@ -59,4 +61,14 @@ public class CustomerDaoImpl extends BaseCRUDDaoMybatis<CustomerEntity,Long> imp
return result;
}
@Override
public List<CustomerCensusVo> getCensus() {
return this.getSqlSession().selectList(this.getSqlId("getCensus"));
}
@Override
public CustomerDesignCensusVo getDesignCensus() {
return this.getSqlSession().selectOne(this.getSqlId("getDesignCensus"));
}
}
package com.mortals.xhx.module.customer.model.vo;
import lombok.Data;
/**
* 用户分类统计
*/
@Data
public class CustomerCensusVo {
/**
* 会员等级,,0:未开启,1:试用客户,2:VIP,3:设计师,默认0
*/
private Integer memberLevel;
/** 统计结果 **/
private Integer customerCount;
}
package com.mortals.xhx.module.customer.model.vo;
import lombok.Data;
/**
* 用户作品统计
*/
@Data
public class CustomerDesignCensusVo {
/** 图片数 **/
private Integer picturesCount;
/** 视频数 **/
private Integer videosCount;
}
......@@ -8,6 +8,8 @@ import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.customer.model.CustomerEntity;
import com.mortals.xhx.module.customer.model.CustomerEntityExt;
import java.util.Map;
/**
* CustomerService
*
......@@ -57,4 +59,10 @@ public interface CustomerService extends ICRUDService<CustomerEntity,Long>{
* @throws AppException
*/
void changePasswordByAdmin(CustomerEntity params, Context context) throws AppException;
/**
* 用户情况统计
* @return
*/
Map<String,Object> getCustomerCensus();
}
\ No newline at end of file
......@@ -15,14 +15,14 @@ import com.mortals.xhx.module.customer.dao.CustomerDao;
import com.mortals.xhx.module.customer.model.CustomerEntity;
import com.mortals.xhx.module.customer.model.CustomerEntityExt;
import com.mortals.xhx.module.customer.model.CustomerQuery;
import com.mortals.xhx.module.customer.model.vo.CustomerCensusVo;
import com.mortals.xhx.module.customer.model.vo.CustomerDesignCensusVo;
import com.mortals.xhx.module.customer.service.CustomerService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.*;
/**
* CustomerService
......@@ -199,4 +199,27 @@ public class CustomerServiceImpl extends AbstractCRUDServiceImpl<CustomerDao, Cu
update.setPassword(newPwd);
this.update(update,context);
}
@Override
public Map<String, Object> getCustomerCensus() {
Map<String, Object> result = new HashMap<>();
List<CustomerCensusVo> customerCensusVos = dao.getCensus();
CustomerDesignCensusVo designCensusVo = dao.getDesignCensus();
if(CollectionUtils.isNotEmpty(customerCensusVos)){
for(CustomerCensusVo item:customerCensusVos){
if(item.getMemberLevel()==1){
result.put("trial",item.getCustomerCount());
}
if(item.getMemberLevel()==2){
result.put("vip",item.getCustomerCount());
}
if(item.getMemberLevel()==3){
result.put("designer",item.getCustomerCount());
}
}
}
result.put("picturesCount",designCensusVo.getPicturesCount());
result.put("videosCount",designCensusVo.getVideosCount());
return result;
}
}
\ No newline at end of file
package com.mortals.xhx.module.customer.web;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.IBaseEnum;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
......@@ -53,6 +54,7 @@ public class CustomerController extends BaseCRUDJsonBodyMappingController<Custom
}
@Override
@UnAuth
public Rest<Object> list(@RequestBody(required = false) CustomerEntity query) {
Map<String, Object> model = new HashMap();
Rest<Object> ret = new Rest();
......@@ -64,8 +66,14 @@ public class CustomerController extends BaseCRUDJsonBodyMappingController<Custom
PageInfo pageInfo = this.buildPageInfo(query);
this.doListBefore(query, model, context);
Result result = this.getService().findExt(query, pageInfo, context);
Map<String,Object> census = service.getCustomerCensus();
model.put("data", result.getList());
model.put("pageInfo", result.getPageInfo());
model.put("trial", census.get("trial"));
model.put("vip", census.get("vip"));
model.put("designer", census.get("designer"));
model.put("picturesCount", census.get("picturesCount"));
model.put("videosCount", census.get("videosCount"));
this.parsePageInfo(model, result.getPageInfo());
code = this.doListAfter(query, model, context);
this.recordSysLog(this.request, busiDesc + " 【成功】");
......
......@@ -67,4 +67,23 @@
</trim>
</select>
<!-- 用户统计 -->
<select id="getCensus" parameterType="paramDto" resultType="com.mortals.xhx.module.customer.model.vo.CustomerCensusVo">
SELECT
memberLevel,
count(id) AS customerCount
FROM
mortals_xhx_customer t
GROUP BY
t.memberLevel
</select>
<!-- 用户统计 -->
<select id="getDesignCensus" parameterType="paramDto" resultType="com.mortals.xhx.module.customer.model.vo.CustomerDesignCensusVo">
SELECT
sum(customerDesignPictures) AS picturesCount,
sum(customerDesignVideos) AS videosCount
FROM
mortals_xhx_customer_work_design_stat
</select>
</mapper>
\ No newline at end of file
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