|
|
@@ -2,12 +2,14 @@ package com.cyksj.web.controller.manage.goods.shop;
|
|
|
|
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.cyksj.common.annotation.NoSubmit;
|
|
|
import com.cyksj.common.constant.Constant;
|
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
+import com.cyksj.common.util.StringUtil;
|
|
|
import com.cyksj.dto.Result;
|
|
|
import com.cyksj.enums.GatewayResponse;
|
|
|
import com.cyksj.mapper.UserMapper;
|
|
|
@@ -27,6 +29,7 @@ import com.ejlchina.searcher.util.MapBuilder;
|
|
|
import com.ejlchina.searcher.util.MapUtils;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
@@ -40,7 +43,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * admin/小店店铺/银河后台/店铺管理
|
|
|
+ * admin/小店店铺/银河后台/商务管理
|
|
|
* @author zwhui
|
|
|
* @date 2023/9/14 16:42
|
|
|
*/
|
|
|
@@ -83,8 +86,13 @@ public class CmsYhShopGoodsController {
|
|
|
* 设置店铺平台价格浮动比例
|
|
|
*/
|
|
|
@PutMapping("/put/goods/rate")
|
|
|
+ @Transactional(rollbackFor = Throwable.class)
|
|
|
public Result<Void> updShopGoodsRate(@RequestBody GoodsDonShopRateReq req) {
|
|
|
req.getList().forEach(e -> {
|
|
|
+ Integer rate = e.getRate();
|
|
|
+ if (rate == null || (rate < 0 && rate > 100)) {
|
|
|
+ throw BusinessRuntimeException.getInstance("请输入正确的比例");
|
|
|
+ }
|
|
|
YhShopGoodsRate one = yhShopGoodsRateService.getOne(Wrappers.lambdaQuery(YhShopGoodsRate.class)
|
|
|
.eq(YhShopGoodsRate::getSkuId, e.getSkuId()).last("limit 1"));
|
|
|
if (one == null) {
|
|
|
@@ -340,9 +348,90 @@ public class CmsYhShopGoodsController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 店铺商务 数据列表
|
|
|
+ * 商务人员列表 详情
|
|
|
*/
|
|
|
@GetMapping("/get/business/list")
|
|
|
+ public Result<SearchResult<YhShopDistributeBusinessView>> getDistributeBusinessView() {
|
|
|
+ long adminId = StpUtil.getLoginIdAsLong();
|
|
|
+ MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap());
|
|
|
+ DateTime beginOfMonth = DateUtil.beginOfMonth(DateTime.now());
|
|
|
+ String thisMonth = beginOfMonth.toString("yyyy-MM");
|
|
|
+ //是否是商务人员
|
|
|
+ if (userBusinessRateService.isBusiness(adminId)) {
|
|
|
+ builder.field(YhShopDistributeBusinessView::getBusinessId, adminId);
|
|
|
+ }
|
|
|
+ builder.put("time", String.format("date_format(ubr.order_created_time,'%%Y-%%m') = '%s'", thisMonth));
|
|
|
+ SearchResult<YhShopDistributeBusinessView> search = beanSearcher.search(YhShopDistributeBusinessView.class, builder.build());
|
|
|
+ search.getDataList().forEach(data -> {
|
|
|
+ Number numOfRelation = beanSearcher.searchCount(UserDistribute.class, MapUtils.builder().field(UserDistribute::getBusinessId, data.getBusinessId()).field(UserDistribute::getDeleted, true).build());
|
|
|
+ data.setNumOfRelation(numOfRelation.intValue());
|
|
|
+ });
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 商务人员提成详情
|
|
|
+ */
|
|
|
+ @GetMapping("/get/takeMoney/detail")
|
|
|
+ public Result<SearchResult<YhShopBusinessTakeMoneyDetail>> getTakeMoneyDetail(String firstMonthDate, String secondMonthDate) {
|
|
|
+ long adminId = StpUtil.getLoginIdAsLong();
|
|
|
+ MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap());
|
|
|
+ //是否是商务人员
|
|
|
+ if (userBusinessRateService.isBusiness(adminId)) {
|
|
|
+ builder.field(YhShopBusinessTakeMoneyDetail::getBusinessId, adminId);
|
|
|
+ }
|
|
|
+ String timeSql = StringUtil.EMPTY;
|
|
|
+ if (StrUtil.isNotBlank(firstMonthDate)) {
|
|
|
+ timeSql += String.format("date_format(ubr.order_created_time,'%%Y-%%m') >= '%s'", firstMonthDate);
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotBlank(secondMonthDate)) {
|
|
|
+ timeSql += String.format("and date_format(ubr.order_created_time,'%%Y-%%m') <= '%s'", secondMonthDate);
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotBlank(timeSql)) {
|
|
|
+ builder.put("time", timeSql);
|
|
|
+ }
|
|
|
+ SearchResult<YhShopBusinessTakeMoneyDetail> search = beanSearcher.search(YhShopBusinessTakeMoneyDetail.class, builder.build());
|
|
|
+ search.getDataList().forEach(data -> {
|
|
|
+ User user = userMapper.selectById(data.getUserId());
|
|
|
+ Optional.ofNullable(user).ifPresent(u -> {
|
|
|
+ data.setNickname(u.getNickname());
|
|
|
+ data.setCreatedTime(u.getCreatedTime());
|
|
|
+ });
|
|
|
+ CmsUser business = cmsUserMapper.selectById(data.getBusinessId());
|
|
|
+ Optional.ofNullable(business).ifPresent(bs -> data.setBusinessName(bs.getNickname()));
|
|
|
+ });
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 商务提成head
|
|
|
+ */
|
|
|
+ @GetMapping("/get/business/headData")
|
|
|
+ public Result<YhShopBusinessTakeMoneyHeadView> getTakeMoneyHeadDetail(String firstMonthDate, String secondMonthDate) {
|
|
|
+ long adminId = StpUtil.getLoginIdAsLong();
|
|
|
+ MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap());
|
|
|
+ //是否是商务人员
|
|
|
+ if (userBusinessRateService.isBusiness(adminId)) {
|
|
|
+ builder.field(YhShopBusinessTakeMoneyHeadView::getBusinessId, adminId);
|
|
|
+ }
|
|
|
+ String timeSql = StringUtil.EMPTY;
|
|
|
+ if (StrUtil.isNotBlank(firstMonthDate)) {
|
|
|
+ timeSql += String.format("date_format(ubr.order_created_time,'%%Y-%%m') >= '%s'", firstMonthDate);
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotBlank(secondMonthDate)) {
|
|
|
+ timeSql += String.format("and date_format(ubr.order_created_time,'%%Y-%%m') <= '%s'", secondMonthDate);
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotBlank(timeSql)) {
|
|
|
+ builder.put("time", timeSql);
|
|
|
+ }
|
|
|
+ YhShopBusinessTakeMoneyHeadView headView = beanSearcher.searchFirst(YhShopBusinessTakeMoneyHeadView.class, builder.build());
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(headView);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 店铺商务 数据列表
|
|
|
+ */
|
|
|
+ @GetMapping("/get/business/data")
|
|
|
public Result<SearchResult<YhShopBusinessDistributesDataView>> getBusinessDistributesData(String startTime, String endTime) {
|
|
|
long adminId = StpUtil.getLoginIdAsLong();
|
|
|
MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap());
|
|
|
@@ -350,12 +439,12 @@ public class CmsYhShopGoodsController {
|
|
|
String time2Sql = StrUtil.EMPTY;
|
|
|
String time3Sql = StrUtil.EMPTY;
|
|
|
if (StrUtil.isNotBlank(startTime)) {
|
|
|
- time1Sql += String.format(" and ud.business_bind_time >= '%s'", startTime);
|
|
|
+ time1Sql += String.format(" and ys.business_bind_time >= '%s'", startTime);
|
|
|
time2Sql += String.format(" and us.created_time >= '%s'", startTime);
|
|
|
time3Sql += String.format(" and od.created_time >= '%s'", startTime);
|
|
|
}
|
|
|
if (StrUtil.isNotBlank(endTime)) {
|
|
|
- time1Sql += String.format(" and ud.business_bind_time < '%s'", endTime);
|
|
|
+ time1Sql += String.format(" and ys.business_bind_time < '%s'", endTime);
|
|
|
time2Sql += String.format(" and us.created_time < '%s'", endTime);
|
|
|
time3Sql += String.format(" and od.created_time < '%s'", endTime);
|
|
|
}
|
|
|
@@ -407,7 +496,6 @@ public class CmsYhShopGoodsController {
|
|
|
@GetMapping("/get/apply")
|
|
|
public Result<SearchResult<YhShopView>> getUserShopApply() {
|
|
|
SearchResult<YhShopView> search = beanSearcher.search(YhShopView.class, MapUtils.flatBuilder(request.getParameterMap())
|
|
|
- .field(YhShopView::getVerifyStatus, List.of(YhShopApplyRecord.Status.verify.name(), YhShopApplyRecord.Status.modify.name())).op(Operator.InList)
|
|
|
.build());
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
|
}
|