Authored by mingdan.ge

cps5mq处理

... ... @@ -208,15 +208,15 @@ public class DateUtil {
public static int getLastDayInt(int lastDay) {
Calendar time = Calendar.getInstance();
time.add(Calendar.DAY_OF_YEAR,-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,-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);
}
... ...
... ... @@ -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);
... ...
... ... @@ -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
... ...
... ... @@ -160,7 +160,7 @@
<update id="updateCpsActByUid" >
update union_share_user
set cps_activity_id = #{activityId,jdbcType=INTEGER},
update_time = #{updateTime,jdbcType=INTEGER},
update_time = #{updateTime,jdbcType=INTEGER}
where uid = #{uid,jdbcType=INTEGER} and cps_activity_id is NULL
</update>
</mapper>
\ No newline at end of file
... ...
... ... @@ -1368,21 +1368,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());
}
}
... ... @@ -1399,12 +1399,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;
}
//
... ... @@ -1535,9 +1535,10 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
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());
});
//发放完成
... ...
... ... @@ -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);
... ...