fanli/src/main/java/com/yeshi/fanli/controller/client/UserInfoController.java
@@ -50,6 +50,7 @@ import com.yeshi.fanli.entity.bus.user.PassWordErrorRecord; import com.yeshi.fanli.entity.bus.user.SMSHistory; import com.yeshi.fanli.entity.bus.user.ThreeSale; import com.yeshi.fanli.entity.bus.user.ThreeSaleExtraInfo; import com.yeshi.fanli.entity.bus.user.UserActiveLog; import com.yeshi.fanli.entity.bus.user.UserInfo; import com.yeshi.fanli.entity.bus.user.WeiXinUser; @@ -65,6 +66,7 @@ import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService; import com.yeshi.fanli.service.inter.hongbao.HongBaoMessageService; import com.yeshi.fanli.service.inter.hongbao.HongBaoService; import com.yeshi.fanli.service.inter.hongbao.ThreeSaleExtraInfoSerivce; import com.yeshi.fanli.service.inter.hongbao.ThreeSaleSerivce; import com.yeshi.fanli.service.inter.order.LostOrderService; import com.yeshi.fanli.service.inter.order.OrderItemServcie; @@ -132,6 +134,9 @@ @Resource private ThreeSaleSerivce threeSaleSerivce; @Resource private ThreeSaleExtraInfoSerivce threeSaleExtraInfoSerivce; @Resource private LostOrderService lostOrderService; @@ -1592,7 +1597,7 @@ * @param id * @param out */ @RequestMapping(value = "getMyTeam") @RequestMapping(value = "getMyTeam", method = RequestMethod.POST) public void getMyTeam(AcceptData acceptData, long page, long uid, long type, PrintWriter out) { int pageSize = Constant.PAGE_SIZE; @@ -1602,23 +1607,7 @@ resultData = threeSaleSerivce.getMyFirstTeam((page - 1) * pageSize, pageSize, uid); } else if (type == 2) { resultData = threeSaleSerivce.getMySecondTeam((page - 1) * pageSize, pageSize, uid); } else if (type == 3) { ThreeSale threeSale = threeSaleSerivce.getMyBoss(uid); if (threeSale != null) { UserInfo boss = threeSale.getBoss(); if (boss != null) { resultData.put("nickName", boss.getNickName()); resultData.put("portrait", boss.getPortrait()); } SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Long createTime = threeSale.getCreateTime(); Date inviteTime = new Date(createTime); resultData.put("inviteTime", "邀请时间:" + sdf.format(inviteTime)); } } } out.print(JsonUtil.loadTrueResult(resultData)); } @@ -1629,7 +1618,7 @@ * @param id * @param out */ @RequestMapping(value = "countMyTeam") @RequestMapping(value = "countMyTeam", method = RequestMethod.POST) public void countMyTeam(AcceptData acceptData, long uid, PrintWriter out) { long firstTeam = threeSaleSerivce.countFirstTeam(uid, 1); @@ -1638,14 +1627,109 @@ long secondTeam = threeSaleSerivce.countSecondTeam(uid, 1); long secondTeamTotal = threeSaleSerivce.countSecondTeam(uid, null); JSONObject bossData = new JSONObject(); ThreeSale threeSale = threeSaleSerivce.getMyBoss(uid); if (threeSale != null) { UserInfo boss = threeSale.getBoss(); if (boss != null) { bossData.put("nickName", boss.getNickName()); bossData.put("portrait", boss.getPortrait()); } SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd"); Long createTime = threeSale.getCreateTime(); Date inviteTime = new Date(createTime); bossData.put("inviteTime", "邀请时间: " + sdf.format(inviteTime)); } JSONObject resultData = new JSONObject(); resultData.put("firstTeam", firstTeam); resultData.put("firstTeamTotal", firstTeamTotal); resultData.put("secondTeam", secondTeam); resultData.put("secondTeamTotal", secondTeamTotal); resultData.put("boss", bossData); out.print(JsonUtil.loadTrueResult(resultData)); } /** * 用户队员信息保存 1.4.1 * @param acceptData * @param uid * @param inviteId 邀请id * @param nickname * @param out */ @RequestMapping(value = "setextrainfo", method = RequestMethod.POST) public void setExtraInfo(AcceptData acceptData, long uid, long inviteId, String nickname, PrintWriter out) { List<ThreeSale> listThreeSale = threeSaleSerivce.listbyIdAndBossId(inviteId, uid, null); if (listThreeSale == null || listThreeSale.size() == 0) { out.print(JsonUtil.loadFalseResult("该记录不存在")); return; } UserInfo worker = listThreeSale.get(0).getWorker(); if (worker == null) { out.print(JsonUtil.loadFalseResult("该记录不存在")); return; } List<ThreeSaleExtraInfo> list = threeSaleExtraInfoSerivce.listbyBossIdAndWorkerId(uid, worker.getId()); if (list == null || list.size() == 0) { ThreeSaleExtraInfo extraInfo = new ThreeSaleExtraInfo(); extraInfo.setWorker(worker); extraInfo.setNickname(nickname); extraInfo.setCreateTime(new Date()); extraInfo.setUpdateTime(new Date()); UserInfo boss = new UserInfo(uid); extraInfo.setBoss(boss); threeSaleExtraInfoSerivce.insert(extraInfo); } else { ThreeSaleExtraInfo extraInfo = list.get(0); extraInfo.setNickname(nickname); extraInfo.setUpdateTime(new Date()); threeSaleExtraInfoSerivce.updateByPrimaryKey(extraInfo); } out.print(JsonUtil.loadTrueResult("修改成功")); } /** * 删除队员关系 * @param acceptData * @param uid * @param inviteId 邀请id * @param out */ @RequestMapping(value = "removethreesale", method = RequestMethod.POST) public void removethreesale(AcceptData acceptData, long uid, long inviteId, PrintWriter out) { List<ThreeSale> listThreeSale = threeSaleSerivce.listbyIdAndBossId(inviteId, uid, 1); if (listThreeSale == null || listThreeSale.size() == 0) { out.print(JsonUtil.loadFalseResult("操作失败")); return; } UserInfo worker = listThreeSale.get(0).getWorker(); if (worker == null) { out.print(JsonUtil.loadFalseResult("操作失败")); return; } // 删除关系 threeSaleSerivce.deleteByPrimaryKey(inviteId); // 删除备注 threeSaleExtraInfoSerivce.deleteByBossIdAndWorkerId(uid, worker.getId()); out.print(JsonUtil.loadTrueResult("操作成功")); } } fanli/src/main/java/com/yeshi/fanli/dao/mybatis/ThreeSaleExtraInfoMapper.java
@@ -1,5 +1,9 @@ package com.yeshi.fanli.dao.mybatis; import java.util.List; import org.apache.ibatis.annotations.Param; import com.yeshi.fanli.entity.bus.user.ThreeSaleExtraInfo; public interface ThreeSaleExtraInfoMapper { @@ -15,4 +19,21 @@ int updateByPrimaryKeySelective(ThreeSaleExtraInfo record); int updateByPrimaryKey(ThreeSaleExtraInfo record); /** * 根据用户id、被邀请id 查询 * @param bossId * @param workerId * @return */ List<ThreeSaleExtraInfo> listbyBossIdAndWorkerId(@Param("bossId") Long bossId, @Param("workerId") Long workerId); /** * 根据用户id、被邀请id删除 * @param bossId * @param workerId * @return */ int deleteByBossIdAndWorkerId(@Param("bossId") Long bossId, @Param("workerId") Long workerId); } fanli/src/main/java/com/yeshi/fanli/dao/mybatis/ThreeSaleMapper.java
@@ -165,4 +165,12 @@ */ ThreeSale getMyBoss(@Param("uid") Long uid); /** * 根据id、uid查询 * @param id * @param uid * @return */ List<ThreeSale> listbyIdAndBossId(@Param("id")Long id, @Param("uid") Long uid, @Param("expire") Integer expire); } fanli/src/main/java/com/yeshi/fanli/mapping/ThreeSaleExtraInfoMapper.xml
@@ -51,4 +51,15 @@ <if test="updateTime != null">tf_updatetime=#{updateTime,jdbcType=TIMESTAMP},</if> </set> where tf_id = #{id,jdbcType=BIGINT} </update> <select id="listbyBossIdAndWorkerId" resultMap="BaseResultMap"> SELECT * FROM `yeshi_ec_threesale_extra_info` t WHERE t.`tf_boss_id` = #{bossId} AND t.`tf_worker_id`= #{workerId} </select> <delete id="deleteByBossIdAndWorkerId" parameterType="java.lang.Long"> delete from yeshi_ec_threesale_extra_info t WHERE t.`tf_boss_id` = #{bossId} AND t.`tf_worker_id`= #{workerId} </delete> </mapper> fanli/src/main/java/com/yeshi/fanli/mapping/ThreeSaleMapper.xml
@@ -129,9 +129,10 @@ <update id="effectThreeSale" parameterType="java.lang.Long"> update yeshi_ec_threeSale t set t.state=1 where t.state=0 and t.worker_id=#{0} AND (t.expire = 0 OR t.expire IS NULL) update yeshi_ec_threeSale t set t.state=1, t.succeedTime = <![CDATA[UNIX_TIMESTAMP(CURRENT_TIMESTAMP()) * 1000]]>, t.updateTime = <![CDATA[UNIX_TIMESTAMP(CURRENT_TIMESTAMP()) * 1000]]> where t.state=0 and t.worker_id=#{0} AND (t.expire = 0 OR t.expire IS NULL) </update> <!-- 查询一度队员集合 --> @@ -197,7 +198,7 @@ <update id="updateExpire" parameterType="java.lang.Long"> update yeshi_ec_threeSale t set t.expire = 1 set t.expire = 1, t.updateTime = <![CDATA[UNIX_TIMESTAMP(CURRENT_TIMESTAMP()) * 1000]]> where t.`id` IN <foreach item="item" collection="list" open="(" separator="," close=")">#{item}</foreach> </update> @@ -343,6 +344,7 @@ ON ts.`boss_id` = ff.`tf_boss_id` AND ts.`worker_id` = ff.`tf_worker_id` WHERE ts.`boss_id` = #{uid} ORDER BY ts.state DESC, ts.expire, ts.succeedTime DESC LIMIT ${start},${count} </select> <select id="countFirstTeam" resultType="java.lang.Long"> @@ -382,4 +384,14 @@ select <include refid="Base_Column_List" /> from yeshi_ec_threeSale where state = 1 and worker_id=#{uid} </select> <select id="listbyIdAndBossId" resultMap="BaseResultMap"> SELECT <include refid="Base_Column_List" /> FROM yeshi_ec_threeSale WHERE id = #{uid} AND boss_id=#{uid} <if test="expire != null and expire == 1"> AND `expire` = 1 <!-- 失效 --> </if> </select> </mapper> fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/ThreeSaleExtraInfoSerivceImpl.java
@@ -1,5 +1,7 @@ package com.yeshi.fanli.service.impl.hongbao; import java.util.List; import javax.annotation.Resource; import org.springframework.stereotype.Service; @@ -45,6 +47,16 @@ } @Override public List<ThreeSaleExtraInfo> listbyBossIdAndWorkerId(Long bossId, Long workerId) { return threeSaleExtraInfoMapper.listbyBossIdAndWorkerId(bossId, workerId); } @Override public int deleteByBossIdAndWorkerId(Long bossId, Long workerId) { return threeSaleExtraInfoMapper.deleteByBossIdAndWorkerId(bossId, workerId); } fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/ThreeSaleSerivceImpl.java
@@ -377,6 +377,17 @@ return threeSaleMapper.getMyBoss(uid); } @Override public ThreeSale selectByPrimaryKey(Long id) { return threeSaleMapper.selectByPrimaryKey(id); } @Override public List<ThreeSale> listbyIdAndBossId(Long id, Long uid, Integer expire) { return threeSaleMapper.listbyIdAndBossId(id, uid, expire); } @Override public JSONObject getMyFirstTeam(long start, int count, Long uid) { @@ -412,18 +423,38 @@ JSONArray resultArray = new JSONArray(); for (ThreeSale threeSale: list) { JSONObject object = new JSONObject(); SimpleDateFormat sdf = new SimpleDateFormat("MM.dd HH:mm"); SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd HH:mm"); SimpleDateFormat formatYears = new SimpleDateFormat("yyyy"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date todayTime = new Date(); // 邀请id object.put("inviteId", threeSale.getId()); Long createTime = threeSale.getCreateTime(); Date inviteTime = new Date(createTime); object.put("inviteTime", sdf.format(inviteTime) + "加入"); String nickName = null; if (formatYears.format(todayTime).equals(formatYears.format(inviteTime))) { // 本年 object.put("inviteTime", sdf.format(inviteTime) + " 加入"); } else { // 往年 object.put("inviteTime", format.format(inviteTime) + " 加入"); } String memoName = ""; ThreeSaleExtraInfo threeSaleExtraInfo = threeSale.getThreeSaleExtraInfo(); if (threeSaleExtraInfo != null) { if (!StringUtil.isNullOrEmpty(threeSaleExtraInfo.getNickname())) { memoName = threeSaleExtraInfo.getNickname(); } } object.put("memoName", memoName); String nickName = ""; String portrait = ""; Long lastLoginTime = null; String portrait = null; Long workerId = null; UserInfo worker = threeSale.getWorker(); @@ -433,7 +464,7 @@ lastLoginTime = worker.getLastLoginTime(); nickName = worker.getNickName(); } object.put("nickName", nickName); object.put("workerId", workerId); object.put("portrait", portrait); @@ -450,7 +481,7 @@ JSONArray array1 = new JSONArray(); array1.add(fontColor1); array1.add("最近登陆" + sdf.format(lastLoginTime)); array1.add("最近登陆 " + sdf.format(lastLoginTime)); array.add(array1); @@ -467,7 +498,7 @@ Calendar c = Calendar.getInstance(); c.setTime(inviteTime); c.add(Calendar.DAY_OF_MONTH, 60);// 邀请不超过60天 Date todayTime = new Date(); long days = (c.getTimeInMillis() -todayTime.getTime()) / (1000*3600*24); if (days < 0) { @@ -480,7 +511,7 @@ JSONArray array2 = new JSONArray(); array2.add(fontColor2); array2.add(days+"天 "); array2.add(days+"天"); JSONArray array3 = new JSONArray(); array3.add(fontColor1); @@ -493,15 +524,6 @@ object.put("type", type); object.put("recentMsg", array); ThreeSaleExtraInfo threeSaleExtraInfo = threeSale.getThreeSaleExtraInfo(); if (threeSaleExtraInfo != null) { if (!StringUtil.isNullOrEmpty(threeSaleExtraInfo.getNickname())) { nickName = threeSaleExtraInfo.getNickname(); } } object.put("nickName", nickName); resultArray.add(object); } fanli/src/main/java/com/yeshi/fanli/service/inter/hongbao/ThreeSaleExtraInfoSerivce.java
@@ -1,5 +1,7 @@ package com.yeshi.fanli.service.inter.hongbao; import java.util.List; import com.yeshi.fanli.entity.bus.user.ThreeSaleExtraInfo; public interface ThreeSaleExtraInfoSerivce { @@ -14,4 +16,20 @@ public int updateByPrimaryKeySelective(ThreeSaleExtraInfo record); public int updateByPrimaryKey(ThreeSaleExtraInfo record); /** * 根据用户id、被邀请id 查询 * @param bossId * @param workerId * @return */ public List<ThreeSaleExtraInfo> listbyBossIdAndWorkerId(Long bossId, Long workerId); /** * 根据用户id、被邀请id删除 * @param bossId * @param workerId * @return */ public int deleteByBossIdAndWorkerId(Long bossId, Long workerId); } fanli/src/main/java/com/yeshi/fanli/service/inter/hongbao/ThreeSaleSerivce.java
@@ -212,4 +212,15 @@ */ public ThreeSale getMyBoss(Long uid); public ThreeSale selectByPrimaryKey(Long id); /** * 查询队员记录 id+uid * @param id * @param uid * @param expire 是否失效状态 * @return */ public List<ThreeSale> listbyIdAndBossId(Long id, Long uid, Integer expire); }