Browse Source

首页数据

PLF 5 years ago
parent
commit
89bb5e8ee2

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

@@ -10,12 +10,10 @@ import com.caimei.utils.TokenEncryptUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.ModelAttribute;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -45,11 +43,10 @@ public class CmOrderRemarkController {
     //订单备注
     @ResponseBody
     @RequestMapping(value = "remarksView")
-    public JsonModel remarksView(Integer orderID, Integer shopOrderID) {
+    public JsonModel remarksView(Integer orderID) {
         //通过商品ID获取对应备注信息
         CmOrderRemark remark = new CmOrderRemark();
         remark.setOrderID(orderID);
-        remark.setShopOrderID(shopOrderID);
         List<CmOrderRemark> remarksList = cmOrderRemarkService.findList(remark);
         return JsonModel.newInstance().success(remarksList);
     }
@@ -60,12 +57,11 @@ public class CmOrderRemarkController {
      *
      * @param remarks
      * @param orderID
-     * @param shopOrderID
      * @return
      */
     @ResponseBody
-    @RequestMapping(value = "addRemarks")
-    public JsonModel addRemarks(String remarks, Integer orderID, Integer shopOrderID, HttpServletRequest httpRequest) {
+    @RequestMapping(value = "addRemarks",method = RequestMethod.POST)
+    public JsonModel addRemarks(String remarks, Integer orderID, HttpServletRequest httpRequest) {
         JsonModel jsonModel = JsonModel.newInstance();
         String token = httpRequest.getHeader("token");
         String decoded = TokenEncryptUtils.decoded(token);
@@ -76,9 +72,9 @@ public class CmOrderRemarkController {
             //保存备注信息
             CmOrderRemark remark = new CmOrderRemark();
             remark.setOrderID(orderID);
-            remark.setShopOrderID(shopOrderID);
             remark.setRemarks(remarks);
             remark.setCreateBy(user.getId());
+            remark.setCreateDate(new Date());
             cmOrderRemarkService.save(remark);
             return jsonModel.success();
         } catch (Exception e) {

+ 55 - 81
src/main/java/com/caimei/modules/order/entity/CmReturnedPurchase.java

@@ -1,6 +1,6 @@
 package com.caimei.modules.order.entity;
 
-import org.hibernate.validator.constraints.Length;
+import org.springframework.format.annotation.DateTimeFormat;
 
 import java.io.Serializable;
 import java.util.Date;
@@ -46,7 +46,9 @@ public class CmReturnedPurchase implements Serializable {
     private String returnTime;        // 申请退款时间
     private String confirmReturnTime;        // 确认退款时间(审核退款时间)
 
+    @DateTimeFormat
     private Date beginReturnTime;
+    @DateTimeFormat
     private Date endReturnTime;
 
     private Date beginConfirmReturnTime;
@@ -69,12 +71,8 @@ public class CmReturnedPurchase implements Serializable {
     private String applicationUserName;//申请人
     private String reviewUserName;//审核人
 
-    public Integer getOrganizeID() {
-        return organizeID;
-    }
-
-    public void setOrganizeID(Integer organizeID) {
-        this.organizeID = organizeID;
+    public static long getSerialVersionUID() {
+        return serialVersionUID;
     }
 
     public Integer getId() {
@@ -85,7 +83,6 @@ public class CmReturnedPurchase implements Serializable {
         this.id = id;
     }
 
-    @Length(min = 0, max = 30, message = "退款退货编号长度必须介于 0 和 30 之间")
     public String getReturnedNo() {
         return returnedNo;
     }
@@ -102,14 +99,29 @@ public class CmReturnedPurchase implements Serializable {
         this.orderID = orderID;
     }
 
-//	@Length(min=0, max=11, message="子订单Id长度必须介于 0 和 11 之间")
-//	public Integer getShopOrderID() {
-//		return shopOrderID;
-//	}
-//
-//	public void setShopOrderID(Integer shopOrderID) {
-//		this.shopOrderID = shopOrderID;
-//	}
+    public Integer getOrganizeID() {
+        return organizeID;
+    }
+
+    public void setOrganizeID(Integer organizeID) {
+        this.organizeID = organizeID;
+    }
+
+    public String getOrderNo() {
+        return orderNo;
+    }
+
+    public void setOrderNo(String orderNo) {
+        this.orderNo = orderNo;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
 
     public Integer getUserID() {
         return userID;
@@ -119,7 +131,6 @@ public class CmReturnedPurchase implements Serializable {
         this.userID = userID;
     }
 
-    @Length(min = 0, max = 2, message = "状态:1退货退款中、2已完成、3已取消长度必须介于 0 和 2 之间")
     public String getStatus() {
         return status;
     }
@@ -128,7 +139,6 @@ public class CmReturnedPurchase implements Serializable {
         this.status = status;
     }
 
-    @Length(min = 0, max = 11, message = "退款方式 1账户余额、2线下转账、3线上退回长度必须介于 0 和 11 之间")
     public String getReturnedWay() {
         return returnedWay;
     }
@@ -137,7 +147,14 @@ public class CmReturnedPurchase implements Serializable {
         this.returnedWay = returnedWay;
     }
 
-    @Length(min = 0, max = 300, message = "退款银行信息(银行名称、户名、开户行、银行账号)长度必须介于 0 和 300 之间")
+    public String getPayType() {
+        return payType;
+    }
+
+    public void setPayType(String payType) {
+        this.payType = payType;
+    }
+
     public String getReturnedBankInfo() {
         return returnedBankInfo;
     }
@@ -146,6 +163,13 @@ public class CmReturnedPurchase implements Serializable {
         this.returnedBankInfo = returnedBankInfo;
     }
 
+    public String getOperatingOrderStatus() {
+        return operatingOrderStatus;
+    }
+
+    public void setOperatingOrderStatus(String operatingOrderStatus) {
+        this.operatingOrderStatus = operatingOrderStatus;
+    }
 
     public Double getReturnedPurchaseFee() {
         return returnedPurchaseFee;
@@ -203,40 +227,6 @@ public class CmReturnedPurchase implements Serializable {
         this.image5 = image5;
     }
 
-    @Length(min = 0, max = 19, message = "申请退款时间长度必须介于 0 和 19 之间")
-    public String getReturnTime() {
-        return returnTime;
-    }
-
-    public void setReturnTime(String returnTime) {
-        this.returnTime = returnTime;
-    }
-
-    @Length(min = 0, max = 19, message = "确认退款时间长度必须介于 0 和 19 之间")
-    public String getConfirmReturnTime() {
-        return confirmReturnTime;
-    }
-
-    public void setConfirmReturnTime(String confirmReturnTime) {
-        this.confirmReturnTime = confirmReturnTime;
-    }
-
-    /*public List<List<CmReturnedPurchaseProduct>> getCmReturnedPurchaseProductList() {
-        return cmReturnedPurchaseProductList;
-    }
-
-    public void setCmReturnedPurchaseProductList(List<List<CmReturnedPurchaseProduct>> cmReturnedPurchaseProductList) {
-        this.cmReturnedPurchaseProductList = cmReturnedPurchaseProductList;
-    }*/
-
-    public List<ShopOrderReturned> getShopOrderReturnedList() {
-        return shopOrderReturnedList;
-    }
-
-    public void setShopOrderReturnedList(List<ShopOrderReturned> shopOrderReturnedList) {
-        this.shopOrderReturnedList = shopOrderReturnedList;
-    }
-
     public String getReviewImage1() {
         return reviewImage1;
     }
@@ -285,20 +275,20 @@ public class CmReturnedPurchase implements Serializable {
         this.reviewRemarks = reviewRemarks;
     }
 
-    public String getOrderNo() {
-        return orderNo;
+    public String getReturnTime() {
+        return returnTime;
     }
 
-    public void setOrderNo(String orderNo) {
-        this.orderNo = orderNo;
+    public void setReturnTime(String returnTime) {
+        this.returnTime = returnTime;
     }
 
-    public String getUserName() {
-        return userName;
+    public String getConfirmReturnTime() {
+        return confirmReturnTime;
     }
 
-    public void setUserName(String userName) {
-        this.userName = userName;
+    public void setConfirmReturnTime(String confirmReturnTime) {
+        this.confirmReturnTime = confirmReturnTime;
     }
 
     public Date getBeginReturnTime() {
@@ -333,20 +323,12 @@ public class CmReturnedPurchase implements Serializable {
         this.endConfirmReturnTime = endConfirmReturnTime;
     }
 
-    /*public List<CmReturnedPurchaseProduct> getProductList() {
-        return productList;
-    }
-
-    public void setProductList(List<CmReturnedPurchaseProduct> productList) {
-        this.productList = productList;
-    }*/
-
-    public String getOperatingOrderStatus() {
-        return operatingOrderStatus;
+    public List<ShopOrderReturned> getShopOrderReturnedList() {
+        return shopOrderReturnedList;
     }
 
-    public void setOperatingOrderStatus(String operatingOrderStatus) {
-        this.operatingOrderStatus = operatingOrderStatus;
+    public void setShopOrderReturnedList(List<ShopOrderReturned> shopOrderReturnedList) {
+        this.shopOrderReturnedList = shopOrderReturnedList;
     }
 
     public String getBankAccountName() {
@@ -436,12 +418,4 @@ public class CmReturnedPurchase implements Serializable {
     public void setReviewUserName(String reviewUserName) {
         this.reviewUserName = reviewUserName;
     }
-
-    public String getPayType() {
-        return payType;
-    }
-
-    public void setPayType(String payType) {
-        this.payType = payType;
-    }
 }

+ 17 - 0
src/main/java/com/caimei/modules/shiro/controller/HomePageController.java

@@ -31,4 +31,21 @@ public class HomePageController {
         Map<String, Object> map = homePageService.orderQuantity(endTime, startTime);
         return JsonModel.newInstance().success(map);
     }
+
+    /**
+     * 销售额趋势数据
+     */
+    @RequestMapping("sale")
+    public JsonModel sale() {
+        Map<String, Object> map = homePageService.sale();
+        return JsonModel.newInstance().success(map);
+    }
+
+    /**
+     * 热销商品统计
+     */
+    @RequestMapping("commodity")
+    public JsonModel commodity(String endTime, String startTime) {
+        return null;
+    }
 }

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

@@ -6,4 +6,6 @@ public interface HomePageService {
     Map<String, Object> receivableAmount(String endTime, String startTime);
 
     Map<String, Object> orderQuantity(String endTime, String startTime);
+
+    Map<String, Object> sale();
 }

+ 61 - 10
src/main/java/com/caimei/modules/shiro/service/impl/HomePageServiceImpl.java

@@ -6,6 +6,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 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;
 
@@ -24,14 +26,11 @@ public class HomePageServiceImpl implements HomePageService {
         //已收总金额
         Long associateAmount = homePageDao.findAssociate(endTime, startTime);
         Long amountReceived = balancePayFee + associateAmount;
-        DecimalFormat df = new DecimalFormat("0%");
-        String percentage = "0%";
-        if (amountReceived != 0 && payTotalFee != 0) {
-            percentage = df.format(amountReceived * 1.0 / payTotalFee);
-        }
+        //未收金额
+        long uncollected = payTotalFee - amountReceived;
         map.put("payTotalFee", payTotalFee);
         map.put("amountReceived", amountReceived);
-        map.put("percentage", percentage);
+        map.put("uncollected", uncollected);
         return map;
     }
 
@@ -43,13 +42,65 @@ public class HomePageServiceImpl implements HomePageService {
         Integer count = homePageDao.orderQuantity(endTime, startTime, "");
         //已收款数量
         Integer received = homePageDao.orderQuantity(endTime, startTime, "3");
-        String receivedPercentage = df.format(received * 1.0 / count);
         //部分收款数量
         Integer portion = homePageDao.orderQuantity(endTime, startTime, "2");
-        String portionPercentage = df.format(portion * 1.0 / count);
+        //未收数量
+        Integer uncollected = homePageDao.orderQuantity(endTime, startTime, "1");
         map.put("count", count);
-        map.put("receivedPercentage", receivedPercentage);
-        map.put("portionPercentage", portionPercentage);
+        map.put("received", received);
+        map.put("portion", portion);
+        map.put("uncollected", uncollected);
+        return map;
+    }
+
+    @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);
+        Map<String, String> map6 = CalendarUtils(-5);
+        Long totalFee6 = homePageDao.findTotalFee(map6.get("endTime"), map6.get("startTime"));
+        map.put(map6.get("month"), totalFee6);
+        return map;
+    }
+
+    public Map<String, String> CalendarUtils(Integer money) {
+        Map<String, String> map = new HashMap();
+        //2、获取本月第一天凌晨开始时间00:00:00和最后一天的最后一刻时间23:59:59
+        Calendar cal = Calendar.getInstance();
+        //当前日期月份
+        cal.add(Calendar.MONTH, money);
+        //设置时间格式为yyyy-MM-dd HH:mm:ss
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        int month = cal.get(Calendar.MONTH) + 1;
+        map.put("month", "" + month);
+        //获取到本月起始日
+        int actualMinimum = cal.getActualMinimum(Calendar.DAY_OF_MONTH);
+        //获取到本月结束日
+        int actualMaximum = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
+        //设置本月起始日的年月日时分秒格式
+        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;
     }
 }