基于SpringBoot vue的零食商城平台

     随着互联网技术的不断变革与发展,全世界人类的生产生活正在经历着翻天覆地的重大变革,如今互联网时代的全面到来便利了生活的方方面面。社会经济的发展和文明的进步为人们生活的改变提供了很大的动力。人们开始越来越多的网上购物,但市面上只售卖零食产品的网站还是屈指可数的。从长远来看,企业对消费者的电子商务将最终在电子商务领域占据重要地位。但是由于各种因素的制约,目前以及比较长的一段时间内,这个层次的业务还只能占比较小的比重。它是以互联网为主要服务提供手段,实现公众消费和提供服务,并保证与其相关的付款方式的电子化。它是随着万维网(WWW)的出现而迅速发展的,可以将其看作是一种电子化的零售。目前,计算机普及率越来越高,计算机的市场正处于蓬勃发展的大好阶段。因此开发一个基于Spring Boot框架的零食商城系统是很有必要的。

根据以上,在查阅了许多网站开发的相关资料的基础上,提出了基于Java技术,采用B/S构建结构,选用Spring Boot框架,Mybatis框架,运用VUE技术,UML技术和MySQL数据库来开发一个零食商城网站,不同于市面上的京东、淘宝等购物网站,而是针对零食产品购物的新型零食购物商城,包含管理员、用户模块实现了商城的基本功能,使得零食产品零食的交易更加方便,有效,成本更低,将成为零食产品零食销售的崭新模式,具有一定的实际意义和推广价值。

关键词:零食商城    Java    Spring Boot框架    MySQL

【551】基于SpringBoot vue的零食商城平台源码和论文含支付宝沙箱支付

安装说明:

此项目是前后端分离的
后台项目:shop
前端项目:Vue-shop

后端项目启动步骤:
1.先把sql导入数据库
2.把后台项目导入编辑器
3.修改数据库配置
4.启动项目
 
前端项目启动步骤:

1.打开Vue-shop目录,在这个文件夹里面加入cmd目录窗口
2.运行启动vue项目目录(需先安装nodejs软件)

先后执行下面命令
npm install
npm run dev 
执行成功之后,命令窗口会显示前端网站信息,复制链接到浏览器打开即可
 

ABSTRACT

With the continuous transformation and development of Internet technology, the production and life of people all over the world are undergoing earth shaking changes. The comprehensive arrival of the Internet era has facilitated all aspects of life. The development of social economy and the progress of civilization have provided great impetus for the change of people's lives. People began to buy more and more online, but there are still few websites on the market that only sell computer products. In the long run, business to consumer e-commerce will eventually occupy an important position in the field of e-commerce. However, due to the constraints of various factors, the business at this level can only account for a relatively small proportion at present and for a relatively long period of time. It uses the Internet as the main service providing means to realize public consumption and service provision, and to ensure the electronic payment methods related to it. It has developed rapidly with the emergence of the world wide web (WWW), which can be regarded as an electronic retail. At present, the computer penetration rate is getting higher and higher, and the computer market is in a good stage of vigorous development. Therefore, it is necessary to develop a computer mall system based on spring boot framework.

According to the above, on the basis of consulting a lot of relevant materials on website development, the author proposes to develop a computer mall website based on Java technology, B / s construction structure, spring boot framework, mybatis framework, Vue technology, UML technology and MySQL database, which is different from shopping websites such as jd.com and Taobao. It is a new computer Mall for computer product shopping, including administrators The user module has realized the basic functions of the mall, making the transaction of computer products more convenient, effective and lower cost. It will become a brand-new mode of computer sales of computer products, with certain practical significance and promotion value.

Keywords: computer mall Java spring boot framework MySQL

package com.java.controller;

import java.util.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSONObject;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.request.AlipayTradePagePayRequest;
import com.java.utils.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.java.model.*;
import com.java.service.*;
;

@RestController
@RequestMapping("/buy")
public class BuyController {
	private BuyService buyService;

	public BuyService getBuyService() {
		return buyService;
	}
	@Autowired
	private ThingTypeService thingtypeService;
	@Autowired
	private BuyListService buylistService;
	@Autowired
	private ClientService clientService;
	@Autowired
	private ThingType2Service thingtype2Service;
	@Autowired
	public void setBuyService(BuyService buyService) {
		this.buyService = buyService;
	}
	@Autowired
	private ThingService thingService;
	@Autowired
	private BuyingService buyingService;
	@Autowired
	private HttpServletRequest request;
	@Autowired
	private HttpServletResponse response;



