Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
commit
37361cb568
|
|
@ -167,10 +167,6 @@ public class FinanceRechargerServiceImpl implements IFinanceRechargerService {
|
|||
rechargeOrder.setRefundStatus(1);
|
||||
rechargeOrderMapper.updateById(rechargeOrder);
|
||||
|
||||
// 更新用户余额
|
||||
user.setUserMoney(user.getUserMoney().subtract(rechargeOrder.getOrderAmount()));
|
||||
userMapper.updateById(user);
|
||||
|
||||
// 记录余额日志
|
||||
userAccountLogMapper.dec(
|
||||
user.getId(),
|
||||
|
|
@ -182,6 +178,11 @@ public class FinanceRechargerServiceImpl implements IFinanceRechargerService {
|
|||
null
|
||||
);
|
||||
|
||||
|
||||
// 更新用户余额
|
||||
user.setUserMoney(user.getUserMoney().subtract(rechargeOrder.getOrderAmount()));
|
||||
userMapper.updateById(user);
|
||||
|
||||
// 生成退款记录
|
||||
String refundSn = refundRecordMapper.randMakeOrderSn("sn");
|
||||
refundRecord = new RefundRecord();
|
||||
|
|
|
|||
|
|
@ -8,10 +8,10 @@ public enum LogMoneyEnum {
|
|||
/**
|
||||
* 用户余额类型
|
||||
*/
|
||||
UM_INC_ADMIN(1001, "平台增加余额"),
|
||||
UM_DEC_ADMIN(1002, "平台减少余额"),
|
||||
UM_INC_RECHARGE(1003, "充值余额增加"),
|
||||
UM_DEC_RECHARGE(1004, "充值余额退回");
|
||||
UM_INC_ADMIN(200, "平台增加余额"),
|
||||
UM_DEC_ADMIN(100, "平台减少余额"),
|
||||
UM_INC_RECHARGE(201, "充值增加余额"),
|
||||
UM_DEC_RECHARGE(101, "充值订单退款减少余额");
|
||||
|
||||
/**
|
||||
* 构造方法
|
||||
|
|
|
|||
|
|
@ -137,13 +137,13 @@ public class WxPayDriver {
|
|||
requestObj.setNotifyUrl(request.getNotifyUrl());
|
||||
requestObj.setSubMchid(request.getSubMchid());
|
||||
requestObj.setGoodsDetails(request.getGoodsDetails());
|
||||
|
||||
WxPayRefundV3Request.Amount amount = new WxPayRefundV3Request.Amount();
|
||||
amount.setRefund(request.getRefundAmount());
|
||||
amount.setTotal(request.getTotalAmount());
|
||||
amount.setCurrency(StringUtils.isEmpty(request.getCurrency()) ? "CNY" : request.getCurrency());
|
||||
requestObj.setAmount(amount);
|
||||
|
||||
WxPayService wxPayService = WxPayDriver.handler(4);
|
||||
return wxPayService.refundV3(requestObj);
|
||||
}
|
||||
|
||||
|
|
@ -176,7 +176,6 @@ public class WxPayDriver {
|
|||
.last("limit 1"));
|
||||
String scene = type.equals("oa") ? "oa_setting" : "mnp_setting";
|
||||
String appId = ConfigUtils.get(scene, "app_id", "");
|
||||
|
||||
Map<String, String> params = MapUtils.jsonToMap(config.getConfig().toString());
|
||||
String mchId = params.get("mch_id");
|
||||
String paySignKey = params.get("pay_sign_key");
|
||||
|
|
@ -190,7 +189,6 @@ public class WxPayDriver {
|
|||
payConfig.setPrivateKeyContent(privateKey);
|
||||
payConfig.setPrivateCertContent(privateCert);
|
||||
payConfig.setUseSandboxEnv(false);
|
||||
|
||||
if (!type.equals("oa")) {
|
||||
wxPayMnpService.setConfig(payConfig);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ public class LoginController {
|
|||
@PostMapping("/mnpLogin")
|
||||
@ApiOperation(value="微信登录")
|
||||
public AjaxResult<LoginTokenVo> mnpLogin(@Validated @RequestBody LoginCodeValidate loginCodeValidate) {
|
||||
Integer terminal = LikeFrontThreadLocal.getTerminal();
|
||||
Integer terminal = ClientEnum.MNP.getCode();
|
||||
|
||||
String code = loginCodeValidate.getCode();
|
||||
|
||||
|
|
@ -145,4 +145,14 @@ public class LoginController {
|
|||
iUserService.bindOa(BindOaValidate, userId);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/mnpAuthBind")
|
||||
@ApiOperation(value="绑定小程序")
|
||||
public AjaxResult<Object> mnpAuthBind(@Validated @RequestBody UserBindWechatValidate BindOaValidate) {
|
||||
Integer userId = LikeFrontThreadLocal.getUserId();
|
||||
iUserService.bindMnp(BindOaValidate, userId);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ public class PayController {
|
|||
Integer payWay = requestObj.getPayWay();
|
||||
Integer orderId = requestObj.getOrderId();
|
||||
Integer terminal = LikeFrontThreadLocal.getTerminal();
|
||||
String code = requestObj.getCode();
|
||||
requestObj.setTerminal(terminal);
|
||||
|
||||
// 订单处理
|
||||
|
|
@ -98,7 +99,7 @@ public class PayController {
|
|||
throw new OperateException("订单已支付");
|
||||
}
|
||||
// 发起支付
|
||||
Object result = iPayService.prepay(requestObj, terminal);
|
||||
Object result = iPayService.prepay(requestObj, terminal, code);
|
||||
return AjaxResult.success(result);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public interface IPayService {
|
|||
* @param terminal 终端
|
||||
* @return Object
|
||||
*/
|
||||
Object prepay(PaymentValidate params, Integer terminal);
|
||||
Object prepay(PaymentValidate params, Integer terminal, String code);
|
||||
|
||||
/**
|
||||
* 支付回调处理
|
||||
|
|
|
|||
|
|
@ -349,11 +349,21 @@ public class LoginServiceImpl implements ILoginService {
|
|||
System.out.println("openId: " + openId);
|
||||
System.out.println("unionId: " + unionId);
|
||||
// 查询授权
|
||||
UserAuth userAuth = userAuthMapper.selectOne(new QueryWrapper<UserAuth>()
|
||||
.nested(wq->wq
|
||||
.eq("unionid", unionId).or()
|
||||
.eq("openid", openId)
|
||||
).last("limit 1"));
|
||||
QueryWrapper queryWrapper = new QueryWrapper<UserAuth>();
|
||||
|
||||
if (StringUtils.equals(unionId, "0") == false) {
|
||||
queryWrapper = new QueryWrapper<UserAuth>()
|
||||
.nested(wq->wq
|
||||
.eq("unionid", unionId).or()
|
||||
.eq("openid", openId)
|
||||
).last("limit 1");
|
||||
} else {
|
||||
queryWrapper = new QueryWrapper<UserAuth>()
|
||||
.nested(wq->wq
|
||||
.eq("openid", openId)
|
||||
).last("limit 1");
|
||||
}
|
||||
UserAuth userAuth = userAuthMapper.selectOne(queryWrapper);
|
||||
|
||||
// 查询用户
|
||||
User user = null;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.mdd.front.service.impl;
|
||||
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.alipay.api.AlipayApiException;
|
||||
import com.alipay.api.AlipayClient;
|
||||
|
|
@ -13,10 +15,7 @@ import com.mdd.common.entity.setting.DevPayConfig;
|
|||
import com.mdd.common.entity.setting.DevPayWay;
|
||||
import com.mdd.common.entity.user.User;
|
||||
import com.mdd.common.entity.user.UserAuth;
|
||||
import com.mdd.common.enums.ClientEnum;
|
||||
import com.mdd.common.enums.LogMoneyEnum;
|
||||
import com.mdd.common.enums.PaymentEnum;
|
||||
import com.mdd.common.enums.YesNoEnum;
|
||||
import com.mdd.common.enums.*;
|
||||
import com.mdd.common.exception.OperateException;
|
||||
import com.mdd.common.exception.PaymentException;
|
||||
import com.mdd.common.mapper.log.UserAccountLogMapper;
|
||||
|
|
@ -25,6 +24,7 @@ import com.mdd.common.mapper.setting.DevPayConfigMapper;
|
|||
import com.mdd.common.mapper.setting.DevPayWayMapper;
|
||||
import com.mdd.common.mapper.user.UserAuthMapper;
|
||||
import com.mdd.common.mapper.user.UserMapper;
|
||||
import com.mdd.common.plugin.wechat.WxMnpDriver;
|
||||
import com.mdd.common.plugin.wechat.WxPayDriver;
|
||||
import com.mdd.common.plugin.wechat.request.PaymentRequestV3;
|
||||
import com.mdd.common.util.*;
|
||||
|
|
@ -34,6 +34,8 @@ import com.mdd.front.vo.pay.PayStatusVo;
|
|||
import com.mdd.front.vo.pay.PayWayInfoVo;
|
||||
import com.mdd.front.vo.pay.PayWayListVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.common.bean.oauth2.WxOAuth2AccessToken;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
|
@ -163,7 +165,7 @@ public class PayServiceImpl implements IPayService {
|
|||
* @param terminal 终端
|
||||
* @return Object
|
||||
*/
|
||||
public Object prepay(PaymentValidate params, Integer terminal) {
|
||||
public Object prepay(PaymentValidate params, Integer terminal, String code) {
|
||||
try {
|
||||
params.setTerminal(terminal);
|
||||
String openId = null;
|
||||
|
|
@ -174,6 +176,20 @@ public class PayServiceImpl implements IPayService {
|
|||
|
||||
if (StringUtils.isNotNull(userAuth)) {
|
||||
openId = userAuth.getOpenid();
|
||||
} else {
|
||||
if(terminal.intValue() != ClientEnum.PC.getCode()) {
|
||||
if (StringUtils.isNotEmpty(code)) {
|
||||
if (ClientEnum.OA.getCode() == terminal.intValue()) {
|
||||
WxMpService wxMpService = WxMnpDriver.oa();
|
||||
WxOAuth2AccessToken wxOAuth2AccessToken = wxMpService.getOAuth2Service().getAccessToken(code);
|
||||
openId = wxOAuth2AccessToken.getOpenId();
|
||||
} else if (ClientEnum.MNP.getCode() == terminal.intValue()) {
|
||||
WxMaService wxMaService = WxMnpDriver.mnp();
|
||||
WxMaJscode2SessionResult sessionResult = wxMaService.getUserService().getSessionInfo(code);
|
||||
openId = sessionResult.getOpenid();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (params.getPayWay()) {
|
||||
|
|
@ -191,12 +207,10 @@ public class PayServiceImpl implements IPayService {
|
|||
requestV3.setOrderAmount(params.getOrderAmount());
|
||||
requestV3.setDescription(params.getDescription());
|
||||
Object result = WxPayDriver.unifiedOrder(requestV3);
|
||||
System.out.println(terminal);
|
||||
if (terminal == ClientEnum.H5.getCode()) {
|
||||
Assert.notNull(params.getRedirect(), "redirectUrl参数缺失");
|
||||
JSONObject ret = new JSONObject();
|
||||
String h5Url = result.toString();
|
||||
System.out.println("aaaaaaaaaa");
|
||||
ret.put("config", WxPayDriver.unifiedOrder(requestV3));
|
||||
ret.put("pay_way", 2);
|
||||
return ret;
|
||||
|
|
@ -345,18 +359,18 @@ public class PayServiceImpl implements IPayService {
|
|||
rechargeOrder.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
rechargeOrderMapper.updateById(rechargeOrder);
|
||||
|
||||
User user = userMapper.selectById(rechargeOrder.getUserId());
|
||||
user.setUserMoney(user.getUserMoney().add(rechargeOrder.getOrderAmount()));
|
||||
user.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
userMapper.updateById(user);
|
||||
|
||||
logMoneyMapper.add(rechargeOrder.getUserId(),
|
||||
LogMoneyEnum.UM_INC_RECHARGE.getCode(),
|
||||
AccountLogEnum.UM_INC_RECHARGE.getCode(),
|
||||
rechargeOrder.getOrderAmount(),
|
||||
rechargeOrder.getId(),
|
||||
rechargeOrder.getSn(),
|
||||
"用户充值余额", null);
|
||||
|
||||
User user = userMapper.selectById(rechargeOrder.getUserId());
|
||||
user.setUserMoney(user.getUserMoney().add(rechargeOrder.getOrderAmount()));
|
||||
user.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
userMapper.updateById(user);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ public class UserServiceImpl implements IUserService {
|
|||
}
|
||||
|
||||
vo.setIsAuth(false);
|
||||
if (terminal.equals(ClientEnum.OA.getCode()) || terminal.equals(ClientEnum.MNP.getCode())) {
|
||||
if (terminal.equals(ClientEnum.OA.getCode()) || terminal.equals(ClientEnum.MNP.getCode()) || terminal.equals(ClientEnum.H5.getCode())) {
|
||||
UserAuth userAuth = userAuthMapper.selectOne(new QueryWrapper<UserAuth>()
|
||||
.select("id,openid,terminal")
|
||||
.eq("user_id", userId)
|
||||
|
|
|
|||
|
|
@ -47,4 +47,7 @@ public class PaymentValidate implements Serializable {
|
|||
@ApiModelProperty(value = "Terminal")
|
||||
private Integer Terminal;
|
||||
|
||||
@ApiModelProperty(value = "微信授权code")
|
||||
private String code;
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue