首页 > 编程语言 >基于微信小程序实现信阳毛尖茶叶商城系统设计与实现

基于微信小程序实现信阳毛尖茶叶商城系统设计与实现

时间:2024-10-24 20:50:35浏览次数:3  
标签:return 毛尖 程序实现 微信 cart new import id view

作者主页:编程千纸鹤

作者简介:Java领域优质创作者、CSDN博客专家 、CSDN内容合伙人、掘金特邀作者、阿里云博客专家、51CTO特邀作者、多年架构师设计经验、多年校企合作经验,被多个学校常年聘为校外企业导师,指导学生毕业设计并参与学生毕业答辩指导,有较为丰富的相关经验。期待与各位高校教师、企业讲师以及同行交流合作

主要内容:Java项目、Python项目、前端项目、PHP、ASP.NET、人工智能与大数据、单片机开发、物联网设计与开发设计、简历模板、学习资料、面试题库、技术互助、就业指导等

业务范围:免费功能设计、开题报告、任务书、中期检查PPT、系统功能实现、代码编写、论文编写和辅导、论文降重、长期答辩答疑辅导、腾讯会议一对一专业讲解辅导答辩、模拟答辩演练、和理解代码逻辑思路等

收藏点赞不迷路  关注作者有好处

文末获取源码 

项目编号:BS-XCX-068

一,环境介绍

语言环境:微信小程序

数据库:Mysql: mysql5.7

WEB框架:SpringBoot+Vue

开发工具:IDEA和微信开发者工具

二,项目简介

基于微信小程序实现信阳毛尖茶叶商城系统的设计与实现,选题背景源于当前电子商务的快速发展以及消费者对高品质茶叶日益增长的需求。信阳毛尖作为中国十大名茶之一,以其独特的色、香、味、形和丰富的营养成分深受消费者喜爱。然而,传统的茶叶销售模式存在成本高、效率低等问题,难以满足现代消费者便捷、高效的购物需求。因此,开发一款基于微信小程序的信阳毛尖茶叶商城系统,不仅有助于提升茶叶的销售效率,还能为消费者提供更为便捷、个性化的购物体验。

该系统的主要功能包括:茶叶产品展示,通过精美的图片、视频和详细介绍,帮助用户全面了解信阳毛尖的品质和特色;分类筛选功能,用户可按茶叶种类、产地、品牌等分类快速找到所需茶叶;购物车功能,支持用户将多种茶叶添加至购物车,统一结算;多种支付方式,如微信支付、支付宝等,方便用户完成支付;会员等级制度和积分系统,激励用户成为忠实客户;实时物流跟踪和自动通知系统,确保用户能够随时查看订单状态和物流信息;用户评价和商家回复功能,帮助其他用户更好地选择茶叶,同时提升用户满意度。

此外,该系统还引入了人工智能技术,根据用户的购买记录和浏览习惯推荐个性化的茶叶产品,提高转化率。同时,通过与微信平台和其他社交平台的整合,实现跨平台的销售和推广,进一步扩大市场覆盖面。通过茶叶小程序商城,结合茶文化知识普及和茶艺展示,提升用户对信阳毛尖的认知和兴趣,促进茶叶消费,推动茶叶产业的持续发展。

三,系统展示

四,核心代码展示


package com.controller;

import java.io.File;
import java.math.BigDecimal;
import java.net.URL;
import java.text.SimpleDateFormat;
import com.alibaba.fastjson.JSONObject;
import java.util.*;
import org.springframework.beans.BeanUtils;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.context.ContextLoader;
import javax.servlet.ServletContext;
import com.service.TokenService;
import com.utils.*;
import java.lang.reflect.InvocationTargetException;

import com.service.DictionaryService;
import org.apache.commons.lang3.StringUtils;
import com.annotation.IgnoreAuth;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.entity.*;
import com.entity.view.*;
import com.service.*;
import com.utils.PageUtils;
import com.utils.R;
import com.alibaba.fastjson.*;

/**
 * 购物车
 * 后端接口
 * @author
 * @email
*/
@RestController
@Controller
@RequestMapping("/cart")
public class CartController {
    private static final Logger logger = LoggerFactory.getLogger(CartController.class);

    private static final String TABLE_NAME = "cart";

    @Autowired
    private CartService cartService;


    @Autowired
    private TokenService tokenService;

