Skip to content

Commit 2ebf8cf

Browse files
committed
销售额分析,部分页面样式
1 parent 9bc9802 commit 2ebf8cf

File tree

12 files changed

+303
-55
lines changed

12 files changed

+303
-55
lines changed

src/main/java/com/changyu/foryou/controller/FoodController.java

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,4 +1300,45 @@ public String uploadDetailImageByFoodId(@RequestParam MultipartFile[] detailImag
13001300
responseMap.put("hotFive", hotFive);*/
13011301
return responseMap;
13021302
}
1303+
1304+
@RequestMapping("addFoodCountById")
1305+
@ResponseBody
1306+
public Map<String, Object> addFoodCountById(@RequestParam Integer campusId, @RequestParam Integer foodId, @RequestParam Integer addCount){
1307+
Map<String,Object> requestMap = new HashMap<String, Object>();
1308+
Map<String,Object> responseMap = new HashMap<String, Object>();
1309+
1310+
requestMap.put("campusId", campusId);
1311+
requestMap.put("foodId", foodId);
1312+
Food thisFood = foodService.selectFoodByPrimaryKey(requestMap);
1313+
requestMap.put("foodCount", thisFood.getFoodCount()+addCount);
1314+
Integer result = foodService.addFoodCountById(requestMap);
1315+
if(result!=0&&result!=-1){
1316+
responseMap.put(Constants.STATUS, Constants.SUCCESS);
1317+
responseMap.put(Constants.MESSAGE, "添加库存成功");
1318+
}else{
1319+
responseMap.put(Constants.STATUS, Constants.FAILURE);
1320+
responseMap.put(Constants.MESSAGE, "添加库存失败");
1321+
}
1322+
return responseMap;
1323+
}
1324+
1325+
@RequestMapping("addFoodCount")
1326+
@ResponseBody
1327+
public Map<String, Object> addFoodCount(@RequestParam Integer campusId, @RequestParam Integer addCount){
1328+
Map<String,Object> requestMap = new HashMap<String, Object>();
1329+
Map<String,Object> responseMap = new HashMap<String, Object>();
1330+
1331+
requestMap.put("campusId", campusId);
1332+
requestMap.put("addCount", addCount);
1333+
//System.out.println(resultMap);
1334+
Integer result = foodService.addFoodCount(requestMap);
1335+
if(result!=0&&result!=-1){
1336+
responseMap.put(Constants.STATUS, Constants.SUCCESS);
1337+
responseMap.put(Constants.MESSAGE, "添加库存成功");
1338+
}else{
1339+
responseMap.put(Constants.STATUS, Constants.FAILURE);
1340+
responseMap.put(Constants.MESSAGE, "添加库存失败");
1341+
}
1342+
return responseMap;
1343+
}
13031344
}

src/main/java/com/changyu/foryou/controller/OrderController.java

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.changyu.foryou.controller;
22

33
import java.text.DecimalFormat;
4+
import java.text.ParseException;
5+
import java.text.SimpleDateFormat;
46
import java.util.ArrayList;
57
import java.util.Calendar;
68
import java.util.Date;
@@ -186,10 +188,11 @@ public void setOrderService(OrderService orderService) {
186188
paramMap.put("limit", limit);
187189
paramMap.put("offset", (page - 1) * limit);
188190
}
191+
paramMap.put("status", status);
189192
List<String> togetherIds = orderService.getTogetherId(paramMap);
190193

