Browse Source

feat:国家客服端上游接口

zhangwei 1 week ago
parent
commit
6eb5fbfd9b
27 changed files with 316 additions and 28 deletions
  1. 12 0
      edu-travel-adapter/edu-travel-adapter-country/src/main/java/edu/travel/adapter/service/country/CountryAdapter.java
  2. 2 2
      edu-travel-adapter/edu-travel-adapter-warehouse/src/main/java/edu/travel/adapter/service/warehouse/ShopWarehouseStaffAdapter.java
  3. 42 0
      edu-travel-api/edu-travel-api-web/src/main/java/edu/travel/controller/BaseCountryServeController.java
  4. 2 1
      edu-travel-api/edu-travel-api-web/src/main/java/edu/travel/controller/ShopProductSkuController.java
  5. 12 1
      edu-travel-common/edu-travel-common-cache/src/main/java/edu/travel/cache/util/RedisKey.java
  6. 10 0
      edu-travel-common/edu-travel-common-datasource/pom.xml
  7. 17 4
      edu-travel-common/edu-travel-common-datasource/src/main/java/edu/travel/config/FieldMetaObjectHandler.java
  8. 34 0
      edu-travel-common/edu-travel-common-util/src/main/java/edu/travel/DateUtil.java
  9. 5 0
      edu-travel-remote/edu-travel-remote-commodity/src/main/java/edu/travel/remote/dto/AddShopOrderDto.java
  10. 10 0
      edu-travel-remote/edu-travel-remote-country/src/main/java/edu/travel/remote/BaseCountryServeRemoteController.java
  11. 23 0
      edu-travel-remote/edu-travel-remote-country/src/main/java/edu/travel/vo/ServiceCountryVo.java
  12. 5 0
      edu-travel-remote/edu-travel-remote-order/src/main/java/edu/travel/remote/dto/AddOrderDto.java
  13. 6 0
      edu-travel-remote/edu-travel-remote-order/src/main/java/edu/travel/remote/dto/AddOrderItemDto.java
  14. 4 1
      edu-travel-remote/edu-travel-remote-tenant/src/main/java/edu/travel/remote/feign/mode/dto/tenant/AddMenuDto.java
  15. 1 1
      edu-travel-remote/edu-travel-remote-tenant/src/main/java/edu/travel/remote/feign/mode/dto/tenant/AddOrUpdateTenantDto.java
  16. 13 0
      edu-travel-remote/edu-travel-remote-warehouse/src/main/java/edu/travel/dto/InsertWarehouseStaffDto.java
  17. 1 1
      edu-travel-remote/edu-travel-remote-warehouse/src/main/java/edu/travel/remote/ShopWarehouseRemoteController.java
  18. 2 2
      edu-travel-remote/edu-travel-remote-warehouse/src/main/java/edu/travel/remote/ShopWarehouseStaffRemoteController.java
  19. 1 1
      edu-travel-service/edu-travel-service-commodity/src/main/java/edu/travel/commodity/service/impl/ShopCategoryServiceImpl.java
  20. 6 3
      edu-travel-service/edu-travel-service-commodity/src/main/java/edu/travel/commodity/service/impl/ShopProductSkuServiceImpl.java
  21. 6 0
      edu-travel-service/edu-travel-service-country/src/main/java/edu/travel/country/entity/BaseCountryServe.java
  22. 69 0
      edu-travel-service/edu-travel-service-country/src/main/java/edu/travel/country/web/BaseCountryServeController.java
  23. 2 1
      edu-travel-service/edu-travel-service-country/src/main/resources/mapper/BaseCountryServeMapper.xml
  24. 5 0
      edu-travel-service/edu-travel-service-tenement/src/main/java/edu/travel/tenant/entity/SysMenu.java
  25. 5 6
      edu-travel-service/edu-travel-service-tenement/src/main/java/edu/travel/tenant/service/impl/ITenantServiceImpl.java
  26. 2 1
      edu-travel-service/edu-travel-service-tenement/src/main/resources/mapper/SysMenuMapper.xml
  27. 19 3
      edu-travel-service/edu-travel-service-warehouse/src/main/java/edu/travel/warehouse/web/ShopWarehouseStaffController.java

+ 12 - 0
edu-travel-adapter/edu-travel-adapter-country/src/main/java/edu/travel/adapter/service/country/CountryAdapter.java

@@ -5,10 +5,14 @@ import edu.travel.dto.BaseCountryServeDto;
 import edu.travel.remote.BaseCountryServeRemoteController;
 import edu.travel.rpc.RPCBaseResponse;
 import edu.travel.vo.BaseCountryServeVo;
+import edu.travel.vo.ServiceCountryVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 
 import java.util.List;
+import java.util.Map;
 
 @Component
 public class CountryAdapter {
@@ -48,4 +52,12 @@ public class CountryAdapter {
     public RPCBaseResponse<List<BaseCountryServeVo>> getAllForm() {
         return baseCountryServeRemoteController.getAllForm();
     }
+    @AdapterAnnotation
+    public RPCBaseResponse<Void> selection(String countryId){
+        return baseCountryServeRemoteController.selection(countryId);
+    }
+    @AdapterAnnotation
+    public RPCBaseResponse<Map<String, List<ServiceCountryVo>>> grouped(){
+        return baseCountryServeRemoteController.grouped();
+    }
 }

+ 2 - 2
edu-travel-adapter/edu-travel-adapter-warehouse/src/main/java/edu/travel/adapter/service/warehouse/ShopWarehouseStaffAdapter.java

@@ -1,7 +1,7 @@
 package edu.travel.adapter.service.warehouse;
 
 import edu.travel.adapter.annotation.AdapterAnnotation;
-import edu.travel.dto.ShopWarehouseStaffDto;
+import edu.travel.dto.InsertWarehouseStaffDto;
 import edu.travel.remote.ShopWarehouseStaffRemoteController;
 import edu.travel.rpc.RPCBaseResponse;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -12,7 +12,7 @@ public class ShopWarehouseStaffAdapter {
     @Autowired
     private ShopWarehouseStaffRemoteController shopWarehouseStaffRemoteController;
     @AdapterAnnotation
-    public RPCBaseResponse<Boolean> insertWarehouseStaff(ShopWarehouseStaffDto staffDto){
+    public RPCBaseResponse<Boolean> insertWarehouseStaff(InsertWarehouseStaffDto staffDto){
         return shopWarehouseStaffRemoteController.insertWarehouseStaff(staffDto);
     }
 }

+ 42 - 0
edu-travel-api/edu-travel-api-web/src/main/java/edu/travel/controller/BaseCountryServeController.java

@@ -0,0 +1,42 @@
+package edu.travel.controller;
+
+import edu.travel.adapter.service.country.CountryAdapter;
+import edu.travel.rpc.RPCBaseResponse;
+import edu.travel.vo.ServiceCountryVo;
+import org.springframework.beans.factory.annotation.Autowired;
+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.RestController;
+
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * 服务国家表(base_country_serve)表控制层
+ *
+ * @author xxxxx
+ */
+@RestController
+@RequestMapping("/baseCountryServe")
+public class BaseCountryServeController {
+    @Autowired
+    private CountryAdapter countryAdapter;
+
+    /**
+     * 选择服务国家
+     */
+    @PostMapping("/selection")
+    public RPCBaseResponse<Void> selection(@RequestBody String countryId) {
+        return countryAdapter.selection(countryId);
+    }
+    /**
+     *
+     */
+    @PostMapping("/grouped")
+    public RPCBaseResponse<Map<String, List<ServiceCountryVo>>> grouped() {
+        return countryAdapter.grouped();
+    }
+
+}

+ 2 - 1
edu-travel-api/edu-travel-api-web/src/main/java/edu/travel/controller/ShopProductSkuController.java

@@ -43,7 +43,8 @@ public class ShopProductSkuController {
      */
 
     @PostMapping("/shopProductSku")
-    public RPCBaseResponse<Void> shopProductSku(@RequestBody AddShopOrderDto params) {
+    public RPCBaseResponse<Void> shopProductSku(@RequestHeader("TimeZone") String timeZone,@RequestBody AddShopOrderDto params) {
+        params.setTimeZone(timeZone);
         return shopProductSkuAdapter.shopProductSku(params);
     }
 

+ 12 - 1
edu-travel-service/edu-travel-service-commodity/src/main/java/edu/travel/commodity/constant/RedisKey.java → edu-travel-common/edu-travel-common-cache/src/main/java/edu/travel/cache/util/RedisKey.java

@@ -1,4 +1,4 @@
-package edu.travel.commodity.constant;
+package edu.travel.cache.util;
 
 public interface RedisKey {
     /**
@@ -24,4 +24,15 @@ public interface RedisKey {
 
     String PRODUCT_ORDER = BASH + "product:order";
 
+
+    /**
+     * 用户时区
+     */
+    String USER_COUNTRY= BASH + "user:country:";
+
+    /**
+     * 国家
+     */
+    String COUNTRY_SORT= BASH + "country:sort";
+
 }

+ 10 - 0
edu-travel-common/edu-travel-common-datasource/pom.xml

@@ -80,5 +80,15 @@
             <groupId>cn.hutool</groupId>
             <artifactId>hutool-all</artifactId>
         </dependency>
+        <dependency>
+            <groupId>edu.travel</groupId>
+            <artifactId>edu-travel-common-cache</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>edu.travel</groupId>
+            <artifactId>edu-travel-common-util</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
     </dependencies>
 </project>

+ 17 - 4
edu-travel-common/edu-travel-common-datasource/src/main/java/edu/travel/config/FieldMetaObjectHandler.java

@@ -1,9 +1,14 @@
 package edu.travel.config;
 
+import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
+import edu.travel.DateUtil;
+import edu.travel.cache.util.RedisKey;
 import org.apache.ibatis.reflection.MetaObject;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.security.core.Authentication;
 import org.springframework.security.core.context.SecurityContextHolder;
 import org.springframework.stereotype.Component;
@@ -19,6 +24,10 @@ import java.util.Date;
  */
 @Component
 public class FieldMetaObjectHandler implements MetaObjectHandler {
+    @Autowired
+    private StringRedisTemplate stringRedisTemplate;
+
+
     private final static String UPDATE_USER_ID = "updateUserId";
     private final static String UPDATE_TIME = "updateTime";
     private final static String CREATE_USER_ID = "createUserId";
@@ -35,19 +44,21 @@ public class FieldMetaObjectHandler implements MetaObjectHandler {
             return;
         }
         Long userId = null;
-
+        //时区
+        String s =null;
         if (!(principal instanceof String && "anonymousUser".equals(principal))) {
             //走登录用户
             String jsonString = JSON.toJSONString(principal);
             JSONObject jsonObject = JSON.parseObject(jsonString);
             userId = jsonObject.getLong("id");
+            s = stringRedisTemplate.opsForValue().get(RedisKey.USER_COUNTRY + userId);
         }
 
         if (metaObject.hasSetter(CREATE_USER_ID)) {
             this.strictInsertFill(metaObject, CREATE_USER_ID, String.class, userId != null ? userId.toString() : "");
         }
         if (metaObject.hasSetter(CREATE_TIME)) {
-            this.strictInsertFill(metaObject, CREATE_TIME, Date.class, new Date());
+            this.strictInsertFill(metaObject, CREATE_TIME, Date.class, ObjectUtil.isEmpty(s)? new Date() : DateUtil.convertServerTimeToUserDateTime(s));
         }
         if (metaObject.hasSetter(PROJECT)) {
             this.strictInsertFill(metaObject, PROJECT, String.class, request.getHeader("project"));
@@ -61,11 +72,13 @@ public class FieldMetaObjectHandler implements MetaObjectHandler {
     public void updateFill(MetaObject metaObject) {
         Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
         JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(principal));
+        String userId = jsonObject.getLong("id").toString();
+        String s = stringRedisTemplate.opsForValue().get(RedisKey.USER_COUNTRY + userId);
         if (metaObject.hasSetter(UPDATE_USER_ID)) {
-            this.strictInsertFill(metaObject, UPDATE_USER_ID, String.class, jsonObject.getLong("id").toString());
+            this.strictInsertFill(metaObject, UPDATE_USER_ID, String.class, userId);
         }
         if (metaObject.hasSetter(UPDATE_TIME)) {
-            this.strictInsertFill(metaObject, UPDATE_TIME, Date.class, new Date());
+            this.strictInsertFill(metaObject, UPDATE_TIME, Date.class,ObjectUtil.isEmpty(s)? new Date() : DateUtil.convertServerTimeToUserDateTime(s));
         }
     }
 }

+ 34 - 0
edu-travel-common/edu-travel-common-util/src/main/java/edu/travel/DateUtil.java

@@ -0,0 +1,34 @@
+package edu.travel;
+
+import java.time.Instant;
+import java.time.ZoneId;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Date;
+
+public class DateUtil {
+    public static String convertServerTimeToUserStringTime(String userTimeZone) {
+        // 获取服务器当前时间
+        ZonedDateTime serverTime = ZonedDateTime.now();
+        // 根据用户时区创建ZoneId
+        ZoneId userZoneId = ZoneId.of(userTimeZone);
+        // 转换时间为用户时区的时间
+        ZonedDateTime userTime = serverTime.withZoneSameInstant(userZoneId);
+        // 格式化输出时间
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        return userTime.format(formatter);
+    }
+
+    public static Date convertServerTimeToUserDateTime(String userTimeZone) {
+        // 获取服务器当前时间
+        ZonedDateTime serverTime = ZonedDateTime.now();
+        // 根据用户时区创建ZoneId
+        ZoneId userZoneId = ZoneId.of(userTimeZone);
+        // 转换时间为用户时区的时间
+        ZonedDateTime userTime = serverTime.withZoneSameInstant(userZoneId);
+        // 将ZonedDateTime转换为Instant
+        Instant instant = userTime.toInstant();
+        // 从Instant创建Date对象
+        return Date.from(instant);
+    }
+}

+ 5 - 0
edu-travel-remote/edu-travel-remote-commodity/src/main/java/edu/travel/remote/dto/AddShopOrderDto.java

@@ -38,4 +38,9 @@ public class AddShopOrderDto {
      * 优惠券ID
      */
     private String globalCouponId;
+
+    /**
+     * 时区
+     */
+    private String timeZone;
 }

+ 10 - 0
edu-travel-remote/edu-travel-remote-country/src/main/java/edu/travel/remote/BaseCountryServeRemoteController.java

@@ -4,11 +4,15 @@ import edu.travel.dto.BaseCountryServeDto;
 import edu.travel.remote.base.RemoteBaseController;
 import edu.travel.rpc.RPCBaseResponse;
 import edu.travel.vo.BaseCountryServeVo;
+import edu.travel.vo.ServiceCountryVo;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestParam;
 
 import java.util.List;
+import java.util.Map;
 
 @FeignClient(path = "/baseCountryServe", name = "country-dev")
 public interface BaseCountryServeRemoteController extends RemoteBaseController<BaseCountryServeVo, BaseCountryServeDto> {
@@ -18,4 +22,10 @@ public interface BaseCountryServeRemoteController extends RemoteBaseController<B
 
     @GetMapping("/getFormId")
     public RPCBaseResponse<BaseCountryServeVo> getFormId(@RequestParam("id") String id);
+
+    @PostMapping("/selection")
+    public RPCBaseResponse<Void> selection(@RequestBody String countryId);
+
+    @GetMapping("/grouped")
+    public RPCBaseResponse<Map<String, List<ServiceCountryVo>>> grouped();
 }

+ 23 - 0
edu-travel-remote/edu-travel-remote-country/src/main/java/edu/travel/vo/ServiceCountryVo.java

@@ -0,0 +1,23 @@
+package edu.travel.vo;
+
+import lombok.Data;
+
+@Data
+public class ServiceCountryVo {
+
+    private String id;
+    /**
+     * 中文国家/洲名称
+     */
+    private String countryNameZh;
+
+    /**
+     * 英文国家/洲名称
+     */
+    private String countryNameEn;
+
+    /**
+     * 本地国家/洲名称
+     */
+    private String countryNameLocal;
+}

+ 5 - 0
edu-travel-remote/edu-travel-remote-order/src/main/java/edu/travel/remote/dto/AddOrderDto.java

@@ -107,4 +107,9 @@ public class AddOrderDto {
      * 平台优惠券ID
      */
     private String globalCouponId;
+    /**
+     * 创建时间
+     */
+    public Date createTime;
+
 }

+ 6 - 0
edu-travel-remote/edu-travel-remote-order/src/main/java/edu/travel/remote/dto/AddOrderItemDto.java

@@ -3,6 +3,7 @@ package edu.travel.remote.dto;
 import lombok.Data;
 
 import java.math.BigDecimal;
+import java.util.Date;
 
 /**
  * 类功能描述:
@@ -58,4 +59,9 @@ public class AddOrderItemDto {
      * 商品ID
      */
     private String productId;
+
+    /**
+     * 创建时间
+     */
+    public Date createTime;
 }

+ 4 - 1
edu-travel-remote/edu-travel-remote-tenant/src/main/java/edu/travel/remote/feign/mode/dto/tenant/AddMenuDto.java

@@ -28,5 +28,8 @@ public class AddMenuDto {
      */
     private SysMenuExtraDataDto sysMenuExtraData;
 
-
+    /**
+     * 排序
+     */
+    private Integer sortOrder;
 }

+ 1 - 1
edu-travel-remote/edu-travel-remote-tenant/src/main/java/edu/travel/remote/feign/mode/dto/tenant/AddOrUpdateTenantDto.java

@@ -101,5 +101,5 @@ public class AddOrUpdateTenantDto {
     /**
      * 仓库Id
      */
-    private String warehouseId;
+    private List<String> warehouseId;
 }

+ 13 - 0
edu-travel-remote/edu-travel-remote-warehouse/src/main/java/edu/travel/dto/InsertWarehouseStaffDto.java

@@ -0,0 +1,13 @@
+package edu.travel.dto;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class InsertWarehouseStaffDto {
+
+    private String userId;
+
+    private List<String> warehouseIds;
+}

+ 1 - 1
edu-travel-remote/edu-travel-remote-warehouse/src/main/java/edu/travel/remote/ShopWarehouseRemoteController.java

@@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.RequestBody;
 import javax.servlet.http.HttpServletRequest;
 import java.util.List;
 
-@FeignClient(path = "/shopWarehouse", name = "warehouse-dev")
+@FeignClient(path = "/shopWarehouse", name = "${spring.application.name}")
 public interface ShopWarehouseRemoteController extends RemoteBaseController<ShopWarehouseVo, ShopWarehouseDto> {
     @GetMapping("/getWarehouseCountryForm")
     public RPCBaseResponse<List<ShopWarehouseVo>> getWarehouseCountryForm(ShopWarehouseDto dto);

+ 2 - 2
edu-travel-remote/edu-travel-remote-warehouse/src/main/java/edu/travel/remote/ShopWarehouseStaffRemoteController.java

@@ -1,6 +1,6 @@
 package edu.travel.remote;
 
-import edu.travel.dto.ShopWarehouseStaffDto;
+import edu.travel.dto.InsertWarehouseStaffDto;
 import edu.travel.rpc.RPCBaseResponse;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -9,5 +9,5 @@ import org.springframework.web.bind.annotation.RequestBody;
 @FeignClient(path = "/shopWarehouseStaff", name = "warehouse-dev")
 public interface ShopWarehouseStaffRemoteController {
     @PostMapping("/insertWarehouseStaff")
-    public RPCBaseResponse<Boolean> insertWarehouseStaff(@RequestBody ShopWarehouseStaffDto staffDto);
+    public RPCBaseResponse<Boolean> insertWarehouseStaff(@RequestBody InsertWarehouseStaffDto staffDto);
 }

+ 1 - 1
edu-travel-service/edu-travel-service-commodity/src/main/java/edu/travel/commodity/service/impl/ShopCategoryServiceImpl.java

@@ -15,7 +15,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import edu.travel.adapter.service.country.CountryAdapter;
 import edu.travel.adapter.service.upload.UploadAdapter;
 import edu.travel.commodity.constant.BaseConstant;
-import edu.travel.commodity.constant.RedisKey;
+import edu.travel.cache.util.RedisKey;
 import edu.travel.commodity.entity.ShopCategory;
 import edu.travel.commodity.mapper.ShopCategoryMapper;
 import edu.travel.commodity.service.ShopCategoryService;

+ 6 - 3
edu-travel-service/edu-travel-service-commodity/src/main/java/edu/travel/commodity/service/impl/ShopProductSkuServiceImpl.java

@@ -6,12 +6,13 @@ import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import edu.travel.DateUtil;
 import edu.travel.adapter.service.country.CountryAdapter;
 import edu.travel.adapter.service.country.CurrencyAdapter;
 import edu.travel.adapter.service.order.OrderAdapter;
 import edu.travel.adapter.service.order.OrderItemAdapter;
 import edu.travel.adapter.service.order.ShopOrderLogAdapter;
-import edu.travel.commodity.constant.RedisKey;
+import edu.travel.cache.util.RedisKey;
 import edu.travel.commodity.entity.ShopAddress;
 import edu.travel.commodity.entity.ShopProduct;
 import edu.travel.commodity.entity.ShopProductSku;
@@ -23,6 +24,7 @@ import edu.travel.commodity.service.ShopAddressService;
 import edu.travel.commodity.service.ShopProductService;
 import edu.travel.commodity.service.ShopProductSkuService;
 import edu.travel.commodity.service.ShopSkuSpecValueService;
+import edu.travel.commodity.utils.IdUtils;
 import edu.travel.commodity.utils.TokenData;
 import edu.travel.exception.BaseException;
 import edu.travel.remote.dto.*;
@@ -173,6 +175,7 @@ public class ShopProductSkuServiceImpl extends ServiceImpl<ShopProductSkuMapper,
                     addOrderItemDto.setPrice(shopProductSku.getPrice());
                     addOrderItemDto.setQuantity(dto.getQuantity());
                     addOrderItemDto.setOrderId(orderNum + "");
+                    addOrderItemDto.setCreateTime(DateUtil.convertServerTimeToUserDateTime(params.getTimeZone()));
 
                     ShopSnapshotVo shopSnapshotVo = snapshot.get(shopProductSku.getSkuId().toString());
                     shopSnapshotVo.setProductName(shopProduct.getProductName());
@@ -197,6 +200,7 @@ public class ShopProductSkuServiceImpl extends ServiceImpl<ShopProductSkuMapper,
                 order.setCurrencyId(currency.getId().toString());
                 order.setOrderRemark(params.getRemark());
                 order.setUserId(userId);
+                order.setCreateTime(DateUtil.convertServerTimeToUserDateTime(params.getTimeZone()));
 
                 orderAdapter.addShopOrder(order);
                 orderItemAdapter.addShopOrderItem(orderItems);
@@ -222,8 +226,7 @@ public class ShopProductSkuServiceImpl extends ServiceImpl<ShopProductSkuMapper,
         if (ObjectUtil.isEmpty(skus)) {
             ShopProductSku bean = new ShopProductSku();
             bean.setProductId(product.getId());
-            Snowflake snowflake = IdUtil.createSnowflake(1, 1);
-            long sku = snowflake.nextId();
+            long sku = IdUtils.getSnowflakeId();
             bean.setSkuId(sku);
             bean.setPrice(product.getDefaultPrice());
             bean.setImageUrl(product.getMainImageUrl());

+ 6 - 0
edu-travel-service/edu-travel-service-country/src/main/java/edu/travel/country/entity/BaseCountryServe.java

@@ -137,4 +137,10 @@ public class BaseCountryServe extends BaseEntity {
     @TableField(exist = false)
     @LinkOne(linkField = "countryId", linkMapper = BaseCountryMapper.class, linkPrimaryField = "id")
     private Map<String, Object> countryMap;
+
+    /**
+     * 时区
+     */
+    @TableField(value = "time_zone")
+    private String timeZone;
 }

+ 69 - 0
edu-travel-service/edu-travel-service-country/src/main/java/edu/travel/country/web/BaseCountryServeController.java

@@ -1,23 +1,41 @@
 package edu.travel.country.web;
 
 
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.extra.pinyin.PinyinUtil;
+import cn.hutool.json.JSONArray;
+import cn.hutool.json.JSONObject;
+import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import edu.travel.cache.util.RedisKey;
 import edu.travel.country.entity.BaseCountryServe;
 import edu.travel.country.service.BaseCountryServeService;
 import edu.travel.country.service.BaseCountryService;
 import edu.travel.dto.BaseCountryServeDto;
 import edu.travel.dto.BaseCountryServeStatusDto;
+import edu.travel.entity.EduTenantPO;
 import edu.travel.remote.BaseCountryServeRemoteController;
 import edu.travel.rpc.RPCBaseResponse;
 import edu.travel.vo.BaseCountryServeStatusVo;
 import edu.travel.vo.BaseCountryServeVo;
+import edu.travel.vo.ServiceCountryVo;
 import edu.travel.web.BaseController;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.security.core.context.SecurityContextHolder;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.stream.Collectors;
+
+import static edu.travel.rpc.RPCBaseResponse.error;
+import static edu.travel.rpc.RPCBaseResponse.success;
 
 /**
  * 服务国家表(base_country_serve)表控制层
@@ -35,6 +53,8 @@ public class BaseCountryServeController extends BaseController<BaseCountryServe>
     private BaseCountryServeService baseCountryServeService;
     @Autowired
     private BaseCountryService baseCountryService;
+    @Autowired
+    private StringRedisTemplate stringRedisTemplate;
 
     /**
      * 分页连表
@@ -150,4 +170,53 @@ public class BaseCountryServeController extends BaseController<BaseCountryServe>
         BeanUtils.copyProperties(listRPCBaseResponse, baseCountryServeVoRPCBaseResponse);
         return baseCountryServeVoRPCBaseResponse;
     }
+
+    /**
+     * 选择服务国家
+     */
+    @PostMapping("/selection")
+    public RPCBaseResponse<Void> selection(@RequestBody String countryId) {
+        EduTenantPO principal = (EduTenantPO) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
+        String userId = principal.getId().toString();
+        BaseCountryServe byId = baseCountryServeService.getById(countryId);
+        if(byId==null){
+            return error("国家不存在");
+        }
+        String key = RedisKey.USER_COUNTRY + userId;
+        stringRedisTemplate.opsForValue().set(key,byId.getTimeZone());
+        return success();
+    }
+    @GetMapping("/grouped")
+    public RPCBaseResponse<Map<String, List<ServiceCountryVo>>> grouped() {
+        //缓存获取
+        String s = stringRedisTemplate.opsForValue().get(RedisKey.COUNTRY_SORT);
+        if(!ObjectUtil.isEmpty(s)){
+            JSONObject objects = JSONUtil.parseObj(s);
+            Map<String, List<ServiceCountryVo>> result = new HashMap<>();
+
+            objects.forEach((key, value) -> {
+                JSONArray jsonArray = (JSONArray) value;
+                List<ServiceCountryVo> countries = jsonArray.toList(ServiceCountryVo.class);
+                result.put(key, countries);
+            });
+            return success(result);
+        }
+
+        List<BaseCountryServe> list = baseCountryServeService.list();
+        List<ServiceCountryVo> serviceCountryVos = BeanUtil.copyToList(list, ServiceCountryVo.class);
+        TreeMap<String, List<ServiceCountryVo>> collect = serviceCountryVos.stream()
+                .filter(country -> country != null && !ObjectUtil.isEmpty(country))
+                .collect(Collectors.groupingBy(
+                        country -> {
+                            String firstChar = country.getCountryNameEn().substring(0, 1);
+                            return firstChar.toUpperCase();
+                        },
+                        TreeMap::new,
+                        Collectors.toList()
+                ));
+        //放入缓存
+        String jsonStr = JSONUtil.toJsonStr(collect);
+        stringRedisTemplate.opsForValue().set(RedisKey.COUNTRY_SORT,jsonStr);
+        return success(collect);
+    }
 }

+ 2 - 1
edu-travel-service/edu-travel-service-country/src/main/resources/mapper/BaseCountryServeMapper.xml

@@ -19,11 +19,12 @@
         <result column="update_user_id" jdbcType="VARCHAR" property="updateUserId"/>
         <result column="delete_flag" jdbcType="INTEGER" property="deleteFlag"/>
         <result column="currency_id" jdbcType="BIGINT" property="currencyId"/>
+        <result column="time_zone" jdbcType="VARCHAR" property="timeZone"/>
     </resultMap>
     <sql id="Base_Column_List">
         <!--@mbg.generated-->
         id, parent_id, country_id, service_charge_value, pay_view_way, country_name_zh, country_name_en,
         country_name_local, serve_enable, project, create_time, create_user_id, update_time,
-        update_user_id, delete_flag, currency_id
+        update_user_id, delete_flag, currency_id,time_zone
     </sql>
 </mapper>

+ 5 - 0
edu-travel-service/edu-travel-service-tenement/src/main/java/edu/travel/tenant/entity/SysMenu.java

@@ -84,4 +84,9 @@ public class SysMenu extends BaseEntity implements Serializable {
     @LinkConst(fieldName = "type", clazz = EnableDict.class)
     private Map codeMenuTypeDict;
 
+    /**
+     * 权重排序
+     */
+    @TableField(value = "sort_order")
+    private Integer sortOrder;
 }

+ 5 - 6
edu-travel-service/edu-travel-service-tenement/src/main/java/edu/travel/tenant/service/impl/ITenantServiceImpl.java

@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import edu.travel.adapter.service.warehouse.ShopWarehouseStaffAdapter;
+import edu.travel.dto.InsertWarehouseStaffDto;
 import edu.travel.dto.ShopWarehouseStaffDto;
 import edu.travel.remote.feign.mode.dto.tenant.AddOrUpdateTenantDto;
 import edu.travel.remote.feign.mode.dto.tenant.AssignRolesOrMenusDto;
@@ -77,12 +78,10 @@ public class ITenantServiceImpl extends SysServiceImpl<EduTenantMapper, EduTenan
         EduTenant principal = (EduTenant) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
         assign(assignRolesOrMenusDto, principal);
         if(!ObjectUtil.isEmpty(addOrUpdateTenantDto.getWarehouseId())){
-            ShopWarehouseStaffDto shopWarehouseStaffDto = new ShopWarehouseStaffDto();
-            shopWarehouseStaffDto.setUserId(tenant.getId().toString());
-
-            shopWarehouseStaffDto.setWarehouseId(addOrUpdateTenantDto.getWarehouseId());
-
-            shopWarehouseStaffAdapter.insertWarehouseStaff(shopWarehouseStaffDto);
+            InsertWarehouseStaffDto insertWarehouseStaffDto = new InsertWarehouseStaffDto();
+            insertWarehouseStaffDto.setUserId(tenant.getId().toString());
+            insertWarehouseStaffDto.setWarehouseIds(addOrUpdateTenantDto.getWarehouseId());
+            shopWarehouseStaffAdapter.insertWarehouseStaff(insertWarehouseStaffDto);
         }
 
         return tenant;

+ 2 - 1
edu-travel-service/edu-travel-service-tenement/src/main/resources/mapper/SysMenuMapper.xml

@@ -8,6 +8,7 @@
         <result column="parent_id" jdbcType="BIGINT" property="parentId"/>
         <result column="title" jdbcType="VARCHAR" property="title"/>
         <result column="type" jdbcType="INTEGER" property="type"/>
+        <result column="sort_order" jdbcType="INTEGER" property="sortOrder"/>
         <result column="component" jdbcType="VARCHAR" property="component"/>
         <result column="path" jdbcType="VARCHAR" property="path"/>
         <result column="name" jdbcType="VARCHAR" property="name"/>
@@ -22,6 +23,6 @@
     <sql id="Base_Column_List">
         <!--@mbg.generated-->
         id, parent_id, title, `type`, component, `path`, `name`, `status`, delete_flag,
-        project, create_user_id, create_time, update_user_id, update_time
+        project, create_user_id, create_time, update_user_id, update_time,sort_order
     </sql>
 </mapper>

+ 19 - 3
edu-travel-service/edu-travel-service-warehouse/src/main/java/edu/travel/warehouse/web/ShopWarehouseStaffController.java

@@ -1,10 +1,13 @@
 package edu.travel.warehouse.web;
 
 import cn.hutool.core.bean.BeanUtil;
+import edu.travel.dto.InsertWarehouseStaffDto;
 import edu.travel.dto.ShopWarehouseStaffDto;
 import edu.travel.remote.ShopWarehouseStaffRemoteController;
 import edu.travel.rpc.RPCBaseResponse;
+import edu.travel.warehouse.entity.ShopWarehouse;
 import edu.travel.warehouse.entity.ShopWarehouseStaff;
+import edu.travel.warehouse.service.ShopWarehouseService;
 import edu.travel.warehouse.service.ShopWarehouseStaffService;
 import edu.travel.web.BaseController;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -13,21 +16,34 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.ArrayList;
+import java.util.List;
+
 
 @RestController
 @RequestMapping("/shopWarehouseStaff")
 class ShopWarehouseStaffController extends BaseController<ShopWarehouseStaff> implements ShopWarehouseStaffRemoteController {
     @Autowired
     private ShopWarehouseStaffService shopWarehouseStaffService;
+    @Autowired
+    private ShopWarehouseService shopWarehouseService;
 
     /**
      *  新增库房人员关联
      * @return {@link RPCBaseResponse }<{@link Boolean }>
      */
     @PostMapping("/insertWarehouseStaff")
-    public RPCBaseResponse<Boolean> insertWarehouseStaff(@RequestBody ShopWarehouseStaffDto staffDto){
-        ShopWarehouseStaff bean = BeanUtil.toBean(staffDto, ShopWarehouseStaff.class);
-        return RPCBaseResponse.success(shopWarehouseStaffService.save(bean));
+    public RPCBaseResponse<Boolean> insertWarehouseStaff(@RequestBody InsertWarehouseStaffDto staffDto){
+
+        List<ShopWarehouse> shopWarehouses = shopWarehouseService.getBaseMapper().selectBatchIds(staffDto.getWarehouseIds());
+        ArrayList<ShopWarehouseStaff> shopWarehouseStaffs = new ArrayList<>();
+        for (ShopWarehouse shopWarehouse : shopWarehouses) {
+            ShopWarehouseStaff shopWarehouseStaff = new ShopWarehouseStaff();
+            shopWarehouseStaff.setWarehouseId(shopWarehouse.getId());
+            shopWarehouseStaff.setUserId(Long.valueOf(staffDto.getUserId()));
+            shopWarehouseStaffs.add(shopWarehouseStaff);
+        }
+        return RPCBaseResponse.success(shopWarehouseStaffService.saveBatch(shopWarehouseStaffs));
     }