...
|
...
|
@@ -18,6 +18,8 @@ import java.util.stream.Collectors; |
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
import com.yoho.service.model.response.UserInfoRspBO;
|
|
|
import com.yoho.unions.helper.UserServiceHelper;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.elasticsearch.common.collect.Maps;
|
...
|
...
|
@@ -155,6 +157,9 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
|
private ConfigReader configReader;
|
|
|
|
|
|
@Autowired
|
|
|
private UserServiceHelper userServiceHelper;
|
|
|
|
|
|
@Autowired
|
|
|
private RedisHashCache redisHashCache;
|
|
|
|
|
|
private AtomicInteger atomicInt = new AtomicInteger(0);
|
...
|
...
|
@@ -1099,17 +1104,40 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
|
*/
|
|
|
@Override
|
|
|
public UninoShareIncomeRankBo queryRank(UninoShareIncomeRankReqBo req){
|
|
|
//查询排行榜
|
|
|
UninoShareIncomeRankBo result = new UninoShareIncomeRankBo();
|
|
|
//todo 查询排行榜
|
|
|
PageResponseBO<UninoShareIncomeBo> rankList = getRankList(req);
|
|
|
result.setRankList(rankList);
|
|
|
if (req.getUid() != null) {
|
|
|
//需要查询用户的数据
|
|
|
//todo 需要查询用户的数据
|
|
|
if (req.getDate() != null) {
|
|
|
BigDecimal amount = unionShareOrdersMonthMapper.selectAmountByUid(Integer.valueOf(req.getDate()), req.getUid(), 1);
|
|
|
if (amount == null) {
|
|
|
amount = new BigDecimal(0);
|
|
|
}
|
|
|
result.setAmount(amount);
|
|
|
DecimalFormat df = new DecimalFormat("0.00");
|
|
|
result.setAmountStr("¥"+df.format(result.getAmount()));
|
|
|
//todo result.setRankNum();
|
|
|
UserInfoRspBO userInfoRspBO = userServiceHelper.getUserInfoFromUic(req.getUid());
|
|
|
if (userInfoRspBO != null) {
|
|
|
result.setImage(userInfoRspBO.getHeadIco());
|
|
|
result.setNickname(userInfoRspBO.getNickname());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return null;
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
//获取排行榜数据
|
|
|
//todo 获取排行榜数据
|
|
|
private PageResponseBO<UninoShareIncomeBo> getRankList(UninoShareIncomeRankReqBo req) {
|
|
|
return null;
|
|
|
List<UninoShareIncomeBo> all = new ArrayList<>();
|
|
|
PageResponseBO<UninoShareIncomeBo> result = new PageResponseBO<>();
|
|
|
result.setPage(req.getPage());
|
|
|
result.setTotal(all.size());
|
|
|
result.setSize(req.getSize());
|
|
|
result.setList(result.getPage()>1?all.subList((result.getPage()-1)*result.getSize()+1,result.getPage()*result.getSize()):null);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
...
|
...
|
@@ -2035,8 +2063,63 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
|
* 更新联盟用户月预估收入
|
|
|
* */
|
|
|
@Override
|
|
|
public void updateMonthData(int promoteUid, Set<Integer> date){
|
|
|
@Database(ForceMaster = true)
|
|
|
public void updateMonthData(int promoteUid, Set<String> date){
|
|
|
date.forEach(d->{
|
|
|
updateOneMonthData(promoteUid, d);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
private void updateOneMonthData(int promoteUid, String date){
|
|
|
//todo
|
|
|
Integer dateInt = Integer.valueOf(date);
|
|
|
Calendar time = Calendar.getInstance();
|
|
|
time.setTime(DateUtil.stringToDate(date, "yyyyMM"));
|
|
|
int beginTime=(int) time.getTimeInMillis()/1000;
|
|
|
time.add(Calendar.DAY_OF_MONTH,1);
|
|
|
int endTime=((int) time.getTimeInMillis()/1000)-1;
|
|
|
UnionShareOrdersMonth unionShareOrdersMonth = getMonthData(promoteUid,dateInt);
|
|
|
UnionShareOrdersMonth month=unionShareOrdersMapper.selectMonthData(promoteUid, beginTime, endTime);
|
|
|
if (month == null|| month.getAmount()==null) {
|
|
|
if (unionShareOrdersMonth != null) {
|
|
|
//月预估收益清了
|
|
|
deleteMonthData(unionShareOrdersMonth.getId());
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
UserInfoRspBO userInfoRspBO = userServiceHelper.getUserInfoFromUic(promoteUid);
|
|
|
if (userInfoRspBO != null) {
|
|
|
month.setImage(userInfoRspBO.getHeadIco());
|
|
|
month.setNickname(userInfoRspBO.getNickname());
|
|
|
}
|
|
|
month.setType(1);//类型:1-联盟用户,2-马甲用户
|
|
|
month.setDate(dateInt);
|
|
|
month.setUpdateTime(DateUtil.getCurrentTimeSecond());
|
|
|
if (unionShareOrdersMonth != null) {
|
|
|
//月预估收益更新
|
|
|
int result=unionShareOrdersMonthMapper.updateByUidAndMonth(month);
|
|
|
if (result > 0) {
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
month.setCreateTime(month.getUpdateTime());
|
|
|
unionShareOrdersMonthMapper.insertSelective(month);
|
|
|
|
|
|
}
|
|
|
|
|
|
private UnionShareOrdersMonth getMonthData(int promoteUid, int date) {
|
|
|
List<UnionShareOrdersMonth> unionShareOrdersMonth = unionShareOrdersMonthMapper.selectMonthData(date, promoteUid,1);
|
|
|
if (unionShareOrdersMonth == null ) {
|
|
|
return null;
|
|
|
}
|
|
|
for (int i = 1; i < unionShareOrdersMonth.size(); i++) {
|
|
|
deleteMonthData(unionShareOrdersMonth.get(i).getId());
|
|
|
}
|
|
|
return unionShareOrdersMonth.get(0);
|
|
|
}
|
|
|
|
|
|
private void deleteMonthData(int id) {
|
|
|
unionShareOrdersMonthMapper.deleteByPrimaryKey(id);
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -2046,4 +2129,5 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport |
|
|
public void dealWithVirtualUserTask(UnionShareVirtualAddBo bo){
|
|
|
//todo
|
|
|
}
|
|
|
//todo 后台操作向redis塞待执行任务
|
|
|
} |
...
|
...
|
|