基于ssm土特产交易商城平台源码和论文

伴随着网购的盛行,用户的消费能力和意识发生了较大的转变。超前的的消费观和落后的交易能力造成产品愈来愈多。农业经济的发展, 促进了土特产交易市场的繁荣, 但是土特产在种植、销售和管理等各个环节, 存在的风险隐患较多, 土特产质量与安全受多重因素影响。 土特产的质量与安全直接决定着土特产效益的高低, 更好地对土特产质量进行有效管控就变得尤为重要。

本平台系统根据Web选用面向对象编程的观念,应用SSM架构,挑选Java这类十分时髦的Web应用程序开发语言表达。最先,对水果市场交易平台的利用状况实现了调研分析。次之,科学研究了当今的java技术,明确提出了根据土特产交易平台的研发计划方案,选用Spring MyBatis架构技术性和MySQL数据库管理方法数据信息。再度,利用UML建模技术性系统对实现了需求分析、功能分析和类设计方案。最后完成了一个功能完善的高校用品平台交易。通过测试步骤,土特产交易平台既能防止买东西产生的新冠疫情冲击性,又能高效率利用資源,合乎当今可持续发展观的规定。

此次设计从系统需求分析、系统设计到系统编程和调试测试等过程,综合锻炼了自身对一个系统的设计与开发的能力。本文的工作为更为复杂的土特产交易平台的建设打下了基础,完成了线上土特产交易的基本流程,达到所需的功能性要求。

关键词:SSM框架;土特产交易;MYSQL

【581】基于ssm土特产交易商城平台源码和论文

Abstract

With the prevalence of online shopping, the consumption ability and consciousness of users have changed greatly. The advanced consumption concept and backward trading ability cause more and more products. The development of agricultural economy has promoted the prosperity of agricultural products trading market, but there are many hidden risks in the planting, sales and management of agricultural products, and the quality and safety of agricultural products are affected by multiple factors. The quality and safety of agricultural products directly determine the efficiency of agricultural products. It is particularly important to effectively control the quality of agricultural products.

According to the web, this new project selects the concept of object-oriented programming, applies SSM architecture, and selects the very fashionable web application development language such as Java for expression. First of all, the utilization of book resources and Book platform transactions in Colleges and universities was investigated and analyzed. Secondly, it has scientifically studied the current Java technology and clearly put forward that according to the R & D plan of the agricultural products trading platform, spring mybatis architecture technology and MySQL database management method data information are selected. Thirdly, the technical system of UML modeling is used to realize the requirements analysis, function analysis and class design scheme. Finally, a fully functional college supplies platform transaction is completed. Through the test steps, the agricultural products trading platform can not only prevent the impact of COVID-19 caused by shopping, but also make efficient use of resources, which is in line with the provisions of today's concept of sustainable development.

This design from the system requirements analysis, system design to system programming and debugging test, comprehensively exercised its own ability to design and develop a system. The work of this paper has laid a foundation for the construction of a more complex agricultural products trading platform, completed the basic process of online book purchase, and achieved the required functional requirements.

Key words: SSM framework; Agricultural products trading; MYSQL

 

package com.shop.controller;

import com.alibaba.fastjson.JSONObject;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.request.AlipayTradePagePayRequest;
import com.shop.base.BaseController;
import com.shop.pojo.*;
import com.shop.service.*;
import com.shop.utils.AlipayConfig;
import com.shop.utils.Consts;
import com.shop.utils.Pager;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * 订单管理
 */
@Controller
@RequestMapping("/itemOrder")
public class ItemOrderController extends BaseController {
    @Autowired
    private ItemOrderService itemOrderService;
    @Autowired
    private UserService userService;
    @Autowired
    private CarService carService;
    @Autowired
    private OrderDetailService orderDetailService;
    @Autowired
    private ItemService itemService;

