基于springboot农副产品交易平台的微信小程序源码和论文

基于微信的农产品交易商城设计与开发

摘要:伴随着移动互联网的进一步发展趋势,传统式手机应用程序的问题慢慢出現在技术性关心的行业。原生态Android运用的安裝和卸载掉危害用户体验,一个轻量的内嵌式WEB程序流程为用户体验吸引住了愈来愈多开发人员的关心。自打微信小程序明确提出后,愈来愈多的互联网公司竞相开发设计单独的微信小程序运用,大有作为。

根据现阶段盛行的微信小程序应用程序开发技术性,融合农产品买卖商城系统的用户需求,开发设计了一套易于器重、可配备、面对小店的农产品买卖商城系统开发。系统软件根据现阶段流行的Java后端工程师框架SpringBoot、流行的数据库配备框架MyBatis和实用的MySQL数据库搭建后台管理网络服务器新项目,应用Vue网站前端开发框架和Element-ui插口原素完成小程序管理员的操作系统插口,依据微信小程序给予的设计方案文档制作原生态农产品买卖商城小程序。微信小程序可以达到现阶段小店的商业要求,完成控制模块的信息配备,易于二次开发。有利于迅速构建成形系统软件,具备一定的社会经济实际效果。

【587】基于springboot农副产品交易平台的微信小程序源码和论文

关键词:农产品交易商城,小程序,动态配置,SpringBoot,Vue


Design and Development of Online Mall Based on WeChat

Abstract:  With the further development trend of mobile Internet, the problems of traditional mobile phone applications are slowly emerging in industries of technical concern. The installation and uninstallation of the original Android application endanger the user experience. A lightweight embedded web program process has attracted more and more developers' attention for the user experience. Since the wechat applet was clearly put forward, more and more Internet companies have competed to develop and design separate wechat applets, which have made great achievements。

According to the popular wechat applet application development technology at this stage, and integrating the user needs of the second-hand book trading mall system, a set of second-hand book trading mall system development which is easy to value, can be equipped and facing small stores is developed and designed. The system software builds a new project of background management network server according to the popular Java back-end engineer framework springboot, the popular database configuration framework mybatis and the practical MySQL database at the present stage, applies the Vue website front-end development framework and element UI socket elements to complete the operating system socket of the applet administrator, and makes the original ecological second-hand book shopping mall applet according to the design scheme documents given by the wechat applet. Wechat applet can meet the business requirements of small stores at this stage, complete the information configuration of control module, and is easy to secondary development. It is conducive to the rapid construction of forming system software, and has a certain social and economic practical effect。

Keywords: online mall, mini program, dynamic allocation, SpringBoot, Vue

package com.ndky.shop_back.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ndky.shop_back.dao.GoodDao;
import com.ndky.shop_back.entity.Good;
import com.ndky.shop_back.entity.QueryInfo;
import com.ndky.shop_back.service.GoodService;
import com.ndky.shop_back.util.Consts;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;

@RestController
public class GoodController {
    @Autowired
    GoodService goodService;

    @RequestMapping("/allGood")
    public String getGoodList(QueryInfo queryInfo) {
        // 获取最大列表数和当前编号
        int number = goodService.getGoodCounts("%" + queryInfo.getQuery() + "%");
        int pageState = (queryInfo.getPageNum() - 1) * queryInfo.getPageSize();

        List<Good> good = goodService.getAllGood("%" + queryInfo.getQuery() + "%", pageState, queryInfo.getPageSize());
        HashMap<String, Object> res = new HashMap<>();
        res.put("number", number);
        res.put("data", good);
        String res_string = JSON.toJSONString(res);
        return res_string;
    }

    @RequestMapping("/goodState")
    public String updateGoodState(@RequestParam("good_id") Integer good_id,
                                  @RequestParam("good_state") Boolean good_state) {
        int i = goodService.updateState(good_id, good_state);
        return i > 0 ? "success" : "error";
    }

    @RequestMapping("/addGood")
    public String addGood(@RequestBody Good good) {
        int i = goodService.addGood(good);


        return i > 0 ? "success" : "error";
    }

    @RequestMapping("/deleteGood")
    public String deleteGood(int good_id) {
        int i = goodService.deleteGood(good_id);
        return i > 0 ? "success" : "error";
    }

    @RequestMapping("/getUpdateGood")
    public String getUpdateGood(int good_id) {
        Good good=goodService.getUpdateGood(good_id);
        String string = JSON.toJSONString(good);//注意这里也可以直接返回对象,springboot会把对象直接转换成字符串
        return string;
    }

    @RequestMapping("/editGood")
    public String editUser(@RequestBody Good good) {
        int i = goodService.editGood(good);
        return i > 0 ? "success" : "error";
    }


    //查询所有商品,返回到微信小程序
    @RequestMapping("/selectAllGood")
    public String selectAllGood(){
        List<Good> list=goodService.selectAllGood();
        String string = JSON.toJSONString(list);//注意这里也可以直接返回对象,springboot会把对象直接转换成字符串
        return string;
    }
    //按照class_name查询商品,填充商品分类右边栏目
    @RequestMapping("/selectGoodByClass")
    public String selectGoodByClass(@Param("class_name") String class_name){
        List<Good> list=goodService.selectGoodByClass(class_name);
        String string = JSON.toJSONString(list);
        return string;
    }

    @RequestMapping("/selectGoodById")
    public String selectGoodById(@Param("good_id") Integer good_id){
        Good good=goodService.selectGoodById(good_id);
        String string = JSON.toJSONString(good);
        return string;
    }

    @RequestMapping("/searchGood")
    public String searchGood(@Param("query") String query){
        List<Good> list=goodService.searchGood(query);
        String string = JSON.toJSONString(list);
        return string;
    }


    @RequestMapping("/setGoodStar")
    public String setGoodStar(@Param("good_id") Integer good_id,@Param("good_star")Integer good_star){
        int i = goodService.setGoodStar(good_id, good_star);
        return i > 0 ? "success" : "error";
    }


    @RequestMapping("/getGoodByStar")
    public String getGoodByStar(QueryInfo queryInfo){
        // 获取最大列表数和当前编号
        int number = goodService.getGoodCounts("%" + queryInfo.getQuery() + "%");
        int pageState = (queryInfo.getPageNum() - 1) * queryInfo.getPageSize();

        List<Good> good = goodService.getGoodByStar("%" + queryInfo.getQuery() + "%", pageState, queryInfo.getPageSize());
        HashMap<String, Object> res = new HashMap<>();
        res.put("number", number);
        res.put("data", good);
        String res_string = JSON.toJSONString(res);
        return res_string;
    }

    @RequestMapping("/getStarByGoodId")
    public Integer getStarByGoodId(@Param("good_id") Integer good_id){
        return goodService.getStarByGoodId(good_id);
    }


    //更新商品图片
    @RequestMapping("/updateGoodImage")
    public Object updateGoodImage(@RequestParam("file") MultipartFile avatorFile, @RequestParam("good_id")int id){
        JSONObject jsonObject = new JSONObject();
        if(avatorFile.isEmpty()){
            jsonObject.put(Consts.CODE,0);
            jsonObject.put(Consts.MSG,"文件上传失败");
            return jsonObject;
        }
        //文件名=当前时间到毫秒+原来的文件名
        String fileName = System.currentTimeMillis()+avatorFile.getOriginalFilename();
        //文件路径
        String filePath = System.getProperty("user.dir")+System.getProperty("file.separator")+"img"
                +System.getProperty("file.separator")+"goodImage";
        //如果文件路径不存在,新增该路径
        File file1 = new File(filePath);
        if(!file1.exists()){
            file1.mkdir();
        }
        //实际的文件地址
        File dest = new File(filePath+System.getProperty("file.separator")+fileName);
        //存储到数据库里的相对文件地址
        String storeAvatorPath = Consts.URL+"/img/goodImage/"+fileName;
        try {
            avatorFile.transferTo(dest);
            Good good=new Good();
            good.setGood_id(id);
            good.setGood_image(storeAvatorPath);

            int flag = goodService.editGood(good);
            if(flag>0){
                jsonObject.put(Consts.CODE,1);
                jsonObject.put(Consts.MSG,"上传成功");
                jsonObject.put("pic",storeAvatorPath);
                return jsonObject;
            }
            jsonObject.put(Consts.CODE,0);
            jsonObject.put(Consts.MSG,"上传失败");
            return jsonObject;
        } catch (IOException e) {
            jsonObject.put(Consts.CODE,0);
            jsonObject.put(Consts.MSG,"上传失败"+e.getMessage());
        }finally {
            return jsonObject;
        }
    }


}

