ssm生活缴费系统源码和论文

ssm生活缴费系统及相关安全技术的设计与实现176


 开发工具:idea 或eclipse
 数据库mysql5.7+
 数据库链接工具:navcat,小海豚等
  技术:ssm

摘  要

互联网发展至今,无论是其理论还是技术都已经成熟,而且它广泛参与在社会中的方方面面。它让信息都可以通过网络传播,搭配信息管理工具可以很好地为人们提供服务。针对生活缴费信息管理混乱,出错率高,信息安全性差,劳动强度大,费时费力等问题,采用生活缴费系统可以有效管理,使信息管理能够更加科学和规范。

生活缴费系统在Eclipse环境中,使用Java语言进行编码,使用Mysql创建数据表保存本系统产生的数据。系统可以提供信息显示和相应服务,其管理员管理电表,供暖,固话,宽带,燃气表,水表,油卡以及它们对应的缴费信息,管理客服,管理帮助信息以及油卡所属公司信息。用户在前台查看帮助信息,联系客服,在后台缴纳电费,水费,宽带费,供暖费,固话费等费用以及查看它们对应的缴费记录。

总之,生活缴费系统集中管理信息,有着保密性强,效率高,存储空间大,成本低等诸多优点。它可以降低信息管理成本,实现信息管理计算机化。

关键词:生活缴费系统;Java语言;Mysql


Abstract

Since the development of the Internet, both its theory and technology have matured, and it has been widely involved in all aspects of society. It allows information to be disseminated through the Internet, and it can serve people well with information management tools. In view of the chaotic management of life payment information, high error rate, poor information security, high labor intensity, and time-consuming and laborious problems, the use of life payment system can effectively manage and make information management more scientific and standardized.

The living payment system is in the Eclipse environment, using Java language for coding, using Mysql to create a data table to save the data generated by the system. The system can provide information display and corresponding services. Its administrator manages electricity meters, heating, fixed-line, broadband, gas meters, water meters, oil cards and their corresponding payment information, manages customer service, manages help information, and information about the company to which the oil card belongs. Users check help information at the front desk, contact customer service, pay electricity, water, broadband, heating, fixed-line charges and other fees in the background, and check their corresponding payment records.

In short, the life payment system centralizes management information, has many advantages such as strong confidentiality, high efficiency, large storage space, and low cost. It can reduce the cost of information management and realize the computerization of information management.

Key WordsLife payment system; Java language; Mysql

package com.controller;


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.StringUtil;
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.RanqibiaoEntity;

import com.service.RanqibiaoService;
import com.entity.view.RanqibiaoView;
import com.service.YonghuService;
import com.entity.YonghuEntity;
import com.service.RanqibiaoListService;
import com.entity.RanqibiaoListEntity;
import com.service.YonghuService;
import com.entity.YonghuEntity;

import com.utils.PageUtils;
import com.utils.R;

/**
 * 燃气表
 * 后端接口
 * @author
 * @email
 * @date 2021-04-12
*/
@RestController
@Controller
@RequestMapping("/ranqibiao")
public class RanqibiaoController {
    private static final Logger logger = LoggerFactory.getLogger(RanqibiaoController.class);

    @Autowired
    private RanqibiaoService ranqibiaoService;


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



    //级联表service
    @Autowired
    private YonghuService yonghuService;
    // 列表详情的表级联service
    @Autowired
    private RanqibiaoListService ranqibiaoListService;
//    @Autowired
//    private YonghuService yonghuService;


    /**
    * 后端列表
    */
    @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(StringUtil.isNotEmpty(role) && "用户".equals(role)){
            params.put("yonghuId",request.getSession().getAttribute("userId"));
        }
        params.put("orderBy","id");
        PageUtils page = ranqibiaoService.queryPage(params);

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

    /**
    * 后端详情
    */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
        logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
        RanqibiaoEntity ranqibiao = ranqibiaoService.selectById(id);
        if(ranqibiao !=null){
            //entity转view
            RanqibiaoView view = new RanqibiaoView();
            BeanUtils.copyProperties( ranqibiao , view );//把实体数据重构到view中

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

    }

