此项目是前后端分离的
后台项目:shop
前端项目:Vue-shop
后端项目启动步骤:
1.先把sql导入数据库
2.把后台项目导入编辑器
3.修改数据库配置
4.启动项目
前端项目启动步骤:
1.打开Vue-shop目录,在这个文件夹里面加入cmd目录窗口
2.运行启动vue项目目录(需先安装nodejs软件)
先后执行下面命令
npm install
npm run dev
执行成功之后,命令窗口会显示前端网站信息,复制链接到浏览器打开即可
进入管理员界面网站
http://localhost:9528/login
账号密码:
admin
111111
演示视频:
【java毕业设计】基于SpringBoot vue的茶叶商城平台源码和论文含支付宝沙箱支付
从古至今,人类社会的进步离不开科学技术的发展,从现在的角度回望历史,每一次科技上的进步所引起的技术变革对人类社会都会造成巨大的影响,人们的生活也会发生翻天覆地的变化,社会的经济发展、生产力的提高都和科学技术的发展有着密切的联系。随着社会经济的不断发展,科学技术也在快速发展,科学技术的创新被越来越多的国家重视,从十八世纪的第一次技术革命开始一直到现在,人类越来越意识到科技改变世界,科技颠覆了人们很久以来的传统生活方式,人类的生活水平得到了很大程度的提高,社会的文明发展也在飞速的进行着。在现代社会中,随着计算机技术的飞速发展,各行各业都尝试用将计算机技术和各自的专业技术相结合,更好地提高工作效率。我国的计算机行业发展迅速,新时代的经济结构相对于以往也有所调整,计算机行业也改变了传统的行业模式,逐渐引进人工智能和机器学习等计算机技术。21世纪互联网时代的全面到来以及新时代社会的不断发展变革,传统网站以及不能满足用户的多元化需求。网站的内容日益丰富而多姿多彩,各大电商、浏览器商也在竞相的开发新的功能,供开发者使用并使用户拥有更好的使用体验,以此来满足各种各样不同需求的使用者。
淘宝、京东等购物网站的大获全胜使越来越多人把目光放在广而全的购物平台上,而忽略了传统单一而精的购物平台。人们开始越来越多的网上购物。目前,计算机普及率越来越高,计算机市场正处于蓬勃发展的大好阶段。众所周知,茶叶产品更新换代的速度很快,而实体店必要的店铺运营成本和员工人力成本也是不低的,对于茶叶产品而言,不需要面面俱到展示所有品牌,所有型号。设计类似与当当网这种只卖书籍的网站或许在未来会更具有竞争力。因为对于售后服务售前服务而言,茶叶产品和其它众多茶叶是无法相提并论的。因此将茶叶产品等茶叶设备放在购物网站上不失为一个明智的选择。
pom.xml :
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.java</groupId>
<artifactId>shop</artifactId>
<version>1.0-SNAPSHOT</version>
<description>shop</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.0.RELEASE</version>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<com.alibaba.fastjson>1.2.70</com.alibaba.fastjson>
<org.projectlombok.lombok>1.16.6</org.projectlombok.lombok>
<mysql.mysql-connector-java>8.0.29</mysql.mysql-connector-java>
<com.baomidou.mybatis-plus>3.1.1</com.baomidou.mybatis-plus>
<org.freemarker.freemarker>2.3.28</org.freemarker.freemarker>
<com.alibaba.druid>1.1.22</com.alibaba.druid>
<org.apache.tomcat.embed.tomcat>9.0.12</org.apache.tomcat.embed.tomcat>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${org.projectlombok.lombok}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>${com.alibaba.fastjson}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.alibaba/druid -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>${com.alibaba.druid}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.mysql-connector-java}</version>
</dependency>
<!-- mybatis plus -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>${com.baomidou.mybatis-plus}</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
<version>${com.baomidou.mybatis-plus}</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.freemarker</groupId>-->
<!-- <artifactId>freemarker</artifactId>-->
<!-- <version>${freemarker.version}</version>-->
<!-- </dependency>-->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<!-- <scope>provided</scope>-->
<version>${org.apache.tomcat.embed.tomcat}</version>
</dependency>
<!-- 添加jstl标签库依赖模块 -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>com.alipay.sdk</groupId>
<artifactId>alipay-sdk-java</artifactId>
<version>3.7.4.ALL</version>
</dependency>
</dependencies>
<build>
<finalName>runok</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.java.shopApplication</mainClass>
</configuration>
<version>1.4.2.RELEASE</version>
</plugin>
</plugins>
<resources>
<resource>
<directory>${basedir}/src/main/webapp</directory>
<targetPath>META-INF/resources</targetPath>
<includes>
<include>**/**</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<includes>
<include>**/**</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<excludes>
<exclude>**/*.woff</exclude>
<exclude>**/*.woff2</exclude>
<exclude>**/*.ttf</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<includes>
<include>**/*.woff</include>
<include>**/*.woff2</include>
<include>**/*.ttf</include>
</includes>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>aliyun</id>
<name>aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</repository>
</repositories>
</project>
沙箱支付代码:
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);
}
}