Authored by mingdan.ge

cps活动返

... ... @@ -3,6 +3,8 @@ package com.yoho.unions.dal;
import com.yoho.unions.dal.model.UnionShareOrdersActivityItem;
import java.util.List;
public interface UnionShareOrdersActivityItemMapper {
int deleteByPrimaryKey(Integer id);
... ... @@ -11,6 +13,7 @@ public interface UnionShareOrdersActivityItemMapper {
int insertSelective(UnionShareOrdersActivityItem record);
UnionShareOrdersActivityItem selectByPrimaryKey(Integer id);
List<UnionShareOrdersActivityItem> selectByActivityId(Integer activityId);
int updateByPrimaryKeySelective(UnionShareOrdersActivityItem record);
... ...
... ... @@ -22,10 +22,13 @@ public interface UnionShareOrdersMapper {
List<UnionShareOrders> selectListBySearchCodition(@Param("beginTime") int beginTime, @Param("endTime") int endTime, @Param("uid") Integer uid, @Param("orderCode") String orderCode, @Param("startIndex") int startIndex, @Param("pageSize") int pageSize);
List<UnionShareOrders> selectListByIds(List<String> ids);
List<UnionShareOrders> selectListByIds(@Param("ids") List<String> ids);
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<UnionShareOrders> selectListByOrderUidForActivity(@Param("beginTime") int beginTime,@Param("endTime") int endTime,@Param("orderUid") Integer orderUid,@Param("promoteUid") Integer promoteUid);
int selectCountByCondition(@Param("promoteUid")int promoteUid, @Param("status")String status);
BigDecimal selectAmountByStatus(@Param("promoteUid")int promoteUid, @Param("statusList")List<String> statusList);
... ... @@ -39,6 +42,7 @@ public interface UnionShareOrdersMapper {
List<Integer> selectIdForActivity(@Param("settlementCode")String settlementCode);
int updateByPrimaryKeySelective(UnionShareOrders record);
int updateByIdsForExtraActivity(@Param("ids")List<Integer> id,@Param("extraActivityId")Integer extraActivityId,@Param("updateTime")Integer updateTime);
int updateStatusById(@Param("id")int id,@Param("oldStatus")String oldStatus,@Param("newStatus")String newStatus,@Param("updateTime")int updateTime);
... ...
... ... @@ -32,7 +32,7 @@ public class UnionShareOrders {
private Integer updateTime;
private Integer activityType;
private Integer extraActivityId;
private Integer activityId;
private BigDecimal extraAmount;
private BigDecimal orderAmount;
... ... @@ -149,12 +149,12 @@ public class UnionShareOrders {
this.amountStr = amountStr;
}
public Integer getActivityType() {
return activityType;
public Integer getExtraActivityId() {
return extraActivityId;
}
public void setActivityType(Integer activityType) {
this.activityType = activityType;
public void setExtraActivityId(Integer extraActivityId) {
this.extraActivityId = extraActivityId;
}
public Integer getActivityId() {
... ... @@ -207,7 +207,7 @@ public class UnionShareOrders {
", amountStr='" + amountStr + '\'' +
", createTime=" + createTime +
", updateTime=" + updateTime +
", activityType=" + activityType +
", extraActivityId=" + extraActivityId +
", activityId=" + activityId +
", extraAmount=" + extraAmount +
", orderAmount=" + orderAmount +
... ...
... ... @@ -13,6 +13,7 @@ public class UnionShareOrdersActivityLogs {
private Integer activityItemId;
private Integer promoteUid;
private Integer orderUid;
private Integer orderId;
... ... @@ -66,6 +67,14 @@ public class UnionShareOrdersActivityLogs {
this.promoteUid = promoteUid;
}
public Integer getOrderUid() {
return orderUid;
}
public void setOrderUid(Integer orderUid) {
this.orderUid = orderUid;
}
public Integer getOrderId() {
return orderId;
}
... ...
... ... @@ -20,6 +20,13 @@
from union_share_orders_activity_item
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectByActivityId" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from union_share_orders_activity_item
where activity_id = #{activityId,jdbcType=INTEGER} and status=1
order by priority desc
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from union_share_orders_activity_item
where id = #{id,jdbcType=INTEGER}
... ...
... ... @@ -8,6 +8,7 @@
<result column="activity_name" property="activityName" jdbcType="INTEGER" />
<result column="activity_item_id" property="activityItemId" jdbcType="INTEGER" />
<result column="promote_uid" property="promoteUid" jdbcType="INTEGER" />
<result column="order_uid" property="orderUid" jdbcType="INTEGER" />
<result column="order_id" property="orderId" jdbcType="INTEGER" />
<result column="amount" property="amount" jdbcType="DECIMAL" />
<result column="status" property="status" jdbcType="INTEGER" />
... ... @@ -16,7 +17,7 @@
<result column="update_time" property="updateTime" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
id, activity_id, activity_type, activity_name, activity_item_id, promote_uid, order_id, amount, status, orders, create_time,
id, activity_id, activity_type, activity_name, activity_item_id, promote_uid,order_uid, order_id, amount, status, orders, create_time,
update_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
... ... @@ -44,7 +45,7 @@
select
<include refid="Base_Column_List" />
from union_share_orders_activity_logs
where orders like CONCAT('%', #{orderCode}, '%')
where status=1 and orders like CONCAT('%', #{orderCode}, '%')
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from union_share_orders_activity_logs
... ... @@ -52,11 +53,11 @@
</delete>
<insert id="insert" parameterType="com.yoho.unions.dal.model.UnionShareOrdersActivityLogs" >
insert into union_share_orders_activity_logs (id, activity_id,activity_type, activity_name, activity_item_id,
promote_uid, order_id, amount,
promote_uid, order_uid, order_id, amount,
status, orders, create_time,
update_time)
values (#{id,jdbcType=INTEGER}, #{activityId,jdbcType=INTEGER},#{activityType,jdbcType=INTEGER}, #{activityName,jdbcType=INTEGER}, #{activityItemId,jdbcType=INTEGER},
#{promoteUid,jdbcType=INTEGER}, #{orderId,jdbcType=INTEGER}, #{amount,jdbcType=DECIMAL},
#{promoteUid,jdbcType=INTEGER},#{orderUid,jdbcType=INTEGER}, #{orderId,jdbcType=INTEGER}, #{amount,jdbcType=DECIMAL},
#{status,jdbcType=INTEGER}, #{orders,jdbcType=VARCHAR}, #{createTime,jdbcType=INTEGER},
#{updateTime,jdbcType=INTEGER})
</insert>
... ... @@ -81,6 +82,9 @@
<if test="promoteUid != null" >
promote_uid,
</if>
<if test="orderUid != null" >
order_uid,
</if>
<if test="orderId != null" >
order_id,
</if>
... ... @@ -119,6 +123,9 @@
<if test="promoteUid != null" >
#{promoteUid,jdbcType=INTEGER},
</if>
<if test="orderUid != null" >
#{orderUid,jdbcType=INTEGER},
</if>
<if test="orderId != null" >
#{orderId,jdbcType=INTEGER},
</if>
... ... @@ -157,6 +164,9 @@
<if test="promoteUid != null" >
promote_uid = #{promoteUid,jdbcType=INTEGER},
</if>
<if test="orderUid != null" >
order_uid = #{orderUid,jdbcType=INTEGER},
</if>
<if test="orderId != null" >
order_id = #{orderId,jdbcType=INTEGER},
</if>
... ... @@ -191,6 +201,7 @@
activity_name = #{activityName,jdbcType=INTEGER},
activity_item_id = #{activityItemId,jdbcType=INTEGER},
promote_uid = #{promoteUid,jdbcType=INTEGER},
order_uid = #{orderUid,jdbcType=INTEGER},
order_id = #{orderId,jdbcType=INTEGER},
amount = #{amount,jdbcType=DECIMAL},
status = #{status,jdbcType=INTEGER},
... ...
... ... @@ -14,14 +14,14 @@
<result column="amount" property="amount" jdbcType="DECIMAL" />
<result column="create_time" property="createTime" jdbcType="INTEGER" />
<result column="update_time" property="updateTime" jdbcType="INTEGER" />
<result column="activity_type" property="activityType" jdbcType="INTEGER" />
<result column="extra_activity_id" property="extraActivityId" jdbcType="INTEGER" />
<result column="activity_id" property="activityId" jdbcType="INTEGER" />
<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,activity_type,activity_id,extra_amount,order_amount
update_time,extra_activity_id,activity_id,extra_amount,order_amount
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
... ... @@ -63,10 +63,19 @@
<include refid="Base_Column_List" />
from union_share_orders
where id in
<foreach collection="list" open="(" close=")" item="id" separator=",">
<foreach collection="ids" open="(" close=")" item="id" separator=",">
#{id}
</foreach>
</select>
<select id="selectListByOrderCodesForActivity" resultMap="BaseResultMap" >
select
<include refid="Base_Column_List" />
from union_share_orders
where status in (10,20,30,40) and order_code in
<foreach collection="orderCodes" open="(" close=")" item="ordercode" separator=",">
#{ordercode}
</foreach>
</select>
<select id="selectOrderCodesByCondition" resultType="java.lang.String" >
select order_code from union_share_orders
where settlement_code = #{settlementCode,jdbcType=VARCHAR} and order_code is not null
... ... @@ -92,13 +101,13 @@
order_uid, settlement_code, status,
last_order_amount, order_time, is_new,
amount, create_time, update_time,
activity_type, activity_id, extra_amount,
extra_activity_id, activity_id, 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},
#{activityType,jdbcType=INTEGER}, #{activityId,jdbcType=INTEGER}, #{extraAmount,jdbcType=DECIMAL},
#{extraActivityId,jdbcType=INTEGER}, #{activityId,jdbcType=INTEGER}, #{extraAmount,jdbcType=DECIMAL},
#{orderAmount,jdbcType=DECIMAL})
</insert>
<insert id="insertSelective" useGeneratedKeys="true" keyProperty="id" parameterType="com.yoho.unions.dal.model.UnionShareOrders" >
... ... @@ -140,8 +149,8 @@
<if test="updateTime != null" >
update_time,
</if>
<if test="activityType != null" >
activity_type,
<if test="extraActivityId != null" >
extra_activity_id,
</if>
<if test="activityId != null" >
activity_id,
... ... @@ -190,8 +199,8 @@
<if test="updateTime != null" >
#{updateTime,jdbcType=INTEGER},
</if>
<if test="activityType != null" >
#{activityType,jdbcType=INTEGER},
<if test="extraActivityId != null" >
#{extraActivityId,jdbcType=INTEGER},
</if>
<if test="activityId != null" >
#{activityId,jdbcType=INTEGER},
... ... @@ -240,8 +249,8 @@
<if test="updateTime != null" >
update_time = #{updateTime,jdbcType=INTEGER},
</if>
<if test="activityType != null" >
activity_type = #{activityType,jdbcType=INTEGER},
<if test="extraActivityId != null" >
extra_activity_id = #{extraActivityId,jdbcType=INTEGER},
</if>
<if test="activityId != null" >
activity_id = #{activityId,jdbcType=INTEGER},
... ... @@ -255,6 +264,15 @@
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByIdsForExtraActivity" >
update union_share_orders
set update_time = #{updateTime,jdbcType=INTEGER},
extra_activity_id = #{extraActivityId,jdbcType=INTEGER}
where id in
<foreach collection="ids" separator="," item="item" index="index" close=")" open="(">
#{item}
</foreach>
</update>
<update id="updateByPrimaryKey" parameterType="com.yoho.unions.dal.model.UnionShareOrders" >
update union_share_orders
set order_code = #{orderCode,jdbcType=VARCHAR},
... ... @@ -268,7 +286,7 @@
amount = #{amount,jdbcType=DECIMAL},
create_time = #{createTime,jdbcType=INTEGER},
update_time = #{updateTime,jdbcType=INTEGER},
activity_type = #{activityType,jdbcType=INTEGER},
extra_activity_id = #{extraActivityId,jdbcType=INTEGER},
activity_id = #{activityId,jdbcType=INTEGER},
extra_amount = #{extraAmount,jdbcType=DECIMAL},
order_amount = #{orderAmount,jdbcType=DECIMAL}
... ... @@ -305,6 +323,18 @@
</if>
order BY create_time desc
</select>
<select id="selectListByOrderUidForActivity" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from union_share_orders where status in (10,20,30,40)
and order_uid = #{orderUid} and promote_uid = #{promoteUid}
<if test="beginTime != 0" >
and order_time &gt; #{beginTime}
</if>
<if test="endTime != 0" >
and order_time &lt;#{endTime}
</if>
</select>
<select id="selectListBySearchCodition" resultMap="BaseResultMap">
select <include refid="Base_Column_List" /> from union_share_orders where 1=1
<if test="uid!=null">
... ...
... ... @@ -18,6 +18,9 @@ import java.util.stream.Collectors;
import javax.annotation.Resource;
import com.yoho.service.model.union.bo.*;
import com.yoho.unions.dal.*;
import com.yoho.unions.dal.model.*;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.elasticsearch.common.collect.Maps;
... ... @@ -37,17 +40,6 @@ import com.yoho.core.dal.datasource.annotation.Database;
import com.yoho.core.rabbitmq.YhProducer;
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.ShareOrdersProductBo;
import com.yoho.service.model.union.bo.ShareSettlementBo;
import com.yoho.service.model.union.bo.ShareUserSettlementInfoBo;
import com.yoho.service.model.union.bo.SocialMediaBo;
import com.yoho.service.model.union.bo.UnionShareBankBo;
import com.yoho.service.model.union.bo.UnionShareOrderSearchBo;
import com.yoho.service.model.union.bo.UnionShareOrdersActivityBo;
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;
... ... @@ -74,28 +66,6 @@ import com.yoho.unions.common.utils.RandomUtil;
import com.yoho.unions.common.utils.StringHideUtils;
import com.yoho.unions.convert.BeanConvert;
import com.yoho.unions.convert.Convert;
import com.yoho.unions.dal.IMktMarketingUrlDAO;
import com.yoho.unions.dal.UnionShareBigDataClickMapper;
import com.yoho.unions.dal.UnionShareOrdersActivityLogsMapper;
import com.yoho.unions.dal.UnionShareOrdersActivityMapper;
import com.yoho.unions.dal.UnionShareOrdersMapper;
import com.yoho.unions.dal.UnionShareOrdersMonthMapper;
import com.yoho.unions.dal.UnionShareOrdersProductMapper;
import com.yoho.unions.dal.UnionShareSettlementMapper;
import com.yoho.unions.dal.UnionShareUserApplyMapper;
import com.yoho.unions.dal.UnionShareUserBankMapper;
import com.yoho.unions.dal.UnionShareUserMapper;
import com.yoho.unions.dal.model.MktMarketingUrl;
import com.yoho.unions.dal.model.UnionShareBigDataClick;
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.UnionShareOrdersListBO;
import com.yoho.unions.dal.model.UnionShareOrdersProduct;
import com.yoho.unions.dal.model.UnionShareSettlement;
import com.yoho.unions.dal.model.UnionShareUser;
import com.yoho.unions.dal.model.UnionShareUserApply;
import com.yoho.unions.dal.model.UnionShareUserBank;
import com.yoho.unions.server.service.IUnionShareService;
import com.yoho.unions.utils.DateUtils;
import com.yoho.unions.utils.ImagesHelper;
... ... @@ -131,6 +101,8 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
@Autowired
UnionShareOrdersActivityMapper unionShareOrdersActivityMapper;
@Autowired
UnionShareOrdersActivityItemMapper unionShareOrdersActivityItemMapper;
@Autowired
UnionShareOrdersMonthMapper unionShareOrdersMonthMapper;
@Autowired
UnionShareBigDataClickMapper unionShareBigDataClickMapper;
... ... @@ -1037,6 +1009,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
* 订单插入或更新
*/
@Override
@Database(ForceMaster = true)
public void saveOrUpdateOrder(ShareOrderBo bo) {
logger.info("saveOrUpdateOrder enter,req is {}",bo);
if (bo == null) {
... ... @@ -1077,34 +1050,137 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
result=unionShareOrdersMapper.updateStatusById(unionShareOrders.getId(), unionShareOrders.getStatus(), bo.getStatus(), DateUtil.getCurrentTimeSecond());
}
if (result > 0 &&ShareOrdersStatusEnum.isFailOrder(unionShareOrders.getStatus())) {
//要作废活动参与记录
UnionShareOrdersActivityLogs updateLogs = new UnionShareOrdersActivityLogs();
updateLogs.setOrderId(unionShareOrders.getId());
updateLogs.setUpdateTime(DateUtil.getCurrentTimeSecond());
updateLogs.setStatus(0);//类型:1-有效,0-作废
unionShareOrdersActivityLogsMapper.updateStatusByOrderId(updateLogs);
//查询是否参与满单返
List<UnionShareOrdersActivityLogs> activityLogs=unionShareOrdersActivityLogsMapper.selectByOrderCode(unionShareOrders.getOrderCode());
if (CollectionUtils.isNotEmpty(activityLogs)) {
//todo 判断满返是否作废
}
rehandExtraActivity(unionShareOrders);
}
//清缓存
clearShareOrderRedis(bo.getPromoteUid());
}
//重新处理订单相关的满单返活动
private void rehandExtraActivity(UnionShareOrders unionShareOrders) {
UnionShareOrdersActivityLogs updateLogs = new UnionShareOrdersActivityLogs();
updateLogs.setOrderId(unionShareOrders.getId());
updateLogs.setUpdateTime(DateUtil.getCurrentTimeSecond());
updateLogs.setStatus(0);//类型:1-有效,0-作废
unionShareOrdersActivityLogsMapper.updateStatusByOrderId(updateLogs);
//查询是否参与满单返
List<UnionShareOrdersActivityLogs> activityLogs=unionShareOrdersActivityLogsMapper.selectByOrderCode(unionShareOrders.getOrderCode());
if (CollectionUtils.isEmpty(activityLogs)) {
return;
}
for(UnionShareOrdersActivityLogs activityLog:activityLogs){
//活动类型:1-订单返利比例升级,2-订单返利翻x倍,3-额外返
if (activityLog.getActivityType() != 3) {
continue;
}
String[] orders=activityLog.getOrders().split(",");
for (int i = 0; i < orders.length; i++) {
if (orders[i].equals(unionShareOrders.getOrderCode())) {
//判断满返是否作废,若作废,查询是否满足该活动低一阶段条件
// 获取某时间段可参与活动的单数
List<String> orderCodeList = Arrays.stream(orders).collect(Collectors.toList());
List<UnionShareOrders> orderList = unionShareOrdersMapper.selectListByOrderCodesForActivity(orderCodeList);
UnionShareOrdersActivityItem item = unionShareOrdersActivityItemMapper.selectByPrimaryKey(activityLog.getActivityItemId());
if (orderList.size() <item.getOrderMinNum()) {
//作废已参加的满单活动
UnionShareOrdersActivityLogs updatelogs = new UnionShareOrdersActivityLogs();
updatelogs.setId(activityLog.getId());
updatelogs.setStatus(0);//类型:1-有效,0-作废
updateLogs.setUpdateTime(DateUtil.getCurrentTimeSecond());
unionShareOrdersActivityLogsMapper.updateByPrimaryKeySelective(updatelogs);
//重新参加活动
boolean joinResult = joinExtraActivity(activityLog.getOrderUid(), activityLog.getPromoteUid(), activityLog.getActivityId());
if (!joinResult) {
//已不满足此活动条件
// clearOrderRelated(orderCodeList);
}
}
}
}
//一个订单最多可以参加一个满单返活动
return;
}
}
//todo 查询进行中的活动
//查询进行中的活动
private List<UnionShareOrdersActivity> queryActivity() {
List<UnionShareOrdersActivity> activities=unionShareOrdersActivityMapper.selectByDate(DateUtil.getCurrentTimeSecond());
return activities;
}
//todo 查询分享人已参加的活动
private void queryUidActivity(int uid) {
// List<UnionShareOrdersActivity> activities=unionShareOrdersActivityLogsMapper.selectByOrderIds()
//获取某时间段可参与活动的单数
private List<UnionShareOrders> queryUidActivity(int orderUid,int promoteUid,int beginTime,int endTime) {
List<UnionShareOrders> orders = unionShareOrdersMapper.selectListByOrderUidForActivity(beginTime, endTime, orderUid,promoteUid);
return orders;
}
// 参加满x单返活动
private boolean joinExtraActivity(int orderUid ,int promoteUid ,int activityId){
UnionShareOrdersActivity activity = unionShareOrdersActivityMapper.selectByPrimaryKey(activityId);
if (activity == null || activity.getType() != 3) {
return false;
}
List<UnionShareOrders> orders = queryUidActivity(orderUid,promoteUid, activity.getStartTime(), activity.getEndTime());
if (orders.size() == 0) {
return false;
}
//查询满x单返活动条目
List<UnionShareOrdersActivityItem> items = unionShareOrdersActivityItemMapper.selectByActivityId(activityId);
for (UnionShareOrdersActivityItem item : items) {
if (orders.size() >= item.getOrderMinNum() && orders.size() <= item.getOrderMaxNum()) {
//满足此项标准
StringBuilder ordersStr = new StringBuilder();
List<Integer> orderIds = new ArrayList<>();
String status=ShareOrdersStatusEnum.CAN_SETTLE.getCode();
for(UnionShareOrders order:orders){
if(ShareOrdersStatusEnum.getLevelByCode(order.getStatus())<2){
status = order.getStatus();
}
ordersStr.append(order.getOrderCode()).append(',');
orderIds.add(order.getId());
}
//更新订单额外返数据
int now = DateUtil.getCurrentTimeSecond();
unionShareOrdersMapper.updateByIdsForExtraActivity(orderIds, activityId,now);
//插入额外返利单
UnionShareOrders insertExtraOrder = new UnionShareOrders();
insertExtraOrder.setExtraAmount(item.getAmount());
insertExtraOrder.setAmount(item.getAmount());
insertExtraOrder.setExtraActivityId(activityId);
insertExtraOrder.setActivityId(activityId);
insertExtraOrder.setPromoteUid(promoteUid);
insertExtraOrder.setOrderUid(orderUid);
insertExtraOrder.setStatus(status);
insertExtraOrder.setCreateTime(now);
insertExtraOrder.setUpdateTime(now);
unionShareOrdersMapper.insertSelective(insertExtraOrder);
//记录满单返活动参与日志
UnionShareOrdersActivityLogs logs = new UnionShareOrdersActivityLogs();
logs.setOrders(ordersStr.substring(0,ordersStr.length()-1));
logs.setOrderId(insertExtraOrder.getId());
logs.setActivityId(activityId);
logs.setActivityName(activity.getActivityName());
logs.setActivityType(activity.getType());
logs.setActivityItemId(item.getId());
logs.setAmount(item.getAmount());
logs.setCreateTime(now);
logs.setUpdateTime(now);
logs.setPromoteUid(promoteUid);
logs.setOrderUid(orderUid);
unionShareOrdersActivityLogsMapper.insertSelective(logs);
return true;
}
}
//参加活动
return false;
}
// 是否可以参与满单返活动
private boolean canJoinExtraActivity(){
return false;
}
//参加加倍返活动
private boolean participateActivity(UnionShareOrders order,UnionShareOrdersActivity activity) {
//1、判断是否符合活动条件
//1.1 活动类型:1-订单返利比例升级,2-订单返利翻x倍,3-额外返
... ... @@ -1154,22 +1230,12 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
updateOrder.setAmount(order.getAmount());
updateOrder.setExtraAmount(order.getExtraAmount());
updateOrder.setActivityId(activity.getId());
updateOrder.setActivityType(activity.getType());
unionShareOrdersMapper.updateByPrimaryKeySelective(updateOrder);
//4、返回
logger.info("participateActivity success,order is {},activity is {}",order,activity);
return true;
}
//todo 查询可参加的活动
private void getActivity() {
}
//todo 判断是否达标
private boolean canJoin(){
return false;
}
//todo 汇总月统计数据
/**
* 保存订单信息
... ...