yubin 3 днів тому
батько
коміт
314350c369

+ 22 - 1
mall-api/src/main/java/com/txz/mall/dto/StorePinkSummaryDTO.java

@@ -2,7 +2,7 @@
 *
 * StorePinkSummaryDTO.java
 * Copyright(C) 2017-2020 fendo公司
-* @date 2025-08-19
+* @date 2025-08-20
 */
 package com.txz.mall.dto;
 
@@ -31,6 +31,11 @@ public class StorePinkSummaryDTO implements Serializable {
      */
     private Long pid;
 
+    /**
+     * 当前拼团人数
+     */
+    private Integer peopleCount;
+
     /**
      * 拼图总人数
      */
@@ -175,6 +180,22 @@ public class StorePinkSummaryDTO implements Serializable {
         this.pid = pid;
     }
 
+    /**
+     * 当前拼团人数
+     * @return people_count 当前拼团人数
+     */
+    public Integer getPeopleCount() {
+        return peopleCount;
+    }
+
+    /**
+     * 当前拼团人数
+     * @param peopleCount 当前拼团人数
+     */
+    public void setPeopleCount(Integer peopleCount) {
+        this.peopleCount = peopleCount;
+    }
+
     /**
      * 拼图总人数
      * @return people 拼图总人数

+ 21 - 1
mall-service/src/main/java/com/txz/mall/business/impl/OrderServiceBusinessImpl.java

@@ -5,6 +5,8 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.txz.mall.business.OrderServiceBusiness;
 import com.txz.mall.core.RedisUtil;
+import com.txz.mall.core.ServiceException;
+import com.txz.mall.dao.StorePinkMapper;
 import com.txz.mall.dubbo.client.CifUserDubboServiceClient;
 import com.txz.mall.model.*;
 import com.txz.mall.service.*;
@@ -13,6 +15,7 @@ import org.apache.commons.lang.time.DateUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.ObjectUtils;
 import tk.mybatis.mapper.entity.Condition;
 import tk.mybatis.mapper.entity.Example;
 import vo.StoreCombinationRankVO;
@@ -39,24 +42,41 @@ public class OrderServiceBusinessImpl implements OrderServiceBusiness {
     private final StoreOrderStatusService storeOrderStatusService;
     private final CifUserDubboServiceClient userDubboServiceClient;
     private final StoreCombinationService storeCombinationService;
+    private final StorePinkService storePinkService;
     private final RedisUtil redisUtil;
 
     @Override
     public StoreOrderVO orderDetail(Long id) {
+        StoreOrderVO vo = new StoreOrderVO();
         StoreOrder storeOrder = storeOrderService.findById(id);
+        if(ObjectUtils.isEmpty(storeOrder)){
+            throw new ServiceException("订单不存在 ID:"+id);
+        }
         Condition infoCondition = new Condition(StoreOrderInfo.class);
         Example.Criteria infoCriteria = infoCondition.createCriteria();
         infoCriteria.andEqualTo("isDelete", 0);
         infoCriteria.andEqualTo("orderId", storeOrder.getId());
         List<StoreOrderInfo> infoList = storeOrderInfoService.findByCondition(infoCondition);
         List<StoreOrderStatus> logList = storeOrderStatusService.getLogList(storeOrder.getId());
+
+        Condition storePinkCondition = new Condition(StorePink.class);
+        Example.Criteria storePinkCriteria = storePinkCondition.createCriteria();
+        storePinkCriteria.andEqualTo("isDelete", 0);
+        storePinkCriteria.andEqualTo("orderIdKey", id);
+
+        List<StorePink> byCondition = storePinkService.findByCondition(storePinkCondition);
+        if(!org.springframework.util.CollectionUtils.isEmpty(byCondition)){
+            StorePink storePink = byCondition.get(0);
+            vo.setStorePink(storePink);
+        }
 //        UserDTO user = userDubboServiceClient.getUser(storeOrder.getUid());
         UserAddress userAddress = userAddressService.findById(storeOrder.getAddressId());
-        StoreOrderVO vo = new StoreOrderVO();
+
         BeanUtils.copyProperties(storeOrder, vo);
         vo.setOrderInfoVO(infoList);
         vo.setOrderAddressVO(userAddress);
         vo.setOrderStatusVO(logList);
+
 //        vo.setUserVO(user);
         return vo;
     }

+ 14 - 18
mall-service/src/main/java/com/txz/mall/web/mng/StorePinkSummaryController.java → mall-service/src/main/java/com/txz/mall/controller/StorePinkSummaryController.java

@@ -1,28 +1,24 @@
-package com.txz.mall.web.mng;
-import com.txz.mall.core.Result;
-import com.txz.mall.model.StorePinkSummary;
-import com.txz.mall.service.StorePinkSummaryService;
-
-import com.txz.mall.core.ResultCode;
+package com.txz.mall.controller;
 
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import com.txz.mall.core.Result;
+import com.txz.mall.core.ResultCode;
+import com.txz.mall.dto.StorePinkSummaryDTO;
+import com.txz.mall.model.StorePinkSummary;
+import com.txz.mall.service.StorePinkSummaryService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
 import tk.mybatis.mapper.entity.Condition;
 import tk.mybatis.mapper.entity.Example.Criteria;
-import org.springframework.web.bind.annotation.*;
-import org.springframework.validation.annotation.Validated;
+
 import javax.annotation.Resource;
-import java.util.List;
 import java.util.Date;
+import java.util.List;
 
 /**
 * Created by CodeGenerator on 2025/08/19.
@@ -63,7 +59,7 @@ public class StorePinkSummaryController {
     	try {
             StorePinkSummary storePinkSummary = new StorePinkSummary();
 			storePinkSummary.setId(id);
-			storePinkSummary.setIsDelete(1);
+			//storePinkSummary.setIsDelete(1);
 			storePinkSummaryService.update(storePinkSummary);
 		} catch (Exception e) {
 			log.error("删除对象操作异常e:{}",e);
@@ -111,7 +107,7 @@ public class StorePinkSummaryController {
     @PostMapping("/list")
 	@ApiOperation(value = "storePinkSummary获取列表")
 	public Result<List<StorePinkSummary>> list(@Validated @RequestBody StorePinkSummaryDTO dto) {
-        PageHelper.startPage(dto.getPage(), dto.getSize());
+       // PageHelper.startPage(dto.getPage(), dto.getSize());
 
         Condition condition = new Condition(StorePinkSummary.class);
         Criteria criteria = condition.createCriteria();

+ 2 - 0
mall-service/src/main/java/com/txz/mall/model/StoreOrder.java

@@ -391,4 +391,6 @@ public class StoreOrder {
     private String outTradeNo;
 
 
+
+
 }

+ 13 - 0
mall-service/src/main/java/com/txz/mall/model/StorePink.java

@@ -23,6 +23,14 @@ public class StorePink {
     @ApiModelProperty(value = "用户id")
     private Long uid;
 
+
+    /**
+     * 拼团汇总表id
+     */
+    @ApiModelProperty(value = "拼团汇总表id")
+    @Column(name = "sps_id")
+    private Long spsId;
+
     /**
      * 订单id 生成
      */
@@ -170,4 +178,9 @@ public class StorePink {
     @Column(name = "is_delete")
     private Integer isDelete;
 
+
+    @ApiModelProperty(value = "订单状态")
+    @Column(name = "order_status")
+    private Integer orderStatus;
+
 }

+ 30 - 9
mall-service/src/main/java/com/txz/mall/model/StorePinkSummary.java

@@ -1,5 +1,7 @@
 package com.txz.mall.model;
 
+import io.swagger.annotations.ApiModelProperty;
+
 import java.math.BigDecimal;
 import java.util.Date;
 import javax.persistence.*;
@@ -29,11 +31,17 @@ public class StorePinkSummary {
      */
     private Long pid;
 
+    /**
+     * 当前拼团人数
+     */
+    private Integer peopleCount;
+
     /**
      * 拼图总人数
      */
     private Integer people;
 
+
     /**
      * 拼团商品单价
      */
@@ -72,13 +80,16 @@ public class StorePinkSummary {
     /**
      * 是否退款  0未退款 1已退款
      */
+    @ApiModelProperty(value = "是否退款 0未退款 1已退款")
     @Column(name = "is_refund")
-    private Byte isRefund;
+    private Integer isRefund;
 
     /**
      * 拼团状态  1进行中  2已完成  3未完成
      */
-    private Byte status;
+    @ApiModelProperty(value = "状态 1进行中 2已完成 3未完成")
+    @Column(name = "status")
+    private Integer status;
 
     /**
      * 是否虚拟拼团
@@ -114,7 +125,17 @@ public class StorePinkSummary {
      * 是否删除
      */
     @Column(name = "is_delete")
-    private Byte isDelete;
+    private Integer isDelete;
+
+
+
+    public Integer getPeopleCount() {
+        return peopleCount;
+    }
+
+    public void setPeopleCount(Integer peopleCount) {
+        this.peopleCount = peopleCount;
+    }
 
     /**
      * 获取拼团ID
@@ -319,7 +340,7 @@ public class StorePinkSummary {
      *
      * @return is_refund - 是否退款  0未退款 1已退款
      */
-    public Byte getIsRefund() {
+    public Integer getIsRefund() {
         return isRefund;
     }
 
@@ -328,7 +349,7 @@ public class StorePinkSummary {
      *
      * @param isRefund 是否退款  0未退款 1已退款
      */
-    public void setIsRefund(Byte isRefund) {
+    public void setIsRefund(Integer isRefund) {
         this.isRefund = isRefund;
     }
 
@@ -337,7 +358,7 @@ public class StorePinkSummary {
      *
      * @return status - 拼团状态  1进行中  2已完成  3未完成
      */
-    public Byte getStatus() {
+    public Integer getStatus() {
         return status;
     }
 
@@ -346,7 +367,7 @@ public class StorePinkSummary {
      *
      * @param status 拼团状态  1进行中  2已完成  3未完成
      */
-    public void setStatus(Byte status) {
+    public void setStatus(Integer status) {
         this.status = status;
     }
 
@@ -445,7 +466,7 @@ public class StorePinkSummary {
      *
      * @return is_delete - 是否删除
      */
-    public Byte getIsDelete() {
+    public Integer getIsDelete() {
         return isDelete;
     }
 
@@ -454,7 +475,7 @@ public class StorePinkSummary {
      *
      * @param isDelete 是否删除
      */
-    public void setIsDelete(Byte isDelete) {
+    public void setIsDelete(Integer isDelete) {
         this.isDelete = isDelete;
     }
 }

+ 5 - 1
mall-service/src/main/java/com/txz/mall/service/StorePinkSummaryService.java

@@ -4,8 +4,12 @@ import com.txz.mall.core.Service;
 
 
 /**
- * Created by CodeGenerator on 2025/08/19.
+ * Created by CodeGenerator on 2025/08/20.
  */
 public interface StorePinkSummaryService extends Service<StorePinkSummary> {
 
+
+
+    Boolean maintainQuantityStatusOfTheStorePinkSummary(Long id);
+
 }

+ 111 - 14
mall-service/src/main/java/com/txz/mall/service/impl/StoreOrderServiceImpl.java

@@ -10,6 +10,9 @@ import cn.hutool.poi.excel.ExcelWriter;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
 import com.txz.cif.dto.AccountDTO;
 import com.txz.cif.dto.Result;
 import com.txz.cif.dto.UserDTO;
@@ -20,6 +23,7 @@ import com.txz.mall.core.AbstractService;
 import com.txz.mall.core.RedisUtil;
 import com.txz.mall.core.ResultCode;
 import com.txz.mall.core.ServiceException;
+import com.txz.mall.dao.StorePinkMapper;
 import com.txz.mall.dubbo.client.CifAccountDubboServiceClient;
 import com.txz.mall.dubbo.client.CifUserDubboServiceClient;
 import com.txz.mall.enums.OrderEventsEnum;
@@ -27,6 +31,7 @@ import com.txz.mall.enums.PinkOrderStatusEnum;
 import com.txz.mall.model.*;
 import com.txz.mall.service.*;
 import com.txz.mall.util.EasyExcelUtil;
+import com.txz.mall.util.EasyToUseUtil;
 import com.txz.mall.util.OrderStateMachine;
 import com.txz.mall.util.OrderUtils;
 import dto.*;
@@ -35,6 +40,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.time.DateUtils;
 import org.apache.commons.lang3.StringEscapeUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.ibatis.session.RowBounds;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -45,6 +51,7 @@ import tk.mybatis.mapper.entity.Condition;
 import tk.mybatis.mapper.entity.Example;
 import vo.*;
 
+import javax.annotation.Resource;
 import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
@@ -69,6 +76,8 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
     private final ProductAttrValueService productAttrValueService;
     private final StoreProductService storeProductService;
     private final StorePinkService storePinkService;
+
+    private final StorePinkSummaryService storePinkSummaryService;
     private final CifUserDubboServiceClient userDubboServiceClient;
     private final StoreOrderStatusService storeOrderStatusService;
     private RedisUtil redisUtil;
@@ -130,7 +139,31 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
         storePink.setUid(storeOrder.getUid());
         storePink.setIsRefund(0);
         storePink.setStatus(1);
+
+       //插入拼团汇总表
+        StorePinkSummary storePinkSummary = new StorePinkSummary();
+        storePinkSummary.setTotalPrice(storeOrder.getTotalPrice());
+        storePinkSummary.setCid(storeCombination.getId());
+        storePinkSummary.setPid(storeCombination.getProductId());
+        storePinkSummary.setPeople(storeCombination.getPeople());
+        storePinkSummary.setAddTime(date);
+        storePinkSummary.setStopTime(DateUtils.addMinutes(date, effectiveTime));
+        storePinkSummary.setIsRefund(0);
+        storePinkSummary.setPeopleCount(1);
+        storePinkSummary.setStatus(1);
+     //   storePinkSummary.setlId();'//天选 默认0  1为天选',
+     //   storePinkSummary.setkId(); // '团长id',
+    //    storePinkSummary.setIsRefund(); //是否退款  0未退款 1已退款',
+        storePinkSummary.setIsRefund(0);
+        storePinkSummary.setStatus(1);
+
+       EasyToUseUtil.appCreateAssignment(date,storePinkSummary);
+        storePinkSummaryService.save(storePinkSummary);
+
+        //插入拼团详情表
+        storePink.setSpsId(storePinkSummary.getId());
         storePinkService.save(storePink);
+
         // 如果是开团,需要更新订单数据
         storeOrder.setPinkId(storePink.getId());
         update(storeOrder);
@@ -152,8 +185,10 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
             Example.Criteria criteria = condition.createCriteria();
             criteria.andEqualTo("isDelete", 0);
             criteria.andEqualTo("isShow", 1);
+            criteria.andEqualTo("id", dto.getCid());
             criteria.andLessThanOrEqualTo("startTime", date);
             criteria.andGreaterThanOrEqualTo("stopTime", date);
+
             List<StoreCombination> combinationList = storeCombinationService.findByCondition(condition);
             if (CollUtil.isEmpty(combinationList)) {
                 throw new ServiceException("拼团商品不存在或未开启");
@@ -162,7 +197,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
             Condition pinkCondition = new Condition(StorePink.class);
             Example.Criteria pinkCriteria = pinkCondition.createCriteria();
             pinkCriteria.andEqualTo("isDelete", 0);
-            pinkCriteria.andEqualTo("orderId", dto.getOrderId());
+            pinkCriteria.andEqualTo("spsId", dto.getSpsId());
             pinkCriteria.andEqualTo("status", 1);
             List<StorePink> pinkList = storePinkService.findByCondition(pinkCondition);
             int count = teamPink.getPeople() - (CollUtil.isEmpty(pinkList) ? 0 : pinkList.size());
@@ -173,17 +208,30 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
             if (uidList.contains(dto.getUserId())) {
                 throw new ServiceException("您已加入该拼团");
             }
-            joinGroup(teamPink, dto, count);
+            joinGroup(teamPink, dto, count,pinkList.size());
         }
     }
 
-    private void joinGroup(StorePink teamPink, GoPinkDTO dto, int count) {
+    private void joinGroup(StorePink teamPink, GoPinkDTO dto, int count,int pinkSize) {
         //拼团剩余人数
         Date date = new Date();
+
+        //修改拼团汇总表  这块得上分布式锁
+        StorePinkSummary storePinkSummary = new StorePinkSummary();
+
+        storePinkSummary.setPeopleCount(pinkSize+1);
+        EasyToUseUtil.appCreateAssignment(date,storePinkSummary);
+        if (count == 1) {
+            storePinkSummary.setStatus(1);
+        }
+        storePinkSummaryService.update(storePinkSummary);
+
+
         // 加入拼团
         StorePink storePink = new StorePink();
         BeanUtils.copyProperties(teamPink, storePink);
         storePink.setId(null);
+        storePink.setSpsId(storePinkSummary.getId());
 //            storePink.setOrderId(null);
 //            storePink.setOrderIdKey(null);
         storePink.setUid(dto.getUserId());
@@ -195,6 +243,8 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
         storePinkService.save(storePink);
         if (count == 1) {
             storePinkService.pinkSuccess(teamPink.getId());
+
+
             // 考虑是否回写主订单
 
         }
@@ -209,16 +259,32 @@ 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);
+        Example.Criteria pinkSummaryCriteria = pinkSummaryCondition.createCriteria();
+        pinkSummaryCriteria.andEqualTo("isDelete", 0);
+        pinkSummaryCriteria.andEqualTo("cid", dto.getCid());
+        pinkSummaryCriteria.andEqualTo("status", 1);
+        pinkSummaryCondition.setOrderByClause("people_count DESC");
+        List<StorePinkSummary> pinkSummaryList = storePinkSummaryService.findByCondition(pinkSummaryCondition);
+        List<StorePinkSummary> pinkSummaryListResult = ((Page<StorePinkSummary>) pinkSummaryList).getRecords();
+
+        if (CollUtil.isEmpty(pinkSummaryListResult)) {
+            throw new ServiceException("暂时没有可加入的团");
+        }
+
+        List<Long> storePinkSummaryId = pinkSummaryListResult.stream().map(StorePinkSummary::getId).collect(Collectors.toList());
         Condition pinkCondition = new Condition(StorePink.class);
         Example.Criteria pinkCriteria = pinkCondition.createCriteria();
         pinkCriteria.andEqualTo("isDelete", 0);
         pinkCriteria.andEqualTo("cid", dto.getCid());
-        pinkCriteria.andEqualTo("status", 1);
+//        pinkCriteria.andEqualTo("status", 1);
+        pinkCriteria.andIn("sps_id",storePinkSummaryId);
         List<StorePink> pinkList = storePinkService.findByCondition(pinkCondition);
 
-        if (CollUtil.isEmpty(pinkList)) {
-            throw new ServiceException("暂时没有可加入的团");
-        }
+
         Map<String, List<StorePink>> collect = pinkList.stream().collect(Collectors.groupingBy(StorePink::getOrderId));
 
         List<List<StorePink>> availableGroups = collect.values().stream()
@@ -239,7 +305,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
                 StorePink pink = maxPinkList.stream().filter(i -> i.getKId().equals(0L)).collect(Collectors.toList()).get(0);
                 int count = pink.getPeople() - (CollUtil.isEmpty(pinkList) ? 0 : pinkList.size());
                 if (count > 0) {
-                    joinGroup(pink, dto, count);
+                    joinGroup(pink, dto, count,pinkList.size());
                 }
             }
         }
@@ -941,6 +1007,21 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
         return arrayList;
     }
 
+    /**
+     *  @ApiModelProperty(value = "类型 0-全部all  1-待支付topay 2-拼团成功success 3-拼团失败failed 4-拼团奖励reward")
+     *     private Integer type;
+     *     ****************************
+     *GROUP_ORDER_TO_PAY(1, "拼团待支付"),
+     * GROUP_ORDER_CANCELLATION(2, "拼团订单取消"),
+     * GROUP_ORDER_PAID(3, "拼团已支付"),
+     * GROUP_ORDER_REFUND(4, "拼团失败已退款"),
+     * GROUP_ORDER_TO_SHIP(5, "拼团待发货"),
+     * GROUP_ORDER_TO_CLOSED(6, "拼团未中奖关闭"),
+     * GROUP_ORDER_TO_RECEVIE(7, "拼团待收货"),
+     * GROUP_ORDER_COMPLETED(8, "拼团订单完成")
+     *     *****************************
+     *  `status` tinyint unsigned NOT NULL DEFAULT '1' COMMENT '状态  1进行中  2已完成  3未完成',
+     */
     @Override
     public List<StoreOrderVO> appList(StoreOrderAppDTO dto) {
         Condition condition = new Condition(StoreOrder.class);
@@ -962,10 +1043,12 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
             case 0:
                 break;
             case 1:
-                criteria.andEqualTo("paid", 0);
+                criteria.andEqualTo("status", 1);
                 break;
             case 2:
-                pinkCriteria.andEqualTo("status", 1);
+                pinkCriteria.andEqualTo("status", 2);
+                pinkCriteria.andEqualTo("lId", 1);
+                pinkCriteria.andIn("order_status", Arrays.asList(3));
                 pinkList = storePinkService.findByCondition(pinkCondition);
                 if (CollUtil.isNotEmpty(pinkList)) {
                     criteria.andIn("id", pinkList.stream().map(StorePink::getOrderIdKey).collect(Collectors.toList()));
@@ -973,13 +1056,16 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
                 break;
             case 3:
                 pinkCriteria.andEqualTo("status", 2);
+                pinkCriteria.andEqualTo("lId", 0);
+                pinkCriteria.andIn("order_status", Arrays.asList(3));
                 pinkList = storePinkService.findByCondition(pinkCondition);
                 if (CollUtil.isNotEmpty(pinkList)) {
                     criteria.andIn("id", pinkList.stream().map(StorePink::getOrderIdKey).collect(Collectors.toList()));
                 }
                 break;
             case 4:
-                pinkCriteria.andIn("status", Arrays.asList(0, 0));
+                pinkCriteria.andEqualTo("status", 2);
+                pinkCriteria.andIn("order_status", Arrays.asList(5,7,8));
                 pinkList = storePinkService.findByCondition(pinkCondition);
                 if (CollUtil.isNotEmpty(pinkList)) {
                     criteria.andIn("id", pinkList.stream().map(StorePink::getOrderIdKey).collect(Collectors.toList()));
@@ -1312,7 +1398,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
 
         // 检验余额够不够
         Result result = accountDubboServiceClient.getWalletAccount(storeOrder.getUid());
-        if (result.getCode().equals(ResultCode.SUCCESS)) {
+        if (result.getCode().equals(ResultCode.SUCCESS.getCode())) {
             AccountDTO accountDTO = JSONObject.parseObject(JSONObject.toJSONString(result.getData()), AccountDTO.class);
             if (accountDTO.getBalance().compareTo(storeOrder.getPayPrice()) < 0) {
                 throw new ServiceException(ResultCode.INSUFFICIENT_BALANCE);
@@ -1366,7 +1452,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
     }
 
 
-    // 中奖回收状态逻辑还没加
+    // 中奖回收状态逻辑还没加    关闭指系统层面的自动结束  如活动时间超时或者拼团超时由定时任务触发
     @Override
     public void close(Long id) {
         StoreOrder storeOrder = findById(id);
@@ -1375,7 +1461,8 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
         if (ObjectUtils.isEmpty(pinkOrderStatusEnum)) {
             throw new ServiceException("当前状态不支持关闭");
         }
-        updateOrderStatus(storeOrder.getId(), PinkOrderStatusEnum.GROUP_ORDER_TO_CLOSED.getKey());
+        updateOrderStatus(storeOrder.getId(), pinkOrderStatusEnum.getKey());
+
 
 //        if (storeOrder.getStatus().equals(Constants.ORDER_STATUS_H5_COMPLETE)) {
 //            updateOrderStatus(storeOrder.getId(), PinkOrderStatusEnum.CLOSE.getKey());
@@ -1441,12 +1528,22 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
         }
     }
 
+    @Resource
+    private StorePinkMapper storePinkMapper;
     @Override
     public void updateOrderStatus(Long id, Integer status) {
         StoreOrder storeOrder = findById(id);
         storeOrder.setStatus(status);
         update(storeOrder);
+
+        StorePink storePink = new StorePink();
+        Example example = new Example(StorePink.class);
+        example.createCriteria().andEqualTo("orderIdKey",id);
+        storePink.setOrderStatus(status);
+        storePinkMapper.updateByConditionSelective(storePink,example);
+
         storeOrderStatusService.createLog(id, "", PinkOrderStatusEnum.getEnum(status).getValue());
+
     }
 
 

+ 10 - 0
mall-service/src/main/java/com/txz/mall/service/impl/StorePinkServiceImpl.java

@@ -10,6 +10,7 @@ import com.txz.mall.dao.StorePinkMapper;
 import com.txz.mall.dubbo.client.CifAccountDubboServiceClient;
 import com.txz.mall.model.StorePink;
 import com.txz.mall.service.StorePinkService;
+import com.txz.mall.service.StorePinkSummaryService;
 import com.txz.mall.util.RandomUtil;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -46,6 +47,10 @@ public class StorePinkServiceImpl extends AbstractService<StorePink> implements
     }
 
 
+
+    @Resource
+    private StorePinkSummaryService storePinkSummaryService;
+
     @Override
     public void pinkSuccess(Long id) {
         Date date = new Date();
@@ -61,6 +66,11 @@ public class StorePinkServiceImpl extends AbstractService<StorePink> implements
             update(i);
         });
 
+
+        Boolean b = storePinkSummaryService.maintainQuantityStatusOfTheStorePinkSummary(teamPink.getSpsId());
+        if(!b){
+            throw new ServiceException("拼团超员请选择新的拼团");
+        }
         // 算出天选
         theSelection(teamPink.getOrderId());
 

+ 73 - 1
mall-service/src/main/java/com/txz/mall/service/impl/StorePinkSummaryServiceImpl.java

@@ -1,17 +1,25 @@
 package com.txz.mall.service.impl;
 
+import com.txz.mall.core.ServiceException;
+import com.txz.mall.dao.StorePinkMapper;
 import com.txz.mall.dao.StorePinkSummaryMapper;
+import com.txz.mall.model.StorePink;
 import com.txz.mall.model.StorePinkSummary;
 import com.txz.mall.service.StorePinkSummaryService;
 import com.txz.mall.core.AbstractService;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
+import org.springframework.util.ObjectUtils;
+import tk.mybatis.mapper.entity.Condition;
+import tk.mybatis.mapper.entity.Example;
 
 import javax.annotation.Resource;
+import java.util.List;
 
 
 /**
- * Created by CodeGenerator on 2025/08/19.
+ * Created by CodeGenerator on 2025/08/20.
  */
 @Service
 @Transactional
@@ -19,4 +27,68 @@ public class StorePinkSummaryServiceImpl extends AbstractService<StorePinkSummar
     @Resource
     private StorePinkSummaryMapper mStorePinkSummaryMapper;
 
+
+    @Resource
+    private StorePinkMapper mStorePinkMapper;
+
+    @Override
+    public Boolean maintainQuantityStatusOfTheStorePinkSummary(Long id) {
+
+
+        Condition condition = new Condition(StorePink.class);
+        // 创建Criteria对象,用于添加查询条件
+        Example.Criteria criteria = condition.createCriteria();
+        // 添加条件:年龄等于25
+        criteria.andEqualTo("spsId", id);
+        List<StorePink> storePinks = mStorePinkMapper.selectByCondition(condition);
+        int peopleCount = 0;
+
+
+
+        StorePinkSummary storePinkSummary = mStorePinkSummaryMapper.selectByPrimaryKey(id);
+        if(ObjectUtils.isEmpty(storePinkSummary)){
+            throw new ServiceException("拼团汇总不存在 id:"+id);
+        }
+
+        Integer status = storePinkSummary.getStatus();
+        Integer num = 2;
+        if(num.equals(status)){
+            throw new ServiceException("拼团已成功不允许任何更改 id:"+id);
+        }
+        Integer people = storePinkSummary.getPeople();
+
+        int countOneInteger = 0;
+        int countTwoInteger = 0;
+        if(!CollectionUtils.isEmpty(storePinks)){
+
+            Integer deleteInteger = new Integer(0);
+            Integer oneInteger = new Integer(1);
+            Integer twoInteger = new Integer(2);
+             countOneInteger = (int) storePinks.stream().filter(a -> {
+                return deleteInteger.equals(a.getIsDelete())
+                        && oneInteger.equals(a.getStatus());
+            }).count();
+
+             countTwoInteger = (int) storePinks.stream().filter(a -> {
+                return deleteInteger.equals(a.getIsDelete())
+                        && twoInteger.equals(a.getStatus());
+            }).count();
+
+         //   peopleCount = storePinks.size();
+        }
+
+        //这里判断  已经付款成功的订单 总数==活动总人数的时候代表拼团成功
+        if(people==(countTwoInteger)){
+            StorePinkSummary storePinkSummaryForUpdate = new StorePinkSummary();
+            storePinkSummaryForUpdate.setId(id);
+            storePinkSummaryForUpdate.setPeopleCount(peopleCount);
+            storePinkSummaryForUpdate.setStatus(num);
+            mStorePinkSummaryMapper.updateByPrimaryKeySelective(storePinkSummaryForUpdate);
+
+        }else if(countTwoInteger<(countOneInteger+countTwoInteger)){
+            return Boolean.FALSE;
+        }
+
+        return Boolean.TRUE;
+    }
 }

+ 27 - 1
mall-service/src/main/java/com/txz/mall/util/EasyToUseUtil.java

@@ -57,8 +57,10 @@ public class EasyToUseUtil {
         topLevelEntity.setCreateUser(user.getName());
         topLevelEntity.setUpdateUser(user.getName());
         topLevelEntity.setUserId(tokenUserId);
+        topLevelEntity.setUpdateUserId(tokenUserId);;
+        topLevelEntity.setCreateUserId(tokenUserId);
+        topLevelEntity.setIsDelete(0);
         BeanUtils.copyProperties(topLevelEntity,t);
-
     }
 
     public static <T> void  appCreateAssignment( T t){
@@ -93,4 +95,28 @@ public class EasyToUseUtil {
         appDeleteAssignment(date, t);
     }
 
+
+    public static <T> void  appUpdateAssignment(Date date, T t){
+        TopLevelEntity topLevelEntity = new TopLevelEntity();
+
+        UserDTO user = new UserDTO();
+        user.setName("Operation");
+        Long tokenUserId = AuthService.getTokenUserId(null);
+        if(!ObjectUtils.isEmpty(tokenUserId)){
+            try{
+                user = instance.cifUserDubboServiceClient.getUser(tokenUserId);
+            }catch (Exception e){
+                log.error("Failed to get user from cifUserDubboServiceClient ,tokenUserId:{}", tokenUserId, e);
+            }
+
+        }
+        Byte b = 1;
+
+        topLevelEntity.setUpdateUser(user.getName());
+        topLevelEntity.setUpdateUserId(tokenUserId);
+        BeanUtils.copyProperties(topLevelEntity,t);
+    }
+
+
+
 }

+ 31 - 0
mall-service/src/main/java/com/txz/mall/web/param/StorePinkSummaryParam.java

@@ -0,0 +1,31 @@
+package com.txz.mall.web.param;
+
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Data
+@NoArgsConstructor
+public class StorePinkSummaryParam extends BasePageParam{
+
+
+
+
+    /**
+     * 拼团商品id
+     */
+    private Long cid;
+
+    /**
+     * 拼团状态  1进行中  2已完成  3未完成
+     */
+    private Byte status;
+
+
+
+
+
+
+}

+ 17 - 0
mall-service/src/main/java/com/txz/mall/web/param/TopLevelEntity.java

@@ -41,4 +41,21 @@ public class TopLevelEntity implements Serializable {
 
     private Long userId;
 
+
+    /**
+     * 创建人id
+     */
+    private Long createUserId;
+
+    /**
+     * 更新人id
+     */
+    private Long updateUserId;
+
+    /**
+     * 是否删除
+     */
+    private Integer isDelete;
+
+
 }

+ 102 - 0
mall-service/src/main/java/com/txz/mall/web/param/result/StorePinkSummaryVO.java

@@ -0,0 +1,102 @@
+package com.txz.mall.web.param.result;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import javax.persistence.Column;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Data
+@NoArgsConstructor
+public class StorePinkSummaryVO implements Serializable {
+
+    /**
+     * 拼团ID
+     */
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    private Long id;
+
+    /**
+     * 购买总金额
+     */
+    @Column(name = "total_price")
+    private BigDecimal totalPrice;
+
+    /**
+     * 拼团商品id
+     */
+    private Long cid;
+
+    /**
+     * 商品id
+     */
+    private Long pid;
+
+    /**
+     * 拼图总人数
+     */
+    private Integer people;
+
+    /**
+     * 拼团商品单价
+     */
+    private BigDecimal price;
+
+    /**
+     * 开始时间
+     */
+    @Column(name = "add_time")
+    private Date addTime;
+
+    /**
+     * 结束时间
+     */
+    @Column(name = "stop_time")
+    private Date stopTime;
+
+    /**
+     * 天选 默认0  1为天选
+     */
+    @Column(name = "l_id")
+    private Long lId;
+
+    /**
+     * 团长id
+     */
+    @Column(name = "k_id")
+    private Long kId;
+
+    /**
+     * 是否发送模板消息  0未发送  1已发送
+     */
+    @Column(name = "is_tpl")
+    private Byte isTpl;
+
+    /**
+     * 是否退款  0未退款 1已退款
+     */
+    @Column(name = "is_refund")
+    private Byte isRefund;
+
+    /**
+     * 拼团状态  1进行中  2已完成  3未完成
+     */
+    private Byte status;
+
+    /**
+     * 是否虚拟拼团
+     */
+    @Column(name = "is_virtual")
+    private Boolean isVirtual;
+
+    
+
+
+}

+ 4 - 1
mall-service/src/main/java/dto/GoPinkDTO.java

@@ -18,7 +18,7 @@ public class GoPinkDTO implements Serializable {
     @ApiModelProperty(value = "拼团id")
     private Long pinkId;
 
-    @ApiModelProperty(value = "拼团商品id")
+    @ApiModelProperty(value = "拼团商品id  m_store_combination.id")
     private Long cid;
 
     @ApiModelProperty(value = "用户id")
@@ -29,4 +29,7 @@ public class GoPinkDTO implements Serializable {
 
     @ApiModelProperty(value = "类型  open-开团  join-加团")
     private String type;
+
+    @ApiModelProperty(value = "拼团汇总表id")
+    private Long spsId;
 }

+ 4 - 4
mall-service/src/main/java/vo/StoreOrderVO.java

@@ -7,10 +7,7 @@
 package vo;
 
 import com.txz.cif.dto.UserDTO;
-import com.txz.mall.model.StoreOrder;
-import com.txz.mall.model.StoreOrderInfo;
-import com.txz.mall.model.StoreOrderStatus;
-import com.txz.mall.model.UserAddress;
+import com.txz.mall.model.*;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
@@ -42,4 +39,7 @@ public class StoreOrderVO extends StoreOrder implements Serializable {
     @ApiModelProperty(value = "拼团状态 0-未开团 1-开团成功 2-开团失败")
     private Integer pinkStatus;
 
+    @ApiModelProperty(value = "拼团信息")
+    private StorePink storePink;
+
 }

+ 1 - 0
mall-service/src/main/resources/mapper/StorePinkSummaryMapper.xml

@@ -9,6 +9,7 @@
     <result column="total_price" jdbcType="DECIMAL" property="totalPrice" />
     <result column="cid" jdbcType="BIGINT" property="cid" />
     <result column="pid" jdbcType="BIGINT" property="pid" />
+    <result column="people_count" jdbcType="INTEGER" property="peopleCount" />
     <result column="people" jdbcType="INTEGER" property="people" />
     <result column="price" jdbcType="DECIMAL" property="price" />
     <result column="add_time" jdbcType="TIMESTAMP" property="addTime" />