Authored by mingdan.ge

cps收入列表和订单列表修改+定时满单返

... ... @@ -9,6 +9,7 @@ public enum ShareOrdersKeyEnum {
ORDER_LIST("yh:union:share:orderList:","type:{}:status:{}: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,"用户提现未提现总计"),
SETTLEMENT_LIST("yh:union:share:settlementList:","key:{}:page:{}:limit:{}",600,"提现列表"),
UNION_TYPE("yh:union:share:unionType:","key:{}",600,"用户登录时获取对应的渠道号"),
... ...
... ... @@ -14,6 +14,7 @@ public interface UnionShareOrdersActivityItemMapper {
UnionShareOrdersActivityItem selectByPrimaryKey(Integer id);
List<UnionShareOrdersActivityItem> selectByActivityId(Integer activityId);
Integer selectMinNumByActivityId(Integer activityId);
int updateByPrimaryKeySelective(UnionShareOrdersActivityItem record);
... ...
... ... @@ -14,8 +14,11 @@ public interface UnionShareOrdersActivityMapper {
UnionShareOrdersActivity selectByPrimaryKey(Integer id);
List<UnionShareOrdersActivity> selectByDate(@Param("time") Integer time);
List<UnionShareOrdersActivity> selectWaitListByDate(@Param("time") Integer time);
int updateByPrimaryKeySelective(UnionShareOrdersActivity record);
int updateByPrimaryKey(UnionShareOrdersActivity record);
int updateStatusById(@Param("id")int id,@Param("oldStatus")int oldStatus,@Param("newStatus")int newStatus,@Param("updateTime")int updateTime);
}
\ No newline at end of file
... ...
package com.yoho.unions.dal;
import com.yoho.service.model.union.bo.UnionShareOrdersUidBo;
import com.yoho.service.model.union.request.UnionShareOrderReqBO;
import com.yoho.unions.dal.model.UnionShareOrders;
import org.apache.ibatis.annotations.Param;
... ... @@ -26,6 +27,7 @@ public interface UnionShareOrdersMapper {
List<UnionShareOrders> selectListByOrderCodesForActivity(@Param("orderCodes") List<String> orderCodes);
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,@Param("num") Integer num);
List<UnionShareOrders> selectListByOrderUidForActivity(@Param("beginTime") int beginTime,@Param("endTime") int endTime,@Param("orderUid") Integer orderUid,@Param("promoteUid") Integer promoteUid);
UnionShareOrders selectActivityOrderByUid(@Param("activityId") int activityId,@Param("orderUid") Integer orderUid,@Param("promoteUid") Integer promoteUid);
... ...
... ... @@ -34,6 +34,7 @@ public class UnionShareOrders {
private Integer extraActivityId;
private Integer activityId;
private String activityName;
private BigDecimal extraAmount;
private BigDecimal orderAmount;
... ... @@ -165,6 +166,14 @@ public class UnionShareOrders {
this.activityId = activityId;
}
public String getActivityName() {
return activityName;
}
public void setActivityName(String activityName) {
this.activityName = activityName;
}
public BigDecimal getExtraAmount() {
return extraAmount;
}
... ... @@ -209,6 +218,7 @@ public class UnionShareOrders {
", updateTime=" + updateTime +
", extraActivityId=" + extraActivityId +
", activityId=" + activityId +
", activityName=" + activityName +
", extraAmount=" + extraAmount +
", orderAmount=" + orderAmount +
'}';
... ...
... ... @@ -27,6 +27,10 @@
where activity_id = #{activityId,jdbcType=INTEGER} and status=1
order by priority desc
</select>
<select id="selectMinNumByActivityId" resultType="java.lang.Integer" parameterType="java.lang.Integer" >
select min(order_min_num) from union_share_orders_activity_item
where activity_id = #{activityId,jdbcType=INTEGER} and status=1
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from union_share_orders_activity_item
where id = #{id,jdbcType=INTEGER}
... ...
... ... @@ -33,6 +33,12 @@
where status=1 and start_time &lt; #{time,jdbcType=INTEGER} and end_time &gt; #{time,jdbcType=INTEGER}
order by priority desc
</select>
<select id="selectWaitListByDate" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from union_share_orders_activity
where status=1 and type=3 and progress=0 and end_time &lt; #{time,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from union_share_orders_activity
where id = #{id,jdbcType=INTEGER}
... ... @@ -192,4 +198,10 @@
priority = #{priority,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateStatusById" >
update union_share_orders_activity
set status = #{newStatus,jdbcType=INTEGER},
update_time = #{updateTime,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER} and status = #{oldStatus,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
... ...
... ... @@ -16,12 +16,13 @@
<result column="update_time" property="updateTime" jdbcType="INTEGER" />
<result column="extra_activity_id" property="extraActivityId" 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" />
<result column="order_amount" property="orderAmount" jdbcType="DECIMAL" />
</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,extra_amount,order_amount
update_time,extra_activity_id,activity_id,activity_name,extra_amount,order_amount
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
... ... @@ -101,13 +102,13 @@
order_uid, settlement_code, status,
last_order_amount, order_time, is_new,
amount, create_time, update_time,
extra_activity_id, activity_id, extra_amount,
extra_activity_id, activity_id,activity_name, extra_amount,
order_amount)
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}, #{extraAmount,jdbcType=DECIMAL},
#{extraActivityId,jdbcType=INTEGER}, #{activityId,jdbcType=INTEGER},#{activityName,jdbcType=VARCHAR}, #{extraAmount,jdbcType=DECIMAL},
#{orderAmount,jdbcType=DECIMAL})
</insert>
<insert id="insertSelective" useGeneratedKeys="true" keyProperty="id" parameterType="com.yoho.unions.dal.model.UnionShareOrders" >
... ... @@ -155,6 +156,9 @@
<if test="activityId != null" >
activity_id,
</if>
<if test="activityName != null" >
activity_name,
</if>
<if test="extraAmount != null" >
extra_amount,
</if>
... ... @@ -205,6 +209,9 @@
<if test="activityId != null" >
#{activityId,jdbcType=INTEGER},
</if>
<if test="activityName != null" >
#{activityName,jdbcType=VARCHAR},
</if>
<if test="extraAmount != null" >
#{extraAmount,jdbcType=DECIMAL},
</if>
... ... @@ -255,6 +262,9 @@
<if test="activityId != null" >
activity_id = #{activityId,jdbcType=INTEGER},
</if>
<if test="activityName != null" >
activity_name = #{activityName,jdbcType=VARCHAR},
</if>
<if test="extraAmount != null" >
extra_amount = #{extraAmount,jdbcType=DECIMAL},
</if>
... ... @@ -288,6 +298,7 @@
update_time = #{updateTime,jdbcType=INTEGER},
extra_activity_id = #{extraActivityId,jdbcType=INTEGER},
activity_id = #{activityId,jdbcType=INTEGER},
activity_name = #{activityName,jdbcType=VARCHAR},
extra_amount = #{extraAmount,jdbcType=DECIMAL},
order_amount = #{orderAmount,jdbcType=DECIMAL}
where id = #{id,jdbcType=INTEGER}
... ... @@ -301,10 +312,10 @@
and order_code = #{orderCode}
</if>
<if test="beginTime != 0" >
and create_time &gt; #{beginTime}
and order_time &gt; #{beginTime}
</if>
<if test="endTime != 0" >
and create_time &lt;#{endTime}
and order_time &lt;#{endTime}
</if>
</select>
<select id="selectAllListByUids" resultMap="BaseResultMap">
... ... @@ -316,12 +327,26 @@
and order_code = #{orderCode}
</if>
<if test="beginTime != 0" >
and create_time &gt; #{beginTime}
and order_time &gt; #{beginTime}
</if>
<if test="endTime != 0" >
and create_time &lt;#{endTime}
and order_time &lt;#{endTime}
</if>
order BY order_time desc
</select>
<select id="selectUidList" resultType="com.yoho.service.model.union.bo.UnionShareOrdersUidBo">
select promote_uid as promoteUid,order_uid as orderUid,count(id) as num
from union_share_orders
where status in(10,20,30,40) and order_code is not null
<if test="num != null" >
and count(id) &gt;= #{num}
</if>
<if test="beginTime != null" >
and order_time &gt; #{beginTime}
</if>
<if test="endTime != null" >
and order_time &lt;#{endTime}
</if>
order BY create_time desc
</select>
<select id="selectListByOrderUidForActivity" resultMap="BaseResultMap">
select
... ... @@ -351,12 +376,12 @@
and order_code = #{orderCode}
</if>
<if test="beginTime != 0" >
and create_time &gt; #{beginTime}
and order_time &gt; #{beginTime}
</if>
<if test="endTime != 0" >
and create_time &lt;#{endTime}
and order_time &lt;#{endTime}
</if>
order BY create_time desc
order BY order_time desc
limit #{startIndex},#{pageSize}
</select>
<update id="updateStatusById" >
... ... @@ -395,7 +420,13 @@
select
<include refid="Base_Column_List" />
from union_share_orders
where promote_uid = #{params.uid,jdbcType=INTEGER} and order_code is not null
where promote_uid = #{params.uid,jdbcType=INTEGER}
<if test="params.type != null and params.type == 1">
and order_code is not null
</if>
<if test="params.type != null and params.type == 2">
and activity_id &gt;0
</if>
<if test="params.tab1 != null and params.tab1 == 1 and params.tab2 == 0">
AND status != 100
</if>
... ... @@ -421,7 +452,7 @@
AND status = 40
</if>
<if test="params.tab1 != null and params.tab1 == 3">
AND status IN (91,92,93)
AND status IN (91,92,93,200)
</if>
order by order_time desc
limit #{params.start,jdbcType=INTEGER}, #{params.size,jdbcType=INTEGER}
... ... @@ -431,7 +462,13 @@
select
count(1)
from union_share_orders
where promote_uid = #{params.uid,jdbcType=INTEGER} and order_code is not null
where promote_uid = #{params.uid,jdbcType=INTEGER}
<if test="params.type != null and params.type == 1">
and order_code is not null
</if>
<if test="params.type != null and params.type == 2">
and activity_id &gt;0
</if>
<if test="params.tab1 != null and params.tab1 == 1 and params.tab2 == 0">
AND status != 100
</if>
... ...
... ... @@ -4,6 +4,8 @@ import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import com.yoho.service.model.union.bo.*;
import com.yoho.unions.dal.model.UnionShareOrdersActivityLogs;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -19,13 +21,6 @@ import com.yoho.core.dal.datasource.annotation.Database;
import com.yoho.core.rest.annotation.ServiceDesc;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yoho.service.model.union.bo.IdOrIdsBo;
import com.yoho.service.model.union.bo.ShareOrderBo;
import com.yoho.service.model.union.bo.ShareSettlementBo;
import com.yoho.service.model.union.bo.ShareUserSettlementInfoBo;
import com.yoho.service.model.union.bo.UnionShareBankBo;
import com.yoho.service.model.union.bo.UnionShareUserBankBo;
import com.yoho.service.model.union.bo.UnionShareUserBo;
import com.yoho.service.model.union.request.UnionShareOrderReqBO;
import com.yoho.service.model.union.request.UnionShareOrderSearchReqBO;
import com.yoho.service.model.union.request.UnionShareUserApplyListReqBo;
... ... @@ -257,6 +252,21 @@ public class UnionShareRest {
ShareOrderBo shareOrderBo = unionShareService.queryOrderDetail(unionShareOrderReqBO.getUid(), unionShareOrderReqBO.getOrderCode());
return new UnionResponse(200, "queryOderDetail success",shareOrderBo);
}
/**
* 活动奖励订单明细
* @param unionShareOrderReqBO
* @return
*/
@RequestMapping("/queryActivityOrder")
@ResponseBody
public UnionResponse queryActivityOrder(@RequestBody UnionShareOrderReqBO unionShareOrderReqBO){
log.info("UnionShareRest.queryActivityOrder unionShareOrderReqBO is {}", unionShareOrderReqBO);
if (null == unionShareOrderReqBO || null == unionShareOrderReqBO.getUid() || null == unionShareOrderReqBO.getActivityOrderId()){
return new UnionResponse(400, "queryActivityOrder uid or orderCode is null");
}
UnionShareOrdersActivityLogsBo shareOrderBo = unionShareService.queryActivityOrder(unionShareOrderReqBO.getUid(),unionShareOrderReqBO.getActivityOrderId());
return new UnionResponse(200, "queryActivityOrder success",shareOrderBo);
}
/**
* 提现记录列表
... ...
... ... @@ -10,6 +10,8 @@ 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.UnionShareOrders;
import com.yoho.unions.dal.model.UnionShareOrdersActivity;
import com.yoho.unions.dal.model.UnionShareOrdersActivityLogs;
import com.yoho.unions.dal.model.UnionShareSettlement;
import java.math.BigDecimal;
... ... @@ -27,6 +29,10 @@ public interface IUnionShareService {
*/
void saveOrUpdateOrder(ShareOrderBo bo);
List<UnionShareOrdersActivity> queryWaitActivity();
void dealWithWaitActivity(UnionShareOrdersActivity activity);
PageUnionShareOrderRspBO queryUnionShareOrders(UnionShareOrderSearchReqBO reqBO);
/**
* 提现结算单状态变更
... ... @@ -119,6 +125,13 @@ public interface IUnionShareService {
ShareOrderBo queryOrderDetail(Integer uid, String orderCode);
/**
* 活动奖励订单明细
* @param activityOrderId
* @return
*/
UnionShareOrdersActivityLogsBo queryActivityOrder(Integer uid,Integer activityOrderId);
/**
* 提现记录列表
* @param unionShareOrderReqBO
* @return
... ...
... ... @@ -842,7 +842,9 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
DecimalFormat df1 = new DecimalFormat("0.00");
for (UnionShareOrders unionShareOrders : unionShareOrdersList){
unionShareOrders.setOrderTimeStr(DateUtils.int2DateStr(unionShareOrders.getOrderTime(), DateUtils.POINT_FOMARTPATTER));
unionShareOrders.setLastOrderAmountStr(df1.format(unionShareOrders.getLastOrderAmount()));
if (unionShareOrders.getLastOrderAmount() != null) {
unionShareOrders.setLastOrderAmountStr(df1.format(unionShareOrders.getLastOrderAmount()));
}
if (Integer.valueOf(unionShareOrders.getStatus()) > 90){
unionShareOrders.setAmountStr("+0");
}else {
... ... @@ -893,6 +895,39 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
return shareOrderBo;
}
/**
* 活动奖励订单明细
* @param activityOrderId
* @return
*/
@Override
public UnionShareOrdersActivityLogsBo queryActivityOrder(Integer uid,Integer activityOrderId){
//先从缓存获取
UnionShareOrdersActivityLogsBo cacheResult = getFromRedis(ShareOrdersKeyEnum.ACTIVITY_ORDER, uid, UnionShareOrdersActivityLogsBo.class, activityOrderId.toString());
if (cacheResult != null) {
logger.debug("UnionShareServiceImpl :: queryOrderDetail get redis cache ,uid is {},cacheResult is {}",uid,cacheResult);
return cacheResult;
}
//数据库获取数据
UnionShareOrdersActivityLogs activityLog = getLogsByOrderId(activityOrderId);
if (activityLog == null) {
return null;
}
UnionShareOrdersActivity activity=queryActivity(activityLog.getActivityId());
UnionShareOrdersActivityLogsBo activityLogBo = new UnionShareOrdersActivityLogsBo();
activityLogBo.setActivityName(activityLog.getActivityName());
DecimalFormat df1 = new DecimalFormat("0.00");
if (activityLog.getStatus() == 0) {
activityLogBo.setAmountStr("¥0");
} else {
activityLogBo.setAmountStr("¥"+df1.format(activityLog.getAmount()));
}
activityLogBo.setOrdercodes(activityLog.getOrders().split(","));
activityLogBo.setTimeStr(DateUtils.int2DateStr(activity.getStartTime(),DateUtils.DEFAULT_FOMARTPATTER)+"-"+DateUtils.int2DateStr(activity.getEndTime(),DateUtils.DEFAULT_FOMARTPATTER));
//设置缓存
addToRedis(ShareOrdersKeyEnum.ACTIVITY_ORDER,uid,activityLogBo, activityOrderId.toString());
return activityLogBo;
}
private void dealWithOrderStatus(ShareOrderBo shareOrderBo) {
//10.待确认 20.待提现 30.提现中 40.提现成功 91.订单取消 92.订单退货 93.订单换货 100.不可结算
switch (Integer.valueOf(shareOrderBo.getStatus())){
... ... @@ -971,7 +1006,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
public PageResponseBO<UnionShareOrders> queryOrderList(UnionShareOrderReqBO unionShareOrderReqBO) {
//先从缓存获取
PageResponseBO<UnionShareOrders> cacheResult = getFromRedis(ShareOrdersKeyEnum.ORDER_LIST, unionShareOrderReqBO.getUid(),PageResponseBO.class, unionShareOrderReqBO.getTab1().toString(),
unionShareOrderReqBO.getTab2().toString(), String.valueOf(unionShareOrderReqBO.getPage()), String.valueOf(unionShareOrderReqBO.getSize()));
unionShareOrderReqBO.getTab2().toString(), String.valueOf(unionShareOrderReqBO.getPage()), String.valueOf(unionShareOrderReqBO.getSize()),unionShareOrderReqBO.getType().toString());
if (cacheResult != null) {
logger.debug("UnionShareServiceImpl :: queryOrderList get redis cache ,uid is {},cacheResult is {}",unionShareOrderReqBO.getUid(),cacheResult);
return cacheResult;
... ... @@ -1001,7 +1036,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
response.setList(unionShareOrdersList);
//设置缓存
addToRedis(ShareOrdersKeyEnum.ORDER_LIST,unionShareOrderReqBO.getUid(),response,unionShareOrderReqBO.getTab1().toString(), unionShareOrderReqBO.getTab2().toString(),
String.valueOf(unionShareOrderReqBO.getPage()), String.valueOf(unionShareOrderReqBO.getSize()));
String.valueOf(unionShareOrderReqBO.getPage()), String.valueOf(unionShareOrderReqBO.getSize()),unionShareOrderReqBO.getType().toString());
return response;
}
... ... @@ -1061,6 +1096,13 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
}
}
if (result > 0 && unionShareOrders.getActivityId() != null&&ShareOrdersStatusEnum.isFailOrder(unionShareOrders.getStatus())){
//该订单参加了加倍返活动,需要把加倍返日志作废
UnionShareOrdersActivityLogs activityLog = getLogsByOrderId(unionShareOrders.getId());
if (activityLog != null) {
invalidActivityLog(activityLog.getId(), DateUtil.getCurrentTimeSecond());
}
}
//清缓存
clearShareOrderRedis(bo.getPromoteUid());
}
... ... @@ -1089,7 +1131,11 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
if (null == activityOrder) {
return null;
}
List<UnionShareOrdersActivityLogs> activityLogs=unionShareOrdersActivityLogsMapper.selectByOrderId(activityOrder.getId());
return getLogsByOrderId(activityOrder.getId());
}
private UnionShareOrdersActivityLogs getLogsByOrderId(int orderId) {
List<UnionShareOrdersActivityLogs> activityLogs=unionShareOrdersActivityLogsMapper.selectByOrderId(orderId);
if (CollectionUtils.isEmpty(activityLogs)) {
return null;
}
... ... @@ -1115,14 +1161,19 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
}
}
private boolean reJoinExtraActivity(UnionShareOrdersActivityLogs activityLog){
int now = DateUtil.getCurrentTimeSecond();
//作废已参加的满单活动
//把活动参与日志状态作废
private void invalidActivityLog(int logId,int now) {
UnionShareOrdersActivityLogs updatelogs = new UnionShareOrdersActivityLogs();
updatelogs.setId(activityLog.getId());
updatelogs.setId(logId);
updatelogs.setStatus(0);//类型:1-有效,0-作废
updatelogs.setUpdateTime(now);
unionShareOrdersActivityLogsMapper.updateByPrimaryKeySelective(updatelogs);
}
private boolean reJoinExtraActivity(UnionShareOrdersActivityLogs activityLog){
int now = DateUtil.getCurrentTimeSecond();
//作废已参加的满单活动
invalidActivityLog(activityLog.getId(), now);
unionShareOrdersMapper.updateStatusById(activityLog.getOrderId(), ShareOrdersStatusEnum.PAY.getCode(), ShareOrdersStatusEnum.ACTIVITY_DISCARD.getCode(), now);
//尝试重新参加活动
... ... @@ -1164,6 +1215,36 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
return true;
}
//处理已结束等待发放奖励的活动
@Override
public void dealWithWaitActivity(UnionShareOrdersActivity activity) {
//奖励发放进度:0-未发放,1-发放中,2-已发放
int updateNum = unionShareOrdersActivityMapper.updateStatusById(activity.getId(), 0, 1, DateUtil.getCurrentTimeSecond());
if (updateNum == 0) {
//活动无需处理
return;
}
int minNum = queryActivityItemMinNum(activity.getId());
//查询可以参与活动的uid组
List<UnionShareOrdersUidBo> uids=unionShareOrdersMapper.selectUidList(activity.getStartTime(), activity.getEndTime(), minNum);
uids.forEach(u->{
joinExtraActivity(u.getOrderUid(), u.getPromoteUid(), activity.getId());
});
//发放完成
unionShareOrdersActivityMapper.updateStatusById(activity.getId(), 1, 2, DateUtil.getCurrentTimeSecond());
return ;
}
//查询已结束等待发放奖励的活动
@Override
public List<UnionShareOrdersActivity> queryWaitActivity() {
//todo 读写缓存
List<UnionShareOrdersActivity> activities=unionShareOrdersActivityMapper.selectWaitListByDate(DateUtil.getCurrentTimeSecond());
return activities;
}
//查询进行中的活动
private List<UnionShareOrdersActivity> queryActivity() {
//todo 读写缓存
... ... @@ -1207,6 +1288,14 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
return items;
}
/**
* 查询满x单返活动条目(正常状态)最低满单数
* */
private Integer queryActivityItemMinNum(int activityId) {
//todo 读写缓存
return unionShareOrdersActivityItemMapper.selectMinNumByActivityId(activityId);
}
public void clearActivityCache(int activityId) {
//todo 清除某活动缓存
}
... ... @@ -1214,7 +1303,6 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
/**
* 参加满x单额外返活动
* */
//todo 需加定时任务每天10点调用此方法,把前一天结束的活动该预发放的奖励单发下去
public boolean joinExtraActivity(int orderUid ,int promoteUid ,int activityId){
UnionShareOrdersActivity activity = queryActivity(activityId);
if (null == activity || activity.getType() != 3) {
... ... @@ -1249,9 +1337,11 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
insertExtraOrder.setAmount(item.getAmount());
insertExtraOrder.setExtraActivityId(activityId);
insertExtraOrder.setActivityId(activityId);
insertExtraOrder.setActivityName(activity.getActivityName());
insertExtraOrder.setPromoteUid(promoteUid);
insertExtraOrder.setOrderUid(orderUid);
insertExtraOrder.setStatus(status);
insertExtraOrder.setOrderTime(now);
insertExtraOrder.setCreateTime(now);
insertExtraOrder.setUpdateTime(now);
unionShareOrdersMapper.insertSelective(insertExtraOrder);
... ... @@ -1317,6 +1407,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
log.setCreateTime(DateUtil.getCurrentTimeSecond());
log.setUpdateTime(log.getCreateTime());
log.setOrderId(order.getId());
log.setAmount(extraAmount);
log.setStatus(1);
log.setOrders(order.getOrderCode());
log.setId(null);
... ... @@ -1328,6 +1419,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
updateOrder.setAmount(order.getAmount());
updateOrder.setExtraAmount(order.getExtraAmount());
updateOrder.setActivityId(activity.getId());
updateOrder.setActivityName(activity.getActivityName());
unionShareOrdersMapper.updateByPrimaryKeySelective(updateOrder);
//4、返回
... ...
package com.yoho.unions.server.task;
import com.yoho.unions.dal.model.UnionShareOrdersActivity;
import com.yoho.unions.server.service.IUnionShareService;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.List;
/**
*
* cps满x单额外返活动收益定时发放
* Created by mingdan.ge on 2018/8/8.
*/
@Component
public class CpsOrderExtraActivityTask {
private Logger logger = LoggerFactory.getLogger(CpsOrderExtraActivityTask.class);
@Autowired
IUnionShareService unionShareService;
// 每天08:30执行
@Scheduled(cron = "* 30 8 * * ?")
public void run() {
logger.info("start giving out extra rewards");
//查询已结束未发放奖励的满x单返活动
List<UnionShareOrdersActivity> activities = unionShareService.queryWaitActivity();
if (CollectionUtils.isEmpty(activities)) {
return;
}
activities.forEach(a->{
unionShareService.dealWithWaitActivity(a);
});
}
}
... ...