Authored by mingdan.ge

cps7期

... ... @@ -8,6 +8,7 @@ import org.slf4j.helpers.MessageFormatter;
public enum ShareOrdersKeyEnum {
ORDER_LIST("yh:union:share:orderList:","type:{}:tab:{}:status:{}:page:{}:limit:{}",600,"订单列表"),
ESTIMATE_LIST("yh:union:share:EstimateList:","type:{}:timeType:{}:page:{}:limit:{}",600,"预估收益详细列表"),
ORDER_INFO("yh:union:share:orderInfo:","key:{}:orderCode:{}",600,"订单详情"),
ACTIVITY_ORDER("yh:union:share:activityOrder:","key:{}",600,"订单详情"),
USER_SETTLEMENT("yh:union:share:userSettlement:","type:{}",600,"用户提现未提现总计"),
... ...
... ... @@ -70,9 +70,9 @@ public class DateUtil {
}
public static void main(String[] ars){
int endTime= DateUtil.getLastDayInt(6);
int endTime= DateUtil.getLastDayStartInt(6);
System.out.println(endTime);
int beginTime=DateUtil.getLastDayInt(7);
int beginTime=DateUtil.getLastDayStartInt(7);
System.out.println(beginTime);
String s = DateUtil.long2DateStr(1449134435000L, "yyyy-MM-dd");
... ... @@ -211,19 +211,46 @@ public class DateUtil {
}
}
public static int getLastDayInt(int lastDay) {
public static Calendar getLastMonthStart(int lastMonth) {
Calendar time = Calendar.getInstance();
time.set(time.get(Calendar.YEAR),time.get(Calendar.MONTH),1,0,0,0);
time.add(Calendar.MONTH,-lastMonth);
return time;
}
public static int getLastMonthStartInt(int lastMonth) {
Calendar time = getLastMonthStart(lastMonth);
return (int) (time.getTime().getTime()/1000);
}
public static int getLastMonthEndInt(int lastMonth) {
Calendar time = getLastMonthStart(1-lastMonth);
return (int) (time.getTime().getTime()/1000)-1;
}
public static int getLastDayStartInt(int lastDay) {
Calendar time = Calendar.getInstance();
time.add(Calendar.DAY_OF_MONTH,-lastDay);
time.set(time.get(Calendar.YEAR),time.get(Calendar.MONTH),time.get(Calendar.DAY_OF_MONTH),0,0,0);
return (int) (time.getTime().getTime()/1000);
}
public static int getLastDayInt(int time,int lastDay) {
public static int getLastDayEndInt(int lastDay) {
Calendar time = Calendar.getInstance();
time.add(Calendar.DAY_OF_MONTH,1-lastDay);
time.set(time.get(Calendar.YEAR),time.get(Calendar.MONTH),time.get(Calendar.DAY_OF_MONTH),0,0,0);
return (int) (time.getTime().getTime()/1000)-1;
}
public static int getLastDayStartInt(int time, int lastDay) {
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(time*1000);
calendar.add(Calendar.DAY_OF_MONTH,-lastDay);
calendar.set(calendar.get(Calendar.YEAR),calendar.get(Calendar.MONTH),calendar.get(Calendar.DAY_OF_MONTH),0,0,0);
return (int) (calendar.getTime().getTime()/1000);
}
public static int getLastDayEndInt(int time, int lastDay) {
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(time*1000);
calendar.add(Calendar.DAY_OF_MONTH,1-lastDay);
calendar.set(calendar.get(Calendar.YEAR),calendar.get(Calendar.MONTH),calendar.get(Calendar.DAY_OF_MONTH),0,0,0);
return (int) (calendar.getTime().getTime()/1000)-1;
}
/**
* 日期格式转换
... ...
... ... @@ -104,6 +104,7 @@
<value>/UnionShareRest/checkApply</value>
<value>/UnionShareRest/resetApply</value>
<value>/UnionShareRest/queryActivityOrder</value>
<value>/UnionShareRest/queryEstimateDetailList</value>
<value>/UnionShareRest/queryRank</value>
<value>/UnionShareRest/updateMonthData</value>
<value>/UnionShareRest/addVirtual</value>
... ...
... ... @@ -69,9 +69,11 @@ public interface UnionShareOrdersMapper {
List<UnionShareOrders> selectRecentlyOrderLimitTen(@Param("uid") int uid);
List<UnionShareOrders> selectOrderList(@Param("params") UnionShareOrderReqBO unionShareOrderReqBO);
List<UnionShareOrders> selectListByCon(@Param("uid") int uid,@Param("type") int type, @Param("beginTime") Integer beginTime, @Param("endTime") Integer endTime,@Param("offset") int offset, @Param("rows") int rows);
Integer selectOrderListCount(@Param("params") UnionShareOrderReqBO unionShareOrderReqBO);
Integer selectCountByCon(@Param("uid") int uid,@Param("type") int type, @Param("beginTime") Integer beginTime, @Param("endTime") Integer endTime);
List<UnionShareOrders> selectListForStatistics(@Param("uid") int uid, @Param("beginTime") int beginTime, @Param("endTime") int endTime);
UnionShareStatisticsRspBO selectStatistics(@Param("uid") int uid, @Param("beginTime") int beginTime, @Param("endTime") int endTime);
... ...
... ... @@ -10,6 +10,7 @@ public class UnionShareUser {
private Integer updateTime;
private Integer createTime;
private Integer applyId;
private Integer inviterUid;
private Integer status;
private Integer specialStatus;
private Integer cpsActivityId;
... ... @@ -106,6 +107,14 @@ public class UnionShareUser {
this.cpsActivityId = cpsActivityId;
}
public Integer getInviterUid() {
return inviterUid;
}
public void setInviterUid(Integer inviterUid) {
this.inviterUid = inviterUid;
}
@Override
public String toString() {
return "UnionShareUser{" +
... ... @@ -116,6 +125,7 @@ public class UnionShareUser {
", updateTime=" + updateTime +
", status=" + status +
", applyId=" + applyId +
", inviterUid=" + inviterUid +
", specialStatus=" + specialStatus +
", cpsActivityId=" + cpsActivityId +
", imageUrl='" + imageUrl + '\'' +
... ...
... ... @@ -8,6 +8,8 @@ public class UnionShareUserApply {
private String name;
private String mobile;
private String inviterUnionType;
private String socialMedia;
private Byte status;
... ... @@ -89,4 +91,12 @@ public class UnionShareUserApply {
public void setCheckTime(Integer checkTime) {
this.checkTime = checkTime;
}
public String getInviterUnionType() {
return inviterUnionType;
}
public void setInviterUnionType(String inviterUnionType) {
this.inviterUnionType = inviterUnionType;
}
}
\ No newline at end of file
... ...
... ... @@ -579,6 +579,45 @@
AND status IN (91,92,93)
</if>
</select>
<select id="selectCountByCon" resultType="java.lang.Integer">
select
count(1)
from union_share_orders
where promote_uid = #{uid,jdbcType=INTEGER} and status in (10,20,30,40)
<if test="type == 1">
and order_code is not null
</if>
<if test="type == 2">
and activity_id &gt;0
</if>
<if test="beginTime != null">
and order_time &gt;= #{beginTime,jdbcType=INTEGER}
</if>
<if test="endTime != null">
and order_time &lt;= #{endTime,jdbcType=INTEGER}
</if>
</select>
<select id="selectListByCon" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from union_share_orders
where promote_uid = #{uid,jdbcType=INTEGER} and status in (10,20,30,40)
<if test="type == 1">
and order_code is not null
</if>
<if test="type == 2">
and activity_id &gt;0
</if>
<if test="beginTime != null and beginTime != 0" >
and order_time &gt;= #{beginTime}
</if>
<if test="endTime != null and endTime != 0" >
and order_time &lt;=#{endTime}
</if>
order by order_time desc
limit #{offset}, #{rows}
</select>
<select id="selectListForStatistics" resultMap="BaseResultMap">
select <include refid="Base_Column_List" />
... ...
... ... @@ -7,6 +7,7 @@
<result column="name" property="name" jdbcType="VARCHAR" />
<result column="mobile" property="mobile" jdbcType="VARCHAR" />
<result column="social_media" property="socialMedia" jdbcType="VARCHAR" />
<result column="inviter_union_type" property="inviterUnionType" jdbcType="VARCHAR" />
<result column="status" property="status" jdbcType="TINYINT" />
<result column="del_flag" property="delFlag" jdbcType="TINYINT" />
<result column="create_time" property="createTime" jdbcType="INTEGER" />
... ... @@ -14,7 +15,7 @@
</resultMap>
<sql id="Base_Column_List" >
id, uid, name, mobile, social_media, status,
del_flag, create_time, check_time
del_flag, create_time, check_time, inviter_union_type
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
... ... @@ -140,6 +141,9 @@
<if test="socialMedia != null" >
social_media,
</if>
<if test="inviterUnionType != null" >
inviter_union_type,
</if>
<if test="status != null" >
status,
</if>
... ... @@ -169,6 +173,9 @@
<if test="socialMedia != null" >
#{socialMedia,jdbcType=VARCHAR},
</if>
<if test="inviterUnionType != null" >
#{inviterUnionType,jdbcType=VARCHAR},
</if>
<if test="status != null" >
#{status,jdbcType=TINYINT},
</if>
... ...
... ... @@ -7,13 +7,14 @@
<result column="union_type" property="unionType" jdbcType="VARCHAR" />
<result column="status" property="status" jdbcType="INTEGER" />
<result column="apply_id" property="applyId" jdbcType="INTEGER" />
<result column="inviter_uid" property="inviterUid" jdbcType="VARCHAR" />
<result column="special_status" property="specialStatus" jdbcType="INTEGER" />
<result column="cps_activity_id" property="cpsActivityId" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="INTEGER" />
<result column="update_time" property="updateTime" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
id, uid, union_type, update_time,create_time,status,apply_id,special_status,cps_activity_id
id, uid, union_type, update_time,create_time,status,apply_id,inviter_uid,special_status,cps_activity_id
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
... ... @@ -103,6 +104,9 @@
<if test="applyId != null" >
apply_id,
</if>
<if test="inviterUid != null" >
inviter_uid,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
... ... @@ -126,6 +130,9 @@
<if test="applyId != null" >
#{applyId,jdbcType=INTEGER},
</if>
<if test="inviterUid != null" >
#{inviterUid,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yoho.unions.dal.model.UnionShareUser" >
... ...
... ... @@ -5,7 +5,7 @@
<parent>
<groupId>com.yoho</groupId>
<artifactId>parent</artifactId>
<version>1.4.6-SNAPSHOT</version>
<version>1.4.7-SNAPSHOT</version>
</parent>
<groupId>com.yoho.dsf</groupId>
<artifactId>yoho-unions</artifactId>
... ...
... ... @@ -340,6 +340,21 @@ public class UnionShareRest {
PageResponseBO<UnionShareOrders> unionShareOrdersList = unionShareService.queryOrderList(unionShareOrderReqBO);
return new UnionResponse(200, "queryOrderList success",unionShareOrdersList);
}
/**
* 预估详细列表
* type(预估收入类型):1-订单收入,2-其他收入
* queryTimeType(查询时间类型):1-昨日,2-本月,3-上月
* */
@RequestMapping("/queryEstimateDetailList")
@ResponseBody
public UnionResponse queryEstimateDetailList(@RequestBody UnionShareOrderReqBO unionShareOrderReqBO){
log.info("UnionShareRest.queryEstimateDetailList unionShareOrderReqBO is {}", unionShareOrderReqBO);
if (null == unionShareOrderReqBO || null == unionShareOrderReqBO.getUid()||unionShareOrderReqBO.getType()==null||unionShareOrderReqBO.getQueryTimeType()==null){
return new UnionResponse(409, "queryEstimateDetailList params error");
}
PageResponseBO<UnionShareOrders> unionShareOrdersList = unionShareService.queryEstimateDetailList(unionShareOrderReqBO);
return new UnionResponse(200, "queryEstimateDetailList success",unionShareOrdersList);
}
/**
* 达人排行
... ...
... ... @@ -154,6 +154,13 @@ public interface IUnionShareService {
PageResponseBO<UnionShareOrders> queryOrderList(UnionShareOrderReqBO unionShareOrderReqBO);
/**
* 预估详细列表
* type(预估收入类型):1-订单收入,2-其他收入
* queryTimeType(预估收入实际):1-昨日,2-本月,3-上月
* */
PageResponseBO<UnionShareOrders> queryEstimateDetailList(UnionShareOrderReqBO unionShareOrderReqBO);
/**
* 达人排行榜
* @param bo
* @return
... ...
... ... @@ -555,7 +555,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
int result=unionShareUserApplyMapper.updateStatus(new HashSet<Integer>(){{add(req.getId());}},1,2, DateUtil.getCurrentTimeSecond());
if (result > 0) {
// 绑定unionType
relateUnionType(unionShareUserApply.getUid(),req.getId(), unionShareUserApply.getMobile());
relateUnionType(unionShareUserApply.getUid(),req.getId(),unionShareUserApply.getInviterUnionType(), unionShareUserApply.getMobile());
}
redisHashCache.delete(ShareOrdersKeyEnum.UNION_TYPE.getPreKey(),unionShareUserApply.getUid());
return result;
... ... @@ -587,7 +587,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
return;
}
try {
relateUnionType(u.getUid(),u.getId(), u.getMobile());
relateUnionType(u.getUid(),u.getId(),u.getInviterUnionType(), u.getMobile());
} catch (Exception e) {
logger.error("relateUnionType error ,uid is {}",u.getUid());
}
... ... @@ -598,7 +598,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
}
}
public void relateUnionType(int uid,int applyId, String mobile) {
public void relateUnionType(int uid,int applyId,String inviterUnionType, String mobile) {
logger.info("relateUnionType,uid is {}", uid);
UnionShareUser unionShareUser1 = unionShareUserMapper.selectByUid(uid);
if (null != unionShareUser1) {
... ... @@ -614,6 +614,8 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
return;
}
Integer inviterUid=unionShareUserMapper.selectUidByUnionType(inviterUnionType);
//生成unionType
MktMarketingUrl unionDepartmentUrl = buildMktMarketingUrl(uid);
try {
... ... @@ -636,6 +638,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
unionShareUser.setCreateTime(DateUtil.getCurrentTimeSecond());
unionShareUser.setUpdateTime(unionShareUser.getCreateTime());
unionShareUser.setApplyId(applyId);
unionShareUser.setInviterUid(inviterUid);
int result = unionShareUserMapper.insertSelective(unionShareUser);
if (result > 0) {
logger.info("relateUnionType,begin to send message,uid is {},unionType is {}", uid,unionDepartmentUrl.getUnionType());
... ... @@ -1277,6 +1280,57 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
}
/**
* 预估详细列表
* type(预估收入类型):1-订单收入,2-其他收入
* queryTimeType(预估收入实际):1-昨日,2-本月,3-上月
* */
@Override
public PageResponseBO<UnionShareOrders> queryEstimateDetailList(UnionShareOrderReqBO unionShareOrderReqBO) {
logger.info("UnionShareServiceImpl.queryEstimateDetailList,bo is {}",unionShareOrderReqBO);
//先从缓存获取
PageResponseBO<UnionShareOrders> cacheResult = getFromRedis(ShareOrdersKeyEnum.ESTIMATE_LIST, unionShareOrderReqBO.getUid(),PageResponseBO.class,unionShareOrderReqBO.getType().toString(),unionShareOrderReqBO.getQueryTimeType().toString(), String.valueOf(unionShareOrderReqBO.getPage()), String.valueOf(unionShareOrderReqBO.getSize()));
if (cacheResult != null) {
logger.info("UnionShareServiceImpl.queryEstimateDetailList get redis cache ,uid is {},cacheResult is {}",unionShareOrderReqBO.getUid(),cacheResult);
return cacheResult;
}
//获取总数
PageResponseBO<UnionShareOrders> response = new PageResponseBO<>();
//queryTimeType(预估收入实际):1-昨日,2-本月,3-上月
int beginTime = 0;
int endTime = 0;
if (unionShareOrderReqBO.getQueryTimeType() == 1) {
beginTime = DateUtil.getLastDayStartInt(1);
endTime = DateUtil.getLastDayEndInt(1);
}else if (unionShareOrderReqBO.getQueryTimeType() == 2) {
beginTime=DateUtil.getLastMonthStartInt(0);
endTime=DateUtil.getLastMonthEndInt(0);
}else if (unionShareOrderReqBO.getQueryTimeType() == 3) {
beginTime=DateUtil.getLastMonthStartInt(1);
endTime=DateUtil.getLastMonthEndInt(1);
}else {
throw new ServiceException(ServiceError.PARAM_ERROR);
}
Integer count = unionShareOrdersMapper.selectCountByCon(unionShareOrderReqBO.getUid(),unionShareOrderReqBO.getType(),beginTime,endTime);
if (count <= 0){
logger.info("UnionShareServiceImpl.queryEstimateDetailList count is 0");
return response;
}
//分页
int start=unionShareOrderReqBO.getPage()>1?(unionShareOrderReqBO.getPage()-1)*unionShareOrderReqBO.getSize():0;
List<UnionShareOrders> unionShareOrdersList = unionShareOrdersMapper.selectListByCon(unionShareOrderReqBO.getUid(),unionShareOrderReqBO.getType(),beginTime,endTime,start,unionShareOrderReqBO.getSize());
dealShareOrderList(unionShareOrdersList,unionShareOrderReqBO.getType());
response.setSize(unionShareOrderReqBO.getSize());
response.setPage(unionShareOrderReqBO.getPage()>1?unionShareOrderReqBO.getPage():1);
response.setTotal(count);
response.setList(unionShareOrdersList);
//设置缓存
addToRedis(ShareOrdersKeyEnum.ESTIMATE_LIST,unionShareOrderReqBO.getUid(),response,unionShareOrderReqBO.getType().toString(),unionShareOrderReqBO.getQueryTimeType().toString(),
String.valueOf(unionShareOrderReqBO.getPage()), String.valueOf(unionShareOrderReqBO.getSize()));
return response;
}
/**
* 达人排行榜
* @param req
* @return
... ... @@ -1591,7 +1645,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
if (activityLog.getActivityType() == 3) {
joinResult = joinExtraActivity(activityLog.getOrderUid(), activityLog.getPromoteUid(), activityLog.getActivityId());
} else if (activityLog.getActivityType() == 4) {
int endTime = DateUtil.getLastDayInt(activityLog.getCreateTime(),1);
int endTime = DateUtil.getLastDayStartInt(activityLog.getCreateTime(),1);
List<UnionShareOrders> orders=unionShareOrdersMapper.selectNewPromoteUidOrder(activityLog.getPromoteUid(), endTime);
joinResult = joinNewCpsActivity(activityLog.getPromoteUid(), orders, activityLog.getActivityId());
}
... ... @@ -1859,9 +1913,9 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
@Override
public void clearActivityCache(int activityId) {
// 清除某活动缓存
String dateStr=DateUtil.getDateStrBySecond(DateUtil.getLastDayInt(0),"yyyyMMdd");
String date1Str=DateUtil.getDateStrBySecond(DateUtil.getLastDayInt(1),"yyyyMMdd");
String date7Str=DateUtil.getDateStrBySecond(DateUtil.getLastDayInt(7),"yyyyMMdd");
String dateStr=DateUtil.getDateStrBySecond(DateUtil.getLastDayStartInt(0),"yyyyMMdd");
String date1Str=DateUtil.getDateStrBySecond(DateUtil.getLastDayStartInt(1),"yyyyMMdd");
String date7Str=DateUtil.getDateStrBySecond(DateUtil.getLastDayStartInt(7),"yyyyMMdd");
redisTemplate.delete(ShareOrdersKeyEnum.ACTIVITY_ING_LIST.getPreKey()+dateStr);
redisTemplate.delete(ShareOrdersKeyEnum.ACTIVITY_ING_LIST.getPreKey()+date1Str);
redisTemplate.delete(ShareOrdersKeyEnum.ACTIVITY_ING_LIST.getPreKey()+date7Str);
... ...
... ... @@ -28,13 +28,13 @@ public class CpsNewUserActivityTask {
public void run() {
logger.info("start giving out new user rewards");
//查询6天前一天为进行中状态的新用户满x单返活动
int endTime= DateUtil.getLastDayInt(6);
int beginTime=DateUtil.getLastDayInt(7);
int endTime= DateUtil.getLastDayStartInt(6);
int beginTime=DateUtil.getLastDayStartInt(7);
List<UnionShareOrdersActivity> activities = unionShareService.queryLastDaysIngActivity(beginTime,endTime);
if (CollectionUtils.isEmpty(activities)) {
return;
}
int orderEndTime = DateUtil.getLastDayInt(0);
int orderEndTime = DateUtil.getLastDayStartInt(0);
//其实一天只允许有一个活动
activities.forEach(a->{
unionShareService.dealWithCpsNewUserActivity(a,beginTime,endTime,orderEndTime);
... ...
... ... @@ -47,8 +47,8 @@ public class CpsOrdersSumMessageTask {
logger.info("get this task,this is {}",bo);
//昨日
int startTime=DateUtil.getLastDayInt(1);
int endTime= DateUtil.getLastDayInt(0);
int startTime=DateUtil.getLastDayStartInt(1);
int endTime= DateUtil.getLastDayStartInt(0);
unionShareService.sendUidAoumtMessage(startTime,endTime);
}
}
... ...
... ... @@ -46,8 +46,8 @@ public class CpsSettlementMessageTask {
}
logger.info("get this task,this is {}",bo);
//今天更新的数据
int startTime=DateUtil.getLastDayInt(0);
int endTime= DateUtil.getLastDayInt(-1);
int startTime=DateUtil.getLastDayStartInt(0);
int endTime= DateUtil.getLastDayStartInt(-1);
unionShareService.sendUidSettlementMessage(startTime,endTime);
}
}
... ...