package com.example.schoolexpress.Controller;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.schoolexpress.Entity.Orders;
import com.example.schoolexpress.Entity.User;
import com.example.schoolexpress.Mapper.OrdersMapper;
import com.example.schoolexpress.Mapper.UserMapper;
import com.example.schoolexpress.Response.ResponseData;
import com.example.schoolexpress.Utils.EnumCode;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@Api(tags = "订单接口")
@RestController()
@CrossOrigin
@RequestMapping("/api/order")
public class OrderController {
@Autowired
OrdersMapper ordersMapper;
@Autowired
UserMapper userMapper;
LambdaQueryWrapper<Orders> wrapper = new LambdaQueryWrapper<>();
@ApiOperation(value = "发布订单")
@PostMapping("/publish")
public ResponseData publish(@RequestBody Orders data) {
// Orders orders = JSON.parseObject(String.valueOf(data), Orders.class);
Orders query = ordersMapper.selectOne(wrapper.eq(Orders::getOrderid, data.getOrderid()));
if (query == null) {
ordersMapper.insert(data);
} else {
ordersMapper.update(data, wrapper.eq(Orders::getOrderid, data.getOrderid()));
}
return ResponseData.success(EnumCode.SUCCESS);
}
@ApiOperation(value = "获取所有未接订单")
@GetMapping("/getOrders")
public ResponseData<?> getorder() {
List<JSONObject> orders = ordersMapper.selectJoinList(JSONObject.class, new MPJLambdaWrapper<Orders>()
.selectAll(Orders.class) // 查询所有的订单
.selectIgnore(Orders::getVerifyCode)
.selectAll(User.class)
.selectIgnore(User::getIdCard, User::getId) // 不查询某些字段
.eq(Orders::getRecStatus, 0) // 未接收订单
.leftJoin(User.class, User::getOpenid, Orders::getOpenid) // 把user表加入到订单表
.orderByDesc(Orders::getPublishTime) // 根距发布时间降序排序
);
// 处理数组字段
orders.forEach(o -> {
o.put("tags", JSONObject.parseArray(o.get("tags").toString()));
o.put("code", JSONObject.parseArray(o.get("code").toString()));
o.put("steps", JSONObject.parseArray(o.get("steps").toString()));
});
System.out.println(orders);
return ResponseData.success(orders);
}
@ApiOperation("模糊搜索")
@GetMapping("/search")
public ResponseData<?> search(@RequestParam String key) {
List<JSONObject> orders = ordersMapper.selectJoinList(JSONObject.class, new MPJLambdaWrapper<Orders>()
.selectAll(Orders.class) // 查询所有的订单
.selectIgnore(Orders::getVerifyCode)
.selectAll(User.class)
.selectIgnore(User::getIdCard, User::getId) // 不查询某些字段
.eq(Orders::getRecStatus, 0)
.like(User::getAddress, key)
.leftJoin(User.class, User::getOpenid, Orders::getOpenid) // 把user表加入到订单表
.orderByDesc(Orders::getPublishTime) // 根距发布时间降序排序
);
// 处理数组字段
orders.forEach(o -> {
o.put("tags", JSONObject.parseArray(o.get("tags").toString()));
o.put("code", JSONObject.parseArray(o.get("code").toString()));
o.put("steps", JSONObject.parseArray(o.get("steps").toString()));
});
return ResponseData.success(orders);
}
@ApiOperation("接收订单")
@PostMapping("/recorder")
public ResponseData<?> recorder(@RequestBody JSONObject data) {
if (data != null) {
User user = userMapper.selectOne(new LambdaQueryWrapper<User>().eq(User::getOpenid, data.getString("openid")));
if (user !=null && user.getIdCard() != null && StringUtils.hasText(user.getIdCard())) {
Orders orders = new Orders();
orders.setSteps(data.getJSONArray("steps"));
orders.setRecStatus(1);
ordersMapper.update(orders, new LambdaQueryWrapper<Orders>().eq(Orders::getOrderid, data.getString("orderid")));
return ResponseData.success(EnumCode.SUCCESS);
} else {
return ResponseData.error(EnumCode.AUTH_ERROR);
}
} else {
return ResponseData.error(EnumCode.PARAM_ERROR);
}
}
@ApiOperation("我接的订单")
@GetMapping("/myorder")
public ResponseData<?> myorder(@RequestParam String openid) {
if (openid.length() > 0) {
List<JSONObject> orders = ordersMapper.selectJoinList(JSONObject.class, new MPJLambdaWrapper<Orders>()
.selectAll(Orders.class) // 查询所有的订单
.selectIgnore(Orders::getVerifyCode)
.selectAll(User.class)
.selectIgnore(User::getIdCard, User::getId) // 不查询某些字段
.eq(Orders::getRecStatus, 1) // 已接收订单
.eq(Orders::getIsComplete, 0)
.apply("JSON_EXTRACT(steps,CONCAT(\"$[\",JSON_LENGTH(steps)-1,\"].openid\")) = {0}", openid) // 根据json数组最后一个JSON对象中的openid的值做判断
.leftJoin(User.class, User::getOpenid, Orders::getOpenid) // 把user表加入到订单表
.orderByDesc(Orders::getPublishTime) // 根距发布时间降序排序
);
// 处理数组字段
orders.forEach(o -> {
o.put("tags", JSONObject.parseArray(o.get("tags").toString()));
o.put("code", JSONObject.parseArray(o.get("code").toString()));
o.put("steps", JSONObject.parseArray(o.get("steps").toString()));
});
return ResponseData.success(orders);
} else {
return ResponseData.error(EnumCode.PARAM_ERROR);
}
}
@ApiOperation("我接的已完成订单")
@GetMapping("/myCompleteOrder")
public ResponseData<?> mycompleteorder(@RequestParam String openid) {
if (openid.length() > 0) {
List<JSONObject> orders = ordersMapper.selectJoinList(JSONObject.class, new MPJLambdaWrapper<Orders>()
.selectAll(Orders.class) // 查询所有的订单
.selectAll(User.class)
.selectIgnore(User::getIdCard, User::getId) // 不查询某些字段
.eq(Orders::getIsComplete, 1) // 已完成订单
.apply("JSON_EXTRACT(steps,CONCAT(\"$[\",JSON_LENGTH(steps)-1,\"].openid\")) = {0}", openid) // 根据json数组最后一个JSON对象中的openid的值做判断
.leftJoin(User.class, User::getOpenid, Orders::getOpenid) // 把user表加入到订单表
.orderByDesc(Orders::getPublishTime) // 根距发布时间降序排序
);
// 处理数组字段
orders.forEach(o -> {
o.put("tags", JSONObject.parseArray(o.get("tags").toString()));
o.put("code", JSONObject.parseArray(o.get("code").toString()));
o.put("steps", JSONObject.parseArray(o.get("steps").toString()));
});
return ResponseData.success(orders);
} else {
return ResponseData.error(EnumCode.PARAM_ERROR);
}
}
@ApiOperation("取消接收订单")
@PostMapping("/cancelMyOrder")
public ResponseData<?> cancleMyOrder(@RequestBody JSONObject data) {
if (data != null) {
Orders orders = new Orders();
orders
没有合适的资源?快使用搜索试试~ 我知道了~
基于微信小程序的校园快递代取小程序源码+数据库(95分以上期末大作业).zip
共548个文件
js:106个
ts:95个
wxss:85个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 142 浏览量
2023-08-12
22:30:25
上传
评论
收藏 1.76MB ZIP 举报
温馨提示
基于微信小程序的校园快递代取小程序源码+数据库(95分以上期末大作业).zip 感谢李老师的耐心指导,代码完整下载可用,微信小程序期末大作业,微信小程序课程设计,基于微信小程序开发的,期末大作业、课程设计、高分必看,已获高分通过项目。 基于微信小程序的校园快递代取小程序源码+数据库(95分以上期末大作业).zip 感谢李老师的耐心指导,代码完整下载可用,微信小程序期末大作业,微信小程序课程设计,基于微信小程序开发的,期末大作业、课程设计、高分必看,已获高分通过项目。基于微信小程序的校园快递代取小程序源码+数据库(95分以上期末大作业).zip 感谢李老师的耐心指导,代码完整下载可用,微信小程序期末大作业,微信小程序课程设计,基于微信小程序开发的,期末大作业、课程设计、高分必看,已获高分通过项目。基于微信小程序的校园快递代取小程序源码+数据库(95分以上期末大作业).zip 感谢李老师的耐心指导,代码完整下载可用,微信小程序期末大作业,微信小程序课程设计,基于微信小程序开发的,期末大作业、课程设计、高分必看,已获高分通过项目。基于微信小程序的校园快递代取小程序源码+数据库(95分以上期
资源推荐
资源详情
资源评论
收起资源包目录
基于微信小程序的校园快递代取小程序源码+数据库(95分以上期末大作业).zip (548个子文件)
mvnw.cmd 7KB
.gitignore 395B
.gitignore 145B
maven-wrapper.jar 57KB
OrderController.java 12KB
HttpUtils.java 10KB
CodeGenerator.java 9KB
UserController.java 7KB
ResponseData.java 3KB
Orders.java 2KB
Swagger2Configuration.java 2KB
EnumCode.java 2KB
WebConfig.java 1KB
User.java 1KB
SchoolExpressApplicationTests.java 1KB
SchoolExpressApplication.java 534B
OrdersMapper.java 362B
UserMapper.java 355B
index.js 12KB
index.js 12KB
index.js 10KB
index.js 9KB
publish.js 9KB
index.js 8KB
user.js 7KB
index.js 7KB
index.js 7KB
index.js 7KB
index.js 6KB
index.js 6KB
myorder.js 6KB
index.js 5KB
transition.js 5KB
index.js 4KB
index.js 4KB
agencyorder.js 4KB
index.js 4KB
index.js 4KB
index.js 4KB
utils.js 4KB
index.js 4KB
index.js 4KB
index.js 3KB
index.js 3KB
utils.js 3KB
utils.js 3KB
index.js 3KB
index.js 3KB
dialog.js 3KB
index.js 3KB
toast.js 3KB
index.js 2KB
index.js 2KB
index.js 2KB
relation.js 2KB
index.js 2KB
index.js 2KB
notify.js 2KB
index.js 2KB
utils.js 2KB
index.js 2KB
index.js 2KB
index.js 2KB
index.js 2KB
index.js 2KB
index.js 2KB
index.js 2KB
version.js 2KB
app.js 2KB
index.js 2KB
index.js 2KB
page-scroll.js 2KB
index.js 1KB
button.js 1KB
validator.js 1KB
index.js 1KB
index.js 1KB
index.js 1KB
index.js 1KB
component.js 1KB
agencyOrderDetail.js 1KB
props.js 1KB
canvas.js 1KB
icon.js 1KB
index.js 1KB
index.js 1KB
animate.js 1KB
touch.js 1KB
index.js 1KB
index.js 1KB
index.js 1KB
index.js 1KB
index.js 1KB
index.js 992B
index.js 981B
index.js 900B
options.js 884B
index.js 861B
link.js 747B
index.js 732B
共 548 条
- 1
- 2
- 3
- 4
- 5
- 6
资源评论
不安分的小女孩
- 粉丝: 9218
- 资源: 2001
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功