191-
System.out.println(JSON.toJSONString(togetherIds));
192-
194+
//System.out.println(JSON.toJSONString(togetherIds));
195+
193196
if (togetherIds.size() != 0) {
194197

195198
for (String togetherId : togetherIds) {
@@ -1510,16 +1513,35 @@ public String getIpAddr(HttpServletRequest request){
15101513
*/
15111514
@RequestMapping("getSalesInfoByCampusId")
15121515
@ResponseBody
1513-
public JSONArray getSalesByDate(Integer campusId){
1516+
public JSONArray getSalesByDate(@RequestParam Integer campusId, String month){
15141517
Map<String,Object> paramMap=new HashMap<String,Object>();
15151518

15161519
Date dateStart;
15171520
Date dateEnd;
15181521
List<TradeInfo> tradeList = new ArrayList<TradeInfo>();
15191522

15201523
paramMap.put("campusId", campusId);
1524+
//System.out.println("month="+month);
1525+
//如果month不为空,说明切换了月份;但是注意month为本月的时候,此时是下面的情况
1526+
if(month!=null&&!month.equals(null)&&!month.equals("")&&!CalendarTool.checkIsThisMonth(month)){
1527+
Map<String,Date> dateMap = CalendarTool.getFirstAndLastDayOfMonth(month);
1528+
dateStart = dateMap.get("monthStart");
1529+
dateEnd = dateMap.get("monthEnd");
1530+
paramMap.put("dateStart", dateStart);
1531+
paramMap.put("dateEnd", dateEnd);
1532+
TradeInfo monthInfo = new TradeInfo();
1533+
monthInfo.setInfoDateType("当月");
1534+
monthInfo.setOrderCount(orderService.getSalesInfoByCampusId(paramMap));//获取指定时间段和指定校区的订单总数
1535+
monthInfo.setTradeVolume(orderService.getTradeVolumeByCampusId(paramMap));//获取指定时间段和指定校区的订单交易额
1536+
paramMap.put("payWay", 1); //payWay:0,没有; 1,支付宝; 2,微信
1537+
monthInfo.setTradeVolumeAliPay(orderService.getTradeVolumeByCampusId(paramMap));//获取指定时间段、指定校区和指定支付方式的订单交易额
1538+
paramMap.put("payWay", 2);
1539+
monthInfo.setTradeVolumeWeChatPay(orderService.getTradeVolumeByCampusId(paramMap));//获取指定时间段、指定校区、指定支付方式的订单交易额
1540+
tradeList.add(monthInfo);
1541+
return (JSONArray)JSON.toJSON(tradeList);
1542+
}
15211543

1522-
//当天订单数、销售额
1544+
//当天订单数、销售额-
15231545
dateStart = CalendarTool.getTodayStart();
15241546
dateEnd = CalendarTool.getTodayEnd();
15251547
paramMap.put("dateStart", dateStart);

src/main/java/com/changyu/foryou/mapper/FoodMapper.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,8 @@ public interface FoodMapper {
4848
Integer cancelRecommend(Map<String, Object> paramMap);//取消推荐
4949

5050
List<FoodWithSales> getTopFive(Map<String, Object> paramMap);
51+
52+
Integer addFoodCountById(Map<String, Object> paramMap);//添加库存
53+
54+
Integer addFoodCount(Map<String, Object> paramMap);
5155
}

src/main/java/com/changyu/foryou/mapping/FoodMapper.xml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
status,
5959
food_flag, tag, is_discount,
6060
category_id,
61-
prime_cost, sale_number,food_count,food.message as message,to_home,home_image
61+
prime_cost, sale_number,food_count,food.message as message,to_home,home_image,is_full_discount
6262
</sql>
6363

6464
<sql id="Small_Column_List">
@@ -521,5 +521,20 @@
521521
limit #{offset,jdbcType=INTEGER},#{limit,jdbcType=INTEGER}
522522
</if>
523523
</select>
524+
525+
<update id="addFoodCountById">
526+
update food set food_count=#{foodCount,jdbcType=INTEGER} where campus_id=#{campusId,jdbcType=INTEGER} and food_id=#{foodId,jdbcType=BIGINT}
527+
</update>
528+
529+
<update id="addFoodCount">
530+
UPDATE food
531+
SET food_count = food_count + #{addCount,jdbcType=INTEGER}
532+
<where>
533+
campus_id=#{campusId,jdbcType=INTEGER}
534+
<if test="foodId!=null">
535+
and fodd_id=#{foodId,jdbcType=BIGINT}
536+
</if>
537+
</where>
538+
</update>
524539
</mapper>
525540

src/main/java/com/changyu/foryou/mapping/OrderMapper.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@
503503
and status=4
504504
</if>
505505
<if test="status==null">
506-
and status !=0
506+
and status !=0 and status!=9 and status!=10 and status!=11
507507
</if>
508508
</where>
509509
group by together_id

src/main/java/com/changyu/foryou/service/FoodService.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,8 @@ public interface FoodService {
106106
public Integer addCategoryWhenAddCampus(Map<String, Object> paramMap);
107107

108108
List<FoodWithSales> getTopFive(Map<String, Object> paramMap);
109+
110+
Integer addFoodCountById(Map<String, Object> paramMap);//添加库存
111+
112+
Integer addFoodCount(Map<String, Object> paramMap);//添加库存
109113
}

src/main/java/com/changyu/foryou/serviceImpl/FoodServiceImpl.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,18 @@ public List<FoodWithSales> getTopFive(Map<String, Object> paramMap) {
279279
// TODO Auto-generated method stub
280280
return foodMapper.getTopFive(paramMap);
281281
}
282+
283+
@Override
284+
public Integer addFoodCountById(Map<String, Object> paramMap) {
285+
// TODO Auto-generated method stub
286+
return foodMapper.addFoodCountById(paramMap);
287+
}
288+
289+
@Override
290+
public Integer addFoodCount(Map<String, Object> paramMap) {
291+
// TODO Auto-generated method stub
292+
return foodMapper.addFoodCount(paramMap);
293+
}
282294

283295
}
284296

src/main/java/com/changyu/foryou/tools/CalendarTool.java

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package com.changyu.foryou.tools;
22

3+
import java.text.ParseException;
34
import java.text.SimpleDateFormat;
45
import java.util.Calendar;
56
import java.util.Date;
7+
import java.util.HashMap;
8+
import java.util.Map;
69

710
public class CalendarTool {
811
public static Date getMondayOfThisWeek() {
@@ -45,9 +48,53 @@ public static Date getFirstDayOfThisMonth(){
4548
return c.getTime();
4649
}
4750

51+
public static Date getFirstDayOfThisMonth(Date date){
52+
Calendar c = Calendar.getInstance();
53+
c.setTime(date);
54+
c.set(c.get(Calendar.YEAR), c.get(Calendar.MONTH), 1, 00, 00, 00);
55+
return c.getTime();
56+
}
57+
4858
public static Date getLastDayOfThisMonth(){
4959
Calendar calendar = Calendar.getInstance();
5060
calendar.set(Calendar.DATE, calendar.getMaximum(Calendar.DATE));
5161
return calendar.getTime();
5262
}
63+
64+
public static Date getLastDayOfThisMonth(Date date){
65+
Calendar c = Calendar.getInstance();
66+
c.setTime(date);
67+
c.set(Calendar.DATE, c.getMaximum(Calendar.DATE));
68+
return c.getTime();
69+
}
70+
71+
public static Map<String,Date> getFirstAndLastDayOfMonth(String month){
72+
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
73+
Date date = null;
74+
try {
75+
date = sdf.parse(month);
76+
} catch (ParseException e) {
77+
// TODO Auto-generated catch block
78+
e.printStackTrace();
79+
}
80+
Map<String,Date> map = new HashMap<String, Date>();
81+
map.put("monthStart", getFirstDayOfThisMonth(date));
82+
map.put("monthEnd", getLastDayOfThisMonth(date));
83+
return map;
84+
}
85+
86+
public static Boolean checkIsThisMonth(String monthStr){
87+
Calendar c = Calendar.getInstance();
88+
int year = c.get(Calendar.YEAR);
89+
int month = c.get(Calendar.MONTH)+1;//月份从0开始
90+
91+
int indexYear = monthStr.indexOf(String.valueOf(year));
92+
int indexMonth = monthStr.lastIndexOf(String.valueOf(month));
93+
94+
if(indexYear==-1||indexMonth==-1){
95+
//说明不是当前年月
96+
return false;
97+
}
98+
return true;
99+
}
53100
}

0 commit comments

Comments
 (0)