	@CrossOrigin(origins = "*")
	@RequestMapping("/add")
	@ResponseBody
	public JsonBody add(@RequestBody Buying b) {
		if(buyingService.GetCount(b)==0)
			return Util.SetMap("您的购物车中无任何商品",false);
		Buy bl=new Buy();

		List<Buying> buying=buyingService.Get(b);
		Buy buy=new Buy();
		buy.setClientId(b.getClientId());

		int id = buyService.Add(buy);
		id=buy.getId();

		if(id<1)
			return Util.SetMap("提交失败",false);
		try {

             int total  = 0;
			int count=0;
			for(Buying bi:buying)
			{
				BuyList buylist=new BuyList();
				buylist.setBuyId(id);
				buylist.setThingId(bi.getThingId());
				buylist.setNum(bi.getNum());
				int success=buylistService.Add(buylist);
				count+=success;
				if(success>0)
					buyingService.Del(bi.getId());


                Thing thing = thingService.GetByID(bi.getThingId());
                total+=thing.getPrice();
			}


            //商户订单号,商户网站订单系统中唯一订单号,必填
            String out_trade_no = UUID.randomUUID().toString();

            //获得初始化的AlipayClient
            AlipayClient alipayClient = new DefaultAlipayClient(AlipayConfig.gatewayUrl, AlipayConfig.app_id, AlipayConfig.merchant_private_key, "json", AlipayConfig.charset, AlipayConfig.alipay_public_key, AlipayConfig.sign_type);
            //设置请求参数
            AlipayTradePagePayRequest alipayRequest = new AlipayTradePagePayRequest();
            //这里设置支付后跳转的地址
            alipayRequest.setReturnUrl(AlipayConfig.return_url);
            //alipayRequest.setNotifyUrl(AlipayConfig.notify_url);

            //付款金额,必填
            String total_amount = String.valueOf(total);
            //订单名称,必填
            String subject ="用户订单";
            //商品描述,可空
            String body = "";

            // 该笔订单允许的最晚付款时间,逾期将关闭交易。取值范围:1m~15d。m-分钟,h-小时,d-天,1c-当天(1c-当天的情况下,无论交易何时创建,都在0点关闭)。 该参数数值不接受小数点, 如 1.5h,可转换为 90m。
            String timeout_express = "5m";

            alipayRequest.setBizContent("{\"out_trade_no\":\""+ out_trade_no +"\","
                    + "\"total_amount\":\""+ total_amount +"\","
                    + "\"subject\":\""+ subject +"\","
                    + "\"body\":\""+ body +"\","
                    + "\"timeout_express\":\""+ timeout_express +"\","
                    + "\"product_code\":\"FAST_INSTANT_TRADE_PAY\"}");

            //请求
            String result = alipayClient.pageExecute(alipayRequest).getBody();



			return Util.SetData(result);


//			if(count==buying.size())
//				return Util.SetMap("下单成功", true);
//			else
//				return Util.SetMap("提交失败", false);
		} catch (Exception e) {
			return Util.SetMap(e.getMessage(), false);
		}
	}

	@CrossOrigin(origins = "*")
	@RequestMapping("/list")
	@ResponseBody
	public JsonBody list(@RequestBody Buy b) {
		List<Buy> bs= buyService.Get(b);
		for(Buy buy:bs)
		{
			buy.setClient(clientService.GetByID(buy.getClientId()));
		}
		return Util.SetData(bs);
	}

	@CrossOrigin(origins = "*")
	@RequestMapping("/del")
	@ResponseBody
	public JsonBody Del(int id) {
		Buy b=new Buy();
		b.setId(id);
		Buy bl=buyService.GetByID(b);
		if(bl.getState()>0)
			return Util.SetError("该订单已发出,不能取消");
		int r = buyService.Del(id);

		if(r>0)
			return Util.SetMap("退单成功!", false);
		else
			return Util.SetMap("退单失败!", false);
	}

	@CrossOrigin(origins = "*")
	@RequestMapping("/state")
	@ResponseBody
	public JsonBody state(@RequestBody Buy bl) {
		int r = buyService.EditState(bl);

		if(r>0)
			return Util.SetMap("操作成功!", true);
		else
			return Util.SetMap("操作失败!", false);
	}


}
package com.java.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.java.model.*;
import com.java.service.*;
import com.java.utils.CommonUtils;
import com.java.utils.JsonBody;
import com.java.utils.PageList;
import com.java.utils.ResponseUtil;
import com.java.utils.StringUtil;;

@RestController
@RequestMapping("/buying")
public class BuyingController {
	private BuyingService buyingService;

	public BuyingService getBuyingService() {
		return buyingService;
	}

	@Autowired
	public void setBuyingService(BuyingService buyingService) {
		this.buyingService = buyingService;
	}

	@Autowired
	private ClientService clientService;

	@Autowired
	private ThingService thingService;



	@Autowired
	private HttpServletRequest request;
	@Autowired
	private HttpServletResponse response;

