摘 要
随着互联网技术的不断变革与发展,全世界人类的生产生活正在经历着翻天覆地的重大变革,如今互联网时代的全面到来便利了生活的方方面面。社会经济的发展和文明的进步为人们生活的改变提供了很大的动力。人们开始越来越多的网上购物,但市面上只售卖家居产品的网站还是屈指可数的。从长远来看,企业对消费者的电子商务将最终在电子商务领域占据重要地位。但是由于各种因素的制约,目前以及比较长的一段时间内,这个层次的业务还只能占比较小的比重。它是以互联网为主要服务提供手段,实现公众消费和提供服务,并保证与其相关的付款方式的电子化。它是随着万维网(WWW)的出现而迅速发展的,可以将其看作是一种电子化的零售。目前,计算机普及率越来越高,计算机的市场正处于蓬勃发展的大好阶段。因此开发一个基于Spring Boot框架的家居商城系统是很有必要的。
根据以上,在查阅了许多网站开发的相关资料的基础上,提出了基于Java技术,采用B/S构建结构,选用Spring Boot框架,Mybatis框架,运用VUE技术,UML技术和MySQL数据库来开发一个家居商城网站,不同于市面上的京东、淘宝等购物网站,而是针对家居产品购物的新型家居购物商城,包含管理员、用户模块实现了商城的基本功能,使得家居产品家居的交易更加方便,有效,成本更低,将成为家居产品家居销售的崭新模式,具有一定的实际意义和推广价值。
关键词:家居商城 Java Spring Boot框架 MySQL
【526】基于SpringBoot vue的家居商城平台源码和论文含支付宝沙箱支付
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("/news")
public class NewsController {
private NewsService newsService;
public NewsService getNewsService() {
return newsService;
}
@Autowired
public void setNewsService(NewsService newsService) {
this.newsService = newsService;
}
@Autowired
private NewsTypeService newstypeService;
@Autowired
private HttpServletRequest request;
@Autowired
private HttpServletResponse response;
@CrossOrigin(origins = "*")
@ResponseBody
@RequestMapping("getbyid")
public JsonBody getbyid(int id) {
Map<String,Object> map = new HashMap<String,Object>();
map.put("add", newsService.GetByID(id));
map.put("newstype", newstypeService.Get());
return Util.SetData(map);
}
@CrossOrigin(origins = "*")
@ResponseBody
@RequestMapping("add")
public JsonBody add(@RequestBody News n) {
int count=0;
if(n.getId()==0)
count = newsService.Add(n);
else
count=newsService.Edit(n);
if(count>0)
return Util.SetMap("保存成功", true);
else
return Util.SetMap("保存失败", false);
}
@CrossOrigin(origins = "*")
@ResponseBody
@RequestMapping("list")
public JsonBody list(News n) {
List<News> ns=newsService.Get(n);
for(News news:ns)
news.setNewstype(newstypeService.GetByID(news.getId()));
return Util.SetData(ns);
}
@CrossOrigin(origins = "*")
@ResponseBody
@RequestMapping("zan")
public JsonBody Zan(int id) {
if(request.getHeader("X-Token")==null)
return Util.SetMap("请先登录",false);
if(newsService.EditZan(id)>0)
return Util.SetMap("点赞成功",true);
else
return Util.SetMap("点赞失败",false);
}
@CrossOrigin(origins = "*")
@ResponseBody
@RequestMapping("del")
public JsonBody del(int id) {
if(newsService.Del(id)>0)
return Util.SetMap("删除成功", true);
else
return Util.SetMap("删除失败", false);
}
}