Authored by caoyan

Merge branch 'dev_180903_cps5' of http://git.yoho.cn/yoho30/yohobuy-union into dev_180903_cps5

... ... @@ -14,7 +14,7 @@ public enum ShareOrdersKeyEnum {
SETTLEMENT_LIST("yh:union:share:settlementList:","key:{}:page:{}:limit:{}",600,"提现列表"),
UNION_TYPE("yh:union:share:unionType:","key:{}",600,"用户登录时获取对应的渠道号"),
RECENTLY_ORDER_LIMIT_TEN("yh:union:share:recentlyOrderLimitTen:","key:{}",600,"用户前台获取个人推广近期订单(10个)"),
ACTIVITY_ING_LIST("yh:union:share:activity:ing:list",null,120,"进行中的活动"),
ACTIVITY_ING_LIST("yh:union:share:activity:ing:list:",null,120,"某天进行中的活动"),
ACTIVITY("yh:union:share:activity:","type:{}:id:{}",120,"活动"),
ORDER_STATISTICS_INFO("yh:union:share:statisticsInfo:","uid:{}:queryTimeType:{}",600,"统计数据"),
RANK_LIST("yh:union:share:ranklist:","type:{}:start:{}:limit:{}",86400,"达人排行榜"),
... ...
... ... @@ -65,9 +65,14 @@ public class DateUtil {
}
public static void main(String[] ars){
int endTime= DateUtil.getLastDayInt(6);
System.out.println(endTime);
int beginTime=DateUtil.getLastDayInt(7);
System.out.println(beginTime);
String s = DateUtil.long2DateStr(1449134435000L, "yyyy-MM-dd");
System.out.print(s);
System.out.print(">>>>>>>>>>"+getCurrentTimeSecond());
System.out.println(s);
System.out.println(">>>>>>>>>>"+getCurrentTimeSecond());
}
... ... @@ -203,15 +208,15 @@ public class DateUtil {
public static int getLastDayInt(int lastDay) {
Calendar time = Calendar.getInstance();
time.add(Calendar.DAY_OF_YEAR,1-lastDay);
time.set(time.get(Calendar.YEAR),time.get(Calendar.MONTH),time.get(Calendar.HOUR_OF_DAY),0,0,0);
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) {
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(time*1000);
calendar.add(Calendar.DAY_OF_YEAR,1-lastDay);
calendar.set(calendar.get(Calendar.YEAR),calendar.get(Calendar.MONTH),calendar.get(Calendar.HOUR_OF_DAY),0,0,0);
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);
}
... ...
... ... @@ -93,6 +93,7 @@
<value>/UnionShareRest/checkBankCard</value>
<value>/UnionShareRest/queryUnionShareUserBanks</value>
<value>/UnionShareRest/queryUnionShareUserApplys</value>
<value>/UnionShareRest/queryUnionShareUsers</value>
<value>/UnionShareRest/getSocialMediaBasicParams</value>
<value>/UnionShareRest/cancelUserBanks</value>
<value>/UnionShareRest/updateBankBranch</value>
... ... @@ -107,6 +108,7 @@
<value>/UnionShareRest/addVirtual</value>
<value>/UnionShareRest/toAddVirtual</value>
<value>/UnionShareRest/dealExtraActivityTask</value>
<value>/UnionShareRest/dealNewUserActivityTask</value>
<value>/UnionShareRest/clearActivity</value>
<value>/UnionShareRest/getStatisticsInfo</value>
<value>/UnionShareRest/queryUnionShareOrdersMonthList</value>
... ...
... ... @@ -71,8 +71,7 @@ public interface UnionShareOrdersMapper {
List<UnionShareOrders> selectListForStatistics(@Param("uid") int uid, @Param("beginTime") int beginTime, @Param("endTime") int endTime);
@MapKey("uid")
Map<Integer, List<UnionShareOrders>> selectNewPromoteUidsOrder(@Param("promoteUids") Set<Integer> promoteUids, @Param("endTime") int endTime);
List<UnionShareOrders> selectNewPromoteUidsOrder(@Param("promoteUids") Set<Integer> promoteUids, @Param("endTime") int endTime);
List<UnionShareOrders> selectNewPromoteUidOrder(@Param("promoteUid") int promoteUid, @Param("endTime") int endTime);
... ...
package com.yoho.unions.dal;
import com.yoho.service.model.union.request.UnionShareUserReqBO;
import com.yoho.service.model.union.response.UnionShareUserRspBo;
import com.yoho.unions.dal.model.UnionShareUser;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
import java.util.Set;
... ... @@ -20,6 +23,9 @@ public interface UnionShareUserMapper {
int selectCountByUid(Integer uid);
int selectTotalByCondition(UnionShareUserReqBO reqBO);
List<UnionShareUserRspBo> selectByCondition(UnionShareUserReqBO reqBO);
int updateByPrimaryKeySelective(UnionShareUser record);
int updateByUid(UnionShareUser record);
... ...
... ... @@ -43,7 +43,7 @@
select
<include refid="Base_Column_List" />
from union_share_orders_activity
where status=1 and type=4 and start_time &lt; #{endTime,jdbcType=INTEGER} and end_time > #{startTime,jdbcType=INTEGER}
where status=1 and type=4 and start_time &lt;= #{endTime,jdbcType=INTEGER} and end_time >= #{startTime,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from union_share_orders_activity
... ...
... ... @@ -15,6 +15,7 @@
<result column="create_time" property="createTime" jdbcType="INTEGER" />
<result column="update_time" property="updateTime" jdbcType="INTEGER" />
<result column="extra_activity_id" property="extraActivityId" jdbcType="INTEGER" />
<result column="cps_extra_activity_id" property="cpsExtraActivityId" jdbcType="INTEGER" />
<result column="activity_id" property="activityId" jdbcType="INTEGER" />
<result column="activity_name" property="activityName" jdbcType="VARCHAR" />
<result column="extra_amount" property="extraAmount" jdbcType="DECIMAL" />
... ... @@ -24,7 +25,7 @@
</resultMap>
<sql id="Base_Column_List" >
id, order_code,settlement_code, promote_uid,order_uid, status, last_order_amount, order_time, is_new, amount, create_time,
update_time,extra_activity_id,activity_id,activity_name,extra_amount,order_amount,special_status,payment_type
update_time,extra_activity_id,cps_extra_activity_id,activity_id,activity_name,extra_amount,order_amount,special_status,payment_type
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
... ... @@ -104,13 +105,13 @@
order_uid, settlement_code, status,
last_order_amount, order_time, is_new,
amount, create_time, update_time,
extra_activity_id, activity_id,activity_name, extra_amount,
extra_activity_id,cps_extra_activity_id, activity_id,activity_name, extra_amount,
order_amount,special_status,payment_type)
values (#{id,jdbcType=INTEGER}, #{orderCode,jdbcType=VARCHAR}, #{promoteUid,jdbcType=INTEGER},
#{orderUid,jdbcType=INTEGER}, #{settlementCode,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR},
#{lastOrderAmount,jdbcType=DECIMAL}, #{orderTime,jdbcType=INTEGER}, #{isNew,jdbcType=TINYINT},
#{amount,jdbcType=DECIMAL}, #{createTime,jdbcType=INTEGER}, #{updateTime,jdbcType=INTEGER},
#{extraActivityId,jdbcType=INTEGER}, #{activityId,jdbcType=INTEGER},#{activityName,jdbcType=VARCHAR}, #{extraAmount,jdbcType=DECIMAL},
#{extraActivityId,jdbcType=INTEGER},#{cpsExtraActivityId,jdbcType=INTEGER}, #{activityId,jdbcType=INTEGER},#{activityName,jdbcType=VARCHAR}, #{extraAmount,jdbcType=DECIMAL},
#{orderAmount,jdbcType=DECIMAL}), #{specialStatus,jdbcType=TINYINT}, #{paymentType,jdbcType=TINYINT}
</insert>
<insert id="insertSelective" useGeneratedKeys="true" keyProperty="id" parameterType="com.yoho.unions.dal.model.UnionShareOrders" >
... ... @@ -155,6 +156,9 @@
<if test="extraActivityId != null" >
extra_activity_id,
</if>
<if test="cpsExtraActivityId != null" >
cps_extra_activity_id,
</if>
<if test="activityId != null" >
activity_id,
</if>
... ... @@ -214,6 +218,9 @@
<if test="extraActivityId != null" >
#{extraActivityId,jdbcType=INTEGER},
</if>
<if test="cpsExtraActivityId != null" >
#{cpsExtraActivityId,jdbcType=INTEGER},
</if>
<if test="activityId != null" >
#{activityId,jdbcType=INTEGER},
</if>
... ... @@ -273,6 +280,9 @@
<if test="extraActivityId != null" >
extra_activity_id = #{extraActivityId,jdbcType=INTEGER},
</if>
<if test="cpsExtraActivityId != null" >
cps_extra_activity_id = #{cpsExtraActivityId,jdbcType=INTEGER},
</if>
<if test="activityId != null" >
activity_id = #{activityId,jdbcType=INTEGER},
</if>
... ... @@ -306,7 +316,7 @@
<update id="updateByIdsForCpsUserActivity" >
update union_share_orders
set update_time = #{updateTime,jdbcType=INTEGER},
extra_activity_id = #{cpsExtraActivityId,jdbcType=INTEGER}
cps_extra_activity_id = #{cpsExtraActivityId,jdbcType=INTEGER}
where id in
<foreach collection="ids" separator="," item="item" index="index" close=")" open="(">
#{item}
... ... @@ -326,6 +336,7 @@
create_time = #{createTime,jdbcType=INTEGER},
update_time = #{updateTime,jdbcType=INTEGER},
extra_activity_id = #{extraActivityId,jdbcType=INTEGER},
cps_extra_activity_id = #{cpsExtraActivityId,jdbcType=INTEGER},
activity_id = #{activityId,jdbcType=INTEGER},
activity_name = #{activityName,jdbcType=VARCHAR},
extra_amount = #{extraAmount,jdbcType=DECIMAL},
... ... @@ -562,7 +573,7 @@
<select id="selectNewPromoteUidsOrder" resultMap="BaseResultMap">
select <include refid="Base_Column_List" />
from union_share_orders
where promote_uid in
where order_code is not null and promote_uid in
<foreach collection="promoteUids" separator="," item="item" index="index" close=")" open="(">
#{item}
</foreach>
... ... @@ -571,7 +582,7 @@
<select id="selectNewPromoteUidOrder" resultMap="BaseResultMap">
select <include refid="Base_Column_List" />
from union_share_orders
where promote_uid = #{promoteUid} and order_time &lt;#{endTime} and status in (10,20,30,40)
where promote_uid = #{promoteUid} and order_code is not null and order_time &lt;#{endTime} and status in (10,20,30,40)
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -31,6 +31,35 @@
select count(1) from union_share_user
where uid = #{uid,jdbcType=INTEGER}
</select>
<select id="selectTotalByCondition" resultType="java.lang.Integer" parameterType="com.yoho.service.model.union.request.UnionShareUserReqBO" >
select count(1) from union_share_user
where status=1
<if test="uid!=null" >
and uid = #{uid,jdbcType=INTEGER}
</if>
<if test="unionType!=null" >
and union_type = #{unionType,jdbcType=VARCHAR}
</if>
<if test="specialStatus!=null" >
and special_status = #{specialStatus,jdbcType=INTEGER}
</if>
</select>
<select id="selectByCondition" resultType="com.yoho.service.model.union.response.UnionShareUserRspBo" parameterType="com.yoho.service.model.union.request.UnionShareUserReqBO" >
select id, uid, union_type unionType, update_time updateTime,create_time createTime,status,apply_id applyId,special_status specialStatus,cps_activity_id cpsActivityId
from union_share_user
where status=1
<if test="uid!=null" >
and uid = #{uid,jdbcType=INTEGER}
</if>
<if test="unionType!=null" >
and union_type = #{unionType,jdbcType=VARCHAR}
</if>
<if test="specialStatus!=null" >
and special_status = #{specialStatus,jdbcType=INTEGER}
</if>
order by create_time desc
limit #{start},#{size}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from union_share_user
where id = #{id,jdbcType=INTEGER}
... ... @@ -160,7 +189,7 @@
<update id="updateCpsActByUid" >
update union_share_user
set cps_activity_id = #{activityId,jdbcType=INTEGER},
update_time = #{updateTime,jdbcType=INTEGER},
where uid = #{uid,jdbcType=INTEGER} and cps_activity_id is NULL
update_time = #{updateTime,jdbcType=INTEGER}
where uid = #{uid,jdbcType=INTEGER} and (cps_activity_id = 0 or cps_activity_id is NULL)
</update>
</mapper>
\ No newline at end of file
... ...
... ... @@ -6,6 +6,10 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import com.yoho.service.model.union.request.*;
import com.yoho.service.model.union.response.*;
import com.yoho.unions.dal.model.*;
import com.yoho.unions.server.task.CpsNewUserActivityTask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -34,31 +38,12 @@ import com.yoho.service.model.union.bo.UnionShareOrdersActivityLogsBo;
import com.yoho.service.model.union.bo.UnionShareUserBankBo;
import com.yoho.service.model.union.bo.UnionShareUserBo;
import com.yoho.service.model.union.bo.UnionShareVirtualAddBo;
import com.yoho.service.model.union.request.UninoShareIncomeRankReqBo;
import com.yoho.service.model.union.request.UnionShareMessageReqBO;
import com.yoho.service.model.union.request.UnionShareOrderReqBO;
import com.yoho.service.model.union.request.UnionShareOrderSearchReqBO;
import com.yoho.service.model.union.request.UnionShareOrdersMonthReqBO;
import com.yoho.service.model.union.request.UnionShareUserApplyListReqBo;
import com.yoho.service.model.union.request.UnionShareUserApplyReqBo;
import com.yoho.service.model.union.request.UnionShareUserBankListReqBo;
import com.yoho.service.model.union.response.PageResponseBO;
import com.yoho.service.model.union.response.PageUnionShareOrderRspBO;
import com.yoho.service.model.union.response.UnionResponse;
import com.yoho.service.model.union.response.UnionShareStatisticsRspBO;
import com.yoho.service.model.union.response.UnionShareUserApplyListBo;
import com.yoho.service.model.union.response.UnionShareUserBankListBO;
import com.yoho.unions.common.ApiResponse;
import com.yoho.unions.dal.model.UnionShareMessage;
import com.yoho.unions.dal.model.UnionShareOrders;
import com.yoho.unions.dal.model.UnionShareOrdersMonth;
import com.yoho.unions.dal.model.UnionShareSettlement;
import com.yoho.unions.server.service.IUnionShareService;
import com.yoho.unions.server.task.CpsOrderExtraActivityTask;
/**
* Created by mingdan.ge on 2018/5/14.
* 接口在nginx内做了限制,只可以内部ip访问
*/
@Controller
@RequestMapping("/UnionShareRest")
... ... @@ -73,6 +58,9 @@ public class UnionShareRest {
@Autowired
CpsOrderExtraActivityTask cpsOrderExtraActivityTask;
@Autowired
CpsNewUserActivityTask cpsNewUserActivityTask;
@RequestMapping("/getShareInfoByUid")
@ResponseBody
public ShareUserSettlementInfoBo getShareInfoByUid(@RequestBody int uid){
... ... @@ -272,6 +260,19 @@ public class UnionShareRest {
}
/**
* 查询联盟用户列表
* @param req
* @return
*/
@RequestMapping("/queryUnionShareUsers")
@ResponseBody
public UnionResponse queryUnionShareUsers(UnionShareUserReqBO req){
log.info("queryUnionShareUsers parm is {}");
PageResponseBO<UnionShareUserRspBo> result = unionShareService.queryUnionShareUsers(req);
return new UnionResponse(200, "queryUnionShareUsers success",result);
}
/**
* 订单明细
* Created by qing.zhao on 2018/5/15
* @param unionShareOrderReqBO
... ... @@ -409,6 +410,17 @@ public class UnionShareRest {
}
/**
* 手动执行一次新人活动奖励发放
* */
@RequestMapping("/dealNewUserActivityTask")
@ResponseBody
public UnionResponse dealNewUserActivityTask(){
log.info("UnionShareRest.dealNewUserActivityTask.");
cpsNewUserActivityTask.run();
return new UnionResponse(200, "dealNewUserActivityTask success");
}
/**
* 清活动缓存
* */
@RequestMapping("/clearActivity")
... ...
... ... @@ -18,24 +18,9 @@ import com.yoho.service.model.union.bo.UnionShareOrdersActivityLogsBo;
import com.yoho.service.model.union.bo.UnionShareUserBankBo;
import com.yoho.service.model.union.bo.UnionShareUserBo;
import com.yoho.service.model.union.bo.UnionShareVirtualAddBo;
import com.yoho.service.model.union.request.UninoShareIncomeRankReqBo;
import com.yoho.service.model.union.request.UnionShareMessageReqBO;
import com.yoho.service.model.union.request.UnionShareOrderReqBO;
import com.yoho.service.model.union.request.UnionShareOrderSearchReqBO;
import com.yoho.service.model.union.request.UnionShareOrdersMonthReqBO;
import com.yoho.service.model.union.request.UnionShareUserApplyListReqBo;
import com.yoho.service.model.union.request.UnionShareUserApplyReqBo;
import com.yoho.service.model.union.request.UnionShareUserBankListReqBo;
import com.yoho.service.model.union.response.PageResponseBO;
import com.yoho.service.model.union.response.PageUnionShareOrderRspBO;
import com.yoho.service.model.union.response.UnionShareStatisticsRspBO;
import com.yoho.service.model.union.response.UnionShareUserApplyListBo;
import com.yoho.service.model.union.response.UnionShareUserBankListBO;
import com.yoho.unions.dal.model.UnionShareMessage;
import com.yoho.unions.dal.model.UnionShareOrders;
import com.yoho.unions.dal.model.UnionShareOrdersActivity;
import com.yoho.unions.dal.model.UnionShareOrdersMonth;
import com.yoho.unions.dal.model.UnionShareSettlement;
import com.yoho.service.model.union.request.*;
import com.yoho.service.model.union.response.*;
import com.yoho.unions.dal.model.*;
/**
* 联盟红人推广返利
... ... @@ -228,7 +213,9 @@ public interface IUnionShareService {
* @return
*/
PageResponseBO<UnionShareUserApplyListBo> queryUnionShareUserApplys(UnionShareUserApplyListReqBo parm);
PageResponseBO<UnionShareUserRspBo> queryUnionShareUsers(UnionShareUserReqBO req);
/**
* 获取返现订单统计信息
* @param bo
... ...
... ... @@ -19,6 +19,8 @@ import java.util.stream.Collectors;
import javax.annotation.Resource;
import com.yoho.service.model.union.request.*;
import com.yoho.service.model.union.response.*;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.elasticsearch.common.collect.Maps;
... ... @@ -57,20 +59,6 @@ import com.yoho.service.model.union.bo.UnionShareOrdersUidBo;
import com.yoho.service.model.union.bo.UnionShareUserBankBo;
import com.yoho.service.model.union.bo.UnionShareUserBo;
import com.yoho.service.model.union.bo.UnionShareVirtualAddBo;
import com.yoho.service.model.union.request.UninoShareIncomeRankReqBo;
import com.yoho.service.model.union.request.UnionShareMessageReqBO;
import com.yoho.service.model.union.request.UnionShareOrderReqBO;
import com.yoho.service.model.union.request.UnionShareOrderSearchReqBO;
import com.yoho.service.model.union.request.UnionShareOrdersMonthReqBO;
import com.yoho.service.model.union.request.UnionShareUserApplyListReqBo;
import com.yoho.service.model.union.request.UnionShareUserApplyReqBo;
import com.yoho.service.model.union.request.UnionShareUserBankListReqBo;
import com.yoho.service.model.union.response.PageResponseBO;
import com.yoho.service.model.union.response.PageUnionShareOrderRspBO;
import com.yoho.service.model.union.response.UnionShareOrderRspBO;
import com.yoho.service.model.union.response.UnionShareStatisticsRspBO;
import com.yoho.service.model.union.response.UnionShareUserApplyListBo;
import com.yoho.service.model.union.response.UnionShareUserBankListBO;
import com.yoho.unions.common.enums.BankEnum;
import com.yoho.unions.common.enums.ShareOrdersKeyEnum;
import com.yoho.unions.common.enums.ShareOrdersStatusEnum;
... ... @@ -436,6 +424,34 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
result.setTotal(total);
return result;
}
/**
* 查询申请记录
* @param req
* @return
*/
@Override
public PageResponseBO<UnionShareUserRspBo> queryUnionShareUsers(UnionShareUserReqBO req) {
logger.info("queryUnionShareUsers.req is {}",req);
int total=this.unionShareUserMapper.selectTotalByCondition(req);
if(total==0){
logger.info("queryUnionShareUsers end.req is {},total is 0",req);
return null;
}
List<UnionShareUserRspBo> list=this.unionShareUserMapper.selectByCondition(req);
List<String> unionTypeList = list.stream().map(bo -> bo.getUnionType()).collect(Collectors.toList());
Map<Long, MktMarketingUrl> longMktMarketingUrlMap = mktMarketingUrlDAO.selectByUnionTypes(unionTypeList);
list.forEach(u->{
if (longMktMarketingUrlMap.containsKey(Long.valueOf(u.getUnionType()))) {
u.setUnionName(longMktMarketingUrlMap.get(Long.valueOf(u.getUnionType())).getName());
}
});
PageResponseBO<UnionShareUserRspBo> result=new PageResponseBO<>();
result.setList(list);
result.setPage(req.getPage());
result.setSize(req.getSize());
result.setTotal(total);
return result;
}
private void covertSocialMedia(UnionShareUserApplyListBo bo) {
if (null != bo.getSocialMedia()) {
... ... @@ -1369,21 +1385,21 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
if (result > 0 && (unionShareOrders.getExtraActivityId() != null||unionShareOrders.getExtraActivityId() != null)) {
if (ShareOrdersStatusEnum.isFailOrder(bo.getStatus())) {
//订单不可参与活动,重新处理该单参与的满单返
if (unionShareOrders.getExtraActivityId() != null) {
rehandSomeExtraActivity(unionShareOrders.getOrderUid(),unionShareOrders.getPromoteUid(),unionShareOrders.getExtraActivityId());
if (unionShareOrders.getExtraActivityId() != null && unionShareOrders.getExtraActivityId() > 0) {
rehandSomeExtraActivity(unionShareOrders.getOrderUid(), unionShareOrders.getPromoteUid(), unionShareOrders.getExtraActivityId());
}
if (unionShareOrders.getCpsExtraActivityId() != null) {
rehandSomeExtraActivity(null,unionShareOrders.getPromoteUid(),unionShareOrders.getCpsExtraActivityId());
if (unionShareOrders.getCpsExtraActivityId() != null && unionShareOrders.getCpsExtraActivityId() > 0) {
rehandSomeExtraActivity(null, unionShareOrders.getPromoteUid(), unionShareOrders.getCpsExtraActivityId());
}
}
if (ShareOrdersStatusEnum.CAN_SETTLE.getCode().equals(bo.getStatus())
|| ShareOrdersStatusEnum.getLevelByCode(bo.getStatus()) > ShareOrdersStatusEnum.CAN_SETTLE.getLevel()) {
//有效订单已完结,判断是否需要把该单的满返活动状态改成可结算
if (unionShareOrders.getExtraActivityId() != null) {
changeSomeExtraActivityStatus(unionShareOrders.getOrderUid(),unionShareOrders.getPromoteUid(),unionShareOrders.getExtraActivityId());
if (unionShareOrders.getExtraActivityId() != null && unionShareOrders.getExtraActivityId() > 0) {
changeSomeExtraActivityStatus(unionShareOrders.getOrderUid(), unionShareOrders.getPromoteUid(), unionShareOrders.getExtraActivityId());
}
if (unionShareOrders.getCpsExtraActivityId() != null) {
changeSomeExtraActivityStatus(null,unionShareOrders.getPromoteUid(),unionShareOrders.getCpsExtraActivityId());
if (unionShareOrders.getCpsExtraActivityId() != null && unionShareOrders.getCpsExtraActivityId() > 0) {
changeSomeExtraActivityStatus(null, unionShareOrders.getPromoteUid(), unionShareOrders.getCpsExtraActivityId());
}
}
... ... @@ -1400,12 +1416,12 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
}
/**
* 获取订单参与的满返活动返利单
* 获取订单参与的满返活动返利单
* */
private UnionShareOrders getRelatedActivityOrder(Integer orderUid,int promoteUid,int activityId) {
logger.info("getRelatedActivityOrder,orderUid is {},,promoteUid is {},activityId is {}.",orderUid,promoteUid,activityId);
UnionShareOrdersActivity activity = queryActivity(activityId);
if (null == activity || activity.getType() != 3) {
if (null == activity || (activity.getType() != 3&& activity.getType() != 4)) {
return null;
}
//
... ... @@ -1530,15 +1546,25 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
public void dealWithCpsNewUserActivity(UnionShareOrdersActivity activity,int beginTime,int endTime,int orderEndTime) {
logger.info("dealWithCpsNewUserActivity,activity is {},beginTime is {},endTime is {},orderEndTime is {}.",activity,beginTime,endTime,orderEndTime);
//查询可以参与活动的uid
Set<Integer> uids=unionShareUserApplyMapper.selectUidListByTime(activity.getStartTime(), activity.getEndTime());
if (activity.getStartTime() > beginTime) {
beginTime = activity.getStartTime();
}
if (activity.getEndTime() < endTime) {
endTime = activity.getEndTime();
}
if (endTime <= beginTime) {
return;
}
Set<Integer> uids=unionShareUserApplyMapper.selectUidListByTime(beginTime, endTime);
logger.info("dealWithCpsNewUserActivity,activity is {},beginTime is {},endTime is {},orderEndTime is {},selectUidListByTime, uids is {}",activity,beginTime,endTime,orderEndTime,uids);
if (CollectionUtils.isEmpty(uids)) {
return;
}
//查询uid名下分享订单
Map<Integer, List<UnionShareOrders>> uidOrders=unionShareOrdersMapper.selectNewPromoteUidsOrder(uids, orderEndTime);
List<UnionShareOrders> orders=unionShareOrdersMapper.selectNewPromoteUidsOrder(uids, orderEndTime);
Map<Integer, List<UnionShareOrders>> uidOrders=orders.stream().collect(Collectors.groupingBy(UnionShareOrders::getPromoteUid));
uids.forEach(u->{
joinNewCpsActivity(u,uidOrders.get(u), activity.getId());
joinNewCpsActivity(u, uidOrders.get(u), activity.getId());
});
//发放完成
... ... @@ -1585,7 +1611,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
@Override
public List<UnionShareOrdersActivity> queryLastDaysIngActivity(int beginTime,int endTime) {
logger.info("queryLastDaysActivity.beginTime is {},endTime is {}.",beginTime,endTime);
if (beginTime <= endTime) {
if (beginTime >= endTime) {
return null;
}
... ... @@ -1593,26 +1619,27 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
return activities;
}
//查询进行中的活动
private List<UnionShareOrdersActivity> queryActivity() {
logger.info("queryActivity.");
String activitiesCache = redisValueCache.get(ShareOrdersKeyEnum.ACTIVITY_ING_LIST.getPreKey(), String.class);
//查询某时间为进行中的活动
private List<UnionShareOrdersActivity> queryActivityByDate(int date) {
logger.info("queryActivityByDate.date is {}.",date);
String dateStr=DateUtil.getDateStrBySecond(date, "yyyyMMdd");
String activitiesCache = redisValueCache.get(ShareOrdersKeyEnum.ACTIVITY_ING_LIST.getPreKey()+dateStr, String.class);
List<UnionShareOrdersActivity> activities;
if (activitiesCache != null) {
activities = JSONObject.parseArray(activitiesCache, UnionShareOrdersActivity.class);
if (CollectionUtils.isNotEmpty(activities)) {
logger.info("queryActivity.get chache {}",activities);
logger.info("queryActivityByDate.date is {},dateStr is {},get chache {}",date,dateStr,activities);
return activities;
}
}
activities=unionShareOrdersActivityMapper.selectByDate(DateUtil.getCurrentTimeSecond());
activities=unionShareOrdersActivityMapper.selectByDate(date);
if (CollectionUtils.isEmpty(activities)) {
return new ArrayList<>();
}
logger.info("queryActivity.add to redis.value is {}",activities);
redisValueCache.set(ShareOrdersKeyEnum.ACTIVITY_ING_LIST.getPreKey(),activities,ShareOrdersKeyEnum.ACTIVITY_ING_LIST.getCacheTime(),TimeUnit.SECONDS);
logger.info("queryActivityByDate.add to redis.value is {}",activities);
redisValueCache.set(ShareOrdersKeyEnum.ACTIVITY_ING_LIST.getPreKey()+dateStr,activities,ShareOrdersKeyEnum.ACTIVITY_ING_LIST.getCacheTime(),TimeUnit.SECONDS);
return activities;
}
//获取某时间段可参与活动的单数
... ... @@ -1985,7 +2012,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
unionShareOrdersMapper.insertSelective(insertReq);
//活动返利
try {
List<UnionShareOrdersActivity> activityList = queryActivity();
List<UnionShareOrdersActivity> activityList = queryActivityByDate(bo.getOrderTime());
for (UnionShareOrdersActivity a :activityList ) {
if(participateActivity(insertReq,a)) {
//参加了活动,参加一个加返活动就可以了
... ... @@ -2253,8 +2280,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
bo.setOrderCodes(orderCodes);
bo.setOrderList(orderList);
bo.setActivities(activityBos);
System.out.println(JsonUtil.objectToJSON(bo));
mqLog.info("relateSettlementAndOrder,send mq {} to erp,uid is {},settlementCode is {},bo is {}", SETTLEMENT_TOPIC, uid, settlementCode, bo);
mqLog.info("relateSettlementAndOrder,send mq {} to erp,uid is {},settlementCode is {},bo is {}", SETTLEMENT_TOPIC, uid, settlementCode, JsonUtil.objectToJSON(bo));
yhProducer.send(SETTLEMENT_TOPIC, bo);
settlementLog.info("relateSettlementAndOrder,send mq {} to erp success,uid is {},settlementCode is {},bo is {}", SETTLEMENT_TOPIC, uid, settlementCode, bo);
return totalAmount;
... ...
... ... @@ -34,7 +34,7 @@ public class CpsNewUserActivityTask {
if (CollectionUtils.isEmpty(activities)) {
return;
}
int orderEndTime = DateUtil.getLastDayInt(1);
int orderEndTime = DateUtil.getLastDayInt(0);
//其实一天只允许有一个活动
activities.forEach(a->{
unionShareService.dealWithCpsNewUserActivity(a,beginTime,endTime,orderEndTime);
... ...
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Yoho!Buy运营平台</title>
<script src="/union/js/include.js"></script>
<script src="/union/js/ajaxfileupload.js"></script>
</head>
<body class="easyui-layout" fit="true">
<div region="north" style="padding-bottom: 35px; height: auto;">
<script>
document.write(addHead('CPS联盟管理', 'CPS联盟用户管理'));
</script>
<form id="searchForm" method="post" accept-charset="utf-8">
<div style="margin-left: 10px;margin-top: 10px">
<label>用户ID:</label>
<input class="easyui-textbox" id="uid" name="uid"/>
<label>渠道号:</label>
<input class="easyui-textbox" id="unionType" name="unionType"/>
<label>是否有锁粉权限:</label>
<input class="easyui-combobox" id="specialStatus" name="specialStatus"
data-options="valueField: 'value',
textField: 'label',
data: [{
label: '是',
value: '2'
},{
label: '否',
value: '1'
}]">
</input>
<a id="searchBtn" style="margin-left: 20px" class="easyui-linkbutton btn-primary" data-options="iconCls:'icon-more'">查询</a>
</div>
</form>
</div>
<div region="center">
<div style="margin-left: 30px;margin-top: 20px; height: 500px;">
<table id="userTable"></table>
</div>
</div>
<script type="text/javascript">
$(function () {
$("#userTable").myDatagrid({
fit: true,
fitColumns: true,
<!-- idField: "id",-->
nowrap: false,
url: contextPath + "/UnionShareRest/queryUnionShareUsers",
method: 'POST',
loadFilter: function (data) {
var temp = defaultLoadFilter(data);
temp=null==temp?[]:temp;
temp.rows = temp.list;
return temp;
},
columns: [[{
title: "用户ID",
field: "uid",
width: 200,
align: "center"
}, {
title: "渠道号",
field: "unionType",
width: 200,
align: "center"
}, {
title: "渠道名称",
field: "unionName",
width: 200,
align: "center"
}, {
title: "是否有锁粉权限",
field: "specialStatus",
width: 200,
align: "center",
formatter: function (value, rowData, rowIndex) {
//状态:1-申请中,2-通过,3-拒绝
if(value == 1) {
return "否";
}
if(value == 2) {
return "是";
}
}
}, {
title: "创建时间",
field: "createTimeStr",
width: 200,
align: "center"
}, {
title: "更新时间",
field: "updateTimeStr",
width: 200,
align: "center"
}, {
title: "参与新人活动id",
field: "cpsActivityId",
width: 100,
align: "center"
}
]],
cache: false,
pagination: true,
pageSize: 10,
pageList: [10],
idField: "id",
singleSelect: false,
checkOnSelect: false
});
$("#searchBtn").linkbutton({
iconCls : "icon-search",
onClick : function() {
var param = getParams();
$("#userTable").myDatagrid("load", param);
}
});
function getParams() {
var param = {
uid:$("#uid").val(),
unionType:$("#unionType").val(),
specialStatus:$("#specialStatus").combobox('getValue')
};
return param;
}
});
</script>
</body>
</html>
\ No newline at end of file
... ...