|
|
@@ -11,12 +11,12 @@ import cn.enilu.flash.bean.vo.front.Rets;
|
|
|
import cn.enilu.flash.dao.MongoRepository;
|
|
|
import cn.enilu.flash.service.front.IdsService;
|
|
|
import cn.enilu.flash.service.front.PositionService;
|
|
|
+import cn.enilu.flash.utils.BeanUtil;
|
|
|
import cn.enilu.flash.utils.Maps;
|
|
|
import cn.enilu.flash.utils.factory.Page;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import org.nutz.json.Json;
|
|
|
import org.nutz.lang.Strings;
|
|
|
-import org.nutz.mapl.Mapl;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.geo.GeoResult;
|
|
|
import org.springframework.data.geo.GeoResults;
|
|
|
@@ -40,46 +40,48 @@ public class ShopController extends BaseController {
|
|
|
private IdsService idsService;
|
|
|
@Autowired
|
|
|
private PositionService positionService;
|
|
|
- @RequestMapping(value = "/restaurant/{id}",method = RequestMethod.GET)
|
|
|
|
|
|
- public Object getShop(@PathVariable("id")Long id) {
|
|
|
- Object data = mongoRepository.findOne(id,"shops");
|
|
|
- return Rets.success(data) ;
|
|
|
+ @RequestMapping(value = "/restaurant/{id}", method = RequestMethod.GET)
|
|
|
+
|
|
|
+ public Object getShop(@PathVariable("id") Long id) {
|
|
|
+ Object data = mongoRepository.findOne(id, "shops");
|
|
|
+ return Rets.success(data);
|
|
|
}
|
|
|
|
|
|
- @RequestMapping(value = "restaurants",method = RequestMethod.GET)
|
|
|
- public Object listShop(@RequestParam(value = "latitude",required = false) String latitude,
|
|
|
- @RequestParam(value = "longitude",required = false) String longitude) {
|
|
|
+ @RequestMapping(value = "restaurants", method = RequestMethod.GET)
|
|
|
+ public Object listShop(@RequestParam(value = "latitude", required = false) String latitude,
|
|
|
+ @RequestParam(value = "longitude", required = false) String longitude) {
|
|
|
if (com.google.common.base.Strings.isNullOrEmpty(latitude) || "undefined".equals(latitude)
|
|
|
|| com.google.common.base.Strings.isNullOrEmpty(longitude) || "undefined".equals(longitude)) {
|
|
|
Page<Shop> page = new PageFactory<Shop>().defaultPage();
|
|
|
- return Rets.success(mongoRepository.queryPage(page,Shop.class));
|
|
|
+ return Rets.success(mongoRepository.queryPage(page, Shop.class));
|
|
|
} else {
|
|
|
//查询指定经纬度范围内的餐厅
|
|
|
- GeoResults<Map> geoResults = mongoRepository.near(Double.valueOf(longitude),Double.valueOf(latitude),"shops");
|
|
|
- List<GeoResult<Map>> geoResultList = geoResults.getContent();
|
|
|
+ GeoResults<Map> geoResults = mongoRepository.near(Double.valueOf(longitude), Double.valueOf(latitude), "shops");
|
|
|
+ List<GeoResult<Map>> geoResultList = geoResults.getContent();
|
|
|
List list = Lists.newArrayList();
|
|
|
- for(int i=0;i<geoResultList.size();i++){
|
|
|
+ for (int i = 0; i < geoResultList.size(); i++) {
|
|
|
list.add(geoResultList.get(i).getContent());
|
|
|
}
|
|
|
return Rets.success(list);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @RequestMapping(value = "/restaurants/count",method = RequestMethod.GET)
|
|
|
+ @RequestMapping(value = "/restaurants/count", method = RequestMethod.GET)
|
|
|
|
|
|
public Object countShop() {
|
|
|
long count = mongoRepository.count(Shop.class);
|
|
|
return Rets.success("count", count);
|
|
|
}
|
|
|
- @RequestMapping(value = "/restaurants/{id}",method = RequestMethod.DELETE)
|
|
|
|
|
|
- public Object deleteShop(@PathVariable("id")Long id) {
|
|
|
- mongoRepository.delete(id,"shops");
|
|
|
+ @RequestMapping(value = "/restaurants/{id}", method = RequestMethod.DELETE)
|
|
|
+
|
|
|
+ public Object deleteShop(@PathVariable("id") Long id) {
|
|
|
+ mongoRepository.delete(id, "shops");
|
|
|
return Rets.success();
|
|
|
}
|
|
|
|
|
|
- @RequestMapping(value = "/updateshop",method = RequestMethod.POST)
|
|
|
+ @RequestMapping(value = "/updateshop", method = RequestMethod.POST)
|
|
|
|
|
|
public Object updateShop(@ModelAttribute @Valid Shop shop) {
|
|
|
// Map data = getRequestPayload( Map.class);
|
|
|
@@ -93,45 +95,68 @@ public class ShopController extends BaseController {
|
|
|
updateMap.put("recent_order_num", shop.getRecent_order_num());
|
|
|
updateMap.put("image_path", shop.getImage_path());
|
|
|
|
|
|
- mongoRepository.update( shop.getId(), "shops", updateMap);
|
|
|
+ mongoRepository.update(shop.getId(), "shops", updateMap);
|
|
|
return Rets.success();
|
|
|
}
|
|
|
|
|
|
- @RequestMapping(value = "/addShop",method = RequestMethod.POST)
|
|
|
-
|
|
|
+ @RequestMapping(value = "/addShop", method = RequestMethod.POST)
|
|
|
public Object addShop(@ModelAttribute @Valid ShopVo shopVo) {
|
|
|
- System.out.println(Json.toJson(shopVo));
|
|
|
- Map data = (Map) Mapl.toMaplist(shopVo);
|
|
|
+
|
|
|
Shop shop = new Shop();
|
|
|
+ BeanUtil.copyProperties(shopVo, shop);
|
|
|
shop.setId(idsService.getId(Ids.RESTAURANT_ID));
|
|
|
- System.out.println(Json.toJson(shop));
|
|
|
- if(1==1){
|
|
|
- return Rets.success();
|
|
|
+ List activities = Json.fromJson(List.class,shopVo.getActivitiesJson());
|
|
|
+ int index = 0;
|
|
|
+ for (int i = 0; i < activities.size(); i++) {
|
|
|
+ Map activity = (Map) activities.get(i);
|
|
|
+ String iconName = activity.get("icon_name").toString();
|
|
|
+ switch (iconName) {
|
|
|
+ case "减":
|
|
|
+ activity.put("icon_color", "f07373");
|
|
|
+ activity.put("id", index++);
|
|
|
+ break;
|
|
|
+ case "特":
|
|
|
+ activity.put("icon_color", "EDC123");
|
|
|
+ activity.put("id", index++);
|
|
|
+ break;
|
|
|
+ case "新":
|
|
|
+ activity.put("icon_color ", "70bc46");
|
|
|
+ activity.put("id", index++);
|
|
|
+ break;
|
|
|
+ case "领":
|
|
|
+ activity.put("icon_color ", "E3EE0D");
|
|
|
+ activity.put("id ", index++);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
+ shop.setActivities(activities);
|
|
|
+
|
|
|
List<Map> supports = new ArrayList<Map>(4);
|
|
|
- if ((boolean) data.get("bao")) {
|
|
|
+ if (shopVo.getBao()) {
|
|
|
supports.add(buildSupport("已加入“外卖保”计划,食品安全有保障", "999999", "保", 7, "外卖保"));
|
|
|
}
|
|
|
- if ((boolean) data.get("zhun")) {
|
|
|
+ if (shopVo.getZhun()) {
|
|
|
supports.add(buildSupport("准时必达,超时秒赔", "57A9FF", "准", 9, "准时达"));
|
|
|
}
|
|
|
- if ((boolean) data.get("piao")) {
|
|
|
+ if (shopVo.getPiao()) {
|
|
|
supports.add(buildSupport("该商家支持开发票,请在下单时填写好发票抬头", "999999", "票", 4, "开发票"));
|
|
|
}
|
|
|
shop.setSupports(supports);
|
|
|
- shop.setIs_new((boolean) data.get("new"));
|
|
|
+ shop.setIs_new(shopVo.getNews());
|
|
|
|
|
|
- if ((boolean) data.get("delivery_mode")) {
|
|
|
+ if (shopVo.getDeliveryMode()) {
|
|
|
Map<String, Object> deliveryMode = Maps.newHashMap("color", "57A9FF", "id", 1, "is_solid", true, "text", "蜂鸟专送");
|
|
|
shop.setDelivery_mode(deliveryMode);
|
|
|
}
|
|
|
Map<String, String> tips = new HashMap<String, String>(2);
|
|
|
- tips.put("tips", "配送费约¥" + data.get("float_delivery_fee"));
|
|
|
+ tips.put("tips", "配送费约¥" +shopVo.getFloat_delivery_fee());
|
|
|
shop.setPiecewise_agent_fee(tips);
|
|
|
List<String> openingHours = new ArrayList<String>();
|
|
|
- if (Strings.isNotBlank(Strings.sNull(data.get("startTime"))) &&
|
|
|
- Strings.isNotBlank(Strings.sNull(data.get("endTime")))) {
|
|
|
- openingHours.add(data.get("startTime").toString() + "/" + data.get("endTime").toString());
|
|
|
+ if (Strings.isNotBlank(shopVo.getStartTime()) &&
|
|
|
+ Strings.isNotBlank(shopVo.getEndTime())) {
|
|
|
+ openingHours.add(shopVo.getStartTime() + "/" + shopVo.getEndTime());
|
|
|
} else {
|
|
|
openingHours.add("08:30/20:30");
|
|
|
}
|
|
|
@@ -139,11 +164,11 @@ public class ShopController extends BaseController {
|
|
|
shop.setOpening_hours(openingHours);
|
|
|
|
|
|
Map<String, String> license = new HashMap<String, String>();
|
|
|
- if (Strings.isNotBlank(Strings.sNull(data.get("business_license_image")))) {
|
|
|
- license.put("business_license_image", data.get("business_license_image").toString());
|
|
|
+ if (Strings.isNotBlank(Strings.sNull(shopVo.getBusiness_license_image()))) {
|
|
|
+ license.put("business_license_image", shopVo.getBusiness_license_image());
|
|
|
}
|
|
|
- if (Strings.isNotBlank(Strings.sNull(data.get("catering_service_license_image")))) {
|
|
|
- license.put("catering_service_license_image", data.get("catering_service_license_image").toString());
|
|
|
+ if (Strings.isNotBlank(shopVo.getCatering_service_license_image())) {
|
|
|
+ license.put("catering_service_license_image",shopVo.getCatering_service_license_image());
|
|
|
}
|
|
|
shop.setLicense(license);
|
|
|
|
|
|
@@ -160,33 +185,6 @@ public class ShopController extends BaseController {
|
|
|
"registered_number", "");
|
|
|
shop.setIdentification(identification);
|
|
|
|
|
|
- List activities = (List) data.get("activities");
|
|
|
- int index = 0;
|
|
|
- for (int i = 0; i < activities.size(); i++) {
|
|
|
- Map activity = (Map) activities.get(i);
|
|
|
- String iconName = activity.get("icon_name").toString();
|
|
|
- switch (iconName) {
|
|
|
- case "减":
|
|
|
- activity.put("icon_color", "f07373");
|
|
|
- activity.put("id", index++);
|
|
|
- break;
|
|
|
- case "特":
|
|
|
- activity.put("icon_color", "EDC123");
|
|
|
- activity.put("id", index++);
|
|
|
- break;
|
|
|
- case "新":
|
|
|
- activity.put("icon_color ", "70bc46");
|
|
|
- activity.put("id", index++);
|
|
|
- break;
|
|
|
- case "领":
|
|
|
- activity.put("icon_color ", "E3EE0D");
|
|
|
- activity.put("id ", index++);
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- shop.setActivities(activities);
|
|
|
|
|
|
CityInfo cityInfo = positionService.getPostion(getIp());
|
|
|
if (cityInfo != null) {
|
|
|
@@ -197,28 +195,31 @@ public class ShopController extends BaseController {
|
|
|
locations.add(Double.valueOf(cityInfo.getLat()));
|
|
|
shop.setLocation(locations);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
mongoRepository.save(shop);
|
|
|
|
|
|
return Rets.success();
|
|
|
}
|
|
|
|
|
|
- @RequestMapping(value = "addcategory",method = RequestMethod.POST)
|
|
|
+ @RequestMapping(value = "addcategory", method = RequestMethod.POST)
|
|
|
|
|
|
public Object addCategory(HttpServletRequest request) {
|
|
|
- Menu menu = getRequestPayload( Menu.class);
|
|
|
+ Menu menu = getRequestPayload(Menu.class);
|
|
|
menu.setId(idsService.getId(Ids.CATEGORY_ID));
|
|
|
System.out.println(Json.toJson(menu));
|
|
|
//todo 进行处理后保存
|
|
|
mongoRepository.save(menu);
|
|
|
return Rets.success();
|
|
|
}
|
|
|
- @RequestMapping(value = "/v2/restaurant/category",method = RequestMethod.GET)
|
|
|
+
|
|
|
+ @RequestMapping(value = "/v2/restaurant/category", method = RequestMethod.GET)
|
|
|
|
|
|
public Object categories() {
|
|
|
return Rets.success(mongoRepository.findAll("categories"));
|
|
|
}
|
|
|
|
|
|
- @RequestMapping(value = "/getcategory/{id}",method = RequestMethod.GET)
|
|
|
+ @RequestMapping(value = "/getcategory/{id}", method = RequestMethod.GET)
|
|
|
|
|
|
public Object getCategory(@PathVariable("id") Long restaurantId) {
|
|
|
List list = mongoRepository.findAll("menus", "restaurant_id", restaurantId);
|
|
|
@@ -226,14 +227,15 @@ public class ShopController extends BaseController {
|
|
|
}
|
|
|
|
|
|
|
|
|
- @RequestMapping(value = "/v2/menu/{id}",method = RequestMethod.GET)
|
|
|
- public Object getMenus(@PathVariable("id")Long id){
|
|
|
- return Rets.success(mongoRepository.findOne(id,"menus"));
|
|
|
+ @RequestMapping(value = "/v2/menu/{id}", method = RequestMethod.GET)
|
|
|
+ public Object getMenus(@PathVariable("id") Long id) {
|
|
|
+ return Rets.success(mongoRepository.findOne(id, "menus"));
|
|
|
}
|
|
|
- @RequestMapping(value = "/v2/menu",method = RequestMethod.GET)
|
|
|
|
|
|
- public Object getMenu(@RequestParam("restaurant_id")Long restaurantId, @RequestParam("allMenu")boolean allMEnu){
|
|
|
- return Rets.success(mongoRepository.findAll("menus","restaurant_id",restaurantId));
|
|
|
+ @RequestMapping(value = "/v2/menu", method = RequestMethod.GET)
|
|
|
+
|
|
|
+ public Object getMenu(@RequestParam("restaurant_id") Long restaurantId, @RequestParam("allMenu") boolean allMEnu) {
|
|
|
+ return Rets.success(mongoRepository.findAll("menus", "restaurant_id", restaurantId));
|
|
|
}
|
|
|
|
|
|
|