Source code and papers of food ordering system based on ssm+vue

Food ordering system source code and paper based on ssm+vue 157

 Development tools: idea or eclipse
 database mysql5.7+
 database link tools: navcat, little dolphin and other
  technologies: ssm 

  • Basis for topic selection, purpose and significance, main references
  1. Background and basis for topic selection

The Internet has brought about tremendous changes in our work and life. Global economic integration has promoted the development of management informatization. At the same time, management informatization has also promoted the development of economic integration. As early as the 1980s, the United States had begun to develop the e-commerce industry. A good economy, complete technology and stable social conditions provided a good development atmosphere for the development of the management information industry. In 1999, in order to provide Internet access to every user who needs it, the European Commission formulated the e-Europe plan. Many companies have added the online information management model to their applications. It has a novel form, personalized design, diversified services, and huge room for growth. It has brought huge benefits to related companies and has also won opportunities for them. The brand's leading position in the industry.

The management information industry has a strong development trend. It is a new force that is constantly promoting the country's economic growth. Logistics security, network security, user information security and other related issues have been greatly improved. Basically, these problems that people are worried about rarely occur. There are many resources in the network, complete types, and strong comparability, which provides users with great convenience. Compared with foreign countries, my country's management informatization emerged relatively late, but relevant technical personnel continue to develop and improve computer technology, which has led to unprecedented development of the network market, attracting more and more people to accept and use it, and promoting The management information industry continues to develop and is gradually narrowing the gap with foreign countries. At the beginning of the 21st century, Jack Ma vigorously used Internet technology to establish Alipay and Taobao. Later, the emergence of e-commerce platforms such as Vipshop and JD.com, as well as gourmet food delivery platforms such as Ele.me and Meituan, marked the development of our country. E-commerce is gradually becoming mature, which also proves that the development of network technology has brought the level of our management information industry to its peak.

  1. purpose meaning

Nowadays, the widespread popularization and application of the Internet marks the arrival of the information age. The management information industry occupies an increasingly important position in life. Information services and management have greatly simplified the traditional management model. To a great extent, it has improved people’s living standards and working styles. To put it simply, the informatization form of ordering management is very simple, and the operation is convenient and fast. Relevant staff can directly manage it online. Management and control do not need to be limited by time and space. Management can be completed online anytime and anywhere. Now, with the popularization and application of the Internet, management informatization has been recognized by the majority of users, and they like this way to manage ordering information. Online management has become more and more popular and has extremely high practical value. Therefore, I developed the online Ordering system. Compared with foreign countries, my country's management information industry started late. However, in recent years, the development of my country's social management information service industry has advanced by leaps and bounds, and the gap with foreign countries is gradually narrowing. To some extent, our lives are increasingly inseparable from the Internet. At the same time, the management information industry also occupies an increasingly important position. This system provides users with a management platform with a friendly interface and simple use, so that the management of ordering information is no longer limited by time and space, and can be managed and controlled anytime and anywhere, which is of great value and significance.

  1. main reference

[1] Tian Jianyong. Design and implementation of e-commerce website based on MVC architecture [J]. Computer Knowledge and Technology, 2020, 16(21): 235-236.

[2] Xu Gang, Zhai Mengjiao. Design and implementation of beauty information business website based on SSM [J]. Journal of Shangqiu Vocational and Technical College, 2019, 18(06): 65-71.

[3] Tang Tao. Design and implementation of agricultural product website based on Web technology [J]. Computer Programming Skills and Maintenance, 2019(12):18-20.

[4] Wang Qiheng. Research on software development technology of B/S structure [J]. Computer Products and Circulation, 2019(11):17.

[5] Ma Chengping. Design and implementation of business website behavior analysis system [D]. Southeast University, 2019.

[6] Zhou Yanling. Exploration and research on developing WEB applications with Spring MVC framework [J]. Science and Technology Square, 2016(06):25-28.

[7] Xie Xiaoyuan. Design and implementation of front-end module in micro-mall system based on J2EE technology [D]. Nanjing University, 2016.

[8] Yang Xuhui, Zhou Qingguo, Han Genliang, Zheng Wei, Qi Changyu. Design and implementation of a Java code obfuscator based on source code [J]. Journal of Gansu Science, 2015, 27(02): 28-32.

[9] Guo Shanshan. Research on the application of lightweight J2EE key technologies in information systems [D]. Wuhan University of Technology, 2013.

[10] Yue Shuling, Song Yanping, Lu Yufu. Application of Web database technology in e-commerce [J]. China Business and Trade, 2012(06):125-126.

package com.controller;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.*;
import javax.servlet.http.HttpServletRequest;

import com.entity.*;
import com.entity.view.CaipinView;
import com.service.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;

