Authored by mingdan.ge

cps订单管理

... ... @@ -304,7 +304,7 @@
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectCountBySearchCodition" resultType="int">
select count(*) from union_share_orders where 1=1
select count(*) from union_share_orders where order_code is not null
<if test="uid!=null">
and promote_uid = #{uid}
</if>
... ... @@ -319,7 +319,7 @@
</if>
</select>
<select id="selectAllListByUids" resultMap="BaseResultMap">
select <include refid="Base_Column_List" /> from union_share_orders where 1=1
select <include refid="Base_Column_List" /> from union_share_orders where order_code is not null
<if test="uid!=null">
and promote_uid = #{uid}
</if>
... ... @@ -373,7 +373,7 @@
limit 1
</select>
<select id="selectListBySearchCodition" resultMap="BaseResultMap">
select <include refid="Base_Column_List" /> from union_share_orders where 1=1
select <include refid="Base_Column_List" /> from union_share_orders where order_code is not null
<if test="uid!=null">
and promote_uid =#{uid}
</if>
... ...
... ... @@ -378,6 +378,7 @@ public class UnionShareRest {
log.info("UnionShareRest.toAddVirtual.");
UnionShareVirtualAddBo addBo = new UnionShareVirtualAddBo();
addBo.setTime(DateUtil.getCurrentTimeSecond());
addBo.setNum(-1);
unionShareService.dealWithVirtualUserTask(addBo);
return new UnionResponse(200, "toAddVirtual success");
}
... ...
... ... @@ -295,9 +295,11 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
private UnionShareOrderRspBO initShareUnionOrderRspBO(String unionType,MktMarketingUrl mktMarketingUrl,UnionShareOrders orders){
UnionShareOrderRspBO orderRspBO=new UnionShareOrderRspBO();
orderRspBO.setOrderAmount(orders.getLastOrderAmount());
orderRspBO.setAmount(orders.getAmount());
orderRspBO.setOrderStatus(ShareOrdersStatusEnum.getDescByCode(orders.getStatus()));
orderRspBO.setIsNew(orders.getIsNew());
orderRspBO.setUid(orders.getPromoteUid());
orderRspBO.setOrderUid(orders.getOrderUid());
orderRspBO.setOrderCode(orders.getOrderCode());
orderRspBO.setId(orders.getId());
orderRspBO.setOrderTime(DateUtil.long2DateStr(Long.valueOf(orders.getOrderTime()) * Long.valueOf(1000), "yyyy-MM-dd HH:mm:ss"));
... ... @@ -322,7 +324,11 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
Map<Integer,UnionShareUser> userMap=unionShareUserMapper.selectByUids(getUids(ordersDOList));
Map<Long,MktMarketingUrl> mktMarketMap=listMktMarketingUrls(ordersDOList,userMap);
for (UnionShareOrders userOrders : ordersDOList) {
String unionType=userMap.get(userOrders.getPromoteUid()).getUnionType();
UnionShareUser unionShareUser = userMap.get(userOrders.getPromoteUid());
if (unionShareUser == null) {
continue;
}
String unionType= unionShareUser.getUnionType();
MktMarketingUrl mktMarketingUrl = isLong(unionType)?mktMarketMap.get(Long.valueOf(unionType)):null;
UnionShareOrderRspBO bo=initShareUnionOrderRspBO(unionType,mktMarketingUrl,userOrders);
unionOrderRspBOList.add(bo);
... ... @@ -333,6 +339,10 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
private Map<Long,MktMarketingUrl> listMktMarketingUrls(List<UnionShareOrders> ordersDOList, Map<Integer,UnionShareUser> userMap){
List<String> unionTypes=new ArrayList<>();
for (UnionShareOrders userOrders : ordersDOList) {
UnionShareUser unionShareUser = userMap.get(userOrders.getPromoteUid());
if (unionShareUser == null) {
continue;
}
String unionType=userMap.get(userOrders.getPromoteUid()).getUnionType();
if(StringUtils.isNotBlank(unionType)){
unionTypes.add(unionType);
... ... @@ -2445,6 +2455,18 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
logger.info("dealWithVirtualUserTask end.Virtual data is null.bo is {},today is {}",bo,date);
return;
}
if (bo.getNum() > -1) {
//不是手动执行,需要排除分布式其他机器已执行情况
UnionShareVirtualAddBo addBo=redisValueCache.get(VIRTUAL_ADD_KEY, UnionShareVirtualAddBo.class);
if (addBo == null) {
logger.info("dealWithVirtualUserTask end,query redis for virtual end.does not need");
return;
}
if (addBo.getNum()!=bo.getNum()) {
logger.info("dealWithVirtualUserTask end,query redis for virtual end.has be done");
return;
}
}
logger.info("dealWithVirtualUserTask.bo is {},today is {},deal num is {}",bo,date,unionShareOrdersMonths.size());
unionShareOrdersMonths.forEach(un->{
int i = new Random().nextInt(499);
... ...
... ... @@ -12,7 +12,9 @@ import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Calendar;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
* 马甲用户隔日随机增
... ... @@ -36,12 +38,19 @@ public class CpsVirtualUserTask {
// @Scheduled(cron = "10/25 59 14 * * ?")
public void run() {
logger.info("CpsVirtualUserTask.run,query redis for virtual.");
//查询是否有随机增预操作
//查询是否有随机增预操作
UnionShareVirtualAddBo addBo=redisValueCache.get(VIRTUAL_ADD_KEY, UnionShareVirtualAddBo.class);
if (addBo == null) {
logger.info("CpsVirtualUserTask.run,query redis for virtual end.does not need");
return;
}
if (addBo.getNum()>0) {
logger.info("CpsVirtualUserTask.run,query redis for virtual end.has be done");
return;
}
int num = Calendar.getInstance().get(Calendar.MILLISECOND);
addBo.setNum(num);
redisValueCache.set(VIRTUAL_ADD_KEY,addBo,600, TimeUnit.SECONDS);
logger.info("CpsVirtualUserTask.run,start to deal with {}.",addBo);
//随机增当月数据
unionShareService.dealWithVirtualUserTask(addBo);
... ...
... ... @@ -94,11 +94,21 @@
width: 200,
align: "center"
}, {
title: "下单用户ID",
field: "orderUid",
width: 200,
align: "center"
}, {
title: "订单金额",
field: "orderAmount",
width: 200,
align: "center"
}, {
title: "返利金额",
field: "amount",
width: 200,
align: "center"
}, {
title: "订单状态",
field: "orderStatus",
width: 200,
... ...