| | |
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.GsonBuilder;
|
| | | import com.yeshi.fanli.entity.admin.UserInfoAdmin;
|
| | | import com.yeshi.fanli.entity.bus.user.AccountDetails;
|
| | | import com.yeshi.fanli.entity.bus.user.Extract;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBao;
|
| | | import com.yeshi.fanli.entity.bus.user.MoneyRecord;
|
| | |
| | | import com.yeshi.fanli.util.HongBaoUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | |
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | @Controller
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | public static void main(String[] args) {
|
| | | |
| | | |
| | | /**
|
| | | * 队员关系
|
| | | * @param pageIndex
|
| | | * @param key
|
| | | * @param state
|
| | | * @param startTime
|
| | | * @param endTime
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getRelationList")
|
| | | public void getRelationList(String callback, Integer pageIndex, Integer pageSize, Long uid, Integer type,
|
| | | Integer state, String startTime, String endTime, PrintWriter out) {
|
| | |
|
| | | if (pageIndex == null || pageIndex < 1) {
|
| | | pageIndex = 1;
|
| | | }
|
| | |
|
| | | if (pageSize == null || pageSize < 1) {
|
| | | pageSize = Constant.PAGE_SIZE;
|
| | | }
|
| | | |
| | | try {
|
| | | |
| | | if (!StringUtil.isNullOrEmpty(endTime)) {
|
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
| | | Date enddate = sdf.parse(endTime);
|
| | | Calendar c = Calendar.getInstance();
|
| | | c.setTime(enddate);
|
| | | c.add(Calendar.DAY_OF_MONTH, 1);// 今天+1天
|
| | | endTime = sdf.format(c.getTime());
|
| | | }
|
| | | |
| | | List<ThreeSale> listQuery = null;
|
| | | if (type == 0) {
|
| | | // 上级用户
|
| | | if (uid == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询上级需输入用户id"));
|
| | | return;
|
| | | }
|
| | | listQuery = threeSaleService.listSuperiorQuery((pageIndex - 1) * pageSize, pageSize, state, uid);
|
| | | } else if (type == 1) {
|
| | | // 一级用户
|
| | | listQuery = threeSaleService.listFirstTeamQuery((pageIndex - 1) * pageSize, pageSize, uid, |
| | | state, startTime, endTime);
|
| | | } else if (type == 2) {
|
| | | // 二级用户
|
| | | listQuery = threeSaleService.listSecondTeamQuery((pageIndex - 1) * pageSize, pageSize, uid,
|
| | | state, startTime, endTime);
|
| | | }
|
| | | |
| | | if (listQuery == null || listQuery.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
|
| | | return;
|
| | | }
|
| | | |
| | | for (ThreeSale threeSale: listQuery) {
|
| | | Integer expire = threeSale.getExpire();
|
| | | if (threeSale.getState()) {
|
| | | threeSale.setExpire(1); // 邀请成功
|
| | | } else {
|
| | | if (expire != null && expire == 1) {
|
| | | threeSale.setExpire(2); // 邀请失效
|
| | | } else {
|
| | | threeSale.setExpire(0);// 已邀请
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | long count = 0;
|
| | | if (type == 0) {
|
| | | // 上级用户
|
| | | count = threeSaleService.countSuperiorQuery(state, uid);
|
| | | } else if (type == 1) {
|
| | | // 一级用户
|
| | | count = threeSaleService.countFirstTeamQuery(uid, state, startTime, endTime);
|
| | | } else if (type == 2) {
|
| | | // 二级用户
|
| | | count = threeSaleService.countSecondTeamQuery(uid, state, startTime, endTime);
|
| | | }
|
| | | |
| | | int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
|
| | | PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
|
| | | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("pe", pe);
|
| | | data.put("result_list", listQuery);
|
| | | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | | |
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败"));
|
| | | e.printStackTrace();
|
| | | } |
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 用户账户明细
|
| | | * @param callback
|
| | | * @param pageIndex
|
| | | * @param pageSize
|
| | | * @param id
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getAccountDetails")
|
| | | public void getAccountDetails(String callback, Integer pageIndex,Integer pageSize, Long uid, PrintWriter out) {
|
| | | if (pageIndex == null || pageIndex < 1) {
|
| | | pageIndex = 1;
|
| | | }
|
| | |
|
| | | if (pageSize == null || pageSize < 1) {
|
| | | pageSize = Constant.PAGE_SIZE;
|
| | | }
|
| | | |
| | | if (uid == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请传递正确数据"));
|
| | | return;
|
| | | }
|
| | | |
| | | try {
|
| | | |
| | | List<AccountDetails> detailsList = accountDetailsService.findAccountDetailsList(uid, pageIndex);
|
| | | if (detailsList == null || detailsList.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
|
| | | return;
|
| | | }
|
| | | |
| | | int count = accountDetailsService.getCount(uid);
|
| | | |
| | | int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
|
| | | PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
|
| | | |
| | | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("pe", pe);
|
| | | data.put("result_list", GsonUtil.toJsonExpose(detailsList));
|
| | | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | | |
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败"));
|
| | | }
|
| | | }
|
| | | |
| | | public static void main(String[] args) {
|
| | | java.lang.System.out.println(java.lang.System.currentTimeMillis());
|
| | | }
|
| | |
|
| | |
| | | */ |
| | | int updateExpire(List<Long> list); |
| | | |
| | | /** |
| | | * 一级查询 |
| | | * @param start |
| | | * @param count |
| | | * @param key |
| | | * @param startTime |
| | | * @param endTime |
| | | * @return |
| | | */ |
| | | List<ThreeSale> listFirstTeamQuery(@Param("start") long start, @Param("count") int count, @Param("uid") Long uid, |
| | | @Param("state")Integer state, @Param("startTime") String startTime, @Param("endTime") String endTime); |
| | | |
| | | long countFirstTeamQuery(@Param("uid") Long uid, @Param("state")Integer state, @Param("startTime") String startTime, |
| | | @Param("endTime") String endTime); |
| | | |
| | | |
| | | /** |
| | | * 二级查询 |
| | | * @param start |
| | | * @param count |
| | | * @param key |
| | | * @param startTime |
| | | * @param endTime |
| | | * @return |
| | | */ |
| | | List<ThreeSale> listSecondTeamQuery(@Param("start")long start, @Param("count")int count, @Param("uid")Long uid, |
| | | @Param("state")Integer state, @Param("startTime")String startTime, @Param("endTime")String endTime); |
| | | |
| | | long countSecondTeamQuery(@Param("uid")Long uid, @Param("state")Integer state, @Param("startTime")String startTime, |
| | | @Param("endTime") String endTime); |
| | | |
| | | |
| | | |
| | | /** |
| | | * 上级查询 |
| | | * @param start |
| | | * @param count |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | List<ThreeSale> listSuperiorQuery(@Param("start") long start, @Param("count") int count, |
| | | @Param("state")Integer state, @Param("uid") Long uid); |
| | | |
| | | long countSuperiorQuery(@Param("state")Integer state, @Param("uid") Long uid); |
| | | |
| | | } |
| | |
| | | javaType="com.yeshi.fanli.entity.bus.user.UserInfo"> |
| | | <id column="worker_id" property="id" jdbcType="BIGINT" /> |
| | | </association> |
| | | |
| | | </resultMap> |
| | | |
| | | <resultMap id="AllResultMap" type="com.yeshi.fanli.entity.bus.user.ThreeSale"> |
| | | <id column="id" property="id" jdbcType="BIGINT" /> |
| | | <result column="state" property="state" jdbcType="BOOLEAN" /> |
| | | <result column="createTime" property="createTime" jdbcType="BIGINT" /> |
| | | <result column="expire" property="expire" jdbcType="INTEGER" /> |
| | | |
| | | <association property="boss" column="boss_id" |
| | | select="com.yeshi.fanli.dao.mybatis.UserInfoMapper.selectByPKey" /> |
| | | |
| | | <association property="worker" column="worker_id" |
| | | select="com.yeshi.fanli.dao.mybatis.UserInfoMapper.selectByPKey" /> |
| | | </resultMap> |
| | | |
| | | <sql id="Base_Column_List">id,boss_id,worker_id,state,expire,createTime</sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | |
| | | close=")">#{item}</foreach> |
| | | </update> |
| | | |
| | | <select id="listFirstTeamQuery" resultMap="AllResultMap"> |
| | | SELECT * FROM `yeshi_ec_threesale` |
| | | WHERE 1=1 |
| | | <if test="uid != null"> |
| | | AND `boss_id` = #{uid} |
| | | </if> |
| | | <if test="state == 0"> |
| | | AND `state` = 0 AND (expire = 0 OR expire IS NULL) |
| | | </if> |
| | | <if test="state == 1"> |
| | | AND `state` = 1 |
| | | </if> |
| | | <if test="state ==2"> |
| | | AND `expire` = 1 <!-- 失效 --> |
| | | </if> |
| | | <if test="startTime != null and startTime !='' "> |
| | | <![CDATA[AND FROM_UNIXTIME(createTime/1000) >= #{startTime}]]> |
| | | </if> |
| | | <if test="endTime != null and endTime !='' "> |
| | | <![CDATA[AND FROM_UNIXTIME(createTime/1000) <= #{endTime}]]> |
| | | </if> |
| | | ORDER BY createTime DESC |
| | | LIMIT ${start},${count} |
| | | </select> |
| | | |
| | | <select id="countFirstTeamQuery" resultType="java.lang.Long"> |
| | | SELECT count(id) FROM `yeshi_ec_threesale` |
| | | WHERE 1=1 |
| | | <if test="uid != null"> |
| | | AND `boss_id` = #{uid} |
| | | </if> |
| | | <if test="state == 0"> |
| | | AND `state` = 0 AND (expire = 0 OR expire IS NULL) |
| | | </if> |
| | | <if test="state == 1"> |
| | | AND `state` = 1 |
| | | </if> |
| | | <if test="state ==2"> |
| | | AND `expire` = 1 <!-- 失效 --> |
| | | </if> |
| | | <if test="startTime != null and startTime !='' "> |
| | | <![CDATA[AND FROM_UNIXTIME(createTime/1000) >= #{startTime}]]> |
| | | </if> |
| | | <if test="endTime != null and endTime !=''"> |
| | | <![CDATA[AND FROM_UNIXTIME(createTime/1000) <= #{endTime}]]> |
| | | </if> |
| | | </select> |
| | | |
| | | |
| | | <select id="listSecondTeamQuery" resultMap="AllResultMap"> |
| | | SELECT yet.* FROM ( |
| | | SELECT DISTINCT(ts.`id`) AS id FROM `yeshi_ec_threesale` ts |
| | | LEFT JOIN yeshi_ec_threesale tf ON ts.`boss_id`=tf.`worker_id` |
| | | WHERE 1=1 |
| | | <if test="uid != null"> |
| | | AND tf.`boss_id` = #{uid} |
| | | </if> |
| | | <if test="state == 0"> |
| | | AND ts.`state` = 0 AND (ts.expire = 0 OR ts.expire IS NULL) |
| | | </if> |
| | | <if test="state == 1"> |
| | | AND ts.`state` = 1 |
| | | </if> |
| | | <if test="state ==2"> |
| | | AND ts.`expire` = 1 <!-- 失效 --> |
| | | </if> |
| | | <if test="startTime != null and startTime !='' "> |
| | | <![CDATA[AND FROM_UNIXTIME(ts.createTime/1000) >= #{startTime}]]> |
| | | </if> |
| | | <if test="endTime != null and endTime !=''"> |
| | | <![CDATA[AND FROM_UNIXTIME(ts.createTime/1000) <= #{endTime}]]> |
| | | </if> |
| | | |
| | | )A LEFT JOIN yeshi_ec_threesale yet ON yet.id = A.id |
| | | ORDER BY yet.`createtime` DESC |
| | | LIMIT ${start},${count} |
| | | </select> |
| | | |
| | | <select id="countSecondTeamQuery" resultType="java.lang.Long" > |
| | | SELECT COUNT(A.id) FROM ( |
| | | SELECT DISTINCT(ts.`id`) AS id FROM `yeshi_ec_threesale` ts |
| | | LEFT JOIN yeshi_ec_threesale tf ON ts.`boss_id`=tf.`worker_id` |
| | | WHERE 1=1 |
| | | <if test="uid != null"> |
| | | AND tf.`boss_id` = #{uid} |
| | | </if> |
| | | <if test="state == 0"> |
| | | AND ts.`state` = 0 AND (ts.expire = 0 OR ts.expire IS NULL) |
| | | </if> |
| | | <if test="state == 1"> |
| | | AND ts.`state` = 1 |
| | | </if> |
| | | <if test="state ==2"> |
| | | AND ts.`expire` = 1 <!-- 失效 --> |
| | | </if> |
| | | <if test="startTime != null and startTime !='' "> |
| | | <![CDATA[AND FROM_UNIXTIME(ts.createTime/1000) >= #{startTime}]]> |
| | | </if> |
| | | <if test="endTime != null and endTime !=''"> |
| | | <![CDATA[AND FROM_UNIXTIME(ts.createTime/1000) <= #{endTime}]]> |
| | | </if> |
| | | )A |
| | | </select> |
| | | |
| | | <select id="listSuperiorQuery" resultMap="AllResultMap"> |
| | | SELECT * FROM `yeshi_ec_threesale` ts |
| | | WHERE ts.`worker_id` = #{uid} |
| | | <if test="state == 0"> |
| | | AND ts.`state` = 0 AND (ts.expire = 0 OR ts.expire IS NULL) |
| | | </if> |
| | | <if test="state == 1"> |
| | | AND ts.`state` = 1 |
| | | </if> |
| | | <if test="state ==2"> |
| | | AND ts.`expire` = 1 <!-- 失效 --> |
| | | </if> |
| | | ORDER BY ts.`createtime` DESC |
| | | LIMIT ${start},${count} |
| | | </select> |
| | | |
| | | <select id="countSuperiorQuery" resultType="java.lang.Long" > |
| | | SELECT COUNT(ts.id) FROM `yeshi_ec_threesale` ts |
| | | WHERE ts.`worker_id` = #{uid} |
| | | <if test="state == 0"> |
| | | AND ts.`state` = 0 AND (ts.expire = 0 OR ts.expire IS NULL) |
| | | </if> |
| | | <if test="state == 1"> |
| | | AND ts.`state` = 1 |
| | | </if> |
| | | <if test="state ==2"> |
| | | AND ts.`expire` = 1 <!-- 失效 --> |
| | | </if> |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | LEFT JOIN yeshi_ec_binding_account b ON u.`id` = b.`uid` |
| | | where 1=1 |
| | | <if test="key != null and key !='' "> |
| | | AND (u.id LIKE '%${key}%' OR u.`phone` LIKE '%${key}%' OR b.`account` LIKE '%${key}%') |
| | | AND (u.id LIKE '%${key}%' OR u.`phone` LIKE '%${key}%' OR u.`wxName` LIKE '%${key}%' |
| | | OR u.`nick_name` LIKE '%${key}%' OR u.`tbName` LIKE '%${key}%' OR b.`account` LIKE '%${key}%') |
| | | </if> |
| | | <if test="startTime != null and startTime !='' "> |
| | | <![CDATA[ AND FROM_UNIXTIME(createtime/1000) >= '${startTime}' ]]> |
| | |
| | | SELECT count(u.id) FROM yeshi_ec_user u |
| | | LEFT JOIN yeshi_ec_binding_account b ON u.`id` = b.`uid` |
| | | where <![CDATA[ 1>0 ]]> |
| | | <if test="key != null and key !='' "> |
| | | AND (u.id LIKE '%${key}%' OR u.`phone` LIKE '%${key}%' OR b.`account` LIKE '%${key}%') |
| | | <if test="key != null and key !='' "> |
| | | AND (u.id LIKE '%${key}%' OR u.`phone` LIKE '%${key}%' OR u.`wxName` LIKE '%${key}%' |
| | | OR u.`nick_name` LIKE '%${key}%' OR u.`tbName` LIKE '%${key}%' OR b.`account` LIKE '%${key}%') |
| | | </if> |
| | | <if test="startTime != null and startTime !='' "> |
| | | <![CDATA[ AND FROM_UNIXTIME(createtime/1000) >= '${startTime}' ]]> |
| | |
| | | LEFT JOIN yeshi_ec_binding_account b ON u.`id` = b.`uid` |
| | | where <![CDATA[ 1>0 ]]> |
| | | <if test="key != null and key !='' "> |
| | | AND (u.id LIKE '%${key}%' OR u.`phone` LIKE '%${key}%' OR b.`account` LIKE '%${key}%') |
| | | AND (u.id LIKE '%${key}%' OR u.`phone` LIKE '%${key}%' OR u.`wxName` LIKE '%${key}%' |
| | | OR u.`nick_name` LIKE '%${key}%' OR u.`tbName` LIKE '%${key}%' OR b.`account` LIKE '%${key}%') |
| | | </if> |
| | | <if test="startTime != null and startTime !='' "> |
| | | <![CDATA[ AND FROM_UNIXTIME(createtime/1000) >= '${startTime}' ]]> |
| | |
| | | import org.springframework.orm.hibernate4.HibernateCallback;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.yeshi.utils.NumberUtil;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.ThreeSaleMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.UserInfoMapper;
|
| | |
| | | import com.yeshi.fanli.service.inter.hongbao.ThreeSaleSerivce;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import org.yeshi.utils.NumberUtil;
|
| | |
|
| | | @Service
|
| | | public class ThreeSaleSerivceImpl implements ThreeSaleSerivce {
|
| | |
| | | public int updateExpire(List<Long> list){
|
| | | return threeSaleMapper.updateExpire(list);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<ThreeSale> listFirstTeamQuery(long start, int count, Long uid, Integer state, String startTime,
|
| | | String endTime) {
|
| | | return threeSaleMapper.listFirstTeamQuery(start, count, uid, state, startTime, endTime);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countFirstTeamQuery(Long uid, Integer state, String startTime, String endTime) {
|
| | | return threeSaleMapper.countFirstTeamQuery(uid, state, startTime, endTime);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<ThreeSale> listSecondTeamQuery(long start, int count, Long uid, Integer state, String startTime,
|
| | | String endTime) {
|
| | | return threeSaleMapper.listSecondTeamQuery(start, count, uid, state, startTime, endTime);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countSecondTeamQuery(Long uid, Integer state, String startTime, String endTime) {
|
| | | return threeSaleMapper.countSecondTeamQuery(uid, state, startTime, endTime);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<ThreeSale> listSuperiorQuery(long start, int count, Integer state, Long uid) {
|
| | | return threeSaleMapper.listSuperiorQuery(start, count, state, uid);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countSuperiorQuery(Integer state, Long uid) {
|
| | | return threeSaleMapper.countSuperiorQuery(state, uid);
|
| | | }
|
| | | |
| | |
|
| | |
|
| | | }
|
| | |
| | | */
|
| | | public int updateExpire(List<Long> list);
|
| | |
|
| | | /**
|
| | | * 一级查询
|
| | | * @param start
|
| | | * @param count
|
| | | * @param uid
|
| | | * @param startTime
|
| | | * @param endTime
|
| | | * @return
|
| | | */
|
| | | public List<ThreeSale> listFirstTeamQuery(long start, int count, Long uid, Integer state, |
| | | String startTime, String endTime);
|
| | | |
| | | public long countFirstTeamQuery(Long uid, Integer state, String startTime, String endTime);
|
| | |
|
| | | /**
|
| | | * 二级查询
|
| | | * @param start
|
| | | * @param count
|
| | | * @param uid
|
| | | * @param startTime
|
| | | * @param endTime
|
| | | * @return
|
| | | */
|
| | | public List<ThreeSale> listSecondTeamQuery(long start, int count, Long uid, Integer state, |
| | | String startTime,String endTime);
|
| | | |
| | | public long countSecondTeamQuery(Long uid, Integer state, String startTime, String endTime);
|
| | | |
| | | |
| | | /**
|
| | | * 上级查询
|
| | | * @param start
|
| | | * @param count
|
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public List<ThreeSale> listSuperiorQuery(long start, int count, Integer state, Long uid);
|
| | | |
| | | public long countSuperiorQuery(Integer state, Long uid);
|
| | | |
| | | }
|