支付
This commit is contained in:
parent
fab091e614
commit
c8e155eaf6
@ -10,10 +10,14 @@ import com.pixelai.api.pa.service.PaVipCurrencyService;
|
|||||||
import com.pixelai.api.pa.service.PaVipService;
|
import com.pixelai.api.pa.service.PaVipService;
|
||||||
import com.pixelai.config.WeChatConfig;
|
import com.pixelai.config.WeChatConfig;
|
||||||
import com.pixelai.utils.WeChatUtil;
|
import com.pixelai.utils.WeChatUtil;
|
||||||
|
import com.wechat.pay.java.core.exception.HttpException;
|
||||||
|
import com.wechat.pay.java.core.exception.ServiceException;
|
||||||
import com.wechat.pay.java.core.exception.ValidationException;
|
import com.wechat.pay.java.core.exception.ValidationException;
|
||||||
import com.wechat.pay.java.core.http.*;
|
import com.wechat.pay.java.core.http.*;
|
||||||
import com.wechat.pay.java.core.notification.NotificationParser;
|
import com.wechat.pay.java.core.notification.NotificationParser;
|
||||||
import com.wechat.pay.java.core.util.GsonUtil;
|
import com.wechat.pay.java.core.util.GsonUtil;
|
||||||
|
import com.wechat.pay.java.service.payments.jsapi.JsapiService;
|
||||||
|
import com.wechat.pay.java.service.payments.jsapi.model.Payer;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import com.wechat.pay.java.service.partnerpayments.h5.model.Transaction;
|
import com.wechat.pay.java.service.partnerpayments.h5.model.Transaction;
|
||||||
@ -39,6 +43,8 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class OrderPayAppService {
|
public class OrderPayAppService {
|
||||||
@ -48,6 +54,8 @@ public class OrderPayAppService {
|
|||||||
private NotificationParser notificationParser;
|
private NotificationParser notificationParser;
|
||||||
@Resource
|
@Resource
|
||||||
private H5Service h5Service;
|
private H5Service h5Service;
|
||||||
|
// @Resource
|
||||||
|
// private JsapiService jsapiService;
|
||||||
@Resource
|
@Resource
|
||||||
private PaOrderService paOrderService;
|
private PaOrderService paOrderService;
|
||||||
@Resource
|
@Resource
|
||||||
@ -123,26 +131,24 @@ public class OrderPayAppService {
|
|||||||
paOrderService.updateById(order);
|
paOrderService.updateById(order);
|
||||||
logger.info("Order status updated to HAVE_TO_PAY. Order ID: {}", order.getId());
|
logger.info("Order status updated to HAVE_TO_PAY. Order ID: {}", order.getId());
|
||||||
//支付成功-充值钻石
|
//支付成功-充值钻石
|
||||||
PaVipCurrency currency = new PaVipCurrency();
|
PaVipCurrency currency = paVipCurrencyService.findByUserId(order.getMemberId());
|
||||||
currency.setState("t");
|
currency.setState("t");
|
||||||
if (order.getBuyType().equals("1")){
|
if (order.getBuyType().equals("1")){
|
||||||
currency.setNumerical(5);
|
currency.setNumerical(currency.getNumerical()+5);
|
||||||
}else if (order.getBuyType().equals("2")){
|
}else if (order.getBuyType().equals("2")){
|
||||||
currency.setNumerical(10);
|
currency.setNumerical(currency.getNumerical()+10);
|
||||||
}else if (order.getBuyType().equals("3")){
|
}else if (order.getBuyType().equals("3")){
|
||||||
currency.setNumerical(20);
|
currency.setNumerical(currency.getNumerical()+20);
|
||||||
}else if (order.getBuyType().equals("4")){
|
}else if (order.getBuyType().equals("4")){
|
||||||
currency.setNumerical(30);
|
currency.setNumerical(currency.getNumerical()+30);
|
||||||
}else if (order.getBuyType().equals("5")){
|
}else if (order.getBuyType().equals("5")){
|
||||||
currency.setNumerical(50);
|
currency.setNumerical(currency.getNumerical()+50);
|
||||||
}else if (order.getBuyType().equals("6")){
|
}else if (order.getBuyType().equals("6")){
|
||||||
currency.setNumerical(100);
|
currency.setNumerical(currency.getNumerical()+100);
|
||||||
}else {
|
}else {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
currency.setUserid(order.getMemberId());
|
paVipCurrencyService.updateById(currency);
|
||||||
paVipCurrencyService.save(currency);
|
|
||||||
// 添加日志
|
// 添加日志
|
||||||
PaConsumption consumption = new PaConsumption();
|
PaConsumption consumption = new PaConsumption();
|
||||||
consumption.setAddOrSub("add");
|
consumption.setAddOrSub("add");
|
||||||
@ -156,4 +162,39 @@ public class OrderPayAppService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// public PaOrder jsPay(PaOrder order, HttpServletRequest request) {
|
||||||
|
// com.wechat.pay.java.service.payments.jsapi.model.PrepayRequest prepayRequest = new com.wechat.pay.java.service.payments.jsapi.model.PrepayRequest();
|
||||||
|
// prepayRequest.setAppid(weChatConfig.getAppId());
|
||||||
|
// prepayRequest.setMchid(weChatConfig.getMerchantId());
|
||||||
|
// String tradeNo = WeChatUtil.generateTradeNumber();
|
||||||
|
// prepayRequest.setOutTradeNo(tradeNo);
|
||||||
|
// prepayRequest.setDescription("钻石购买");
|
||||||
|
// prepayRequest.setNotifyUrl(weChatConfig.notifyUrl);
|
||||||
|
// com.wechat.pay.java.service.payments.jsapi.model.Amount amount = new com.wechat.pay.java.service.payments.jsapi.model.Amount();
|
||||||
|
// amount.setTotal((order.getAmount().multiply(new BigDecimal("100"))).intValue());
|
||||||
|
// prepayRequest.setAmount(amount);
|
||||||
|
// Payer payer = new Payer();
|
||||||
|
// payer.setOpenid(order.getOpenid());
|
||||||
|
// prepayRequest.setPayer(payer);
|
||||||
|
// // 调用下单方法,得到应答
|
||||||
|
// PrepayResponse response;
|
||||||
|
// try {
|
||||||
|
// com.wechat.pay.java.service.payments.jsapi.model.PrepayResponse prepay = jsapiService.prepay(prepayRequest);
|
||||||
|
// //预支付成功,创建预支付订单
|
||||||
|
// order.setOrderNum(tradeNo);
|
||||||
|
// order.setPayStatus(PayState.TO_BE_PAID);
|
||||||
|
// order.setCreateTime(new Date());
|
||||||
|
// order.setState("t");
|
||||||
|
// order.setH5Url(null);
|
||||||
|
// paOrderService.save(order);
|
||||||
|
// return order;
|
||||||
|
// } catch (HttpException e) { // 发送HTTP请求失败
|
||||||
|
// e.printStackTrace();
|
||||||
|
// } catch (ServiceException e) { // 服务返回状态小于200或大于等于300,例如500
|
||||||
|
// e.printStackTrace();
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,8 @@ import javax.validation.Valid;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
/**
|
/**
|
||||||
@ -110,6 +112,16 @@ public class PaOrderController extends BaseController {
|
|||||||
return new Result<>(true, order1);
|
return new Result<>(true, order1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ApiOperation(value = "js支付")
|
||||||
|
// @RequestMapping("jsPay")
|
||||||
|
// public Result jsPay(PaOrder order, HttpServletRequest request) {
|
||||||
|
// PaOrder order1 = payAppService.jsPay(order, request);
|
||||||
|
// if (Objects.isNull(order1)) {
|
||||||
|
// return new Result<>(false, "支付失败");
|
||||||
|
// }
|
||||||
|
// return new Result<>(true, order1);
|
||||||
|
// }
|
||||||
|
|
||||||
@ApiOperation(value = "h5回调")
|
@ApiOperation(value = "h5回调")
|
||||||
@PostMapping(value = "payNotify")
|
@PostMapping(value = "payNotify")
|
||||||
@Unsecured
|
@Unsecured
|
||||||
|
@ -72,4 +72,8 @@ public class PaOrder implements Serializable {
|
|||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
@ApiModelProperty(value = "预下单地址")
|
@ApiModelProperty(value = "预下单地址")
|
||||||
private String h5Url;
|
private String h5Url;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
@ApiModelProperty(value = "openid")
|
||||||
|
private String openid;
|
||||||
}
|
}
|
||||||
|
@ -44,4 +44,10 @@ public interface PaVipCurrencyService extends IService<PaVipCurrency> {
|
|||||||
*/
|
*/
|
||||||
IPage<PaVipCurrency> page(PaVipCurrency example,IPage page);
|
IPage<PaVipCurrency> page(PaVipCurrency example,IPage page);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* userId获取
|
||||||
|
* @param memberId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
PaVipCurrency findByUserId(Integer memberId);
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,8 @@ public class PaOrderServiceImpl extends ServiceImpl<PaOrderMapper, PaOrder> impl
|
|||||||
*/
|
*/
|
||||||
private QueryWrapper<PaOrder> buildWrapper(PaOrder example) {
|
private QueryWrapper<PaOrder> buildWrapper(PaOrder example) {
|
||||||
QueryWrapper<PaOrder> wrapper = new QueryWrapper<>();
|
QueryWrapper<PaOrder> wrapper = new QueryWrapper<>();
|
||||||
|
wrapper.lambda()
|
||||||
|
.eq(example.getMemberId() != null, PaOrder::getMemberId, example.getMemberId());
|
||||||
return wrapper;
|
return wrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,6 +76,15 @@ public class PaVipCurrencyServiceImpl extends ServiceImpl<PaVipCurrencyMapper, P
|
|||||||
return this.page(page,buildWrapper(example));
|
return this.page(page,buildWrapper(example));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PaVipCurrency findByUserId(Integer memberId) {
|
||||||
|
QueryWrapper<PaVipCurrency> queryWrapper=new QueryWrapper<>();
|
||||||
|
queryWrapper.lambda()
|
||||||
|
.eq(PaVipCurrency::getUserid,memberId)
|
||||||
|
.eq(PaVipCurrency::getState,"t");
|
||||||
|
return getOne(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建查询
|
* 构建查询
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user