Commit 565b5aaf authored by 周健威's avatar 周健威

Merge remote-tracking branch 'origin/dev' into dev

parents 39f3ac4a 0ef9993a
......@@ -135,9 +135,11 @@ public class AuthController {
return appAuthService.checkBindWechat(username);
}
@RequestMapping(value = "/wxlogin", method = RequestMethod.POST)
public JSONObject wxlogin(@RequestParam(value="openid",defaultValue="")String openid,@RequestParam(value="isQQ",defaultValue="0")Integer isQQ)throws Exception{
public JSONObject wxlogin(@RequestParam(value="openid",defaultValue="")String openid,
@RequestParam(value="isQQ",defaultValue="0")Integer isQQ,
@RequestParam(value="code",defaultValue="")String code)throws Exception{
log.info(openid+"----require wxlogin...");
JSONObject data=appAuthService.wxlogin(openid,isQQ);
JSONObject data=appAuthService.wxlogin(openid,isQQ,code);
if(data!=null&&data.getInteger("status")== ResultCode.SUCCESS_CODE){
JSONObject result=data.getJSONObject("data");
if(result==null){
......@@ -154,10 +156,11 @@ public class AuthController {
public JSONObject login(@RequestParam(value="username",defaultValue="")String username,
@RequestParam(value="mobilecode",defaultValue="")String mobilecode,
@RequestParam(value="password",defaultValue="")String password,
@RequestParam(value="type",defaultValue="1")Integer type)throws Exception{
@RequestParam(value="type",defaultValue="1")Integer type,
@RequestParam(value="code",defaultValue="")String code)throws Exception{
log.info(username+"----require login...");
JSONObject data=appAuthService.tlogin(username,password,mobilecode,type);
JSONObject data=appAuthService.tlogin(username,password,mobilecode,type,code);
if(data!=null&&data.getInteger("status")== ResultCode.SUCCESS_CODE){
JSONObject result=data.getJSONObject("data");
if(result==null){
......
......@@ -42,12 +42,15 @@ public interface IUserService {
@RequestMapping(value = "/api/app/user/checkBindWechat",method = RequestMethod.POST)
public JSONObject checkBindWechat( @RequestParam(value="username")String username);
@RequestMapping(value = "/api/app/user/wxlogin",method = RequestMethod.POST)
public JSONObject wxlogin(@RequestParam(value="openid")String openid,@RequestParam(value="isQQ")Integer isQQ);
public JSONObject wxlogin(@RequestParam(value="openid")String openid,
@RequestParam(value="isQQ")Integer isQQ,
@RequestParam(value="code",defaultValue="")String code);
@RequestMapping(value = "/api/app/user/login", method = RequestMethod.POST)
public JSONObject login( @RequestParam(value="username")String username,
@RequestParam(value="password")String password,
@RequestParam(value="mobilecode")String mobilecode,
@RequestParam(value="type")Integer type);
@RequestParam(value="type")Integer type,
@RequestParam(value="")String code);
@RequestMapping(value = "/api/app/user/reset", method = RequestMethod.POST)
public JSONObject reset( @RequestParam(value="username")String username,
@RequestParam(value="mobilecode")String mobilecode,
......
......@@ -15,8 +15,8 @@ public interface AuthService {
JSONObject register(String username, String mobilecode, String password,String code) throws Exception;
JSONObject wxregister( String username, String mobilecode, String password, String nickname, String headimgurl, String openid, String unionid, Integer type,Integer isQQ,String code) throws Exception;
JSONObject checkBindWechat(String username) throws Exception;
JSONObject wxlogin(String openid,Integer isQQ) throws Exception;
JSONObject tlogin(String username, String password,String mobilecode,Integer type) throws Exception;
JSONObject wxlogin(String openid,Integer isQQ,String code) throws Exception;
JSONObject tlogin(String username, String password,String mobilecode,Integer type,String code) throws Exception;
String getToken(String username,Integer id) throws Exception;
JSONObject reset(String username, String mobilecode, String password) throws Exception;
......
......@@ -84,13 +84,13 @@ public class AppAuthServiceImpl implements AuthService {
}
@Override
public JSONObject wxlogin(String openid,Integer isQQ) throws Exception {
return userService.wxlogin(openid,isQQ);
public JSONObject wxlogin(String openid,Integer isQQ,String code) throws Exception {
return userService.wxlogin(openid,isQQ,code);
}
@Override
public JSONObject tlogin(String username, String password, String mobilecode, Integer type) throws Exception {
return userService.login(username,password,mobilecode,type);
public JSONObject tlogin(String username, String password, String mobilecode, Integer type,String code) throws Exception {
return userService.login(username,password,mobilecode,type,code);
}
@Override
......
......@@ -82,13 +82,13 @@ public class AuthServiceImpl implements AuthService {
}
@Override
public JSONObject wxlogin(String openid,Integer isQQ) throws Exception {
return userService.wxlogin(openid,isQQ);
public JSONObject wxlogin(String openid,Integer isQQ,String code) throws Exception {
return userService.wxlogin(openid,isQQ,code);
}
@Override
public JSONObject tlogin(String username, String password, String mobilecode, Integer type) throws Exception {
return userService.login(username,password,mobilecode,type);
public JSONObject tlogin(String username, String password, String mobilecode, Integer type,String code) throws Exception {
return userService.login(username,password,mobilecode,type,code);
}
@Override
......
......@@ -16,4 +16,6 @@ public class UserIncomeBo {
private Integer userId;
private BigDecimal income;
private Long leagueTime;
}
......@@ -25,7 +25,10 @@ public class UserTeamMemberBo {
* 用户名
*/
private String userName;
/**
* 真实名称
*/
private String realName;
/**
* 昵称
*/
......
......@@ -30,6 +30,8 @@ public class AppUserPositionTempVo {
@ApiModelProperty(value = "职位名")
private String positionName;
private Integer positionId;
@ApiModelProperty(value = "数据状态 1:已核销 2:未核销")
private Integer status;
......
......@@ -103,11 +103,13 @@ public class AppUserPositionTempBiz extends BaseBiz<AppUserPositionTempMapper, A
if (StringUtils.isNotEmpty(appUserPositionTempFindDTO.getPhone())) {
criteria.andEqualTo("phone", appUserPositionTempFindDTO.getPhone());
}
if (DataStatus.USERED.code == appUserPositionTempFindDTO.getStatus()) {
criteria.andIsNotNull("userId");
}
if (DataStatus.NO_USERED.code == appUserPositionTempFindDTO.getStatus()) {
criteria.andIsNull("userId");
if(Objects.nonNull(appUserPositionTempFindDTO.getStatus())) {
if (DataStatus.USERED.code == appUserPositionTempFindDTO.getStatus()) {
criteria.andIsNotNull("userId");
}
if (DataStatus.NO_USERED.code == appUserPositionTempFindDTO.getStatus()) {
criteria.andIsNull("userId");
}
}
PageDataVO<AppUserPositionTemp> pageDataVO = PageDataVO.pageInfo(appUserPositionTempFindDTO.getPage(), appUserPositionTempFindDTO.getLimit(), () -> mapper.selectByExample(example));
List<AppUserPositionTemp> data = pageDataVO.getData();
......@@ -129,6 +131,7 @@ public class AppUserPositionTempBiz extends BaseBiz<AppUserPositionTempMapper, A
String postionName = postionMap == null ? "" : postionMap.get(appUserPositionTemp.getPositionId()).getName();
appUserPositionTempVo.setPositionName(postionName);
appUserPositionTempVo.setStatus(appUserPositionTemp.getUserId() == null ? DataStatus.NO_USERED.code : DataStatus.USERED.code);
appUserPositionTempVos.add(appUserPositionTempVo);
}
dataVO.setData(appUserPositionTempVos);
......
......@@ -242,8 +242,8 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper,AppUserRel
return AopContext.currentProxy() != null ? (AppUserRelationBiz) AopContext.currentProxy() : this;
}
public PageDataVO<AppUserRelation> findMemberPageByLeaderId(Integer leaderId, Integer pageNo, Integer pageSize) {
return PageDataVO.pageInfo(pageNo, pageSize, () -> mapper.selectByLeaderId(leaderId));
public List<AppUserRelation> findMemberPageByLeaderId(Integer leaderId) {
return mapper.selectByLeaderId(leaderId);
}
public InviteMemberVo findInviteMemberByActivitState(Integer leaderId, Integer state, Integer page, Integer limit) {
......
......@@ -271,13 +271,8 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A
}
public Map<Integer, BigDecimal> findMemberIdAndIncomeMapByMemberIds(List<Integer> memberIds) {
Map<Integer, BigDecimal> memberIdAndIncomeMap = new HashMap<>();
List<UserIncomeBo> userIncomeBos = mapper.accquireIncomeByMemberIds(memberIds);
if (CollectionUtils.isNotEmpty(userIncomeBos)) {
memberIdAndIncomeMap = userIncomeBos.stream().collect(Collectors.toMap(UserIncomeBo::getUserId, userIncomeBo -> userIncomeBo.getIncome() == null ? new BigDecimal(0) : userIncomeBo.getIncome()));
}
return memberIdAndIncomeMap;
public PageDataVO<UserIncomeBo> findMemberIdAndIncomeMapByMemberIds(Integer parentId,Integer pageNo,Integer pageSize) {
return PageDataVO.pageInfo(pageNo,pageSize,()->mapper.accquireIncomeByMemberIds(parentId));
}
public SellingWalletPagVo findSellingWaterPageByWaiting(Integer waiting, Integer userId, Integer pageNo, Integer pageSize) {
......
package com.github.wxiaoqi.security.admin.biz;
import com.github.wxiaoqi.security.admin.bo.PromoteBO;
import com.github.wxiaoqi.security.admin.bo.UserIncomeBo;
import com.github.wxiaoqi.security.admin.bo.UserTeamMemberBo;
import com.github.wxiaoqi.security.admin.entity.AppUserDetail;
import com.github.wxiaoqi.security.admin.entity.AppUserLogin;
......@@ -14,6 +15,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
......@@ -40,12 +42,11 @@ public class UserBusinessBiz {
public UserTeamMemberVo findTeamMemberPageByUserId(Integer userId, Integer pageNo, Integer pageSize) {
UserTeamMemberVo userTeamMemberVo = new UserTeamMemberVo();
//根据用户id去关系表里查询下级
PageDataVO<AppUserRelation> memberPage = appUserRelationBiz.findMemberPageByLeaderId(userId, pageNo, pageSize);
UserTeamMemberVo userTeamMemberVo = new UserTeamMemberVo();
List<AppUserRelation> teamMemberBos = memberPage.getData();
if (CollectionUtils.isEmpty(teamMemberBos)) {
PageDataVO<UserIncomeBo> dataVO = appUserSellingWaterBiz.findMemberIdAndIncomeMapByMemberIds(userId, pageNo, pageSize);
List<UserIncomeBo> data = dataVO.getData();
if (CollectionUtils.isEmpty(data)) {
userTeamMemberVo.setPageNum(pageNo);
userTeamMemberVo.setPageSize(pageSize);
userTeamMemberVo.setTotalIncome(new BigDecimal(0));
......@@ -53,63 +54,61 @@ public class UserBusinessBiz {
return userTeamMemberVo;
}
List<Integer> memberIds = teamMemberBos.stream().map(team -> team.getUserId()).collect(Collectors.toList());
Map<Integer, BigDecimal> memberIdAndIncomeMap = appUserSellingWaterBiz.findMemberIdAndIncomeMapByMemberIds(memberIds);
if (memberIdAndIncomeMap == null) {
return userTeamMemberVo;
}
Map<Integer,AppUserLogin> userIdAndAppUserLoginMap = appUserLoginBiz.findUserIdAndUserLoginMapByMemberIds(memberIds);
Map<Integer, AppUserDetail> userIdAndAppUserDetailMap = appUserDetailBiz.findUserIdAndUserDetailMapByMemberIds(memberIds);
Map<Integer, UserIncomeBo> userIdAndIncomMap = data.stream().collect(Collectors.toMap(UserIncomeBo::getUserId, Function.identity()));
List<Integer> memberIds = data.stream().map(UserIncomeBo::getUserId).collect(Collectors.toList());
Map<Integer, AppUserLogin> userIdAndAppUserLoginMap = appUserLoginBiz.findUserIdAndUserLoginMapByMemberIds(memberIds);
Map<Integer, AppUserDetail> userIdAndAppUserDetailMap = appUserDetailBiz.findUserIdAndUserDetailMapByMemberIds(memberIds);
List<UserTeamMemberBo> userTeamMemberBos = new ArrayList<>();
UserTeamMemberBo userTeamMemberBo;
BigDecimal totalIncome = new BigDecimal(0);
for (AppUserRelation appUserRelation : teamMemberBos) {
for (Integer memberId : memberIds) {
userTeamMemberBo = new UserTeamMemberBo();
userTeamMemberBo.setLeagueTime(appUserRelation.getBindTime());
userTeamMemberBo.setUserId(appUserRelation.getUserId());
userTeamMemberBo.setLeagueTime(userIdAndIncomMap.get(memberId).getLeagueTime());
userTeamMemberBo.setUserId(memberId);
if (userIdAndAppUserLoginMap!=null){
AppUserLogin appUserLogin = userIdAndAppUserLoginMap.get(appUserRelation.getUserId());
if (appUserLogin==null){
if (userIdAndAppUserLoginMap != null) {
AppUserLogin appUserLogin = userIdAndAppUserLoginMap.get(memberId);
if (appUserLogin == null) {
continue;
}
userTeamMemberBo.setUserName(appUserLogin.getUsername());
}
if (userIdAndAppUserDetailMap!=null){
AppUserDetail appUserDetail = userIdAndAppUserDetailMap.get(appUserRelation.getUserId());
userTeamMemberBo.setHeadUrl(appUserDetail==null?"":appUserDetail.getHeadimgurl());
userTeamMemberBo.setNickName(appUserDetail==null?"":appUserDetail.getNickname());
if (userIdAndAppUserDetailMap != null) {
AppUserDetail appUserDetail = userIdAndAppUserDetailMap.get(memberId);
userTeamMemberBo.setHeadUrl(appUserDetail == null ? "" : appUserDetail.getHeadimgurl());
userTeamMemberBo.setNickName(appUserDetail == null ? "" : appUserDetail.getNickname());
userTeamMemberBo.setRealName(appUserDetail == null ? "" : appUserDetail.getRealname());
}
BigDecimal income=memberIdAndIncomeMap.get(appUserRelation.getUserId())==null?new BigDecimal(0):memberIdAndIncomeMap.get(appUserRelation.getUserId());
BigDecimal income = userIdAndIncomMap.get(memberId).getIncome() == null ? new BigDecimal(0) : userIdAndIncomMap.get(memberId).getIncome();
userTeamMemberBo.setIncome(income);
totalIncome = totalIncome.add(income);
userTeamMemberBos.add(userTeamMemberBo);
}
userTeamMemberVo.setPageNum(memberPage.getPageNum());
userTeamMemberVo.setPageSize(memberPage.getPageSize());
userTeamMemberVo.setTotalCount(memberPage.getTotalCount().intValue());
userTeamMemberVo.setTotalPage(memberPage.getTotalPage());
userTeamMemberBos.sort(Comparator.comparing(UserTeamMemberBo::getIncome).reversed());
userTeamMemberVo.setPageNum(dataVO.getPageNum());
userTeamMemberVo.setPageSize(dataVO.getPageSize());
userTeamMemberVo.setTotalCount(dataVO.getTotalCount().intValue());
userTeamMemberVo.setTotalPage(dataVO.getTotalPage());
userTeamMemberVo.setUserTeamMemberBos(userTeamMemberBos);
userTeamMemberVo.setTotalIncome(totalIncome);
return userTeamMemberVo;
}
public PromoteBO getPromoteBoByUserId(Integer userId) {
public PromoteBO getPromoteBoByUserId(Integer userId) {
PromoteBO promoteBO = new PromoteBO();
Integer leaderId = appUserRelationBiz.findLeaderIdByMemberId(userId);
Map<Integer,Integer> memberStateAndCountMap = appUserRelationBiz.findMemberSateAndCountMapByLeaderId(userId);
Integer leaderId = appUserRelationBiz.findLeaderIdByMemberId(userId);
Map<Integer, Integer> memberStateAndCountMap = appUserRelationBiz.findMemberSateAndCountMapByLeaderId(userId);
if (leaderId != 0) {
Map<Integer, AppUserLogin> userIdAndUserLoginMap = appUserLoginBiz.findUserIdAndUserLoginMapByMemberIds(Arrays.asList(leaderId));
Map<Integer, AppUserDetail> userIdAndUserDetailMap = appUserDetailBiz.findUserIdAndUserDetailMapByMemberIds(Arrays.asList(leaderId));
if (!userIdAndUserLoginMap.isEmpty()){
if (!userIdAndUserLoginMap.isEmpty()) {
promoteBO.setLeaderUsername(userIdAndUserLoginMap.get(leaderId).getUsername());
}
if (!userIdAndUserDetailMap.isEmpty()){
if (!userIdAndUserDetailMap.isEmpty()) {
promoteBO.setLeaderHeadUrl(userIdAndUserDetailMap.get(leaderId).getHeadimgurl());
}
}
......@@ -117,7 +116,7 @@ public class UserBusinessBiz {
promoteBO.setActivatedNumber(memberStateAndCountMap.get(1));
BigDecimal totalIncome = appUserSellingWaterBiz.selectTotalIncomeByUserId(userId);
promoteBO.setTotalIncome(totalIncome==null?new BigDecimal(0):totalIncome);
promoteBO.setTotalIncome(totalIncome == null ? new BigDecimal(0) : totalIncome);
return promoteBO;
}
}
......@@ -17,7 +17,7 @@ import java.util.List;
*/
public interface AppUserSellingWaterMapper extends Mapper<AppUserSellingWater> {
List<UserIncomeBo> accquireIncomeByMemberIds(@Param("memberIds") List<Integer> memberIds);
List<UserIncomeBo> accquireIncomeByMemberIds(@Param("parentId") Integer parentId);
BigDecimal selectTotalIncomeByUserId(@Param("userId") Integer userId);
}
......@@ -316,8 +316,8 @@ public class AppPermissionService {
}*/
//临时会员绑定
insertUserMemberByUserIdAndPhone(userid, username);
/*//参加新人活动
jionActivity(userid);*/
//参加新人活动
jionActivity(userid);
//创建钱包
walletBiz.createWalletByUserId(appUserLogin.getId());
// 登录结果要做做统一处理
......@@ -950,8 +950,8 @@ public class AppPermissionService {
relationBiz.bindByUserId(userid, small_id);
//发送短信通知用户
thirdFeign.sendCode(username, password, SystemConfig.TEMPLATECODE);
/* //参加新人活动
jionActivity(userid);*/
//参加新人活动
jionActivity(userid);
// 登录结果要做做统一处理
JSONObject data = autoLogin(userid, username, headimgurl, nickname,null,null,2);
// 到im注册,获取返回结果
......
......@@ -4,19 +4,24 @@
<select id="accquireIncomeByMemberIds" resultType="com.github.wxiaoqi.security.admin.bo.UserIncomeBo">
SELECT DISTINCT
`source_id`as userId,
IFNULL((( SELECT SUM(commission) FROM `app_user_selling_water` WHERE source_id=ausw.source_id AND `status` = 0 AND
`waiting` = 1 )
- ( SELECT SUM(commission) FROM `app_user_selling_water` WHERE source_id=ausw.source_id AND `status` = 1 AND
`waiting` = 1 )),0) as `income`
FROM
`app_user_selling_water` as ausw
WHERE
source_id in
<foreach collection="memberIds" item="memberId" open="(" close=")" separator=",">
#{memberId}
</foreach>
SELECT
aur.user_id,
aur.bind_time as `leagueTime`,
ausww.income
FROM
`app_user_relation` AS `aur`
LEFT JOIN (SELECT DISTINCT
`source_id` AS userId,
IFNULL(
(
( SELECT SUM( commission ) FROM `app_user_selling_water` WHERE source_id = ausw.source_id AND `status` = 0 AND `waiting` = 1 ) - ( SELECT SUM( commission ) FROM `app_user_selling_water` WHERE source_id = ausw.source_id AND `status` = 1 AND `waiting` = 1 )
),
0
) AS `income`
FROM
`app_user_selling_water` AS ausw) AS ausww ON ausww.userId=aur.user_id
WHERE aur.parent_id=#{parentId}
ORDER BY ausww.`income` DESC
</select>
<select id="selectTotalIncomeByUserId" resultType="java.math.BigDecimal">
......
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