• Java项目:SSM停车场管理系统


    作者主页:源码空间站2022

     简介:Java领域优质创作者、Java项目、学习资料、技术互助

    文末获取源码

    项目介绍

    本项目为后台管理系统,分为管理员、用户、工作人员三种角色;

    管理员角色包含以下功能:

    登陆页面,收入查看,停车卡开卡等功能。

    用户角色包含以下功能:
    用户登录,停车卡管理,优惠券管理,发送站内信,查看停车记录等功能。

    工作人员角色包含以下功能:

    登陆首页,车辆入库,车辆出库,停车卡管理,优惠券管理,站内信查看,用户管理等功能。

    环境需要

    1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
    2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
    3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
    4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 

    5.数据库:MySql 5.7版本;

    6.是否Maven项目:是;

    技术栈

    1. 后端:Spring+SpringMVC+Mybatis

    2. 前端:JSP+Bootstrap+Javascript

    使用说明

    1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;

    2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;

    若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;

    3. 将项目中dbconfig.properties配置文件中的数据库配置改为自己的配置;

    4. 运行项目,输入http://localhost:8080/ssm_depot_system/login/login 登录

    注:Tomcat中配置项目路径必须为ssm_depot_system

    运行截图

    用户角色

    管理员角色

    工作人员角色

    相关代码 

    CardController

    1. package com.depot.ex.admin.controller;
    2. import java.text.SimpleDateFormat;
    3. import java.util.Date;
    4. import java.util.List;
    5. import javax.servlet.http.HttpSession;
    6. import org.apache.ibatis.annotations.Param;
    7. import org.springframework.beans.factory.annotation.Autowired;
    8. import org.springframework.stereotype.Controller;
    9. import org.springframework.transaction.annotation.Transactional;
    10. import org.springframework.ui.Model;
    11. import org.springframework.util.StringUtils;
    12. import org.springframework.validation.BindingResult;
    13. import org.springframework.web.bind.annotation.RequestMapping;
    14. import org.springframework.web.bind.annotation.RequestParam;
    15. import org.springframework.web.bind.annotation.ResponseBody;
    16. import com.depot.ex.admin.dto.CouponData;
    17. import com.depot.ex.admin.dto.DepotcardManagerData;
    18. import com.depot.ex.admin.entity.CardType;
    19. import com.depot.ex.admin.entity.Coupon;
    20. import com.depot.ex.admin.entity.Depotcard;
    21. import com.depot.ex.admin.entity.Income;
    22. import com.depot.ex.admin.entity.ParkInfo;
    23. import com.depot.ex.admin.entity.User;
    24. import com.depot.ex.admin.service.CardtypeService;
    25. import com.depot.ex.admin.service.CouponService;
    26. import com.depot.ex.admin.service.DepotcardService;
    27. import com.depot.ex.admin.service.IllegalInfoService;
    28. import com.depot.ex.admin.service.IncomeService;
    29. import com.depot.ex.admin.service.ParkinfoService;
    30. import com.depot.ex.admin.service.ParkinfoallService;
    31. import com.depot.ex.admin.service.UserService;
    32. import com.depot.ex.utils.Constants;
    33. import com.depot.ex.utils.Msg;
    34. /**
    35. * *
    36. *
    37. * @author 作者 E-mail: *
    38. * @date 创建时间:2019年08月27日 下午2:07:13 *
    39. * @version 1.0 *
    40. * @parameter *
    41. * @since *
    42. * @return
    43. */
    44. @Controller
    45. public class CardController {
    46. @Autowired
    47. private DepotcardService depotcardService;
    48. @Autowired
    49. private CardtypeService cardtypeService;
    50. @Autowired
    51. private UserService userService;
    52. @Autowired
    53. private ParkinfoService parkinfoService;
    54. @Autowired
    55. private IncomeService incomeService;
    56. @Autowired
    57. private CouponService couponService;
    58. @Autowired
    59. private IllegalInfoService illegalInfoService;
    60. @Autowired
    61. private ParkinfoallService parkinfoallService;
    62. @ResponseBody
    63. @RequestMapping("/index/card/findAllCardType")
    64. public Msg findAllCardType()
    65. {
    66. List cardTypes=cardtypeService.findAllCardType();
    67. return Msg.success().add("cardTypes", cardTypes);
    68. }
    69. @ResponseBody
    70. @RequestMapping("/index/card/addDepotCard")
    71. @Transactional
    72. public Msg addDepotCard(DepotcardManagerData depotcardManagerData)
    73. {
    74. if(Integer.parseInt(depotcardManagerData.getType())!=1)
    75. {
    76. depotcardManagerData.setDeductedtime(new Date());
    77. }
    78. Depotcard depotcard=depotcardService.save(depotcardManagerData);
    79. double money=0;
    80. Income income=new Income();
    81. if(depotcard==null)
    82. {
    83. return Msg.fail().add("va_msg", "账号已存在!");
    84. }
    85. int type=Integer.parseInt(depotcardManagerData.getType());
    86. /*if(type==1)
    87. {
    88. income.setTrueincome(0);
    89. }else{
    90. income.setTrueincome(1);
    91. }*/
    92. if(type==2)
    93. {
    94. money=depotcard.getMoney();
    95. money-=Constants.MONTHCARD;
    96. depotcard.setMoney(money);
    97. depotcardService.updateDepotcardBycardnum(depotcard);
    98. income.setMoney(Constants.MONTHCARD);
    99. }
    100. if(type==3)
    101. {
    102. money=depotcard.getMoney();
    103. money-=Constants.YEARCARD;
    104. depotcard.setMoney(money);
    105. depotcardService.updateDepotcardBycardnum(depotcard);
    106. income.setMoney(Constants.YEARCARD);
    107. }
    108. income.setCardnum(depotcard.getCardnum());
    109. income.setType(type);
    110. income.setMethod(depotcardManagerData.getPayid());
    111. income.setSource(0);
    112. income.setTime(new Date());
    113. incomeService.save(income);
    114. userService.saveByaddDepotCard(depotcardManagerData.getUsername(),depotcardManagerData.getName(),depotcard.getId());
    115. return Msg.success().add("depotcard", depotcard).add("username", depotcardManagerData.getUsername());
    116. }
    117. @ResponseBody
    118. @RequestMapping("/index/card/findDepotCardByCardnum")
    119. public Msg findDepotCardByCardnum(@RequestParam("cardnum")String cardnum,HttpSession session)
    120. {
    121. User currentUser=(User) session.getAttribute("user");
    122. Depotcard depotcard=depotcardService.findByCardnum(cardnum);
    123. if(depotcard==null)
    124. {
    125. return Msg.fail();
    126. }
    127. int typeid=depotcard.getType();
    128. int cardid=depotcard.getId();
    129. User user=userService.findUserByCardid(cardid);
    130. CardType cardType=cardtypeService.findCardTypeByid(typeid);
    131. List cardTypes=cardtypeService.findAllCardType();
    132. return Msg.success().add("depotcard", depotcard).add("cardType", cardType)
    133. .add("cardTypes", cardTypes).add("user", user).add("user_role", currentUser.getRole());
    134. }
    135. @ResponseBody
    136. @RequestMapping("/index/card/alertDepotCard")
    137. public Msg alertDepotCard(DepotcardManagerData depotcardManagerData)
    138. {
    139. Depotcard depotcard=depotcardService.findByCardnum(depotcardManagerData.getCardnum());
    140. if(depotcardManagerData.getType()==null)
    141. {
    142. depotcardManagerData.setType(Integer.toString(depotcard.getType()));
    143. }
    144. if(depotcardManagerData.getIslose()!=depotcard.getIslose()
    145. ||Integer.parseInt(depotcardManagerData.getType())!=depotcard.getType())
    146. {
    147. depotcard.setIslose(depotcardManagerData.getIslose());
    148. depotcard.setType(Integer.parseInt(depotcardManagerData.getType()));
    149. depotcardService.updateDepotcardBycardnum(depotcard);
    150. }else{
    151. return Msg.fail();
    152. }
    153. return Msg.success();
    154. }
    155. @ResponseBody
    156. @RequestMapping("/index/card/deleteDepotCard")
    157. @Transactional
    158. public Msg deleteDepotCard(@RequestParam("cardnum")String cardnum)
    159. {
    160. Depotcard depotcard=depotcardService.findByCardnum(cardnum);
    161. int cardid=depotcard.getId();
    162. ParkInfo parkInfo=parkinfoService.findParkinfoByCardnum(cardnum);
    163. //正在停车不能删
    164. if(parkInfo!=null)
    165. {
    166. return Msg.fail().add("va_msg", "有车辆在停车,不能删除!");
    167. }
    168. userService.deleteUserByCardid(cardid);
    169. depotcardService.deleteDepotCard(cardnum);
    170. return Msg.success();
    171. }
    172. @ResponseBody
    173. @RequestMapping("/index/card/findCoupon")
    174. public Msg findCoupon(@RequestParam("cardnum")String cardnum)
    175. {
    176. List list=couponService.findAllCouponByCardNum(cardnum, "");
    177. if(list!=null&&list.size()>0)
    178. {
    179. return Msg.success().add("val", list.get(0).getMoney());
    180. }
    181. return Msg.fail();
    182. }
    183. /**
    184. * 充值提交
    185. */
    186. @ResponseBody
    187. @RequestMapping("/index/card/rechargeDepotCardSubmit")
    188. public Msg rechargeDepotCardSubmit(DepotcardManagerData depotcardManagerData){
    189. Depotcard depotcard=depotcardService.findByCardnum(depotcardManagerData.getCardnum());
    190. Income income=new Income();
    191. if(depotcard==null)
    192. {
    193. return Msg.fail().add("va_msg", "该停车卡不存在,请重新输入!");
    194. }
    195. double money=depotcard.getMoney()+depotcardManagerData.getMoney();
    196. List list=couponService.findAllCouponByCardNum(depotcardManagerData.getCardnum(), "");
    197. if(list!=null&&list.size()>0)
    198. {
    199. couponService.deleteCoupon(list.get(0).getId());
    200. }
    201. try {
    202. depotcardService.addMoney(depotcardManagerData.getCardnum(),money);
    203. } catch (Exception e) {
    204. return Msg.fail().add("va_msg", "出现错误!");
    205. }
    206. income.setCardnum(depotcardManagerData.getCardnum());
    207. income.setType(depotcard.getType());
    208. income.setSource(0);
    209. income.setMethod(depotcardManagerData.getPayid());
    210. income.setMoney(money);
    211. income.setTime(new Date());
    212. incomeService.save(income);
    213. return Msg.success();
    214. }
    215. @ResponseBody
    216. @RequestMapping("/index/card/changeLoseCard")
    217. @Transactional
    218. public Msg changeLoseCard(DepotcardManagerData depotcardManagerData)
    219. {
    220. String cardnum=depotcardManagerData.getCardnum();
    221. Depotcard depotcard=depotcardService.findByCardnum(cardnum);
    222. User user=userService.findUserByCardid(depotcard.getId());
    223. if(StringUtils.isEmpty(cardnum))
    224. {
    225. return Msg.fail();
    226. }
    227. Date date=new Date();
    228. SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
    229. String trans=formatter.format(date);
    230. String dateStr=trans.replaceAll(" ", "").replaceAll("-", "");
    231. String cardnumNew=user.getUsername()+dateStr;
    232. Depotcard depotcardNew=depotcardService.findByCardnum(cardnumNew);
    233. if(depotcardNew!=null)
    234. {
    235. return Msg.fail();
    236. }
    237. depotcardService.updateCardnum(cardnum,cardnumNew);
    238. couponService.updateCardnum(cardnum,cardnumNew);
    239. illegalInfoService.updateCardnum(cardnum,cardnumNew);
    240. incomeService.updateCardnum(cardnum,cardnumNew);
    241. parkinfoService.updateCardnum(cardnum,cardnumNew);
    242. parkinfoallService.updateCardnum(cardnum,cardnumNew);
    243. depotcardNew=depotcardService.findByCardnum(cardnumNew);
    244. depotcardNew.setIslose(0);
    245. depotcardService.updateDepotcardBycardnum(depotcardNew);
    246. return Msg.success();
    247. }
    248. @ResponseBody
    249. @RequestMapping("/index/card/isAlertType")
    250. public Msg isAlertType(DepotcardManagerData depotcardManagerData)
    251. {
    252. Depotcard depotcard=depotcardService.findByCardnum(depotcardManagerData.getCardnum());
    253. if(depotcardManagerData.getType()==null)
    254. {
    255. depotcardManagerData.setType(Integer.toString(depotcard.getType()));
    256. }
    257. if(depotcard.getType()!=Integer.parseInt(depotcardManagerData.getType()))
    258. {
    259. if(Integer.parseInt(depotcardManagerData.getType())>1)
    260. {
    261. double money=depotcard.getMoney();
    262. List listCou=couponService.findAllCouponByCardNum(depotcard.getCardnum(), "");
    263. if(listCou!=null&&listCou.size()>0)
    264. {
    265. money+=listCou.get(0).getMoney();
    266. }
    267. //假如是月卡
    268. if(Integer.parseInt(depotcardManagerData.getType())==2)
    269. {
    270. if(money
    271. {
    272. return Msg.fail().add("money_pay", Constants.MONTHCARD-money);
    273. }else{
    274. return Msg.success().add("money_pay", Constants.MONTHCARD);
    275. }
    276. }else{
    277. if(money
    278. {
    279. return Msg.fail().add("money_pay", Constants.YEARCARD-money);
    280. }else{
    281. return Msg.success().add("money_pay", Constants.MONTHCARD);
    282. }
    283. }
    284. }
    285. }
    286. return Msg.success().add("money_pay", 0);
    287. }
    288. }

    CheckController

    1. package com.depot.ex.admin.controller;
    2. import static org.hamcrest.CoreMatchers.nullValue;
    3. import java.text.SimpleDateFormat;
    4. import java.util.Date;
    5. import java.util.List;
    6. import javax.servlet.http.HttpSession;
    7. import org.springframework.beans.factory.annotation.Autowired;
    8. import org.springframework.stereotype.Controller;
    9. import org.springframework.transaction.annotation.Transactional;
    10. import org.springframework.ui.Model;
    11. import org.springframework.util.StringUtils;
    12. import org.springframework.web.bind.annotation.RequestMapping;
    13. import org.springframework.web.bind.annotation.RequestParam;
    14. import org.springframework.web.bind.annotation.ResponseBody;
    15. import com.depot.ex.admin.dto.CouponData;
    16. import com.depot.ex.admin.dto.FormData;
    17. import com.depot.ex.admin.entity.Coupon;
    18. import com.depot.ex.admin.entity.Depotcard;
    19. import com.depot.ex.admin.entity.IllegalInfo;
    20. import com.depot.ex.admin.entity.Income;
    21. import com.depot.ex.admin.entity.ParkInfo;
    22. import com.depot.ex.admin.entity.Parkinfoall;
    23. import com.depot.ex.admin.entity.User;
    24. import com.depot.ex.admin.service.CouponService;
    25. import com.depot.ex.admin.service.DepotcardService;
    26. import com.depot.ex.admin.service.IllegalInfoService;
    27. import com.depot.ex.admin.service.IncomeService;
    28. import com.depot.ex.admin.service.ParkinfoService;
    29. import com.depot.ex.admin.service.ParkinfoallService;
    30. import com.depot.ex.admin.service.ParkspaceService;
    31. import com.depot.ex.admin.service.UserService;
    32. import com.depot.ex.utils.Constants;
    33. import com.depot.ex.utils.Msg;
    34. /**
    35. * *
    36. *
    37. * @author 作者 E-mail: *
    38. * @date 创建时间:2019年08月5日 下午12:00:13 *
    39. * @version 1.0 *
    40. * @parameter *
    41. * @since *
    42. * @return
    43. */
    44. @Controller
    45. public class CheckController {
    46. @Autowired
    47. private ParkinfoService parkinfoservice;
    48. @Autowired
    49. private ParkspaceService parkspaceService;
    50. @Autowired
    51. private DepotcardService depotcardService;
    52. @Autowired
    53. private UserService userService;
    54. @Autowired
    55. private IllegalInfoService illegalInfoService;
    56. @Autowired
    57. private ParkinfoallService parkinfoallService;
    58. @Autowired
    59. private IncomeService incomeService;
    60. @Autowired
    61. private CouponService couponService;
    62. @RequestMapping("/index/check/checkIn")
    63. @ResponseBody
    64. @Transactional
    65. // 入库操作
    66. public Msg checkIn(Model model, FormData data) {
    67. Depotcard depotcard=depotcardService.findByCardnum(data.getCardNum());
    68. if(data.getParkTem()!=1)
    69. {
    70. if(depotcard!=null)
    71. {
    72. if(depotcard.getIslose()==1)
    73. {
    74. return Msg.fail().add("va_msg", "该卡已挂失!");
    75. }
    76. }else{
    77. return Msg.fail().add("va_msg", "该卡不存在!");
    78. }
    79. }
    80. parkinfoservice.saveParkinfo(data);
    81. parkspaceService.changeStatus(data.getId(), 1);
    82. return Msg.success();
    83. }
    84. @RequestMapping("/index/check/checkOut")
    85. @ResponseBody
    86. @Transactional
    87. // 出库操作(0扣费,1不用扣费,9付钱)
    88. public Msg checkOut(Model model, FormData data) {
    89. int pay_money=data.getPay_money();
    90. Date parkout=new Date();
    91. Parkinfoall parkinfoall=new Parkinfoall();
    92. ParkInfo parkInfo=parkinfoservice.findParkinfoByParknum(data.getParkNum());
    93. if(data.getPay_type()==9)
    94. {
    95. Depotcard depotcard=depotcardService.findByCardnum(data.getCardNum());
    96. IllegalInfo illegalInfo=illegalInfoService.findByCardnumParkin(data.getCardNum(),parkInfo.getParkin());
    97. Income income=new Income();
    98. List coupons=couponService.findAllCouponByCardNum(data.getCardNum(), "");
    99. if(coupons!=null&&coupons.size()>0)
    100. {
    101. couponService.deleteCoupon(coupons.get(0).getId());
    102. }
    103. depotcardService.addMoney(data.getCardNum(), 0);
    104. income.setMoney(pay_money);
    105. income.setMethod(data.getPayid());
    106. income.setCardnum(data.getCardNum());
    107. income.setCarnum(data.getCarNum());
    108. if(depotcard!=null)
    109. {
    110. income.setType(depotcard.getType());
    111. }
    112. if(illegalInfo!=null)
    113. {
    114. income.setIsillegal(1);
    115. }
    116. income.setSource(1);
    117. income.setTime(parkout);
    118. Date parkin=parkInfo.getParkin();
    119. long day=parkout.getTime()-parkin.getTime();
    120. long time=day/(1000*60);
    121. if(day%(1000*60)>0){
    122. time+=1;
    123. }
    124. income.setDuration(time);
    125. incomeService.save(income);
    126. }else{
    127. if(data.getPay_type()==9)
    128. {
    129. return Msg.fail().add("va_msg", "系统出错!");
    130. }else if(data.getPay_type()==0)
    131. {
    132. //正常扣费,月卡或年卡过期
    133. Depotcard depotcard=depotcardService.findByCardnum(data.getCardNum());
    134. IllegalInfo illegalInfo=illegalInfoService.findByCardnumParkin(data.getCardNum(),parkInfo.getParkin());
    135. double money=depotcard.getMoney();
    136. List coupons=couponService.findAllCouponByCardNum(data.getCardNum(), "");
    137. if(coupons!=null&&coupons.size()>0)
    138. {
    139. money-=coupons.get(0).getMoney();
    140. couponService.deleteCoupon(coupons.get(0).getId());
    141. }
    142. money-=pay_money;
    143. depotcardService.addMoney(depotcard.getCardnum(),money);
    144. /*Income income=new Income();
    145. income.setMoney(pay_money);
    146. income.setMethod(data.getPayid());
    147. income.setCardnum(data.getCardNum());
    148. income.setCarnum(data.getCarNum());
    149. income.setType(depotcard.getType());
    150. if(illegalInfo!=null)
    151. {
    152. income.setIsillegal(1);
    153. }
    154. income.setSource(1);
    155. income.setTime(parkout);*/
    156. /*Date parkin=parkInfo.getParkin();
    157. long day=parkout.getTime()-parkin.getTime();
    158. long time=day/(1000*60);
    159. if(day%(1000*60)>0){
    160. time+=1;
    161. }
    162. income.setDuration(time);
    163. income.setTrueincome(1);
    164. incomeService.save(income);*/
    165. }else{
    166. //月卡或年卡在期
    167. }
    168. }
    169. parkinfoall.setCardnum(parkInfo.getCardnum());
    170. parkinfoall.setCarnum(parkInfo.getCarnum());
    171. parkinfoall.setParkin(parkInfo.getParkin());
    172. parkinfoall.setParknum(data.getParkNum());
    173. parkinfoall.setParkout(parkout);
    174. parkinfoall.setParktemp(parkInfo.getParktem());
    175. parkinfoallService.save(parkinfoall);
    176. parkspaceService.changeStatusByParkNum(data.getParkNum(),0);
    177. parkinfoservice.deleteParkinfoByParkNum(data.getParkNum());
    178. return Msg.success();
    179. }
    180. @RequestMapping("/index/check/findParkinfoByParknum")
    181. @ResponseBody
    182. // 根据停车位号查找停车位信息
    183. public Msg findParkinfoByParknum(@RequestParam("parkNum") int parknum) {
    184. ParkInfo parkInfo = parkinfoservice.findParkinfoByParknum(parknum);
    185. return Msg.success().add("parkInfo", parkInfo);
    186. }
    187. @RequestMapping("/index/check/findParkinfoByCardnum")
    188. @ResponseBody
    189. // 根据停车位号/车牌号查找停车位信息
    190. public Msg findParkinfoByCardnum(@RequestParam("cardnum") String cardnum) {
    191. ParkInfo parkInfo = parkinfoservice.findParkinfoByCardnum(cardnum);
    192. if(parkInfo!=null)
    193. {
    194. return Msg.success().add("parkInfo", parkInfo);
    195. }
    196. return Msg.fail();
    197. }
    198. @RequestMapping("/index/check/findParkinfoDetailByParknum")
    199. @ResponseBody
    200. //根据停车位号查找停车详细信息
    201. public Msg findParkinfoDetailByParknum(@RequestParam("parkNum") int parknum)
    202. {
    203. ParkInfo parkInfo = parkinfoservice.findParkinfoByParknum(parknum);
    204. if(parkInfo==null)
    205. {
    206. return Msg.fail();
    207. }
    208. Date date=parkInfo.getParkin();
    209. SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    210. String parkin=formatter.format(date);
    211. System.out.println(parkInfo.toString());
    212. String cardnum=parkInfo.getCardnum();
    213. Depotcard depotcard=depotcardService.findByCardnum(cardnum);
    214. int cardid=0;
    215. User user =null;
    216. if(depotcard!=null)
    217. {
    218. cardid=depotcard.getId();
    219. user =userService.findUserByCardid(cardid);
    220. }
    221. return Msg.success().add("parkInfo", parkInfo).add("user", user).add("parkin", parkin);
    222. }
    223. @RequestMapping("/index/check/illegalSubmit")
    224. @ResponseBody
    225. //违规提交
    226. public Msg illegalSubmit(FormData data,HttpSession httpSession)
    227. {
    228. User currentUser=(User) httpSession.getAttribute("user");
    229. ParkInfo parkInfo=parkinfoservice.findParkinfoByCardnum(data.getCardNum());
    230. IllegalInfo info=new IllegalInfo();
    231. IllegalInfo illegalInfo=illegalInfoService.findByCardnumParkin(data.getCardNum(),parkInfo.getParkin());
    232. if(illegalInfo!=null)
    233. {
    234. return Msg.fail().add("va_msg", "添加失败,已经有违规!");
    235. }
    236. info.setCardnum(data.getCardNum());
    237. info.setCarnum(data.getCarNum());
    238. info.setIllegalInfo(data.getIllegalInfo());
    239. info.setUid(currentUser.getId());
    240. Date date=new Date();
    241. info.setTime(date);
    242. info.setParkin(parkInfo.getParkin());
    243. info.setDelete("N");
    244. try {
    245. illegalInfoService.save(info);
    246. } catch (Exception e) {
    247. e.printStackTrace();
    248. return Msg.fail().add("va_msg", "添加失败");
    249. }
    250. return Msg.success().add("va_msg", "添加成功");
    251. }
    252. /*是否需要支付
    253. * type:0是正常扣费
    254. * type:1是月卡年卡没到期*/
    255. @RequestMapping("/index/check/ispay")
    256. @ResponseBody
    257. public Msg ispay(@RequestParam("parknum") Integer parknum)
    258. {
    259. ParkInfo parkInfo=parkinfoservice.findParkinfoByParknum(parknum.intValue());
    260. Date date=new Date();
    261. Date parkin;
    262. long time=0;
    263. long day=0;
    264. int illegalmoney=0;
    265. //临时停车(10块)
    266. if(parkInfo==null)
    267. {
    268. return Msg.fail().add("type", 9);
    269. }
    270. //是否有违规需要缴费
    271. IllegalInfo illegalInfo=illegalInfoService.findByCarnum(parkInfo.getCarnum(),parkInfo.getParkin());
    272. if(illegalInfo!=null)
    273. {
    274. illegalmoney=Constants.ILLEGAL;
    275. }
    276. if(StringUtils.isEmpty(parkInfo.getCardnum()))
    277. {
    278. //需要现金或扫码支付,1小时10块
    279. parkin=parkInfo.getParkin();
    280. day=date.getTime()-parkin.getTime();
    281. time=day/(1000*60*60);
    282. if(day%(1000*60*60)>0){
    283. time+=1;
    284. }
    285. return Msg.success().add("money_pay", time*Constants.TEMPMONEY+illegalmoney).add("va_msg", "临时停车"+(illegalmoney>0? ",有违规:"+illegalInfo.getIllegalInfo():""));
    286. }
    287. String cardnum=parkInfo.getCardnum();
    288. Depotcard depotcard=depotcardService.findByCardnum(cardnum);
    289. //正常卡(8块)
    290. if(depotcard!=null&&depotcard.getType()==1)
    291. {
    292. //卡中余额
    293. double balance=depotcard.getMoney();
    294. int money=0;
    295. List coupons=couponService.findAllCouponByCardNum(cardnum, "");
    296. if(coupons!=null&&coupons.size()>0)
    297. {
    298. money=coupons.get(0).getMoney();
    299. }
    300. parkin=parkInfo.getParkin();
    301. day=date.getTime()-parkin.getTime();
    302. time=day/(1000*60*60);
    303. if(day%(1000*60*60)>0){
    304. time+=1;
    305. }
    306. if(balance+money-illegalmoney
    307. {
    308. return Msg.success().add("money_pay", time*Constants.HOURMONEY+illegalmoney-money-balance).add("va_msg", "余额不足"+(illegalmoney>0? ",有违规:"+illegalInfo.getIllegalInfo():""));
    309. }else{
    310. return Msg.fail().add("type", 0).add("money_pay", time*Constants.HOURMONEY+illegalmoney-money);
    311. }
    312. }
    313. Date deductedtime=depotcard.getDeductedtime();
    314. if(depotcard.getType()>1)
    315. {
    316. day=date.getTime()-deductedtime.getTime();
    317. }
    318. if(depotcard.getType()==3){
    319. time=day/(1000*60*60*24*30);
    320. }
    321. if(depotcard.getType()==4){
    322. time=day/(1000*60*60*24*365);
    323. }
    324. //如果月卡或年卡没到期,直接出库
    325. if(time<1)
    326. {
    327. return Msg.fail().add("type", 1);
    328. }else{
    329. //否则查看停车卡余额是否足够扣费,不够则需要现金或扫码
    330. //卡中余额
    331. double balance=depotcard.getMoney();
    332. int money=0;
    333. List coupons=couponService.findAllCouponByCardNum(cardnum, "");
    334. if(coupons!=null&&coupons.size()>0)
    335. {
    336. money=coupons.get(0).getMoney();
    337. }
    338. parkin=parkInfo.getParkin();
    339. day=date.getTime()-parkin.getTime();
    340. time=day/(1000*60*60);
    341. if(day%(1000*60*60)>0){
    342. time+=1;
    343. }
    344. if(balance+money-illegalmoney
    345. {
    346. return Msg.success().add("money_pay", time*Constants.HOURMONEY+illegalmoney-money-balance).add("va_msg", "余额不足"+(illegalmoney>0? ",有违规:"+illegalInfo.getIllegalInfo():""));
    347. }else{
    348. return Msg.fail().add("type", 0);
    349. }
    350. }
    351. }
    352. }

    如果也想学习本系统,下面领取。关注并回复:080ssm 

     

  • 相关阅读:
    【YashanDB知识库】数据变化率超过阈值统计信息失效
    Wireshark抓包分析IP协议
    PHP8的类与对象的基本操作之类常量-PHP8知识详解
    MySQL 5.7到8.0数据迁移
    使用WebDriver采样器将JMeter与Selenium集成
    mysql基础面试题
    【火猫体育】法甲:他背叛国米追求高薪,就要被新东家赶走
    1985-2023年6月全球各国经济政策不确定性数据
    java-php-python-ssm网上拍卖系统2021计算机毕业设计
    【路径规划-多式联运】基于遗传算法求解多式联运冷链运输成本优化问题附matlab代码
  • 原文地址:https://blog.csdn.net/m0_74967853/article/details/128179193