| | |
| | | package com.xzx.gc.shop.controller; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.xzx.gc.common.constant.CommonEnum; |
| | | import com.xzx.gc.common.constant.Constants; |
| | | import com.xzx.gc.common.dto.log.OperationAppLog; |
| | | import com.xzx.gc.common.request.BaseController; |
| | | import com.xzx.gc.entity.ScoreOrder; |
| | | import com.xzx.gc.model.JsonResult; |
| | | import com.xzx.gc.shop.dto.QueryGoodsListDto; |
| | | import com.xzx.gc.shop.dto.QueryOrderListDto; |
| | | import com.xzx.gc.shop.dto.*; |
| | | import com.xzx.gc.shop.mapper.ScoreOrderMapper; |
| | | import com.xzx.gc.shop.service.OrderService; |
| | | import com.xzx.gc.shop.vo.QueryGoodsListVo; |
| | | import com.xzx.gc.shop.vo.QueryOrderListVo; |
| | | import com.xzx.gc.shop.vo.ViewOrderVo; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiResponse; |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @RestController |
| | |
| | | |
| | | @Resource |
| | | private OrderService orderService; |
| | | @Resource |
| | | private ScoreOrderMapper scoreOrderMapper; |
| | | |
| | | /** |
| | | * 查询订单列表 |
| | |
| | | return JsonResult.success(result); |
| | | } |
| | | |
| | | /** |
| | | * 查询订单详情 |
| | | */ |
| | | @PostMapping(Constants.ADMIN_VIEW_PREFIX + "/score/goods/viewOrder.json") |
| | | @ApiResponses({@ApiResponse( code = 200, message = "success", response = ViewOrderVo.class)}) |
| | | @ApiOperation(value="订单管理-查询订单详情", notes="test: 仅0有正确返回") |
| | | public JsonResult<ViewOrderVo> viewOrder(@RequestBody ViewOrderDto viewOrderDto) { |
| | | Long id = viewOrderDto.getId(); |
| | | ScoreOrder scoreOrder = scoreOrderMapper.selectByPrimaryKey(id); |
| | | if(ObjectUtil.isEmpty(scoreOrder)){ |
| | | return JsonResult.failMessage("订单不存在!"); |
| | | } |
| | | ViewOrderVo viewOrderVo = orderService.viewOrder(id); |
| | | return JsonResult.success(viewOrderVo); |
| | | } |
| | | |
| | | /** |
| | | * 发货 |
| | | */ |
| | | @PostMapping(Constants.ADMIN_VIEW_PREFIX + "/score/goods/deliverGoods.json") |
| | | @ApiOperation(value="订单管理-发货", notes="test: 仅0有正确返回") |
| | | public JsonResult deliverGoods(@RequestBody DeliverGoodsDto model, HttpServletRequest request) { |
| | | long id = model.getId(); |
| | | ScoreOrder scoreOrder = scoreOrderMapper.selectByPrimaryKey(id); |
| | | if(ObjectUtil.isEmpty(scoreOrder)){ |
| | | return JsonResult.failMessage("订单不存在!"); |
| | | } |
| | | Integer status = scoreOrder.getStatus(); |
| | | if(ScoreOrder.STATUS_READY != status){ |
| | | return JsonResult.failMessage("当前订单不是代发货状态!"); |
| | | } |
| | | String expressCom = model.getExpressCom(); |
| | | if(StrUtil.isEmpty(expressCom)){ |
| | | return JsonResult.failMessage("物流公司不能为空!"); |
| | | } |
| | | String expressNo = model.getExpressNo(); |
| | | if(StrUtil.isEmpty(expressNo)){ |
| | | return JsonResult.failMessage("快递单号不能为空!"); |
| | | } |
| | | Long aLong = orderService.deliverGoods(model); |
| | | if(aLong > 0){ |
| | | OperationAppLog build = OperationAppLog.builder().appPrograme(CommonEnum.后台.getValue()).opreateName(getAdminName(request)) |
| | | .methodName(Constants.SCORESHOP_MODUL_NAME).operateAction("订单管理-发货-" + id).build(); |
| | | mqUtil.sendApp(build); |
| | | return JsonResult.success("操作成功!"); |
| | | }else{ |
| | | return JsonResult.success("操作失败!"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 确认提货 |
| | | */ |
| | | @PostMapping(Constants.ADMIN_VIEW_PREFIX + "/score/goods/insureOrder.json") |
| | | @ApiOperation(value="订单管理-确认提货", notes="test: 仅0有正确返回") |
| | | public JsonResult insureOrder(@RequestBody InsureOrderDto model, HttpServletRequest request) { |
| | | long id = model.getId(); |
| | | ScoreOrder scoreOrder = scoreOrderMapper.selectByPrimaryKey(id); |
| | | if(ObjectUtil.isEmpty(scoreOrder)){ |
| | | return JsonResult.failMessage("订单不存在!"); |
| | | } |
| | | Integer status = scoreOrder.getStatus(); |
| | | if(ScoreOrder.STATUS_DOING != status){ |
| | | return JsonResult.failMessage("当前订单不是已收货状态!"); |
| | | } |
| | | List<String> voucherImgs = model.getVoucherImgs(); |
| | | if(CollUtil.isEmpty(voucherImgs)){ |
| | | return JsonResult.failMessage("凭证不能为空!"); |
| | | } |
| | | Long orderId = orderService.insureOrder(model); |
| | | if(orderId > 0){ |
| | | OperationAppLog build = OperationAppLog.builder().appPrograme(CommonEnum.后台.getValue()).opreateName(getAdminName(request)) |
| | | .methodName(Constants.SCORESHOP_MODUL_NAME).operateAction("订单管理-确认提货-" + orderId).build(); |
| | | mqUtil.sendApp(build); |
| | | return JsonResult.success("操作成功!"); |
| | | }else{ |
| | | return JsonResult.success("操作失败!"); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | } |