提交 21f7da30 作者: zhenjie

商城订单关闭接口

上级 0aa416f0
...@@ -47,8 +47,8 @@ public class UavOrderController extends BaseController { ...@@ -47,8 +47,8 @@ public class UavOrderController extends BaseController {
@ApiOperation(value = "关闭") @ApiOperation(value = "关闭")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)}) @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@GetMapping("close") @GetMapping("close")
public ResultBody close(@RequestParam Integer id) { public ResultBody close(@RequestParam Integer id, HttpServletRequest request) {
return uavOrderService.close(id); return uavOrderService.close(id, this.getCurrentAccount(request).getToken());
} }
@ApiOperation(value = "后台订单列表") @ApiOperation(value = "后台订单列表")
......
package com.mmc.oms.feign;
import com.mmc.oms.common.result.ResultBody;
import com.mmc.oms.feign.hystrix.PaymentAppApiHystrix;
import com.mmc.oms.model.vo.ApplyRefundVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
/**
* @author: zj
* @Date: 2023/9/8 11:08
*/
@FeignClient(url = "${payment.url}", name = "payment-svc", fallback = PaymentAppApiHystrix.class)
public interface PaymentAppApi {
@PostMapping("wechat/applyRefund")
public ResultBody applyRefund(@RequestBody ApplyRefundVO applyRefundVO);
}
package com.mmc.oms.feign.hystrix;
import com.alibaba.fastjson2.JSONObject;
import com.mmc.oms.common.result.ResultBody;
import com.mmc.oms.feign.PaymentAppApi;
import com.mmc.oms.model.vo.ApplyRefundVO;
import lombok.extern.slf4j.Slf4j;
/**
* @author: zj
* @Date: 2023/9/8 11:08
*/
@Slf4j
public class PaymentAppApiHystrix implements PaymentAppApi {
@Override
public ResultBody applyRefund(ApplyRefundVO applyRefundVO) {
log.error("PaymentAppApiHystrix applyRefund ---- param:{}", JSONObject.toJSONString(applyRefundVO));
return ResultBody.error("调用微信退款失败");
}
}
\ No newline at end of file
package com.mmc.oms.model.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author LW
* @date 2023/7/22 14:51
* 概要:
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ApplyRefundVO {
@ApiModelProperty(value = "商户订单号", required = true)
private String outTradeNo;
@ApiModelProperty(value = "退款原因")
private String reason;
@ApiModelProperty(value = "退款金额", required = true)
private Long refund;
// @ApiModelProperty(value = "商品信息(可填可不填)")
// private List<GoodsDetail> goodsDetail;
}
...@@ -20,7 +20,7 @@ public interface UavOrderService { ...@@ -20,7 +20,7 @@ public interface UavOrderService {
ResultBody detail(Integer id) throws Exception; ResultBody detail(Integer id) throws Exception;
ResultBody close(Integer id); ResultBody close(Integer id, String token);
ResultBody list(UavOrderQO uavOrderQO, BaseAccountDTO currentAccount); ResultBody list(UavOrderQO uavOrderQO, BaseAccountDTO currentAccount);
......
...@@ -13,12 +13,14 @@ import com.mmc.oms.dao.uav.UavOrderExpressDao; ...@@ -13,12 +13,14 @@ import com.mmc.oms.dao.uav.UavOrderExpressDao;
import com.mmc.oms.entity.mall.UserAddressDO; import com.mmc.oms.entity.mall.UserAddressDO;
import com.mmc.oms.entity.uav.*; import com.mmc.oms.entity.uav.*;
import com.mmc.oms.enums.UavOrderStatus; import com.mmc.oms.enums.UavOrderStatus;
import com.mmc.oms.feign.PaymentAppApi;
import com.mmc.oms.feign.UserAppApi; import com.mmc.oms.feign.UserAppApi;
import com.mmc.oms.model.dto.kdn.KdnExpDTO; import com.mmc.oms.model.dto.kdn.KdnExpDTO;
import com.mmc.oms.model.dto.order.ExpStationsDTO; import com.mmc.oms.model.dto.order.ExpStationsDTO;
import com.mmc.oms.model.dto.uav.*; import com.mmc.oms.model.dto.uav.*;
import com.mmc.oms.model.dto.user.BaseAccountDTO; import com.mmc.oms.model.dto.user.BaseAccountDTO;
import com.mmc.oms.model.qo.uav.UavOrderQO; import com.mmc.oms.model.qo.uav.UavOrderQO;
import com.mmc.oms.model.vo.ApplyRefundVO;
import com.mmc.oms.model.vo.demand.CommonPaymentVO; import com.mmc.oms.model.vo.demand.CommonPaymentVO;
import com.mmc.oms.model.vo.uav.*; import com.mmc.oms.model.vo.uav.*;
import com.mmc.oms.model.vo.wallet.TopUpOrderVO; import com.mmc.oms.model.vo.wallet.TopUpOrderVO;
...@@ -59,6 +61,9 @@ public class UavOrderServiceImpl implements UavOrderService { ...@@ -59,6 +61,9 @@ public class UavOrderServiceImpl implements UavOrderService {
@Autowired @Autowired
private PmsClient pmsClient; private PmsClient pmsClient;
@Autowired
private PaymentAppApi paymentAppApi;
@Override @Override
@Transactional @Transactional
public ResultBody addOrder(AddUavOrderVO param, BaseAccountDTO currentAccount) { public ResultBody addOrder(AddUavOrderVO param, BaseAccountDTO currentAccount) {
...@@ -231,10 +236,32 @@ public class UavOrderServiceImpl implements UavOrderService { ...@@ -231,10 +236,32 @@ public class UavOrderServiceImpl implements UavOrderService {
return kdn; return kdn;
} }
@Transactional
@Override @Override
public ResultBody close(Integer id) { public ResultBody close(Integer id, String token) {
UavOrderDO uavOrderDO = uavOrderDao.detail(id);
// TODO 退款、修改订单状态 // TODO 退款、修改订单状态
this.updateUavOrderStatus(id, UavOrderStatus.CLOSE); this.updateUavOrderStatus(id, UavOrderStatus.CLOSE);
// 云享金、佣金
PayUavWalletVO payUavWalletVO = new PayUavWalletVO();
payUavWalletVO.setCashAmount(uavOrderDO.getShareAmount());
payUavWalletVO.setSalaryAmount(uavOrderDO.getSalaryAmount());
payUavWalletVO.setOrderStatus(1400);
payUavWalletVO.setUserAccountId(uavOrderDO.getUserAccountId());
ResultBody resultBody = userAppApi.feignPayUavWallet(payUavWalletVO, token);
if (!resultBody.getCode().equals(ResultEnum.SUCCESS.getResultCode())){
return resultBody;
}
// 微信退款
ApplyRefundVO applyRefundVO = new ApplyRefundVO();
applyRefundVO.setOutTradeNo(uavOrderDO.getOrderNo());
applyRefundVO.setReason("关闭订单");
applyRefundVO.setRefund(uavOrderDO.getOtherAmount().multiply(BigDecimal.valueOf(100)).longValue());
ResultBody applyRefund = paymentAppApi.applyRefund(applyRefundVO);
if (!applyRefund.getCode().equals(ResultEnum.SUCCESS.getResultCode())) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
}
return ResultBody.success(); return ResultBody.success();
} }
...@@ -320,6 +347,7 @@ public class UavOrderServiceImpl implements UavOrderService { ...@@ -320,6 +347,7 @@ public class UavOrderServiceImpl implements UavOrderService {
uavOrderExpressDO.setReceiveTime(new Date()); uavOrderExpressDO.setReceiveTime(new Date());
uavOrderExpressDao.updateUavOrderExpressDO(uavOrderExpressDO); uavOrderExpressDao.updateUavOrderExpressDO(uavOrderExpressDO);
// TODO 订单抽成设置 // TODO 订单抽成设置
return ResultBody.success(); return ResultBody.success();
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论