本文主要是介绍沙箱支付springboot药品销售系统药品商城java药店系统,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
开发技术:ssm springboot2.1.4 springMVC mybatis 前端jsp页面
开发工具:eclipse或idea mysql5.x maven环境
管理员功能:
用户管理:用户列表 可删除用户
商品管理:查看 修改 删除 添加活动,添加商品分类,添加商品
信息 库存量 图片等信息
活动管理:添加活动,每个商品可以对应活动。
(只能满足一个活动。用户实际付款会判断是否享有活动,对应实
付金额计算。)
订单管理:查询用户未发货 待收货 已完成订单,可对未发货商品
发货。
退出系统
用户端:
登录注册:登录需要输入验证码,注册校验密码长度
商城首页模糊搜索商品
对商品分类搜索
查看商品详情信息 描述 评论等信息
用户购买商品可以加入购物车 加入收藏
结算购物车时会校验商品库存量
下单后结算金额时,会判断是否享有活动,计算实付金额
用户中心:
可以查看个人信息,修改信息,修改密码
地址管理:用户收货地址管理,添加 修改 删除地址 可以添加多个
地址,下单的时候选择一个。
用户订单管理:查看自己下单信息 未完成 已完成订单,
用户购买-->后台发货-用户收货-订单完成
对完成订单的商品可以评论 评论后,可以在对应的商品详情页下方
展示
对已完成订单评论 删除。
收藏管理:对商品收藏,也可以删除
主页:http://localhost:8080/shop/
后台地址
http://localhost:8080/shop/admin/login admin 12345678
支付宝沙箱环境配置步骤:
账号密码申请以及 秘钥等。
https://opendocs.alipay.com/open/200/105311
https://www.cnblogs.com/thcy1314/articles/10511146.html
在代码中
第一步 : 引入依赖
<dependency>
<groupId>com.alipay.sdk</groupId>
<artifactId>alipay-sdk-java</artifactId>
<version>3.1.0</version>
</dependency>
第二步:配置支付宝沙箱支付配置类
秘钥 回调地址等信息
已配置好可以直接用
第三步 加入业务
得到result支付的二维码页面
package com.shop.controller.front;import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.shop.entity.*;
import com.shop.entity.*;
import com.shop.service.AddressService;
import com.shop.service.GoodsService;
import com.shop.service.OrderService;
import com.shop.service.UserService;
import com.shop.util.Md5Util;
import com.shop.util.Msg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;@Controller
public class CustomerController {@RequestMapping("/login")public String loginView() {return "login";}@Autowiredprivate UserService userService;@RequestMapping("/register")public String register() {return "register";}@RequestMapping("/registerresult")public String registerResult(User user, Model registerResult) {List<User> userList = new ArrayList<>();user.setPassword(Md5Util.MD5Encode(user.getPassword(), "utf-8"));UserExample userExample = new UserExample();userExample.or().andUsernameLike(user.getUsername());userList = userService.selectByExample(userExample);if (!userList.isEmpty()) {registerResult.addAttribute("errorMsg", "用户名被占用");return "register";} else {Date RegTime = new Date();user.setRegtime(RegTime);userService.insertSelective(user);return "redirect:/login";}}@RequestMapping("/loginconfirm")public String loginConfirm(User user, Model loginResult, HttpServletRequest request, @RequestParam("confirmlogo") String confirmlogo) {System.out.println("传进来的用户帐号和密码为:" + user);//进行用户密码MD5加密验证user.setPassword(Md5Util.MD5Encode(user.getPassword(), "UTF-8"));HttpSession session = request.getSession();String verificationCode = (String) session.getAttribute("certCode");if (!confirmlogo.equals(verificationCode)) {loginResult.addAttribute("errorMsg", "验证码错误");return "login";}List<User> userList = new ArrayList<User>();UserExample userExample = new UserExample();userExample.or().andUsernameEqualTo(user.getUsername()).andPasswordEqualTo(user.getPassword());userList = userService.selectByExample(userExample);if (!userList.isEmpty()) {session.setAttribute("user", userList.get(0));return "redirect:/main";} else {loginResult.addAttribute("errorMsg", "用户名与密码不匹配");return "login";}}@RequestMapping("/information")public String information(Model userModel, HttpServletRequest request) {HttpSession session = request.getSession();User user;Integer userId;user = (User) session.getAttribute("user");if (user == null) {return "redirect:/login";}userId = user.getUserid();user = userService.selectByPrimaryKey(userId);userModel.addAttribute("user", user);return "information";}@RequestMapping("/saveInfo")@ResponseBodypublic Msg saveInfo(String name, String email, String telephone, HttpServletRequest request) {try {HttpSession session = request.getSession();User user = (User) session.getAttribute("user");Integer userid = user.getUserid();User user1 = userService.selectByPrimaryKey(userid);user1.setEmail(email);user1.setTelephone(telephone);userService.updateByPrimaryKeySelective(user1);return Msg.success("更新成功");} catch (Exception e) {e.printStackTrace();return Msg.fail("更新失败");}}@Autowiredprivate AddressService addressService;@RequestMapping("/info/address")public String address(HttpServletRequest request, Model addressModel) {HttpSession session = request.getSession();User user = (User) session.getAttribute("user");if (user == null) {return "redirect:/login";}AddressExample addressExample = new AddressExample();addressExample.or().andUseridEqualTo(user.getUserid());List<Address> addressList = addressService.getAllAddressByExample(addressExample);addressModel.addAttribute("addressList", addressList);return "address";}@RequestMapping("/saveAddr")@ResponseBodypublic Msg saveAddr(Address address) {addressService.updateByPrimaryKeySelective(address);return Msg.success("修改成功");}@RequestMapping("/deleteAddr")@ResponseBodypublic Msg deleteAddr(Address address) {addressService.deleteByPrimaryKey(address.getAddressid());return Msg.success("删除成功");}@RequestMapping("/insertAddr")@ResponseBodypublic Msg insertAddr(Address address, HttpServletRequest request) {HttpSession session = request.getSession();User user = new User();user = (User) session.getAttribute("user");address.setUserid(user.getUserid());addressService.insertSelective(address);return Msg.success("添加成功");}@Autowiredprivate OrderService orderService;@Autowiredprivate GoodsService goodsService;@RequestMapping("/info/list")public String list(HttpServletRequest request, Model orderModel) {HttpSession session = request.getSession();User user;user = (User) session.getAttribute("user");if (user == null) {return "redirect:/login";}OrderExample orderExample = new OrderExample();orderExample.or().andUseridEqualTo(user.getUserid());List<Order> orderList = orderService.selectOrderByExample(orderExample);orderModel.addAttribute("orderList", orderList);Order order;OrderItem orderItem;List<OrderItem> orderItemList = new ArrayList<>();Goods goods;Address address;for (Integer i = 0; i < orderList.size(); i++) {order = orderList.get(i);OrderItemExample orderItemExample = new OrderItemExample();orderItemExample.or().andOrderidEqualTo(order.getOrderid());orderItemList = orderService.getOrderItemByExample(orderItemExample);List<Goods> goodsList = new ArrayList<>();List<Integer> goodsIdList = new ArrayList<>();for (Integer j = 0; j < orderItemList.size(); j++) {orderItem = orderItemList.get(j);Goods good = goodsService.selectById(orderItem.getGoodsid());good.setCategory(orderItem.getNum());goodsList.add(good);}order.setGoodsInfo(goodsList);address = addressService.selectByPrimaryKey(order.getAddressid());order.setAddress(address);orderList.set(i, order);}orderModel.addAttribute("orderList", orderList);return "list";}@RequestMapping("/deleteList")@ResponseBodypublic Msg deleteList(Order order) {orderService.deleteById(order.getOrderid());return Msg.success("删除成功");}/*** 收藏商品* @param pn* @param request* @param model* @return*/@RequestMapping("/info/favorite")public String showFavorite(@RequestParam(value = "page", defaultValue = "1") Integer pn, HttpServletRequest request, Model model) {HttpSession session = request.getSession();User user = (User) session.getAttribute("user");if (user == null) {return "redirect:/login";}//一页显示几个数据PageHelper.startPage(pn, 16);FavoriteExample favoriteExample = new FavoriteExample();favoriteExample.or().andUseridEqualTo(user.getUserid());List<Favorite> favoriteList = goodsService.selectFavByExample(favoriteExample);List<Integer> goodsIdList = new ArrayList<Integer>();for (Favorite tmp : favoriteList) {goodsIdList.add(tmp.getGoodsid());}List<Goods> goodsList = new ArrayList<>();if(goodsIdList!=null && goodsIdList.size()>0){for (Integer id:goodsIdList) {goodsList.add( goodsService.selectById(id)) ;}}//获取图片地址for (int i = 0; i < goodsList.size(); i++) {Goods goods = goodsList.get(i);List<ImagePath> imagePathList = goodsService.findImagePath(goods.getGoodsid());goods.setImagePaths(imagePathList);//判断是否收藏goods.setFav(true);goodsList.set(i, goods);}//显示几个页号PageInfo page = new PageInfo(goodsList, 5);model.addAttribute("pageInfo", page);return "favorite";}@RequestMapping("/savePsw")@ResponseBodypublic Msg savePsw(String Psw, HttpServletRequest request) {HttpSession session = request.getSession();User user = (User) session.getAttribute("user");user.setPassword(Md5Util.MD5Encode(Psw, "UTF-8"));userService.updateByPrimaryKeySelective(user);return Msg.success("修改密码成功");}@RequestMapping("/finishList")@ResponseBodypublic Msg finishiList(Integer orderid) {Order order = orderService.selectByPrimaryKey(orderid);order.setIsreceive(true);order.setIscomplete(true);orderService.updateOrderByKey(order);return Msg.success("完成订单成功");}@RequestMapping("/logout")public String logout(HttpServletRequest request) {HttpSession session = request.getSession();session.removeAttribute("user");return "redirect:/login";}}
这篇关于沙箱支付springboot药品销售系统药品商城java药店系统的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!