parent
b9a995aa40
commit
61b203c4ca
@ -0,0 +1,133 @@ |
||||
package com.cweb.controller; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.github.pagehelper.PageHelper; |
||||
import com.github.pagehelper.PageInfo; |
||||
import com.hai.common.exception.ErrorCode; |
||||
import com.hai.common.exception.ErrorHelp; |
||||
import com.hai.common.exception.SysCode; |
||||
import com.hai.common.security.SessionObject; |
||||
import com.hai.common.security.UserCenter; |
||||
import com.hai.common.utils.DateUtil; |
||||
import com.hai.common.utils.IDGenerator; |
||||
import com.hai.common.utils.ResponseMsgUtil; |
||||
import com.hai.config.TuanYouConfig; |
||||
import com.hai.entity.*; |
||||
import com.hai.model.HighMerchantStoreModel; |
||||
import com.hai.model.HighUserModel; |
||||
import com.hai.model.ResponseData; |
||||
import com.hai.service.*; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.dao.DeadlockLoserDataAccessException; |
||||
import org.springframework.stereotype.Controller; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.annotation.Resource; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.math.BigDecimal; |
||||
import java.util.Date; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import java.util.stream.Collectors; |
||||
|
||||
/** |
||||
* @Auther: 胡锐 |
||||
* @Description: |
||||
* @Date: 2021/3/26 23:08 |
||||
*/ |
||||
@Controller |
||||
@RequestMapping(value = "/orderPre") |
||||
@Api(value = "预约订单接口") |
||||
public class HighOrderPreController { |
||||
private static Logger log = LoggerFactory.getLogger(HighOrderPreController.class); |
||||
|
||||
@Autowired |
||||
private UserCenter userCenter; |
||||
|
||||
@Resource |
||||
private HighOrderPreService highOrderPreService; |
||||
|
||||
|
||||
@RequestMapping(value = "/getUserOrderPreList", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "获取用户预约订单") |
||||
public ResponseData getUserOrderPreList(@RequestParam(name = "status", required = false) Integer status, |
||||
@RequestParam(name = "orderNo", required = false) String orderNo, |
||||
@RequestParam(name = "orderPreNo", required = false) String preOrderNo, |
||||
@RequestParam(name = "goodsName", required = false) String goodsName, |
||||
@RequestParam(name = "pageNum", required = true) Integer pageNum, |
||||
@RequestParam(name = "pageSize", required = true) Integer pageSize, |
||||
HttpServletRequest request) { |
||||
try { |
||||
|
||||
// 用户
|
||||
SessionObject sessionObject = userCenter.getSessionObject(request); |
||||
HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); |
||||
|
||||
Map<String,Object> map = new HashMap<>(); |
||||
map.put("preUserId", userInfoModel.getHighUser().getId()); |
||||
map.put("status", status); |
||||
map.put("orderNo", orderNo); |
||||
map.put("preOrderNo", preOrderNo); |
||||
map.put("goodsName", goodsName); |
||||
|
||||
PageHelper.startPage(pageNum,pageSize); |
||||
return ResponseMsgUtil.success(new PageInfo<>(highOrderPreService.getListOrderPre(map))); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighOrderController --> getUserPreOrderList() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value = "/getOrderPreById", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "根据id查询预约订单详情") |
||||
public ResponseData getOrderPreById(@RequestParam(name = "orderPreId", required = true) Long orderPreId) { |
||||
try { |
||||
|
||||
return ResponseMsgUtil.success(highOrderPreService.findByOrderId(orderPreId)); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighOrderController --> getOrderById() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value = "/orderComplete", method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "订单完成") |
||||
public ResponseData orderComplete(@RequestBody JSONObject body) { |
||||
try { |
||||
if (body == null || body.getLong("preOrderId") == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
// 查询预约订单详情
|
||||
HighOrderPre orderPre = highOrderPreService.findByOrderId(body.getLong("preOrderId")); |
||||
if (orderPre == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到预约订单"); |
||||
} |
||||
if (orderPre.getStatus() != 2) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.STATUS_ERROR, ""); |
||||
} |
||||
orderPre.setStatus(3); |
||||
orderPre.setUpdateTime(new Date()); |
||||
highOrderPreService.updateOrderPre(orderPre); |
||||
|
||||
return ResponseMsgUtil.success("操作成功"); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighOrderController --> orderComplete() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
|
||||
} |
Loading…
Reference in new issue