import com.utils.PageUtils;
import com.utils.R;

/**
 * 菜品表
 * 后端接口
 * @author
 * @email
 * @date 2024-03-08
*/
@RestController
@Controller
@RequestMapping("/caipin")
public class CaipinController {
    private static final Logger logger = LoggerFactory.getLogger(CaipinController.class);

    @Autowired
    private CaipinService caipinService;

    @Autowired
    private KuchuenService kuchuenService;

    @Autowired
    private LiushuiService liushuiService;


    @Autowired
    private YudingcanzhuoService yudingcanzhuoService;

    @Autowired
    private DingdanxiangqingService dingdanxiangqingService;

    /**
    * 后端列表
    */
    @RequestMapping("/page")
    public R page(@RequestParam Map<String, Object> params){
        logger.debug("Controller:"+this.getClass().getName()+",page方法");
        PageUtils page = caipinService.queryPage(params);
        return R.ok().put("data", page);
    }
    /**
    * 后端详情
    */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
        logger.debug("Controller:"+this.getClass().getName()+",info方法");
        CaipinEntity caipin = caipinService.selectById(id);
        if(caipin!=null){
            CaipinView caipinView = new CaipinView();
            BeanUtils.copyProperties(caipin, caipinView);
            KuchuenEntity kuchuenEntity = kuchuenService.selectById(caipin.getHxTypes());
            BeanUtils.copyProperties(kuchuenEntity, caipinView ,new String[]{ "id", "createDate"});
            return R.ok().put("data", caipinView);
        }else {
            return R.error(511,"查不到数据");
        }

    }

    /**
    * 后端保存
    */
    @RequestMapping("/save")
    public R save(@RequestBody CaipinEntity caipin, HttpServletRequest request){
        logger.debug("Controller:"+this.getClass().getName()+",save");
        Wrapper<CaipinEntity> queryWrapper = new EntityWrapper<CaipinEntity>()
            .eq("hx_types", caipin.getHxTypes())
            ;
        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        CaipinEntity caipinEntity = caipinService.selectOne(queryWrapper);
        if("".equals(caipin.getImgPhoto()) || "null".equals(caipin.getImgPhoto())){
            caipin.setImgPhoto(null);
        }
        if(caipinEntity==null){
            caipinService.insert(caipin);
            return R.ok();
        }else {
            return R.error(511,"表中有相同数据");
        }
    }

    /**
    * 修改
    */
    @RequestMapping("/update")
    public R update(@RequestBody CaipinEntity caipin, HttpServletRequest request){
        logger.debug("Controller:"+this.getClass().getName()+",update");
        //根据字段查询是否有相同数据
        Wrapper<CaipinEntity> queryWrapper = new EntityWrapper<CaipinEntity>()
            .notIn("id",caipin.getId())
            .eq("hx_types", caipin.getHxTypes())
            .eq("money", caipin.getMoney())
            .eq("caipin_content", caipin.getCaipinContent())
            ;
        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        CaipinEntity caipinEntity = caipinService.selectOne(queryWrapper);
        if("".equals(caipin.getImgPhoto()) || "null".equals(caipin.getImgPhoto())){
                caipin.setImgPhoto(null);
        }
        if(caipinEntity==null){
            caipinService.updateById(caipin);//根据id更新
            return R.ok();
        }else {
            return R.error(511,"表中有相同数据");
        }
    }


    /**
    * 删除
    */
    @RequestMapping("/diancai")
    public R diancai(@RequestParam Map<String, Object> params, HttpServletRequest request){
        if(params.size() == 0){
            return R.error("请选择要购买的菜品");
        }
        //获取系统当前时间的时间戳作为订单号
        long danhao = new Date().getTime();
        //new 一个订单详情表
        DingdanxiangqingEntity dingdanxiangqing = new DingdanxiangqingEntity();
        //new 一个流水表
        LiushuiEntity liushui = new LiushuiEntity();
        //循环前端传过来的key
            for (String id: params.keySet()) {
                //根据前端传来的key(id)查询数据
                CaipinEntity caipin = caipinService.selectOne(new EntityWrapper<CaipinEntity>().eq("hx_types",id));
                //判断查出来的数据是否为空
                if(caipin == null){
                    //为空返回前台
                    return R.error();
                }
                //判断前端传来的菜品数量是否为空或者小于0
                if(StringUtils.isBlank((String)params.get(id)) || Integer.parseInt(String.valueOf(params.get(id))) <= 0){
                    return R.error("您选择的菜品数量不能小于0哦");
                }

                //根据前台传来的key(id)去库存表中查询数据
                KuchuenEntity kuchuenEntity = kuchuenService.selectById(id);
                //如果为空返回前台
                if(kuchuenEntity == null){
                    return R.error("这件菜品菜品不存在于库存");
                }
                //把map中的值转为Integger
                Integer zhi = Integer.parseInt(String.valueOf(kuchuenEntity.getId()));
                //根据当前登录人的id去已预约的餐桌信息表中查询数据
                YudingcanzhuoEntity yudingcanzhuo = yudingcanzhuoService.selectOne(new EntityWrapper().eq("yh_types", request.getSession().getAttribute("userId")));
                //如果为空就返回前端
                if(yudingcanzhuo == null){
                    return R.error("请先预定餐桌后再预定菜品,以免餐桌不足");
                }
                //如果为空就返回前端
                if(yudingcanzhuo.getCzTypes() == null){
                    return R.error("请先预定餐桌后再预定菜品,以免餐桌不足");
                }

                //判断库存中的菜品数量是否大于用户购买的数量
                if(kuchuenEntity.getNumber() < Integer.parseInt(String.valueOf(params.get(String.valueOf(zhi))))){
                    //库存小于是返回并提示
                    return R.error(kuchuenEntity.getName()+" 库存只剩:"+kuchuenEntity.getNumber()+" 个,不足:"+ params.get(id)+" 个!!!");
                }

                //订单详情中添加进用户购买数量
                dingdanxiangqing.setNumber(zhi);
                //在订单详情表中存入生成的订单号
                dingdanxiangqing.setOdd(String.valueOf(danhao));
                //在订单详情表中存入菜品信息
                dingdanxiangqing.setHxTypes(caipin.getHxTypes());
                //订单详情表中存入菜品价格
                dingdanxiangqing.setMoney(caipin.getMoney());
                //新增订单详情信息
                dingdanxiangqingService.insert(dingdanxiangqing);


                //给流水表中的总价赋值为0
                liushui.setMaxMoney(0.0);
                //获取系统当前时间
                liushui.setCreateTime(new Date());
                //设置上面生成的订单号
                liushui.setOdd(String.valueOf(danhao));
                //在流水表存入中查出来的餐桌信息
                liushui.setCzTypes(yudingcanzhuo.getCzTypes());
                //在流水表存入当前登录用户的信息
                liushui.setYhTypes((Integer) request.getSession().getAttribute("userId"));
                //设置为未支付
                liushui.setSfTypes(2);
                //计算总价
                liushui.setMaxMoney(liushui.getMaxMoney()+(dingdanxiangqing.getMoney()*dingdanxiangqing.getNumber()));

                //库存数量减去用户购买数量
                int i = kuchuenEntity.getNumber() - zhi;
                //将库存数量更新
                kuchuenEntity.setNumber(i);
                //修改库存数量
                kuchuenService.updateById(kuchuenEntity);
            }
        //新增流水信息
        liushuiService.insert(liushui);
        return R.ok();
    }

    /**
    * 删除
    */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
        logger.debug("Controller:"+this.getClass().getName()+",delete");
        caipinService.deleteBatchIds(Arrays.asList(ids));
        return R.ok();
    }
}

 