    /**
     * 订单管理列表
     */
    @RequestMapping("/findBySql")
    public String findBySql(ItemOrder itemOrder, Model model){
        //分页查询
        String sql = "select * from item_order where 1=1 ";
        if(!(isEmpty(itemOrder.getCode()))){
            sql +=" and code like '%"+itemOrder.getCode()+"%' ";
        }
        sql += " order by id desc";
        Pager<ItemOrder> pagers = itemOrderService.findBySqlRerturnEntity(sql);
        model.addAttribute("pagers",pagers);
        //存储查询条件
        model.addAttribute("obj",itemOrder);
        return "itemOrder/itemOrder";
    }
    @RequestMapping("/delete")
    public String delete(Integer id){
        itemOrderService.deleteById(id);
        return "redirect:/itemOrder/findBySql";
    }
    /**
     * 我的订单
     */
    @RequestMapping("/my")
    public String my(Model model, HttpServletRequest request){
        Object attribute = request.getSession().getAttribute(Consts.USERID);
        if(attribute==null){
            return "redirect:/login/uLogin";
        }
        Integer userId = Integer.valueOf(attribute.toString());
        //全部订单
        String sql = "select * from item_order where user_id="+userId+" order by id desc";
        List<ItemOrder> all = itemOrderService.listBySqlReturnEntity(sql);
        //待发货
        String sql2 = "select * from item_order where user_id="+userId+" and status=0 order by id desc";
        List<ItemOrder> dfh = itemOrderService.listBySqlReturnEntity(sql2);

        //已取消
        String sql3 = "select * from item_order where user_id="+userId+" and status=1 order by id desc";
        List<ItemOrder> yqx = itemOrderService.listBySqlReturnEntity(sql3);
        //已发货
        String sql4 = "select * from item_order where user_id="+userId+" and status=2 order by id desc";
        List<ItemOrder> dsh = itemOrderService.listBySqlReturnEntity(sql4);
        //已收货
        String sql5 = "select * from item_order where user_id="+userId+" and status=3 order by id desc";
        List<ItemOrder> ysh = itemOrderService.listBySqlReturnEntity(sql5);

        model.addAttribute("all",all);
        model.addAttribute("dfh",dfh);
        model.addAttribute("yqx",yqx);
        model.addAttribute("dsh",dsh);
        model.addAttribute("ysh",ysh);
        return "itemOrder/my";
    }

    /**
     * 购物车结算提交
     */
    @RequestMapping("/exAdd")
    @ResponseBody
    public String exAdd(@RequestBody List<CarDto> list,HttpServletRequest request){
        Object attribute = request.getSession().getAttribute(Consts.USERID);
        JSONObject js = new JSONObject();
        if(attribute==null){
            js.put(Consts.RES,0);
            return js.toJSONString();
        }
        Integer userId = Integer.valueOf(attribute.toString());
        User byId = userService.getById(userId);
        if(StringUtils.isEmpty(byId.getAddress())){
            js.put(Consts.RES,2);
            return js.toJSONString();
        }
        List<Integer> ids = new ArrayList<>();
        BigDecimal to = new BigDecimal(0);
        for(CarDto c:list){
            ids.add(c.getId());
            Car load = carService.load(c.getId());
            to = to.add(new BigDecimal(load.getPrice()).multiply(new BigDecimal(c.getNum())));
        }
        ItemOrder order = new ItemOrder();
        order.setStatus(-1);
        order.setCode(getOrderNo());
        order.setIsDelete(0);
        order.setTotal(to.setScale(2,BigDecimal.ROUND_HALF_UP).toString());
        order.setUserId(userId);
        order.setAddTime(new Date());
        itemOrderService.insert(order);

        //订单详情放入orderDetail,删除购物车
        if(!CollectionUtils.isEmpty(ids)){
            for(CarDto c:list){
                Car load = carService.load(c.getId());
                OrderDetail de = new OrderDetail();
                de.setItemId(load.getItemId());
                de.setOrderId(order.getId());
                de.setStatus(0);
                de.setNum(c.getNum());
                de.setTotal(String.valueOf(c.getNum()*load.getPrice()));
                orderDetailService.insert(de);
                //修改成交数
                Item load2 = itemService.load(load.getItemId());
                load2.setGmNum(load2.getGmNum()+c.getNum());
                itemService.updateById(load2);
                //删除购物车
                carService.deleteById(c.getId());
            }
        }
        js.put(Consts.RES,1);
        return js.toJSONString();
    }

