package com.yeshi.fanli.dao.user.vip;
|
|
import java.util.ArrayList;
|
import java.util.Date;
|
import java.util.List;
|
|
import org.springframework.data.domain.Sort;
|
import org.springframework.data.mongodb.core.query.Criteria;
|
import org.springframework.data.mongodb.core.query.Query;
|
import org.springframework.data.mongodb.core.query.Update;
|
import org.springframework.stereotype.Repository;
|
|
import com.yeshi.fanli.dao.MongodbBaseDao;
|
import com.yeshi.fanli.entity.bus.user.vip.GiveVIPApplyInfo;
|
|
@Repository
|
public class GiveVIPApplyInfoDao extends MongodbBaseDao<GiveVIPApplyInfo> {
|
|
/**
|
* 查询列表
|
* @Title: list
|
* @Description:
|
* @param sourceUid
|
* @param state
|
* @param start
|
* @param count
|
* @return
|
* List<GiveVIPApplyInfo> 返回类型
|
* @throws
|
*/
|
public List<GiveVIPApplyInfo> listByTargetUid(Long targetUid, Integer state, int start, int count) {
|
Query query = new Query();
|
|
List<Criteria> list = new ArrayList<Criteria>();
|
if (targetUid != null)
|
list.add(Criteria.where("targetUid").is(targetUid));
|
|
if (state != null)
|
list.add(Criteria.where("state").is(state));
|
|
if (list.size() > 0) {
|
Criteria[] cas = new Criteria[list.size()];
|
for (int i = 0; i < list.size(); i++)
|
cas[i] = list.get(i);
|
query.addCriteria(new Criteria().andOperator(cas));
|
}
|
query.skip(start);
|
query.limit(count);
|
query.with(new Sort(Sort.Direction.DESC, "createTime"));
|
return findList(query);
|
}
|
|
public long countByTargetUid(Long targetUid, Integer state) {
|
Query query = new Query();
|
|
List<Criteria> list = new ArrayList<Criteria>();
|
if (targetUid != null)
|
list.add(Criteria.where("targetUid").is(targetUid));
|
|
if (state != null)
|
list.add(Criteria.where("state").is(state));
|
|
if (list.size() > 0) {
|
|
Criteria[] cas = new Criteria[list.size()];
|
for (int i = 0; i < list.size(); i++)
|
cas[i] = list.get(i);
|
query.addCriteria(new Criteria().andOperator(cas));
|
}
|
return count(query);
|
}
|
|
|
|
public List<GiveVIPApplyInfo> listBySourceUid(Long sourceUid, Integer state, int start, int count) {
|
Query query = new Query();
|
|
List<Criteria> list = new ArrayList<Criteria>();
|
if (sourceUid != null)
|
list.add(Criteria.where("sourceUid").is(sourceUid));
|
|
if (state != null)
|
list.add(Criteria.where("state").is(state));
|
|
if (list.size() > 0) {
|
Criteria[] cas = new Criteria[list.size()];
|
for (int i = 0; i < list.size(); i++)
|
cas[i] = list.get(i);
|
query.addCriteria(new Criteria().andOperator(cas));
|
}
|
query.skip(start);
|
query.limit(count);
|
query.with(new Sort(Sort.Direction.DESC, "createTime"));
|
return findList(query);
|
}
|
|
public long countBySourceUid(Long sourceUid, Integer state) {
|
Query query = new Query();
|
|
List<Criteria> list = new ArrayList<Criteria>();
|
if (sourceUid != null)
|
list.add(Criteria.where("sourceUid").is(sourceUid));
|
|
if (state != null)
|
list.add(Criteria.where("state").is(state));
|
|
if (list.size() > 0) {
|
|
Criteria[] cas = new Criteria[list.size()];
|
for (int i = 0; i < list.size(); i++)
|
cas[i] = list.get(i);
|
query.addCriteria(new Criteria().andOperator(cas));
|
}
|
return count(query);
|
}
|
|
public void updateSelective(GiveVIPApplyInfo info) {
|
Query query = new Query();
|
query.addCriteria(Criteria.where("id").is(info.getId()));
|
Update update = new Update();
|
if (info.getHasDoOtherPlatform() != null)
|
update.set("hasDoOtherPlatform", info.getHasDoOtherPlatform());
|
if (info.getApplyReason() != null)
|
update.set("getApplyReson", info.getApplyReason());
|
if (info.getImgList() != null)
|
update.set("imgList", info.getImgList());
|
if (info.getLevel() != null)
|
update.set("level", info.getLevel());
|
if (info.getMark() != null)
|
update.set("mark", info.getMark());
|
if (info.getOtherDirectTeams() != null)
|
update.set("otherDirectTeams", info.getOtherDirectTeams());
|
if (info.getOtherInDirectTeams() != null)
|
update.set("otherInDirectTeams", info.getOtherInDirectTeams());
|
if (info.getOtherLevel() != null)
|
update.set("otherLevel", info.getOtherLevel());
|
if (info.getOtherMonthIncome() != null)
|
update.set("otherMonthIncome", info.getOtherMonthIncome());
|
if (info.getOtherPlatformName() != null)
|
update.set("otherPlatformName", info.getOtherPlatformName());
|
if (info.getPhone() != null)
|
update.set("phone", info.getPhone());
|
if (info.getRejectReson() != null)
|
update.set("rejectReson", info.getRejectReson());
|
if (info.getSourceUid() != null)
|
update.set("sourceUid", info.getSourceUid());
|
if (info.getState() != null)
|
update.set("state", info.getState());
|
if (info.getTargetUid() != null)
|
update.set("targetUid", info.getTargetUid());
|
if (info.getVerifyTime() != null)
|
update.set("verifyTime", info.getVerifyTime());
|
if (info.getWxID() != null)
|
update.set("wxID", info.getWxID());
|
update.set("updateTime", new Date());
|
update(query, update);
|
}
|
|
public void saveImgs(String id, List<String> imgList) {
|
GiveVIPApplyInfo info = new GiveVIPApplyInfo();
|
info.setId(id);
|
info.setImgList(imgList);
|
updateSelective(info);
|
}
|
|
}
|