支付模块剥离;报销调整
This commit is contained in:
parent
5dd83e3997
commit
d3ca17d681
@ -1,7 +1,6 @@
|
|||||||
package com.cpop.core.base.enums;
|
package com.cpop.core.base.enums;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单来源
|
* 订单来源
|
||||||
@ -12,7 +11,12 @@ public enum OrderSource {
|
|||||||
/**
|
/**
|
||||||
* 商城
|
* 商城
|
||||||
*/
|
*/
|
||||||
MALL("Mall",0.002);
|
MALL("Mall",0.002),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 微信支付
|
||||||
|
*/
|
||||||
|
EASY_LEARN("easyLearn",0.002);
|
||||||
|
|
||||||
OrderSource(String name, Double rate) {
|
OrderSource(String name, Double rate) {
|
||||||
this.rate = rate;
|
this.rate = rate;
|
||||||
|
|||||||
@ -18,10 +18,15 @@
|
|||||||
<groupId>com.cpop</groupId>
|
<groupId>com.cpop</groupId>
|
||||||
<artifactId>Cpop-Core</artifactId>
|
<artifactId>Cpop-Core</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--微信支付-->
|
<!--系统包-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.binarywang</groupId>
|
<groupId>com.cpop</groupId>
|
||||||
<artifactId>weixin-java-pay</artifactId>
|
<artifactId>Cpop-System</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!--支付-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.cpop</groupId>
|
||||||
|
<artifactId>Cpop-Pay</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,68 @@
|
|||||||
|
package com.cpop.jambox.business.bo;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DB
|
||||||
|
* @version 1.0.0
|
||||||
|
* @since 2023-12-21 17:15
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@ApiModel(value = "OncePlaceOrderBo对象", description = "一次性支付参数")
|
||||||
|
public class OncePlaceOrderBo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 品牌id
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("品牌id")
|
||||||
|
private String brandCloudId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校区id
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("校区id")
|
||||||
|
private String storeCloudId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户名
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("客户名")
|
||||||
|
private String customerName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户电话
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("客户电话")
|
||||||
|
private String customerPhone;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品/课卡id
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("产品/课卡id")
|
||||||
|
private String productId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 总金额
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("总金额")
|
||||||
|
private BigDecimal totalAmount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 总支付金额
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("总支付金额")
|
||||||
|
private BigDecimal totalPayAmount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 员工id
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("员工id")
|
||||||
|
private String staffId;
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package com.cpop.jambox.business.controller;
|
package com.cpop.jambox.business.controller.backstage;
|
||||||
|
|
||||||
import com.mybatisflex.core.paginate.Page;
|
import com.mybatisflex.core.paginate.Page;
|
||||||
import com.cpop.core.base.R;
|
import com.cpop.core.base.R;
|
||||||
@ -1,27 +1,23 @@
|
|||||||
package com.cpop.jambox.business.controller;
|
package com.cpop.jambox.business.controller.backstage;
|
||||||
|
|
||||||
import com.alibaba.excel.EasyExcel;
|
import com.alibaba.excel.EasyExcel;
|
||||||
import com.cpop.core.base.R;
|
import com.cpop.core.base.R;
|
||||||
import com.cpop.jambox.business.bo.EasyLearnPageBo;
|
import com.cpop.jambox.business.bo.EasyLearnPageBo;
|
||||||
|
import com.cpop.jambox.business.bo.OncePlaceOrderBo;
|
||||||
import com.cpop.jambox.business.dto.EasyLearnPageDto;
|
import com.cpop.jambox.business.dto.EasyLearnPageDto;
|
||||||
import com.cpop.jambox.business.service.EasyLearnOrderService;
|
import com.cpop.jambox.business.service.EasyLearnOrderService;
|
||||||
import com.cpop.jambox.business.vo.EasyLearnPageVo;
|
import com.cpop.jambox.business.vo.EasyLearnPageVo;
|
||||||
import com.mybatisflex.core.paginate.Page;
|
import com.mybatisflex.core.paginate.Page;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import io.swagger.annotations.ApiParam;
|
import io.swagger.annotations.ApiParam;
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 果酱-放心学订单表 控制层。
|
* 果酱-放心学订单表 控制层。
|
||||||
@ -89,4 +85,17 @@ public class EasyLearnController {
|
|||||||
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
|
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
|
||||||
EasyExcel.write(response.getOutputStream(), EasyLearnPageDto.class).sheet("记录").doWrite(easyLearnOrderService.getEasyLearnXml(bo));
|
EasyExcel.write(response.getOutputStream(), EasyLearnPageDto.class).sheet("记录").doWrite(easyLearnOrderService.getEasyLearnXml(bo));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 一次性支付下单
|
||||||
|
* @author DB
|
||||||
|
* @since 2023/10/23 12:15
|
||||||
|
* @param bo 下单请求对象
|
||||||
|
* @return com.cpop.core.base.R<java.lang.Void>
|
||||||
|
*/
|
||||||
|
@PostMapping("/oncePlaceOrderBo")
|
||||||
|
@ApiOperation("一次性支付下单")
|
||||||
|
public R<Object> oncePlaceOrderBo(@RequestBody @Validated @ApiParam("一次性支付") OncePlaceOrderBo bo) {
|
||||||
|
return R.ok(easyLearnOrderService.oncePlaceOrderBo(bo));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -0,0 +1,50 @@
|
|||||||
|
package com.cpop.jambox.business.controller.callback;
|
||||||
|
|
||||||
|
import com.cpop.jambox.business.service.EasyLearnOrderService;
|
||||||
|
import com.github.binarywang.wxpay.bean.notify.WxPayNotifyResponse;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DB
|
||||||
|
* @version 1.0.0
|
||||||
|
* @since 2023-12-21 16:06
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@Api(tags = "果酱-放心学回调接口")
|
||||||
|
@RequestMapping("/easyLearn/callBack")
|
||||||
|
public class EasyLearnCallBackController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EasyLearnOrderService easyLearnOrderService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 微信支付订单通知
|
||||||
|
* @author DB
|
||||||
|
* @since 2023/12/21
|
||||||
|
* @param xmlData 数据
|
||||||
|
* @return java.lang.String
|
||||||
|
*/
|
||||||
|
@PostMapping("/notify/order")
|
||||||
|
public String parseOrderNotifyResult(@RequestBody String xmlData){
|
||||||
|
easyLearnOrderService.wxPayNotifyOrder(xmlData);
|
||||||
|
return WxPayNotifyResponse.success("成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 微信支付分账通知
|
||||||
|
* @author DB
|
||||||
|
* @since 2023/10/27 16:04
|
||||||
|
* @param xmlData 数据
|
||||||
|
* @return java.lang.String
|
||||||
|
*/
|
||||||
|
@PostMapping("/notify/profitSharing")
|
||||||
|
public String parseProfitSharingNotifyResult(@RequestBody String xmlData){
|
||||||
|
easyLearnOrderService.parseProfitSharingNotifyResult(xmlData);
|
||||||
|
return WxPayNotifyResponse.success("成功");
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -6,14 +6,12 @@ import com.cpop.core.base.entity.BaseUpdateListener;
|
|||||||
import com.mybatisflex.annotation.Column;
|
import com.mybatisflex.annotation.Column;
|
||||||
import com.mybatisflex.annotation.Id;
|
import com.mybatisflex.annotation.Id;
|
||||||
import com.mybatisflex.annotation.Table;
|
import com.mybatisflex.annotation.Table;
|
||||||
import java.io.Serializable;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 果酱-放心学订单表 实体类。
|
* 果酱-放心学订单表 实体类。
|
||||||
*
|
*
|
||||||
@ -85,10 +83,6 @@ public class EasyLearnOrder extends BaseEntity implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private Integer orderType;
|
private Integer orderType;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 逻辑删除(0否1是)
|
* 逻辑删除(0否1是)
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,14 +1,13 @@
|
|||||||
package com.cpop.jambox.business.service;
|
package com.cpop.jambox.business.service;
|
||||||
|
|
||||||
import com.cpop.jambox.business.bo.EasyLearnPageBo;
|
import com.cpop.jambox.business.bo.EasyLearnPageBo;
|
||||||
|
import com.cpop.jambox.business.bo.OncePlaceOrderBo;
|
||||||
import com.cpop.jambox.business.dto.EasyLearnPageDto;
|
import com.cpop.jambox.business.dto.EasyLearnPageDto;
|
||||||
import com.cpop.jambox.business.entity.EasyLearnOrder;
|
import com.cpop.jambox.business.entity.EasyLearnOrder;
|
||||||
import com.cpop.jambox.business.vo.EasyLearnPageVo;
|
import com.cpop.jambox.business.vo.EasyLearnPageVo;
|
||||||
import com.mybatisflex.core.paginate.Page;
|
import com.mybatisflex.core.paginate.Page;
|
||||||
import com.mybatisflex.core.service.IService;
|
import com.mybatisflex.core.service.IService;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -36,4 +35,28 @@ public interface EasyLearnOrderService extends IService<EasyLearnOrder> {
|
|||||||
* @return List<EasyLearnPageDto>
|
* @return List<EasyLearnPageDto>
|
||||||
*/
|
*/
|
||||||
List<EasyLearnPageDto> getEasyLearnXml(EasyLearnPageBo bo);
|
List<EasyLearnPageDto> getEasyLearnXml(EasyLearnPageBo bo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 微信支付订单通知
|
||||||
|
* @author DB
|
||||||
|
* @since 2023/12/21
|
||||||
|
* @param xmlData 数据
|
||||||
|
*/
|
||||||
|
void wxPayNotifyOrder(String xmlData);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 微信支付分账通知
|
||||||
|
* @author DB
|
||||||
|
* @since 2023/12/21
|
||||||
|
* @param xmlData 数据
|
||||||
|
*/
|
||||||
|
void parseProfitSharingNotifyResult(String xmlData);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 一次性支付下单
|
||||||
|
* @author DB
|
||||||
|
* @since 2023/10/23 12:15
|
||||||
|
* @param bo 下单请求对象
|
||||||
|
*/
|
||||||
|
Object oncePlaceOrderBo(OncePlaceOrderBo bo);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,34 +1,56 @@
|
|||||||
package com.cpop.jambox.business.service.impl;
|
package com.cpop.jambox.business.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.cpop.common.utils.StringUtils;
|
import com.cpop.common.utils.StringUtils;
|
||||||
|
import com.cpop.common.utils.bean.BeanUtils;
|
||||||
|
import com.cpop.common.utils.ip.IpUtils;
|
||||||
import com.cpop.core.base.entity.PageDomain;
|
import com.cpop.core.base.entity.PageDomain;
|
||||||
|
import com.cpop.core.base.enums.OrderSource;
|
||||||
|
import com.cpop.core.base.exception.ServiceException;
|
||||||
|
import com.cpop.core.service.RedisService;
|
||||||
|
import com.cpop.core.utils.SecurityUtils;
|
||||||
|
import com.cpop.core.utils.SpringUtils;
|
||||||
import com.cpop.core.utils.sql.SqlUtils;
|
import com.cpop.core.utils.sql.SqlUtils;
|
||||||
import com.cpop.jambox.business.bo.EasyLearnPageBo;
|
import com.cpop.jambox.business.bo.EasyLearnPageBo;
|
||||||
|
import com.cpop.jambox.business.bo.OncePlaceOrderBo;
|
||||||
import com.cpop.jambox.business.dto.EasyLearnPageDto;
|
import com.cpop.jambox.business.dto.EasyLearnPageDto;
|
||||||
|
import com.cpop.jambox.business.entity.BrandExtend;
|
||||||
import com.cpop.jambox.business.entity.EasyLearnOrder;
|
import com.cpop.jambox.business.entity.EasyLearnOrder;
|
||||||
|
import com.cpop.jambox.business.entity.StoreExtend;
|
||||||
import com.cpop.jambox.business.mapper.EasyLearnOrderMapper;
|
import com.cpop.jambox.business.mapper.EasyLearnOrderMapper;
|
||||||
|
import com.cpop.jambox.business.service.BrandExtendService;
|
||||||
import com.cpop.jambox.business.service.EasyLearnOrderService;
|
import com.cpop.jambox.business.service.EasyLearnOrderService;
|
||||||
|
import com.cpop.jambox.business.service.StoreExtendService;
|
||||||
import com.cpop.jambox.business.vo.EasyLearnPageVo;
|
import com.cpop.jambox.business.vo.EasyLearnPageVo;
|
||||||
|
import com.cpop.jambox.framework.constant.JamboxRedisConstant;
|
||||||
|
import com.cpop.pay.framewok.handler.wxPay.WxPayHandler;
|
||||||
|
import com.cpop.pay.framewok.task.WxPayAsyncTask;
|
||||||
|
import com.cpop.system.business.service.ProfitSharingService;
|
||||||
|
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
|
||||||
|
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
|
||||||
|
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||||
|
import com.github.binarywang.wxpay.service.WxPayService;
|
||||||
import com.mybatisflex.core.FlexGlobalConfig;
|
import com.mybatisflex.core.FlexGlobalConfig;
|
||||||
import com.mybatisflex.core.datasource.DataSourceKey;
|
import com.mybatisflex.core.datasource.DataSourceKey;
|
||||||
import com.mybatisflex.core.datasource.FlexDataSource;
|
import com.mybatisflex.core.datasource.FlexDataSource;
|
||||||
import com.mybatisflex.core.paginate.Page;
|
import com.mybatisflex.core.paginate.Page;
|
||||||
import com.mybatisflex.core.query.QueryWrapper;
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
import com.mybatisflex.core.row.Db;
|
import com.mybatisflex.core.row.Db;
|
||||||
import com.mybatisflex.core.row.DbChain;
|
|
||||||
import com.mybatisflex.core.row.Row;
|
import com.mybatisflex.core.row.Row;
|
||||||
import com.mybatisflex.core.row.RowUtil;
|
import com.mybatisflex.core.row.RowUtil;
|
||||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||||
import com.zaxxer.hikari.HikariDataSource;
|
import com.zaxxer.hikari.HikariDataSource;
|
||||||
import org.apache.poi.util.StringUtil;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.locks.Lock;
|
||||||
|
|
||||||
import static com.mybatisflex.core.query.QueryMethods.column;
|
import static com.cpop.jambox.business.entity.table.BrandExtendTableDef.BRAND_EXTEND;
|
||||||
import static com.mybatisflex.core.query.QueryMethods.distinct;
|
import static com.cpop.jambox.business.entity.table.EasyLearnOrderTableDef.EASY_LEARN_ORDER;
|
||||||
|
import static com.cpop.jambox.business.entity.table.StoreExtendTableDef.STORE_EXTEND;
|
||||||
|
import static com.cpop.system.business.entity.table.ProfitSharingTableDef.PROFIT_SHARING;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 果酱-放心学订单表 服务层实现。
|
* 果酱-放心学订单表 服务层实现。
|
||||||
@ -39,6 +61,12 @@ import static com.mybatisflex.core.query.QueryMethods.distinct;
|
|||||||
@Service("easyLearnOrderService")
|
@Service("easyLearnOrderService")
|
||||||
public class EasyLearnOrderServiceImpl extends ServiceImpl<EasyLearnOrderMapper, EasyLearnOrder> implements EasyLearnOrderService {
|
public class EasyLearnOrderServiceImpl extends ServiceImpl<EasyLearnOrderMapper, EasyLearnOrder> implements EasyLearnOrderService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private WxPayHandler wxPayHandler;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private WxPayAsyncTask wxPayAsyncTask;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取放心学分页
|
* 获取放心学分页
|
||||||
*
|
*
|
||||||
@ -312,4 +340,107 @@ public class EasyLearnOrderServiceImpl extends ServiceImpl<EasyLearnOrderMapper,
|
|||||||
FlexDataSource flexDataSource = FlexGlobalConfig.getDefaultConfig().getDataSource();
|
FlexDataSource flexDataSource = FlexGlobalConfig.getDefaultConfig().getDataSource();
|
||||||
flexDataSource.removeDatasource("jamboxProd");
|
flexDataSource.removeDatasource("jamboxProd");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 微信支付订单通知
|
||||||
|
* @author DB
|
||||||
|
* @since 2023/12/21
|
||||||
|
* @param xmlData 数据
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void wxPayNotifyOrder(String xmlData) {
|
||||||
|
try {
|
||||||
|
WxPayService wxPayService = wxPayHandler.getWxPayService();
|
||||||
|
WxPayOrderNotifyResult notifyResult = wxPayService.parseOrderNotifyResult(xmlData);
|
||||||
|
if(!StringUtils.equals(notifyResult.getResultCode(),"SUCCESS")){
|
||||||
|
throw new ServiceException(notifyResult.getReturnMsg());
|
||||||
|
}
|
||||||
|
String orderId = notifyResult.getOutTradeNo();
|
||||||
|
//更新订单
|
||||||
|
this.updateChain().set(EASY_LEARN_ORDER.OUT_ORDER_NO, notifyResult.getTransactionId()).where(EASY_LEARN_ORDER.ID.eq(orderId)).update();
|
||||||
|
//需要分账
|
||||||
|
if (notifyResult.getTotalFee() >= Math.ceil(1 / OrderSource.MALL.getRate())) {
|
||||||
|
wxPayAsyncTask.asyncWxPayProfitSharing(orderId, notifyResult, wxPayService, OrderSource.EASY_LEARN);
|
||||||
|
}
|
||||||
|
} catch (WxPayException e) {
|
||||||
|
throw new ServiceException(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 微信支付分账通知
|
||||||
|
* @author DB
|
||||||
|
* @since 2023/12/21
|
||||||
|
* @param xmlData 数据
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void parseProfitSharingNotifyResult(String xmlData) {
|
||||||
|
WxPayService wxPayService = wxPayHandler.getWxPayService();
|
||||||
|
try {
|
||||||
|
WxPayOrderNotifyResult notifyResult = wxPayService.parseOrderNotifyResult(xmlData);
|
||||||
|
//更新分账订单
|
||||||
|
SpringUtils.getBean(ProfitSharingService.class).updateChain().set(PROFIT_SHARING.OUT_PROFIT_SHARING_ID, notifyResult.getTransactionId())
|
||||||
|
.set(PROFIT_SHARING.AMOUNT, notifyResult.getTotalFee())
|
||||||
|
.set(PROFIT_SHARING.PROFIT_SHARING_STATUS, 1)
|
||||||
|
//当前分账账户
|
||||||
|
.set(PROFIT_SHARING.PAY_ACCOUNT, wxPayService.getConfig().getSubMchId())
|
||||||
|
.where(PROFIT_SHARING.ID.eq(notifyResult.getOutTradeNo()))
|
||||||
|
.update();
|
||||||
|
} catch (WxPayException e) {
|
||||||
|
throw new ServiceException(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 一次性支付下单
|
||||||
|
* @author DB
|
||||||
|
* @since 2023/10/23 12:15
|
||||||
|
* @param bo 下单请求对象
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Object oncePlaceOrderBo(OncePlaceOrderBo bo) {
|
||||||
|
//获取当前下单用户信息
|
||||||
|
JSONObject loginUserInfo = SecurityUtils.getInstance().getLoginUserInfo();
|
||||||
|
//分布式锁进行幂等处理
|
||||||
|
RedisService redisService = SpringUtils.getBean(RedisService.class);
|
||||||
|
//分布式锁进行幂等处理
|
||||||
|
Lock userIdLock = redisService.distributedLock(JamboxRedisConstant.ONCE_PAY_LOCK_USER_PAY + bo.getCustomerPhone());
|
||||||
|
if (userIdLock.tryLock()){
|
||||||
|
try {
|
||||||
|
//获取品牌
|
||||||
|
BrandExtend brandExtend = SpringUtils.getBean(BrandExtendService.class).queryChain().where(BRAND_EXTEND.BRAND_CLOUD_ID.eq(bo.getBrandCloudId())).one();
|
||||||
|
//获取校区
|
||||||
|
StoreExtend storeExtend = SpringUtils.getBean(StoreExtendService.class).queryChain().where(STORE_EXTEND.STORE_CLOUD_ID.eq(bo.getStoreCloudId())).one();
|
||||||
|
//创建订单
|
||||||
|
EasyLearnOrder easyLearnOrder = BeanUtils.mapToClass(bo, EasyLearnOrder.class);
|
||||||
|
easyLearnOrder.setOrderType(2).setBrandId(brandExtend.getBrandId()).setStoreId(storeExtend.getStoreId());
|
||||||
|
this.save(easyLearnOrder);
|
||||||
|
//获取商户信息
|
||||||
|
WxPayService wxPayService = wxPayHandler.getWxPayService(null, null, null);
|
||||||
|
WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
|
||||||
|
//需要分账
|
||||||
|
if (bo.getTotalAmount().scaleByPowerOfTen(2).intValue() >= Math.ceil(1 / OrderSource.EASY_LEARN.getRate())) {
|
||||||
|
//需要分账
|
||||||
|
orderRequest.setProfitSharing("Y");
|
||||||
|
}
|
||||||
|
orderRequest.setSpbillCreateIp(IpUtils.getHostIp())
|
||||||
|
.setOpenid(loginUserInfo.getString("openId"))
|
||||||
|
//商品描述
|
||||||
|
.setBody("一次性支付")
|
||||||
|
.setOutTradeNo(easyLearnOrder.getId())
|
||||||
|
//元转分
|
||||||
|
.setTotalFee(easyLearnOrder.getTotalAmount().scaleByPowerOfTen(2).intValue())
|
||||||
|
.setTradeType("JSAPI");
|
||||||
|
return wxPayService.createOrder(orderRequest);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new ServiceException(e.getMessage());
|
||||||
|
} finally {
|
||||||
|
//释放锁
|
||||||
|
userIdLock.unlock();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//获取锁失败,直接返回空
|
||||||
|
throw new ServiceException("请勿重复支付");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,14 @@
|
|||||||
|
package com.cpop.jambox.framework.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DB
|
||||||
|
* @version 1.0.0
|
||||||
|
* @since 2023-12-21 17:29
|
||||||
|
*/
|
||||||
|
public interface JamboxRedisConstant {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 一次性支付
|
||||||
|
*/
|
||||||
|
String ONCE_PAY_LOCK_USER_PAY = "jambox:oncePayLock:userPay:";
|
||||||
|
}
|
||||||
@ -3,21 +3,15 @@ package com.cpop.mall.web;
|
|||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.cpop.core.utils.SpringUtils;
|
import com.cpop.core.utils.SpringUtils;
|
||||||
import com.cpop.core.utils.uuid.IdUtils;
|
import com.cpop.core.utils.uuid.IdUtils;
|
||||||
import com.cpop.mall.business.entity.Order;
|
import com.cpop.pay.framewok.config.wxPay.WxPayProperties;
|
||||||
import com.cpop.mall.business.service.OrderService;
|
|
||||||
import com.cpop.mall.framework.config.wxPay.WxPayProperties;
|
|
||||||
import com.cpop.system.business.entity.Brand;
|
import com.cpop.system.business.entity.Brand;
|
||||||
import com.cpop.system.business.entity.ProfitSharing;
|
|
||||||
import com.cpop.system.business.service.BrandService;
|
import com.cpop.system.business.service.BrandService;
|
||||||
import com.cpop.system.business.service.ProfitSharingService;
|
|
||||||
import com.github.binarywang.wxpay.bean.payscore.WxPartnerPayScoreResult;
|
|
||||||
import com.github.binarywang.wxpay.bean.profitsharing.ProfitSharingFinishRequest;
|
import com.github.binarywang.wxpay.bean.profitsharing.ProfitSharingFinishRequest;
|
||||||
import com.github.binarywang.wxpay.bean.profitsharing.ProfitSharingQueryRequest;
|
import com.github.binarywang.wxpay.bean.profitsharing.ProfitSharingQueryRequest;
|
||||||
import com.github.binarywang.wxpay.bean.profitsharing.ProfitSharingQueryResult;
|
import com.github.binarywang.wxpay.bean.profitsharing.ProfitSharingQueryResult;
|
||||||
import com.github.binarywang.wxpay.bean.profitsharing.ProfitSharingReceiverRequest;
|
import com.github.binarywang.wxpay.bean.profitsharing.ProfitSharingReceiverRequest;
|
||||||
import com.github.binarywang.wxpay.bean.profitsharingV3.ProfitSharingResult;
|
import com.github.binarywang.wxpay.bean.profitsharingV3.ProfitSharingResult;
|
||||||
import com.github.binarywang.wxpay.bean.profitsharingV3.ProfitSharingReturnRequest;
|
import com.github.binarywang.wxpay.bean.profitsharingV3.ProfitSharingReturnRequest;
|
||||||
import com.github.binarywang.wxpay.bean.profitsharingV3.ProfitSharingUnfreezeRequest;
|
|
||||||
import com.github.binarywang.wxpay.bean.request.WxPayRefundV3Request;
|
import com.github.binarywang.wxpay.bean.request.WxPayRefundV3Request;
|
||||||
import com.github.binarywang.wxpay.bean.result.WxPayOrderQueryResult;
|
import com.github.binarywang.wxpay.bean.result.WxPayOrderQueryResult;
|
||||||
import com.github.binarywang.wxpay.bean.result.WxPayRefundV3Result;
|
import com.github.binarywang.wxpay.bean.result.WxPayRefundV3Result;
|
||||||
|
|||||||
@ -7,7 +7,6 @@ import com.cpop.core.base.exception.ServiceException;
|
|||||||
import com.cpop.core.utils.SecurityUtils;
|
import com.cpop.core.utils.SecurityUtils;
|
||||||
import com.cpop.core.utils.SpringUtils;
|
import com.cpop.core.utils.SpringUtils;
|
||||||
import com.cpop.core.utils.sql.SqlUtils;
|
import com.cpop.core.utils.sql.SqlUtils;
|
||||||
import com.cpop.core.utils.uuid.IdUtils;
|
|
||||||
import com.cpop.mall.business.bo.OrderRefundPageBo;
|
import com.cpop.mall.business.bo.OrderRefundPageBo;
|
||||||
import com.cpop.mall.business.bo.OrderRejectRefundBo;
|
import com.cpop.mall.business.bo.OrderRejectRefundBo;
|
||||||
import com.cpop.mall.business.dto.UserPointDto;
|
import com.cpop.mall.business.dto.UserPointDto;
|
||||||
@ -17,17 +16,13 @@ import com.cpop.mall.business.mapper.OrderRefundMapper;
|
|||||||
import com.cpop.mall.business.service.OrderRefundService;
|
import com.cpop.mall.business.service.OrderRefundService;
|
||||||
import com.cpop.mall.business.service.OrderService;
|
import com.cpop.mall.business.service.OrderService;
|
||||||
import com.cpop.mall.business.vo.OrderRefundPageVo;
|
import com.cpop.mall.business.vo.OrderRefundPageVo;
|
||||||
import com.cpop.mall.framework.config.wxPay.WxPayProperties;
|
import com.cpop.pay.framewok.config.wxPay.WxPayProperties;
|
||||||
import com.cpop.mall.framework.handler.WxPayHandler;
|
import com.cpop.pay.framewok.handler.wxPay.WxPayHandler;
|
||||||
import com.cpop.system.business.entity.Brand;
|
|
||||||
import com.cpop.system.business.entity.ProfitSharing;
|
import com.cpop.system.business.entity.ProfitSharing;
|
||||||
import com.cpop.system.business.service.BrandService;
|
|
||||||
import com.cpop.system.business.service.ProfitSharingService;
|
import com.cpop.system.business.service.ProfitSharingService;
|
||||||
import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult;
|
|
||||||
import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyV3Result;
|
import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyV3Result;
|
||||||
import com.github.binarywang.wxpay.bean.profitsharingV3.ProfitSharingReturnRequest;
|
import com.github.binarywang.wxpay.bean.profitsharingV3.ProfitSharingReturnRequest;
|
||||||
import com.github.binarywang.wxpay.bean.request.WxPayRefundV3Request;
|
import com.github.binarywang.wxpay.bean.request.WxPayRefundV3Request;
|
||||||
import com.github.binarywang.wxpay.bean.result.WxPayRefundV3Result;
|
|
||||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||||
import com.github.binarywang.wxpay.service.WxPayService;
|
import com.github.binarywang.wxpay.service.WxPayService;
|
||||||
import com.mybatisflex.annotation.KeyType;
|
import com.mybatisflex.annotation.KeyType;
|
||||||
|
|||||||
@ -19,25 +19,24 @@ import com.cpop.jambox.business.entity.BrandExtend;
|
|||||||
import com.cpop.jambox.business.service.BrandExtendService;
|
import com.cpop.jambox.business.service.BrandExtendService;
|
||||||
import com.cpop.mall.business.bo.*;
|
import com.cpop.mall.business.bo.*;
|
||||||
import com.cpop.mall.business.dto.UserPointDto;
|
import com.cpop.mall.business.dto.UserPointDto;
|
||||||
import com.cpop.mall.business.dto.WxPayGoodsDetailDto;
|
import com.cpop.pay.framewok.core.dto.WxPayGoodsDetailDto;
|
||||||
import com.cpop.mall.business.entity.*;
|
import com.cpop.mall.business.entity.*;
|
||||||
import com.cpop.mall.business.mapper.OrderMapper;
|
import com.cpop.mall.business.mapper.OrderMapper;
|
||||||
import com.cpop.mall.business.service.*;
|
import com.cpop.mall.business.service.*;
|
||||||
import com.cpop.mall.framework.task.OrderDetailAsyncTask;
|
|
||||||
import com.cpop.mall.framework.task.OrderOverTimeUnPayTask;
|
|
||||||
import com.cpop.mall.framework.task.ProductRecordSyncStockTask;
|
|
||||||
import com.cpop.mall.framework.task.WxPayAsyncTask;
|
|
||||||
import com.cpop.mall.business.vo.OrderDetailVo;
|
import com.cpop.mall.business.vo.OrderDetailVo;
|
||||||
import com.cpop.mall.business.vo.OrderInfoVo;
|
import com.cpop.mall.business.vo.OrderInfoVo;
|
||||||
import com.cpop.mall.business.vo.OrderPageVo;
|
import com.cpop.mall.business.vo.OrderPageVo;
|
||||||
import com.cpop.mall.framework.constant.MallRedisConstant;
|
import com.cpop.mall.framework.constant.MallRedisConstant;
|
||||||
import com.cpop.mall.framework.enums.BuyRestrictEnums;
|
import com.cpop.mall.framework.enums.BuyRestrictEnums;
|
||||||
import com.cpop.mall.framework.enums.QuartzEnums;
|
import com.cpop.mall.framework.enums.QuartzEnums;
|
||||||
import com.cpop.mall.framework.handler.WxPayHandler;
|
import com.cpop.mall.framework.task.OrderDetailAsyncTask;
|
||||||
|
import com.cpop.mall.framework.task.OrderOverTimeUnPayTask;
|
||||||
|
import com.cpop.mall.framework.task.ProductRecordSyncStockTask;
|
||||||
|
import com.cpop.pay.framewok.task.WxPayAsyncTask;
|
||||||
|
import com.cpop.pay.framewok.handler.wxPay.WxPayHandler;
|
||||||
import com.cpop.system.business.entity.Brand;
|
import com.cpop.system.business.entity.Brand;
|
||||||
import com.cpop.system.business.service.BrandService;
|
import com.cpop.system.business.service.BrandService;
|
||||||
import com.cpop.system.business.service.ProfitSharingService;
|
import com.cpop.system.business.service.ProfitSharingService;
|
||||||
|
|
||||||
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
|
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
|
||||||
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
|
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
|
||||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||||
@ -69,7 +68,7 @@ import static com.cpop.mall.business.entity.table.ProductRecordTableDef.PRODUCT_
|
|||||||
import static com.cpop.mall.business.entity.table.ProductTableDef.PRODUCT;
|
import static com.cpop.mall.business.entity.table.ProductTableDef.PRODUCT;
|
||||||
import static com.cpop.system.business.entity.table.ProfitSharingTableDef.PROFIT_SHARING;
|
import static com.cpop.system.business.entity.table.ProfitSharingTableDef.PROFIT_SHARING;
|
||||||
import static com.cpop.system.business.entity.table.StoreTableDef.STORE;
|
import static com.cpop.system.business.entity.table.StoreTableDef.STORE;
|
||||||
import static com.mybatisflex.core.query.QueryMethods.*;
|
import static com.mybatisflex.core.query.QueryMethods.sum;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -530,7 +529,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|||||||
Map<String, Integer> orderNumMap = orderDetails.stream().collect(Collectors.toMap(OrderDetail::getProductRecordId, OrderDetail::getNumber));
|
Map<String, Integer> orderNumMap = orderDetails.stream().collect(Collectors.toMap(OrderDetail::getProductRecordId, OrderDetail::getNumber));
|
||||||
//需要分账
|
//需要分账
|
||||||
if (notifyResult.getTotalFee() >= Math.ceil(1 / OrderSource.MALL.getRate())) {
|
if (notifyResult.getTotalFee() >= Math.ceil(1 / OrderSource.MALL.getRate())) {
|
||||||
wxPayAsyncTask.asyncWxPayProfitSharing(orderId, notifyResult, wxPayService);
|
wxPayAsyncTask.asyncWxPayProfitSharing(orderId, notifyResult, wxPayService, OrderSource.MALL);
|
||||||
}
|
}
|
||||||
//异步更新
|
//异步更新
|
||||||
SpringUtils.getBean(ProductRecordSyncStockTask.class).asyncUpdateRecords(orderNumMap);
|
SpringUtils.getBean(ProductRecordSyncStockTask.class).asyncUpdateRecords(orderNumMap);
|
||||||
|
|||||||
@ -1,48 +0,0 @@
|
|||||||
package com.cpop.mall.framework.config.wxPay;
|
|
||||||
|
|
||||||
import com.cpop.common.utils.StringUtils;
|
|
||||||
import com.github.binarywang.wxpay.config.WxPayConfig;
|
|
||||||
import com.github.binarywang.wxpay.service.WxPayService;
|
|
||||||
import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author DB
|
|
||||||
* @Description:
|
|
||||||
* @create 2023-10-26 22:38
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
@ConditionalOnClass(WxPayService.class)
|
|
||||||
@EnableConfigurationProperties(WxPayProperties.class)
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class WxPayConfiguration {
|
|
||||||
private WxPayProperties properties;
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
@ConditionalOnMissingBean
|
|
||||||
public WxPayService wxService() {
|
|
||||||
WxPayConfig payConfig = new WxPayConfig();
|
|
||||||
payConfig.setAppId(StringUtils.trimToNull(this.properties.getAppId()));
|
|
||||||
payConfig.setMchId(StringUtils.trimToNull(this.properties.getMchId()));
|
|
||||||
payConfig.setMchKey(StringUtils.trimToNull(this.properties.getMchKey()));
|
|
||||||
//服务商模式微信支付
|
|
||||||
payConfig.setApiV3Key(this.properties.getApiV3Key());
|
|
||||||
payConfig.setCertSerialNo(this.properties.getCertSerialNo());
|
|
||||||
payConfig.setKeyPath(this.properties.getKeyPath());
|
|
||||||
payConfig.setPrivateKeyPath(this.properties.getPrivateKeyPath());
|
|
||||||
payConfig.setPrivateCertPath(this.properties.getPrivateCertPath());
|
|
||||||
//通知地址
|
|
||||||
payConfig.setNotifyUrl(this.properties.getNotifyUrl());
|
|
||||||
// 可以指定是否使用沙箱环境
|
|
||||||
payConfig.setUseSandboxEnv(false);
|
|
||||||
WxPayService wxPayService = new WxPayServiceImpl();
|
|
||||||
wxPayService.setConfig(payConfig);
|
|
||||||
return wxPayService;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,78 +0,0 @@
|
|||||||
package com.cpop.mall.framework.config.wxPay;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author DB
|
|
||||||
* @Description:
|
|
||||||
* @create 2023-10-26 22:39
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@ConfigurationProperties(prefix = "wx.pay")
|
|
||||||
public class WxPayProperties {
|
|
||||||
/**
|
|
||||||
* 设置微信公众号或者小程序等的appid
|
|
||||||
*/
|
|
||||||
private String appId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 微信支付商户号
|
|
||||||
*/
|
|
||||||
private String mchId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 微信支付商户密钥
|
|
||||||
*/
|
|
||||||
private String mchKey;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* apiclient_cert.p12文件的绝对路径,或者如果放在项目中,请以classpath:开头指定
|
|
||||||
*/
|
|
||||||
private String keyPath;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* apiV3 秘钥值
|
|
||||||
*/
|
|
||||||
private String apiV3Key;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* apiclient_key.pem证书文件的绝对路径或者以classpath:开头的类路径
|
|
||||||
*/
|
|
||||||
private String privateKeyPath;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* apiclient_cert.pem证书文件的绝对路径或者以classpath:开头的类路径
|
|
||||||
*/
|
|
||||||
private String privateCertPath;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* apiV3 证书序列号值
|
|
||||||
*/
|
|
||||||
private String certSerialNo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 支付通知地址
|
|
||||||
*/
|
|
||||||
private String notifyUrl;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 退款通知
|
|
||||||
*/
|
|
||||||
private String notifyRefund;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分账账号
|
|
||||||
*/
|
|
||||||
private String sharingAccount;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分账账号名
|
|
||||||
*/
|
|
||||||
private String sharingAccountName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分账通知
|
|
||||||
*/
|
|
||||||
private String notifySharing;
|
|
||||||
}
|
|
||||||
@ -1,72 +0,0 @@
|
|||||||
package com.cpop.mall.framework.handler;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.cpop.common.utils.StringUtils;
|
|
||||||
import com.cpop.core.base.exception.ServiceException;
|
|
||||||
import com.cpop.core.utils.SecurityUtils;
|
|
||||||
import com.cpop.core.utils.SpringUtils;
|
|
||||||
import com.cpop.system.business.entity.Brand;
|
|
||||||
import com.cpop.system.business.service.BrandService;
|
|
||||||
import com.github.binarywang.wxpay.config.WxPayConfig;
|
|
||||||
import com.github.binarywang.wxpay.service.WxPayService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author DB
|
|
||||||
* @createTime 2023/10/27 15:47
|
|
||||||
* @description
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
public class WxPayHandler {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private WxPayService wxPayService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @descriptions 获取微信支付service
|
|
||||||
* @author DB
|
|
||||||
* @date 2023/10/27 15:53
|
|
||||||
* @return: com.github.binarywang.wxpay.service.WxPayService
|
|
||||||
*/
|
|
||||||
public WxPayService getWxPayService(){
|
|
||||||
//查询当前登陆用户所在品牌的商户id
|
|
||||||
JSONObject loginUserInfo = SecurityUtils.getInstance().getLoginUserInfo();
|
|
||||||
if (loginUserInfo == null) {
|
|
||||||
//直接返回
|
|
||||||
return wxPayService;
|
|
||||||
}
|
|
||||||
String brandId = loginUserInfo.getString("brandId");
|
|
||||||
Brand brand = SpringUtils.getBean(BrandService.class).getById(brandId);
|
|
||||||
//检查是否开启分账
|
|
||||||
if (!brand.getIsOpenSharing()) {
|
|
||||||
throw new ServiceException("当前商户暂未开启分账,请联系相关客服");
|
|
||||||
}
|
|
||||||
WxPayConfig payConfig = wxPayService.getConfig();
|
|
||||||
//子商户信息
|
|
||||||
payConfig.setSubMchId(StringUtils.trimToNull(brand.getWxMchId()));
|
|
||||||
// 可以指定是否使用沙箱环境
|
|
||||||
payConfig.setUseSandboxEnv(false);
|
|
||||||
wxPayService.setConfig(payConfig);
|
|
||||||
return wxPayService;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @descriptions 根据商户appid或商户号获取对应微信支付接口
|
|
||||||
* @author DB
|
|
||||||
* @date 2023/10/18 10:34
|
|
||||||
* @param subAppId 子商户appid
|
|
||||||
* @param subMchId 子商户id
|
|
||||||
* @return: com.github.binarywang.wxpay.service.WxPayService
|
|
||||||
*/
|
|
||||||
public WxPayService getWxPayService(String subAppId, String subMchId) {
|
|
||||||
WxPayConfig payConfig = wxPayService.getConfig();
|
|
||||||
//子商户信息
|
|
||||||
payConfig.setSubAppId(StringUtils.trimToNull(subAppId));
|
|
||||||
payConfig.setSubMchId(StringUtils.trimToNull(subMchId));
|
|
||||||
// 可以指定是否使用沙箱环境
|
|
||||||
payConfig.setUseSandboxEnv(false);
|
|
||||||
wxPayService.setConfig(payConfig);
|
|
||||||
return wxPayService;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -17,9 +17,9 @@ import java.io.Serializable;
|
|||||||
@ApiModel(value = "FinanceReimburseAuditPageBo对象", description = "财务报销审核请求参数")
|
@ApiModel(value = "FinanceReimburseAuditPageBo对象", description = "财务报销审核请求参数")
|
||||||
public class FinanceReimburseAuditPageBo implements Serializable {
|
public class FinanceReimburseAuditPageBo implements Serializable {
|
||||||
/**
|
/**
|
||||||
* 状态:0已提交1审批中2已下发3:下款中;5:驳回
|
* 状态:0:审批中;1:下款中;2:已下发-1:驳回
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "状态:0已提交1审批中2已下发3:下款中;4:驳回")
|
@ApiModelProperty(value = "状态:0:审批中;1:下款中;2:已下发-1:驳回")
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -18,9 +18,9 @@ import java.io.Serializable;
|
|||||||
public class FinanceReimbursePageBo implements Serializable {
|
public class FinanceReimbursePageBo implements Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 状态:0已提交1审批中2已下发3:下款中;5:驳回
|
* 状态:0:审批中;1:下款中;2:已下发-1:驳回
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "状态:0:已提交;1:审批中;2:下款中;3:已下发;4:驳回")
|
@ApiModelProperty(value = "状态:0:审批中;1:下款中;2:已下发-1:驳回")
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import com.alibaba.fastjson.JSONObject;
|
|||||||
import com.cpop.common.utils.StringUtils;
|
import com.cpop.common.utils.StringUtils;
|
||||||
import com.cpop.core.base.R;
|
import com.cpop.core.base.R;
|
||||||
import com.cpop.core.base.exception.ServiceException;
|
import com.cpop.core.base.exception.ServiceException;
|
||||||
import com.cpop.oam.framework.config.wxPay.WxPayConfiguration;
|
import com.cpop.pay.framewok.config.wxPay.WxPayConfiguration;
|
||||||
import com.cpop.system.business.bo.ChangeWechatSharingBo;
|
import com.cpop.system.business.bo.ChangeWechatSharingBo;
|
||||||
import com.cpop.system.business.entity.Brand;
|
import com.cpop.system.business.entity.Brand;
|
||||||
import com.cpop.system.business.service.BrandService;
|
import com.cpop.system.business.service.BrandService;
|
||||||
@ -17,7 +17,10 @@ import io.swagger.annotations.ApiOperation;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|||||||
@ -1,16 +1,10 @@
|
|||||||
package com.cpop.oam.business.service.impl;
|
package com.cpop.oam.business.service.impl;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.mybatisflex.core.paginate.Page;
|
|
||||||
import com.mybatisflex.core.query.QueryWrapper;
|
|
||||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
|
||||||
import com.cpop.common.utils.bean.BeanUtils;
|
import com.cpop.common.utils.bean.BeanUtils;
|
||||||
import com.cpop.core.base.entity.LoginUser;
|
import com.cpop.core.base.entity.LoginUser;
|
||||||
import com.cpop.core.base.entity.PageDomain;
|
import com.cpop.core.base.entity.PageDomain;
|
||||||
import com.cpop.core.base.entity.loginInfo.OamStaffLoginInfo;
|
|
||||||
import com.cpop.core.base.enums.UserType;
|
|
||||||
import com.cpop.core.base.exception.ServiceException;
|
import com.cpop.core.base.exception.ServiceException;
|
||||||
import com.cpop.core.service.RedisService;
|
|
||||||
import com.cpop.core.utils.SecurityUtils;
|
import com.cpop.core.utils.SecurityUtils;
|
||||||
import com.cpop.core.utils.SpringUtils;
|
import com.cpop.core.utils.SpringUtils;
|
||||||
import com.cpop.core.utils.sql.SqlUtils;
|
import com.cpop.core.utils.sql.SqlUtils;
|
||||||
@ -23,6 +17,9 @@ import com.cpop.oam.business.service.FinanceReimburseStageService;
|
|||||||
import com.cpop.oam.business.vo.FinanceReimburseAuditPageVo;
|
import com.cpop.oam.business.vo.FinanceReimburseAuditPageVo;
|
||||||
import com.cpop.oam.business.vo.FinanceReimbursePageVo;
|
import com.cpop.oam.business.vo.FinanceReimbursePageVo;
|
||||||
import com.cpop.oam.business.vo.ReimbursePersonStatisticVo;
|
import com.cpop.oam.business.vo.ReimbursePersonStatisticVo;
|
||||||
|
import com.mybatisflex.core.paginate.Page;
|
||||||
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
|
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@ -115,6 +112,11 @@ public class FinanceReimburseServiceImpl extends ServiceImpl<FinanceReimburseMap
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void updateReimburseStatus(ReimburseStatusBo bo) {
|
public void updateReimburseStatus(ReimburseStatusBo bo) {
|
||||||
List<FinanceReimburse> list = this.list(QueryWrapper.create().where(FINANCE_REIMBURSE.ID.in(bo.getIds())));
|
List<FinanceReimburse> list = this.list(QueryWrapper.create().where(FINANCE_REIMBURSE.ID.in(bo.getIds())));
|
||||||
|
//审批批量转下款
|
||||||
|
if (list.get(0).getStatus() == 1) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
List<String> allFinishReimburseIds = new ArrayList<>();
|
List<String> allFinishReimburseIds = new ArrayList<>();
|
||||||
if (!list.isEmpty()){
|
if (!list.isEmpty()){
|
||||||
list.forEach(item->{
|
list.forEach(item->{
|
||||||
|
|||||||
@ -41,9 +41,9 @@ public class FinanceReimburseAuditPageVo implements Serializable {
|
|||||||
private String staffName;
|
private String staffName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 状态:0已提交1审批中2已下发3:下款中;5:驳回
|
* 状态:0:审批中;1:下款中;2:已下发-1:驳回
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty("状态:0已提交1审批中2已下发3:下款中;5:驳回")
|
@ApiModelProperty("状态:0:审批中;1:下款中;2:已下发-1:驳回")
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -41,9 +41,9 @@ public class FinanceReimbursePageVo implements Serializable {
|
|||||||
private String staffName;
|
private String staffName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 状态:0已提交1审批中2已下发3:下款中;5:驳回
|
* 状态:0:审批中;1:下款中;2:已下发-1:驳回
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty("状态:0已提交1审批中2已下发3:下款中;5:驳回")
|
@ApiModelProperty("状态:0:审批中;1:下款中;2:已下发-1:驳回")
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,51 +0,0 @@
|
|||||||
package com.cpop.oam.framework.config.wxPay;
|
|
||||||
|
|
||||||
import com.cpop.common.utils.StringUtils;
|
|
||||||
import com.github.binarywang.wxpay.config.WxPayConfig;
|
|
||||||
import com.github.binarywang.wxpay.service.WxPayService;
|
|
||||||
import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author DB
|
|
||||||
* @Description:
|
|
||||||
* @create 2023-10-26 22:38
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
@ConditionalOnClass(WxPayService.class)
|
|
||||||
@EnableConfigurationProperties(WxPayProperties.class)
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class WxPayConfiguration {
|
|
||||||
private WxPayProperties properties;
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
@ConditionalOnMissingBean
|
|
||||||
public WxPayService wxService() {
|
|
||||||
WxPayConfig payConfig = new WxPayConfig();
|
|
||||||
payConfig.setAppId(StringUtils.trimToNull(this.properties.getAppId()));
|
|
||||||
payConfig.setMchId(StringUtils.trimToNull(this.properties.getMchId()));
|
|
||||||
payConfig.setMchKey(StringUtils.trimToNull(this.properties.getMchKey()));
|
|
||||||
//服务商模式微信支付
|
|
||||||
payConfig.setApiV3Key(this.properties.getApiV3Key());
|
|
||||||
payConfig.setCertSerialNo(this.properties.getCertSerialNo());
|
|
||||||
payConfig.setKeyPath(this.properties.getKeyPath());
|
|
||||||
payConfig.setPrivateKeyPath(this.properties.getPrivateKeyPath());
|
|
||||||
payConfig.setPrivateCertPath(this.properties.getPrivateCertPath());
|
|
||||||
//通知地址
|
|
||||||
payConfig.setNotifyUrl(this.properties.getNotifyUrl());
|
|
||||||
// 可以指定是否使用沙箱环境
|
|
||||||
payConfig.setUseSandboxEnv(false);
|
|
||||||
WxPayService wxPayService = new WxPayServiceImpl();
|
|
||||||
wxPayService.setConfig(payConfig);
|
|
||||||
return wxPayService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public WxPayProperties getProperties() {
|
|
||||||
return properties;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,78 +0,0 @@
|
|||||||
package com.cpop.oam.framework.config.wxPay;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author DB
|
|
||||||
* @Description:
|
|
||||||
* @create 2023-10-26 22:39
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@ConfigurationProperties(prefix = "wx.pay")
|
|
||||||
public class WxPayProperties {
|
|
||||||
/**
|
|
||||||
* 设置微信公众号或者小程序等的appid
|
|
||||||
*/
|
|
||||||
private String appId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 微信支付商户号
|
|
||||||
*/
|
|
||||||
private String mchId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 微信支付商户密钥
|
|
||||||
*/
|
|
||||||
private String mchKey;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* apiclient_cert.p12文件的绝对路径,或者如果放在项目中,请以classpath:开头指定
|
|
||||||
*/
|
|
||||||
private String keyPath;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* apiV3 秘钥值
|
|
||||||
*/
|
|
||||||
private String apiV3Key;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* apiclient_key.pem证书文件的绝对路径或者以classpath:开头的类路径
|
|
||||||
*/
|
|
||||||
private String privateKeyPath;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* apiclient_cert.pem证书文件的绝对路径或者以classpath:开头的类路径
|
|
||||||
*/
|
|
||||||
private String privateCertPath;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* apiV3 证书序列号值
|
|
||||||
*/
|
|
||||||
private String certSerialNo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 支付通知地址
|
|
||||||
*/
|
|
||||||
private String notifyUrl;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 退款通知
|
|
||||||
*/
|
|
||||||
private String notifyRefund;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分账账号
|
|
||||||
*/
|
|
||||||
private String sharingAccount;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分账账号名
|
|
||||||
*/
|
|
||||||
private String sharingAccountName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分账通知
|
|
||||||
*/
|
|
||||||
private String notifySharing;
|
|
||||||
}
|
|
||||||
@ -1,72 +0,0 @@
|
|||||||
package com.cpop.oam.framework.handler.wxPay;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.cpop.common.utils.StringUtils;
|
|
||||||
import com.cpop.core.base.exception.ServiceException;
|
|
||||||
import com.cpop.core.utils.SecurityUtils;
|
|
||||||
import com.cpop.core.utils.SpringUtils;
|
|
||||||
import com.cpop.system.business.entity.Brand;
|
|
||||||
import com.cpop.system.business.service.BrandService;
|
|
||||||
import com.github.binarywang.wxpay.config.WxPayConfig;
|
|
||||||
import com.github.binarywang.wxpay.service.WxPayService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author DB
|
|
||||||
* @createTime 2023/10/27 15:47
|
|
||||||
* @description
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
public class WxPayHandler {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private WxPayService wxPayService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @descriptions 获取微信支付service
|
|
||||||
* @author DB
|
|
||||||
* @date 2023/10/27 15:53
|
|
||||||
* @return: com.github.binarywang.wxpay.service.WxPayService
|
|
||||||
*/
|
|
||||||
public WxPayService getWxPayService(){
|
|
||||||
//查询当前登陆用户所在品牌的商户id
|
|
||||||
JSONObject loginUserInfo = SecurityUtils.getInstance().getLoginUserInfo();
|
|
||||||
if (loginUserInfo == null) {
|
|
||||||
//直接返回
|
|
||||||
return wxPayService;
|
|
||||||
}
|
|
||||||
String brandId = loginUserInfo.getString("brandId");
|
|
||||||
Brand brand = SpringUtils.getBean(BrandService.class).getById(brandId);
|
|
||||||
//检查是否开启分账
|
|
||||||
if (!brand.getIsOpenSharing()) {
|
|
||||||
throw new ServiceException("当前商户暂未开启分账,请联系相关客服");
|
|
||||||
}
|
|
||||||
WxPayConfig payConfig = wxPayService.getConfig();
|
|
||||||
//子商户信息
|
|
||||||
payConfig.setSubMchId(StringUtils.trimToNull(brand.getWxMchId()));
|
|
||||||
// 可以指定是否使用沙箱环境
|
|
||||||
payConfig.setUseSandboxEnv(false);
|
|
||||||
wxPayService.setConfig(payConfig);
|
|
||||||
return wxPayService;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @descriptions 根据商户appid或商户号获取对应微信支付接口
|
|
||||||
* @author DB
|
|
||||||
* @date 2023/10/18 10:34
|
|
||||||
* @param subAppId 子商户appid
|
|
||||||
* @param subMchId 子商户id
|
|
||||||
* @return: com.github.binarywang.wxpay.service.WxPayService
|
|
||||||
*/
|
|
||||||
public WxPayService getWxPayService(String subAppId, String subMchId) {
|
|
||||||
WxPayConfig payConfig = wxPayService.getConfig();
|
|
||||||
//子商户信息
|
|
||||||
payConfig.setSubAppId(StringUtils.trimToNull(subAppId));
|
|
||||||
payConfig.setSubMchId(StringUtils.trimToNull(subMchId));
|
|
||||||
// 可以指定是否使用沙箱环境
|
|
||||||
payConfig.setUseSandboxEnv(false);
|
|
||||||
wxPayService.setConfig(payConfig);
|
|
||||||
return wxPayService;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -12,9 +12,7 @@
|
|||||||
<name>Cpop-Pay</name>
|
<name>Cpop-Pay</name>
|
||||||
<description>Cpop-Pay</description>
|
<description>Cpop-Pay</description>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<properties>
|
|
||||||
<java.version>17</java.version>
|
|
||||||
</properties>
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!--核心包-->
|
<!--核心包-->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@ -23,6 +23,7 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
@EnableConfigurationProperties(WxPayProperties.class)
|
@EnableConfigurationProperties(WxPayProperties.class)
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class WxPayConfiguration {
|
public class WxPayConfiguration {
|
||||||
|
|
||||||
private WxPayProperties properties;
|
private WxPayProperties properties;
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
package com.cpop.mall.business.dto;
|
package com.cpop.pay.framewok.core.dto;
|
||||||
|
|
||||||
import com.alibaba.fastjson.annotation.JSONField;
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -72,4 +72,25 @@ public class WxPayHandler {
|
|||||||
wxPayService.setConfig(payConfig);
|
wxPayService.setConfig(payConfig);
|
||||||
return wxPayService;
|
return wxPayService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据商户appid或商户号获取对应微信支付接口
|
||||||
|
* @author DB
|
||||||
|
* @since 2023/10/18 10:34
|
||||||
|
* @param subAppId 子商户appid
|
||||||
|
* @param subMchId 子商户id
|
||||||
|
* @param notifyUrl 通知地址
|
||||||
|
* @return com.github.binarywang.wxpay.service.WxPayService
|
||||||
|
*/
|
||||||
|
public WxPayService getWxPayService(String subAppId, String subMchId,String notifyUrl) {
|
||||||
|
WxPayConfig payConfig = wxPayService.getConfig();
|
||||||
|
//子商户信息
|
||||||
|
payConfig.setSubAppId(StringUtils.trimToNull(subAppId));
|
||||||
|
payConfig.setSubMchId(StringUtils.trimToNull(subMchId));
|
||||||
|
payConfig.setNotifyUrl(notifyUrl);
|
||||||
|
// 可以指定是否使用沙箱环境
|
||||||
|
payConfig.setUseSandboxEnv(false);
|
||||||
|
wxPayService.setConfig(payConfig);
|
||||||
|
return wxPayService;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,32 +1,29 @@
|
|||||||
package com.cpop.mall.framework.task;
|
package com.cpop.pay.framewok.task;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONArray;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.cpop.common.utils.StringUtils;
|
import com.cpop.common.utils.StringUtils;
|
||||||
import com.cpop.core.base.enums.OrderSource;
|
import com.cpop.core.base.enums.OrderSource;
|
||||||
import com.cpop.core.base.exception.ServiceException;
|
import com.cpop.core.base.exception.ServiceException;
|
||||||
import com.cpop.core.utils.SpringUtils;
|
import com.cpop.pay.framewok.config.wxPay.WxPayProperties;
|
||||||
import com.cpop.mall.framework.config.wxPay.WxPayProperties;
|
|
||||||
import com.cpop.system.business.entity.ProfitSharing;
|
|
||||||
import com.cpop.system.business.service.BrandService;
|
|
||||||
import com.cpop.system.business.service.ProfitSharingService;
|
|
||||||
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
|
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
|
||||||
import com.github.binarywang.wxpay.bean.profitsharing.ProfitSharingRequest;
|
import com.github.binarywang.wxpay.bean.profitsharing.ProfitSharingRequest;
|
||||||
import com.github.binarywang.wxpay.bean.profitsharing.ProfitSharingResult;
|
import com.github.binarywang.wxpay.bean.profitsharing.ProfitSharingResult;
|
||||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||||
import com.github.binarywang.wxpay.service.WxPayService;
|
import com.github.binarywang.wxpay.service.WxPayService;
|
||||||
|
import com.mybatisflex.core.row.Db;
|
||||||
|
import com.mybatisflex.core.row.DbChain;
|
||||||
|
import com.mybatisflex.core.row.Row;
|
||||||
|
import com.mybatisflex.core.row.RowKey;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static com.cpop.system.business.entity.table.BrandTableDef.BRAND;
|
|
||||||
import static com.cpop.system.business.entity.table.ProfitSharingTableDef.PROFIT_SHARING;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author DB
|
* @author DB
|
||||||
* @createTime 2023/11/03 11:13
|
* @createTime 2023/11/03 11:13
|
||||||
@ -48,11 +45,11 @@ public class WxPayAsyncTask {
|
|||||||
* @return: void
|
* @return: void
|
||||||
*/
|
*/
|
||||||
@Async("customAsyncThreadPool")
|
@Async("customAsyncThreadPool")
|
||||||
public void asyncWxPayProfitSharing(String orderId, WxPayOrderNotifyResult notifyResult, WxPayService wxPayService) {
|
public void asyncWxPayProfitSharing(String orderId, WxPayOrderNotifyResult notifyResult, WxPayService wxPayService,OrderSource orderSource) {
|
||||||
ProfitSharingRequest profitSharingRequest = buildProfitSharingRequest(orderId, notifyResult);
|
ProfitSharingRequest profitSharingRequest = buildProfitSharingRequest(orderId, notifyResult, orderSource);
|
||||||
try {
|
try {
|
||||||
Thread.sleep(5000);
|
Thread.sleep(5000);
|
||||||
wxPayProfitSharing(profitSharingRequest, wxPayService, 0);
|
wxPayProfitSharing(profitSharingRequest, wxPayService, 0,orderSource);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
throw new ServiceException(e.getMessage());
|
throw new ServiceException(e.getMessage());
|
||||||
}
|
}
|
||||||
@ -66,16 +63,20 @@ public class WxPayAsyncTask {
|
|||||||
* @param notifyResult 通知结果
|
* @param notifyResult 通知结果
|
||||||
* @return: com.github.binarywang.wxpay.bean.profitsharingV3.ProfitSharingRequest
|
* @return: com.github.binarywang.wxpay.bean.profitsharingV3.ProfitSharingRequest
|
||||||
*/
|
*/
|
||||||
private ProfitSharingRequest buildProfitSharingRequest(String orderId, WxPayOrderNotifyResult notifyResult) {
|
private ProfitSharingRequest buildProfitSharingRequest(String orderId, WxPayOrderNotifyResult notifyResult,OrderSource orderSource) {
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
Double ceil = Math.ceil(notifyResult.getTotalFee() * OrderSource.MALL.getRate());
|
Double ceil = Math.ceil(notifyResult.getTotalFee() * OrderSource.MALL.getRate());
|
||||||
ProfitSharing profitSharing = new ProfitSharing();
|
Row row = Row.ofKey(RowKey.SNOW_FLAKE_ID)
|
||||||
profitSharing.setOrderId(orderId)
|
.set("order_id", orderId)
|
||||||
.setProfitSharingStatus(0)
|
.set("profit_sharing_status", 0)
|
||||||
.setOrderSource(OrderSource.MALL.toString())
|
.set("amount", ceil.longValue())
|
||||||
.setAmount(ceil.longValue())
|
.set("pay_account", notifyResult.getSubMchId())
|
||||||
.setPayAccount(notifyResult.getSubMchId());
|
.set("order_source",orderSource.toString())
|
||||||
ProfitSharingService profitSharingService = SpringUtils.getBean(ProfitSharingService.class);
|
.set("create_time", now)
|
||||||
profitSharingService.save(profitSharing);
|
.set("update_time", now)
|
||||||
|
.set("create_user_id", "1")
|
||||||
|
.set("update_user_id", "1");
|
||||||
|
Db.insert("cp_sys_profit_sharing", row);
|
||||||
//固定商户信息
|
//固定商户信息
|
||||||
Map<String, Object> mapReceiver = new HashMap<>(4);
|
Map<String, Object> mapReceiver = new HashMap<>(4);
|
||||||
mapReceiver.put("type", "MERCHANT_ID");
|
mapReceiver.put("type", "MERCHANT_ID");
|
||||||
@ -87,7 +88,7 @@ public class WxPayAsyncTask {
|
|||||||
//分账请求参数
|
//分账请求参数
|
||||||
ProfitSharingRequest profitSharingRequest = new ProfitSharingRequest();
|
ProfitSharingRequest profitSharingRequest = new ProfitSharingRequest();
|
||||||
profitSharingRequest.setReceivers(JSONObject.toJSONString(receivers));
|
profitSharingRequest.setReceivers(JSONObject.toJSONString(receivers));
|
||||||
profitSharingRequest.setOutOrderNo(profitSharing.getId());
|
profitSharingRequest.setOutOrderNo(row.getString("id"));
|
||||||
profitSharingRequest.setTransactionId(notifyResult.getTransactionId());
|
profitSharingRequest.setTransactionId(notifyResult.getTransactionId());
|
||||||
profitSharingRequest.setSubMchId(notifyResult.getSubMchId());
|
profitSharingRequest.setSubMchId(notifyResult.getSubMchId());
|
||||||
return profitSharingRequest;
|
return profitSharingRequest;
|
||||||
@ -102,28 +103,33 @@ public class WxPayAsyncTask {
|
|||||||
* @param flag 标记
|
* @param flag 标记
|
||||||
* @return: void
|
* @return: void
|
||||||
*/
|
*/
|
||||||
private void wxPayProfitSharing(ProfitSharingRequest profitSharingRequest, WxPayService wxPayService, Integer flag) {
|
private void wxPayProfitSharing(ProfitSharingRequest profitSharingRequest, WxPayService wxPayService, Integer flag, OrderSource orderSource) {
|
||||||
try {
|
try {
|
||||||
ProfitSharingResult profitSharingResult = wxPayService.getProfitSharingService().profitSharing(profitSharingRequest);
|
ProfitSharingResult profitSharingResult = wxPayService.getProfitSharingService().profitSharing(profitSharingRequest);
|
||||||
if (StringUtils.equals(profitSharingResult.getResultCode(), "SUCCESS")) {
|
if (StringUtils.equals(profitSharingResult.getResultCode(), "SUCCESS")) {
|
||||||
//存入系统
|
//存入系统
|
||||||
SpringUtils.getBean(ProfitSharingService.class).updateChain()
|
DbChain.table("cp_sys_profit_sharing")
|
||||||
.set(PROFIT_SHARING.OUT_PROFIT_SHARING_ID, profitSharingResult.getOrderId())
|
.set("out_profit_sharing_id", profitSharingResult.getOrderId())
|
||||||
.set(PROFIT_SHARING.PROFIT_SHARING_STATUS, 1)
|
.set("profit_sharing_status", 1)
|
||||||
.where(PROFIT_SHARING.ID.eq(profitSharingResult.getOutOrderNo()))
|
.where("id = ?", profitSharingResult.getOutOrderNo())
|
||||||
.update();
|
.update();
|
||||||
} else {
|
} else {
|
||||||
throw new ServiceException(profitSharingResult.getReturnMsg());
|
throw new ServiceException(profitSharingResult.getReturnMsg());
|
||||||
}
|
}
|
||||||
} catch (WxPayException e) {
|
} catch (WxPayException e) {
|
||||||
if (flag > 5) {
|
if (flag > 5) {
|
||||||
//关闭商城支付
|
if (OrderSource.MALL == orderSource) {
|
||||||
SpringUtils.getBean(BrandService.class).updateChain().set(BRAND.IS_OPEN_SHARING, false).where(BRAND.WX_MCH_ID.eq(wxPayService.getConfig().getSubMchId())).update();
|
//关闭商城支付
|
||||||
|
DbChain.table("cp_sys_brand")
|
||||||
|
.set("is_open_sharing", false)
|
||||||
|
.where("wx_mch_id = ?", wxPayService.getConfig().getSubMchId())
|
||||||
|
.update();
|
||||||
|
}
|
||||||
throw new ServiceException(e.getMessage());
|
throw new ServiceException(e.getMessage());
|
||||||
} else {
|
} else {
|
||||||
//重复调用
|
//重复调用
|
||||||
flag = flag + 1;
|
flag = flag + 1;
|
||||||
wxPayProfitSharing(profitSharingRequest, wxPayService, flag);
|
wxPayProfitSharing(profitSharingRequest, wxPayService, flag, orderSource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user