后台提现增加了企业付款到零钱功能
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package co.yixiang.modules.activity.rest;
|
||||
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import co.yixiang.aop.log.Log;
|
||||
import co.yixiang.exception.BadRequestException;
|
||||
@ -11,7 +12,13 @@ import co.yixiang.modules.shop.domain.YxUserBill;
|
||||
import co.yixiang.modules.shop.service.YxUserBillService;
|
||||
import co.yixiang.modules.shop.service.YxUserService;
|
||||
import co.yixiang.modules.shop.service.dto.YxUserDTO;
|
||||
import co.yixiang.modules.wechat.service.YxWechatUserService;
|
||||
import co.yixiang.modules.wechat.service.dto.YxWechatUserDTO;
|
||||
import co.yixiang.utils.OrderUtil;
|
||||
import co.yixiang.utils.RedisUtil;
|
||||
import com.github.binarywang.wxpay.bean.entpay.EntPayRequest;
|
||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||
import com.github.binarywang.wxpay.service.WxPayService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -22,6 +29,8 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* @date 2019-11-14
|
||||
@ -40,6 +49,12 @@ public class YxUserExtractController {
|
||||
@Autowired
|
||||
private YxUserBillService yxUserBillService;
|
||||
|
||||
@Autowired
|
||||
private WxPayService wxPayService;
|
||||
|
||||
@Autowired
|
||||
private YxWechatUserService wechatUserService;
|
||||
|
||||
@Log("查询")
|
||||
@ApiOperation(value = "查询")
|
||||
@GetMapping(value = "/yxUserExtract")
|
||||
@ -89,6 +104,40 @@ public class YxUserExtractController {
|
||||
|
||||
resources.setFailTime(OrderUtil.getSecondTimestampTwo());
|
||||
|
||||
}
|
||||
//todo 此处为企业付款,没经过测试
|
||||
boolean isTest = true;
|
||||
if(!isTest){
|
||||
YxWechatUserDTO wechatUser = wechatUserService.findById(resources.getUid());
|
||||
if(ObjectUtil.isNotNull(wechatUser)){
|
||||
String apiUrl = RedisUtil.get("api_url");
|
||||
if(StrUtil.isBlank(apiUrl)) throw new BadRequestException("请配置api地址");
|
||||
//读取redis配置
|
||||
String appId = RedisUtil.get("wxpay_appId");
|
||||
String mchId = RedisUtil.get("wxpay_mchId");
|
||||
if(StrUtil.isBlank(appId) || StrUtil.isBlank(mchId)){
|
||||
throw new BadRequestException("请配置微信支付");
|
||||
}
|
||||
EntPayRequest entPayRequest = new EntPayRequest();
|
||||
try {
|
||||
entPayRequest.setAppid(appId);
|
||||
entPayRequest.setMchId(mchId);
|
||||
entPayRequest.setOpenid(wechatUser.getOpenid());
|
||||
entPayRequest.setPartnerTradeNo(resources.getId().toString());
|
||||
entPayRequest.setCheckName("FORCE_CHECK");
|
||||
entPayRequest.setReUserName(resources.getRealName());
|
||||
entPayRequest.setAmount(resources.getExtractPrice()
|
||||
.multiply(new BigDecimal(100)).intValue());
|
||||
entPayRequest.setDescription("佣金提现");
|
||||
entPayRequest.setSpbillCreateIp("127.0.0.1");
|
||||
wxPayService.getEntPayService().entPay(entPayRequest);
|
||||
} catch (WxPayException e) {
|
||||
throw new BadRequestException(e.getMessage());
|
||||
}
|
||||
}else{
|
||||
throw new BadRequestException("不是微信用户无法退款");
|
||||
}
|
||||
|
||||
}
|
||||
yxUserExtractService.update(resources);
|
||||
return new ResponseEntity(HttpStatus.NO_CONTENT);
|
||||
|
Reference in New Issue
Block a user