如今的信息时代,对信息的共享性,信息的流通性有着较高要求,因此传统管理方式就不适合。为了让管理模式进行升级,也为了更好的维护信息,社区超市管理系统的开发运用就显得很有必要。并且通过开发社区超市管理系统,不仅可以让所学的微信小程序技术得到实际运用,也可以掌握MySQL的使用方法,对自身编程能力也有一个检验和提升的过程。尤其是通过实践,可以对系统的开发流程加深印象,无论是前期的分析与设计,还是后期的编码测试等环节,都可以有一个深刻的了解。
借助于社区超市管理系统这样的工具,让信息系统化,流程化,规范化是最终的发展结果,让其遵循实际操作流程的情况下,对信息实施规范化处理,让信息通过电子的方式进行保存,无论是管理人员检索信息,可以便利化操作,真正缩短信息处理时间,节省人力和信息管理的成本。
关键字:社区超市管理系统,微信小程序技术,MySQL
基于小程序的社区超市管理系统+springboot后台管理源码和论文weixin166
Abstract
In today's information age, there are high requirements for the sharing and circulation of information, so the traditional management method is not suitable. In order to upgrade the management mode and better maintain information, the development and application of student dormitory management system is very necessary. And by developing the student dormitory management system, we can not only make practical use of the wechat applet technology we have learned, but also master the use method of MySQL, and have a process of testing and improving our own programming ability. Especially through practice, we can deepen our impression on the development process of the system. We can have a deep understanding of both the early analysis and design and the later coding and testing.
With the help of tools such as student dormitory management system, systematization, process and standardization of information are the final development results. Under the condition of following the actual operation process, standardized processing of information is implemented, and information is saved electronically. Whether managers retrieve information, it can facilitate operation and really shorten the information processing time, Save labor and information management costs.
Key Words:Student dormitory management system, Wechat Mini Programt echnology, MySQL
表4.1收货地址表
序号 |
列名 |
数据类型 |
说明 |
允许空 |
1 |
Id |
Int |
id |
否 |
2 |
yonghu_id |
Integer |
创建用户 |
是文章来源:https://www.toymoban.com/news/detail-812853.html |
3 |
address_name |
String |
收货人 |
是 |
4 |
address_phone |
String |
电话 |
是 |
5 |
address_dizhi |
String |
地址 |
是 |
6 |
isdefault_types |
Integer |
是否默认地址 |
是 |
7 |
insert_time |
Date |
添加时间 |
是 |
8 |
update_time |
Date |
修改时间 |
是 |
9 |
create_time |
Date |
创建时间 |
是 |
表4.2购物车表
序号 |
列名 |
数据类型 |
说明 |
允许空 |
1 |
Id |
Int |
id |
否 |
2 |
yonghu_id |
Integer |
所属用户 |
是 |
3 |
shangpin_id |
Integer |
商品 |
是 |
4 |
buy_number |
Integer |
购买数量 |
是 |
5 |
create_time |
Date |
添加时间 |
是 |
6 |
update_time |
Date |
更新时间 |
是 |
7 |
insert_time |
Date |
创建时间 |
是 |
表4.3超市管理员表
序号 |
列名 |
数据类型 |
说明 |
允许空 |
1 |
Id |
Int |
id |
否 |
2 |
chaoshi_name |
String |
超市管理姓名 |
是 |
3 |
chaoshi_phone |
String |
联系方式 |
是 |
4 |
chaoshi_id_number |
String |
身份证号 |
是 |
5 |
chaoshi_delete |
Integer |
假删 |
是 |
6 |
create_time |
Date |
创建时间 |
是 |
表4.4字典表表
序号 |
列名 |
数据类型 |
说明 |
允许空 |
1 |
Id |
Int |
id |
否 |
2 |
dic_code |
String |
字段 |
是 |
3 |
dic_name |
String |
字段名 |
是 |
4 |
code_index |
Integer |
编码 |
是 |
文章来源地址https://www.toymoban.com/news/detail-812853.html
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("/shangpinOrder")
public class ShangpinOrderController {
private static final Logger logger = LoggerFactory.getLogger(ShangpinOrderController.class);
@Autowired
private ShangpinOrderService shangpinOrderService;
@Autowired
private TokenService tokenService;
@Autowired
private DictionaryService dictionaryService;
//级联表service
@Autowired
private AddressService addressService;
@Autowired
private ShangpinService shangpinService;
@Autowired
private YonghuService yonghuService;
@Autowired
private CartService cartService;
@Autowired
private ShangpinCommentbackService shangpinCommentbackService;
/**
* 后端列表
*/
@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.isEmpty(role))
return R.error(511,"权限为空");
else if("用户".equals(role))
params.put("yonghuId",request.getSession().getAttribute("userId"));
else if("超市管理员".equals(role))
params.put("chaoshiId",request.getSession().getAttribute("userId"));
if(params.get("orderBy")==null || params.get("orderBy")==""){
params.put("orderBy","id");
}
PageUtils page = shangpinOrderService.queryPage(params);
//字典表数据转换
List<ShangpinOrderView> list =(List<ShangpinOrderView>)page.getList();
for(ShangpinOrderView 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);
ShangpinOrderEntity shangpinOrder = shangpinOrderService.selectById(id);
if(shangpinOrder !=null){
//entity转view
ShangpinOrderView view = new ShangpinOrderView();
BeanUtils.copyProperties( shangpinOrder , view );//把实体数据重构到view中
//级联表
AddressEntity address = addressService.selectById(shangpinOrder.getAddressId());
if(address != null){
BeanUtils.copyProperties( address , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段
view.setAddressId(address.getId());
}
//级联表
ShangpinEntity shangpin = shangpinService.selectById(shangpinOrder.getShangpinId());
if(shangpin != null){
BeanUtils.copyProperties( shangpin , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段
view.setShangpinId(shangpin.getId());
}
//级联表
YonghuEntity yonghu = yonghuService.selectById(shangpinOrder.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("/save")
public R save(@RequestBody ShangpinOrderEntity shangpinOrder, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,shangpinOrder:{}",this.getClass().getName(),shangpinOrder.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
if(StringUtil.isEmpty(role))
return R.error(511,"权限为空");
else if("用户".equals(role))
shangpinOrder.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
shangpinOrder.setInsertTime(new Date());
shangpinOrder.setCreateTime(new Date());
shangpinOrderService.insert(shangpinOrder);
return R.ok();
}
/**
* 后端修改
*/
@RequestMapping("/update")
public R update(@RequestBody ShangpinOrderEntity shangpinOrder, HttpServletRequest request){
logger.debug("update方法:,,Controller:{},,shangpinOrder:{}",this.getClass().getName(),shangpinOrder.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
// if(StringUtil.isEmpty(role))
// return R.error(511,"权限为空");
// else if("用户".equals(role))
// shangpinOrder.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
//根据字段查询是否有相同数据
Wrapper<ShangpinOrderEntity> queryWrapper = new EntityWrapper<ShangpinOrderEntity>()
.eq("id",0)
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
ShangpinOrderEntity shangpinOrderEntity = shangpinOrderService.selectOne(queryWrapper);
if(shangpinOrderEntity==null){
// String role = String.valueOf(request.getSession().getAttribute("role"));
// if("".equals(role)){
// shangpinOrder.set
// }
shangpinOrderService.updateById(shangpinOrder);//根据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());
shangpinOrderService.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<ShangpinOrderEntity> shangpinOrderList = 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){
//循环
ShangpinOrderEntity shangpinOrderEntity = new ShangpinOrderEntity();
// shangpinOrderEntity.setShangpinOrderUuidNumber(data.get(0)); //订单号 要改的
// shangpinOrderEntity.setShangpinId(Integer.valueOf(data.get(0))); //商品 要改的
// shangpinOrderEntity.setYonghuId(Integer.valueOf(data.get(0))); //用户 要改的
// shangpinOrderEntity.setBuyNumber(Integer.valueOf(data.get(0))); //购买的数量 要改的
// shangpinOrderEntity.setAddressId(Integer.valueOf(data.get(0))); //收获地址 要改的
// shangpinOrderEntity.setShangpinOrderTruePrice(data.get(0)); //实付价格 要改的
// shangpinOrderEntity.setShangpinOrderTypes(Integer.valueOf(data.get(0))); //订单类型 要改的
// shangpinOrderEntity.setShangpinOrderPaymentTypes(Integer.valueOf(data.get(0))); //支付类型 要改的
// shangpinOrderEntity.setInsertTime(date);//时间
// shangpinOrderEntity.setCreateTime(date);//时间
shangpinOrderList.add(shangpinOrderEntity);
//把要查询是否重复的字段放入map中
//订单号
if(seachFields.containsKey("shangpinOrderUuidNumber")){
List<String> shangpinOrderUuidNumber = seachFields.get("shangpinOrderUuidNumber");
shangpinOrderUuidNumber.add(data.get(0));//要改的
}else{
List<String> shangpinOrderUuidNumber = new ArrayList<>();
shangpinOrderUuidNumber.add(data.get(0));//要改的
seachFields.put("shangpinOrderUuidNumber",shangpinOrderUuidNumber);
}
}
//查询是否重复
//订单号
List<ShangpinOrderEntity> shangpinOrderEntities_shangpinOrderUuidNumber = shangpinOrderService.selectList(new EntityWrapper<ShangpinOrderEntity>().in("shangpin_order_uuid_number", seachFields.get("shangpinOrderUuidNumber")));
if(shangpinOrderEntities_shangpinOrderUuidNumber.size() >0 ){
ArrayList<String> repeatFields = new ArrayList<>();
for(ShangpinOrderEntity s:shangpinOrderEntities_shangpinOrderUuidNumber){
repeatFields.add(s.getShangpinOrderUuidNumber());
}
return R.error(511,"数据库的该表中的 [订单号] 字段已经存在 存在数据为:"+repeatFields.toString());
}
shangpinOrderService.insertBatch(shangpinOrderList);
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 = shangpinOrderService.queryPage(params);
//字典表数据转换
List<ShangpinOrderView> list =(List<ShangpinOrderView>)page.getList();
for(ShangpinOrderView 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);
ShangpinOrderEntity shangpinOrder = shangpinOrderService.selectById(id);
if(shangpinOrder !=null){
//entity转view
ShangpinOrderView view = new ShangpinOrderView();
BeanUtils.copyProperties( shangpinOrder , view );//把实体数据重构到view中
//级联表
AddressEntity address = addressService.selectById(shangpinOrder.getAddressId());
if(address != null){
BeanUtils.copyProperties( address , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段
view.setAddressId(address.getId());
}
//级联表
ShangpinEntity shangpin = shangpinService.selectById(shangpinOrder.getShangpinId());
if(shangpin != null){
BeanUtils.copyProperties( shangpin , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段
view.setShangpinId(shangpin.getId());
}
//级联表
YonghuEntity yonghu = yonghuService.selectById(shangpinOrder.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 ShangpinOrderEntity shangpinOrder, HttpServletRequest request){
logger.debug("add方法:,,Controller:{},,shangpinOrder:{}",this.getClass().getName(),shangpinOrder.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
if("用户".equals(role)){
ShangpinEntity shangpinEntity = shangpinService.selectById(shangpinOrder.getShangpinId());
if(shangpinEntity == null){
return R.error(511,"查不到该物品");
}
// Double shangpinNewMoney = shangpinEntity.getShangpinNewMoney();
if(false){
}
else if((shangpinEntity.getShangpinKucunNumber() -shangpinOrder.getBuyNumber())<0){
return R.error(511,"购买数量不能大于库存数量");
}
else if(shangpinEntity.getShangpinNewMoney() == 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() - shangpinEntity.getShangpinNewMoney()*shangpinOrder.getBuyNumber();//余额
if(balance<0)
return R.error(511,"余额不够支付");
shangpinOrder.setShangpinOrderTypes(2); //设置订单状态为已支付
shangpinOrder.setShangpinOrderTruePrice(shangpinEntity.getShangpinNewMoney()*shangpinOrder.getBuyNumber()); //设置实付价格
shangpinOrder.setYonghuId(userId); //设置订单支付人id
shangpinOrder.setShangpinOrderPaymentTypes(1);
shangpinOrder.setInsertTime(new Date());
shangpinOrder.setCreateTime(new Date());
shangpinEntity.setShangpinKucunNumber( shangpinEntity.getShangpinKucunNumber() -shangpinOrder.getBuyNumber());
shangpinService.updateById(shangpinEntity);
shangpinOrderService.insert(shangpinOrder);//新增订单
yonghuEntity.setNewMoney(balance);//设置金额
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 shangpinOrderUuidNumber = String.valueOf(new Date().getTime());
//获取当前登录用户的id
Integer userId = (Integer) request.getSession().getAttribute("userId");
Integer addressId = Integer.valueOf(String.valueOf(params.get("addressId")));
Integer shangpinOrderPaymentTypes = Integer.valueOf(String.valueOf(params.get("shangpinOrderPaymentTypes")));//支付类型
String data = String.valueOf(params.get("shangpins"));
JSONArray jsonArray = JSON.parseArray(data);
List<Map> shangpins = JSON.parseObject(jsonArray.toString(), List.class);
//获取当前登录用户的个人信息
YonghuEntity yonghuEntity = yonghuService.selectById(userId);
//当前订单表
List<ShangpinOrderEntity> shangpinOrderList = new ArrayList<>();
//商品表
List<ShangpinEntity> shangpinList = new ArrayList<>();
//购物车ids
List<Integer> cartIds = new ArrayList<>();
BigDecimal zhekou = new BigDecimal(1.0);
//循环取出需要的数据
for (Map<String, Object> map : shangpins) {
//取值
Integer shangpinId = Integer.valueOf(String.valueOf(map.get("shangpinId")));//商品id
Integer buyNumber = Integer.valueOf(String.valueOf(map.get("buyNumber")));//购买数量
ShangpinEntity shangpinEntity = shangpinService.selectById(shangpinId);//购买的商品
String id = String.valueOf(map.get("id"));
if(StringUtil.isNotEmpty(id))
cartIds.add(Integer.valueOf(id));
//判断商品的库存是否足够
if(shangpinEntity.getShangpinKucunNumber() < buyNumber){
//商品库存不足直接返回
return R.error(shangpinEntity.getShangpinName()+"的库存不足");
}else{
//商品库存充足就减库存
shangpinEntity.setShangpinKucunNumber(shangpinEntity.getShangpinKucunNumber() - buyNumber);
}
//订单信息表增加数据
ShangpinOrderEntity shangpinOrderEntity = new ShangpinOrderEntity<>();
//赋值订单信息
shangpinOrderEntity.setShangpinOrderUuidNumber(shangpinOrderUuidNumber);//订单号
shangpinOrderEntity.setShangpinId(shangpinId);//商品
shangpinOrderEntity.setYonghuId(userId);//用户
shangpinOrderEntity.setBuyNumber(buyNumber);//购买的数量 ??????
shangpinOrderEntity.setAddressId(addressId);//收获地址
shangpinOrderEntity.setShangpinOrderTypes(2);//订单类型
shangpinOrderEntity.setShangpinOrderPaymentTypes(shangpinOrderPaymentTypes);//支付类型
shangpinOrderEntity.setInsertTime(new Date());//订单创建时间
shangpinOrderEntity.setCreateTime(new Date());//创建时间
//判断是什么支付方式 1代表余额 2代表积分
if(shangpinOrderPaymentTypes == 1){//余额支付
//计算金额
Double money = new BigDecimal(shangpinEntity.getShangpinNewMoney()).multiply(new BigDecimal(buyNumber)).multiply(zhekou).doubleValue();
if(yonghuEntity.getNewMoney() - money <0 ){
return R.error("余额不足,请充值!!!");
}else{
//计算所获得积分
Double buyJifen =0.0;
yonghuEntity.setNewMoney(yonghuEntity.getNewMoney() - money); //设置金额
shangpinOrderEntity.setShangpinOrderTruePrice(money);
}
}
shangpinOrderList.add(shangpinOrderEntity);
shangpinList.add(shangpinEntity);
}
shangpinOrderService.insertBatch(shangpinOrderList);
shangpinService.updateBatchById(shangpinList);
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)){
ShangpinOrderEntity shangpinOrder = shangpinOrderService.selectById(id);
Integer buyNumber = shangpinOrder.getBuyNumber();
Integer shangpinOrderPaymentTypes = shangpinOrder.getShangpinOrderPaymentTypes();
Integer shangpinId = shangpinOrder.getShangpinId();
if(shangpinId == null)
return R.error(511,"查不到该物品");
ShangpinEntity shangpinEntity = shangpinService.selectById(shangpinId);
if(shangpinEntity == null)
return R.error(511,"查不到该物品");
Double shangpinNewMoney = shangpinEntity.getShangpinNewMoney();
if(shangpinNewMoney == 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;
//判断是什么支付方式 1代表余额 2代表积分
if(shangpinOrderPaymentTypes == 1){//余额支付
//计算金额
Double money = shangpinEntity.getShangpinNewMoney() * buyNumber * zhekou;
//计算所获得积分
Double buyJifen = 0.0;
yonghuEntity.setNewMoney(yonghuEntity.getNewMoney() + money); //设置金额
}
shangpinEntity.setShangpinKucunNumber(shangpinEntity.getShangpinKucunNumber() + buyNumber);
shangpinOrder.setShangpinOrderTypes(1);//设置订单状态为退款
shangpinOrderService.updateById(shangpinOrder);//根据id更新
yonghuService.updateById(yonghuEntity);//更新用户信息
shangpinService.updateById(shangpinEntity);//更新订单中物品的信息
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());
ShangpinOrderEntity shangpinOrderEntity = new ShangpinOrderEntity();;
shangpinOrderEntity.setId(id);
shangpinOrderEntity.setShangpinOrderTypes(3);
boolean b = shangpinOrderService.updateById( shangpinOrderEntity);
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());
ShangpinOrderEntity shangpinOrderEntity = new ShangpinOrderEntity();
shangpinOrderEntity.setId(id);
shangpinOrderEntity.setShangpinOrderTypes(4);
boolean b = shangpinOrderService.updateById( shangpinOrderEntity);
if(!b){
return R.error("收货出错");
}
return R.ok();
}
/**
* 评价
*/
@RequestMapping("/commentback")
public R commentback(Integer id, String commentbackText,HttpServletRequest request){
logger.debug("commentback方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
String role = String.valueOf(request.getSession().getAttribute("role"));
if("用户".equals(role)){
ShangpinOrderEntity shangpinOrder = shangpinOrderService.selectById(id);
if(shangpinOrder == null)
return R.error(511,"查不到该订单");
if(shangpinOrder.getShangpinOrderTypes() != 4)
return R.error(511,"您不能评价");
Integer shangpinId = shangpinOrder.getShangpinId();
if(shangpinId == null)
return R.error(511,"查不到该物品");
ShangpinCommentbackEntity shangpinCommentbackEntity = new ShangpinCommentbackEntity();
shangpinCommentbackEntity.setId(id);
shangpinCommentbackEntity.setShangpinId(shangpinId);
shangpinCommentbackEntity.setYonghuId((Integer) request.getSession().getAttribute("userId"));
shangpinCommentbackEntity.setShangpinCommentbackText(commentbackText);
shangpinCommentbackEntity.setReplyText(null);
shangpinCommentbackEntity.setInsertTime(new Date());
shangpinCommentbackEntity.setUpdateTime(null);
shangpinCommentbackEntity.setCreateTime(new Date());
shangpinCommentbackService.insert(shangpinCommentbackEntity);
shangpinOrder.setShangpinOrderTypes(5);//设置订单状态为已评价
shangpinOrderService.updateById(shangpinOrder);//根据id更新
return R.ok();
}else{
return R.error(511,"您没有权限评价");
}
}
}
到了这里,关于基于小程序的社区超市管理系统+springboot后台管理源码和论文的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!