微信小程序毕业设计-微信食堂线上订餐系统项目开发实战(附源码+论文)

news2024/10/6 22:25:49

大家好!我是程序猿老A,感谢您阅读本文,欢迎一键三连哦。

💞当前专栏:微信小程序毕业设计

精彩专栏推荐👇🏻👇🏻👇🏻

🎀 Python毕业设计
🌎Java毕业设计

开发运行环境

①前端:微信小程序开发工具

② 后端:Java

  • 框架:ssm
  • JDK版本:JDK1.8
  • 服务器:tomcat7
  • 数据库:mysql 5.7
  • 数据库工具:Navicat12
  • 开发软件:eclipse/myeclipse/idea
  • Maven包:Maven3.3.9
  • 浏览器:谷歌浏览器

演示视频

原版高清演示视频-编号:197
https://pan.quark.cn/s/b2f44f423421

源码下载地址:

https://download.csdn.net/download/2301_76953549/89227626

论文目录

【如需全文请按文末获取联系】
在这里插入图片描述
在这里插入图片描述

一、项目简介

微信食堂线上订餐小程序可以实现商品管理,商品评价管理,商家管理,公告管理,商品订单管理,在线充值等功能。该系统采用了SSM框架,Mysql数据库,Java语言等技术实现管理员后台,采用微信开发者工具来对用户小程序端进行了开发。

二、系统设计

2.1软件功能模块设计

图4.1即为设计的管理员功能结构,管理员权限操作的功能包括对用户注册信息,对商家信息,商品信息,公告信息等进行管理。
在这里插入图片描述
图4.2即为设计的商家功能结构,商家权限操作的功能包括管理商品,管理并回复商品评价,管理商品订单,查看公告等。
在这里插入图片描述
图4.3即为设计的用户功能结构,用户权限操作的功能包括购买商品,查看商家资料,查看公告,查看商品评价,管理商品订单,进行账户充值等。
在这里插入图片描述

2.2数据库设计

(1)图4.4即为商品这个实体所拥有的属性值。
在这里插入图片描述
(2)图4.5即为商品订单这个实体所拥有的属性值。
在这里插入图片描述

(4)图4.7即为商家这个实体所拥有的属性值。
在这里插入图片描述
(5)图4.8即为上面介绍的实体中存在的联系。
在这里插入图片描述

三、系统项目部分截图

3.1管理员功能实现

商家管理
图5.2 即为编码实现的商家管理界面,管理员在商家管理界面中具备更改商家营业执照,商家星级类型以及商家联系方式等信息,以及删除,添加商家等权限。
在这里插入图片描述
用户管理
图5.3 即为编码实现的用户管理界面,管理员在用户管理界面为用户的账号进行密码重置,更改用户的基础信息,删除需要删除的用户资料等。
在这里插入图片描述

3.2商家功能实现

商品管理
图5.4 即为编码实现的商品管理界面,商家在商品管理界面中具备增加商品库存,减少商品库存,为商品进行下架,更改商品信息,添加商品等权限。
在这里插入图片描述
商品评价管理
图5.5 即为编码实现的商品评价管理界面,商家在商品评价管理界面中查看用户对订单商品的评价,商家需要回复评价信息。
在这里插入图片描述

3.3用户功能实现

商品信息
图5.7 即为编码实现的商品信息界面,用户在商品信息界面中购买商品,或点击加入购物车按钮把商品保存在购物车里面。
在这里插入图片描述
订单确认
图5.8 即为编码实现的订单确认界面,用户在订单确认界面中需要确认购买的商品以及收货的地址信息,在余额充足的情况下就可以成功支付订单。
在这里插入图片描述
我的商品订单
图5.9 即为编码实现的我的商品订单界面,用户在我的商品订单界面中可以取餐,可以退款,可以评价订单。
在这里插入图片描述

四、部分核心代码


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("/caipinOrder")
public class CaipinOrderController {
    private static final Logger logger = LoggerFactory.getLogger(CaipinOrderController.class);

    @Autowired
    private CaipinOrderService caipinOrderService;


    @Autowired
    private TokenService tokenService;
    @Autowired
    private DictionaryService dictionaryService;

    //级联表service
    @Autowired
    private AddressService addressService;
    @Autowired
    private CaipinService caipinService;
    @Autowired
    private YonghuService yonghuService;
@Autowired
private CaipinCommentbackService caipinCommentbackService;
@Autowired
private CartService cartService;
@Autowired
private ShangjiaService shangjiaService;



