|
@@ -0,0 +1,123 @@
|
|
|
+package com.miaxis.pc.controller.order;
|
|
|
+
|
|
|
+import com.miaxis.common.annotation.Log;
|
|
|
+import com.miaxis.common.core.controller.BaseController;
|
|
|
+import com.miaxis.common.core.domain.Response;
|
|
|
+import com.miaxis.common.core.page.ResponsePageInfo;
|
|
|
+import com.miaxis.common.enums.BusinessTypeEnum;
|
|
|
+import com.miaxis.common.utils.OrderCodeFactory;
|
|
|
+import com.miaxis.common.utils.poi.ExcelUtil;
|
|
|
+import com.miaxis.wx.domain.WxJsOrder;
|
|
|
+import com.miaxis.wx.dto.WxJsOrderOutTradeNoDTO;
|
|
|
+import com.miaxis.wx.dto.WxNotifyReturnDTO;
|
|
|
+import com.miaxis.wx.service.IRefundRecordService;
|
|
|
+import com.miaxis.wx.service.IWxJsOrderService;
|
|
|
+import io.swagger.annotations.*;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 【订单】Controller
|
|
|
+ *
|
|
|
+ * @author miaxis
|
|
|
+ * @date 2022-03-25
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/order/info")
|
|
|
+@Api(tags={"【PC-订单】"})
|
|
|
+public class WxJsOrderController extends BaseController{
|
|
|
+ @Autowired
|
|
|
+ private IWxJsOrderService wxJsOrderService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IRefundRecordService refundRecordService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询订单列表
|
|
|
+ */
|
|
|
+
|
|
|
+ @PreAuthorize("@ss.hasPermi('order:info:query')")
|
|
|
+ @GetMapping("/list")
|
|
|
+ @ApiOperation("查询订单列表")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "pageNum",value = "当前页码" ,dataType = "int", paramType = "query", required = false),
|
|
|
+ @ApiImplicitParam(name = "pageSize",value = "每页数据量" , dataType = "int", paramType = "query", required = false),
|
|
|
+ })
|
|
|
+ public ResponsePageInfo<WxJsOrder> list(@ModelAttribute WxJsOrder wxJsOrder){
|
|
|
+ startPage();
|
|
|
+ List<WxJsOrder> list = wxJsOrderService.selectWxJsOrderList(wxJsOrder);
|
|
|
+ return toResponsePageInfo(list);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取订单详细信息
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('order:info:query')")
|
|
|
+ @GetMapping(value = "/{id}")
|
|
|
+ @ApiOperation("获取订单详细信息")
|
|
|
+ public Response<WxJsOrder> getInfo(
|
|
|
+ @ApiParam(name = "id", value = "订单参数", required = true)
|
|
|
+ @PathVariable("id") Long id
|
|
|
+ ){
|
|
|
+ return Response.success(wxJsOrderService.getById(id));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增订单
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('order:info:add')")
|
|
|
+ @Log(title = "订单", businessType = BusinessTypeEnum.INSERT)
|
|
|
+ @PostMapping
|
|
|
+ @ApiOperation("新增订单")
|
|
|
+ public Response<Integer> add(@RequestBody WxJsOrder wxJsOrder){
|
|
|
+ return toResponse(wxJsOrderService.save(wxJsOrder) ? 1 : 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改订单
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('order:info:edit')")
|
|
|
+ @Log(title = "订单", businessType = BusinessTypeEnum.UPDATE)
|
|
|
+ @PutMapping
|
|
|
+ @ApiOperation("修改订单")
|
|
|
+ public Response<Integer> edit(@RequestBody WxJsOrder wxJsOrder){
|
|
|
+ return toResponse(wxJsOrderService.updateById(wxJsOrder) ? 1 : 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除订单
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('order:info:remove')")
|
|
|
+ @Log(title = "订单", businessType = BusinessTypeEnum.DELETE)
|
|
|
+ @DeleteMapping("/{ids}")
|
|
|
+ @ApiOperation("删除订单")
|
|
|
+ public Response<Integer> remove(
|
|
|
+ @ApiParam(name = "ids", value = "订单ids参数", required = true)
|
|
|
+ @PathVariable Long[] ids
|
|
|
+ ){
|
|
|
+ return toResponse(wxJsOrderService.removeByIds(Arrays.asList(ids)) ? 1 : 0);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 订单退款
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('order:info:refund')")
|
|
|
+ @Log(title = "订单", businessType = BusinessTypeEnum.UPDATE)
|
|
|
+ @PostMapping("/refund")
|
|
|
+ @ApiOperation("订单退款")
|
|
|
+ public Response<WxNotifyReturnDTO> refund(@RequestBody WxJsOrderOutTradeNoDTO wxJsOrderOutTradeNoDTO) throws Exception {
|
|
|
+ WxJsOrder wxJsOrder = wxJsOrderService.getByOutTradeNo(wxJsOrderOutTradeNoDTO.getOutTradeNo());
|
|
|
+ WxNotifyReturnDTO wxNotifyReturnDTO = refundRecordService.refund(wxJsOrder, OrderCodeFactory.getOrderCode(null), wxJsOrderOutTradeNoDTO.getReason());
|
|
|
+ return Response.success(wxNotifyReturnDTO);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|