Browse Source

首页数据

PLF 5 years ago
parent
commit
557bddea5e

+ 2 - 2
src/main/java/com/caimei/modules/order/controller/CmOrderRemarkController.java

@@ -60,8 +60,8 @@ public class CmOrderRemarkController {
      * @return
      */
     @ResponseBody
-    @RequestMapping(value = "addRemarks",method = RequestMethod.POST)
-    public JsonModel addRemarks(String remarks, Integer orderID, HttpServletRequest httpRequest) {
+    @RequestMapping(value = "addRemarks", method = RequestMethod.POST)
+    public JsonModel addRemarks(@RequestBody String remarks, @RequestBody Integer orderID, HttpServletRequest httpRequest) {
         JsonModel jsonModel = JsonModel.newInstance();
         String token = httpRequest.getHeader("token");
         String decoded = TokenEncryptUtils.decoded(token);

+ 18 - 0
src/main/java/com/caimei/modules/order/entity/NewOrderProduct.java

@@ -95,6 +95,24 @@ public class NewOrderProduct {
     private Boolean firstReturn;    //是否是第一次退货退款
     private Double newCostPrice; // 成本价
     private Double singleShouldPayTotalTax; //单个付供应商税费
+    private Integer frequency;  //订单量
+    private Integer totalNum;   //销售量
+
+    public Integer getFrequency() {
+        return frequency;
+    }
+
+    public void setFrequency(Integer frequency) {
+        this.frequency = frequency;
+    }
+
+    public Integer getTotalNum() {
+        return totalNum;
+    }
+
+    public void setTotalNum(Integer totalNum) {
+        this.totalNum = totalNum;
+    }
 
     public String getBuyer() {
         return buyer;

+ 4 - 1
src/main/java/com/caimei/modules/shiro/controller/HomePageController.java

@@ -1,11 +1,13 @@
 package com.caimei.modules.shiro.controller;
 
+import com.caimei.modules.order.entity.NewOrderProduct;
 import com.caimei.modules.shiro.service.HomePageService;
 import com.caimei.utils.JsonModel;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.List;
 import java.util.Map;
 
 @RestController
@@ -46,6 +48,7 @@ public class HomePageController {
      */
     @RequestMapping("commodity")
     public JsonModel commodity(String endTime, String startTime) {
-        return null;
+        List<NewOrderProduct> orderProduct = homePageService.commodity(endTime, startTime);
+        return JsonModel.newInstance().success(orderProduct);
     }
 }

+ 5 - 0
src/main/java/com/caimei/modules/shiro/dao/HomePageDao.java

@@ -1,8 +1,11 @@
 package com.caimei.modules.shiro.dao;
 
+import com.caimei.modules.order.entity.NewOrderProduct;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
+
 @Mapper
 public interface HomePageDao {
 
@@ -13,4 +16,6 @@ public interface HomePageDao {
     Long findAssociate(@Param("endTime") String endTime, @Param("startTime") String startTime);
 
     Integer orderQuantity(@Param("endTime") String endTime, @Param("startTime") String startTime, @Param("receiptStatus") String receiptStatus);
+
+    List<NewOrderProduct> commodity(@Param("endTime") String endTime, @Param("startTime") String startTime);
 }

+ 5 - 0
src/main/java/com/caimei/modules/shiro/service/HomePageService.java

@@ -1,5 +1,8 @@
 package com.caimei.modules.shiro.service;
 
+import com.caimei.modules.order.entity.NewOrderProduct;
+
+import java.util.List;
 import java.util.Map;
 
 public interface HomePageService {
@@ -8,4 +11,6 @@ public interface HomePageService {
     Map<String, Object> orderQuantity(String endTime, String startTime);
 
     Map<String, Object> sale();
+
+    List<NewOrderProduct> commodity(String endTime, String startTime);
 }

+ 39 - 21
src/main/java/com/caimei/modules/shiro/service/impl/HomePageServiceImpl.java

@@ -1,5 +1,6 @@
 package com.caimei.modules.shiro.service.impl;
 
+import com.caimei.modules.order.entity.NewOrderProduct;
 import com.caimei.modules.shiro.dao.HomePageDao;
 import com.caimei.modules.shiro.service.HomePageService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -7,9 +8,7 @@ import org.springframework.stereotype.Service;
 
 import java.text.DecimalFormat;
 import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.*;
 
 @Service
 public class HomePageServiceImpl implements HomePageService {
@@ -56,27 +55,48 @@ public class HomePageServiceImpl implements HomePageService {
     @Override
     public Map<String, Object> sale() {
         Map<String, Object> map = new HashMap();
-        Map<String, String> map1 = CalendarUtils(0);
-        Long totalFee1 = homePageDao.findTotalFee(map1.get("endTime"), map1.get("startTime"));
-        map.put(map1.get("month"), totalFee1);
-        Map<String, String> map2 = CalendarUtils(-1);
-        Long totalFee2 = homePageDao.findTotalFee(map2.get("endTime"), map2.get("startTime"));
-        map.put(map2.get("month"), totalFee2);
-        Map<String, String> map3 = CalendarUtils(-2);
-        Long totalFee3 = homePageDao.findTotalFee(map3.get("endTime"), map3.get("startTime"));
-        map.put(map3.get("month"), totalFee3);
-        Map<String, String> map4 = CalendarUtils(-3);
-        Long totalFee4 = homePageDao.findTotalFee(map4.get("endTime"), map4.get("startTime"));
-        map.put(map4.get("month"), totalFee4);
-        Map<String, String> map5 = CalendarUtils(-4);
-        Long totalFee5 = homePageDao.findTotalFee(map5.get("endTime"), map5.get("startTime"));
-        map.put(map5.get("month"), totalFee5);
+        List<String> list1 = new ArrayList();
+        List<Long> list2 = new ArrayList();
         Map<String, String> map6 = CalendarUtils(-5);
         Long totalFee6 = homePageDao.findTotalFee(map6.get("endTime"), map6.get("startTime"));
-        map.put(map6.get("month"), totalFee6);
+        list1.add(map6.get("month"));
+        list2.add(totalFee6);
+
+        Map<String, String> map5 = CalendarUtils(-4);
+        Long totalFee5 = homePageDao.findTotalFee(map5.get("endTime"), map5.get("startTime"));
+        list1.add(map5.get("month"));
+        list2.add(totalFee5);
+
+        Map<String, String> map4 = CalendarUtils(-3);
+        Long totalFee4 = homePageDao.findTotalFee(map4.get("endTime"), map4.get("startTime"));
+        list1.add(map4.get("month"));
+        list2.add(totalFee4);
+
+        Map<String, String> map3 = CalendarUtils(-2);
+        Long totalFee3 = homePageDao.findTotalFee(map3.get("endTime"), map3.get("startTime"));
+        list1.add(map3.get("month"));
+        list2.add(totalFee3);
+
+        Map<String, String> map2 = CalendarUtils(-1);
+        Long totalFee2 = homePageDao.findTotalFee(map2.get("endTime"), map2.get("startTime"));
+        list1.add(map2.get("month"));
+        list2.add(totalFee2);
+
+        Map<String, String> map1 = CalendarUtils(0);
+        Long totalFee1 = homePageDao.findTotalFee(map1.get("endTime"), map1.get("startTime"));
+        list1.add(map1.get("month"));
+        list2.add(totalFee1);
+
+        map.put("month", list1);
+        map.put("payTotalFee", list2);
         return map;
     }
 
+    @Override
+    public List<NewOrderProduct> commodity(String endTime, String startTime) {
+        return homePageDao.commodity(endTime, startTime);
+    }
+
     public Map<String, String> CalendarUtils(Integer money) {
         Map<String, String> map = new HashMap();
         //2、获取本月第一天凌晨开始时间00:00:00和最后一天的最后一刻时间23:59:59
@@ -95,12 +115,10 @@ public class HomePageServiceImpl implements HomePageService {
         cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONDAY), actualMinimum, 00, 00, 00);
         //打印本月起始日的年月日时分秒格式
         map.put("startTime", sdf.format(cal.getTime()));
-        System.out.println("这个月的第一天是: " + sdf.format(cal.getTime()));
         //设置本月结束日的年月日时分秒格式
         cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONDAY), actualMaximum, 23, 59, 59);
         //打印本月结束日的年月日时分秒格式
         map.put("endTime", sdf.format(cal.getTime()));
-        System.out.println("这个月的最后一天是: " + sdf.format(cal.getTime()));
         return map;
     }
 }

+ 26 - 0
src/main/resources/mapper/HomePageMapper.xml

@@ -75,4 +75,30 @@
             AND receiptStatus = #{receiptStatus}
         </if>
     </select>
+
+    <select id="commodity" resultType="com.caimei.modules.order.entity.NewOrderProduct">
+        SELECT
+          cop.*,
+          COUNT(*) AS frequency,
+          SUM(cop.num) AS totalNum
+        FROM
+          cm_order_product cop
+          LEFT JOIN cm_order co ON co.orderID = cop.orderID
+        WHERE
+          co.status NOT IN (0, 6, 7)
+          AND co.organizeID = 1
+          AND co.delFlag = '0'
+        <if test="startTime != null and startTime != ''">
+            AND co.orderTime <![CDATA[ >= ]]> #{startTime}
+        </if>
+        <if test="endTime != null and endTime != ''">
+            AND co.orderTime <![CDATA[ <= ]]> #{endTime}
+        </if>
+        GROUP BY
+          cop.productID
+        ORDER BY
+          frequency DESC
+        LIMIT
+          10
+    </select>
 </mapper>