Преглед изворни кода

银河店铺后台 店铺头部数据

zoujiajian пре 2 година
родитељ
комит
5c9a6edca4

+ 2 - 0
netflix-dao/src/main/java/com/cyksj/mapper/OrderDonMapper.java

@@ -47,4 +47,6 @@ public interface OrderDonMapper extends BaseMapper<OrderDon> {
 	BigDecimal selectThisMonthDistributeOrderMoney(@Param("skuIds") Set<Long> skuIds, @Param("startDate") String startDate, @Param("endDate") String endDate);
 
 	Map<String, Object> getOrderDetailByGoodsType(@Param("type") Integer type, @Param("noOrderStatus") List<String> noOrderStatus, @Param("startDate") Date startDate, @Param("endDate") Date endDate);
+
+	Map<String, Integer> selectYhShopDistributeOrderDetail(@Param("startDate") Date startDate, @Param("endDate") Date endDate);
 }

+ 11 - 0
netflix-dao/src/main/java/com/cyksj/mapper/shop/YhShopMapper.java

@@ -3,6 +3,11 @@ package com.cyksj.mapper.shop;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.cyksj.model.entity.YhShop;
 import com.cyksj.model.views.YhShopDistributeView;
+import org.apache.ibatis.annotations.Param;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.Map;
 
 /*
  *项目名: yhlxj
@@ -14,4 +19,10 @@ public interface YhShopMapper extends BaseMapper<YhShop> {
 	String selectSoldMaxGoods(Long userId);
 
 	YhShopDistributeView getApplyDetailByUserId(Long userId);
+
+	Map<String, Integer> selectYhShopDetail(@Param("startDate") Date startDate, @Param("endDate") Date endDate);
+
+	BigDecimal selectYhShopTakeMoney(@Param("startDate") Date startDate, @Param("endDate") Date endDate);
+
+	Map<String, Integer> selectYhShopApplyMoney(@Param("startDate") Date startDate, @Param("endDate") Date endDate);
 }

+ 25 - 0
netflix-dao/src/main/java/com/cyksj/model/views/BackgroundDataView.java

@@ -183,4 +183,29 @@ public class BackgroundDataView {
 	 */
 	private Integer waitingSendRealOrder;
 
+	/**
+	 * 店铺数量
+	 */
+	private Integer numOfYhShop;
+
+	/**
+	 * 小店注册人数
+	 */
+	private Integer numOfYhShopRegisterUser;
+
+	/**
+	 * 店铺销售单数
+	 */
+	private Integer numOfYhShopDsOrders;
+
+	/**
+	 * 店铺销售金额
+	 */
+	private BigDecimal yhShopAmount;
+
+	/**
+	 * 店铺提成金额
+	 */
+	private BigDecimal yhShopTakeMoney;
+
 }

+ 12 - 0
netflix-dao/src/main/resources/mapper/OrderDonMapper.xml

@@ -189,4 +189,16 @@
             and created_time &lt; #{endDate}
         </if>
     </select>
+
+    <select id="selectYhShopDistributeOrderDetail" resultType="java.util.Map">
+        select count(*) as numOfDsOrder,
+               ifnull(sum(money),0) as dsMoney
+        from `order_don` where yhs_id > 0 and status not in ('close','noPayment','refund')
+        <if test="startDate != null">
+            and created_time >= #{startDate}
+        </if>
+        <if test="endDate != null">
+            and created_time &lt; #{endDate}
+        </if>
+    </select>
 </mapper>

+ 36 - 0
netflix-dao/src/main/resources/mapper/YhShopMapper.xml

@@ -19,4 +19,40 @@
                  left join yh_shop_distribute_money_apply da on da.user_id = u.id and verify_status = 'success'
         group by u.id, u.points
     </select>
+
+    <select id="selectYhShopDetail" resultType="java.util.Map">
+        select count(distinct ys.user_id) as numOfYhShop,
+               count(distinct us.user_id) as numOfRegisterYhShopUser
+        from (select user_id from `yh_shop` ys where
+        verify_status = 'success'
+        <if test="startDate != null">
+            and created_time >= #{startDate}
+        </if>
+        <if test="endDate != null">
+            and created_time &lt; #{endDate}
+        </if>) ys left join yh_shop_user_distribute_shared us on us.shop_user_id = ys.user_id
+    </select>
+
+    <select id="selectYhShopTakeMoney" resultType="java.math.BigDecimal">
+        select ifnull(sum(money),0) from `yh_shop_distribute_waiting_send_points` where send_status in
+        ('waiting','success')
+        <if test="startDate != null">
+            and created_time >= #{startDate}
+        </if>
+        <if test="endDate != null">
+            and created_time &lt; #{endDate}
+        </if>
+    </select>
+
+    <select id="selectYhShopApplyMoney" resultType="java.util.Map">
+        select ifnull(sum(if(verify_status = 'success',money,0)),0)s,
+        ifnull(sum(if(verify_status = 'verifying',money,0)),0)vf
+        from yh_shop_distribute_money_apply where verify_status in ('verifying','success')
+        <if test="startDate != null">
+            and created_time >= #{startDate}
+        </if>
+        <if test="endDate != null">
+            and created_time &lt; #{endDate}
+        </if>
+    </select>
 </mapper>

+ 2 - 0
netflix-service/src/main/java/com/cyksj/service/mange/statistics/StatisticsDataService.java

@@ -41,4 +41,6 @@ public interface StatisticsDataService {
 	 * 每月业务数据导出
 	 */
 	List<ExcelSheetAndData> exportMonthlyData(Long startTime, Long endTime);
+
+	void yhShopDistribute(BackgroundDataView backgroundDataView, Date startDate, Date endDate);
 }

