|
@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
import com.txz.cif.dto.Result;
|
|
import com.txz.cif.dto.Result;
|
|
import com.txz.cif.dto.UserDTO;
|
|
import com.txz.cif.dto.UserDTO;
|
|
import com.txz.cif.param.AccomplishParam;
|
|
import com.txz.cif.param.AccomplishParam;
|
|
|
|
+import com.txz.cif.param.OrderParam;
|
|
import com.txz.mall.constants.Constants;
|
|
import com.txz.mall.constants.Constants;
|
|
import com.txz.mall.core.AbstractService;
|
|
import com.txz.mall.core.AbstractService;
|
|
import com.txz.mall.core.ServiceException;
|
|
import com.txz.mall.core.ServiceException;
|
|
@@ -173,11 +174,17 @@ public class StorePinkServiceImpl extends AbstractService<StorePink> implements
|
|
criteria.andEqualTo("orderStatus", PinkOrderStatusEnum.GROUP_ORDER_PAID.getKey());
|
|
criteria.andEqualTo("orderStatus", PinkOrderStatusEnum.GROUP_ORDER_PAID.getKey());
|
|
List<StorePink> list = findByCondition(condition);
|
|
List<StorePink> list = findByCondition(condition);
|
|
if (CollUtil.isEmpty(list)) {
|
|
if (CollUtil.isEmpty(list)) {
|
|
- throw new ServiceException("没有拼团订单");
|
|
|
|
|
|
+ throw new ServiceException("没有拼团订单"+spsId);
|
|
}
|
|
}
|
|
long count = list.stream().filter(i -> i.getLId().equals(1)).count();
|
|
long count = list.stream().filter(i -> i.getLId().equals(1)).count();
|
|
if (count >= luckNum) {
|
|
if (count >= luckNum) {
|
|
- throw new ServiceException("已有天选");
|
|
|
|
|
|
+ throw new ServiceException("已有天选"+spsId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ StorePinkSummary storePinkSummary = storePinkSummaryService.findById(spsId);
|
|
|
|
+ if(ObjectUtils.isEmpty(storePinkSummary)){
|
|
|
|
+ throw new ServiceException("没有拼团汇总记录"+spsId);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -186,6 +193,12 @@ public class StorePinkServiceImpl extends AbstractService<StorePink> implements
|
|
List<Long> idCollect = list.stream().map(StorePink::getId).collect(Collectors.toList());
|
|
List<Long> idCollect = list.stream().map(StorePink::getId).collect(Collectors.toList());
|
|
List<Long> randomIds = RandomUtil.uniqueRandom(idCollect, (int) luckNum);
|
|
List<Long> randomIds = RandomUtil.uniqueRandom(idCollect, (int) luckNum);
|
|
|
|
|
|
|
|
+ AccomplishParam param = new AccomplishParam();
|
|
|
|
+
|
|
|
|
+ param.setBizNo(storePinkSummary.getCode());
|
|
|
|
+ param.setBizId(storePinkSummary.getId()+"");
|
|
|
|
+ List<OrderParam> orderParamList = new ArrayList<>();
|
|
|
|
+
|
|
//选出中奖单号 推进状态
|
|
//选出中奖单号 推进状态
|
|
randomIds.forEach(i -> {
|
|
randomIds.forEach(i -> {
|
|
StorePink luckPink = new StorePink();
|
|
StorePink luckPink = new StorePink();
|
|
@@ -207,11 +220,22 @@ public class StorePinkServiceImpl extends AbstractService<StorePink> implements
|
|
|
|
|
|
storeOrderStatusService.createLog(storeOrder.getId(), Constants.ORDER_STATUS_PINK_SUCCESS_ORDER, "拼团成功");
|
|
storeOrderStatusService.createLog(storeOrder.getId(), Constants.ORDER_STATUS_PINK_SUCCESS_ORDER, "拼团成功");
|
|
|
|
|
|
|
|
+ //中奖者
|
|
|
|
+ param.setWinnerOrderNo(storeOrder.getOrderId());
|
|
|
|
+ param.setWinnerUserId(storeOrder.getUid());
|
|
|
|
+ Integer kId = storePink.getKId();
|
|
|
|
+ Integer zero = 0;
|
|
|
|
+ if(zero.equals(kId)){
|
|
|
|
+ param.setOpenGroupUserId(storeOrder.getUid());
|
|
|
|
+ param.setOpenOrderNo(storeOrder.getOrderId());
|
|
|
|
+ }
|
|
//获奖者的状态联动已经完成了所以把他从列表中移除
|
|
//获奖者的状态联动已经完成了所以把他从列表中移除
|
|
list.remove(storePink);
|
|
list.remove(storePink);
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
+ param.setTransTime(date);
|
|
//将所有参团成员的status设置为 已开奖
|
|
//将所有参团成员的status设置为 已开奖
|
|
list.forEach(a->{
|
|
list.forEach(a->{
|
|
|
|
|
|
@@ -241,28 +265,29 @@ public class StorePinkServiceImpl extends AbstractService<StorePink> implements
|
|
|
|
|
|
|
|
|
|
//非天选之子给他退款
|
|
//非天选之子给他退款
|
|
- AccomplishParam param = new AccomplishParam();
|
|
|
|
- param.setBizNo(storeOrder.getOrderId());
|
|
|
|
- param.setBizId(storeOrder.getId().toString());
|
|
|
|
- List<Long> userIds = CollUtil.newArrayList(storeOrder.getUid());
|
|
|
|
- param.setUserIds(userIds);
|
|
|
|
|
|
+ OrderParam orderParam = new OrderParam();
|
|
|
|
+ orderParam.setOrderId(storeOrder.getId()+"");
|
|
|
|
+ orderParam.setUserId(storeOrder.getUid());
|
|
|
|
+ orderParam.setOrderNo(storeOrder.getOrderId());
|
|
|
|
+
|
|
Integer kId = a.getKId();
|
|
Integer kId = a.getKId();
|
|
Integer zero = 0;
|
|
Integer zero = 0;
|
|
if(zero.equals(kId)){
|
|
if(zero.equals(kId)){
|
|
param.setOpenGroupUserId(storeOrder.getUid());
|
|
param.setOpenGroupUserId(storeOrder.getUid());
|
|
|
|
+ param.setOpenOrderNo(storeOrder.getOrderId());
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ //当前只能拼1个商品 所以理论上这个价格都是一样的,这边就循环覆盖即可
|
|
param.setAmount(storeOrder.getPayPrice());
|
|
param.setAmount(storeOrder.getPayPrice());
|
|
- param.setTransTime(date);
|
|
|
|
- Result result = cifAccountDubboServiceClient.accomplishGroup(param);
|
|
|
|
-
|
|
|
|
- if(!result.getCode().equals("200")){
|
|
|
|
- throw new ServiceException("拼团成团未中奖用户退款失败message:"+result.getMessage());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ orderParamList.add(orderParam);
|
|
|
|
|
|
});
|
|
});
|
|
|
|
+ param.setUserIds(orderParamList);
|
|
|
|
|
|
|
|
+ Result result = cifAccountDubboServiceClient.accomplishGroup(param);
|
|
|
|
+
|
|
|
|
+ if(!result.getCode().equals("200")){
|
|
|
|
+ throw new ServiceException("拼团成团未中奖用户退款失败message:"+result.getMessage());
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
|