...
|
...
|
@@ -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、返回
|
...
|
...
|
|