소스 검색

优化下单逻辑,减少数据库操作

lc 1 주 전
부모
커밋
1dd4954324

+ 8 - 3
mall-service/src/main/java/com/txz/mall/configurer/AsyncConfig.java

@@ -18,8 +18,13 @@ public class AsyncConfig {
     @Bean("taskExecutor")
     public Executor taskExecutor() {
         ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
-        executor.setCorePoolSize(10);
-        executor.setMaxPoolSize(30);
+        //todo 核心线程数的配置方案:CPU密集型任务:核心线程数设置为 CPU核心数 + 1 IO密集型任务:核心线程数设置为 2 * CPU核心数
+        int coreSize = Runtime.getRuntime().availableProcessors();
+        if (coreSize < 8) coreSize = 8;
+        executor.setCorePoolSize(coreSize);
+        executor.setMaxPoolSize(coreSize * 2);
+//        executor.setCorePoolSize(10);
+//        executor.setMaxPoolSize(30);
         executor.setQueueCapacity(200);
         executor.setThreadNamePrefix("async-task-");
         executor.setKeepAliveSeconds(30);
@@ -27,4 +32,4 @@ public class AsyncConfig {
         executor.initialize();
         return executor;
     }
-}
+}

+ 0 - 23
mall-service/src/main/java/com/txz/mall/controller/CombinationController.java

@@ -198,29 +198,6 @@ public class CombinationController {
         return Result.success(arrayList);
     }
 
-    /**
-     * 去开团
-     */
-//    @ApiOperation(value = "支付成功-去开团")
-//    @PostMapping(value = "/open")
-    public Result goOpen(@RequestParam("orderId") String orderId) {
-        storeOrderService.goOpen(orderId);
-        return Result.success();
-    }
-
-    /**
-     * 去拼团
-     */
-//    @ApiOperation(value = "去拼团")
-//    @PostMapping(value = "/pink")
-    public Result goPink(@Validated @RequestBody GoPinkDTO dto) {
-        if (dto.getPinkId() == null && dto.getCid() == null) {
-            return Result.fail(ResultCode.ID_IS_NULL);
-        }
-        storeOrderService.goPink(dto);
-        return Result.success();
-    }
-
     /**
      * 更多拼团
      */

+ 17 - 38
mall-service/src/main/java/com/txz/mall/controller/appcontroller/AppCombinationController.java