    private static String date;
    private static long orderNum = 0L;
    public static synchronized String getOrderNo(){
        String str = new SimpleDateFormat("yyyyMMddHHmm").format(new Date());
        if(date==null||!date.equals(str)){
            date = str;
            orderNum = 0L;
        }
        orderNum++;
        long orderNO = Long.parseLong(date)*10000;
        orderNO += orderNum;
        return orderNO+"";
    }




    @RequestMapping("/orderpay")
    public void toPay(Integer id, HttpServletResponse httpResponse) {
        ItemOrder order =itemOrderService.load(id);



        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 orderNum1=null;
        String totalPrice1=null;
        String subject1= null;
        try {
            orderNum1 =String.valueOf(order.getId());
            totalPrice1 =order.getTotal();
            subject1 = new String("Cypress Order".getBytes("ISO-8859-1"),"UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        alipayRequest.setBizContent("{\"out_trade_no\":\""+ orderNum1 +"\","
                + "\"total_amount\":\""+ totalPrice1 +"\","
                + "\"subject\":\""+ subject1 +"\","
                + "\"body\":\"\","
                + "\"product_code\":\"FAST_INSTANT_TRADE_PAY\"}");

        String form = "";
        try {
            form = alipayClient.pageExecute(alipayRequest).getBody(); // 调用SDK生成表单
            httpResponse.setContentType("text/html;charset=UTF-8" );
            httpResponse.getWriter().write(form);// 直接将完整的表单html输出到页面
            httpResponse.getWriter().flush();
            httpResponse.getWriter().close();
        } catch (Exception e) {
            e.printStackTrace();
        }


    }

    @RequestMapping("paySuccess")
    public String paysuccess(HttpServletRequest request,Model model) throws Exception{

       System.out.println("支付成功回调!!!!!!!!!!!");
        request.setCharacterEncoding("utf-8");//乱码解决,这段代码在出现乱码时使用
        //获取支付宝POST过来反馈信息
        Map<String,String> params = new HashMap<String,String>();
        Map<String,String[]> requestParams = request.getParameterMap();
        // 商户订单号
        String out_trade_no = new String(request.getParameter("out_trade_no").getBytes("ISO-8859-1"), "UTF-8");


        ItemOrder order =itemOrderService.load(Integer.valueOf(out_trade_no));
        order.setStatus(0);
        itemOrderService.updateById(order);
        model.addAttribute("obj",order);
        return "redirect:/itemOrder/my";
    }













    /**
     * 取消订单
     */
    @RequestMapping("/qx")
    public String qx(Integer id,Model model){
        ItemOrder obj =itemOrderService.load(id);
        obj.setStatus(1);
        itemOrderService.updateById(obj);
        model.addAttribute("obj",obj);
        return "redirect:/itemOrder/my";
    }

    /**
     * 后台发货
     */
    @RequestMapping("/fh")
    public String fh(Integer id,Model model){
        ItemOrder obj =itemOrderService.load(id);
        obj.setStatus(2);
        itemOrderService.updateById(obj);
        model.addAttribute("obj",obj);
        return "redirect:/itemOrder/findBySql";
    }

    /**
     * 用户收货
     */
    @RequestMapping("/sh")
    public String sh(Integer id,Model model){
        ItemOrder obj =itemOrderService.load(id);
        obj.setStatus(3);
        itemOrderService.updateById(obj);
        model.addAttribute("obj",obj);
        return "redirect:/itemOrder/my";
    }

    /**
     * 用户评价入口
     */
    @RequestMapping("/pj")
    public String pj(Integer id,Model model){
        model.addAttribute("id",id);
        return "itemOrder/pj";
    }
}














  • 22
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

程序猿毕业分享网

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

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

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

打赏作者

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

抵扣说明:

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

余额充值