zq-erp/src/main/java/com/matrix/system/app/action/ApiVipInfoAction.java
@@ -2,7 +2,13 @@ import com.matrix.core.pojo.AjaxResult; import com.matrix.system.app.dto.VipInfoListDto; import com.matrix.system.app.vo.VipInfoListVo; import com.matrix.system.hive.service.SysVipInfoService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -17,10 +23,16 @@ @RequestMapping(value = "/api/vip") public class ApiVipInfoAction { @Autowired private SysVipInfoService sysVipInfoService; @ApiOperation(value = "获取会员通讯录列表", notes = "获取会员通讯录列表") @ApiResponses({ @ApiResponse(code = 200, message = "ok", response = VipInfoListVo.class) }) @PostMapping(value = "/findVipInfoList") public AjaxResult findVipInfoList(@RequestBody VipInfoListDto vipInfoListDto) { return null; return AjaxResult.buildSuccessInstance(sysVipInfoService.findVipAddressBook(vipInfoListDto)); } } zq-erp/src/main/java/com/matrix/system/app/dto/VipInfoListDto.java
@@ -13,11 +13,14 @@ @ApiModelProperty(value = "查询参数(客户姓名/手机/会员编号/拼音)", example = "") private String queryKey; @ApiModelProperty(value = "排序字段") private String order; @ApiModelProperty(value = "排序 desc/asc", example = "asc") private String order = "asc"; @ApiModelProperty(value = "排序 desc/asc") private String sort; @ApiModelProperty(value = "排序字段 monthArrived(本月到店次数) yearArrived(本年) used(消费) consume(消耗) vipLevel(会员等级) arriveTime(上次到店)", example = "zjm") private String sort = "zjm"; @ApiModelProperty(hidden = true) private Long shopId; public String getQueryKey() { return queryKey; @@ -42,4 +45,12 @@ public void setSort(String sort) { this.sort = sort; } public Long getShopId() { return shopId; } public void setShopId(Long shopId) { this.shopId = shopId; } } zq-erp/src/main/java/com/matrix/system/app/vo/VipInfoListVo.java
New file @@ -0,0 +1,67 @@ package com.matrix.system.app.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; /** * @author wzy * @date 2020-12-22 **/ @ApiModel(value = "VipInfoListVo", description = "会员列表返回类") public class VipInfoListVo { @ApiModelProperty(value = "会员姓名") private String vipName; @ApiModelProperty(value = "会员手机号") private String phone; @ApiModelProperty(value = "到店次数") private Integer arriveCnt; @ApiModelProperty(value = "头像") private String photo; @ApiModelProperty(value = "会员ID") private Long id; public String getVipName() { return vipName; } public void setVipName(String vipName) { this.vipName = vipName; } public String getPhone() { return phone; } public void setPhone(String phone) { this.phone = phone; } public Integer getArriveCnt() { return arriveCnt; } public void setArriveCnt(Integer arriveCnt) { this.arriveCnt = arriveCnt; } public String getPhoto() { return photo; } public void setPhoto(String photo) { this.photo = photo; } public Long getId() { return id; } public void setId(Long id) { this.id = id; } } zq-erp/src/main/java/com/matrix/system/common/interceptor/ApiUserLoginInterceptor.java
@@ -10,6 +10,9 @@ import com.matrix.core.tools.RSAUtils; import com.matrix.core.tools.StringUtils; import com.matrix.system.common.bean.SysUsers; import com.matrix.system.common.dao.SysUsersDao; import com.matrix.system.hive.bean.SysVipInfo; import com.matrix.system.hive.dao.SysVipInfoDao; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @@ -32,11 +35,23 @@ @Value("${login_private_key}") private String privateKey; @Value("${evn}") private String evn; @Autowired private SysUsersDao sysUsersDao; private final String TOKEN_HEADER = "Authorization"; private final String TOKEN_START_WITH = "Bearer "; @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { if ("dev".equals(evn)) { SysUsers sysUsers = sysUsersDao.selectById(1012L); request.getSession().setAttribute(MatrixConstance.LOGIN_KEY, sysUsers); return true; } String token = resolveToken(request); AjaxResult ajaxResult = new AjaxResult(); ajaxResult.setStatus(AjaxResult.STATUS_LOGIN_INVALID); zq-erp/src/main/java/com/matrix/system/hive/dao/SysVipInfoDao.java
@@ -1,6 +1,8 @@ package com.matrix.system.hive.dao; import com.matrix.core.pojo.PaginationVO; import com.matrix.system.app.dto.VipInfoListDto; import com.matrix.system.app.vo.VipInfoListVo; import com.matrix.system.hive.bean.SysVipInfo; import com.matrix.system.hive.pojo.VipInfoVo; import org.apache.ibatis.annotations.Param; @@ -202,4 +204,6 @@ public int batchInsert(@Param("list") List<SysVipInfo> list); public List<SysVipInfo> selectVipInfoByVipNo(@Param("companyId") Long companyId, @Param("vipNo") String vipNo); List<VipInfoListVo> selectVipAddressBookByList(@Param("record") VipInfoListDto vipInfoListDto); } zq-erp/src/main/java/com/matrix/system/hive/service/SysVipInfoService.java
@@ -1,6 +1,8 @@ package com.matrix.system.hive.service; import com.matrix.core.pojo.PaginationVO; import com.matrix.system.app.dto.VipInfoListDto; import com.matrix.system.app.vo.VipInfoListVo; import com.matrix.system.hive.bean.SysVipInfo; import com.matrix.system.hive.plugin.util.BaseServices; import com.matrix.system.hive.pojo.VipInfoVo; @@ -180,4 +182,6 @@ public List<SysVipInfo> findAll(SysVipInfo sysVipInfo); public int importVipInfo(File file) throws IOException; List<VipInfoListVo> findVipAddressBook(VipInfoListDto vipInfoListDto); } zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysVipInfoServiceImpl.java
@@ -6,6 +6,8 @@ import com.matrix.core.tools.*; import com.matrix.core.tools.excl.ExcelSheetPO; import com.matrix.core.tools.excl.ExcelUtil; import com.matrix.system.app.dto.VipInfoListDto; import com.matrix.system.app.vo.VipInfoListVo; import com.matrix.system.common.bean.SysUsers; import com.matrix.system.common.tools.ServiceUtil; import com.matrix.system.constance.Dictionary; @@ -417,5 +419,10 @@ return result; } @Override public List<VipInfoListVo> findVipAddressBook(VipInfoListDto vipInfoListDto) { SysUsers sysUsers = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); vipInfoListDto.setShopId(sysUsers.getShopId()); return sysVipInfoDao.selectVipAddressBookByList(vipInfoListDto); } } zq-erp/src/main/resources/mybatis/mapper/hive/SysVipInfoDao.xml
@@ -1219,5 +1219,72 @@ <select id="selectVipInfoByVipNo" resultMap="SysVipInfoMapSimple"> select * from sys_vip_info where company_id=#{companyId} and vip_no=#{vipNo} </select> <select id="selectVipAddressBookByList" resultType="com.matrix.system.app.vo.VipInfoListVo"> select a.ID id, a.VIP_NAME vipName, a.PHONE phone, a.photo photo, b.arriveCnt arriveCnt from sys_vip_info a left join ( select x.vip_id, count(1) arriveCnt from ( select vip_id, date_format(datatime, '%Y-%m-%d') from achieve_new where 1=1 <!-- 本月到店次数 --> <if test="record.sort == 'monthArrived'"> and date_format(curdate(), '%Y-%m') = date_format(datatime, '%Y-%m') </if> <!-- 本年到店次数 --> <if test="record.sort == 'yearArrived'"> and date_format(curdate(), '%Y') = date_format(datatime, '%Y') </if> group by date_format(datatime, '%Y-%m-%d'), vip_id ) x group by x.vip_id ) b on a.ID=b.vip_id <!-- 本月消费 --> <if test="record.sort == 'used'"> left join ( select y.vip_id, sum(IFNULL(card_cash, 0) + IFNULL(proj_cash,0) + IFNULL(goods_cash, 0)) used from achieve_new y where date_format(datatime,'%Y-%m') = date_format(curdate(), '%Y-%m') group by y.vip_id ) c on a.id=c.vip_id </if> <!-- 本月消耗 --> <if test="record.sort == 'consume'"> left join ( select z.vip_id, SUM(IFNULL(free_consume, 0) + IFNULL(his_consume, 0) + IFNULL(consume, 0)) consume from achieve_new z where date_format(datatime,'%Y-%m') = date_format(curdate(), '%Y-%m') group by z.vip_id ) d on a.ID = d.vip_id </if> <!-- 上次到店时间 --> <if test="record.sort == 'arriveTime'"> left join ( select m.vip_id, MAX(datatime) arriveTime from achieve_new m group by m.vip_id ) e on a.ID=e.vip_id </if> <!-- 会员级别排序 --> <if test="record.sort == 'vipLevel'"> left join ( select n.VIP_LEVEL vipLevel, n.ID from sys_vip_level n ) f on a.LEVEL_ID = f.ID </if> where 1=1 <if test="record.queryKey != null and record.queryKey != ''"> and (instr(PHONE,#{record.queryKey}) or instr(VIP_NAME ,#{record.queryKey}) or instr(zjm ,#{record.queryKey}) or instr(VIP_NO ,#{record.queryKey})) </if> <if test="record.shopId != null"> and a.shop_id=#{record.shopId} </if> <if test="record.sort == 'monthArrived' or record.sort == 'yearArrived'"> order by arriveCnt ${record.order} </if> <if test="record.sort != 'monthArrived' and record.sort != 'yearArrived'"> order by ${record.sort} ${record.order} </if> </select> </mapper>