@@ -44,16 +44,16 @@ import java.util.stream.Collectors;
 @RestController
 @RequestMapping("/app/combination")
 public class AppCombinationController {
-    
+
     private static Logger log = LoggerFactory.getLogger(AppCombinationController.class);
-    
+
     @Resource
     private StoreCombinationService storeCombinationService;
     @Resource
     private StoreOrderService storeOrderService;
     @Resource
     private OrderServiceBusiness orderServiceBusiness;
-    
+
     //    @PostMapping("/add")
     //    @ApiOperation(value = "拼团商品表新增")
     //    public Result add(@RequestBody StoreCombination storeCombination) {
@@ -70,7 +70,7 @@ public class AppCombinationController {
     //        }
     //        return Result.success();
     //    }
-    
+
     //    @DeleteMapping("/delete")
     //    @ApiOperation(value = "拼团商品表删除")
     //    public Result delete(@RequestParam Long id) {
@@ -96,7 +96,7 @@ public class AppCombinationController {
     //        }
     //        return Result.success();
     //    }
-    
+
     //    @PutMapping("/update")
     //    @ApiOperation(value = "拼团商品表更新")
     //    public Result update(@RequestBody StoreCombination storeCombination) {
@@ -108,7 +108,7 @@ public class AppCombinationController {
     //        }
     //        try {
     //            storeCombination.setUpdateTime(new Date());
-    
+
     /// /            storeCombination.setUpdateUserId(userId);
     //            storeCombinationService.update(storeCombination);
     //        } catch (Exception e) {
@@ -123,7 +123,7 @@ public class AppCombinationController {
         if (id == null) {
             return Result.fail(ResultCode.ID_IS_NULL);
         }
-        
+
         StoreCombination storeCombination = null;
         try {
             storeCombination = storeCombinationService.findById(id);
@@ -133,7 +133,7 @@ public class AppCombinationController {
         }
         return Result.success(storeCombination);
     }
-    
+
     // @PostMapping("/app/list")
     // @ApiOperation(value = "拼团商品表获取列表")
     // public Result<List<StoreCombination>> list(@RequestBody StoreProductDTO dto) {
@@ -242,8 +242,8 @@ public class AppCombinationController {
 
         return Result.success(new PageInfo(storeCombinationVOS));
     }
-    
-    
+
+
     @PostMapping("/addActivityProduct")
     @ApiOperation(value = "添加活动商品")
     public Result addActivityProduct(@RequestBody StoreCombinationAddParam storeCombinationAddParam) {
@@ -256,7 +256,7 @@ public class AppCombinationController {
         storeCombinationService.addActivityProduct(storeCombinationAddParam.getList(), storeCombinationAddParam.getActivityId());
         return Result.success();
     }
-    
+
     @GetMapping("/getActivityProductIds")
     @ApiOperation(value = "获取活动商品ids")
     public Result<List<Long>> getActivityProductIds(@RequestParam("activityId") Long activityId) {
@@ -268,30 +268,9 @@ public class AppCombinationController {
         List<Long> arrayList = combinationList.stream().map(StoreCombination::getProductId).collect(Collectors.toList());
         return Result.success(arrayList);
     }
-    
-    /**
-     * 去开团
-     */
-    //    @ApiOperation(value = "支付成功-去开团")
-    //    @PostMapping(value = "/open")
-    public Result goOpen(@RequestParam("orderId") String orderId) {
-        storeOrderService.goOpen(orderId);
-        return Result.success();
-    }
-    
-    /**
-     * 去拼团
-     */
-    //    @ApiOperation(value = "去拼团")
-    //    @PostMapping(value = "/pink")
-    public Result goPink(@Validated @RequestBody GoPinkDTO dto) {
-        if (dto.getPinkId() == null && dto.getCid() == null) {
-            return Result.fail(ResultCode.ID_IS_NULL);
-        }
-        storeOrderService.goPink(dto);
-        return Result.success();
-    }
-    
+
+
+
     /**
      * 更多拼团
      */
@@ -309,7 +288,7 @@ public class AppCombinationController {
         }
         return Result.success(pageInfo);
     }
-    
+
     @ApiOperation(value = "排行榜")
     @GetMapping(value = "/rank")
     public Result<List<StoreCombinationRankVO>> getRank(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer size) {
@@ -324,6 +303,6 @@ public class AppCombinationController {
         }
         return Result.success(pageInfo);
     }
-    
-    
+
+
 }

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

@@ -1,6 +1,7 @@
 package com.txz.mall.service;
 
 import com.github.pagehelper.PageInfo;
+import com.txz.cif.dto.UserDTO;
 import com.txz.mall.core.Result;
 import com.txz.mall.core.Service;
 import com.txz.mall.model.StoreOrder;
@@ -28,12 +29,12 @@ public interface StoreOrderService extends Service<StoreOrder> {
     /**
      * 去开团
      */
-    void goOpen(String orderId);
+    void goOpen(String orderId, UserDTO user);
 
     /**
      * 去拼团
      */
-    void goPink(GoPinkDTO dto);
+    void goPink(GoPinkDTO dto, UserDTO user);
 
     /**
      * 导出订单

+ 91 - 154
mall-service/src/main/java/com/txz/mall/service/impl/StoreOrderServiceImpl.java

@@ -181,145 +181,105 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
     private DailySalesSummaryOfProductsService dailySalesSummaryOfProductsService;
 
     @Override
-    public void goOpen(String orderId) {
+    public void goOpen(String orderId,UserDTO user) {
         StoreOrder storeOrder = findBy("orderId", orderId);
         if (storeOrder == null) {
             String s = I18nUtil.get("order.does.not.exist");
             throw new ServiceException(s + orderId);
         }
-        UserDTO user = userDubboServiceClient.getUser(storeOrder.getUid());
-        StorePink storePink = new StorePink();
-        long storePinkId = IdUtil.getSnowflake(1, 3).nextId();
-        storePink.setId(storePinkId);
-        if (!ObjectUtils.isEmpty(user)) {
-            storePink.setAvatar(user.getHeadPic());
-            storePink.setNickname(user.getName());
-        }
-
-        storePink.setUid(storeOrder.getUid());
-        storePink.setOrderId(storeOrder.getOrderId());
-        storePink.setOrderIdKey(storeOrder.getId());
-        storePink.setTotalNum(storeOrder.getTotalNum());
-        storePink.setTotalPrice(storeOrder.getTotalPrice());
-        StoreCombination storeCombination = storeCombinationService.findById(storeOrder.getCombinationId());
-        storePink.setCid(storeCombination.getId());
-        storePink.setPid(storeCombination.getProductId());
-        storePink.setPeople(storeCombination.getPeople());
-        storePink.setPrice(storeCombination.getPrice());
-        Date date = storeOrder.getCreateTime();
-        Integer effectiveTime = storeCombination.getEffectiveTime();
-        storePink.setAddTime(date);
-        storePink.setStopTime(DateUtils.addMinutes(date, effectiveTime));
-        storePink.setKId(0);
-        storePink.setLId(0);
-        storePink.setUid(storeOrder.getUid());
-        storePink.setIsRefund(0);
-        storePink.setStatus(1);
-        storePink.setOrderStatus(storeOrder.getStatus());
-
-        // 插入拼团汇总表
-        StorePinkSummary storePinkSummary = new StorePinkSummary();
-        long storePinkSummaryId = IdUtil.getSnowflake(1, 2).nextId();
-        storePinkSummary.setId(storePinkSummaryId);
-        storePinkSummary.setTotalPrice(storeOrder.getTotalPrice());
-        storePinkSummary.setCid(storeCombination.getId());
-        storePinkSummary.setPid(storeCombination.getProductId());
-
-        SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd");
-        String formatted = sdf.format(date);
-        String tgCode = OrderUtils.getTGCode(formatted);
-
-        storePinkSummary.setCode(tgCode);
-        storePinkSummary.setPeople(storeCombination.getPeople());
-        storePinkSummary.setAddTime(date);
-        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);
-        List<String> orderNoSet = new ArrayList<>();
-        orderNoSet.add(orderId);
-        String orderNoSetStr = JSONObject.toJSONString(orderNoSet);
-        storePinkSummary.setOrderNoSet(orderNoSetStr);
-        EasyToUseUtil.appCreateAssignment(date, storePinkSummary);
-        storePinkSummaryService.save(storePinkSummary);
-
-        // 插入拼团详情表
-        storePink.setSpsId(storePinkSummary.getId());
-        storePink.setSpsCode(storePinkSummary.getCode());
-        EasyToUseUtil.appCreateAssignment(date, storePink);
-        storePinkService.save(storePink);
-
-        // 插入每日统计表
-        dailySalesSummaryOfProductsService.saveDailySalesSummaryOfProducts(storePink);
+//        UserDTO user = userDubboServiceClient.getUser(storeOrder.getUid());
+      afterGoOpen(storeOrder,user);
+    }
 
-        // 如果是开团,需要更新订单数据
-        storeOrder.setPinkId(storePink.getId());
 
-        Example exampleStoreOrder = new Example(StoreOrder.class);
-        exampleStoreOrder.createCriteria().andEqualTo("orderId", orderId);
-        storeOrder.setOrderId(null);
-        storeOrder.setCreateTime(null);
-        storeOrder.setUid(null);
-
-        storeOrderMapper.updateByConditionSelective(storeOrder, exampleStoreOrder);
-        // 先清空分片建再设置回去传递到后面,因为分片建不允许更新
-        storeOrder.setOrderId(orderId);
-        // 分库分表后下面的修改方式已经不合适了换上上面的方式
-        //   update(storeOrder);
+  /**
+   *
+   * @param storeOrder
+   * @param user
+   */
+  private void afterGoOpen(StoreOrder storeOrder,UserDTO user) {
+      StorePink storePink = new StorePink();
+      long storePinkId = IdUtil.getSnowflake(1, 3).nextId();
+      storePink.setId(storePinkId);
+      if (!ObjectUtils.isEmpty(user)) {
+        storePink.setAvatar(user.getHeadPic());
+        storePink.setNickname(user.getName());
+      }
+      storePink.setUid(storeOrder.getUid());
+      storePink.setOrderId(storeOrder.getOrderId());
+      storePink.setOrderIdKey(storeOrder.getId());
+      storePink.setTotalNum(storeOrder.getTotalNum());
+      storePink.setTotalPrice(storeOrder.getTotalPrice());
+      StoreCombination storeCombination = storeCombinationService.findById(storeOrder.getCombinationId());
+      storePink.setCid(storeCombination.getId());
+      storePink.setPid(storeCombination.getProductId());
+      storePink.setPeople(storeCombination.getPeople());
+      storePink.setPrice(storeCombination.getPrice());
+      Date date = storeOrder.getCreateTime();
+      Integer effectiveTime = storeCombination.getEffectiveTime();
+      storePink.setAddTime(date);
+      storePink.setStopTime(DateUtils.addMinutes(date, effectiveTime));
+      storePink.setKId(0);
+      storePink.setLId(0);
+      storePink.setUid(storeOrder.getUid());
+      storePink.setIsRefund(0);
+      storePink.setStatus(1);
+      storePink.setOrderStatus(storeOrder.getStatus());
+
+      // 插入拼团汇总表
+      StorePinkSummary storePinkSummary = new StorePinkSummary();
+      long storePinkSummaryId = IdUtil.getSnowflake(1, 2).nextId();
+      storePinkSummary.setId(storePinkSummaryId);
+      storePinkSummary.setTotalPrice(storeOrder.getTotalPrice());
+      storePinkSummary.setCid(storeCombination.getId());
+      storePinkSummary.setPid(storeCombination.getProductId());
+
+      SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd");
+      String formatted = sdf.format(date);
+      String tgCode = OrderUtils.getTGCode(formatted);
+
+      storePinkSummary.setCode(tgCode);
+      storePinkSummary.setPeople(storeCombination.getPeople());
+      storePinkSummary.setAddTime(date);
+      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);
+      List<String> orderNoSet = new ArrayList<>();
+      orderNoSet.add(storeOrder.getOrderId());
+      String orderNoSetStr = JSONObject.toJSONString(orderNoSet);
+      storePinkSummary.setOrderNoSet(orderNoSetStr);
+      EasyToUseUtil.appCreateAssignment(date, storePinkSummary,user);
+      storePinkSummaryService.save(storePinkSummary);
+
+      // 插入拼团详情表
+      storePink.setSpsId(storePinkSummary.getId());
+      storePink.setSpsCode(storePinkSummary.getCode());
+      EasyToUseUtil.appCreateAssignment(date, storePink,user);
+      storePinkService.save(storePink);
+      // 插入每日统计表
+      dailySalesSummaryOfProductsService.saveDailySalesSummaryOfProducts(storePink);
+      StoreOrder  upStoreOrder = new StoreOrder();
+      // 如果是开团,需要更新订单数据
+      upStoreOrder.setPinkId(storePink.getId());
+      Example exampleStoreOrder = new Example(StoreOrder.class);
+      exampleStoreOrder.createCriteria().andEqualTo("orderId", storeOrder.getOrderId());
+      storeOrderMapper.updateByConditionSelective(upStoreOrder, exampleStoreOrder);
+      // 先清空分片建再设置回去传递到后面,因为分片建不允许更新
+      storeOrder.setOrderId(storeOrder.getOrderId());
     }
 
-    //    @Override
-    //    public void goPink(GoPinkDTO dto) {
-    //        Date date = new Date();
-    //        if (dto.getPinkId() == null && dto.getCid() != null) {
-    //            automaticMatch(dto);
-    //        }
-    //        if (dto.getPinkId() != null) {
-    //            StorePink teamPink = storePinkService.findById(dto.getPinkId());
-    //            if (ObjectUtil.isNull(teamPink) || teamPink.getIsRefund().equals(1)) {
-    //                throw new ServiceException(I18nUtil.get("the.corresponding.group.buying.does.not.exist"));
-    //            }
-    //            Condition condition = new Condition(StoreCombination.class);
-    //            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(I18nUtil.get("group.buying.product.does.not.exist.or.is.not.activated"));
-    //            }
-    //
-    //            Condition pinkCondition = new Condition(StorePink.class);
-    //            Example.Criteria pinkCriteria = pinkCondition.createCriteria();
-    //            pinkCriteria.andEqualTo("isDelete", 0);
-    //            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());
-    //            if (count < 1) {
-    //                throw new ServiceException(I18nUtil.get("group.buying.is.full"));
-    //            }
-    //            List<Long> uidList = pinkList.stream().map(StorePink::getUid).collect(Collectors.toList());
-    //            if (uidList.contains(dto.getUserId())) {
-    //                throw new ServiceException("您已加入该拼团");
-    //            }
-    //            joinGroup(teamPink, dto, count,pinkList.size());
-    //        }
-    //    }
 
 
     @Override
-    public void goPink(GoPinkDTO dto) {
+    public void goPink(GoPinkDTO dto, UserDTO user) {
         dto.setPinkId(null);
         Date date = new Date();
         if (dto.getPinkId() == null && dto.getCid() != null) {
-            automaticMatch(dto);
+            automaticMatch(dto,user);
         }
         if (dto.getPinkId() != null) {
             StorePink teamPink = storePinkService.findById(dto.getPinkId());
@@ -355,24 +315,13 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
             if (uidList.contains(dto.getUserId())) {
                 throw new ServiceException(I18nUtil.get("duplicate.group.buying"));
             }
-            joinGroup(teamPink, dto, count, pinkList.size());
+            joinGroup(teamPink, dto, user);
         }
     }
 
-    private void joinGroup(StorePink teamPink, GoPinkDTO dto, int count, int pinkSize) {
+    private void joinGroup(StorePink teamPink, GoPinkDTO dto,  UserDTO user) {
         // 拼团剩余人数
         Date date = new Date();
-
-        // 修改拼团汇总表  这块得上分布式锁   这块不需要了,会去 maintainQuantityStatusOfTheStorePinkSummary幂等时时维护 汇总表的拼团状态和拼团数量的
-        //        StorePinkSummary storePinkSummary = new StorePinkSummary();
-        //        storePinkSummary.setId(dto.getSpsId());
-        //        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);
@@ -388,7 +337,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
         storePink.setIsRefund(0);
         storePink.setKId(1);
         storePink.setSpsCode(dto.getSpsCode());
-        UserDTO user = userDubboServiceClient.getUser(dto.getUserId());
+//        UserDTO user = userDubboServiceClient.getUser(dto.getUserId());
         if (!ObjectUtils.isEmpty(user)) {
             storePink.setUid(dto.getUserId());
             storePink.setAvatar(user.getHeadPic());
@@ -410,24 +359,12 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
         Condition storeOrderCondition = new Condition(StoreOrder.class);
         storeOrderCondition.createCriteria().andEqualTo("orderId", dto.getOrderId());
         storeOrderMapper.updateByConditionSelective(storeOrder, storeOrderCondition);
-        //**分库整改
-        // update(storeOrder);
-        //        if(!b){
-        //            throw new ServiceException("拼团超员请选择新的拼团");
-        //        }
-
-        //        if (count == 1) {
-        //            storePinkService.pinkSuccess(teamPink.getId());
-        //
-        //            // 考虑是否回写主订单
-        //
-        //        }
     }
 
     /**
      * 自动匹配
      */
-    private void automaticMatch(GoPinkDTO dto) {
+    private void automaticMatch(GoPinkDTO dto, UserDTO user) {
         // 找一个最快能成团的
         StoreCombination storeCombination = storeCombinationService.findById(dto.getCid());
         if (ObjectUtil.isNull(storeCombination) || storeCombination.getIsDelete().equals(1)) {
@@ -518,7 +455,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
                 if (count > 0) {
                     dto.setSpsId(pink.getSpsId()); // 拼团汇总表id
                     dto.setSpsCode(pink.getSpsCode()); // 拼团汇总表code
-                    joinGroup(pink, dto, count, pinkList.size());
+                    joinGroup(pink, dto,user);
                 } else {
                     throw new ServiceException(I18nUtil.get("the.number.of.group.buying.participants.exceeds.the.limit.please.initiate.group.buying.again.pinkid") + pink.getId());
                 }
@@ -1818,7 +1755,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
     // 处理拼团逻辑
     private void handleGroupPurchase(CreateOrderRequest request, StoreOrder storeOrder, UserDTO user) {
       if ("open".equals(request.getType())) {
-        goOpen(storeOrder.getOrderId());
+         afterGoOpen(storeOrder,user);
       }
       if ("join".equals(request.getType())) {
         GoPinkDTO goPinkDTO = new GoPinkDTO();
@@ -1828,7 +1765,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
         goPinkDTO.setSpsId(request.getSpsId());
         goPinkDTO.setPinkId(request.getPinkId());
         goPinkDTO.setUserId(user.getId());
-        goPink(goPinkDTO);
+        goPink(goPinkDTO, user);
       }
     }
 

+ 21 - 41
mall-service/src/main/java/com/txz/mall/util/EasyToUseUtil.java

@@ -121,47 +121,27 @@ public class EasyToUseUtil {
         BeanUtils.copyProperties(topLevelEntity,t);
     }
 
-
-    /**
-     * {"id":1,"name":"admin",
-     * "loginAccount":"admin",
-     * "password":"51D0DBF9A1A4A103AC3270B5C67E5E0A",
-     * "salt":"q3VNUI1341h",
-     * "phoneNo":"17682302017",
-     * "email":"1",
-     * "status":"0",
-     * "createTime":1504681409000,
-     * "updateTime":1583286557000,
-     * "createUserId":"1",
-     * "updateUserId":"admin",
-     * "token":"f3813140-f2a4-457b-8382-e3e049bfe705"}
-     * @param request
-     * @return
-     */
-//    public static <T> void  pcUpdateAssignment(Date date, T t){
-//        TopLevelEntity topLevelEntity = new TopLevelEntity();
-//
-//        UserDTO user = new UserDTO();
-//        user.setName("Operation");
-//        JSONObject tokenUser = UserUtil.getTokenUser(null);
-//        Long tokenUserId = 0L;
-//
-//
-//        if(!ObjectUtils.isEmpty(tokenUser)){
-//            if(!ObjectUtils.isEmpty(tokenUser.getLongValue("id"))){
-//                tokenUserId = tokenUser.getLongValue("id");
-//            }
-//            if(!ObjectUtils.isEmpty(tokenUser.getString("loginAccount"))){
-//                user.setName(tokenUser.getString("loginAccount"));
-//            }
-//
-//        }
-//        Byte b = 1;
-//
-//        topLevelEntity.setUpdateUser(user.getName());
-//        topLevelEntity.setUpdateUserId(tokenUserId);
-//        BeanUtils.copyProperties(topLevelEntity,t);
-//    }
+  /**
+   *
+   * @param date
+   * @param t
+   * @param user
+   * @param <T>
+   */
+    public static <T> void  appCreateAssignment(Date date, T t,UserDTO user){
+      TopLevelEntity topLevelEntity = new TopLevelEntity();
+      topLevelEntity.setIsValid((byte) 1);
+      topLevelEntity.setVersion(1);
+      topLevelEntity.setCreateTime(date);
+      topLevelEntity.setUpdateTime(date);
+      topLevelEntity.setCreateUser(user.getName());
+      topLevelEntity.setUpdateUser(user.getName());
+      topLevelEntity.setUserId(user.getId());
+      topLevelEntity.setUpdateUserId(user.getId());;
+      topLevelEntity.setCreateUserId(user.getId());
+      topLevelEntity.setIsDelete(0);
+      BeanUtils.copyProperties(topLevelEntity,t);
+    }
 
 
 }