Authored by mingdan.ge

Merge branch 'master' into dev_181025_cps8

# Conflicts:
#	dal/src/main/java/com/yoho/unions/dal/model/UnionShareOrdersActivity.java
#	dal/src/main/resources/META-INF/mybatis/UnionShareOrdersActivityMapper.xml
... ... @@ -35,6 +35,7 @@ public interface UnionShareOrdersMapper {
List<UnionShareOrders> selectAllListByUids(@Param("beginTime") int beginTime,@Param("endTime") int endTime,@Param("uid") Integer uid,@Param("orderCode") String orderCode);
List<UnionShareOrdersUidBo> selectUidList(@Param("beginTime") int beginTime, @Param("endTime") int endTime);
List<UnionShareOrdersUidBo> selectPromoteUidList(@Param("beginTime") int beginTime, @Param("endTime") int endTime);
List<UnionShareOrdersUidBo> selectUidAmountList(@Param("beginTime") int beginTime, @Param("endTime") int endTime);
List<UnionShareOrdersUidBo> selectUidSettlementList(@Param("beginTime") int beginTime, @Param("endTime") int endTime);
... ...
... ... @@ -10,6 +10,7 @@ public class UnionShareOrdersActivity extends BaseBO{
private String activityName;
private Integer type;
private Integer extraUidType;
private Integer needSkn;
private String skns;
... ... @@ -166,6 +167,14 @@ public class UnionShareOrdersActivity extends BaseBO{
this.uids = uids;
}
public Integer getExtraUidType() {
return extraUidType;
}
public void setExtraUidType(Integer extraUidType) {
this.extraUidType = extraUidType;
}
public String getSkns() {
return skns;
}
... ...
... ... @@ -5,6 +5,7 @@
<id column="id" property="id" jdbcType="INTEGER" />
<result column="activity_name" property="activityName" jdbcType="VARCHAR" />
<result column="type" property="type" jdbcType="INTEGER" />
<result column="extra_uid_type" property="extraUidType" jdbcType="INTEGER" />
<result column="need_skn" property="needSkn" jdbcType="INTEGER" />
<result column="skns" property="skns" jdbcType="VARCHAR" />
<result column="collage" property="collage" jdbcType="INTEGER" />
... ... @@ -24,7 +25,7 @@
</resultMap>
<sql id="Base_Column_List" >
id, activity_name, type, need_skn,skns,collage, is_new,new_days,uids_type, amount,order_amount, percent, progress, start_time,
end_time, create_time, status, priority
end_time, create_time, status, priority,extra_uid_type
</sql>
<sql id="Blob_Column_List" >
uids
... ... @@ -65,13 +66,13 @@
need_skn,skns,collage, is_new,new_days,uids_type,uids, amount,order_amount,
percent, progress, start_time,
end_time, create_time, status,
priority)
priority,extra_uid_type)
values (#{id,jdbcType=INTEGER}, #{activityName,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER},
#{needSkn,jdbcType=INTEGER},#{skns,jdbcType=VARCHAR},#{collage,jdbcType=INTEGER}, #{isNew,jdbcType=TINYINT},#{newDays,jdbcType=INTEGER}
,#{uidsType,jdbcType=INTEGER},#{uids,jdbcType=VARCHAR}, #{amount,jdbcType=DECIMAL}, #{orderAmount,jdbcType=DECIMAL},
#{percent,jdbcType=INTEGER}, #{progress,jdbcType=INTEGER}, #{startTime,jdbcType=INTEGER},
#{endTime,jdbcType=INTEGER}, #{createTime,jdbcType=INTEGER}, #{status,jdbcType=INTEGER},
#{priority,jdbcType=INTEGER})
#{priority,jdbcType=INTEGER},#{extraUidType,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="com.yoho.unions.dal.model.UnionShareOrdersActivity" >
insert into union_share_orders_activity
... ... @@ -133,6 +134,9 @@
<if test="priority != null" >
priority,
</if>
<if test="extraUidType != null" >
extra_uid_type,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
... ... @@ -192,6 +196,9 @@
<if test="priority != null" >
#{priority,jdbcType=INTEGER},
</if>
<if test="extraUidType != null" >
#{extraUidType,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yoho.unions.dal.model.UnionShareOrdersActivity" >
... ...
... ... @@ -398,6 +398,18 @@
</if>
group by promote_uid,order_uid
</select>
<select id="selectPromoteUidList" resultType="com.yoho.service.model.union.bo.UnionShareOrdersUidBo">
select promote_uid as promoteUid,count(id) as num
from union_share_orders
where status in(10,20,30,40) and order_code is not null
<if test="beginTime != null" >
and order_time &gt;= #{beginTime}
</if>
<if test="endTime != null" >
and order_time &lt;= #{endTime}
</if>
group by promote_uid
</select>
<select id="selectUidAmountList" resultType="com.yoho.service.model.union.bo.UnionShareOrdersUidBo">
select promote_uid as promoteUid,sum(amount) as amount,count(order_code) as num
from union_share_orders
... ... @@ -426,7 +438,10 @@
select
<include refid="Base_Column_List" />
from union_share_orders where order_code is not null and status in (10,20,30,40)
and order_uid = #{orderUid} and promote_uid = #{promoteUid}
and promote_uid = #{promoteUid}
<if test="orderUid != null" >
and order_uid = #{orderUid}
</if>
<if test="beginTime != 0" >
and order_time &gt; #{beginTime}
</if>
... ...
... ... @@ -2032,9 +2032,16 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
return;
}
// int minNum = queryActivityItemMinNum(activity.getId());
//查询可以参与活动的uid组
logger.info("dealWithWaitActivity,activity is {},selectUidList",activity);
List<UnionShareOrdersUidBo> uids=unionShareOrdersMapper.selectUidList(activity.getStartTime(), activity.getEndTime());
List<UnionShareOrdersUidBo> uids;
//满单返过滤维度:1-下单人满单,2-分享人满单
if (activity.getExtraUidType() == 2) {
uids = unionShareOrdersMapper.selectPromoteUidList(activity.getStartTime(), activity.getEndTime());
} else {
uids = unionShareOrdersMapper.selectUidList(activity.getStartTime(), activity.getEndTime());
}
logger.info("dealWithWaitActivity,activity is {},selectUidList, uids is {}",activity,uids);
uids.forEach(u->{
joinExtraActivity(u.getOrderUid(), u.getPromoteUid(), activity.getId());
... ... @@ -2117,7 +2124,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
return activities;
}
//获取某时间段可参与活动的单数
private List<UnionShareOrders> queryUidActivity(int orderUid,int promoteUid,int beginTime,int endTime) {
private List<UnionShareOrders> queryUidActivity(Integer orderUid,int promoteUid,int beginTime,int endTime) {
logger.info("queryUidActivity,orderUid is {},promoteUid is {},beginTime is {},endTime is {}.",orderUid,promoteUid,beginTime,endTime);
List<UnionShareOrders> orders = unionShareOrdersMapper.selectListByOrderUidForActivity(beginTime, endTime, orderUid,promoteUid);
return orders;
... ... @@ -2222,7 +2229,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
/**
* 参加满x单额外返活动
* */
public boolean joinExtraActivity(int orderUid ,int promoteUid ,int activityId){
public boolean joinExtraActivity(Integer orderUid ,int promoteUid ,int activityId){
logger.info("joinExtraActivity,orderUid is {},promoteUid is {},activityId is {}.",orderUid,promoteUid,activityId);
//查询是否已参加过此活动
... ... @@ -2345,11 +2352,11 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
//向数据库插入参与某种额外返、新cps额外返活动的数据
boolean insertJoinDataForActivity(List<UnionShareOrders> orders, Integer orderUid , int promoteUid , UnionShareOrdersActivity activity, UnionShareOrdersActivityItem item) {
//满足此项标准
if (orderUid != null && activity.getType() != 3) {
// if (orderUid != null && activity.getType() != 3) {
//活动类型:1-订单返利比例升级,2-订单返利翻x倍,3-额外返,4-cps新人额外返
//当类型为3时需要传orderUid,当类型为4时不需要传orderUid
return false;
}
// return false;
// }
StringBuilder ordersStr = new StringBuilder();
List<Integer> orderIds = new ArrayList<>();
String status=ShareOrdersStatusEnum.CAN_SETTLE.getCode();
... ... @@ -2364,14 +2371,14 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
int now = DateUtil.getCurrentTimeSecond();
UnionShareOrders insertExtraOrder = new UnionShareOrders();
UnionShareOrdersActivityLogs logs = new UnionShareOrdersActivityLogs();
if (orderUid != null) {
if (activity.getType() == 3) {
//3-额外返
logger.info("insertJoinDataForActivity,orderUid is {},promoteUid is {},activityId is {},updateByIdsForExtraActivity,orderIds is {} .",orderUid,promoteUid,activity.getId(),orderIds);
unionShareOrdersMapper.updateByIdsForExtraActivity(orderIds, activity.getId(),now);
insertExtraOrder.setOrderUid(orderUid);
logs.setOrderUid(orderUid);
insertExtraOrder.setExtraActivityId(activity.getId());
}else {
} else if (activity.getType() == 4) {
//4-cps新人n天额外返
int updateNum = unionShareUserMapper.updateCpsActByUid(promoteUid, activity.getId(), now);
if (updateNum < 1) {
... ... @@ -2379,8 +2386,10 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
return false;
}
//更新关联订单
unionShareOrdersMapper.updateByIdsForCpsUserActivity(orderIds, activity.getId(),now);
unionShareOrdersMapper.updateByIdsForCpsUserActivity(orderIds, activity.getId(), now);
insertExtraOrder.setCpsExtraActivityId(activity.getId());
} else {
return false;
}
//插入额外返利单
... ...