Skip to content

Commit 8e8b57f

Browse files
author
xiaowei
committed
update bugs
1 parent 479bc9f commit 8e8b57f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1019
-334
lines changed

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

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

3-
43
import java.text.ParseException;
54
import java.text.SimpleDateFormat;
65
import java.util.Date;
@@ -345,14 +344,20 @@ public Map<String, Object> addCity(@RequestParam String cityName){
345344

346345
paramMap.put("cityName", cityName);
347346

348-
Integer result = campusService.addCity(paramMap);
349-
if(result!=-1&&result!=0){
350-
responseMap.put(Constants.STATUS, Constants.SUCCESS);
351-
responseMap.put(Constants.MESSAGE,"添加城市成功!");
347+
if(campusService.getCityByName(cityName)==null){
348+
Integer result = campusService.addCity(paramMap);
349+
if(result!=-1&&result!=0){
350+
responseMap.put(Constants.STATUS, Constants.SUCCESS);
351+
responseMap.put(Constants.MESSAGE,"添加城市成功!");
352+
}else{
353+
responseMap.put(Constants.STATUS, Constants.FAILURE);
354+
responseMap.put(Constants.MESSAGE, "添加城市失败!");
355+
}
352356
}else{
353357
responseMap.put(Constants.STATUS, Constants.FAILURE);
354-
responseMap.put(Constants.MESSAGE, "添加城市失败!");
358+
responseMap.put(Constants.MESSAGE, "该城市已存在");
355359
}
360+
356361
return responseMap;
357362
}
358363

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

Lines changed: 51 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ public class FoodController {
5353
private OrderService orderService;
5454
private CampusService campusService;
5555

56-
5756
protected static final Logger LOG = LoggerFactory.getLogger(FoodController.class);
5857

5958
@Autowired
@@ -150,7 +149,6 @@ public void setCampusService(CampusService campusService){
150149
}
151150
}
152151
else{
153-
154152
foodTag=foodTag.replace(","," ").replace(".", " ").replace(">", " ").replace("'", " ").replace(",", " ").trim();
155153
String[] Flags=foodTag.split(" ");
156154
for (int i = 0; i < Flags.length; i++) {
@@ -396,40 +394,7 @@ public void setCampusService(CampusService campusService){
396394
return foods;
397395
}
398396

399-
/**
400-
* 获取食品 的一级分类
401-
* @return
402-
*/
403-
/*@RequestMapping("/getAllFoodFristCategorys")
404-
public @ResponseBody List<FoodCategory> getAllFoodFirstCategorys(){
405-
List<FoodCategory> foodCategories =new ArrayList<FoodCategory>();
406-
407-
try {
408-
foodCategories=foodService.getAllFoodFirstCategories();
409-
} catch (Exception e) {
410-
e.getStackTrace();
411-
}
412-
413-
return foodCategories;
414-
}*/
415-
416-
/**
417-
* 获取食品的二级分类
418-
* @return
419-
*/
420-
/*@RequestMapping("/getAllFoodSecondCategorys")
421-
public @ResponseBody List<FoodCategory> getAllFoodSecondCategorys(){
422-
List<FoodCategory> foodCategories =new ArrayList<FoodCategory>();
423-
424-
try {
425-
foodCategories=foodService.getAllFoodSecondCategories();
426-
} catch (Exception e) {
427-
e.getStackTrace();
428-
}
429-
430-
return foodCategories;
431-
}*/
432-
397+
433398
/**
434399
* 添加食品口味 弃用
435400
* @param campusId
@@ -864,7 +829,7 @@ public String updateFoods(@RequestParam MultipartFile[] myfile,HttpServletReques
864829
//Short isDefault=Short.valueOf(request.getParameter("default_special"));
865830
String realPath = request.getSession().getServletContext().getRealPath("/");
866831
realPath=realPath.replace("foryou", "ForyouImage");
867-
realPath=realPath.concat("\\food\\");
832+
realPath=realPath.concat("food/");
868833
System.out.println(realPath); //打印出服务器路径
869834

870835
List<String> imageUrl=new ArrayList<String>();
@@ -1190,8 +1155,7 @@ public String updateHomeImageByFoodId(@RequestParam MultipartFile homeImageFile,
11901155

11911156
if(homeImageFile.isEmpty()){ //不更新主页图片
11921157
System.out.println("文件未上传");
1193-
1194-
1158+
11951159
int flag = foodService.uploadHomeFoodByFoodId(paramMap);
11961160
if(flag!=0&&flag!=-1){
11971161
return "redirect:/pages/food.html";
@@ -1245,27 +1209,52 @@ public String uploadDetailImageByFoodId(@RequestParam MultipartFile[] detailImag
12451209
StringBuffer bufferInfo = new StringBuffer();
12461210

12471211
String foodId = request.getParameter("foodId");
1248-
1212+
String campusId = request.getParameter("campusId");
1213+
1214+
int i=0;
12491215
for (MultipartFile detailImageFile : detailImageFiles) {
1216+
i++;
1217+
String is_delete=request.getParameter("is_delete"+i);
1218+
if(is_delete!=null&&request.getParameter("is_delete"+i).equals("on")){
1219+
bufferInfo.append("");
1220+
break;
1221+
}
12501222
if(detailImageFile.isEmpty()){
1251-
System.out.println("文件未上传");
1223+
System.out.println("文件未上传");
1224+
bufferInfo.append(","+request.getParameter("img"+i));
12521225
}else{
12531226
String contentType = detailImageFile.getContentType();
12541227
if(contentType.startsWith("image")){
12551228
String realPath = request.getSession().getServletContext().getRealPath("/");
12561229
realPath = realPath.replace("foryou", "ForyouImage");
1257-
realPath.concat("food");
1230+
realPath=realPath.concat("food/");
1231+
//System.out.println(realPath);
12581232
String newFileName = new Date().getTime()+""+new Random().nextInt()+".jpg";
12591233
FileUtils.copyInputStreamToFile(detailImageFile.getInputStream(), new File(realPath, newFileName));
1260-
String imageUrl = Constants.localIp+"/food/info/"+newFileName;
1261-
bufferInfo.append(imageUrl);
1234+
String imageUrl = Constants.localIp+"/food/"+newFileName;
1235+
bufferInfo.append(","+imageUrl);
1236+
1237+
String oldImgUrl=request.getParameter("img"+i);
1238+
if(imageUrl!=null&&oldImgUrl!=null){
1239+
String[] temp=oldImgUrl.split("/");
1240+
String imageName=temp[(temp.length-1)];
1241+
1242+
String name2=realPath+imageName;
1243+
1244+
File file=new File(name2);
1245+
if(file.isFile()){
1246+
file.delete();//删除
1247+
}
1248+
}
12621249
}
1250+
12631251
}
12641252
}
12651253

12661254
Map<String, Object> paramMap = new HashMap<String, Object>();
12671255
paramMap.put("foodId", foodId);
12681256
paramMap.put("info", bufferInfo.toString());
1257+
paramMap.put("campusId", campusId);
12691258
int flag = foodService.updateInfoByFoodId(paramMap);
12701259
if(flag!=0&&flag!=-1){
12711260
return "redirect:/pages/food.html";
@@ -1346,6 +1335,9 @@ public String uploadDetailImageByFoodId(@RequestParam MultipartFile[] detailImag
13461335
return responseMap;
13471336
}
13481337

1338+
/*
1339+
* 添加商品库存
1340+
*/
13491341
@RequestMapping("addFoodCountById")
13501342
@ResponseBody
13511343
public Map<String, Object> addFoodCountById(@RequestParam Integer campusId, @RequestParam Integer foodId, @RequestParam Integer addCount){
@@ -1367,6 +1359,9 @@ public Map<String, Object> addFoodCountById(@RequestParam Integer campusId, @Req
13671359
return responseMap;
13681360
}
13691361

1362+
/*
1363+
* 添加库存
1364+
*/
13701365
@RequestMapping("addFoodCount")
13711366
@ResponseBody
13721367
public Map<String, Object> addFoodCount(@RequestParam Integer campusId, @RequestParam Integer addCount){
@@ -1387,6 +1382,9 @@ public Map<String, Object> addFoodCount(@RequestParam Integer campusId, @Request
13871382
return responseMap;
13881383
}
13891384

1385+
/*
1386+
* 获取商品详情
1387+
*/
13901388
@RequestMapping("/getDetailImg")
13911389
@ResponseBody
13921390
public Map<String,Object> getDetailImg(@RequestParam Integer campusId,@RequestParam Long foodId){
@@ -1399,7 +1397,15 @@ public Map<String,Object> getDetailImg(@RequestParam Integer campusId,@RequestPa
13991397

14001398
String imgs=foodService.getDetailImg(paramMap);
14011399
String[] detailImgs=imgs.split(",");
1402-
resultMap.put("imgs",detailImgs);
1400+
List<String> detailImgsWithoutNull=new ArrayList<String>();
1401+
1402+
for(String img:detailImgs){
1403+
if(!img.trim().equals("")){
1404+
detailImgsWithoutNull.add(img);
1405+
}
1406+
}
1407+
resultMap.put("imgs",detailImgsWithoutNull);
1408+
14031409
resultMap.put(Constants.STATUS,Constants.SUCCESS);
14041410
resultMap.put(Constants.MESSAGE, "获取成功");
14051411
} catch (Exception e) {

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

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,6 +1280,7 @@ public Map<String, Object> getBigOrderById(@RequestParam String togetherId) {
12801280

12811281
try {
12821282
Order order = new Order(campusId, phoneId, foodId, foodCount);
1283+
order.setStatus((short)7);
12831284
paramMap.put("orderId",order.getOrderId());
12841285
int flag = orderService.insertSelectiveOrder(order);
12851286

@@ -1405,12 +1406,27 @@ public String getIpAddr(HttpServletRequest request){
14051406
return JSONArray.parseArray(JSON.toJSONStringWithDateFormat(refundOrders, "yyyy-MM-dd"));
14061407
}
14071408

1409+
/**
1410+
* 获取退款订单
1411+
* @param campusId
1412+
* @return
1413+
*/
1414+
@RequestMapping("/getInvalideOrder")
1415+
public @ResponseBody JSONArray getInvalidOrder(Integer campusId){
1416+
Map<String,Object> paramMap=new HashMap<String,Object>();
1417+
1418+
paramMap.put("campusId",campusId);
1419+
1420+
List<SuperAdminOrder> refundOrders=orderService.getPCInvalidOrders(paramMap); //PC获取无效订单
1421+
return JSONArray.parseArray(JSON.toJSONStringWithDateFormat(refundOrders, "yyyy-MM-dd"));
1422+
}
1423+
14081424
/**
14091425
* 取消退款
14101426
* @return
14111427
*/
14121428
@RequestMapping("/cancelRefund")
1413-
public @ResponseBody Map<String,Object> cancelRefund(String togetherId){
1429+
public @ResponseBody Map<String,Object> cancelRefund(@RequestParam String togetherId){
14141430
Map<String,Object> resultMap=new HashMap<>();
14151431

14161432
try {
@@ -1443,7 +1459,7 @@ public String getIpAddr(HttpServletRequest request){
14431459
* @return
14441460
*/
14451461
@RequestMapping("/refund")
1446-
public @ResponseBody Map<String,Object> refund(String togetherId,Float totalPrice){
1462+
public @ResponseBody Map<String,Object> refund(@RequestParam String togetherId,Float totalPrice){
14471463
Map<String,Object> resultMap=new HashMap<>();
14481464

14491465
try {
@@ -1595,4 +1611,28 @@ public JSONArray getSalesByDate(@RequestParam Integer campusId, String month){
15951611
return (JSONArray)JSON.toJSON(tradeList);
15961612
}
15971613

1614+
@RequestMapping("/deleteOrderTrue")
1615+
@ResponseBody
1616+
public Map<String,Object> deleteOrderTrue(@RequestParam String togetherId){
1617+
Map<String,Object> resultMap=new HashMap<String,Object>();
1618+
try {
1619+
Map<String,Object> paramMap=new HashMap<String,Object>();
1620+
paramMap.put("togetherId",togetherId);
1621+
int flag=orderService.deleteOrderTrue(paramMap);
1622+
if(flag!=-1){
1623+
resultMap.put(Constants.STATUS,Constants.SUCCESS);
1624+
resultMap.put(Constants.MESSAGE,"删除成功");
1625+
}else{
1626+
resultMap.put(Constants.STATUS,Constants.FAILURE);
1627+
resultMap.put(Constants.MESSAGE, "删除失败");
1628+
}
1629+
} catch (Exception e) {
1630+
e.getStackTrace();
1631+
resultMap.put(Constants.STATUS,Constants.FAILURE);
1632+
resultMap.put(Constants.MESSAGE, "删除失败");
1633+
}
1634+
1635+
return resultMap;
1636+
}
1637+
15981638
}

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import org.springframework.stereotype.Controller;
1616
import org.springframework.web.bind.annotation.RequestMapping;
1717

18+
import com.changyu.foryou.model.Order;
19+
import com.changyu.foryou.service.FoodService;
1820
import com.changyu.foryou.service.OrderService;
1921
import com.changyu.foryou.service.PayService;
2022
import com.changyu.foryou.service.PushService;
@@ -35,6 +37,7 @@ public class PayController {
3537
private OrderService orderService;
3638
private UserService userService;
3739
private PushService pushService;
40+
private FoodService foodService;
3841

3942
private static final Logger LOGGER = Logger
4043
.getLogger(PayController.class);
@@ -47,6 +50,10 @@ public void setPushService(PushService pushService) {
4750
this.pushService = pushService;
4851
}
4952

53+
@Autowired
54+
public void setFoodService(FoodService foodService) {
55+
this.foodService = foodService;
56+
}
5057

5158
public PayService getPayService() {
5259
return payService;
@@ -166,6 +173,14 @@ public int doPaySuccess(String buffer){
166173
System.out.println(paramMap);
167174
int flag=orderService.updateOrderStatusAndAmount(paramMap); //支付完成后更新订单状态以及更新价格 ,以及chargeId
168175

176+
List<Order> orders = orderService.getAllOrdersByTogetherId(charge.getOrderNo()); // 获取该笔订单的消息
177+
for(Order order:orders){
178+
paramMap.put("foodId", order.getFoodId());
179+
paramMap.put("orderCount", order.getOrderCount());
180+
paramMap.put("campusId",order.getCampusId());
181+
foodService.changeFoodCount(paramMap); // 增加销量,减少存货
182+
}
183+
169184
final Integer campusId=orderService.getCampusIdByTogetherId(paramMap);
170185
// 开启线程去访问极光推送
171186

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ Map<String, Object> toLogin(@RequestParam String phone,@RequestParam String pass
154154
session.setAttribute("type", users.getType());
155155
session.setAttribute("phone", users.getPhone());
156156
Date date=new Date();
157-
userService.updateLastLoginTime(date,phone);
157+
userService.updateLastLoginTime(date,phone);
158+
orderService.deleteStatus7Order(phone);
158159
} else {
159160
map.put(Constants.STATUS, Constants.FAILURE);
160161
map.put(Constants.MESSAGE, "账号或密码错误,请检查后输入");
@@ -407,14 +408,13 @@ Map<String, Object> resetPassword(@RequestParam String phone,
407408
String phone=request.getParameter("phoneId");
408409

409410
Map<String, Object> map = new HashMap<String, Object>();
410-
image=image.replaceAll(" ", "+");
411+
//image=image.replaceAll(" ", "+");
411412

412413
String realPath = request.getSession().getServletContext().getRealPath("/");
413414
realPath=realPath.replace("foryou", "ForyouImage");
414-
realPath=realPath.concat("/users/");
415+
realPath=realPath.concat("users/");
415416
String fileNameString=new Random().nextLong()+""+new Date().getTime()+".jpg";
416417

417-
418418
if (image == null) {
419419
map.put(Constants.STATUS, Constants.FAILURE);
420420
map.put(Constants.MESSAGE, "没有文件");
@@ -423,8 +423,6 @@ Map<String, Object> resetPassword(@RequestParam String phone,
423423
@SuppressWarnings("restriction")
424424
BASE64Decoder decoder = new BASE64Decoder();
425425
try {
426-
427-
428426
//Base64解码
429427
@SuppressWarnings("restriction")
430428
byte[] b = decoder.decodeBuffer(image);
@@ -483,7 +481,7 @@ Map<String, Object> resetPassword(@RequestParam String phone,
483481

484482
String realPath = request.getSession().getServletContext().getRealPath("/");
485483
realPath=realPath.replace("foryou", "ForyouImage");
486-
realPath=realPath.concat("/android/");
484+
realPath=realPath.concat("android/");
487485
String fileNameString=new Random().nextInt(100)+""+new Date().getTime()+"log.log";
488486

489487
if (log == null) {

0 commit comments

Comments
 (0)