package com.controller;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;

import com.utils.ValidatorUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.annotation.IgnoreAuth;

import com.entity.AddressEntity;
import com.entity.view.AddressView;

import com.service.AddressService;
import com.service.TokenService;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.MPUtil;
import com.utils.CommonUtil;


/**
 * 地址
 * 后端接口
 * @author 
 * @email 
 * @date 2021-01-25 11:41:44
 */
@RestController
@RequestMapping("/address")
public class AddressController {
    @Autowired
    private AddressService addressService;
    


    /**
     * 后端列表
     */
    @RequestMapping("/page")
    public R page(@RequestParam Map<String, Object> params,AddressEntity address, HttpServletRequest request){
    	if(!request.getSession().getAttribute("role").toString().equals("管理员")) {
    		address.setUserid((Integer)request.getSession().getAttribute("userId"));
    	}

        EntityWrapper<AddressEntity> ew = new EntityWrapper<AddressEntity>();
		PageUtils page = addressService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, address), params), params));
        return R.ok().put("data", page);
    }
    
    /**
     * 前端列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params,AddressEntity address, HttpServletRequest request){
    	if(!request.getSession().getAttribute("role").toString().equals("管理员")) {
    		address.setUserid((Integer)request.getSession().getAttribute("userId"));
    	}

        EntityWrapper<AddressEntity> ew = new EntityWrapper<AddressEntity>();
		PageUtils page = addressService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, address), params), params));
        return R.ok().put("data", page);
    }

	/**
     * 列表
     */
    @RequestMapping("/lists")
    public R list( AddressEntity address){
       	EntityWrapper<AddressEntity> ew = new EntityWrapper<AddressEntity>();
      	ew.allEq(MPUtil.allEQMapPre( address, "address")); 
        return R.ok().put("data", addressService.selectListView(ew));
    }

	 /**
     * 查询
     */
    @RequestMapping("/query")
    public R query(AddressEntity address){
        EntityWrapper< AddressEntity> ew = new EntityWrapper< AddressEntity>();
 		ew.allEq(MPUtil.allEQMapPre( address, "address")); 
		AddressView addressView =  addressService.selectView(ew);
		return R.ok("查询地址成功").put("data", addressView);
    }
	
    /**
     * 后端详情
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
        AddressEntity address = addressService.selectById(id);
        return R.ok().put("data", address);
    }

    /**
     * 前端详情
     */
    @RequestMapping("/detail/{id}")
    public R detail(@PathVariable("id") Long id){
        AddressEntity address = addressService.selectById(id);
        return R.ok().put("data", address);
    }
    



    /**
     * 后端保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody AddressEntity address, HttpServletRequest request){
    	address.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
    	//ValidatorUtils.validateEntity(address);
    	address.setUserid((Integer)request.getSession().getAttribute("userId"));
		Integer userId = (Integer)request.getSession().getAttribute("userId");
    	if(address.getIsdefault().equals("是")) {
    		addressService.updateForSet("isdefault='否'", new EntityWrapper<AddressEntity>().eq("userid", userId));
    	}
    	address.setUserid(userId);

        addressService.insert(address);
        return R.ok();
    }
    
    /**
     * 前端保存
     */
    @RequestMapping("/add")
    public R add(@RequestBody AddressEntity address, HttpServletRequest request){
    	address.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
    	//ValidatorUtils.validateEntity(address);
    	address.setUserid((Integer)request.getSession().getAttribute("userId"));
		Integer userId = (Integer)request.getSession().getAttribute("userId");
    	if(address.getIsdefault().equals("是")) {
    		addressService.updateForSet("isdefault='否'", new EntityWrapper<AddressEntity>().eq("userid", userId));
    	}
    	address.setUserid(userId);

        addressService.insert(address);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody AddressEntity address, HttpServletRequest request){
        //ValidatorUtils.validateEntity(address);
        if(address.getIsdefault().equals("是")) {
    		addressService.updateForSet("isdefault='否'", new EntityWrapper<AddressEntity>().eq("userid", request.getSession().getAttribute("userId")));
    	}
        addressService.updateById(address);//全部更新
        return R.ok();
    }
    
    /**
     * 获取默认地址
     */
    @RequestMapping("/default")
    public R defaultAddress(HttpServletRequest request){
    	Wrapper<AddressEntity> wrapper = new EntityWrapper<AddressEntity>().eq("isdefault", "是").eq("userid", request.getSession().getAttribute("userId"));
        AddressEntity address = addressService.selectOne(wrapper);
        return R.ok().put("data", address);
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
        addressService.deleteBatchIds(Arrays.asList(ids));
        return R.ok();
    }
    
    /**
     * 提醒接口
     */
	@RequestMapping("/remind/{columnName}/{type}")
	public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request, 
						 @PathVariable("type") String type,@RequestParam Map<String, Object> map) {
		map.put("column", columnName);
		map.put("type", type);
		
		if(type.equals("2")) {
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
			Calendar c = Calendar.getInstance();
			Date remindStartDate = null;
			Date remindEndDate = null;
			if(map.get("remindstart")!=null) {
				Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
				c.setTime(new Date()); 
				c.add(Calendar.DAY_OF_MONTH,remindStart);
				remindStartDate = c.getTime();
				map.put("remindstart", sdf.format(remindStartDate));
			}
			if(map.get("remindend")!=null) {
				Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
				c.setTime(new Date());
				c.add(Calendar.DAY_OF_MONTH,remindEnd);
				remindEndDate = c.getTime();
				map.put("remindend", sdf.format(remindEndDate));
			}
		}
		
		Wrapper<AddressEntity> wrapper = new EntityWrapper<AddressEntity>();
		if(map.get("remindstart")!=null) {
			wrapper.ge(columnName, map.get("remindstart"));
		}
		if(map.get("remindend")!=null) {
			wrapper.le(columnName, map.get("remindend"));
		}
		if(!request.getSession().getAttribute("role").toString().equals("管理员")) {
    		wrapper.eq("userid", (Long)request.getSession().getAttribute("userId"));
    	}


		int count = addressService.selectCount(wrapper);
		return R.ok().put("count", count);
	}
	


}

Guess you like

Origin blog.csdn.net/weixin_46437112/article/details/132753416