Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.booking.business.web;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Set;
- import net.sf.json.JSONArray;
- import net.sf.json.JSONObject;
- import com.opensymphony.xwork2.ActionContext;
- import com.opensymphony.xwork2.ActionSupport;
- import com.booking.business.service.IAnnounceService;
- import com.booking.business.service.IServicesService;
- import com.booking.business.service.IStoreService;
- import com.booking.business.service.ITimetableService;
- import com.booking.business.service.IUserService;
- import com.booking.domain.Announce;
- import com.booking.domain.BookingOrder;
- import com.booking.domain.Services;
- import com.booking.domain.Store;
- import com.booking.domain.Timetable;
- import com.booking.domain.User;
- public class StoreManageAction extends ActionSupport{
- protected IStoreService storeService;
- protected IUserService userService;
- protected IAnnounceService announceService;
- protected IServicesService servicesService;
- protected ITimetableService timetableService;
- private Integer storeId;
- private String storename;
- // private String brief;
- private String address;
- private Integer announceId;
- private String userId;
- private String openId;
- private HashMap<String, Object> resultMap = new HashMap<String, Object>();
- public String manageStore() throws Exception{
- ActionContext ctx = ActionContext.getContext();
- String openId = (String) ctx.get("openId");
- Store store = userService.getUser(openId).getStore();
- Set<Timetable> timelist = store.getTimetables();
- System.out.println(timelist.size());
- ctx.put("store", store);
- ctx.put("timelist", timelist);
- return "manageStore";
- }
- public String addStore() throws Exception{
- resultMap = new HashMap<String, Object>();
- storeService.addStore(storename, address, userService.getUser(openId));
- resultMap.put("status", true);
- resultMap.put("msg", "保存成功");
- return SUCCESS;
- }
- public String listStore() throws Exception{
- List<Store> list = storeService.listStore();
- ActionContext ctx = ActionContext.getContext();
- ctx.put("list", list);
- return "listStore";
- }
- public String listOrders() throws Exception{
- Set<BookingOrder> list = storeService.getStore(storeId).getOrders();
- ActionContext ctx = ActionContext.getContext();
- ctx.put("list", list);
- return "listOrders";
- }
- public String listServices() throws Exception{
- Set<Services> list = storeService.getStore(storeId).getServices();
- ActionContext ctx = ActionContext.getContext();
- ctx.put("list", list);
- return "listServices";
- }
- // 前端接口
- public String outwardAdminNavigation() throws Exception{
- return "outwardAdminNavigation";
- }
- /*
- * 列出所有商店
- * @param openId
- */
- public String outwardStoreList() throws Exception{
- ActionContext ctx = ActionContext.getContext();
- List<Store> list = storeService.listStore();
- ctx.put("list", list);
- return "outwardStoreList";
- }
- /*
- * 查看商店信息
- *
- */
- public String outwardViewStore() throws Exception{
- ActionContext ctx = ActionContext.getContext();
- String openId = (String) ctx.get("openId");
- ctx.put("store", storeService.getStore(storeId));
- return "outwardViewStore";
- }
- /*
- * 列出我的商店的订单
- * @param openId
- */
- public String outwardStoreListOrders() throws Exception{
- ActionContext ctx = ActionContext.getContext();
- String openId = (String) ctx.get("openId");
- Set<BookingOrder> list = userService.getUser(openId).getStore().getOrders();
- ctx.put("list", list);
- return "outwardStoreListOrders";
- }
- /*
- * 列出我的商店的公告
- * @param openId
- */
- public String outwardStoreListAnnounce() throws Exception{
- ActionContext ctx = ActionContext.getContext();
- String openId = (String) ctx.get("openId");
- Set<Announce> list = userService.getUser(openId).getStore().getAnnounces();
- ctx.put("list", list);
- return "outwardStoreListAnnounce";
- }
- /*
- * 公告具体
- */
- public String outwardStoreViewAnnounce() throws Exception{
- ActionContext ctx = ActionContext.getContext();
- Announce announce = announceService.getAnnounce(announceId);
- ctx.put("announce", announce);
- return "outwardStoreViewAnnounce";
- }
- /*
- * 列出服务项目
- * @param storeId
- */
- public String outwardListServices() throws Exception{
- ActionContext ctx = ActionContext.getContext();
- String openId = (String) ctx.get("openId");
- Store store = userService.getUser(openId).getStore();
- ctx.put("list", store.getServices());
- return "outwardListServices";
- }
- /*
- * 商店时间列表
- * @param openId
- */
- public String outwardListTime() throws Exception{
- ActionContext ctx = ActionContext.getContext();
- resultMap = new HashMap<String, Object>();
- String openId = (String) ctx.get("openId");
- Store store = userService.getUser(openId).getStore();
- ctx.put("listTime", timetableService.getTimetables(store));
- return "outwardListTime";
- }
- /*
- * 添加订单+展示预约时间
- * @param openId
- * @param storeId
- */
- public String outwardManageOrder() throws Exception{
- ActionContext ctx = ActionContext.getContext();
- String openId = (String) ctx.get("openId");
- User user = userService.getUser(openId);
- System.out.println(storeId);
- Store store = storeService.getStore(storeId);
- Set<Services> listser = store.getServices();
- ArrayList<String> stt = this.showTimetable(store);
- resultMap = new HashMap<String, Object>();
- resultMap.put("timetable", stt);
- JSONObject json = JSONObject.fromObject(resultMap);
- ctx.put("data", json);
- ctx.put("user", user);
- ctx.put("store", store);
- ctx.put("listser", listser);
- return "outwardManageOrder";
- }
- /*
- * 处理申请
- * @param pass 1/0
- * @servicesId
- */
- // public String dealServicess() throws Exception{
- // Services services = servicesService.getServices(servicesId);
- // resultMap = new HashMap<String, Object>();
- //
- // if(pass == 1){
- // services.setPass(1);
- // services.getUser().setStore(services.getStore());
- // } else if(pass == 0){
- // services.setPass(0);
- // }
- // services.setStatus(1);
- // servicesService.updateServices(services);
- // resultMap.put("status", true);
- // resultMap.put("ret", pass==1?"已通过申请":"已拒绝申请");
- // return SUCCESS;
- // }
- /*
- * 店主跳转到商店信息页面
- * @param openId
- */
- public String outwardStoreManage() throws Exception{
- ActionContext ctx = ActionContext.getContext();
- String openId = (String) ctx.get("openId");
- Store store = userService.getUser(openId).getStore();
- Set<Timetable> timelist = store.getTimetables();
- System.out.println(timelist.size());
- ctx.put("store", store);
- ctx.put("timelist", timelist);
- return "outwardStoreManage";
- }
- /*
- * 修改商店名称
- * @param openId
- */
- public String updateStoreName() throws Exception{
- ActionContext ctx = ActionContext.getContext();
- resultMap = new HashMap<String, Object>();
- String openId = (String) ctx.get("openId");
- Store store = userService.getUser(openId).getStore();
- store.setStorename(storename);
- store.setAddress(address);
- storeService.updateStore(store);
- resultMap.put("status", true);
- resultMap.put("ret", "修改成功");
- return SUCCESS;
- }
- /*
- * 整合工作时间
- * @Timetable tt
- * @return ArrayList<String> stt
- */
- public ArrayList<String> showTimetable(Store store){
- List<Timetable> tts = new ArrayList<Timetable>(store.getTimetables());
- ArrayList<String> stt = new ArrayList<String>();
- for (int b=0;b<7;b++){
- stt.add(b, "");
- }
- for(int i = 0;i<tts.size();i++){
- if(tts.get(i).getIsOn()==true){
- Timetable ti = tts.get(i);
- System.out.printf("i="+i+";");
- for(int j = 0;j<ti.getWeekday().length();j=j+2){
- System.out.print("j="+j+";");
- Integer wd = Integer.valueOf(ti.getWeekday().charAt(j)+"");
- System.out.println("wd="+wd);
- Integer st = Integer.valueOf(ti.getStarttime().substring(0, 2));
- System.out.printf("st="+st+";");
- Integer ed = Integer.valueOf(ti.getEndtime().substring(0, 2));
- System.out.println("ed="+ed+";");
- String ts = "";
- int dd = ed-st;
- for(int k = 0;k<dd;k++ ){
- int s = st+k;
- System.out.printf("s="+s+";");
- System.out.println("tsb="+ts+";");
- ts= ts+s+",";
- System.out.println("ts="+ts+";");
- }
- stt.set(wd,ts);
- System.out.println("stt[wd]="+stt.get(wd));
- }
- }
- }
- for(int a = 0;a<stt.size();a++){
- System.out.println(a+" : "+stt.get(a));
- }
- System.out.println(stt);
- return stt;
- }
- public IStoreService getStoreService() {
- return storeService;
- }
- public void setStoreService(IStoreService storeService) {
- this.storeService = storeService;
- }
- public IUserService getUserService() {
- return userService;
- }
- public void setUserService(IUserService userService) {
- this.userService = userService;
- }
- public IServicesService getServicesService() {
- return servicesService;
- }
- public void setServicesService(IServicesService servicesService) {
- this.servicesService = servicesService;
- }
- public Integer getStoreId() {
- return storeId;
- }
- public void setStoreId(Integer storeId) {
- this.storeId = storeId;
- }
- public String getStorename() {
- return storename;
- }
- public void setStorename(String storename) {
- this.storename = storename;
- }
- public String getAddress() {
- return address;
- }
- public void setAddress(String address) {
- this.address = address;
- }
- public String getUserId() {
- return userId;
- }
- public void setUserId(String userId) {
- this.userId = userId;
- }
- public String getOpenId() {
- return openId;
- }
- public void setOpenId(String openId) {
- this.openId = openId;
- }
- public HashMap<String, Object> getResultMap() {
- return resultMap;
- }
- public void setResultMap(HashMap<String, Object> resultMap) {
- this.resultMap = resultMap;
- }
- public IAnnounceService getAnnounceService() {
- return announceService;
- }
- public void setAnnounceService(IAnnounceService announceService) {
- this.announceService = announceService;
- }
- public ITimetableService getTimetableService() {
- return timetableService;
- }
- public void setTimetableService(ITimetableService timetableService) {
- this.timetableService = timetableService;
- }
- public Integer getAnnounceId() {
- return announceId;
- }
- public void setAnnounceId(Integer announceId) {
- this.announceId = announceId;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement