package com.yami.shop.api.controller;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.yami.shop.bean.app.dto.ProdCommDataDto;
|
import com.yami.shop.bean.model.Product;
|
import com.yami.shop.bean.model.ShopDetail;
|
import com.yami.shop.bean.model.ShopWallet;
|
import com.yami.shop.bean.model.UserAssets;
|
import com.yami.shop.bean.param.ShopManagementParam;
|
import com.yami.shop.bean.vo.HalfMonthShopRevenueVO;
|
import com.yami.shop.bean.vo.ShopDetailVO;
|
import com.yami.shop.bean.vo.statistics.PlatformStatisticsVO;
|
import com.yami.shop.common.response.ServerResponseEntity;
|
import com.yami.shop.security.api.util.SecurityUtils;
|
import com.yami.shop.service.*;
|
import com.yami.shop.sys.common.service.ShopEmployeeService;
|
import com.yami.shop.user.common.service.UserScoreDetailService;
|
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
import ma.glasnost.orika.MapperFacade;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
import java.util.Date;
|
import java.util.List;
|
|
@RestController
|
@RequestMapping("/p/shopManagement")
|
@Tag(name = "店铺管理接口")
|
public class ShopManagementController {
|
@Autowired
|
private ShopDetailService shopDetailService;
|
@Autowired
|
private UserCollectionShopService userCollectionShopService;
|
@Autowired
|
private OrderService orderService;
|
@Autowired
|
private ProductService productService;
|
@Autowired
|
private UserScoreDetailService userScoreDetailService;
|
@Autowired
|
private ShopEmployeeService shopEmployeeService;
|
@Autowired
|
private StatisticsService statisticsService;
|
@Autowired
|
private ShopWalletService shopWalletService;
|
@Autowired
|
private IUserAssetsService userAssetsService;
|
@Autowired
|
private MapperFacade mapperFacade;
|
@Autowired
|
private ProdCommService prodCommService;
|
|
@GetMapping("/getShopInfo")
|
@Operation(summary = "获取店铺管理页面展示信息" ,description = "获取店铺管理页面展示信息")
|
public ServerResponseEntity<ShopManagementParam> getShopInfo() {
|
ShopManagementParam shopManagementParam = new ShopManagementParam();
|
String userId = SecurityUtils.getUser().getUserId();
|
PlatformStatisticsVO platformStatisticsVO = statisticsService.platformRealTimeOverview(new Date());
|
ShopDetail shopDetail = shopDetailService.getShopDetailByUserId(userId);
|
ShopDetailVO shopDetailVO = mapperFacade.map(shopDetail, ShopDetailVO.class);
|
if (shopDetail != null) {
|
shopManagementParam.setShopDetail(shopDetailVO);
|
shopManagementParam.setShopFans(userCollectionShopService.getFansCountByShopId(shopDetail.getShopId()));
|
List<Long> prodId = productService.getProdIdByShopId(shopDetail.getShopId());
|
shopManagementParam.setShopGrade(prodCommService.getProdScoreByProdIdList(prodId) != null ? prodCommService.getProdScoreByProdIdList(prodId) : shopManagementParam.getShopGrade());
|
shopManagementParam.setShopProdCount(orderService.getShopProdCountByShopId(shopDetail.getShopId()));
|
shopManagementParam.setTodayDealQuota(orderService.getCurrentPayAmount(shopDetail.getShopId()));
|
// 今日访客
|
shopManagementParam.setTodayCaller(platformStatisticsVO.getTodayVisitors() != null ? platformStatisticsVO.getTodayVisitors() : 0);
|
shopManagementParam.setThisWeekOrderNumber(orderService.countByShopIdAndWeek(shopDetail.getShopId(),new Date()));
|
List<HalfMonthShopRevenueVO> halfMonthShopRevenue = orderService.getHalfMonthShopRevenue(shopDetail.getShopId());
|
shopManagementParam.setHalfMonthShopRevenue(halfMonthShopRevenue);
|
ShopWallet shopWallet = shopWalletService.getShopWalletByShopId(shopDetail.getShopId());
|
shopManagementParam.setCanWithdrawMoney(shopWallet.getSettledAmount() != null ? shopWallet.getSettledAmount() : 0);
|
UserAssets userAssets = userAssetsService
|
.getOne(Wrappers.lambdaQuery(UserAssets.class)
|
.eq(UserAssets::getUserId, userId)
|
.isNotNull(UserAssets::getBalance));
|
shopManagementParam.setAccountBalance(userAssets != null ? userAssets.getBalance() : 0);
|
shopManagementParam.setFreezeBalance(userAssets != null ? userAssets.getFreeze() : 0.0);
|
shopManagementParam.setUnconfirmedPayment(shopWallet.getFreezeAmount() != null ? shopWallet.getFreezeAmount() : 0);
|
shopManagementParam.setScoreCount(userScoreDetailService.getUsableScoreByUserId(userId));
|
shopManagementParam.setShopEmployeeCount(shopEmployeeService.getShopEmployeeCountByShopId(shopDetail.getShopId()));
|
return ServerResponseEntity.success(shopManagementParam);
|
}
|
return ServerResponseEntity.success();
|
}
|
}
|