| 
					
				 | 
			
			
				@@ -1,11 +1,19 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 package cn.newfeifan.mall.sale.controller.admin.shop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import cn.newfeifan.mall.module.enums.ErrorCodeConstants; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import cn.newfeifan.mall.module.system.api.user.dto.AdminUserRespDTO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import cn.newfeifan.mall.module.system.controller.admin.user.vo.user.UserRespVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import cn.newfeifan.mall.sale.controller.admin.merchant.vo.MerchantRespVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.newfeifan.mall.sale.controller.admin.shop.vo.ShopPageReqVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.newfeifan.mall.sale.controller.admin.shop.vo.ShopRespVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.newfeifan.mall.sale.controller.admin.shop.vo.ShopSaveReqVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import cn.newfeifan.mall.sale.dal.dataobject.merchant.MerchantDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import cn.newfeifan.mall.sale.service.merchant.MerchantService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.newfeifan.mall.sale.service.shop.ShopService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.web.bind.annotation.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import javax.annotation.Resource; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.validation.annotation.Validated; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.security.access.prepost.PreAuthorize; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import io.swagger.v3.oas.annotations.tags.Tag; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -16,17 +24,22 @@ import javax.validation.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import javax.servlet.http.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.io.IOException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.stream.Collectors; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.newfeifan.mall.framework.common.pojo.PageParam; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.newfeifan.mall.framework.common.pojo.PageResult; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.newfeifan.mall.framework.common.pojo.CommonResult; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.newfeifan.mall.framework.common.util.object.BeanUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import static cn.newfeifan.mall.framework.common.pojo.CommonResult.error; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import static cn.newfeifan.mall.framework.common.pojo.CommonResult.success; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.newfeifan.mall.framework.excel.core.util.ExcelUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.newfeifan.mall.framework.operatelog.core.annotations.OperateLog; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import static cn.newfeifan.mall.framework.operatelog.core.enums.OperateTypeEnum.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import static cn.newfeifan.mall.module.enums.ErrorCodeConstants.MERCHANT_NOT_EXISTS; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.newfeifan.mall.sale.dal.dataobject.shop.ShopDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -36,6 +49,10 @@ import cn.newfeifan.mall.sale.dal.dataobject.shop.ShopDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @Validated 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 public class ShopController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Resource 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private MerchantService merchantService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Resource 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private ShopService shopService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -72,6 +89,45 @@ public class ShopController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return success(BeanUtils.toBean(shop, ShopRespVO.class)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @GetMapping("/getAllShop") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Operation(summary = "获得商户下所有店铺") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Parameter(name = "merId", description = "编号", required = true, example = "1024") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @PreAuthorize("@ss.hasPermission('sale:merchant:query')") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public CommonResult<List<ShopRespVO>> getMerchantAllShop(@RequestParam("merId") Long merId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 获取所有店铺 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<ShopRespVO> shops = shopService.getMerchantAllShop(merId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return success(shops); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @GetMapping("/getAllUser") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Operation(summary = "获取店铺下的所有人员列表") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Parameter(name = "id", description = "编号", required = true, example = "1024") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @PreAuthorize("@ss.hasPermission('sale:merchant:query')") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public CommonResult<List<UserRespVO>> getAllUser(@RequestParam("id") Long id) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 获取所有店铺 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<UserRespVO> shops = shopService.getAllUser(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return success(shops); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @GetMapping("/getAllUserByMer") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Operation(summary = "获取商户下的所有人员列表") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Parameter(name = "merId", description = "编号", required = true, example = "1024") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @PreAuthorize("@ss.hasPermission('sale:merchant:query')") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public CommonResult<List<UserRespVO>> getAllUserByMer(@RequestParam("merId") Long merId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 获取所有店铺 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<ShopRespVO> shops = shopService.getMerchantAllShop(merId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (shops.isEmpty()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return success(Collections.emptyList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<Long> shopIds = shops.stream().map(ShopRespVO::getId).collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<UserRespVO> userRespVOS = shopService.getAllUser(shopIds); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return success(userRespVOS); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @GetMapping("/page") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Operation(summary = "获得店铺分页") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @PreAuthorize("@ss.hasPermission('sale:shop:query')") 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -85,12 +141,12 @@ public class ShopController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @PreAuthorize("@ss.hasPermission('sale:shop:export')") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @OperateLog(type = EXPORT) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public void exportShopExcel(@Valid ShopPageReqVO pageReqVO, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-              HttpServletResponse response) throws IOException { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                HttpServletResponse response) throws IOException { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         List<ShopDO> list = shopService.getShopPage(pageReqVO).getList(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // 导出 Excel 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         ExcelUtils.write(response, "店铺.xls", "数据", ShopRespVO.class, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        BeanUtils.toBean(list, ShopRespVO.class)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                BeanUtils.toBean(list, ShopRespVO.class)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |