|
@@ -18,7 +18,6 @@ import com.alipay.api.request.AlipayTradeWapPayRequest;
|
|
|
import com.alipay.api.response.AlipayTradeAppPayResponse;
|
|
|
import com.alipay.api.response.AlipayTradeQueryResponse;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.zbkj.common.constants.*;
|
|
|
import com.zbkj.common.exception.CrmebException;
|
|
|
import com.zbkj.common.model.bill.Bill;
|
|
@@ -44,6 +43,7 @@ import com.zbkj.common.vo.*;
|
|
|
import com.zbkj.common.vo.wxvedioshop.ShopOrderAddResultVo;
|
|
|
import com.zbkj.common.vo.wxvedioshop.order.*;
|
|
|
import com.zbkj.service.service.*;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
@@ -59,7 +59,6 @@ import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* PayServiceImpl 接口实现
|
|
|
-
|
|
|
*/
|
|
|
@Service
|
|
|
public class PayServiceImpl implements PayService {
|
|
@@ -136,6 +135,8 @@ public class PayServiceImpl implements PayService {
|
|
|
private UserBypassAccountService userBypassAccountService;
|
|
|
@Autowired
|
|
|
private UserEnterpriseRecordService userEnterpriseRecordService;
|
|
|
+ @Autowired
|
|
|
+ private EmailUtil emailUtil;
|
|
|
|
|
|
/**
|
|
|
* 获取支付配置
|
|
@@ -177,6 +178,8 @@ public class PayServiceImpl implements PayService {
|
|
|
throw new CrmebException("订单状态异常");
|
|
|
}
|
|
|
User user = userService.getInfo();
|
|
|
+
|
|
|
+
|
|
|
// 根据支付类型进行校验,更换支付类型
|
|
|
order.setPayType(orderPayRequest.getPayType());
|
|
|
order.setPayChannel(orderPayRequest.getPayChannel());
|
|
@@ -188,22 +191,22 @@ public class PayServiceImpl implements PayService {
|
|
|
}
|
|
|
//加企业信息id,为以后 如果人员跳槽还能查到另个公司购买信息做准备
|
|
|
LambdaQueryWrapper<UserEnterprise> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper.eq( UserEnterprise::getUserId, order.getUid() );
|
|
|
- queryWrapper.eq( UserEnterprise::getIsDelete, 0 );
|
|
|
- UserEnterprise one = userEnterpriseService.getOne( queryWrapper, false );
|
|
|
+ queryWrapper.eq(UserEnterprise::getUserId, order.getUid());
|
|
|
+ queryWrapper.eq(UserEnterprise::getIsDelete, 0);
|
|
|
+ UserEnterprise one = userEnterpriseService.getOne(queryWrapper, false);
|
|
|
if (one == null) {
|
|
|
LambdaQueryWrapper<UserBypassAccount> queryWrapper2 = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper2.eq( UserBypassAccount::getUserId, order.getUid() );
|
|
|
- queryWrapper2.eq( UserBypassAccount::getIsDelete, 0 );
|
|
|
- UserBypassAccount one1 = userBypassAccountService.getOne( queryWrapper2, false );
|
|
|
+ queryWrapper2.eq(UserBypassAccount::getUserId, order.getUid());
|
|
|
+ queryWrapper2.eq(UserBypassAccount::getIsDelete, 0);
|
|
|
+ UserBypassAccount one1 = userBypassAccountService.getOne(queryWrapper2, false);
|
|
|
if (one1 == null) {
|
|
|
|
|
|
} else {
|
|
|
- one = userEnterpriseService.getById( one1.getEnterpriseId() );
|
|
|
+ one = userEnterpriseService.getById(one1.getEnterpriseId());
|
|
|
}
|
|
|
}
|
|
|
- if (one!=null){
|
|
|
- order.setQyId( one.getId() );
|
|
|
+ if (one != null) {
|
|
|
+ order.setQyId(one.getId());
|
|
|
}
|
|
|
|
|
|
OrderPayResultResponse response = new OrderPayResultResponse();
|
|
@@ -222,6 +225,34 @@ public class PayServiceImpl implements PayService {
|
|
|
Boolean yueBoolean = yuePay(order, user);
|
|
|
response.setStatus(yueBoolean);
|
|
|
logger.info("余额支付 response : {}", JSON.toJSONString(response));
|
|
|
+ //创建订单完成后发送邮件
|
|
|
+ HashMap<String, String> map = systemConfigService.info(59);
|
|
|
+ String isCerateTemp = map.get("isCerateTemp");
|
|
|
+ String orderNo = order.getOrderNo();
|
|
|
+ List<OrderDetail> byOrderNo = orderDetailService.getByOrderNo(orderNo);
|
|
|
+ for (OrderDetail orderDetail : byOrderNo) {
|
|
|
+ Integer merId = orderDetail.getMerId();
|
|
|
+ Merchant merchant = merchantService.getById(merId);
|
|
|
+ if (StringUtils.isNotBlank(isCerateTemp)) {
|
|
|
+ if ("1".equals(isCerateTemp)) {
|
|
|
+ String fromEmail = map.get("fromEmail");
|
|
|
+ String emailPassword = map.get("emailPassword");
|
|
|
+ String cerateTemp = map.get("cerateTemp");
|
|
|
+ String cerateTempTitle = map.get("cerateTempTitle");
|
|
|
+ String afterEmail = StringUtils.substringAfter(fromEmail, "@");
|
|
|
+ if ("163.com".equals(afterEmail)) {
|
|
|
+ emailUtil.sendMessage(fromEmail, emailPassword, "smtp.163.com", merchant.getEmail(), cerateTempTitle, cerateTemp);
|
|
|
+ } else if ("qq.com".equals(afterEmail)) {
|
|
|
+ emailUtil.sendMessage(fromEmail, emailPassword, "smtp.qq.com", merchant.getEmail(), cerateTempTitle, cerateTemp);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
return response;
|
|
|
}
|
|
|
// 微信支付,调用微信预下单,返回拉起微信支付需要的信息
|
|
@@ -232,10 +263,11 @@ public class PayServiceImpl implements PayService {
|
|
|
response.setStatus(true);
|
|
|
response.setJsConfig(vo);
|
|
|
logger.info("订单支付 微信下单 response :{}", JSON.toJSONString(response));
|
|
|
+
|
|
|
}
|
|
|
|
|
|
// 微信视频号下单 需要额外调用支付参数
|
|
|
- if(order.getPayChannel().equals(PayConstants.PAY_CHANNEL_WECHAT_MINI_VIDEO)){
|
|
|
+ if (order.getPayChannel().equals(PayConstants.PAY_CHANNEL_WECHAT_MINI_VIDEO)) {
|
|
|
WxPayJsResultVo vo = new WxPayJsResultVo();
|
|
|
UserToken tokenByUser = userTokenService.getTokenByUserId(user.getId(), UserConstants.USER_TOKEN_TYPE_ROUTINE);
|
|
|
List<OrderDetail> orderDetailList = orderDetailService.getByOrderNo(order.getOrderNo());
|
|
@@ -287,11 +319,11 @@ public class PayServiceImpl implements PayService {
|
|
|
shopOrderAddVo.setMerId(order.getMerId());
|
|
|
|
|
|
// 订单路由地址
|
|
|
- shopOrderAddVo.setPath("/pages/users/order_details/index?orderNo="+orderPayRequest.getOrderNo());
|
|
|
+ shopOrderAddVo.setPath("/pages/users/order_details/index?orderNo=" + orderPayRequest.getOrderNo());
|
|
|
|
|
|
// 组装订单信息 视频号都是单品 最多是多量
|
|
|
List<MerchantOrder> merchantOrderList = merchantOrderService.getByOrderNo(orderPayRequest.getOrderNo());
|
|
|
- if(ObjectUtil.isNull(merchantOrderList) || merchantOrderList.size() == 0) {
|
|
|
+ if (ObjectUtil.isNull(merchantOrderList) || merchantOrderList.size() == 0) {
|
|
|
throw new CrmebException("未找到视频号商品订单");
|
|
|
}
|
|
|
MerchantOrder CurrentMerchantOrder = merchantOrderList.get(0);
|
|
@@ -316,13 +348,41 @@ public class PayServiceImpl implements PayService {
|
|
|
ShopOrderGetPaymentParamsRersponseVo shopOrderGetPaymentParamsRersponseVo = wechatVideoOrderService.shopOrderGetPaymentParams(videoPaymentRequestVo);
|
|
|
logger.info("视频号下单时 获取的支付参数 {}", JSON.toJSONString(shopOrderGetPaymentParamsRersponseVo));
|
|
|
response.setStatus(true);
|
|
|
- vo.setTimeStamp(WxPayUtil.getCurrentTimestamp()+"");
|
|
|
+ vo.setTimeStamp(WxPayUtil.getCurrentTimestamp() + "");
|
|
|
vo.setNonceStr(shopOrderGetPaymentParamsRersponseVo.getNonceStr());
|
|
|
vo.setPackages(shopOrderGetPaymentParamsRersponseVo.get_package());
|
|
|
vo.setPaySign(shopOrderGetPaymentParamsRersponseVo.getPaySign());
|
|
|
vo.setSignType(shopOrderGetPaymentParamsRersponseVo.getSignType());
|
|
|
response.setJsConfig(vo);
|
|
|
logger.info("订单支付 视频号下单 response:{}", JSON.toJSONString(response));
|
|
|
+ //创建订单完成后发送邮件
|
|
|
+ HashMap<String, String> map = systemConfigService.info(59);
|
|
|
+ String isCerateTemp = map.get("isCerateTemp");
|
|
|
+ String orderNo = order.getOrderNo();
|
|
|
+ List<OrderDetail> byOrderNo = orderDetailService.getByOrderNo(orderNo);
|
|
|
+ for (OrderDetail orderDetail : byOrderNo) {
|
|
|
+ Integer merId = orderDetail.getMerId();
|
|
|
+
|
|
|
+ Merchant merchant = merchantService.getById(merId);
|
|
|
+ if (StringUtils.isNotBlank(isCerateTemp)) {
|
|
|
+ if ("1".equals(isCerateTemp)) {
|
|
|
+ String fromEmail = map.get("fromEmail");
|
|
|
+ String emailPassword = map.get("emailPassword");
|
|
|
+ String cerateTemp = map.get("cerateTemp");
|
|
|
+ String cerateTempTitle = map.get("cerateTempTitle");
|
|
|
+ String afterEmail = StringUtils.substringAfter(fromEmail, "@");
|
|
|
+ if ("163.com".equals(afterEmail)) {
|
|
|
+ emailUtil.sendMessage(fromEmail, emailPassword, "smtp.163.com", merchant.getEmail(), cerateTempTitle, cerateTemp);
|
|
|
+ } else if ("qq.com".equals(afterEmail)) {
|
|
|
+ emailUtil.sendMessage(fromEmail, emailPassword, "smtp.qq.com", merchant.getEmail(), cerateTempTitle, cerateTemp);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return response;
|
|
|
}
|
|
|
// 微信支付,调用微信预下单,返回拉起微信支付需要的信息
|
|
@@ -333,6 +393,33 @@ public class PayServiceImpl implements PayService {
|
|
|
response.setStatus(true);
|
|
|
response.setJsConfig(vo);
|
|
|
logger.info("订单支付 微信下单 response :{}", JSON.toJSONString(response));
|
|
|
+ //创建订单完成后发送邮件
|
|
|
+ HashMap<String, String> map = systemConfigService.info(59);
|
|
|
+ String isCerateTemp = map.get("isCerateTemp");
|
|
|
+ String orderNo = order.getOrderNo();
|
|
|
+ List<OrderDetail> byOrderNo = orderDetailService.getByOrderNo(orderNo);
|
|
|
+ for (OrderDetail orderDetail : byOrderNo) {
|
|
|
+ Integer merId = orderDetail.getMerId();
|
|
|
+
|
|
|
+ Merchant merchant = merchantService.getById(merId);
|
|
|
+ if (StringUtils.isNotBlank(isCerateTemp)) {
|
|
|
+ if ("1".equals(isCerateTemp)) {
|
|
|
+ String fromEmail = map.get("fromEmail");
|
|
|
+ String emailPassword = map.get("emailPassword");
|
|
|
+ String cerateTemp = map.get("cerateTemp");
|
|
|
+ String cerateTempTitle = map.get("cerateTempTitle");
|
|
|
+ String afterEmail = StringUtils.substringAfter(fromEmail, "@");
|
|
|
+ if ("163.com".equals(afterEmail)) {
|
|
|
+ emailUtil.sendMessage(fromEmail, emailPassword, "smtp.163.com", merchant.getEmail(), cerateTempTitle, cerateTemp);
|
|
|
+ } else if ("qq.com".equals(afterEmail)) {
|
|
|
+ emailUtil.sendMessage(fromEmail, emailPassword, "smtp.qq.com", merchant.getEmail(), cerateTempTitle, cerateTemp);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
return response;
|
|
|
}
|
|
|
|
|
@@ -342,10 +429,66 @@ public class PayServiceImpl implements PayService {
|
|
|
response.setStatus(true);
|
|
|
response.setAlipayRequest(result);
|
|
|
logger.info("订单支付 支付宝 response :{}", JSON.toJSONString(response));
|
|
|
+ //创建订单完成后发送邮件
|
|
|
+ HashMap<String, String> map = systemConfigService.info(59);
|
|
|
+ String isCerateTemp = map.get("isCerateTemp");
|
|
|
+ String orderNo = order.getOrderNo();
|
|
|
+ List<OrderDetail> byOrderNo = orderDetailService.getByOrderNo(orderNo);
|
|
|
+ for (OrderDetail orderDetail : byOrderNo) {
|
|
|
+ Integer merId = orderDetail.getMerId();
|
|
|
+
|
|
|
+ Merchant merchant = merchantService.getById(merId);
|
|
|
+ if (StringUtils.isNotBlank(isCerateTemp)) {
|
|
|
+ if ("1".equals(isCerateTemp)) {
|
|
|
+ String fromEmail = map.get("fromEmail");
|
|
|
+ String emailPassword = map.get("emailPassword");
|
|
|
+ String cerateTemp = map.get("cerateTemp");
|
|
|
+ String cerateTempTitle = map.get("cerateTempTitle");
|
|
|
+ String afterEmail = StringUtils.substringAfter(fromEmail, "@");
|
|
|
+ if ("163.com".equals(afterEmail)) {
|
|
|
+ emailUtil.sendMessage(fromEmail, emailPassword, "smtp.163.com", merchant.getEmail(), cerateTempTitle, cerateTemp);
|
|
|
+ } else if ("qq.com".equals(afterEmail)) {
|
|
|
+ emailUtil.sendMessage(fromEmail, emailPassword, "smtp.qq.com", merchant.getEmail(), cerateTempTitle, cerateTemp);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
return response;
|
|
|
}
|
|
|
response.setStatus(false);
|
|
|
logger.info("订单支付 END response:{}", JSON.toJSONString(response));
|
|
|
+
|
|
|
+
|
|
|
+ //创建订单完成后发送邮件
|
|
|
+ HashMap<String, String> map = systemConfigService.info(59);
|
|
|
+ String isCerateTemp = map.get("isCerateTemp");
|
|
|
+ String orderNo = order.getOrderNo();
|
|
|
+ List<OrderDetail> byOrderNo = orderDetailService.getByOrderNo(orderNo);
|
|
|
+ for (OrderDetail orderDetail : byOrderNo) {
|
|
|
+ Integer merId = orderDetail.getMerId();
|
|
|
+
|
|
|
+ Merchant merchant = merchantService.getById(merId);
|
|
|
+ if (StringUtils.isNotBlank(isCerateTemp)) {
|
|
|
+ if ("1".equals(isCerateTemp)) {
|
|
|
+ String fromEmail = map.get("fromEmail");
|
|
|
+ String emailPassword = map.get("emailPassword");
|
|
|
+ String cerateTemp = map.get("cerateTemp");
|
|
|
+ String cerateTempTitle = map.get("cerateTempTitle");
|
|
|
+ String afterEmail = StringUtils.substringAfter(fromEmail, "@");
|
|
|
+ if ("163.com".equals(afterEmail)) {
|
|
|
+ emailUtil.sendMessage(fromEmail, emailPassword, "smtp.163.com", merchant.getEmail(), cerateTempTitle, cerateTemp);
|
|
|
+ } else if ("qq.com".equals(afterEmail)) {
|
|
|
+ emailUtil.sendMessage(fromEmail, emailPassword, "smtp.qq.com", merchant.getEmail(), cerateTempTitle, cerateTemp);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
return response;
|
|
|
}
|
|
|
|
|
@@ -370,58 +513,58 @@ public class PayServiceImpl implements PayService {
|
|
|
order.setIsLineOfCredit(1);
|
|
|
order.setPayChannel(orderPayRequest.getPayChannel());
|
|
|
// 信用额度支付
|
|
|
- if (!orderPayRequest.getPayType().equals("信用额度") ){
|
|
|
+ if (!orderPayRequest.getPayType().equals("信用额度")) {
|
|
|
throw new CrmebException("该支付是信用额度支付,传错参数");
|
|
|
}
|
|
|
- UserEnterprise one =null;
|
|
|
- List<OrderDetail> byOrderNo = orderDetailService.getByOrderNo( order.getOrderNo() );
|
|
|
+ UserEnterprise one = null;
|
|
|
+ List<OrderDetail> byOrderNo = orderDetailService.getByOrderNo(order.getOrderNo());
|
|
|
boolean isSameName = byOrderNo.stream()
|
|
|
.map(OrderDetail::getMerId)
|
|
|
.distinct()
|
|
|
.limit(2)
|
|
|
.count() <= 1;
|
|
|
- if (!isSameName){
|
|
|
+ if (!isSameName) {
|
|
|
throw new CrmebException("信用额度支付 不允许多家商户商品购买");
|
|
|
}
|
|
|
//查询信用额度够不够
|
|
|
- if (orderPayRequest.getUsertype().equals("企业用户") ){
|
|
|
+ if (orderPayRequest.getUsertype().equals("企业用户")) {
|
|
|
LambdaQueryWrapper<UserEnterprise> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper.eq( UserEnterprise::getUserId, user.getId() );
|
|
|
- queryWrapper.eq( UserEnterprise::getIsDelete, 0 );
|
|
|
- one = userEnterpriseService.getOne( queryWrapper );
|
|
|
- if (one==null){
|
|
|
+ queryWrapper.eq(UserEnterprise::getUserId, user.getId());
|
|
|
+ queryWrapper.eq(UserEnterprise::getIsDelete, 0);
|
|
|
+ one = userEnterpriseService.getOne(queryWrapper);
|
|
|
+ if (one == null) {
|
|
|
throw new CrmebException("企业用户查询失败,信用额度查询失败");
|
|
|
}
|
|
|
- if (one.getMerchantId()!=byOrderNo.get( 0 ).getMerId()){
|
|
|
+ if (one.getMerchantId() != byOrderNo.get(0).getMerId()) {
|
|
|
throw new CrmebException("你购买的商品不是绑定信用商户的商品,所以不能使用信用额度支付");
|
|
|
}
|
|
|
if (one.getAvailableLineOfCredit().compareTo(order.getPayPrice()) < 0) {
|
|
|
throw new CrmebException("企业信用额度不足");
|
|
|
}
|
|
|
- order.setAccount( one.getAccount() );
|
|
|
- order.setQyName( one.getEnterpriseName() );
|
|
|
+ order.setAccount(one.getAccount());
|
|
|
+ order.setQyName(one.getEnterpriseName());
|
|
|
//加企业信息id,为以后 如果人员跳槽还能查到另个公司购买信息做准备
|
|
|
- order.setQyId( one.getId() );
|
|
|
+ order.setQyId(one.getId());
|
|
|
}
|
|
|
- if (orderPayRequest.getUsertype().equals("企业子用户") ){
|
|
|
+ if (orderPayRequest.getUsertype().equals("企业子用户")) {
|
|
|
LambdaQueryWrapper<UserBypassAccount> queryWrapper2 = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper2.eq( UserBypassAccount::getUserId, user.getId() );
|
|
|
- queryWrapper2.eq( UserBypassAccount::getIsDelete, 0 );
|
|
|
- UserBypassAccount one1 = userBypassAccountService.getOne( queryWrapper2 );
|
|
|
- if (one1==null){
|
|
|
+ queryWrapper2.eq(UserBypassAccount::getUserId, user.getId());
|
|
|
+ queryWrapper2.eq(UserBypassAccount::getIsDelete, 0);
|
|
|
+ UserBypassAccount one1 = userBypassAccountService.getOne(queryWrapper2);
|
|
|
+ if (one1 == null) {
|
|
|
throw new CrmebException("企业用户查询失败,信用额度查询失败");
|
|
|
}
|
|
|
- one = userEnterpriseService.getById( one1.getEnterpriseId() );
|
|
|
- if (one.getMerchantId()!=byOrderNo.get( 0 ).getMerId()){
|
|
|
+ one = userEnterpriseService.getById(one1.getEnterpriseId());
|
|
|
+ if (one.getMerchantId() != byOrderNo.get(0).getMerId()) {
|
|
|
throw new CrmebException("你购买的商品不是绑定信用商户的商品,所以不能使用信用额度支付");
|
|
|
}
|
|
|
if (one.getAvailableLineOfCredit().compareTo(order.getPayPrice()) < 0) {
|
|
|
throw new CrmebException("企业信用额度不足");
|
|
|
}
|
|
|
- order.setAccount( one1.getAccount() );
|
|
|
- order.setQyName( one.getEnterpriseName() );
|
|
|
+ order.setAccount(one1.getAccount());
|
|
|
+ order.setQyName(one.getEnterpriseName());
|
|
|
//加企业信息id,为以后 如果人员跳槽还能查到另个公司购买信息做准备
|
|
|
- order.setQyId( one.getId() );
|
|
|
+ order.setQyId(one.getId());
|
|
|
}
|
|
|
|
|
|
OrderPayResultResponse response = new OrderPayResultResponse();
|
|
@@ -431,16 +574,71 @@ public class PayServiceImpl implements PayService {
|
|
|
|
|
|
// 信用额度支付
|
|
|
if (order.getPayType().equals("信用额度")) {
|
|
|
- Boolean yueBoolean = XYEDPay(order, user,one);
|
|
|
+ Boolean yueBoolean = XYEDPay(order, user, one);
|
|
|
response.setStatus(yueBoolean);
|
|
|
logger.info("信用额度支付 response : {}", JSON.toJSONString(response));
|
|
|
+ //创建订单完成后发送邮件
|
|
|
+ HashMap<String, String> map = systemConfigService.info(59);
|
|
|
+ String isCerateTemp = map.get("isCerateTemp");
|
|
|
+ String orderNo = order.getOrderNo();
|
|
|
+ List<OrderDetail> byOrderNo1 = orderDetailService.getByOrderNo(orderNo);
|
|
|
+ for (OrderDetail orderDetail : byOrderNo1) {
|
|
|
+ Integer merId = orderDetail.getMerId();
|
|
|
+
|
|
|
+ Merchant merchant = merchantService.getById(merId);
|
|
|
+ if (StringUtils.isNotBlank(isCerateTemp)) {
|
|
|
+ if ("1".equals(isCerateTemp)) {
|
|
|
+ String fromEmail = map.get("fromEmail");
|
|
|
+ String emailPassword = map.get("emailPassword");
|
|
|
+ String cerateTemp = map.get("cerateTemp");
|
|
|
+ String cerateTempTitle = map.get("cerateTempTitle");
|
|
|
+ String afterEmail = StringUtils.substringAfter(fromEmail, "@");
|
|
|
+ if ("163.com".equals(afterEmail)) {
|
|
|
+ emailUtil.sendMessage(fromEmail, emailPassword, "smtp.163.com", merchant.getEmail(), cerateTempTitle, cerateTemp);
|
|
|
+ } else if ("qq.com".equals(afterEmail)) {
|
|
|
+ emailUtil.sendMessage(fromEmail, emailPassword, "smtp.qq.com", merchant.getEmail(), cerateTempTitle, cerateTemp);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
return response;
|
|
|
}
|
|
|
|
|
|
response.setStatus(false);
|
|
|
logger.info("订单支付 END response:{}", JSON.toJSONString(response));
|
|
|
+ //支付完成完成后发送邮件
|
|
|
+ HashMap<String, String> map = systemConfigService.info(59);
|
|
|
+ String isCerateTemp = map.get("isCerateTemp");
|
|
|
+ String orderNo = order.getOrderNo();
|
|
|
+ List<OrderDetail> byOrderNo1 = orderDetailService.getByOrderNo(orderNo);
|
|
|
+ for (OrderDetail orderDetail : byOrderNo1) {
|
|
|
+ Integer merId = orderDetail.getMerId();
|
|
|
+
|
|
|
+ Merchant merchant = merchantService.getById(merId);
|
|
|
+ if (StringUtils.isNotBlank(isCerateTemp)) {
|
|
|
+ if ("1".equals(isCerateTemp)) {
|
|
|
+ String fromEmail = map.get("fromEmail");
|
|
|
+ String emailPassword = map.get("emailPassword");
|
|
|
+ String cerateTemp = map.get("cerateTemp");
|
|
|
+ String cerateTempTitle = map.get("cerateTempTitle");
|
|
|
+ String afterEmail = StringUtils.substringAfter(fromEmail, "@");
|
|
|
+ if ("163.com".equals(afterEmail)) {
|
|
|
+ emailUtil.sendMessage(fromEmail, emailPassword, "smtp.163.com", merchant.getEmail(), cerateTempTitle, cerateTemp);
|
|
|
+ } else if ("qq.com".equals(afterEmail)) {
|
|
|
+ emailUtil.sendMessage(fromEmail, emailPassword, "smtp.qq.com", merchant.getEmail(), cerateTempTitle, cerateTemp);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
return response;
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 查询支付结果
|
|
|
*
|
|
@@ -555,6 +753,7 @@ public class PayServiceImpl implements PayService {
|
|
|
/**
|
|
|
* 支付成功后置处理
|
|
|
* 经验逻辑确定后,可在处理中加入经验处理
|
|
|
+ *
|
|
|
* @param orderNo 订单编号
|
|
|
*/
|
|
|
@Override
|
|
@@ -608,6 +807,7 @@ public class PayServiceImpl implements PayService {
|
|
|
|
|
|
/**
|
|
|
* 支付成功后置处理(临时)
|
|
|
+ *
|
|
|
* @param orderNo 订单编号
|
|
|
*/
|
|
|
@Override
|
|
@@ -721,9 +921,10 @@ public class PayServiceImpl implements PayService {
|
|
|
|
|
|
/**
|
|
|
* 单商户订单处理
|
|
|
- * @param order 主订单
|
|
|
+ *
|
|
|
+ * @param order 主订单
|
|
|
* @param merchantOrder 商户订单
|
|
|
- * @param user 用户
|
|
|
+ * @param user 用户
|
|
|
*/
|
|
|
private Boolean oneMerchantOrderProcessing(Order order, MerchantOrder merchantOrder, User user) {
|
|
|
List<UserIntegralRecord> integralList = CollUtil.newArrayList();
|
|
@@ -811,9 +1012,10 @@ public class PayServiceImpl implements PayService {
|
|
|
|
|
|
/**
|
|
|
* 多商户订单处理
|
|
|
- * @param order 主订单
|
|
|
+ *
|
|
|
+ * @param order 主订单
|
|
|
* @param merchantOrderList 商户订单列表
|
|
|
- * @param user 用户
|
|
|
+ * @param user 用户
|
|
|
*/
|
|
|
private Boolean manyMerchantOrderProcessing(Order order, List<MerchantOrder> merchantOrderList, User user) {
|
|
|
List<UserIntegralRecord> integralList = CollUtil.newArrayList();
|
|
@@ -949,7 +1151,7 @@ public class PayServiceImpl implements PayService {
|
|
|
if (order.getPayChannel().equals(PayConstants.PAY_CHANNEL_WECHAT_PUBLIC) && payNotification.getIsWechat().equals(1) && user.getIsWechatPublic()) {
|
|
|
userToken = userTokenService.getTokenByUserId(user.getId(), UserConstants.USER_TOKEN_TYPE_WECHAT);
|
|
|
if (ObjectUtil.isNull(userToken)) {
|
|
|
- return ;
|
|
|
+ return;
|
|
|
}
|
|
|
// 发送微信模板消息
|
|
|
/**
|
|
@@ -969,13 +1171,13 @@ public class PayServiceImpl implements PayService {
|
|
|
temMap.put("keyword5", order.getPayTime().toString());
|
|
|
temMap.put(Constants.WE_CHAT_TEMP_KEY_END, "欢迎下次再来!");
|
|
|
templateMessageService.pushTemplateMessage(payNotification.getWechatId(), temMap, userToken.getToken());
|
|
|
- return ;
|
|
|
+ return;
|
|
|
}
|
|
|
if (order.getPayChannel().equals(PayConstants.PAY_CHANNEL_WECHAT_MINI) && payNotification.getIsRoutine().equals(1)) {
|
|
|
// 小程序发送订阅消息
|
|
|
userToken = userTokenService.getTokenByUserId(user.getId(), UserConstants.USER_TOKEN_TYPE_ROUTINE);
|
|
|
if (ObjectUtil.isNull(userToken)) {
|
|
|
- return ;
|
|
|
+ return;
|
|
|
}
|
|
|
// 组装数据
|
|
|
// temMap.put("character_string1", storeOrder.getOrderId());
|
|
@@ -991,7 +1193,8 @@ public class PayServiceImpl implements PayService {
|
|
|
|
|
|
/**
|
|
|
* 佣金处理
|
|
|
- * @param merchantOrder 商户订单部分
|
|
|
+ *
|
|
|
+ * @param merchantOrder 商户订单部分
|
|
|
* @param orderDetailList 订单详情列表
|
|
|
* @return 佣金记录列表
|
|
|
*/
|
|
@@ -1002,7 +1205,7 @@ public class PayServiceImpl implements PayService {
|
|
|
}
|
|
|
// 检测商城是否开启分销功能
|
|
|
String isOpen = systemConfigService.getValueByKey(SysConfigConstants.RETAIL_STORE_SWITCH);
|
|
|
- if(StrUtil.isBlank(isOpen) || isOpen.equals("0")){
|
|
|
+ if (StrUtil.isBlank(isOpen) || isOpen.equals("0")) {
|
|
|
return CollUtil.newArrayList();
|
|
|
}
|
|
|
long count = orderDetailList.stream().filter(e -> e.getSubBrokerageType() > 0).count();
|
|
@@ -1012,7 +1215,7 @@ public class PayServiceImpl implements PayService {
|
|
|
// 查找订单所属人信息
|
|
|
User user = userService.getById(merchantOrder.getUid());
|
|
|
// 当前用户不存在 没有上级 或者 当用用户上级时自己 直接返回
|
|
|
- if(ObjectUtil.isNull(user.getSpreadUid()) || user.getSpreadUid() < 1 || user.getSpreadUid().equals(merchantOrder.getUid())){
|
|
|
+ if (ObjectUtil.isNull(user.getSpreadUid()) || user.getSpreadUid() < 1 || user.getSpreadUid().equals(merchantOrder.getUid())) {
|
|
|
return CollUtil.newArrayList();
|
|
|
}
|
|
|
// 获取参与分佣的人(两级)
|
|
@@ -1089,15 +1292,16 @@ public class PayServiceImpl implements PayService {
|
|
|
|
|
|
/**
|
|
|
* 佣金处理
|
|
|
- * @param order 订单
|
|
|
+ *
|
|
|
+ * @param order 订单
|
|
|
* @param merchantOrderList 商户订单部分
|
|
|
- * @param orderDetailList 订单详情列表
|
|
|
+ * @param orderDetailList 订单详情列表
|
|
|
* @return 佣金记录列表
|
|
|
*/
|
|
|
private List<UserBrokerageRecord> assignCommission(Order order, List<MerchantOrder> merchantOrderList, List<OrderDetail> orderDetailList) {
|
|
|
// 检测商城是否开启分销功能
|
|
|
String isOpen = systemConfigService.getValueByKey(SysConfigConstants.RETAIL_STORE_SWITCH);
|
|
|
- if(StrUtil.isBlank(isOpen) || isOpen.equals("0")){
|
|
|
+ if (StrUtil.isBlank(isOpen) || isOpen.equals("0")) {
|
|
|
return CollUtil.newArrayList();
|
|
|
}
|
|
|
// 营销产品不参与
|
|
@@ -1111,7 +1315,7 @@ public class PayServiceImpl implements PayService {
|
|
|
// 查找订单所属人信息
|
|
|
User user = userService.getById(order.getUid());
|
|
|
// 当前用户不存在 没有上级 或者 当用用户上级时自己 直接返回
|
|
|
- if(ObjectUtil.isNull(user.getSpreadUid()) || user.getSpreadUid() < 1 || user.getSpreadUid().equals(order.getUid())){
|
|
|
+ if (ObjectUtil.isNull(user.getSpreadUid()) || user.getSpreadUid() < 1 || user.getSpreadUid().equals(order.getUid())) {
|
|
|
return CollUtil.newArrayList();
|
|
|
}
|
|
|
// 获取参与分佣的人(两级)
|
|
@@ -1192,6 +1396,7 @@ public class PayServiceImpl implements PayService {
|
|
|
|
|
|
/**
|
|
|
* 获取参与分佣人员(两级)
|
|
|
+ *
|
|
|
* @param spreadUid 一级分佣人Uid
|
|
|
* @return List<MyRecord>
|
|
|
*/
|
|
@@ -1291,6 +1496,7 @@ public class PayServiceImpl implements PayService {
|
|
|
|
|
|
/**
|
|
|
* 初始化订单分帐表
|
|
|
+ *
|
|
|
* @param merchantOrder 商户部分订单
|
|
|
* @return 分账记录
|
|
|
*/
|
|
@@ -1316,8 +1522,9 @@ public class PayServiceImpl implements PayService {
|
|
|
|
|
|
/**
|
|
|
* 初始化订单支付商户账单表
|
|
|
+ *
|
|
|
* @param merchantOrder 商户订单部分
|
|
|
- * @param merchantFee 商户分账金额
|
|
|
+ * @param merchantFee 商户分账金额
|
|
|
*/
|
|
|
private MerchantBill initPayMerchantBill(MerchantOrder merchantOrder, BigDecimal merchantFee) {
|
|
|
MerchantBill merchantBill = new MerchantBill();
|
|
@@ -1333,8 +1540,9 @@ public class PayServiceImpl implements PayService {
|
|
|
|
|
|
/**
|
|
|
* 初始化订单支付平台账单表
|
|
|
- * @param order 订单
|
|
|
- * @param merchantOrder 商户订单部分
|
|
|
+ *
|
|
|
+ * @param order 订单
|
|
|
+ * @param merchantOrder 商户订单部分
|
|
|
* @param orderProfitSharing 分账数据
|
|
|
* @return List
|
|
|
*/
|
|
@@ -1659,7 +1867,7 @@ public class PayServiceImpl implements PayService {
|
|
|
/**
|
|
|
* 信用额度支付
|
|
|
*/
|
|
|
- private Boolean XYEDPay(Order order, User user,UserEnterprise userEnterprise) {
|
|
|
+ private Boolean XYEDPay(Order order, User user, UserEnterprise userEnterprise) {
|
|
|
// 信用额度扣除
|
|
|
Boolean execute = transactionTemplate.execute(e -> {
|
|
|
Boolean update = Boolean.TRUE;
|
|
@@ -1671,15 +1879,15 @@ public class PayServiceImpl implements PayService {
|
|
|
// 这里只扣除金额,账单记录在task中处理
|
|
|
if (order.getPayPrice().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
// update = userService.updateNowMoney(order.getUid(), order.getPayPrice(), Constants.OPERATION_TYPE_SUBTRACT);
|
|
|
- BigDecimal subtract = userEnterprise.getAvailableLineOfCredit().subtract( order.getPayPrice() ); //可用额度 减去 订单金额等于现在的可用额度
|
|
|
+ BigDecimal subtract = userEnterprise.getAvailableLineOfCredit().subtract(order.getPayPrice()); //可用额度 减去 订单金额等于现在的可用额度
|
|
|
|
|
|
- BigDecimal subtract2 = userEnterprise.getUsedLineOfCredit().add( order.getPayPrice() );//已用额度 加上 订单金额等于现在的 已用信用额度
|
|
|
+ BigDecimal subtract2 = userEnterprise.getUsedLineOfCredit().add(order.getPayPrice());//已用额度 加上 订单金额等于现在的 已用信用额度
|
|
|
|
|
|
- UserEnterprise userEnterprise1 =new UserEnterprise();
|
|
|
- userEnterprise1.setId( userEnterprise.getId() );
|
|
|
- userEnterprise1.setAvailableLineOfCredit( subtract );
|
|
|
- userEnterprise1.setUsedLineOfCredit( subtract2 );
|
|
|
- update = userEnterpriseService.updateById( userEnterprise1 );
|
|
|
+ UserEnterprise userEnterprise1 = new UserEnterprise();
|
|
|
+ userEnterprise1.setId(userEnterprise.getId());
|
|
|
+ userEnterprise1.setAvailableLineOfCredit(subtract);
|
|
|
+ userEnterprise1.setUsedLineOfCredit(subtract2);
|
|
|
+ update = userEnterpriseService.updateById(userEnterprise1);
|
|
|
if (!update) {
|
|
|
logger.error("信用额度支付,扣除信用额度支付失败,orderNo = {}", order.getOrderNo());
|
|
|
e.setRollbackOnly();
|
|
@@ -1852,7 +2060,7 @@ public class PayServiceImpl implements PayService {
|
|
|
List<Integer> proIdList = orderDetailList.stream().map(OrderDetail::getProductId).distinct().collect(Collectors.toList());
|
|
|
for (Integer proId : proIdList) {
|
|
|
List<ProductCoupon> couponsForGiveUser = productCouponService.getListByProductId(proId);
|
|
|
- for (int i = 0; i < couponsForGiveUser.size();) {
|
|
|
+ for (int i = 0; i < couponsForGiveUser.size(); ) {
|
|
|
ProductCoupon productCoupon = couponsForGiveUser.get(i);
|
|
|
MyRecord record = couponUserService.paySuccessGiveAway(productCoupon.getCouponId(), order.getUid());
|
|
|
if (record.getStr("status").equals("fail")) {
|