+ 30 - 1
netflix-service/src/main/java/com/cyksj/service/mange/statistics/impl/StatisticsDataServiceImpl.java

@@ -12,6 +12,7 @@ import com.cyksj.dto.Result;
 import com.cyksj.enums.GatewayResponse;
 import com.cyksj.mapper.*;
 import com.cyksj.mapper.manage.statistics.*;
+import com.cyksj.mapper.shop.YhShopMapper;
 import com.cyksj.model.entity.*;
 import com.cyksj.model.excel.ExcelAccountData;
 import com.cyksj.model.excel.ExcelMonthOrderData;
@@ -23,7 +24,10 @@ import com.cyksj.model.excel.statistics.ExcelRegisterAccountData;
 import com.cyksj.model.excel.statistics.ExcelStreamingAccountData;
 import com.cyksj.model.manage.views.GroupsRelationView;
 import com.cyksj.model.manage.views.OrderDonView;
-import com.cyksj.model.views.*;
+import com.cyksj.model.views.BackgroundDataView;
+import com.cyksj.model.views.DistributeOrdersView;
+import com.cyksj.model.views.ExpiredAccountDataView;
+import com.cyksj.model.views.GoodsDonSkuView;
 import com.cyksj.service.mange.CmsAccountService;
 import com.cyksj.service.mange.statistics.StatisticsDataDayService;
 import com.cyksj.service.mange.statistics.StatisticsDataService;
@@ -80,6 +84,7 @@ public class StatisticsDataServiceImpl implements StatisticsDataService {
 
 	private final StatisticsExportMapper statisticsExportMapper;
 
+	private final YhShopMapper yhShopMapper;
 	private static final GlobalThreadPoolTaskExecutor TASK_POOL = GlobalThreadPoolTaskExecutor.getInstance();
 
 	@Override
@@ -328,6 +333,30 @@ public class StatisticsDataServiceImpl implements StatisticsDataService {
 		return excelSheetDataList;
 	}
 
+	@Override
+	public void yhShopDistribute(BackgroundDataView backgroundDataView, Date startDate, Date endDate) {
+		//店铺数量
+		//注册用户
+		Map<String, Integer> yhShopDetail = yhShopMapper.selectYhShopDetail(startDate, endDate);
+		backgroundDataView.setNumOfYhShop(yhShopDetail.get("numOfYhShop"));
+		backgroundDataView.setNumOfYhShopRegisterUser(yhShopDetail.get("numOfRegisterYhShopUser"));
+		//销售单数
+		//销售金额
+		Map<String, Integer> yhShopOrderDetail = orderDonMapper.selectYhShopDistributeOrderDetail(startDate, endDate);
+		backgroundDataView.setNumOfYhShopDsOrders(yhShopOrderDetail.get("numOfDsOrder"));
+		backgroundDataView.setYhShopAmount(BigDecimal.valueOf(yhShopOrderDetail.get("dsMoney")).divide(BigDecimal.valueOf(100)));
+		//提成金额
+		BigDecimal yhShopTakeMoney = yhShopMapper.selectYhShopTakeMoney(startDate, endDate);
+		backgroundDataView.setYhShopTakeMoney(yhShopTakeMoney.divide(BigDecimal.valueOf(100)));
+
+
+		Map<String,Integer> yhShopApplyDetail = yhShopMapper.selectYhShopApplyMoney(startDate, endDate);
+		//已提现
+		backgroundDataView.setDistributeGotMoney(BigDecimal.valueOf(yhShopApplyDetail.get("s")).divide(BigDecimal.valueOf(100)));
+		//待审核
+		backgroundDataView.setDistributeVerifyingMoney(BigDecimal.valueOf(yhShopApplyDetail.get("vf")).divide(BigDecimal.valueOf(100)));
+	}
+
 	public void exportAllTypeData(List<ExcelSheetAndData> excelSheetDataList, String startDate, String endDate) {
 		CountDownLatch latch = new CountDownLatch(2);
 		TASK_POOL.execute(() -> {

+ 24 - 0
netflix-web/src/main/java/com/cyksj/web/controller/manage/goods/shop/CmsYhShopGoodsController.java

@@ -2,6 +2,7 @@ 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.DateUtil;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.cyksj.common.annotation.NoSubmit;
@@ -18,6 +19,7 @@ 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.cyksj.service.mange.statistics.StatisticsDataService;
 import com.ejlchina.searcher.BeanSearcher;
 import com.ejlchina.searcher.SearchResult;
 import com.ejlchina.searcher.param.Operator;
@@ -30,6 +32,7 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
 import java.math.BigDecimal;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import java.util.Optional;
@@ -63,6 +66,8 @@ public class CmsYhShopGoodsController {
 
     private final YhShopMapper yhShopMapper;
 
+    private final StatisticsDataService statisticsDataService;
+
 
     /**
      * 获取店铺平台价格
@@ -432,4 +437,23 @@ public class CmsYhShopGoodsController {
         cmsYhShopCommonService.verifyYhShopApply(verifyReq);
         return GatewayResponse.SUCCESS.newBuilder().toResult();
     }
+
+    /**
+     * 店铺头部数据
+     */
+    @GetMapping("/get/head/data")
+    public Result<BackgroundDataView> getHeadData(Long startTime, Long endTime) {
+        BackgroundDataView backgroundDataView = new BackgroundDataView();
+        Date startDate = null;
+        Date endDate = null;
+        if (startTime != null) {
+            startDate = DateUtil.date(startTime);
+        }
+        if (endTime != null) {
+            endDate = DateUtil.date(endTime);
+        }
+        //分销金额数据统计
+        statisticsDataService.yhShopDistribute(backgroundDataView, startDate, endDate);
+        return GatewayResponse.SUCCESS.newBuilder().toResult(backgroundDataView);
+    }
 }