package com.oying.modules.message.rest; import cn.hutool.core.bean.BeanUtil; import com.oying.annotation.Log; import com.oying.modules.message.domain.MessageOrderSeller; import com.oying.modules.message.domain.MessageOrderSeller; import com.oying.modules.message.domain.dto.MessageOrderSellerDTO; import com.oying.modules.message.service.MessageOrderSellerService; import com.oying.modules.message.domain.dto.MessageOrderSellerQueryCriteria; import com.oying.utils.R; import lombok.RequiredArgsConstructor; import java.util.List; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import io.swagger.annotations.*; import java.io.IOException; import javax.servlet.http.HttpServletResponse; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.oying.utils.PageResult; /** * @author 李萌 * @date 2025-05-20 **/ @RestController @RequiredArgsConstructor @Api(tags = "卖家端订单消息通知") @RequestMapping("/api/message/messageOrderSeller") public class MessageOrderSellerController { private final MessageOrderSellerService messageOrderSellerService; // @ApiOperation("导出数据") // @GetMapping(value = "/download") // @PreAuthorize("@el.check('messageOrderSeller:list')") // public void exportMessageOrderSeller(HttpServletResponse response, MessageOrderSellerQueryCriteria criteria) throws IOException { // messageOrderSellerService.download(messageOrderSellerService.queryAll(criteria), response); // } @GetMapping @ApiOperation("查询卖家端订单消息通知") @PreAuthorize("@el.check('messageOrderSeller:list')") public R> queryMessageOrderSeller(MessageOrderSellerQueryCriteria criteria){ Page page = new Page<>(criteria.getPage(), criteria.getSize()); // return new ResponseEntity<>(messageOrderSellerService.queryAll(criteria,page),HttpStatus.OK); return R.success(messageOrderSellerService.queryAll(criteria,page)); } // @PostMapping // @Log("新增卖家端订单消息通知") // @ApiOperation("新增卖家端订单消息通知") // @PreAuthorize("@el.check('messageOrderSeller:add')") // public ResponseEntity createMessageOrderSeller(@Validated @RequestBody MessageOrderSeller resources){ // messageOrderSellerService.create(resources); // return new ResponseEntity<>(HttpStatus.CREATED); // } // // @PutMapping // @Log("修改卖家端订单消息通知") // @ApiOperation("修改卖家端订单消息通知") // @PreAuthorize("@el.check('messageOrderSeller:edit')") // public ResponseEntity updateMessageOrderSeller(@Validated @RequestBody MessageOrderSeller resources){ // messageOrderSellerService.update(resources); // return new ResponseEntity<>(HttpStatus.NO_CONTENT); // } // // @DeleteMapping // @Log("删除卖家端订单消息通知") // @ApiOperation("删除卖家端订单消息通知") // @PreAuthorize("@el.check('messageOrderSeller:del')") // public ResponseEntity deleteMessageOrderSeller(@ApiParam(value = "传ID数组[]") @RequestBody List ids) { // messageOrderSellerService.deleteAll(ids); // return new ResponseEntity<>(HttpStatus.OK); // } // //订单状态变化通知 // @GetMapping("/status/{order_id}") // @ApiOperation("查询一条订单状态变化通知") // public R getMessageOrderSeller(@PathVariable Integer order_id) { // MessageOrderSeller messageOrderSeller = messageOrderSellerService.findByOrderId(order_id); // String message = messageOrderSeller.getMessageType(); // //// return new ResponseEntity<>(message, HttpStatus.OK); // return R.success(message); // } //根据store_id 返回list订单状态变化通知 @GetMapping("/status/store/{store_id}") @ApiOperation("根据store_id 返回list订单状态变化通知") public R> getMessageOrderSeller(@PathVariable String store_id) { List messageOrderSeller = messageOrderSellerService.findByStoreId(store_id); //转换为MessageOrderSellerDTO huto tools List dtoList = BeanUtil.copyToList(messageOrderSeller, MessageOrderSellerDTO.class); //判断store_id存在 if (messageOrderSeller == null) { return R.fail("store_id不存在"); }else{return R.success(dtoList);} } //让前端标记已读 @PostMapping("/read/{order_id}") @ApiOperation("让前端标记已读 按条") public R getMessageOrderSellerRead(@PathVariable Integer order_id) { if(messageOrderSellerService.updateMessageOrderSellerRead(order_id)){ return R.success("已读"); }else{ return R.fail("id不存在"); } } //让后端队友更新我的表 @PostMapping("/update/seller") @ApiOperation("让后端队友更新消息表") public R updateMessageOrderSeller(@RequestBody MessageOrderSeller resources) { //插入一条数据 if(messageOrderSellerService.saveOrUpdate(resources)) return R.success("更新成功"); return R.fail("更新失败"); // if(messageOrderSellerService.updateById(resources)){ // return R.success("更新成功"); // }else{ // return R.fail("更新失败"); // } } //订单送达通知 @GetMapping("/deliver/{order_id}") @ApiOperation("查询一条订单送达通知") public R getMessageOrderSellerDeliver(@PathVariable Integer order_id) { MessageOrderSeller messageOrderSeller = messageOrderSellerService.findByOrderId(order_id); String message = messageOrderSeller.getMessageType(); //如果MessageType为订单送达,则返回message——content if (message.equals("买家下单")) { String messageContent = messageOrderSeller.getMessageContent(); // return new ResponseEntity<>(messageContent, HttpStatus.OK); return R.success(messageContent); }else{ //返回没送达 // return new ResponseEntity<>("买家没下单", HttpStatus.OK); return R.fail("没送达"); } } //实现点击跳转到订单详情 @GetMapping("/link/{order_id}") @ApiOperation("点击跳转到订单详情") public R getMessageOrderSellerLink(@PathVariable Integer order_id) { MessageOrderSeller messageOrderSeller = messageOrderSellerService.findByOrderId(order_id); String link = messageOrderSeller.getLink(); // return new ResponseEntity<>(link, HttpStatus.OK); return R.success(link); } }