    @Autowired
    private AddressService addressService;//收货地址
    @Autowired
    private ChayeService chayeService;//茶叶
    @Autowired
    private ChayeCollectionService chayeCollectionService;//茶叶收藏
    @Autowired
    private ChayeCommentbackService chayeCommentbackService;//茶叶评价
    @Autowired
    private ChayeOrderService chayeOrderService;//茶叶订单
    @Autowired
    private DictionaryService dictionaryService;//字典
    @Autowired
    private ForumService forumService;//论坛
    @Autowired
    private GonggaoService gonggaoService;//公告
    @Autowired
    private LishijieshaoService lishijieshaoService;//茗茶历史
    @Autowired
    private YonghuService yonghuService;//用户
    @Autowired
    private UsersService usersService;//管理员


    /**
    * 后端列表
    */
    @RequestMapping("/page")
    public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
        logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
        String role = String.valueOf(request.getSession().getAttribute("role"));
        if(false)
            return R.error(511,"永不会进入");
        else if("用户".equals(role))
            params.put("yonghuId",request.getSession().getAttribute("userId"));
        CommonUtil.checkMap(params);
        PageUtils page = cartService.queryPage(params);

        //字典表数据转换
        List<CartView> list =(List<CartView>)page.getList();
        for(CartView c:list){
            //修改对应字典表字段
            dictionaryService.dictionaryConvert(c, request);
        }
        return R.ok().put("data", page);
    }

    /**
    * 后端详情
    */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id, HttpServletRequest request){
        logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
        CartEntity cart = cartService.selectById(id);
        if(cart !=null){
            //entity转view
            CartView view = new CartView();
            BeanUtils.copyProperties( cart , view );//把实体数据重构到view中
            //级联表 用户
            //级联表
            YonghuEntity yonghu = yonghuService.selectById(cart.getYonghuId());
            if(yonghu != null){
            BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createTime", "insertTime", "updateTime", "yonghuId"});//把级联的数据添加到view中,并排除id和创建时间字段,当前表的级联注册表
            view.setYonghuId(yonghu.getId());
            }
            //级联表 茶叶
            //级联表
            ChayeEntity chaye = chayeService.selectById(cart.getChayeId());
            if(chaye != null){
            BeanUtils.copyProperties( chaye , view ,new String[]{ "id", "createTime", "insertTime", "updateTime", "yonghuId"});//把级联的数据添加到view中,并排除id和创建时间字段,当前表的级联注册表
            view.setChayeId(chaye.getId());
            }
            //修改对应字典表字段
            dictionaryService.dictionaryConvert(view, request);
            return R.ok().put("data", view);
        }else {
            return R.error(511,"查不到数据");
        }

    }

    /**
    * 后端保存
    */
    @RequestMapping("/save")
    public R save(@RequestBody CartEntity cart, HttpServletRequest request){
        logger.debug("save方法:,,Controller:{},,cart:{}",this.getClass().getName(),cart.toString());

        String role = String.valueOf(request.getSession().getAttribute("role"));
        if(false)
            return R.error(511,"永远不会进入");
        else if("用户".equals(role))
            cart.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));

        Wrapper<CartEntity> queryWrapper = new EntityWrapper<CartEntity>()
            .eq("yonghu_id", cart.getYonghuId())
            .eq("chaye_id", cart.getChayeId())
            .eq("buy_number", cart.getBuyNumber())
            ;

        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        CartEntity cartEntity = cartService.selectOne(queryWrapper);
        if(cartEntity==null){
            cart.setCreateTime(new Date());
            cart.setInsertTime(new Date());
            cartService.insert(cart);
            return R.ok();
        }else {
            return R.error(511,"商品已添加到购物车");
        }
    }

    /**
    * 后端修改
    */
    @RequestMapping("/update")
    public R update(@RequestBody CartEntity cart, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {
        logger.debug("update方法:,,Controller:{},,cart:{}",this.getClass().getName(),cart.toString());
        CartEntity oldCartEntity = cartService.selectById(cart.getId());//查询原先数据

        String role = String.valueOf(request.getSession().getAttribute("role"));
//        if(false)
//            return R.error(511,"永远不会进入");
//        else if("用户".equals(role))
//            cart.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
        cart.setUpdateTime(new Date());

            cartService.updateById(cart);//根据id更新
            return R.ok();
    }



    /**
    * 删除
    */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids, HttpServletRequest request){
        logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
        List<CartEntity> oldCartList =cartService.selectBatchIds(Arrays.asList(ids));//要删除的数据
        cartService.deleteBatchIds(Arrays.asList(ids));

        return R.ok();
    }


    /**
     * 批量上传
     */
    @RequestMapping("/batchInsert")
    public R save( String fileName, HttpServletRequest request){
        logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
        Integer yonghuId = Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")));
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        //.eq("time", new SimpleDateFormat("yyyy-MM-dd").format(new Date()))
        try {
            List<CartEntity> cartList = new ArrayList<>();//上传的东西
            Map<String, List<String>> seachFields= new HashMap<>();//要查询的字段
            Date date = new Date();
            int lastIndexOf = fileName.lastIndexOf(".");
            if(lastIndexOf == -1){
                return R.error(511,"该文件没有后缀");
            }else{
                String suffix = fileName.substring(lastIndexOf);
                if(!".xls".equals(suffix)){
                    return R.error(511,"只支持后缀为xls的excel文件");
                }else{
                    URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径
                    File file = new File(resource.getFile());
                    if(!file.exists()){
                        return R.error(511,"找不到上传文件,请联系管理员");
                    }else{
                        List<List<String>> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件
                        dataList.remove(0);//删除第一行,因为第一行是提示
                        for(List<String> data:dataList){
                            //循环
                            CartEntity cartEntity = new CartEntity();
//                            cartEntity.setYonghuId(Integer.valueOf(data.get(0)));   //所属用户 要改的
//                            cartEntity.setChayeId(Integer.valueOf(data.get(0)));   //茶叶 要改的
//                            cartEntity.setBuyNumber(Integer.valueOf(data.get(0)));   //购买数量 要改的
//                            cartEntity.setCreateTime(date);//时间
//                            cartEntity.setUpdateTime(sdf.parse(data.get(0)));          //更新时间 要改的
//                            cartEntity.setInsertTime(date);//时间
                            cartList.add(cartEntity);


                            //把要查询是否重复的字段放入map中
                        }

                        //查询是否重复
                        cartService.insertBatch(cartList);
                        return R.ok();
                    }
                }
            }
        }catch (Exception e){
            e.printStackTrace();
            return R.error(511,"批量插入数据异常,请联系管理员");
        }
    }




    /**
    * 前端列表
    */
    @IgnoreAuth
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){
        logger.debug("list方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));

        CommonUtil.checkMap(params);
        PageUtils page = cartService.queryPage(params);

        //字典表数据转换
        List<CartView> list =(List<CartView>)page.getList();
        for(CartView c:list)
            dictionaryService.dictionaryConvert(c, request); //修改对应字典表字段

        return R.ok().put("data", page);
    }

    /**
    * 前端详情
    */
    @RequestMapping("/detail/{id}")
    public R detail(@PathVariable("id") Integer id, HttpServletRequest request){
        logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
        CartEntity cart = cartService.selectById(id);
            if(cart !=null){


                //entity转view
                CartView view = new CartView();
                BeanUtils.copyProperties( cart , view );//把实体数据重构到view中

                //级联表
                    YonghuEntity yonghu = yonghuService.selectById(cart.getYonghuId());
                if(yonghu != null){
                    BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段
                    view.setYonghuId(yonghu.getId());
                }
                //级联表
                    ChayeEntity chaye = chayeService.selectById(cart.getChayeId());
                if(chaye != null){
                    BeanUtils.copyProperties( chaye , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段
                    view.setChayeId(chaye.getId());
                }
                //修改对应字典表字段
                dictionaryService.dictionaryConvert(view, request);
                return R.ok().put("data", view);
            }else {
                return R.error(511,"查不到数据");
            }
    }


    /**
    * 前端保存
    */
    @RequestMapping("/add")
    public R add(@RequestBody CartEntity cart, HttpServletRequest request){
        logger.debug("add方法:,,Controller:{},,cart:{}",this.getClass().getName(),cart.toString());
        Wrapper<CartEntity> queryWrapper = new EntityWrapper<CartEntity>()
            .eq("yonghu_id", cart.getYonghuId())
            .eq("chaye_id", cart.getChayeId())
            .eq("buy_number", cart.getBuyNumber())
//            .notIn("cart_types", new Integer[]{102})
            ;
        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        CartEntity cartEntity = cartService.selectOne(queryWrapper);
        if(cartEntity==null){
            cart.setCreateTime(new Date());
            cart.setInsertTime(new Date());
        cartService.insert(cart);

            return R.ok();
        }else {
            return R.error(511,"表中有相同数据");
        }
    }

}

五,相关作品展示

基于Java开发、Python开发、PHP开发、C#开发等相关语言开发的实战项目

基于Nodejs、Vue等前端技术开发的前端实战项目

基于微信小程序和安卓APP应用开发的相关作品

基于51单片机等嵌入式物联网开发应用

基于各类算法实现的AI智能应用

基于大数据实现的各类数据管理和推荐系统

 

 

标签:return,毛尖,程序实现,微信,cart,new,import,id,view
From: https://blog.csdn.net/BS009/article/details/143209600

相关文章

  • 微信小程序中组件通信的性能优化方法有哪些?
    减少不必要的数据传递原理:组件间传递的数据量越小,通信的开销就越小。每次数据传递都涉及到数据的序列化、传输和反序列化等过程,过多或过大的数据传递会增加这些操作的频率和资源消耗。示例:比如在父子组件通信中,如果子组件只需要使用父组件中一个数据字段的部......
  • 如何在微信小程序中使用事件总线进行组件通信?
    创建事件总线(EventBus)模块目的:事件总线是一个独立的模块,用于管理事件的发布和订阅。它提供了一个集中的机制,使得组件之间可以通过发布和订阅事件来进行通信,而不需要依赖组件之间的父子关系或其他复杂的层级结构。代码实现:创建一个名为event-bus.js的文件,......
  • 如何避免在微信小程序中使用事件总线进行组件通信时出现内存泄漏?
    理解内存泄漏问题的产生原因在微信小程序中使用事件总线进行组件通信时,内存泄漏可能是由于组件在销毁后仍然被事件总线持有引用,导致无法被垃圾回收机制正常回收。例如,组件订阅了事件总线的某个事件,当组件被销毁时,如果没有正确地取消订阅,那么事件总线中仍然保存着对该组件......
  • Genymotion 模拟器上安装最新版本的微信并正常运行
    安装Genymotion安装步骤1安装虚拟机VirtualBox https://www.virtualbox.org/wiki/Downloads2注册Genymotion帐号 https://www.genymotion.com/account/create/3登录,下载并安装Genymotion https://www.genymotion.com/download/ android9版本的:  Genymotion-ARM-Tran......
  • Zabbix添加企业微信机器人告警
    环境查看系统环境#cat/etc/redhat-releaseCentOSStreamrelease9#uname-aLinuxCentOSStream9Zabbix2035.14.0-391.el9.x86_64#1SMPPREEMPT_DYNAMICTueNov2820:35:49UTC2023x86_64x86_64x86_64GNU/Linux软件环境#zabbix_server--versionzabbix_......
  • 基于微信小程序的外卖点餐餐厅点餐美食点餐系统的设计与开发
    基于微信小程序的外卖点餐餐厅点餐美食点餐系统的设计与开发视频介绍:基于微信小程序的外卖点餐餐厅点餐美食点餐系统的设计与开发具体贴图链接:贴图链接缩略图如下:开发环境及工具:大等于jdk1.8,大于mysql5.5,idea,微信开发者工具技术说明:vue.js小程序java......
  • 基于微信小程序的健康生活运动社交系统的设计与开发
    基于微信小程序的健康生活运动社交系统的设计与开发视频介绍基于微信小程序的健康生活运动社交系统的设计与开发具体贴图链接:项目贴图缩略图如下:开发环境及工具:大等于jdk1.8,大于mysql5.5,idea,微信开发者工具技术说明:vue.js小程序javaspringbootmybatis......
  • 基于微信小程序的校园二手交易闲置二手交易系统的设计与开发
    基于微信小程序的校园二手交易闲置二手交易系统的设计与开发视频介绍基于微信小程序的校园二手交易闲置二手交易系统的设计与开发具体贴图链接:贴图链接缩略图如下:开发环境及工具:大等于jdk1.8,大于mysql5.5,idea,微信开发者工具技术说明:thymeleaf小程序java......
  • 微信小程序input框onfocus获取焦点的延迟问题
    今天敲代码,原本想实现的效果是:input框有placeholder,点击input,placeholder清空。好比上图,点击输入框,框内的“请输入四位XX”就会消失。原本想着是,给input框添加@focus,当input框获取到焦点的时候,清空placeholder。但是实际运行时候发现,placeholder清空......
  • 基于Android的的酒店管理APP小程序实现(源码+lw+部署文档+讲解等)
    项目整体介绍基于安卓Android的酒店管理APP和小程序可以为酒店提供更便捷的管理方式和更好的客户服务体验。一、背景随着移动互联网的发展,越来越多的人习惯使用手机进行各种操作,包括酒店预订、入住登记、服务请求等。因此,开发一款基于安卓Android的酒店管理APP......