	@Autowired
	private ThingTypeService thingtypeService;
	@Autowired
	private ThingType2Service thingtype2Service;

	@CrossOrigin(origins = "*")
	@ResponseBody
	@RequestMapping("add")
	public JsonBody add(@RequestBody Buying n) {
		if(buyingService.GetCount(n)>0)
			return Util.SetMap("该物品已存在购物车", false);
			if(buyingService.Add(n)>0)
				return Util.SetMap("成功加入购物车", true);
			else
				return Util.SetMap("加入购物车失败", false);
	}

	@CrossOrigin(origins = "*")
	@ResponseBody
	@RequestMapping("list")
	public JsonBody list(@RequestBody Buying n) {
		List<Buying> ns=buyingService.Get(n);
		for(Buying buying:ns)
		{
			buying.setClient(clientService.GetByID(buying.getClientId()));
			Thing t=thingService.GetByID(buying.getThingId());
			t.setThingtype(thingtypeService.GetByID(t.getThingtypeId()));
			t.setThingtype2(thingtype2Service.GetByID(t.getThingtype2Id()));
			buying.setThing(t);
		}
		Map<String,Object> map=new HashMap<String,Object>();
		map.put("buying", ns);
		map.put("sum", buyingService.GetSum(n));
		return Util.SetData(map);
	}


	@CrossOrigin(origins = "*")
	@ResponseBody
	@RequestMapping("editnum")
	public JsonBody EditNum(@RequestBody Buying buying) {
		if(buyingService.EditNum(buying)>0)
			return Util.SetMap("操作成功",true);
		else
			return Util.SetMap("操作失败",false);
	}


	@CrossOrigin(origins = "*")
	@ResponseBody
	@RequestMapping("del")
	public JsonBody del(int id) {
		if(buyingService.Del(id)>0)
			return Util.SetMap("删除成功", true);
		else
			return Util.SetMap("删除失败", false);
	}


}
package com.java.controller;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.*;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.ibatis.annotations.Param;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.system.ApplicationHome;
import org.springframework.stereotype.Controller;
import org.springframework.util.FileCopyUtils;
import org.springframework.web.bind.annotation.CrossOrigin;
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.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import com.alibaba.druid.support.logging.Resources;
import com.java.utils.CommonUtils;
import com.java.utils.JsonBody;
import com.java.utils.StringUtil;

@RestController
public class UploadController {
	String comp=StringUtil.GetProject();

	@Autowired
	private HttpServletRequest request;
	//上传文件
	@CrossOrigin(origins = "*")
	@RequestMapping("/upload")
	@ResponseBody
    public JsonBody uploadFile(@RequestBody MultipartFile files) throws IOException {

        try {
        	//E:\my_task\202206\wx19611600068\springboot\src\main\resources\META-INF\resources\file
			ApplicationHome applicationHome = new ApplicationHome(this.getClass());
			String absolutePath = applicationHome.getDir().getParentFile()
					.getParentFile().getAbsolutePath()+"\\src\\main\\resources\\META-INF\\resources\\file\\";
			File path = new File(absolutePath);

			if (!path.exists()) {
				path.mkdirs();//文件夹不存在,创建文件夹
			}
			String originalFilename = files.getOriginalFilename();//获得原始的文件名 "a.jpg"
			int index = originalFilename.lastIndexOf(".");
			String newName = originalFilename.substring(0, index) + "_" + UUID.randomUUID().toString() + originalFilename.substring(index);
			files.transferTo(new File(absolutePath + newName));//不出现异常,就是文件上传成功
			JsonBody jb=Util.SetMap("上传成功",true);
			jb.setData("/file/" + newName);
			return jb;
		} catch (Exception e) {
				return Util.SetMap("上传失败,请检查上传接口配置",false);
		}

    }

    private void copyFileUsingFileStreams(File source,File datedirs,String newfilename)
            throws IOException {
    	comp+=comp.toLowerCase().indexOf("webroot")<0?"/WebRoot/file/":"";//同时复制附件到项目下面
    	//新文件
        File newFile = new File(comp+File.separator+datedirs+File.separator+newfilename);
        //判断目标文件所在的目录是否存在
        if(!newFile.getParentFile().exists()) {
            //如果目标文件所在的目录不存在,则创建父目录
            newFile.getParentFile().mkdirs();
        }
        InputStream input = null;
        OutputStream output = null;
        try {
               input = new FileInputStream(source);
               output = new FileOutputStream(newFile);
               byte[] buf = new byte[1024];
               int bytesRead;
               while ((bytesRead = input.read(buf)) > 0) {
                   output.write(buf, 0, bytesRead);
               }
        } finally {
            input.close();
            output.close();
        }
    }


}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

程序猿毕业分享网

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值