|
|
|
@@ -0,0 +1,94 @@ |
|
|
|
package com.simple.controller; |
|
|
|
|
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
import com.simple.common.ErrorCode; |
|
|
|
import com.simple.common.Result; |
|
|
|
import com.simple.common.ResultData; |
|
|
|
import com.simple.domain.po.WxAppinfo; |
|
|
|
import com.simple.domain.po.WxCUser; |
|
|
|
import com.simple.domain.po.WxMerchantBUser; |
|
|
|
import com.simple.domain.po.WxRefundOrder; |
|
|
|
import com.simple.enums.EnumPayWay; |
|
|
|
import com.simple.exception.MallinkException; |
|
|
|
import com.simple.service.WxRefundOrderService; |
|
|
|
import io.swagger.annotations.ApiImplicitParam; |
|
|
|
import io.swagger.annotations.ApiImplicitParams; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.log4j.Logger; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
@RestController |
|
|
|
@RequestMapping("/api/refund") |
|
|
|
public class WxRefundOrderController extends BaseController |
|
|
|
{ |
|
|
|
private Logger logger = Logger.getLogger(WxRefundOrderController.class); |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private WxRefundOrderService wxRefundOrderService; |
|
|
|
|
|
|
|
@ApiOperation(value = "发起退款", notes = "{\"orderId\":,\"string\", \"payOrderId\":\"string\"}") |
|
|
|
@PostMapping("/create") |
|
|
|
public ResultData create(@RequestBody Map<String, String> paramMap) { |
|
|
|
logger.info("/api/refund/create" + paramMap.toString()); |
|
|
|
//Assert.notNull(wxRefundOrder.getName(), "角色名不能为空"); |
|
|
|
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); |
|
|
|
String orderIdStr = paramMap.get("orderId"); |
|
|
|
String payOrderIdStr = paramMap.get("payOrderId"); |
|
|
|
if (StringUtils.isBlank(orderIdStr)) { |
|
|
|
logger.error("orderId不能为空: " + paramMap.toString()); |
|
|
|
return new ResultData(ErrorCode.PARAMETER_NOT_NULL.getCode(), "orderId不能为空"); |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(payOrderIdStr)) { |
|
|
|
logger.error("payOrderId不能为空: " + paramMap.toString()); |
|
|
|
return new ResultData(ErrorCode.PARAMETER_NOT_NULL.getCode(), "payOrderId不能为空"); |
|
|
|
} |
|
|
|
Long orderId = 0L; |
|
|
|
try { |
|
|
|
orderId = Long.valueOf(orderIdStr); |
|
|
|
} catch (NumberFormatException e) { |
|
|
|
logger.error("orderId参数不正确: " + paramMap.toString()); |
|
|
|
return new ResultData(ErrorCode.PARAMETER_NOT_NULL.getCode(), "orderId参数不正确"); |
|
|
|
} |
|
|
|
WxRefundOrder refundOrder = new WxRefundOrder(); |
|
|
|
refundOrder.setPayOrderNo(payOrderIdStr); |
|
|
|
refundOrder.setOrderId(orderId); |
|
|
|
|
|
|
|
WxCUser cUser = getUser(); |
|
|
|
WxAppinfo appinfo = getAppInfo(cUser.getAppId()); |
|
|
|
try { |
|
|
|
wxRefundOrderService.createRefundOrder(appinfo, refundOrder, EnumPayWay.PAY_WAY_WEAPP); |
|
|
|
return new ResultData(); |
|
|
|
} catch (MallinkException e) { |
|
|
|
logger.error(e.getMessage()); |
|
|
|
return new ResultData(e.getErrorCode(), e.getMessage()); |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error(e.getMessage()); |
|
|
|
return new ResultData(ErrorCode.REFUND_ORDER_ERROR); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation("分页列表接口") |
|
|
|
@GetMapping("list") |
|
|
|
@ApiImplicitParams({ |
|
|
|
@ApiImplicitParam(name="pageNum",value="页数",dataType="int", paramType = "query",required=true), |
|
|
|
@ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)}) |
|
|
|
public ResultData list(@ModelAttribute WxRefundOrder wxRefundOrder,Integer pageNum, Integer pageSize) { |
|
|
|
if (null == wxRefundOrder) wxRefundOrder = new WxRefundOrder(); |
|
|
|
final PageInfo<WxRefundOrder> page = wxRefundOrderService.listAsPage(wxRefundOrder, pageNum, pageSize); |
|
|
|
return new ResultData(page); |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation("根据id查询接口") |
|
|
|
@GetMapping("/findById") |
|
|
|
@ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) |
|
|
|
public ResultData findById(Long id) { |
|
|
|
return new ResultData(Result.SUCCESS,"查询成功",wxRefundOrderService.getById(id)); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |