yubin преди 1 седмица
родител
ревизия
71c12d3f70

+ 1 - 7
mall-service/src/main/java/com/txz/mall/controller/OrderController.java

@@ -173,7 +173,7 @@ public class OrderController {
     @ApiOperation("定时任务关闭订单测试")
     @PostMapping("/scheduled/task/close")
     public Result close() {
-        storeOrderService.scheduledTaskClose();
+        storeOrderService.scheduledTaskStorePinkSummaryClose();
         return Result.success();
     }
 
@@ -245,12 +245,6 @@ public class OrderController {
 //        return Result.success(result);
 //    }
 
-    @ApiOperation("导出发货单")
-    @PostMapping("/exportDelivery")
-    public Result exportDelivery(HttpServletResponse response) {
-        storeOrderService.exportDelivery(response);
-        return Result.success();
-    }
 
 
     //    @ApiOperation(value = "预下单")

+ 2 - 1
mall-service/src/main/java/com/txz/mall/service/StoreOrderService.java

@@ -132,7 +132,8 @@ public interface StoreOrderService extends Service<StoreOrder> {
     /**
      * 定时订单关闭
      */
-    void scheduledTaskClose();
+    void scheduledTaskStorePinkSummaryClose();
+
 
     /**
      * 订单取消

+ 12 - 10
mall-service/src/main/java/com/txz/mall/service/impl/StoreOrderServiceImpl.java

@@ -215,17 +215,13 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
         storePinkSummary.setPid(storeCombination.getProductId());
         storePinkSummary.setPeople(storeCombination.getPeople());
         storePinkSummary.setAddTime(date);
-        storePinkSummary.setStopTime(DateUtils.addMinutes(date, effectiveTime));
+        Integer effectiveTime1 = storeCombination.getEffectiveTime();
+        Date settleTime = DateUtil.offsetHour(date,effectiveTime1);
+        storePinkSummary.setStopTime(settleTime);
         storePinkSummary.setIsRefund(0);
+        storePinkSummary.setIsVirtual(Boolean.TRUE);  //初始化时直接锁定,防止团长还没支付这个团就暴露出来了。等团长支付时会重新计算是否锁定
         storePinkSummary.setPeopleCount(1);
         storePinkSummary.setStatus(1);
-        //   storePinkSummary.setlId();'//天选 默认0  1为天选',
-        //   storePinkSummary.setkId(); // '团长id',
-        //    storePinkSummary.setIsRefund(); //是否退款  0未退款 1已退款',
-        storePinkSummary.setIsRefund(0);
-        
-        
-        EasyToUseUtil.appCreateAssignment(date, storePinkSummary);
 
 
         EasyToUseUtil.appCreateAssignment(date, storePinkSummary);
@@ -387,7 +383,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
         if (ObjectUtil.isNull(storeCombination) || storeCombination.getIsDelete().equals(1)) {
             throw new ServiceException("对应拼团商品不存在");
         }
-        
+        //这里要排除掉团长未付款的拼团
         
         PageHelper.startPage(1, 10);
         Condition pinkSummaryCondition = new Condition(StorePinkSummary.class);
@@ -1712,6 +1708,12 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
         }
 
         StorePink storePink = storePinkService.findById(storeOrder.getPinkId());
+        Integer status = 0;
+        //团长在未成团时不能退款
+        if(storePink.getKId().equals(status) && storePink.getStatus().equals(StorePinkStatusEnum.NOT_DRAWN.getKey())){
+            throw new ServiceException("当前成员是团长,且该团未开奖,暂时不支持退款:"+id);
+        }
+
         // 批量退款接口调用 这块要前置,退款成功后再去改状态
         if (ObjectUtils.isEmpty(storePink)) {
             throw new ServiceException("拼团时间过期关闭时时拼团信息不存在ID:" + storeOrder.getPinkId());
@@ -1868,7 +1870,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
     @Resource
     private StorePinkSummaryMapper storePinkSummaryMapper;
     @Override
-    public void scheduledTaskClose() {
+    public void scheduledTaskStorePinkSummaryClose() {
 
         Date date = new Date();
         PageHelper.startPage(1, 10);

+ 45 - 26
mall-service/src/main/java/com/txz/mall/service/impl/StorePinkSummaryServiceImpl.java

@@ -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);
         }

+ 1 - 0
mall-service/src/main/java/com/txz/mall/service/impl/StoreProductServiceImpl.java

@@ -17,6 +17,7 @@ import com.txz.mall.core.AuthService;
 import com.txz.mall.core.ServiceException;
 import com.txz.mall.dao.MidFavoriteMapper;
 import com.txz.mall.dao.StoreCombinationMapper;
+import com.txz.mall.dao.StoreProductMapper;
 import com.txz.mall.model.ProductAttr;
 import com.txz.mall.model.ProductAttrValue;
 import com.txz.mall.model.StoreOrder;