|  |  |  | 
|---|
|  |  |  | 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.ScoreDetails; | 
|---|
|  |  |  | import com.xzx.gc.entity.ScoreOrder; | 
|---|
|  |  |  | import com.xzx.gc.model.JsonResult; | 
|---|
|  |  |  | import com.xzx.gc.shop.dto.*; | 
|---|
|  |  |  | import com.xzx.gc.shop.mapper.ScoreDetailsMapper; | 
|---|
|  |  |  | import com.xzx.gc.shop.mapper.ScoreOrderMapper; | 
|---|
|  |  |  | import com.xzx.gc.shop.service.OrderService; | 
|---|
|  |  |  | import com.xzx.gc.shop.vo.QueryOrderListVo; | 
|---|
|  |  |  | 
|---|
|  |  |  | import io.swagger.annotations.ApiResponse; | 
|---|
|  |  |  | import io.swagger.annotations.ApiResponses; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.PostMapping; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RequestBody; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RestController; | 
|---|
|  |  |  | import tk.mybatis.mapper.entity.Example; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import javax.annotation.Resource; | 
|---|
|  |  |  | import javax.servlet.http.HttpServletRequest; | 
|---|
|  |  |  | 
|---|
|  |  |  | private OrderService orderService; | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private ScoreOrderMapper scoreOrderMapper; | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private ScoreDetailsMapper scoreDetailsMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 查询订单列表 | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Integer status = scoreOrder.getStatus(); | 
|---|
|  |  |  | if(ScoreOrder.STATUS_READY != status){ | 
|---|
|  |  |  | return JsonResult.failMessage("当前订单不是代发货状态!"); | 
|---|
|  |  |  | return JsonResult.failMessage("当前订单不是待发货状态!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String expressCom = model.getExpressCom(); | 
|---|
|  |  |  | if(StrUtil.isEmpty(expressCom)){ | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 取消 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @PostMapping(Constants.ADMIN_VIEW_PREFIX + "/score/goods/cancelOrder.json") | 
|---|
|  |  |  | @ApiOperation(value="订单管理-取消", notes="test: 仅0有正确返回") | 
|---|
|  |  |  | public JsonResult cancelOrder(@RequestBody CancelOrderDto 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("当前订单不是待发货状态!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ScoreOrder order = scoreOrderMapper.selectByPrimaryKey(model.getId()); | 
|---|
|  |  |  | Example exampleDetails = new Example(ScoreDetails.class); | 
|---|
|  |  |  | Example.Criteria criteriaDetails = exampleDetails.createCriteria(); | 
|---|
|  |  |  | criteriaDetails.andEqualTo("orderNo",order.getOrderNo()); | 
|---|
|  |  |  | criteriaDetails.andEqualTo("userId",order.getUserId()); | 
|---|
|  |  |  | criteriaDetails.andEqualTo("type",ScoreDetails.SCORE_TYPE_SHOPPING_RETURN); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<ScoreDetails> scoreDetails = scoreDetailsMapper.selectByExample(exampleDetails); | 
|---|
|  |  |  | if(CollUtil.isNotEmpty(scoreDetails)){ | 
|---|
|  |  |  | return JsonResult.failMessage("当前订单已经取消过了!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Long aLong = orderService.cancelOrder(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("操作失败!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|