240401
This commit is contained in:
@@ -1,182 +0,0 @@
|
||||
package com.gxwebsoft.open.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alipay.api.AlipayApiException;
|
||||
import com.alipay.api.DefaultAlipayClient;
|
||||
import com.alipay.api.request.AlipaySystemOauthTokenRequest;
|
||||
import com.alipay.api.request.AlipayUserInfoShareRequest;
|
||||
import com.alipay.api.response.AlipaySystemOauthTokenResponse;
|
||||
import com.alipay.api.response.AlipayUserInfoShareResponse;
|
||||
import com.gxwebsoft.common.core.config.ConfigProperties;
|
||||
import com.gxwebsoft.common.core.exception.BusinessException;
|
||||
import com.gxwebsoft.common.core.security.JwtSubject;
|
||||
import com.gxwebsoft.common.core.security.JwtUtil;
|
||||
import com.gxwebsoft.common.core.utils.AlipayConfigUtil;
|
||||
import com.gxwebsoft.common.core.utils.CommonUtil;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.LoginRecord;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.common.system.entity.UserRole;
|
||||
import com.gxwebsoft.common.system.param.UserParam;
|
||||
import com.gxwebsoft.common.system.result.LoginResult;
|
||||
import com.gxwebsoft.common.system.service.LoginRecordService;
|
||||
import com.gxwebsoft.common.system.service.UserRoleService;
|
||||
import com.gxwebsoft.common.system.service.UserService;
|
||||
import com.gxwebsoft.shop.entity.UserOauth;
|
||||
import com.gxwebsoft.shop.mapper.UserOauthMapper;
|
||||
import com.gxwebsoft.shop.param.UserOauthParam;
|
||||
import com.gxwebsoft.shop.service.UserOauthService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import static com.gxwebsoft.common.core.utils.CommonUtil.randomUsername;
|
||||
|
||||
/**
|
||||
* 登录认证控制器
|
||||
*
|
||||
* @author WebSoft
|
||||
* @since 2018-12-24 16:10:11
|
||||
*/
|
||||
@Api(tags = "登录认证")
|
||||
@RestController
|
||||
@RequestMapping("/api/open/login-alipay")
|
||||
public class OpenAlipayController extends BaseController {
|
||||
@Resource
|
||||
private ConfigProperties configProperties;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
@Resource
|
||||
private LoginRecordService loginRecordService;
|
||||
@Resource
|
||||
private UserRoleService userRoleService;
|
||||
@Resource
|
||||
private UserOauthService userOauthService;
|
||||
@Resource
|
||||
private AlipayConfigUtil alipayConfig;
|
||||
@Resource
|
||||
private UserOauthMapper userOauthMapper;
|
||||
@Resource
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
@ApiOperation("支付宝授权码")
|
||||
@PostMapping("/getAuthCode")
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public ApiResult<?> getAuthCode(@RequestBody UserParam param, HttpServletRequest req) throws AlipayApiException {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
// 读取缓存信息
|
||||
String setting = stringRedisTemplate.opsForValue().get("cache"+param.getTenantId()+":setting:register");
|
||||
if(setting == null){
|
||||
throw new BusinessException("请先配置注册设置");
|
||||
}
|
||||
JSONObject jsonObject = JSONObject.parseObject(setting);
|
||||
String roleId = jsonObject.getString("roleId");
|
||||
// 实例化客户端
|
||||
DefaultAlipayClient alipayClient = alipayConfig.alipayClient(param.getTenantId());
|
||||
try {
|
||||
AlipaySystemOauthTokenRequest request = new AlipaySystemOauthTokenRequest();
|
||||
request.setGrantType("authorization_code");
|
||||
request.setCode(param.getAuthCode());
|
||||
AlipaySystemOauthTokenResponse response = alipayClient.certificateExecute(request);
|
||||
if (response.isSuccess()) {
|
||||
final String accessToken = response.getAccessToken();
|
||||
AlipayUserInfoShareRequest request2 = new AlipayUserInfoShareRequest();
|
||||
AlipayUserInfoShareResponse userInfo = alipayClient.certificateExecute(request2, accessToken);
|
||||
String nickName = "支付宝用户";
|
||||
String avatar = "";
|
||||
if(StrUtil.isNotBlank(userInfo.getAvatar())){
|
||||
avatar = userInfo.getAvatar();
|
||||
}
|
||||
if (StrUtil.isNotBlank(userInfo.getNickName())) {
|
||||
nickName = userInfo.getNickName();
|
||||
}
|
||||
if(userInfo.isSuccess()){
|
||||
// 查询是否已注册
|
||||
UserOauthParam userOauthParam = new UserOauthParam();
|
||||
userOauthParam.setOauthId(userInfo.getUserId());
|
||||
userOauthParam.setTenantId(param.getTenantId());
|
||||
UserOauth userOauth = userOauthParam.getOne(userOauthMapper.getByOauthId(userOauthParam));
|
||||
if(userOauth != null){
|
||||
UserParam userParam = new UserParam();
|
||||
userParam.setUserId(userOauth.getUserId());
|
||||
userParam.setTenantId(userOauth.getTenantId());
|
||||
User user = userService.getByOauthId(userParam);
|
||||
if(user != null){
|
||||
// 签发token
|
||||
String access_token = JwtUtil.buildToken(new JwtSubject(user.getUsername(), user.getTenantId()),
|
||||
configProperties.getTokenExpireTime(), configProperties.getTokenKey());
|
||||
return success("登录成功", new LoginResult(access_token, user));
|
||||
}
|
||||
userOauthService.removeById(userOauth.getId());
|
||||
}
|
||||
// 新注册用户
|
||||
User user = new User();
|
||||
user.setStatus(0);
|
||||
user.setUsername(randomUsername("Ali_"));
|
||||
user.setNickname(nickName);
|
||||
user.setAvatar(avatar);
|
||||
user.setCity(userInfo.getCity());
|
||||
user.setProvince(userInfo.getProvince());
|
||||
user.setPassword(userService.encodePassword(CommonUtil.randomUUID16()));
|
||||
user.setTenantId(param.getTenantId());
|
||||
boolean isSuccess = userService.saveUser(user);
|
||||
if(isSuccess){
|
||||
// 添加用户角色
|
||||
UserRole userRole = new UserRole();
|
||||
userRole.setUserId(user.getUserId());
|
||||
userRole.setTenantId(param.getTenantId());
|
||||
userRole.setRoleId(Integer.valueOf(roleId));
|
||||
userRoleService.save(userRole);
|
||||
// 添加第三方用户信息
|
||||
UserOauth userOauth2 = new UserOauth();
|
||||
userOauth2.setUserId(user.getUserId());
|
||||
userOauth2.setTenantId(param.getTenantId());
|
||||
userOauth2.setOauthType("MP-ALIPAY");
|
||||
userOauth2.setOauthId(userInfo.getUserId());
|
||||
userOauthService.save(userOauth2);
|
||||
|
||||
UserParam userParam = new UserParam();
|
||||
userParam.setUserId(user.getUserId());
|
||||
userParam.setTenantId(user.getTenantId());
|
||||
User result = userService.getByOauthId(userParam);
|
||||
loginRecordService.saveAsync(result.getUsername(), LoginRecord.TYPE_REGISTER, null, result.getTenantId(), req);
|
||||
// 签发token
|
||||
String access_token = JwtUtil.buildToken(new JwtSubject(result.getUsername(), result.getTenantId()),
|
||||
configProperties.getTokenExpireTime(), configProperties.getTokenKey());
|
||||
return success("登录成功", new LoginResult(access_token, result));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (AlipayApiException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return fail("支付宝授权失败");
|
||||
}
|
||||
|
||||
@ApiOperation("授权手机号码")
|
||||
@PostMapping("/update")
|
||||
public ApiResult<User> updateInfo(@RequestBody User user) {
|
||||
user.setUserId(getLoginUserId());
|
||||
// 不能修改的字段
|
||||
user.setUsername(null);
|
||||
user.setPassword(null);
|
||||
user.setEmailVerified(null);
|
||||
user.setOrganizationId(null);
|
||||
user.setStatus(null);
|
||||
if (userService.updateById(user)) {
|
||||
return success(userService.getByIdRel(user.getUserId()));
|
||||
}
|
||||
return fail("保存失败", null);
|
||||
}
|
||||
}
|
||||
@@ -1,123 +0,0 @@
|
||||
package com.gxwebsoft.open.controller;
|
||||
|
||||
import com.gxwebsoft.apps.entity.BcAgent;
|
||||
import com.gxwebsoft.apps.param.BcAgentParam;
|
||||
import com.gxwebsoft.apps.service.BcAgentService;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 代报餐管理控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2023-04-24 19:25:59
|
||||
*/
|
||||
@Api(tags = "代报餐管理管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/open/bc-agent")
|
||||
public class OpenBcAgentController extends BaseController {
|
||||
@Resource
|
||||
private BcAgentService bcAgentService;
|
||||
|
||||
@ApiOperation("分页查询代报餐管理")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<BcAgent>> page(BcAgentParam param) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
// 使用关联查询
|
||||
param.setParentId(getLoginUserId());
|
||||
return success(bcAgentService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部代报餐管理")
|
||||
@GetMapping()
|
||||
public ApiResult<List<BcAgent>> list(BcAgentParam param) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
// 使用关联查询
|
||||
param.setParentId(getLoginUserId());
|
||||
return success(bcAgentService.listRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询代报餐管理")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<BcAgent> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(bcAgentService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加代报餐管理")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody BcAgent bcAgent) {
|
||||
if (bcAgentService.save(bcAgent)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('apps:bcAgent:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改代报餐管理")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody BcAgent bcAgent) {
|
||||
if (bcAgentService.updateById(bcAgent)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('apps:bcAgent:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除代报餐管理")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (bcAgentService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('apps:bcAgent:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加代报餐管理")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<BcAgent> list) {
|
||||
if (bcAgentService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('apps:bcAgent:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改代报餐管理")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<BcAgent> batchParam) {
|
||||
if (batchParam.update(bcAgentService, "agent_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('apps:bcAgent:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除代报餐管理")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (bcAgentService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,481 +0,0 @@
|
||||
package com.gxwebsoft.open.controller;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.gxwebsoft.apps.entity.BcEquipment;
|
||||
import com.gxwebsoft.apps.param.BcEquipmentParam;
|
||||
import com.gxwebsoft.apps.service.BcEquipmentService;
|
||||
import com.gxwebsoft.apps.utils.BcUtil;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.common.system.service.UserService;
|
||||
import com.gxwebsoft.shop.entity.Order;
|
||||
import com.gxwebsoft.shop.entity.OrderGoods;
|
||||
import com.gxwebsoft.shop.entity.UserReferee;
|
||||
import com.gxwebsoft.shop.param.OrderGoodsParam;
|
||||
import com.gxwebsoft.shop.param.OrderParam;
|
||||
import com.gxwebsoft.shop.param.UserRefereeParam;
|
||||
import com.gxwebsoft.shop.service.OrderGoodsService;
|
||||
import com.gxwebsoft.shop.service.OrderService;
|
||||
import com.gxwebsoft.shop.service.UserRefereeService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.gxwebsoft.common.core.constants.OrderConstants.*;
|
||||
import static com.gxwebsoft.shop.constants.OrderConstants.ORDER_GOODS_DELIVERY_STATUS20;
|
||||
|
||||
/**
|
||||
* 云报餐机器接口
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2023-04-24 19:25:59
|
||||
*/
|
||||
@Api(tags = "云报餐机器接口")
|
||||
@RestController
|
||||
@RequestMapping("/hxz/v1")
|
||||
public class OpenBcController extends BaseController {
|
||||
@Resource
|
||||
private BcUtil bcUtil;
|
||||
@Resource
|
||||
private OrderService orderService;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
@Resource
|
||||
private OrderGoodsService orderGoodsService;
|
||||
@Resource
|
||||
private UserRefereeService userRefereeService;
|
||||
@Resource
|
||||
private BcEquipmentService bcEquipmentService;
|
||||
|
||||
@ApiOperation("获取服务器时间接口")
|
||||
@PostMapping("/ServerTime")
|
||||
public HashMap<String, Object> ServerTime(HttpServletRequest request) {
|
||||
final String deviceId = request.getHeader("Device-ID"); // 设备ID
|
||||
final String now = DateUtil.format(DateUtil.date(), "yyyyMMddHHmmss") + (DateUtil.thisDayOfWeek() - 1); // 服务器时间
|
||||
System.out.println(deviceId + "获取服务器时间接口 = " + now);
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("Status",1);
|
||||
map.put("Msg","服务器时间");
|
||||
map.put("Time", now);
|
||||
return map;
|
||||
}
|
||||
|
||||
@ApiOperation("付款码(二维码)支付接口")
|
||||
@PostMapping("/QRCodeTransaction")
|
||||
public HashMap<String, Object> QRCodeTransaction(@RequestBody String QR, HttpServletRequest request) {
|
||||
// 1.提取订单号ID
|
||||
final String deviceId = request.getHeader("Device-ID"); // 设备ID
|
||||
final JSONObject jsonObject = JSONObject.parseObject(QR);
|
||||
final String orderNo = jsonObject.getString("QR");
|
||||
|
||||
System.out.println("deviceId = " + deviceId);
|
||||
System.out.println("QR = " + QR);
|
||||
|
||||
// 2.查询订单数据
|
||||
|
||||
// 3.查询该餐段的菜品
|
||||
|
||||
// 4.核销菜品
|
||||
|
||||
// 5.通知设备
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("Status",1);
|
||||
map.put("Msg","支付成功");
|
||||
map.put("Qrorder", orderNo);
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
@ApiOperation("二维码支付结果查询接口")
|
||||
@PostMapping("/TransactionInquiry")
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public HashMap<String, Object> TransactionInquiry(@RequestBody String QROrder, HttpServletRequest request) {
|
||||
// 1. 提取订单号
|
||||
final JSONObject jsonObject = JSONObject.parseObject(QROrder);
|
||||
final String orderNo = jsonObject.getString("QROrder");
|
||||
StringBuilder foods = new StringBuilder(); // 消费机回显信息
|
||||
String DeviceID = request.getHeader("Device-ID"); // 设备ID
|
||||
|
||||
final BcEquipmentParam bcEquipmentParam = new BcEquipmentParam();
|
||||
bcEquipmentParam.setEquipmentCode(DeviceID);
|
||||
final List<BcEquipment> bcEquipments = bcEquipmentService.listRel(bcEquipmentParam);
|
||||
final BcEquipment bcEquipment = bcEquipments.get(0);
|
||||
final Integer gear = bcEquipment.getGear(); // 设备所属档口
|
||||
final Integer categoryId = bcUtil.getCurrentPeriod(bcEquipment.getTenantId()); // 餐段
|
||||
// int categoryId = 26;
|
||||
// 是否有取餐数据
|
||||
boolean isSuccess = true;
|
||||
|
||||
// 打印测试
|
||||
System.out.println("查询支付结果(订单号:)******** = " + orderNo);
|
||||
System.out.println("bcEquipment = " + bcEquipment);
|
||||
System.out.println("gear = " + gear);
|
||||
System.out.println("StrUtil.isNumeric(orderNo) = " + StrUtil.isNumeric(orderNo));
|
||||
|
||||
// 2.非代取餐模式
|
||||
if (!orderNo.startsWith("dqc:")) {
|
||||
System.out.println("非代取餐模式 = ");
|
||||
// 4.排除其他情况
|
||||
if(!StrUtil.isNumeric(orderNo)){
|
||||
foods.append("非取餐码");
|
||||
isSuccess = false;
|
||||
}else{
|
||||
OrderParam orderParam = new OrderParam();
|
||||
orderParam.setOrderNo(orderNo);
|
||||
List<Order> list = orderService.listRel(orderParam);
|
||||
Order order = list.get(0);
|
||||
// System.out.println("order-one = " + order);
|
||||
OrderGoodsParam orderGoodsParam = new OrderGoodsParam();
|
||||
// 2.1查询订单商品
|
||||
List<OrderGoods> orderGoods = orderGoodsService.list(new LambdaQueryWrapper<OrderGoods>()
|
||||
.eq(OrderGoods::getOrderId, order.getOrderId())
|
||||
.eq(OrderGoods::getDeliveryStatus,RECEIPT_STATUS_NO)
|
||||
.eq(OrderGoods::getCategoryId,categoryId)
|
||||
.eq(OrderGoods::getGear,gear)
|
||||
);
|
||||
// System.out.println("2.1查询订单商品 = " + orderGoods);
|
||||
// 2.2查询用户信息
|
||||
User user = userService.getById(order.getUserId());
|
||||
// 2.收集菜品信息
|
||||
foods.append("姓名:").append(order.getNickname()).append("\r\n");
|
||||
// foods.append("签到:").append(DateUtil.format(DateUtil.date(),"MM-dd HH:mm")).append("\r\n");
|
||||
for (OrderGoods item : orderGoods) {
|
||||
// 过滤份数totalNum=0的菜品
|
||||
if (!item.getTotalNum().equals(0)) {
|
||||
foods.append(item.getGoodsName()).append(" ").append(item.getTotalNum()).append("份").append(" ¥").append(item.getTotalPrice()).append("\r\n");
|
||||
OrderGoods food = new OrderGoods();
|
||||
food.setOrderGoodsId(item.getOrderGoodsId());
|
||||
food.setDeliveryStatus(ORDER_GOODS_DELIVERY_STATUS20);
|
||||
orderGoodsService.updateById(food);
|
||||
// 更新订单部分发布状态
|
||||
final Order order1 = new Order();
|
||||
order1.setOrderId(item.getOrderId());
|
||||
if(categoryId == 27){
|
||||
order1.setDeliveryStatus(DELIVERY_STATUS_YES);
|
||||
}else{
|
||||
order1.setDeliveryStatus(DELIVERY_STATUS_30);
|
||||
}
|
||||
orderService.updateById(order1);
|
||||
}
|
||||
}
|
||||
if(orderGoods.size() == 0){
|
||||
foods.append("没有取餐数据");
|
||||
isSuccess = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3.代取餐模式
|
||||
ArrayList<OrderGoods> saveOrderGoods = new ArrayList<>();
|
||||
ArrayList<Order> saveOrder = new ArrayList<>();
|
||||
if(orderNo.startsWith("dqc:")){
|
||||
System.out.println("代取餐模式 = ");
|
||||
final String dealerId = StrUtil.removePrefix(orderNo, "dqc:");
|
||||
System.out.println("dealerId = " + dealerId);
|
||||
UserRefereeParam userRefereeParam = new UserRefereeParam();
|
||||
userRefereeParam.setDealerId(Integer.valueOf(dealerId));
|
||||
userRefereeParam.setDeleted(0);
|
||||
List<UserReferee> userRefereeList = userRefereeService.listRel(userRefereeParam);
|
||||
// 查询帮代餐的成员ID集
|
||||
List<Integer> userIds = userRefereeList.stream().map(UserReferee::getUserId).collect(Collectors.toList());
|
||||
userIds.add(Integer.valueOf(dealerId));
|
||||
System.out.println("userIds = " + userIds);
|
||||
// 查询成员的订单
|
||||
List<Order> list = orderService.list(new LambdaQueryWrapper<Order>()
|
||||
.in(Order::getUserId, userIds)
|
||||
.eq(Order::getDeliveryTime, DateUtil.parse(DateUtil.today()))
|
||||
.eq(Order::getPayStatus, PAY_STATUS_SUCCESS)
|
||||
.ne(Order::getDeliveryStatus, RECEIPT_STATUS_YES)
|
||||
.eq(Order::getDeleted, 0)
|
||||
);
|
||||
System.out.println("list = " + list.size());
|
||||
if(list.size() > 0){
|
||||
// 收集订单ID集
|
||||
List<Integer> orderIds = list.stream().map(Order::getOrderId).collect(Collectors.toList());
|
||||
System.out.println("orderIds = " + orderIds);
|
||||
// 查询商品
|
||||
if(orderIds.size() > 0){
|
||||
List<OrderGoods> orderGoodsList = orderGoodsService.list(new LambdaQueryWrapper<OrderGoods>()
|
||||
.in(OrderGoods::getOrderId, orderIds)
|
||||
.ne(OrderGoods::getDeliveryStatus,RECEIPT_STATUS_YES)
|
||||
.gt(OrderGoods::getTotalNum,0)
|
||||
.eq(OrderGoods::getCategoryId,categoryId)
|
||||
.eq(OrderGoods::getGear,gear)
|
||||
);
|
||||
if (orderGoodsList.size() == 0) {
|
||||
foods.append("没有取餐数据");
|
||||
isSuccess = false;
|
||||
}
|
||||
System.out.println("orderGoodsList = " + orderGoodsList.size());
|
||||
// 查询用户信息
|
||||
User dealer = userService.getById(dealerId);
|
||||
foods.append("代取:").append(dealer.getNickname()).append("\r\n");
|
||||
foods.append("共" + orderGoodsList.size() + "份").append("\r\n");
|
||||
// foods.append("签到:").append(DateUtil.format(DateUtil.date(),"MM-dd HH:mm")).append("\r\n");
|
||||
// 批量核销操作
|
||||
for (OrderGoods og : orderGoodsList) {
|
||||
System.out.println("og = " + og);
|
||||
foods.append(og.getGoodsName()).append("\r\n");
|
||||
final OrderGoods orderGoods = new OrderGoods();
|
||||
orderGoods.setOrderGoodsId(og.getOrderGoodsId());
|
||||
orderGoods.setDeliveryStatus(ORDER_GOODS_DELIVERY_STATUS20);
|
||||
saveOrderGoods.add(orderGoods);
|
||||
// 更新订单部分发货状态
|
||||
Order order2 = new Order();
|
||||
order2.setOrderId(og.getOrderId());
|
||||
if(categoryId == 27){
|
||||
order2.setDeliveryStatus(DELIVERY_STATUS_YES);
|
||||
}else{
|
||||
order2.setDeliveryStatus(DELIVERY_STATUS_30);
|
||||
}
|
||||
saveOrder.add(order2);
|
||||
}
|
||||
}else{
|
||||
foods.append("没有取餐数据");
|
||||
isSuccess = false;
|
||||
}
|
||||
}else{
|
||||
foods.append("没有取餐数据");
|
||||
isSuccess = false;
|
||||
}
|
||||
}
|
||||
// 4.更新状态
|
||||
orderGoodsService.updateBatchById(saveOrderGoods);
|
||||
orderService.updateBatchById(saveOrder);
|
||||
|
||||
// 5.通知设备
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("Status", 1);
|
||||
map.put("Msg","");
|
||||
map.put("Name", "");
|
||||
map.put("CardNo", "");
|
||||
map.put("Money", "");
|
||||
map.put("Subsidy", "");
|
||||
map.put("Times", "");
|
||||
map.put("Integral", "");
|
||||
map.put("InTime", "");
|
||||
map.put("OutTime", "");
|
||||
map.put("CumulativeTime ", "");
|
||||
map.put("Amount","0.00");
|
||||
map.put("VoiceID",null);
|
||||
map.put("Text", foods);
|
||||
|
||||
// 5.1无取餐数据
|
||||
if(!isSuccess){
|
||||
map.put("Status", 0);
|
||||
map.put("Msg","没有取餐数据");
|
||||
map.put("Text",null);
|
||||
System.out.println("5.1无取餐数据 = " + map);
|
||||
return map;
|
||||
}
|
||||
System.out.println("5.通知设备 = " + map);
|
||||
return map;
|
||||
}
|
||||
|
||||
@ApiOperation("终端查询日统计接口")
|
||||
@PostMapping("/Counts")
|
||||
public HashMap<String, Object> Counts(HttpServletRequest request) {
|
||||
|
||||
final String deviceId = request.getHeader("Device-ID");
|
||||
System.out.println("deviceId = " + deviceId);
|
||||
final Integer categoryId = bcUtil.getCurrentPeriod(10048);
|
||||
System.out.println("categoryId = " + categoryId);
|
||||
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("Status",1);
|
||||
map.put("Msg","终端查询日统计接口");
|
||||
map.put("Text", "" +
|
||||
"日统计\n" +
|
||||
"日总金额:0.00\n" +
|
||||
"日总次数:0\n" +
|
||||
"时段统计\n" +
|
||||
"一时段金额:0.00\n" +
|
||||
"一时段次数:0" +
|
||||
"");
|
||||
|
||||
// 发送消息测试
|
||||
bcUtil.send("您的申请已通过");
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
// @ApiOperation("二维码支付结果查询接口")
|
||||
// @PostMapping("/demo")
|
||||
// @Transactional(rollbackFor = {Exception.class})
|
||||
// public HashMap<String, Object> demo(@RequestBody String QROrder, HttpServletRequest request) {
|
||||
// System.out.println("二维码支付结果查询接口 = " + QROrder);
|
||||
// // 1. 提取订单号
|
||||
// final JSONObject jsonObject = JSONObject.parseObject(QROrder);
|
||||
// final String orderNo = jsonObject.getString("QROrder");
|
||||
// StringBuilder foods = new StringBuilder(); // 消费机回显信息
|
||||
//// String DeviceID = request.getHeader("Device-ID"); // 设备ID
|
||||
////
|
||||
//// final BcEquipmentParam bcEquipmentParam = new BcEquipmentParam();
|
||||
//// bcEquipmentParam.setEquipmentCode(DeviceID);
|
||||
//// final List<BcEquipment> bcEquipments = bcEquipmentService.listRel(bcEquipmentParam);
|
||||
//// final BcEquipment bcEquipment = bcEquipments.get(0);
|
||||
// final Integer gear = 20; // 设备所属档口
|
||||
//// final Integer categoryId = bcUtil.getCurrentPeriod(bcEquipment.getTenantId()); // 餐段
|
||||
// int categoryId = 26;
|
||||
//
|
||||
// // 打印测试
|
||||
// System.out.println("查询支付结果(订单号:)******** = " + orderNo);
|
||||
// System.out.println("gear = " + gear);
|
||||
// System.out.println("StrUtil.isNumeric(orderNo) = " + StrUtil.isNumeric(orderNo));
|
||||
//
|
||||
// // 2.非代取餐模式
|
||||
// if (!orderNo.startsWith("dqc:")) {
|
||||
// System.out.println("非代取餐模式 = ");
|
||||
// // 4.排除其他情况
|
||||
// if(!StrUtil.isNumeric(orderNo)){
|
||||
// foods.append("非取餐码");
|
||||
// }else{
|
||||
// OrderParam orderParam = new OrderParam();
|
||||
// orderParam.setOrderNo(orderNo);
|
||||
// List<Order> list = orderService.listRel(orderParam);
|
||||
// Order order = list.get(0);
|
||||
// System.out.println("order-one = " + order);
|
||||
// OrderGoodsParam orderGoodsParam = new OrderGoodsParam();
|
||||
// // 2.1查询订单商品
|
||||
// List<OrderGoods> orderGoods = orderGoodsService.list(new LambdaQueryWrapper<OrderGoods>()
|
||||
// .eq(OrderGoods::getOrderId, order.getOrderId())
|
||||
// .eq(OrderGoods::getDeliveryStatus,RECEIPT_STATUS_NO)
|
||||
// .eq(OrderGoods::getCategoryId,categoryId)
|
||||
// .eq(OrderGoods::getGear,gear)
|
||||
// );
|
||||
// // 2.2查询用户信息
|
||||
// User user = userService.getById(order.getUserId());
|
||||
// // 2.收集菜品信息
|
||||
// foods.append("姓名:").append(order.getNickname()).append("\r\n");
|
||||
// foods.append("签到:").append(DateUtil.format(DateUtil.date(),"MM-dd HH:mm")).append("\r\n");
|
||||
// for (OrderGoods item : orderGoods) {
|
||||
// // 过滤份数totalNum=0的菜品
|
||||
// if (!item.getTotalNum().equals(0)) {
|
||||
// foods.append(item.getGoodsName()).append(" ").append(item.getTotalNum()).append("份").append(" ¥").append(item.getTotalPrice()).append("\r\n");
|
||||
// OrderGoods food = new OrderGoods();
|
||||
// food.setOrderGoodsId(item.getOrderGoodsId());
|
||||
// food.setDeliveryStatus(ORDER_GOODS_DELIVERY_STATUS20);
|
||||
// orderGoodsService.updateById(food);
|
||||
// // 更新订单部分发布状态
|
||||
// final Order order1 = new Order();
|
||||
// order1.setOrderId(item.getOrderId());
|
||||
// if(categoryId == 27){
|
||||
// order1.setDeliveryStatus(DELIVERY_STATUS_YES);
|
||||
// }else{
|
||||
// order1.setDeliveryStatus(DELIVERY_STATUS_30);
|
||||
// }
|
||||
// orderService.updateById(order1);
|
||||
// }
|
||||
// }
|
||||
// if(orderGoods.size() == 0){
|
||||
// foods.append("没有取餐数据");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // 3.代取餐模式
|
||||
// ArrayList<OrderGoods> saveOrderGoods = new ArrayList<>();
|
||||
// ArrayList<Order> saveOrder = new ArrayList<>();
|
||||
// if(orderNo.startsWith("dqc:")){
|
||||
// System.out.println("代取餐模式 = ");
|
||||
// final String dealerId = StrUtil.removePrefix(orderNo, "dqc:");
|
||||
// System.out.println("dealerId = " + dealerId);
|
||||
// UserRefereeParam userRefereeParam = new UserRefereeParam();
|
||||
// userRefereeParam.setDealerId(Integer.valueOf(dealerId));
|
||||
// userRefereeParam.setDeleted(0);
|
||||
// List<UserReferee> userRefereeList = userRefereeService.listRel(userRefereeParam);
|
||||
// // 查询帮代餐的成员ID集
|
||||
// List<Integer> userIds = userRefereeList.stream().map(UserReferee::getUserId).collect(Collectors.toList());
|
||||
// userIds.add(getLoginUserId());
|
||||
// System.out.println("userIds = " + userIds);
|
||||
// // 查询成员的订单
|
||||
// List<Order> list = orderService.list(new LambdaQueryWrapper<Order>()
|
||||
// .in(Order::getUserId, userIds)
|
||||
// .eq(Order::getDeliveryTime, DateUtil.parse(DateUtil.today()))
|
||||
// .eq(Order::getPayStatus, PAY_STATUS_SUCCESS)
|
||||
// .ne(Order::getDeliveryStatus, RECEIPT_STATUS_YES)
|
||||
// .eq(Order::getDeleted, 0)
|
||||
// );
|
||||
// if(list.size() > 0){
|
||||
// // 收集订单ID集
|
||||
// List<Integer> orderIds = list.stream().map(Order::getOrderId).collect(Collectors.toList());
|
||||
// System.out.println("orderIds = " + orderIds);
|
||||
// // 查询商品
|
||||
// if(orderIds.size() > 0){
|
||||
// List<OrderGoods> orderGoodsList = orderGoodsService.list(new LambdaQueryWrapper<OrderGoods>()
|
||||
// .in(OrderGoods::getOrderId, orderIds)
|
||||
// .ne(OrderGoods::getDeliveryStatus,RECEIPT_STATUS_YES)
|
||||
// .gt(OrderGoods::getTotalNum,0)
|
||||
// .eq(OrderGoods::getCategoryId,categoryId)
|
||||
// .eq(OrderGoods::getGear,gear)
|
||||
// );
|
||||
// // 查询用户信息
|
||||
// User dealer = userService.getById(dealerId);
|
||||
// foods.append("代取:").append(dealer.getNickname()).append("\r\n");
|
||||
// foods.append("共" + orderGoodsList.size() + "份");
|
||||
//// foods.append("签到:").append(DateUtil.format(DateUtil.date(),"MM-dd HH:mm")).append("\r\n");
|
||||
// // 批量核销操作
|
||||
// for (OrderGoods og : orderGoodsList) {
|
||||
// foods.append(",").append(og.getGoodsName());
|
||||
// final OrderGoods orderGoods = new OrderGoods();
|
||||
// orderGoods.setOrderGoodsId(og.getOrderGoodsId());
|
||||
// orderGoods.setDeliveryStatus(ORDER_GOODS_DELIVERY_STATUS20);
|
||||
// saveOrderGoods.add(orderGoods);
|
||||
// // 更新订单部分发货状态
|
||||
// Order order2 = new Order();
|
||||
// order2.setOrderId(og.getOrderId());
|
||||
// if(categoryId == 27){
|
||||
// order2.setDeliveryStatus(DELIVERY_STATUS_YES);
|
||||
// }else{
|
||||
// order2.setDeliveryStatus(DELIVERY_STATUS_30);
|
||||
// }
|
||||
// saveOrder.add(order2);
|
||||
// }
|
||||
// }else{
|
||||
// foods.append("没有取餐数据");
|
||||
// }
|
||||
// }else{
|
||||
// foods.append("没有取餐数据");
|
||||
// }
|
||||
// }
|
||||
// // 4.更新状态
|
||||
// orderGoodsService.updateBatchById(saveOrderGoods);
|
||||
// orderService.updateBatchById(saveOrder);
|
||||
//
|
||||
// // 5.通知设备
|
||||
// HashMap<String, Object> map = new HashMap<>();
|
||||
// map.put("Status", 1);
|
||||
// map.put("Msg","");
|
||||
// map.put("Name", "");
|
||||
// map.put("CardNo", "");
|
||||
// map.put("Money", "");
|
||||
// map.put("Subsidy", "");
|
||||
// map.put("Times", "");
|
||||
// map.put("Integral", "");
|
||||
// map.put("InTime", "");
|
||||
// map.put("OutTime", "");
|
||||
// map.put("CumulativeTime ", "");
|
||||
// map.put("Amount","0.00");
|
||||
// map.put("VoiceID",null);
|
||||
// map.put("Text", foods);
|
||||
//
|
||||
// // 5.通知设备
|
||||
// System.out.println("通知设备 = " + map);
|
||||
// return map;
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -1,129 +0,0 @@
|
||||
package com.gxwebsoft.open.controller;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.gxwebsoft.apps.entity.BcTemporary;
|
||||
import com.gxwebsoft.apps.param.BcTemporaryParam;
|
||||
import com.gxwebsoft.apps.service.BcTemporaryService;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 临时报餐管理控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2023-04-24 21:47:57
|
||||
*/
|
||||
@Api(tags = "临时报餐管理管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/open/bc-temporary")
|
||||
public class OpenBcTemporaryController extends BaseController {
|
||||
@Resource
|
||||
private BcTemporaryService bcTemporaryService;
|
||||
|
||||
@ApiOperation("分页查询临时报餐管理")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<BcTemporary>> page(BcTemporaryParam param) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
// 使用关联查询
|
||||
param.setUserId(getLoginUserId());
|
||||
param.setDayTime(DateUtil.date());
|
||||
return success(bcTemporaryService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部临时报餐管理")
|
||||
@GetMapping()
|
||||
public ApiResult<List<BcTemporary>> list(BcTemporaryParam param) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
// 使用关联查询
|
||||
return success(bcTemporaryService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('apps:bcTemporary:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询临时报餐管理")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<BcTemporary> get(@PathVariable("id") Integer id) {
|
||||
return success(bcTemporaryService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(bcTemporaryService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('apps:bcTemporary:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加临时报餐管理")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody BcTemporary bcTemporary) {
|
||||
if (bcTemporaryService.save(bcTemporary)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('apps:bcTemporary:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改临时报餐管理")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody BcTemporary bcTemporary) {
|
||||
if (bcTemporaryService.updateById(bcTemporary)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('apps:bcTemporary:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除临时报餐管理")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (bcTemporaryService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('apps:bcTemporary:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加临时报餐管理")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<BcTemporary> list) {
|
||||
if (bcTemporaryService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('apps:bcTemporary:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改临时报餐管理")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<BcTemporary> batchParam) {
|
||||
if (batchParam.update(bcTemporaryService, "temporary_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('apps:bcTemporary:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除临时报餐管理")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (bcTemporaryService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -87,7 +87,7 @@ public class OpenCartController extends BaseController {
|
||||
}
|
||||
// 2.创建订单
|
||||
Order order = new Order();
|
||||
order.setOrderNo(IdUtil.getSnowflakeNextId());
|
||||
order.setOrderNo(makeOrderNumber(""));
|
||||
order.setTotalPrice(param.getTotalPrice());
|
||||
order.setOrderPrice(param.getTotalPrice());
|
||||
order.setPayPrice(param.getTotalPrice());
|
||||
|
||||
@@ -1,353 +0,0 @@
|
||||
package com.gxwebsoft.open.controller;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alipay.api.AlipayApiException;
|
||||
import com.alipay.api.DefaultAlipayClient;
|
||||
import com.alipay.api.domain.AlipayOpenAppQrcodeCreateModel;
|
||||
import com.alipay.api.request.AlipayOpenAppQrcodeCreateRequest;
|
||||
import com.alipay.api.response.AlipayOpenAppQrcodeCreateResponse;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.gxwebsoft.apps.entity.Equipment;
|
||||
import com.gxwebsoft.apps.entity.EquipmentRecord;
|
||||
import com.gxwebsoft.apps.param.EquipmentParam;
|
||||
import com.gxwebsoft.apps.service.EquipmentRecordService;
|
||||
import com.gxwebsoft.apps.service.EquipmentService;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.core.utils.AlipayConfigUtil;
|
||||
import com.gxwebsoft.common.core.web.*;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.shop.entity.Order;
|
||||
import com.gxwebsoft.shop.entity.OrderRefund;
|
||||
import com.gxwebsoft.shop.param.OrderParam;
|
||||
import com.gxwebsoft.shop.service.OrderRefundService;
|
||||
import com.gxwebsoft.shop.service.OrderService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
import static com.gxwebsoft.apps.constants.EquipmentConstants.*;
|
||||
import static com.gxwebsoft.common.core.constants.OrderConstants.*;
|
||||
|
||||
/**
|
||||
* 设备管理控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2022-11-30 02:11:16
|
||||
*/
|
||||
@Api(tags = "设备管理管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/open/equipment")
|
||||
public class OpenEquipmentController extends BaseController {
|
||||
@Resource
|
||||
private EquipmentService equipmentService;
|
||||
@Resource
|
||||
private OrderService orderService;
|
||||
@Resource
|
||||
private AlipayConfigUtil alipayConfig;
|
||||
@Resource
|
||||
private EquipmentRecordService equipmentRecordService;
|
||||
@Resource
|
||||
private OrderRefundService orderRefundService;
|
||||
|
||||
@PreAuthorize("hasAuthority('apps:equipment:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询设备管理")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<Equipment>> page(EquipmentParam param) {
|
||||
// 使用关联查询
|
||||
PageParam<Equipment, EquipmentParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
if (getMerchantCode() != null) {
|
||||
param.setMerchantCode(getMerchantCode());
|
||||
}
|
||||
return success(equipmentService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('apps:equipment:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部设备管理")
|
||||
@GetMapping()
|
||||
public ApiResult<List<Equipment>> list(EquipmentParam param) {
|
||||
PageParam<Equipment, EquipmentParam> page = new PageParam<>(param);
|
||||
// page.setDefaultOrder("create_time desc");
|
||||
// return success(equipmentService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
return success(equipmentService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('apps:equipment:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询设备管理")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<Equipment> get(@PathVariable("id") Integer id) {
|
||||
// return success(equipmentService.getById(id));
|
||||
// 使用关联查询
|
||||
return success(equipmentService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('apps:equipment:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加设备管理")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Equipment equipment) throws AlipayApiException {
|
||||
// 记录当前登录用户id、租户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null && getMerchantCode() != null) {
|
||||
equipment.setMerchantCode(getMerchantCode());
|
||||
}
|
||||
if (equipmentService.count(new LambdaQueryWrapper<Equipment>()
|
||||
.eq(Equipment::getEquipmentCode, equipment.getEquipmentCode())) > 0) {
|
||||
return fail("设备编号已存在");
|
||||
}
|
||||
if (equipmentService.save(equipment)) {
|
||||
// 生成二维码
|
||||
String qrcode = createQrcode(equipment);
|
||||
equipment.setQrcode(qrcode);
|
||||
equipmentService.saveOrUpdate(equipment);
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('apps:equipment:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改设备管理")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody Equipment equipment) throws AlipayApiException {
|
||||
if (equipmentService.updateById(equipment)) {
|
||||
// 生成二维码
|
||||
String qrcode = createQrcode(equipment);
|
||||
equipment.setQrcode(qrcode);
|
||||
equipmentService.saveOrUpdate(equipment);
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('apps:equipment:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除设备管理")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (equipmentService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('apps:equipment:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加设备管理")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<Equipment> list) {
|
||||
if (equipmentService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('apps:equipment:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改设备管理")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<Equipment> batchParam) {
|
||||
if (batchParam.update(equipmentService, "equipment_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('apps:equipment:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除设备管理")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (equipmentService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
// 生成支付宝小程序码
|
||||
private String createQrcode(Equipment equipment) throws AlipayApiException{
|
||||
// 实例化客户端
|
||||
DefaultAlipayClient alipayClient = alipayConfig.alipayClient(getTenantId());
|
||||
|
||||
AlipayOpenAppQrcodeCreateRequest request = new AlipayOpenAppQrcodeCreateRequest();
|
||||
AlipayOpenAppQrcodeCreateModel model = new AlipayOpenAppQrcodeCreateModel();
|
||||
model.setUrlParam("pages/checkout/checkout");
|
||||
model.setQueryParam("equipmentId=".concat(equipment.getEquipmentId().toString()).concat("&equipmentCode=").concat(equipment.getEquipmentCode()));
|
||||
model.setDescribe("扫码租赁电池");
|
||||
request.setBizModel(model);
|
||||
AlipayOpenAppQrcodeCreateResponse response = alipayClient.certificateExecute(request);
|
||||
System.out.println(response.getBody());
|
||||
if (response.isSuccess()) {
|
||||
System.out.println("调用成功");
|
||||
final JSONObject jsonObject = JSONObject.parseObject(response.getBody());
|
||||
final String alipay_open_app_qrcode_create_response = jsonObject.getString("alipay_open_app_qrcode_create_response");
|
||||
final JSONObject jsonObject1 = JSONObject.parseObject(alipay_open_app_qrcode_create_response);
|
||||
return jsonObject1.getString("qr_code_url");
|
||||
} else {
|
||||
System.out.println("调用失败");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation("绑定设备")
|
||||
@PostMapping("/bind")
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public ApiResult<?> bindEquipment(@RequestBody Equipment equipment) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
final Integer orderId = equipment.getOrderId();
|
||||
final String equipmentCode = equipment.getEquipmentCode();
|
||||
final Order order = orderService.getById(orderId);
|
||||
Equipment one = equipmentService.getByEquipmentCode(equipmentCode);
|
||||
if(one == null){
|
||||
return fail("设备不存在");
|
||||
}
|
||||
if(!one.getUserId().equals(0)){
|
||||
return fail("该设备已被绑定");
|
||||
}
|
||||
// 绑定设备
|
||||
Equipment saveData = new Equipment();
|
||||
saveData.setEquipmentId(one.getEquipmentId());
|
||||
saveData.setUserId(getLoginUserId());
|
||||
saveData.setOrderId(orderId);
|
||||
if (equipmentService.updateById(saveData)) {
|
||||
// 记录明细
|
||||
EquipmentRecord record = new EquipmentRecord();
|
||||
record.setEquipmentCode(one.getEquipmentCode());
|
||||
record.setUserId(getLoginUserId());
|
||||
record.setOrderId(orderId);
|
||||
record.setEventType(EVENT_TYPE_BIND);
|
||||
record.setComments("使用电池:");
|
||||
record.setMerchantCode(one.getMerchantCode());
|
||||
equipmentRecordService.save(record);
|
||||
// 订单发货
|
||||
order.setDeliveryStatus(DELIVERY_STATUS_YES);
|
||||
order.setOrderStatus(ORDER_STATUS_COMPLETED);
|
||||
order.setReceiptStatus(RECEIPT_STATUS_YES);
|
||||
order.setExpirationTime(DateUtil.nextMonth());
|
||||
order.setEquipmentId(one.getEquipmentId());
|
||||
orderService.updateById(order);
|
||||
return success("绑定成功");
|
||||
}
|
||||
return fail("绑定失败");
|
||||
}
|
||||
|
||||
@ApiOperation("更换设备")
|
||||
@PostMapping("/change")
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public ApiResult<?> changeEquipment(@RequestBody Equipment equipment) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
String equipmentCode = equipment.getEquipmentCode();
|
||||
Integer oid = equipment.getEquipmentId();
|
||||
Integer orderId = equipment.getOrderId();
|
||||
System.out.println("oid = " + oid);
|
||||
Integer loginUserId = getLoginUserId();
|
||||
// 新电池
|
||||
Equipment one = equipmentService.getByEquipmentCode(equipmentCode);
|
||||
// 旧电池
|
||||
Equipment old = equipmentService.getById(oid);
|
||||
// 订单信息
|
||||
Order order = orderService.getById(orderId);
|
||||
if(one == null){
|
||||
return fail("设备不存在");
|
||||
}
|
||||
if(!one.getUserId().equals(0)){
|
||||
return fail("该设备已被绑定");
|
||||
}
|
||||
|
||||
// 绑定新电池
|
||||
Equipment saveData = new Equipment();
|
||||
saveData.setEquipmentId(one.getEquipmentId());
|
||||
saveData.setUserId(loginUserId);
|
||||
saveData.setOrderId(orderId);
|
||||
boolean b = equipmentService.updateById(saveData);
|
||||
// 记录新电池明细
|
||||
EquipmentRecord record = new EquipmentRecord();
|
||||
record.setEquipmentCode(equipmentCode);
|
||||
record.setEventType(EVENT_TYPE_BIND);
|
||||
record.setUserId(loginUserId);
|
||||
record.setOrderId(orderId);
|
||||
record.setMerchantCode(one.getMerchantCode());
|
||||
equipmentRecordService.save(record);
|
||||
|
||||
if (b) {
|
||||
// 解绑旧电池
|
||||
old.setUserId(0);
|
||||
old.setMerchantCode(one.getMerchantCode());
|
||||
equipmentService.updateById(old);
|
||||
// 记录明细
|
||||
EquipmentRecord record2 = new EquipmentRecord();
|
||||
record2.setEquipmentCode(old.getEquipmentCode());
|
||||
record2.setUserId(loginUserId);
|
||||
record2.setOrderId(orderId);
|
||||
record2.setEventType(EVENT_TYPE_UNBIND);
|
||||
record2.setMerchantCode(one.getMerchantCode());
|
||||
equipmentRecordService.save(record2);
|
||||
// 更新订单
|
||||
order.setEquipmentId(one.getEquipmentId());
|
||||
orderService.updateById(order);
|
||||
return success("换电成功");
|
||||
}
|
||||
return fail("换电失败");
|
||||
}
|
||||
|
||||
@ApiOperation("重置")
|
||||
@PostMapping("/receipt")
|
||||
public ApiResult<?> receipt(@RequestBody Order order){
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
orderService.updateById(order);
|
||||
return success("重置成功");
|
||||
}
|
||||
|
||||
@ApiModelProperty("退租")
|
||||
@PostMapping("/rentingOut")
|
||||
public ApiResult<?> rentingOut(@RequestBody Order order){
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
final int count = orderRefundService.count(new LambdaQueryWrapper<OrderRefund>().eq(OrderRefund::getOrderId, order.getOrderId()));
|
||||
if(count > 0){
|
||||
return fail("申请成功,请等待客服人员审核");
|
||||
}
|
||||
final OrderRefund refund = new OrderRefund();
|
||||
refund.setOrderId(order.getOrderId());
|
||||
refund.setOrderGoodsId(order.getGoodsId());
|
||||
refund.setUserId(getLoginUserId());
|
||||
refund.setType(10);
|
||||
refund.setApplyDesc("申请退租");
|
||||
refund.setRefundMoney(new BigDecimal(0));
|
||||
refund.setMerchantCode(order.getMerchantCode());
|
||||
if (orderRefundService.save(refund)) {
|
||||
return success("申请成功,请等待客服人员审核");
|
||||
}
|
||||
return fail("退租失败");
|
||||
}
|
||||
|
||||
// @ApiModelProperty("退租")
|
||||
// @PostMapping("/rentingOut")
|
||||
// public ApiResult<?> rentingOut(@RequestBody Order order){
|
||||
// // 验证签名
|
||||
// isCheckSign();
|
||||
// order.setReceiptStatus(RECEIPT_STATUS_RETURN);
|
||||
// if(orderService.updateById(order)){
|
||||
// final Equipment equipment = equipmentService.getById(order.getEquipmentId());
|
||||
// equipment.setUserId(0);
|
||||
// equipmentService.updateById(equipment);
|
||||
// return success("操作成功,请等待客服人员审核");
|
||||
// }
|
||||
// return fail("退租失败");
|
||||
// }
|
||||
}
|
||||
@@ -65,7 +65,7 @@ public class OpenFileController extends BaseController {
|
||||
result.setThumbnail(requestURL + "/thumbnail/" + path);
|
||||
}
|
||||
result.setDownloadUrl(requestURL + "/download/" + path);
|
||||
result.setMerchantCode(getMerchantCode());
|
||||
// result.setMerchantCode(getMerchantCode());
|
||||
fileRecordService.save(result);
|
||||
return success(result);
|
||||
} catch (Exception e) {
|
||||
@@ -97,7 +97,7 @@ public class OpenFileController extends BaseController {
|
||||
result.setPath(path);
|
||||
result.setUrl(requestURL + path);
|
||||
result.setThumbnail(FileServerUtil.isImage(upload) ? (requestURL + "/thumbnail" + path) : null);
|
||||
result.setMerchantCode(getMerchantCode());
|
||||
// result.setMerchantCode(getMerchantCode());
|
||||
fileRecordService.save(result);
|
||||
return success(result);
|
||||
} catch (Exception e) {
|
||||
@@ -199,9 +199,9 @@ public class OpenFileController extends BaseController {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
// 搜索条件
|
||||
if (getMerchantCode() != null) {
|
||||
param.setMerchantCode(getMerchantCode());
|
||||
}
|
||||
// if (getMerchantCode() != null) {
|
||||
// param.setMerchantCode(getMerchantCode());
|
||||
// }
|
||||
PageResult<FileRecord> result = fileRecordService.pageRel(param);
|
||||
// String requestURL = StrUtil.removeSuffix(request.getRequestURL(), "/page");
|
||||
String requestURL = config.getFileServer();
|
||||
|
||||
@@ -1,303 +0,0 @@
|
||||
package com.gxwebsoft.open.controller;
|
||||
|
||||
import cn.hutool.core.date.DateUnit;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.gxwebsoft.apps.utils.BcUtil;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.common.system.service.UserService;
|
||||
import com.gxwebsoft.shop.entity.Order;
|
||||
import com.gxwebsoft.shop.entity.OrderGoods;
|
||||
import com.gxwebsoft.shop.entity.UserBalanceLog;
|
||||
import com.gxwebsoft.shop.mapper.OrderMapper;
|
||||
import com.gxwebsoft.shop.param.CartParam;
|
||||
import com.gxwebsoft.shop.param.OrderGoodsParam;
|
||||
import com.gxwebsoft.shop.param.OrderParam;
|
||||
import com.gxwebsoft.shop.service.OrderGoodsService;
|
||||
import com.gxwebsoft.shop.service.OrderService;
|
||||
import com.gxwebsoft.shop.service.UserBalanceLogService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import static com.gxwebsoft.common.core.constants.BalanceConstants.BALANCE_REFUND;
|
||||
import static com.gxwebsoft.common.core.constants.OrderConstants.*;
|
||||
|
||||
/**
|
||||
* 订单记录表控制器
|
||||
*
|
||||
* @author WebSoft
|
||||
* @since 2022-11-16 11:25:58
|
||||
*/
|
||||
@Api(tags = "订单记录表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/open/order")
|
||||
public class OpenOrderController extends BaseController {
|
||||
@Resource
|
||||
private BcUtil bcUtil;
|
||||
@Resource
|
||||
private OrderService orderService;
|
||||
@Resource
|
||||
private OrderGoodsService orderGoodsService;
|
||||
@Resource
|
||||
private OrderMapper orderMapper;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
@Resource
|
||||
private UserBalanceLogService userBalanceLogService;
|
||||
|
||||
@ApiOperation("查询全部订单记录表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<Order>> list(OrderParam param) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
// 使用关联查询
|
||||
return success(orderService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:order:list')")
|
||||
@ApiOperation("根据id查询订单记录表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<Order> get(@PathVariable("id") Integer id) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
return success(orderService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(orderService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:order:list')")
|
||||
@ApiOperation("查询报餐明细")
|
||||
@GetMapping("/getMyOrder")
|
||||
public ApiResult<Order> getMyOrder(CartParam cartParam) {
|
||||
Integer userId = 0;
|
||||
if(cartParam.getAgentUserId() != null){
|
||||
userId = cartParam.getAgentUserId();
|
||||
}else{
|
||||
userId = getLoginUserId();
|
||||
}
|
||||
System.out.println("cartParam = " + cartParam);
|
||||
System.out.println("userId = " + userId);
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
// 报餐明细(查询昨天这个时间点后下的订单)
|
||||
LambdaQueryWrapper<Order> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper
|
||||
.eq(Order::getUserId,userId)
|
||||
.eq(Order::getPayStatus,PAY_STATUS_SUCCESS)
|
||||
.eq(Order::getOrderStatus,ORDER_STATUS_DOING)
|
||||
.eq(Order::getDeleted,0)
|
||||
.eq(Order::getIsTemporary,0)
|
||||
.eq(Order::getDeliveryTime,cartParam.getDeliveryTime());
|
||||
Order order = orderService.getOne(lambdaQueryWrapper,false);
|
||||
// 查询订单商品
|
||||
if(order != null){
|
||||
OrderGoodsParam param = new OrderGoodsParam();
|
||||
param.setOrderId(order.getOrderId());
|
||||
// 是否按餐段查询
|
||||
if(cartParam.getIsPeriod() != null){
|
||||
param.setCategoryId(bcUtil.categoryId);
|
||||
}
|
||||
PageParam<OrderGoods, OrderGoodsParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("gear asc, sort_number asc, create_time desc");
|
||||
order.setGoodsList(orderGoodsService.list(page.getOrderWrapper()));
|
||||
}
|
||||
return success(order);
|
||||
}
|
||||
|
||||
@ApiOperation("查询今日当前餐段菜品")
|
||||
@PostMapping("/currentOrderGoods")
|
||||
public ApiResult<List<OrderGoods>> currentOrderGoods(OrderGoodsParam param) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
// 使用关联查询
|
||||
param.setCategoryId(bcUtil.categoryId);
|
||||
return success(orderGoodsService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:order:list')")
|
||||
@ApiOperation("查询核销订单明细")
|
||||
@GetMapping("/getReceiptOrder")
|
||||
public ApiResult<?> getReceiptOrder(CartParam cartParam) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
Integer userId = 0;
|
||||
|
||||
// 核销自己(查询今天他下的订单)
|
||||
if(cartParam.getUserId() != null){
|
||||
userId = cartParam.getUserId();
|
||||
OrderParam orderParam = new OrderParam();
|
||||
orderParam.setUserId(userId);
|
||||
orderParam.setPayStatus(PAY_STATUS_SUCCESS);
|
||||
orderParam.setOrderStatus(ORDER_STATUS_DOING);
|
||||
orderParam.setDeliveryTime(cartParam.getDeliveryTime());
|
||||
List<Order> list = orderService.listRel(orderParam);
|
||||
// 查询订单商品
|
||||
list.forEach(d -> {
|
||||
OrderGoodsParam param = new OrderGoodsParam();
|
||||
param.setOrderId(d.getOrderId());
|
||||
d.setGoodsList(orderGoodsService.listRel(param));
|
||||
});
|
||||
return success(list);
|
||||
}
|
||||
|
||||
// 代核销模式
|
||||
if(cartParam.getDealerId() != null){
|
||||
userId = cartParam.getDealerId();
|
||||
return success(userId);
|
||||
}
|
||||
return fail("找不到报餐数据",null);
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:order:save')")
|
||||
@ApiOperation("添加订单记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Order order) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
// 记录当前登录用户id、租户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
order.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (orderService.save(order)) {
|
||||
return success("添加成功",order);
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:order:update')")
|
||||
@ApiOperation("修改订单记录表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody Order order) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
if (orderService.updateById(order)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("取消订单")
|
||||
@PostMapping("/cancel")
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public ApiResult<?> cancel(@RequestBody Order order) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
if (order.getOrderId() == null) {
|
||||
return fail("订单不存在!");
|
||||
}
|
||||
// 取消报餐截止时间
|
||||
Date date = DateUtil.date();
|
||||
int hours = date.getHours();
|
||||
System.out.println("hours = " + hours);
|
||||
if(hours > 19){
|
||||
return fail("每天晚上8点后截止取消报餐");
|
||||
}
|
||||
order.setOrderStatus(ORDER_STATUS_CANCEL);
|
||||
if (orderService.updateById(order)) {
|
||||
final Order orderInfo = orderService.getById(order.getOrderId());
|
||||
// 退款
|
||||
User user = userService.getById(orderInfo.getUserId());
|
||||
System.out.println("user = " + user);
|
||||
BigDecimal balance = user.getBalance().add(orderInfo.getPayPrice());
|
||||
user.setBalance(balance);
|
||||
userService.updateById(user);
|
||||
// 记录余额明细
|
||||
UserBalanceLog userBalanceLog = new UserBalanceLog();
|
||||
userBalanceLog.setUserId(orderInfo.getUserId());
|
||||
userBalanceLog.setScene(BALANCE_REFUND);
|
||||
userBalanceLog.setMoney(orderInfo.getPayPrice());
|
||||
userBalanceLog.setBalance(balance);
|
||||
userBalanceLog.setComments(orderInfo.getOrderNo().toString());
|
||||
userBalanceLog.setMerchantCode(orderInfo.getMerchantCode());
|
||||
userBalanceLogService.save(userBalanceLog);
|
||||
return success("订单取消成功",orderInfo);
|
||||
}
|
||||
return fail("订单取消失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除订单记录表")
|
||||
@GetMapping("/remove/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
if (orderService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:order:save')")
|
||||
@ApiOperation("批量添加订单记录表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<Order> list) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
if (orderService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:order:update')")
|
||||
@ApiOperation("批量修改订单记录表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<Order> batchParam) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
if (batchParam.update(orderService, "order_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:order:remove')")
|
||||
@ApiOperation("批量删除订单记录表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
if (orderService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("支付成功")
|
||||
@PostMapping("/setPayStatus")
|
||||
public ApiResult<?> setPayStatus(@RequestBody Order order){
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
if (orderService.updateById(order)) {
|
||||
return success("设置成功");
|
||||
}
|
||||
return fail("设置失败");
|
||||
}
|
||||
|
||||
@ApiOperation("核销二维码")
|
||||
@PutMapping("/verification")
|
||||
public ApiResult<?> verification(@RequestBody Order order) {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
order.setOrderStatus(ORDER_STATUS_COMPLETED);
|
||||
order.setReceiptTime(DateUtil.date());
|
||||
if (orderService.updateById(order)) {
|
||||
return success("核销成功");
|
||||
}
|
||||
return fail("核销失败");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user