package com.ndky.shop_back.controller;

import com.alibaba.fastjson.JSON;
import com.ndky.shop_back.entity.Good;
import com.ndky.shop_back.entity.Order;
import com.ndky.shop_back.entity.QueryInfo;
import com.ndky.shop_back.service.OrderService;
import com.sun.org.apache.xpath.internal.operations.Or;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

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

@RestController
public class OrderController {

    @Autowired
    OrderService orderService;


    @RequestMapping("/getAllOrder")
    public String getAllOrder(QueryInfo queryInfo) {
        // 获取最大列表数和当前编号
        int number = orderService.getOrderCounts("%" + queryInfo.getQuery() + "%");
        int pageState = (queryInfo.getPageNum() - 1) * queryInfo.getPageSize();

        List<Order> order = orderService.getAllOrder("%" + queryInfo.getQuery() + "%", pageState, queryInfo.getPageSize());
        HashMap<String, Object> res = new HashMap<>();
        res.put("number", number);
        res.put("data", order);
        String res_string = JSON.toJSONString(res);
        return res_string;
    }


    @RequestMapping("/addOrder")
    public String addOrder(@Param("user_name") String user_name, @Param("user_phone") String user_phone, @Param("order_address") String order_address, @Param("order_text") String order_text, @Param("order_value") Double order_value, @Param("order_state") String order_state,@Param("self_phone") String self_phone) {
        int i = orderService.addOrder(user_name, user_phone, order_address, order_text, order_value, order_state,self_phone);
        return i > 0 ? "success" : "error";
    }


    @RequestMapping("/deleteOrder")
    public int deleteOrder(int order_id) {
        return orderService.deleteOrder(order_id);
    }

    @RequestMapping("/orderGiveGood")
    public String orderGiveGood(int order_id) {
        int i = orderService.orderGiveGood(order_id);
        return i>0?"success":"error";
    }


    @RequestMapping("/getAllOrderNew")
    public String getAllOrderNew(QueryInfo queryInfo) {
        // 获取最大列表数和当前编号
        int number = orderService.getOrderCountsNew("%" + queryInfo.getQuery() + "%");
        int pageState = (queryInfo.getPageNum() - 1) * queryInfo.getPageSize();

        List<Order> order = orderService.getAllOrderNew("%" + queryInfo.getQuery() + "%", pageState, queryInfo.getPageSize());
        HashMap<String, Object> res = new HashMap<>();
        res.put("number", number);
        res.put("data", order);
        String res_string = JSON.toJSONString(res);
        return res_string;
    }


    @RequestMapping("/getAllOrderOld")
    public String getAllOrderOld(QueryInfo queryInfo) {
        // 获取最大列表数和当前编号
        int number = orderService.getOrderCountsOld("%" + queryInfo.getQuery() + "%");
        int pageState = (queryInfo.getPageNum() - 1) * queryInfo.getPageSize();

        List<Order> order = orderService.getAllOrderOld("%" + queryInfo.getQuery() + "%", pageState, queryInfo.getPageSize());
        HashMap<String, Object> res = new HashMap<>();
        res.put("number", number);
        res.put("data", order);
        String res_string = JSON.toJSONString(res);
        return res_string;
    }

    @RequestMapping("/getAllWxOrder")
    public String getAllWxOrder(@Param("self_phone") String self_phone){
        List<Order> list= orderService.getAllWxOrder(self_phone);
        String res_string = JSON.toJSONString(list);
        return res_string;
    }

    @RequestMapping("/getAllWxOrderOld")
    public String getAllWxOrderOld(@Param("self_phone") String self_phone){
        List<Order> list= orderService.getAllWxOrderOld(self_phone);
        String res_string = JSON.toJSONString(list);
        return res_string;
    }
    @RequestMapping("/getAllWxOrderNew")
    public String getAllWxOrderNew(@Param("self_phone") String self_phone){
        List<Order> list= orderService.getAllWxOrderNew(self_phone);
        String res_string = JSON.toJSONString(list);
        return res_string;
    }


}