    /**
    * 后端保存
    */
    @RequestMapping("/save")
    public R save(@RequestBody RanqibiaoEntity ranqibiao, HttpServletRequest request){
        logger.debug("save方法:,,Controller:{},,ranqibiao:{}",this.getClass().getName(),ranqibiao.toString());
        Wrapper<RanqibiaoEntity> queryWrapper = new EntityWrapper<RanqibiaoEntity>()
            .eq("ranqibiao_number", ranqibiao.getRanqibiaoNumber())
            ;
        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        RanqibiaoEntity ranqibiaoEntity = ranqibiaoService.selectOne(queryWrapper);
        if(ranqibiaoEntity==null){
            ranqibiao.setCreateTime(new Date());
            String role = String.valueOf(request.getSession().getAttribute("role"));
            if("用户".equals(role)){
                ranqibiao.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
            }
        //  String role = String.valueOf(request.getSession().getAttribute("role"));
        //  if("".equals(role)){
        //      ranqibiao.set
        //  }
            ranqibiaoService.insert(ranqibiao);
            return R.ok();
        }else {
            return R.error(511,"编号已经被使用");
        }
    }

    /**
    * 后端修改
    */
    @RequestMapping("/update")
    public R update(@RequestBody RanqibiaoEntity ranqibiao, HttpServletRequest request){
        logger.debug("update方法:,,Controller:{},,ranqibiao:{}",this.getClass().getName(),ranqibiao.toString());
        //根据字段查询是否有相同数据
        Wrapper<RanqibiaoEntity> queryWrapper = new EntityWrapper<RanqibiaoEntity>()
            .notIn("id",ranqibiao.getId())
            .andNew()
            .eq("ranqibiao_number", ranqibiao.getRanqibiaoNumber())
            ;
        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        RanqibiaoEntity ranqibiaoEntity = ranqibiaoService.selectOne(queryWrapper);
        if(ranqibiaoEntity==null){
            //  String role = String.valueOf(request.getSession().getAttribute("role"));
            //  if("".equals(role)){
            //      ranqibiao.set
            //  }
            ranqibiaoService.updateById(ranqibiao);//根据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());
        ranqibiaoService.deleteBatchIds(Arrays.asList(ids));
        ranqibiaoListService.delete(new EntityWrapper<RanqibiaoListEntity>().in("ranqibiao_id",ids));//删除设备缴费记录
        return R.ok();
    }



    /**
    * 前端列表
    */
    @RequestMapping("/list")
    public R list(@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(StringUtil.isNotEmpty(role) && "用户".equals(role)){
            params.put("yonghuId",request.getSession().getAttribute("userId"));
        }
        // 没有指定排序字段就默认id倒序
        if(StringUtil.isEmpty(String.valueOf(params.get("orderBy")))){
            params.put("orderBy","id");
        }
        PageUtils page = ranqibiaoService.queryPage(params);

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

    /**
    * 前端详情
    */
    @RequestMapping("/detail/{id}")
    public R detail(@PathVariable("id") Long id){
        logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
        RanqibiaoEntity ranqibiao = ranqibiaoService.selectById(id);
            if(ranqibiao !=null){
                //entity转view
        RanqibiaoView view = new RanqibiaoView();
                BeanUtils.copyProperties( ranqibiao , view );//把实体数据重构到view中

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


    /**
    * 前端保存
    */
    @RequestMapping("/add")
    public R add(@RequestBody RanqibiaoEntity ranqibiao, HttpServletRequest request){
        logger.debug("add方法:,,Controller:{},,ranqibiao:{}",this.getClass().getName(),ranqibiao.toString());
        Wrapper<RanqibiaoEntity> queryWrapper = new EntityWrapper<RanqibiaoEntity>()
            .eq("yonghu_id", ranqibiao.getYonghuId())
            .eq("ranqibiao_number", ranqibiao.getRanqibiaoNumber())
            .eq("ranqibiao_address", ranqibiao.getRanqibiaoAddress())
            ;
        logger.info("sql语句:"+queryWrapper.getSqlSegment());
    RanqibiaoEntity ranqibiaoEntity = ranqibiaoService.selectOne(queryWrapper);
        if(ranqibiaoEntity==null){
            ranqibiao.setCreateTime(new Date());
        //  String role = String.valueOf(request.getSession().getAttribute("role"));
        //  if("".equals(role)){
        //      ranqibiao.set
        //  }
        ranqibiaoService.insert(ranqibiao);
            return R.ok();
        }else {
            return R.error(511,"表中有相同数据");
        }
    }


    /**
     * 缴费
     */
    @RequestMapping("/jiaofei")
    public R jiaofei(@RequestBody  Map<String, Object> params,HttpServletRequest request){
        logger.debug("jiaofei方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
        Integer userId = (Integer) request.getSession().getAttribute("userId");//当前登录人的id
        String role = (String) request.getSession().getAttribute("role");//当前登录人权限
        String jiaofeiMoney = (String) params.get("jiaofeiMoney");//缴费金额
        Integer id = (Integer) params.get("id");//缴费金额

        RanqibiaoEntity ranqibiaoEntity = ranqibiaoService.selectById(id);
        if(ranqibiaoEntity == null){
            return R.error(511,"查询不到电表");
        }
        if("用户".equals(role)){//用户要效验是不是自己的设备
            if(ranqibiaoEntity.getYonghuId() != userId){
                return R.error(511,"您不能给不是自己的设备缴费");
            }
        }
        if(jiaofeiMoney == null || jiaofeiMoney == ""){
            return R.error(511,"缴费金额不能为空");
        }
        if(jiaofeiMoney.contains(".")){
            String[] split = jiaofeiMoney.split("\\.");
            if(split.length>1){//证明有小数
                String xiaoshu = split[1];
                if(xiaoshu.length()>2){
                    return R.error(511,"小数位最大为两位");
                }
            }
            String zhengshu = split[0];
            if(zhengshu.length()>6){
                return R.error(511,"整数位最大为6位");
            }
        }else{
            if(jiaofeiMoney.length()>6){
                return R.error(511,"整数位最大为6位");
            }
        }

        Double jiaofeiMoney1 = Double.parseDouble(jiaofeiMoney);
        if(jiaofeiMoney1 != null ){
            YonghuEntity yonghuEntity = null;

            if("用户".equals(role)) {//用户要效验是不是自己的设备
                yonghuEntity = yonghuService.selectById(userId);//当前登录人的信息
            }else if("管理员".equals(role)) {
                yonghuEntity = yonghuService.selectById(ranqibiaoEntity.getYonghuId());//管理员获取当前设备的用户id
            }

            if(yonghuEntity == null || yonghuEntity.getNewMoney() == null || yonghuEntity.getNewMoney() == 0 ){
                return R.error(511,"用户 或者 用户金额为空");
            }

            Double oldMoney = yonghuEntity.getNewMoney();

            if((oldMoney - jiaofeiMoney1)<0){
                return R.error(511,"缴费金额大于余额,请重选金额或充值");
            }

            yonghuEntity.setNewMoney(oldMoney - jiaofeiMoney1);//设置用户余额
            RanqibiaoListEntity ranqibiaoListEntity = new RanqibiaoListEntity();
            ranqibiaoListEntity.setCreateTime(new Date());
            ranqibiaoListEntity.setInsertTime(new Date());
            ranqibiaoListEntity.setRanqibiaoId(ranqibiaoEntity.getId());
            ranqibiaoListEntity.setRanqibiaoListOldMoney(ranqibiaoEntity.getRanqibiaoMoney());
            ranqibiaoListEntity.setRanqibiaoListNewMoney(jiaofeiMoney1);
            ranqibiaoListEntity.setSuccessTypes(1);

            ranqibiaoEntity.setRanqibiaoMoney(ranqibiaoEntity.getRanqibiaoMoney()+jiaofeiMoney1);//设置设备余额
            ranqibiaoListService.insert(ranqibiaoListEntity);//新增记录
            ranqibiaoService.updateById(ranqibiaoEntity);//更新设备
            yonghuService.updateById(yonghuEntity);//更新用户

        }

        return R.ok();
    }

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

程序猿毕业分享网

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

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

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

打赏作者

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

抵扣说明:

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

余额充值