    /**
    * 后端列表
    */
    @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"));
        else if("商家".equals(role))
            params.put("shangjiaId",request.getSession().getAttribute("userId"));
        if(params.get("orderBy")==null || params.get("orderBy")==""){
            params.put("orderBy","id");
        }
        PageUtils page = caipinOrderService.queryPage(params);

        //字典表数据转换
        List<CaipinOrderView> list =(List<CaipinOrderView>)page.getList();
        for(CaipinOrderView 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);
        CaipinOrderEntity caipinOrder = caipinOrderService.selectById(id);
        if(caipinOrder !=null){
            //entity转view
            CaipinOrderView view = new CaipinOrderView();
            BeanUtils.copyProperties( caipinOrder , view );//把实体数据重构到view中

                //级联表
                AddressEntity address = addressService.selectById(caipinOrder.getAddressId());
                if(address != null){
                    BeanUtils.copyProperties( address , view ,new String[]{ "id", "createTime", "insertTime", "updateTime", "yonghuId"});//把级联的数据添加到view中,并排除id和创建时间字段
                    view.setAddressId(address.getId());
                    view.setAddressYonghuId(address.getYonghuId());
                }
                //级联表
                CaipinEntity caipin = caipinService.selectById(caipinOrder.getCaipinId());
                if(caipin != null){
                    BeanUtils.copyProperties( caipin , view ,new String[]{ "id", "createTime", "insertTime", "updateTime"});//把级联的数据添加到view中,并排除id和创建时间字段
                    view.setCaipinId(caipin.getId());
                }
                //级联表
                YonghuEntity yonghu = yonghuService.selectById(caipinOrder.getYonghuId());
                if(yonghu != null){
                    BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createTime", "insertTime", "updateTime"});//把级联的数据添加到view中,并排除id和创建时间字段
                    view.setYonghuId(yonghu.getId());
                }
            //修改对应字典表字段
            dictionaryService.dictionaryConvert(view, request);
            return R.ok().put("data", view);
        }else {
            return R.error(511,"查不到数据");
        }

    }

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

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

        caipinOrder.setInsertTime(new Date());
        caipinOrder.setCreateTime(new Date());
        caipinOrderService.insert(caipinOrder);
        return R.ok();
    }

    /**
    * 后端修改
    */
    @RequestMapping("/update")
    public R update(@RequestBody CaipinOrderEntity caipinOrder, HttpServletRequest request){
        logger.debug("update方法:,,Controller:{},,caipinOrder:{}",this.getClass().getName(),caipinOrder.toString());

        String role = String.valueOf(request.getSession().getAttribute("role"));
//        if(false)
//            return R.error(511,"永远不会进入");
//        else if("用户".equals(role))
//            caipinOrder.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
        //根据字段查询是否有相同数据
        Wrapper<CaipinOrderEntity> queryWrapper = new EntityWrapper<CaipinOrderEntity>()
            .eq("id",0)
            ;

        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        CaipinOrderEntity caipinOrderEntity = caipinOrderService.selectOne(queryWrapper);
        if(caipinOrderEntity==null){
            caipinOrderService.updateById(caipinOrder);//根据id更新
            return R.ok();
        }else {
            return R.error(511,"表中有相同数据");
        }
    }

    /**
    * 删除
    */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
        logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
        caipinOrderService.deleteBatchIds(Arrays.asList(ids));
        return R.ok();
    }


    /**
     * 批量上传
     */
    @RequestMapping("/batchInsert")
    public R save( String fileName){
        logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
        try {
            List<CaipinOrderEntity> caipinOrderList = 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){
                            //循环
                            CaipinOrderEntity caipinOrderEntity = new CaipinOrderEntity();
//                            caipinOrderEntity.setCaipinOrderUuidNumber(data.get(0));                    //订单号 要改的
//                            caipinOrderEntity.setAddressId(Integer.valueOf(data.get(0)));   //收货地址 要改的
//                            caipinOrderEntity.setCaipinId(Integer.valueOf(data.get(0)));   //商品 要改的
//                            caipinOrderEntity.setYonghuId(Integer.valueOf(data.get(0)));   //用户 要改的
//                            caipinOrderEntity.setBuyNumber(Integer.valueOf(data.get(0)));   //购买数量 要改的
//                            caipinOrderEntity.setCaipinOrderTruePrice(data.get(0));                    //实付价格 要改的
//                            caipinOrderEntity.setCaipinOrderTypes(Integer.valueOf(data.get(0)));   //订单类型 要改的
//                            caipinOrderEntity.setCaipinOrderPaymentTypes(Integer.valueOf(data.get(0)));   //支付类型 要改的
//                            caipinOrderEntity.setInsertTime(date);//时间
//                            caipinOrderEntity.setCreateTime(date);//时间
                            caipinOrderList.add(caipinOrderEntity);


                            //把要查询是否重复的字段放入map中
                                //订单号
                                if(seachFields.containsKey("caipinOrderUuidNumber")){
                                    List<String> caipinOrderUuidNumber = seachFields.get("caipinOrderUuidNumber");
                                    caipinOrderUuidNumber.add(data.get(0));//要改的
                                }else{
                                    List<String> caipinOrderUuidNumber = new ArrayList<>();
                                    caipinOrderUuidNumber.add(data.get(0));//要改的
                                    seachFields.put("caipinOrderUuidNumber",caipinOrderUuidNumber);
                                }
                        }

                        //查询是否重复
                         //订单号
                        List<CaipinOrderEntity> caipinOrderEntities_caipinOrderUuidNumber = caipinOrderService.selectList(new EntityWrapper<CaipinOrderEntity>().in("caipin_order_uuid_number", seachFields.get("caipinOrderUuidNumber")));
                        if(caipinOrderEntities_caipinOrderUuidNumber.size() >0 ){
                            ArrayList<String> repeatFields = new ArrayList<>();
                            for(CaipinOrderEntity s:caipinOrderEntities_caipinOrderUuidNumber){
                                repeatFields.add(s.getCaipinOrderUuidNumber());
                            }
                            return R.error(511,"数据库的该表中的 [订单号] 字段已经存在 存在数据为:"+repeatFields.toString());
                        }
                        caipinOrderService.insertBatch(caipinOrderList);
                        return R.ok();
                    }
                }
            }
        }catch (Exception e){
            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));

        // 没有指定排序字段就默认id倒序
        if(StringUtil.isEmpty(String.valueOf(params.get("orderBy")))){
            params.put("orderBy","id");
        }
        PageUtils page = caipinOrderService.queryPage(params);

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

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


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

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


    /**
    * 前端保存
    */
    @RequestMapping("/add")
    public R add(@RequestBody CaipinOrderEntity caipinOrder, HttpServletRequest request){
        logger.debug("add方法:,,Controller:{},,caipinOrder:{}",this.getClass().getName(),caipinOrder.toString());
        String role = String.valueOf(request.getSession().getAttribute("role"));
        if("用户".equals(role)){
            CaipinEntity caipinEntity = caipinService.selectById(caipinOrder.getCaipinId());
            if(caipinEntity == null){
                return R.error(511,"查不到该物品");
            }
            // Double caipinNewMoney = caipinEntity.getCaipinNewMoney();

            if(false){
            }
            else if((caipinEntity.getCaipinKucunNumber() -caipinOrder.getBuyNumber())<0){
                return R.error(511,"购买数量不能大于库存数量");
            }
            else if(caipinEntity.getCaipinNewMoney() == null){
                return R.error(511,"物品价格不能为空");
            }

            //计算所获得积分
            Double buyJifen =0.0;
            Integer userId = (Integer) request.getSession().getAttribute("userId");
            YonghuEntity yonghuEntity = yonghuService.selectById(userId);
            if(yonghuEntity == null)
                return R.error(511,"用户不能为空");
            if(yonghuEntity.getNewMoney() == null)
                return R.error(511,"用户金额不能为空");
            double balance = yonghuEntity.getNewMoney() - caipinEntity.getCaipinNewMoney()*caipinOrder.getBuyNumber();//余额
            buyJifen = new BigDecimal(caipinEntity.getCaipinPrice()).multiply(new BigDecimal(caipinOrder.getBuyNumber())).doubleValue();//所获积分
            if(balance<0)
                return R.error(511,"余额不够支付");
            caipinOrder.setCaipinOrderTypes(3); //设置订单状态为已支付
            caipinOrder.setCaipinOrderTruePrice(caipinEntity.getCaipinNewMoney()*caipinOrder.getBuyNumber()); //设置实付价格
            caipinOrder.setYonghuId(userId); //设置订单支付人id
            caipinOrder.setCaipinOrderPaymentTypes(1);
            caipinOrder.setInsertTime(new Date());
            caipinOrder.setCreateTime(new Date());
                caipinEntity.setCaipinKucunNumber( caipinEntity.getCaipinKucunNumber() -caipinOrder.getBuyNumber());
                caipinService.updateById(caipinEntity);
                caipinOrderService.insert(caipinOrder);//新增订单
            yonghuEntity.setYonghuSumJifen(yonghuEntity.getYonghuSumJifen() + buyJifen); //设置总积分
            yonghuEntity.setNewMoney(balance);//设置金额
                if(yonghuEntity.getYonghuSumJifen()  < 10000)
                    yonghuEntity.setHuiyuandengjiTypes(1);
                else if(yonghuEntity.getYonghuSumJifen()  < 100000)
                    yonghuEntity.setHuiyuandengjiTypes(2);
                else if(yonghuEntity.getYonghuSumJifen()  < 1000000)
                    yonghuEntity.setHuiyuandengjiTypes(3);
            yonghuService.updateById(yonghuEntity);
            return R.ok();
        }else{
            return R.error(511,"您没有权限支付订单");
        }
    }
    /**
     * 添加订单
     */
    @RequestMapping("/order")
    public R add(@RequestParam Map<String, Object> params, HttpServletRequest request){
        logger.debug("order方法:,,Controller:{},,params:{}",this.getClass().getName(),params.toString());
        String caipinOrderUuidNumber = String.valueOf(new Date().getTime());

        //获取当前登录用户的id
        Integer userId = (Integer) request.getSession().getAttribute("userId");
        Integer addressId = Integer.valueOf(String.valueOf(params.get("addressId")));

        Integer caipinOrderPaymentTypes = Integer.valueOf(String.valueOf(params.get("caipinOrderPaymentTypes")));//支付类型

        String data = String.valueOf(params.get("caipins"));
        JSONArray jsonArray = JSON.parseArray(data);
        List<Map> caipins = JSON.parseObject(jsonArray.toString(), List.class);

        //获取当前登录用户的个人信息
        YonghuEntity yonghuEntity = yonghuService.selectById(userId);

        //当前订单表
        List<CaipinOrderEntity> caipinOrderList = new ArrayList<>();
        //商家表
        ArrayList<ShangjiaEntity> shangjiaList = new ArrayList<>();
        //商品表
        List<CaipinEntity> caipinList = new ArrayList<>();
        //购物车ids
        List<Integer> cartIds = new ArrayList<>();

        BigDecimal zhekou = new BigDecimal(1.0);
        // 获取折扣
        Wrapper<DictionaryEntity> dictionary = new EntityWrapper<DictionaryEntity>()
                .eq("dic_code", "huiyuandengji_types")
                .eq("dic_name", "会员等级类型")
                .eq("code_index", yonghuEntity.getHuiyuandengjiTypes())
                ;
        DictionaryEntity dictionaryEntity = dictionaryService.selectOne(dictionary);
        if(dictionaryEntity != null ){
            zhekou = BigDecimal.valueOf(Double.valueOf(dictionaryEntity.getBeizhu()));
        }

        //循环取出需要的数据
        for (Map<String, Object> map : caipins) {
           //取值
            Integer caipinId = Integer.valueOf(String.valueOf(map.get("caipinId")));//商品id
            Integer buyNumber = Integer.valueOf(String.valueOf(map.get("buyNumber")));//购买数量
            CaipinEntity caipinEntity = caipinService.selectById(caipinId);//购买的商品
            String id = String.valueOf(map.get("id"));
            if(StringUtil.isNotEmpty(id))
                cartIds.add(Integer.valueOf(id));

            //获取商家信息
            Integer shangjiaId = caipinEntity.getShangjiaId();
            ShangjiaEntity shangjiaEntity = shangjiaService.selectById(shangjiaId);//商家

            //判断商品的库存是否足够
            if(caipinEntity.getCaipinKucunNumber() < buyNumber){
                //商品库存不足直接返回
                return R.error(caipinEntity.getCaipinName()+"的库存不足");
            }else{
                //商品库存充足就减库存
                caipinEntity.setCaipinKucunNumber(caipinEntity.getCaipinKucunNumber() - buyNumber);
            }

            //订单信息表增加数据
            CaipinOrderEntity caipinOrderEntity = new CaipinOrderEntity<>();

            //赋值订单信息
            caipinOrderEntity.setCaipinOrderUuidNumber(caipinOrderUuidNumber);//订单号
            caipinOrderEntity.setAddressId(addressId);//收货地址
            caipinOrderEntity.setCaipinId(caipinId);//商品
            caipinOrderEntity.setYonghuId(userId);//用户
            caipinOrderEntity.setBuyNumber(buyNumber);//购买数量 ??????
            caipinOrderEntity.setCaipinOrderTypes(3);//订单类型
            caipinOrderEntity.setCaipinOrderPaymentTypes(caipinOrderPaymentTypes);//支付类型
            caipinOrderEntity.setInsertTime(new Date());//订单创建时间
            caipinOrderEntity.setCreateTime(new Date());//创建时间

            //判断是什么支付方式 1代表余额 2代表积分
            if(caipinOrderPaymentTypes == 1){//余额支付
                //计算金额
                Double money = new BigDecimal(caipinEntity.getCaipinNewMoney()).multiply(new BigDecimal(buyNumber)).multiply(zhekou).doubleValue();

                if(yonghuEntity.getNewMoney() - money <0 ){
                    return R.error("余额不足,请充值!!!");
                }else{
                    //计算所获得积分
                    Double buyJifen =0.0;
                        buyJifen = new BigDecimal(caipinEntity.getCaipinPrice()).multiply(new BigDecimal(buyNumber)).doubleValue();
                    yonghuEntity.setYonghuSumJifen(yonghuEntity.getYonghuSumJifen() + buyJifen); //设置总积分
                    yonghuEntity.setNewMoney(yonghuEntity.getNewMoney() - money); //设置金额
                        if(yonghuEntity.getYonghuSumJifen()  < 10000)
                            yonghuEntity.setHuiyuandengjiTypes(1);
                        else if(yonghuEntity.getYonghuSumJifen()  < 100000)
                            yonghuEntity.setHuiyuandengjiTypes(2);
                        else if(yonghuEntity.getYonghuSumJifen()  < 1000000)
                            yonghuEntity.setHuiyuandengjiTypes(3);


                    caipinOrderEntity.setCaipinOrderTruePrice(money);

                    //修改商家余额
                    shangjiaEntity.setNewMoney(shangjiaEntity.getNewMoney()+money);
                }
            }
            caipinOrderList.add(caipinOrderEntity);
            shangjiaList.add(shangjiaEntity);
            caipinList.add(caipinEntity);

        }
        caipinOrderService.insertBatch(caipinOrderList);
        shangjiaService.updateBatchById(shangjiaList);
        caipinService.updateBatchById(caipinList);
        yonghuService.updateById(yonghuEntity);
        if(cartIds != null && cartIds.size()>0)
            cartService.deleteBatchIds(cartIds);
        return R.ok();
    }











    /**
    * 退款
    */
    @RequestMapping("/refund")
    public R refund(Integer id, HttpServletRequest request){
        logger.debug("refund方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
        String role = String.valueOf(request.getSession().getAttribute("role"));

        if("用户".equals(role)){
            CaipinOrderEntity caipinOrder = caipinOrderService.selectById(id);
            Integer buyNumber = caipinOrder.getBuyNumber();
            Integer caipinOrderPaymentTypes = caipinOrder.getCaipinOrderPaymentTypes();
            Integer caipinId = caipinOrder.getCaipinId();
            if(caipinId == null)
                return R.error(511,"查不到该物品");
            CaipinEntity caipinEntity = caipinService.selectById(caipinId);
            if(caipinEntity == null)
                return R.error(511,"查不到该物品");
            //获取商家信息
            Integer shangjiaId = caipinEntity.getShangjiaId();
            ShangjiaEntity shangjiaEntity = shangjiaService.selectById(shangjiaId);//商家
            Double caipinNewMoney = caipinEntity.getCaipinNewMoney();
            if(caipinNewMoney == null)
                return R.error(511,"物品价格不能为空");

            Integer userId = (Integer) request.getSession().getAttribute("userId");
            YonghuEntity yonghuEntity = yonghuService.selectById(userId);
            if(yonghuEntity == null)
                return R.error(511,"用户不能为空");
            if(yonghuEntity.getNewMoney() == null)
                return R.error(511,"用户金额不能为空");

            Double zhekou = 1.0;
            // 获取折扣
            Wrapper<DictionaryEntity> dictionary = new EntityWrapper<DictionaryEntity>()
                    .eq("dic_code", "huiyuandengji_types")
                    .eq("dic_name", "会员等级类型")
                    .eq("code_index", yonghuEntity.getHuiyuandengjiTypes())
                    ;
            DictionaryEntity dictionaryEntity = dictionaryService.selectOne(dictionary);
            if(dictionaryEntity != null ){
                zhekou = Double.valueOf(dictionaryEntity.getBeizhu());
            }


            //判断是什么支付方式 1代表余额 2代表积分
            if(caipinOrderPaymentTypes == 1){//余额支付
                //计算金额
                Double money = caipinEntity.getCaipinNewMoney() * buyNumber  * zhekou;
                //计算所获得积分
                Double buyJifen = 0.0;
                buyJifen = new BigDecimal(caipinEntity.getCaipinPrice()).multiply(new BigDecimal(buyNumber)).doubleValue();
                yonghuEntity.setYonghuSumJifen(yonghuEntity.getYonghuSumJifen() - buyJifen); //设置总积分
                yonghuEntity.setNewMoney(yonghuEntity.getNewMoney() + money); //设置金额

                if(yonghuEntity.getYonghuSumJifen()  < 10000)
                    yonghuEntity.setHuiyuandengjiTypes(1);
                else if(yonghuEntity.getYonghuSumJifen()  < 100000)
                    yonghuEntity.setHuiyuandengjiTypes(2);
                else if(yonghuEntity.getYonghuSumJifen()  < 1000000)
                    yonghuEntity.setHuiyuandengjiTypes(3);

                //修改商家余额
                shangjiaEntity.setNewMoney(shangjiaEntity.getNewMoney() - money);
            }

            caipinEntity.setCaipinKucunNumber(caipinEntity.getCaipinKucunNumber() + buyNumber);



            caipinOrder.setCaipinOrderTypes(2);//设置订单状态为退款
            caipinOrderService.updateById(caipinOrder);//根据id更新
            shangjiaService.updateById(shangjiaEntity);
            yonghuService.updateById(yonghuEntity);//更新用户信息
            caipinService.updateById(caipinEntity);//更新订单中物品的信息
            return R.ok();
        }else{
            return R.error(511,"您没有权限退款");
        }
    }


    /**
     * 发货
     */
    @RequestMapping("/deliver")
    public R deliver(Integer id){
        logger.debug("refund:,,Controller:{},,ids:{}",this.getClass().getName(),id.toString());
        CaipinOrderEntity  caipinOrderEntity = new  CaipinOrderEntity();;
        caipinOrderEntity.setId(id);
        caipinOrderEntity.setCaipinOrderTypes(4);
        boolean b =  caipinOrderService.updateById( caipinOrderEntity);
        if(!b){
            return R.error("发货出错");
        }
        return R.ok();
    }









    /**
     * 收货
     */
    @RequestMapping("/receiving")
    public R receiving(Integer id){
        logger.debug("refund:,,Controller:{},,ids:{}",this.getClass().getName(),id.toString());
        CaipinOrderEntity  caipinOrderEntity = new  CaipinOrderEntity();
        caipinOrderEntity.setId(id);
        caipinOrderEntity.setCaipinOrderTypes(5);
        boolean b =  caipinOrderService.updateById( caipinOrderEntity);
        if(!b){
            return R.error("收货出错");
        }
        return R.ok();
    }



    /**
    * 评价
    */
    @RequestMapping("/commentback")
    public R commentback(Integer id, String commentbackText, Integer caipinCommentbackPingfenNumber, HttpServletRequest request){
        logger.debug("commentback方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
        String role = String.valueOf(request.getSession().getAttribute("role"));
        if("用户".equals(role)){
            CaipinOrderEntity caipinOrder = caipinOrderService.selectById(id);
        if(caipinOrder == null)
            return R.error(511,"查不到该订单");
        if(caipinOrder.getCaipinOrderTypes() != 5)
            return R.error(511,"您不能评价");
        Integer caipinId = caipinOrder.getCaipinId();
        if(caipinId == null)
            return R.error(511,"查不到该物品");

        CaipinCommentbackEntity caipinCommentbackEntity = new CaipinCommentbackEntity();
            caipinCommentbackEntity.setId(id);
            caipinCommentbackEntity.setCaipinId(caipinId);
            caipinCommentbackEntity.setYonghuId((Integer) request.getSession().getAttribute("userId"));
            caipinCommentbackEntity.setCaipinCommentbackText(commentbackText);
            caipinCommentbackEntity.setReplyText(null);
            caipinCommentbackEntity.setInsertTime(new Date());
            caipinCommentbackEntity.setUpdateTime(null);
            caipinCommentbackEntity.setCreateTime(new Date());
            caipinCommentbackService.insert(caipinCommentbackEntity);

            caipinOrder.setCaipinOrderTypes(1);//设置订单状态为已评价
            caipinOrderService.updateById(caipinOrder);//根据id更新
            return R.ok();
        }else{
            return R.error(511,"您没有权限评价");
        }
    }







}

五、获取源码或论文

如需对应的论文或源码,以及其他定制需求,也可以下方微❤联系。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1866319.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Python数据分析第一课:Anaconda的安装使用

Python数据分析第一课&#xff1a;Anaconda的安装使用 1.Anaconda是什么&#xff1f; Anaconda是一个便捷的获取包&#xff0c;并且对包和环境进行管理的虚拟环境工具,Anaconda包括了conda、Python在内的超过180多个包和依赖项 简单来说&#xff0c;Anaconda是包管理器和环境…

学习入门 chatgpt原理 一

学习文章&#xff1a;人人都能看懂的chatGpt原理课 笔记作为学习用&#xff0c;侵删 Chatph和自然语言处理 什么是ChatGpt ChatGPT&#xff08;Chat Generative Pre-training Transformer&#xff09; 是一个 AI 模型&#xff0c;属于自然语言处理&#xff08; Natural Lang…

【vue】vue响应式原理

vue响应式原理 vue2的响应式原理 vue2对对象类型的监听是通过Object.defineProperty实现的&#xff0c;给想要实现响应式的数据对象每个属性加上get,set方法&#xff0c;以实现数据劫持的操作。而对数组类型的监听是通过重写数组的方法实现的。 Object.defineProperty的定义…

Modbus TCP什么场景用?

什么是Modbus TCP Modbus TCP是一种基于TCP/IP网络的通信协议&#xff0c;它允许不同的设备通过以太网进行数据交换。Modbus协议最初是为串行通信设计的&#xff0c;但随着网络技术的发展&#xff0c;Modbus TCP应运而生&#xff0c;它继承了Modbus RTU和Modbus ASCII的许多优点…

C++基础编程100题-015 OpenJudge-1.3-13 反向输出一个三位数

更多资源请关注纽扣编程微信公众号 http://noi.openjudge.cn/ch0103/13/ 描述 将一个三位数反向输出。 输入 一个三位数n。 输出 反向输出n。 样例输入 100样例输出 001参考程序 #include<bits/stdc.h> using namespace std;int main(){int n;cin>>n;cou…

印刷企业数字工厂管理系统如何保障产品质量

一、引言 随着信息技术的迅猛发展&#xff0c;印刷行业也迎来了数字化转型的浪潮。数字工厂管理系统作为这一转型的核心工具&#xff0c;不仅在提高生产效率、优化资源配置方面发挥了重要作用&#xff0c;更在保障产品质量上扮演着关键角色。本文将深入探讨印刷企业数字工厂管…

021.合并两个有序链表,递归和遍历

题意 将两个升序链表合并为一个新的 升序 链表并返回。新链表是通过拼接给定的两个链表的所有节点组成的。 难度 简单 标签 链表、排序 示例 输入&#xff1a;l1 [1,2,4], l2 [1,3,4] 输出&#xff1a;[1,1,2,3,4,4]输入&#xff1a;l1 [], l2 [] 输出&#xff1a;[]…

常用组件详解(二):torch.nn.Flatten、torch.flatten()

文章目录 torch.nn.Flattentorch.flatten() 官方API文档&#xff1a;点击跳转。torch.nn.Flatten是Pytorch提供的类&#xff0c;常用于将输入数据进行展平&#xff0c;而torch.flatten()函数与之功能相同。 torch.nn.Flatten 类初始化方式&#xff1a; torch.nn.Flatten(star…

微信小程序-自定义组件checkbox

一.自定义Coponent组件 公共组件&#xff1a;将页面内公共的模块抽取为自定义组件&#xff0c;在不同页面复用。 页面组件&#xff1a;将复杂页面进行拆分&#xff0c;降低耦合度&#xff0c;有利于代码维护。 可以新建文件夹component放组件&#xff1a; 组件名为custom-che…

(2024,频域 LoRA,DFT,DCT,自适应门控,基于适配器组合的图像编辑)FouRA:傅里叶 LoRA

FouRA: Fourier Low Rank Adaptation 公和众与号&#xff1a;EDPJ&#xff08;进 Q 交流群&#xff1a;922230617 或加 VX&#xff1a;CV_EDPJ 进 V 交流群&#xff09; 目录 0. 摘要 2. 相关工作 3. 提出的方法 3.1 低秩适应的公式 3.2 频域中的低秩适应 3.3 频率变换 …

三十九篇:UML与SysML:掌握现代软件和系统架构的关键

UML与SysML&#xff1a;掌握现代软件和系统架构的关键 1. 引言 1.1 为什么系统设计如此关键 在当今快速发展的技术环境中&#xff0c;系统设计的重要性不言而喻。无论是软件开发还是复杂的系统工程&#xff0c;良好的设计是确保项目成功的基石。系统设计不仅关系到功能的实现…

搜维尔科技:【研究】触觉手套比控制器更能带来身临其境、更安全、更高效的虚拟体验

自然交互可提高VR模拟的有效性。研究表明&#xff0c;触觉手套比控制器更能带来身临其境、更安全、更高效的虚拟体验。 以下是验证 医疗培训中的触觉技术 “ 95.5%的参与者表示触摸是 XR 教育的重要组成部分&#xff0c;90.9% 的参与者表示 XR 触觉将提供一个安全的学习场所。…

Hadoop 2.0 大家族(一)

目录 一、Hadoop 2.0大家族概述&#xff08;一&#xff09;分布式组件&#xff08;二&#xff09;部署概述 二、ZooKeeper&#xff08;一&#xff09;ZooKeeper简介&#xff08;二&#xff09;ZooKeeper 入门 一、Hadoop 2.0大家族概述 &#xff08;一&#xff09;分布式组件 …

Mybatis 系列全解(2)——全网免费最细最全,手把手教,学完就可做项目!

Mybatis 系列全解&#xff08;2&#xff09; 1. ResultMap结果集映射2. 日志2.1 日志工厂2.2 log4j 3. 分页3.1 实现SQL分页3.2 RowBounds 分页3.3 分页插件 4. 使用注解开发4.1 面向接口编程4.2 使用注解4.3 Mybatis 详细执行过程4.4 CRUD 增删改查 5. Lombok 1. ResultMap结果…

Android Studio中HAXM安装失败的解决方案(HAXM installation failed)

文章目录 错误示例Hyper-VWindows SandboxWindows Hypervisor Platform&#xff08;Windows 虚拟化监控程序平台&#xff09; 出现原因解决方法虚拟机平台方案一方案二方案三 错误示例 表明HAXM (Hardware Accelerated Execution Manager)安装失败了。HAXM是一个硬件辅助虚拟化…

查询DBA_TEMP_FILES报错,删除临时表空间报错ORA-60100

SYMPTOMS 查询DBA_TEMP_FILES报错如下图 ORA-01157: cannotidentify/ock data fle 201 -see DBWR trace fle ORA-01110: data fle 20 1: D:APPADMINISTRATORIORADATA MARTIDATAFILE 01157,00000-"cannotidentify/ock data fle %s -see DBWR trace fle"*Cause: The b…

番外篇 | YOLOv8改进之利用轻量化卷积PConv引入全新的结构CSPPC来替换Neck网络中的C2f | 模型轻量化

前言:Hello大家好,我是小哥谈。本文使用轻量化卷积PConv替换Neck中C2f模块中Bottleneck里的传统卷积核得到CSPPC模块,使得模型更加轻量化。🌈 目录 🚀1.基础概念 🚀2.网络结构 🚀3.添加步骤 🚀4.改进方法 🍀🍀步骤1:block.py文件修改 🍀🍀步…

【MySQL】数据库事务详解

文章目录 前言1. 事务的定义2. 事务的四个特性2.1 原子性2.2 一致性2.3 隔离性2.4 持久性 3. 事务的并发问题3.1 脏读3.2 不可重复读3.3 幻读3.4 更新丢失 4. 事务的隔离级别5. 事务的使用结语 前言 假设我们现在需要操作数据库进行转账&#xff0c;A 给 B 转账 100 块钱&…

【Text2SQL 论文】MCS-SQL:利用多样 prompts + 多项选择来做 Text2SQL

论文&#xff1a;MCS-SQL: Leveraging Multiple Prompts and Multiple-Choice Selection For Text-to-SQL Generation ⭐⭐⭐ arXiv:2405.07467 一、论文速读 已有研究指出&#xff0c;在使用 LLM 使用 ICL 时&#xff0c;ICL 的 few-shot exemplars 的内容、呈现顺序都会敏感…

Apple - View Programming Guide

本文翻译整理自&#xff1a;View Programming Guide&#xff08;更新&#xff1a;2013-08-08 https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/CocoaViewsGuide/Introduction/Introduction.html#//apple_ref/doc/uid/TP40002978-CH1-SW1 文章目录…