|
@@ -44,7 +44,7 @@ public class StorePinkSummaryServiceImpl extends AbstractService<StorePinkSummar
|
|
|
criteria.andEqualTo("spsId", id);
|
|
|
criteria.andEqualTo("isDelete",0);
|
|
|
List<StorePink> storePinks = mStorePinkMapper.selectByCondition(condition);
|
|
|
- int peopleCount = 0;
|
|
|
+ int sumUnpayAndPaid = 0;
|
|
|
|
|
|
|
|
|
|
|
@@ -58,37 +58,41 @@ public class StorePinkSummaryServiceImpl extends AbstractService<StorePinkSummar
|
|
|
|
|
|
//未开团的情况下退款要维护开团汇总表的实时状态 其他状态像已开团和开团失败就不再维护开团汇总表了因为开团失败和已开团的数据都已经被锁定,新的成员无法加入了
|
|
|
if(StorePinkStatusEnum.NOT_DRAWN.getKey().equals(status)){
|
|
|
+ //成团额定人数
|
|
|
+ Integer stipulatedNumber = storePinkSummary.getPeople();
|
|
|
|
|
|
- Integer people = storePinkSummary.getPeople();
|
|
|
+ int countUnpayInteger = 0; //未付款的人数
|
|
|
+
|
|
|
+ int countPaidInteger = 0; //付款成功的人数
|
|
|
+
|
|
|
+ int countTimeOutFailedInteger = 0; //拼团超时失败的数量,只要有1个那么就认为总体都失败
|
|
|
|
|
|
- int countOneInteger = 0; //未付款的人数
|
|
|
- int countTwoInteger = 0; //付款成功的人数
|
|
|
- int countThreeInteger = 0; //评团超时失败的数量,只要有1个那么就认为总体都失败
|
|
|
|
|
|
if(!CollectionUtils.isEmpty(storePinks)){
|
|
|
-
|
|
|
+ //删除标识
|
|
|
Integer deleteInteger = 0;
|
|
|
|
|
|
- countOneInteger = (int) storePinks.stream().filter(a -> {
|
|
|
+ countUnpayInteger = (int) storePinks.stream().filter(a -> {
|
|
|
return deleteInteger.equals(a.getIsDelete())
|
|
|
&& PinkOrderStatusEnum.GROUP_ORDER_TO_PAY.getKey().equals(a.getOrderStatus());
|
|
|
}).count();
|
|
|
|
|
|
- countTwoInteger = (int) storePinks.stream().filter(a -> {
|
|
|
+ countPaidInteger = (int) storePinks.stream().filter(a -> {
|
|
|
return deleteInteger.equals(a.getIsDelete())
|
|
|
&& PinkOrderStatusEnum.GROUP_ORDER_PAID.getKey().equals(a.getOrderStatus());
|
|
|
}).count();
|
|
|
|
|
|
- countThreeInteger = (int) storePinks.stream().filter(a -> {
|
|
|
+ countTimeOutFailedInteger = (int) storePinks.stream().filter(a -> {
|
|
|
return deleteInteger.equals(a.getIsDelete())
|
|
|
&& StorePinkStatusEnum.LOTTERY_FAILED.getKey().equals(a.getStatus());
|
|
|
}).count();
|
|
|
|
|
|
- peopleCount = countOneInteger + countTwoInteger;
|
|
|
+ sumUnpayAndPaid = countUnpayInteger + countPaidInteger;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
|
- if(people < peopleCount){
|
|
|
+ if(stipulatedNumber < sumUnpayAndPaid){
|
|
|
throw new ServiceException("拼团超员 id:"+id);
|
|
|
}
|
|
|
|
|
@@ -97,30 +101,45 @@ public class StorePinkSummaryServiceImpl extends AbstractService<StorePinkSummar
|
|
|
|
|
|
StorePinkSummary storePinkSummaryForUpdate = new StorePinkSummary();
|
|
|
storePinkSummaryForUpdate.setId(id);
|
|
|
- storePinkSummaryForUpdate.setPeopleCount(peopleCount);
|
|
|
+ storePinkSummaryForUpdate.setPeopleCount(sumUnpayAndPaid);
|
|
|
+
|
|
|
+
|
|
|
|
|
|
- //这里判断 已经付款成功的订单 总数==活动总人数的时候代表拼团锁定
|
|
|
- if(people==peopleCount){
|
|
|
+
|
|
|
+ //这里判断 总数==活动总人数的时候代表拼团锁定成员已满 但此时不一定开团得全支付完成才会开团
|
|
|
+ if(stipulatedNumber==sumUnpayAndPaid){
|
|
|
storePinkSummaryForUpdate.setIsVirtual(Boolean.TRUE);
|
|
|
- }
|
|
|
- if(people>peopleCount){
|
|
|
+ }else{
|
|
|
storePinkSummaryForUpdate.setIsVirtual(Boolean.FALSE);
|
|
|
}
|
|
|
- //这里判断 已经付款成功的订单 总数==活动总人数的时候代表拼团成功
|
|
|
- if(people== countTwoInteger){
|
|
|
- storePinkSummaryForUpdate.setIsVirtual(Boolean.TRUE);
|
|
|
+
|
|
|
+ //这里判断 已经付款成功的订单 总数==活动总人数的时候代表拼团成功 其他情况都不成功
|
|
|
+ if(stipulatedNumber == countPaidInteger){
|
|
|
storePinkSummaryForUpdate.setStatus(StorePinkStatusEnum.RESULTS_ANNOUNCED.getKey());
|
|
|
successFlag = true; //拼团成功标识
|
|
|
- }
|
|
|
-
|
|
|
- if(people > countTwoInteger){
|
|
|
+ }else{
|
|
|
storePinkSummaryForUpdate.setStatus(StorePinkStatusEnum.NOT_DRAWN.getKey());
|
|
|
}
|
|
|
|
|
|
- if(countThreeInteger>0){
|
|
|
- storePinkSummaryForUpdate.setIsVirtual(Boolean.TRUE);
|
|
|
- storePinkSummaryForUpdate.setStatus(StorePinkStatusEnum.LOTTERY_FAILED.getKey());
|
|
|
- }
|
|
|
+
|
|
|
+ //这种算团长自己退款了,直接算拼团失败。咨询了山哥说做一下限制,团长不能退款
|
|
|
+ if(sumUnpayAndPaid==0) {
|
|
|
+ storePinkSummaryForUpdate.setIsVirtual(Boolean.TRUE);
|
|
|
+ storePinkSummaryForUpdate.setStatus(StorePinkStatusEnum.LOTTERY_FAILED.getKey());
|
|
|
+ }
|
|
|
+
|
|
|
+ //只要有1个是开奖失败的那么整个团就算开奖失败,开奖失败目前只有活动超时定时任务处理时才会造成
|
|
|
+ // 此时用status 拼团状态==3,
|
|
|
+ // order_status == GROUP_ORDER_REFUND7 (拼团失败)来和
|
|
|
+ // 主动退款
|
|
|
+ //m_store_pink.status == 1 NOT_DRAWN(1, "未开奖"),
|
|
|
+ // m_store_pink.order_status == GROUP_ORDER_REFUND(4, "拼团失败已退款")
|
|
|
+ if(countTimeOutFailedInteger>0){
|
|
|
+ storePinkSummaryForUpdate.setIsVirtual(Boolean.TRUE);
|
|
|
+ storePinkSummaryForUpdate.setStatus(StorePinkStatusEnum.LOTTERY_FAILED.getKey());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
mStorePinkSummaryMapper.updateByPrimaryKeySelective(storePinkSummaryForUpdate);
|
|
|
}
|