|
|
@@ -1,26 +1,41 @@
|
|
|
package com.cyksj.web.controller.manage.goods;
|
|
|
|
|
|
+import cn.dev33.satoken.stp.StpUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.cyksj.common.constant.Constant;
|
|
|
import com.cyksj.dto.Result;
|
|
|
import com.cyksj.enums.GatewayResponse;
|
|
|
+import com.cyksj.mapper.UserMapper;
|
|
|
+import com.cyksj.mapper.manage.cms.CmsUserMapper;
|
|
|
+import com.cyksj.mapper.shop.YhShopMapper;
|
|
|
+import com.cyksj.model.entity.User;
|
|
|
import com.cyksj.model.entity.YhShopGoodsRate;
|
|
|
+import com.cyksj.model.entity.YhShopUserBusinessDefaultRateConfig;
|
|
|
+import com.cyksj.model.entity.YhShopUserPlatDistributeRate;
|
|
|
+import com.cyksj.model.manage.entity.YhShop;
|
|
|
import com.cyksj.model.request.GoodsDonShopRateReq;
|
|
|
import com.cyksj.model.request.ShopGeneralGoodsRateReq;
|
|
|
import com.cyksj.model.request.YhShopVerifyReq;
|
|
|
-import com.cyksj.model.views.ShopGeneralGoodsRateView;
|
|
|
-import com.cyksj.model.views.YhShopGoodsRateView;
|
|
|
-import com.cyksj.model.views.YhShopView;
|
|
|
+import com.cyksj.model.views.*;
|
|
|
import com.cyksj.service.mange.CmsYhShopCommonService;
|
|
|
import com.cyksj.service.mange.CmsYhShopGoodsRateService;
|
|
|
+import com.cyksj.service.mange.business.UserBusinessRateService;
|
|
|
import com.ejlchina.searcher.BeanSearcher;
|
|
|
import com.ejlchina.searcher.SearchResult;
|
|
|
+import com.ejlchina.searcher.param.Operator;
|
|
|
+import com.ejlchina.searcher.util.MapBuilder;
|
|
|
import com.ejlchina.searcher.util.MapUtils;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Optional;
|
|
|
+import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -41,6 +56,14 @@ public class CmsYhShopGoodsController {
|
|
|
|
|
|
private final HttpServletRequest request;
|
|
|
|
|
|
+ private final UserBusinessRateService userBusinessRateService;
|
|
|
+
|
|
|
+ private final UserMapper userMapper;
|
|
|
+
|
|
|
+ private final CmsUserMapper cmsUserMapper;
|
|
|
+
|
|
|
+ private final YhShopMapper yhShopMapper;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 获取店铺平台价格
|
|
|
@@ -87,6 +110,179 @@ public class CmsYhShopGoodsController {
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(shopGeneralGoodsRateViews);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 店铺管理列表
|
|
|
+ */
|
|
|
+ @GetMapping("/get")
|
|
|
+ public Result<SearchResult<YhShopDistributeView>> getYhShopDistributeView(String showId, String nickname, String startTime, String endTime) {
|
|
|
+ long adminId = StpUtil.getLoginIdAsLong();
|
|
|
+ MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap());
|
|
|
+ //是否是商务人员
|
|
|
+ if (userBusinessRateService.isBusiness(adminId)) {
|
|
|
+ builder.field(YhShopDistributeView::getBusinessId, adminId);
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotBlank(showId)) {
|
|
|
+ builder.field(YhShopDistributeView::getUserId, userMapper.getUserIdByShowId(showId));
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotBlank(nickname)) {
|
|
|
+ List<Long> userIds = userMapper.selectListByNickname(nickname);
|
|
|
+ builder.field(YhShopDistributeView::getUserId, userIds).op(Operator.InList);
|
|
|
+ }
|
|
|
+ String timeSql = StrUtil.EMPTY;
|
|
|
+ if (StrUtil.isNotBlank(startTime)) {
|
|
|
+ timeSql += String.format("and od.created_time >= '%s'", startTime);
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotBlank(endTime)) {
|
|
|
+ timeSql += String.format("and od.created_time < '%s'", endTime);
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotBlank(timeSql)) {
|
|
|
+ builder.put("time", timeSql);
|
|
|
+ //按时间筛选 固定推广人分销情况 倒序
|
|
|
+ builder.orderBy(YhShopDistributeView::getDistributeOrdersMoney).desc();
|
|
|
+ }
|
|
|
+ Map<Long, String> businessNameMap = new ConcurrentHashMap<>();
|
|
|
+ SearchResult<YhShopDistributeView> search = beanSearcher.search(YhShopDistributeView.class, builder.build());
|
|
|
+ search.getDataList().forEach(view -> {
|
|
|
+ if (view.getDistributeOrdersMoney().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ Optional.ofNullable(yhShopMapper.selectSoldMaxGoods(view.getUserId())).ifPresent(title -> view.setGoodsTitle(title));
|
|
|
+ }
|
|
|
+ String businessName = businessNameMap.get(view.getBusinessId());
|
|
|
+ view.setBusinessName(businessName);
|
|
|
+ if (StrUtil.isEmpty(businessName)) {
|
|
|
+ Optional.ofNullable(cmsUserMapper.selectById(view.getBusinessId())).ifPresent(cmsUser -> {
|
|
|
+ businessNameMap.putIfAbsent(view.getBusinessId(), cmsUser.getNickname());
|
|
|
+ view.setBusinessName(cmsUser.getNickname());
|
|
|
+ });
|
|
|
+ }
|
|
|
+ Optional.ofNullable(userMapper.selectById(view.getUserId())).ifPresent(user -> view.setNickname(user.getNickname()));
|
|
|
+ });
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 店铺关闭
|
|
|
+ */
|
|
|
+ @PutMapping("/update/status/{id}")
|
|
|
+ public Result<String> updateShopStatus(@PathVariable Long id) {
|
|
|
+ YhShop yhShop = yhShopMapper.selectById(id);
|
|
|
+ if (yhShop != null) {
|
|
|
+ yhShop.setStatus(!yhShop.getStatus());
|
|
|
+ yhShopMapper.updateById(yhShop);
|
|
|
+ }
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置店铺对应商务
|
|
|
+ */
|
|
|
+ @PutMapping("/set/business")
|
|
|
+ public Result<String> setYhShopBusiness(@RequestBody YhShop yhShop) {
|
|
|
+ cmsYhShopCommonService.setYhShopBusiness(yhShop);
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 店铺提现记录详情
|
|
|
+ */
|
|
|
+ @GetMapping("/get/apply/detail/{shopUserId}")
|
|
|
+ public Result<YhShopDistributeView> getYhShopApplyDetail(@PathVariable Long shopUserId) {
|
|
|
+ YhShopDistributeView yhShopDistributeOrderView = yhShopMapper.getApplyDetailByUserId(shopUserId);
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(yhShopDistributeOrderView);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置店铺提成比例
|
|
|
+ */
|
|
|
+ @PutMapping("/set/rate")
|
|
|
+ public Result<String> setYhShopGoodsRate(@RequestBody List<YhShopUserPlatDistributeRate> yhShopUserPlatDistributeRates) {
|
|
|
+ cmsYhShopCommonService.setYhShopGoodsRate(yhShopUserPlatDistributeRates);
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 店铺注册人数列表
|
|
|
+ */
|
|
|
+ @GetMapping("/get/register/detail/{shopUserId}")
|
|
|
+ public Result<SearchResult<YhShopRegisterDetail>> getRegisterDetail(@PathVariable Long shopUserId) {
|
|
|
+ SearchResult<YhShopRegisterDetail> search = beanSearcher.search(YhShopRegisterDetail.class, MapUtils.flatBuilder(request.getParameterMap()).build());
|
|
|
+ search.getDataList().forEach(data -> {
|
|
|
+ List<RegisterDistributeOrdersDetailView> ordersDetailViewList = beanSearcher.searchAll(RegisterDistributeOrdersDetailView.class, MapUtils.builder().field(RegisterDistributeOrdersDetailView::getUserId, data.getUserId()).op(Operator.Equal).build());
|
|
|
+ data.setOrderNums(ordersDetailViewList.size());
|
|
|
+ Optional<BigDecimal> money = ordersDetailViewList.stream().filter(order -> {
|
|
|
+ if (!Constant.noOrderAllStatus.contains(order.getStatus().name())) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }).map(RegisterDistributeOrdersDetailView::getMoney).reduce(BigDecimal::add);
|
|
|
+ data.setMoney(money.isPresent() ? money.get() : BigDecimal.ZERO);
|
|
|
+ });
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 店铺注册人数 订单详情
|
|
|
+ */
|
|
|
+ @GetMapping("/get/register/order/detail/{yhsId}/{userId}")
|
|
|
+ public Result<SearchResult<YhShopRegisterOrderDetail>> getRegisterOrderDetail(@PathVariable Long yhsId, @PathVariable Long userId) {
|
|
|
+ String condition = String.format("where yhs_id = %s and user_id = %s", yhsId, userId);
|
|
|
+ SearchResult<YhShopRegisterOrderDetail> search = beanSearcher.search(YhShopRegisterOrderDetail.class, MapUtils.flatBuilder(request.getParameterMap())
|
|
|
+ .put("condition", condition)
|
|
|
+ .build());
|
|
|
+ String nickname = StrUtil.EMPTY;
|
|
|
+ for (YhShopRegisterOrderDetail data : search.getDataList()) {
|
|
|
+ if (StrUtil.isEmpty(nickname)) {
|
|
|
+ User user = userMapper.selectById(data.getUserId());
|
|
|
+ nickname = user.getNickname();
|
|
|
+ data.setNickname(nickname);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ data.setNickname(nickname);
|
|
|
+ }
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 店铺订单详情
|
|
|
+ */
|
|
|
+ @GetMapping("/get/order/detail/{shopUserId}")
|
|
|
+ public Result<SearchResult<YhShopDistributeOrderView>> getOrderDetail(@PathVariable Long shopUserId) {
|
|
|
+ SearchResult<YhShopDistributeOrderView> search = beanSearcher.search(YhShopDistributeOrderView.class, MapUtils.flatBuilder(request.getParameterMap())
|
|
|
+ .put("suId", String.format("where shop_user_id = %s", shopUserId))
|
|
|
+ .build());
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置店铺商务默认分销比例
|
|
|
+ */
|
|
|
+ @PutMapping("/set/business/default/rate")
|
|
|
+ public Result<String> setBusinessDefaultRate(@RequestBody List<YhShopUserBusinessDefaultRateConfig> configs) {
|
|
|
+ cmsYhShopCommonService.setBusinessDefaultRate(configs);
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 店铺商务默认比例列表展示
|
|
|
+ */
|
|
|
+ @GetMapping("/get/business/default/rate")
|
|
|
+ public Result<List<YhShopUserBusinessDefaultRateConfigView>> setBusinessDefaultRate() {
|
|
|
+ List<YhShopUserBusinessDefaultRateConfigView> search = beanSearcher.searchAll(YhShopUserBusinessDefaultRateConfigView.class, MapUtils.flatBuilder(request.getParameterMap()).build());
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置店铺商务分销比例
|
|
|
+ */
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 店铺商务 列表
|
|
|
+ */
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 店铺提现 列表
|
|
|
+ */
|
|
|
+
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 开店审核列表
|