From c34719a47619552bfb1a4b2954632171fcf257b5 Mon Sep 17 00:00:00 2001
From: DB <2502523450@qq.com>
Date: Wed, 22 Nov 2023 16:02:37 +0800
Subject: [PATCH] =?UTF-8?q?Oam=E6=8E=A5=E5=85=A5=E4=BC=81=E4=B8=9A?=
=?UTF-8?q?=E5=BE=AE=E4=BF=A1;=E8=B0=83=E6=95=B4=E5=93=81=E7=89=8C?=
=?UTF-8?q?=E7=AE=A1=E7=90=86;=E6=B7=BB=E5=8A=A0=E5=88=9D=E5=A7=8B?=
=?UTF-8?q?=E5=8C=96=E8=A7=92=E8=89=B2;=E8=B0=83=E6=95=B4=E5=95=86?=
=?UTF-8?q?=E5=9F=8E=E5=88=86=E8=B4=A6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../cpop/core/base/enums/InitRoleEnum.java | 4 +
.../com/cpop/core/base/table/SysUser.java | 5 +
.../core/handler/LoginFailureHandler.java | 5 +-
.../com/cpop/core/service/CoreService.java | 10 ++
.../core/service/impl/CoreServiceImpl.java | 15 +++
.../strategy/login/MiniLoginStrategy.java | 4 -
.../src/main/resources/mapper/CoreMapper.xml | 6 +
.../com/cpop/mall/web/CpopWxPayTests.java | 28 ++++-
.../service/impl/OrderServiceImpl.java | 10 +-
.../mall/business/task/WxPayAsyncTask.java | 16 +--
.../mall/framework/handler/WxPayHandler.java | 5 +
.../src/main/resources/application-dev.yml | 6 +-
.../src/main/resources/application-prod.yml | 2 +-
.../src/main/resources/application-test.yml | 2 +-
.../src/main/resources/application.yml | 5 +-
.../com/cpop/oam/business/bo/StaffBo.java | 8 +-
.../controller/backstage/WxCpController.java | 41 ++++++-
.../controller/backstage/WxPayController.java | 11 +-
.../callback/WxCpPortalController.java | 21 ++++
.../oam/business/service/OamWxCpService.java | 23 ++++
.../oam/business/service/StaffService.java | 3 +-
.../service/impl/OamWxCpServiceImpl.java | 111 +++++++++++++++++-
.../service/impl/StaffServiceImpl.java | 43 +++++--
.../com/cpop/oam/business/vo/WxCpLoginVo.java | 29 +++++
.../framework/config/wxCp/WxCpProperties.java | 5 +
.../business/bo/ChangeWechatSharingBo.java | 6 +-
.../cpop/system/business/entity/Brand.java | 4 +-
.../service/impl/BrandServiceImpl.java | 2 +-
.../service/impl/RoleServiceImpl.java | 2 +
.../cpop/system/business/vo/BrandPageVo.java | 6 +-
30 files changed, 371 insertions(+), 67 deletions(-)
create mode 100644 Cpop-Oam/src/main/java/com/cpop/oam/business/vo/WxCpLoginVo.java
diff --git a/Cpop-Core/src/main/java/com/cpop/core/base/enums/InitRoleEnum.java b/Cpop-Core/src/main/java/com/cpop/core/base/enums/InitRoleEnum.java
index df7aaea..863bb59 100644
--- a/Cpop-Core/src/main/java/com/cpop/core/base/enums/InitRoleEnum.java
+++ b/Cpop-Core/src/main/java/com/cpop/core/base/enums/InitRoleEnum.java
@@ -16,6 +16,10 @@ public enum InitRoleEnum {
* MALL超级管理员角色
*/
SUPER_MALL_ROLE("2", "SuperMallAdmin", "SuperMallAdmin", -1, UserType.MALL_USER),
+ /**
+ * 企微注册初始化角色
+ */
+ WX_CP_INIT_ROLE("3", "企微注册通用角色", "RegisterRole", 0, UserType.OAM_USER),
;
/**
diff --git a/Cpop-Core/src/main/java/com/cpop/core/base/table/SysUser.java b/Cpop-Core/src/main/java/com/cpop/core/base/table/SysUser.java
index 66b82fd..8410d23 100644
--- a/Cpop-Core/src/main/java/com/cpop/core/base/table/SysUser.java
+++ b/Cpop-Core/src/main/java/com/cpop/core/base/table/SysUser.java
@@ -43,6 +43,11 @@ public class SysUser extends BaseEntity implements Serializable {
*/
private String password;
+ /**
+ * rsa加密后的密码
+ */
+ private String rsaPassword;
+
/**
* 昵称
*/
diff --git a/Cpop-Core/src/main/java/com/cpop/core/handler/LoginFailureHandler.java b/Cpop-Core/src/main/java/com/cpop/core/handler/LoginFailureHandler.java
index e48f393..540764f 100644
--- a/Cpop-Core/src/main/java/com/cpop/core/handler/LoginFailureHandler.java
+++ b/Cpop-Core/src/main/java/com/cpop/core/handler/LoginFailureHandler.java
@@ -49,9 +49,10 @@ public class LoginFailureHandler implements AuthenticationFailureHandler {
if(e instanceof CpopAuthenticationException) {
loginUser.setUserType((UserType) ((CpopAuthenticationException) e).getParams());
errorMessage = e.getMessage();
+ result = R.ok(errorMessage);
+ }else {
+ result = R.fail(errorMessage);
}
- //TODO:暂时先这么处理
- result = R.ok(errorMessage);
if (loginUser.getUserType() == UserType.OAM_USER || loginUser.getUserType() == UserType.MINI_USER) {
//添加登录失败日志
coreService.insertOperationLog(Constants.FAIL, OperationLogEnum.SYSTEM_LOGIN, loginUser, errorMessage);
diff --git a/Cpop-Core/src/main/java/com/cpop/core/service/CoreService.java b/Cpop-Core/src/main/java/com/cpop/core/service/CoreService.java
index 329edd6..78e421c 100644
--- a/Cpop-Core/src/main/java/com/cpop/core/service/CoreService.java
+++ b/Cpop-Core/src/main/java/com/cpop/core/service/CoreService.java
@@ -122,6 +122,16 @@ public interface CoreService {
*/
LoginUser loadUserByUsername(String userName, UserType userType);
+ /**
+ * @descriptions 根据手机号与用户类型获取用户信息
+ * @author DB
+ * @date 2023/10/19 9:57
+ * @param phoneNumber 手机号
+ * @param userType 用户类型
+ * @return 登陆用户
+ */
+ LoginUser loadUserByPhone(String phoneNumber, UserType userType);
+
/**
* @descriptions 根据手机号与用户类型获取用户信息
* @author DB
diff --git a/Cpop-Core/src/main/java/com/cpop/core/service/impl/CoreServiceImpl.java b/Cpop-Core/src/main/java/com/cpop/core/service/impl/CoreServiceImpl.java
index cb94780..2ffd775 100644
--- a/Cpop-Core/src/main/java/com/cpop/core/service/impl/CoreServiceImpl.java
+++ b/Cpop-Core/src/main/java/com/cpop/core/service/impl/CoreServiceImpl.java
@@ -220,6 +220,21 @@ public class CoreServiceImpl implements CoreService {
return userType.getStrategy().getLoginUserInfo(sysUser, null);
}
+ /**
+ * @descriptions 可能存在用户手机号登陆的情况
+ * @author DB
+ * @date 2023/11/21 10:05
+ * @param phoneNumber 手机号
+ * @param userType 用户类型
+ * @return: com.cpop.core.base.entity.LoginUser
+ */
+ @Override
+ public LoginUser loadUserByPhone(String phoneNumber, UserType userType) {
+ //统一获取系统用户信息
+ SysUser sysUser = this.getSysUserByPhone(phoneNumber, userType);
+ return userType.getStrategy().getLoginUserInfo(sysUser, null);
+ }
+
/**
* @descriptions 根据手机号与用户类型获取用户信息
* @author DB
diff --git a/Cpop-Core/src/main/java/com/cpop/core/strategy/login/MiniLoginStrategy.java b/Cpop-Core/src/main/java/com/cpop/core/strategy/login/MiniLoginStrategy.java
index 2a6a3e7..0d4c3e6 100644
--- a/Cpop-Core/src/main/java/com/cpop/core/strategy/login/MiniLoginStrategy.java
+++ b/Cpop-Core/src/main/java/com/cpop/core/strategy/login/MiniLoginStrategy.java
@@ -6,7 +6,6 @@ import com.cpop.core.base.entity.loginInfo.MiniUserLoginInfo;
import com.cpop.core.base.enums.SourceType;
import com.cpop.core.base.enums.UserType;
import com.cpop.core.base.exception.CpopAuthenticationException;
-import com.cpop.core.base.exception.ServiceException;
import com.cpop.core.base.table.SysUser;
import com.mybatisflex.core.row.Db;
import com.mybatisflex.core.row.DbChain;
@@ -98,9 +97,6 @@ public class MiniLoginStrategy implements LoginStrategy {
if (brand == null) {
throw new CpopAuthenticationException("用户登陆失败,果酱品牌暂未录入系统");
}
- if (!brand.getBoolean("isOpenMall")){
- throw new CpopAuthenticationException("用户登陆失败,当前品牌暂未开通分账");
- }
//构建用户信息
Row row = DbChain.table("cp_mini_user")
.select("cmu.id","cmu.open_id","cmu.app_id","cmu.user_id","cmu.brand_id","cmu.nick_name","cmu.avatar","cmu.source_type")
diff --git a/Cpop-Core/src/main/resources/mapper/CoreMapper.xml b/Cpop-Core/src/main/resources/mapper/CoreMapper.xml
index 587ecfe..9ab2674 100644
--- a/Cpop-Core/src/main/resources/mapper/CoreMapper.xml
+++ b/Cpop-Core/src/main/resources/mapper/CoreMapper.xml
@@ -195,6 +195,9 @@
password,
+
+ rsa_password,
+
nick_name,
@@ -241,6 +244,9 @@
#{password},
+
+ #{rsaPassword},
+
#{nickName},
diff --git a/Cpop-Mall/Cpop-Mall-Web/src/test/java/com/cpop/mall/web/CpopWxPayTests.java b/Cpop-Mall/Cpop-Mall-Web/src/test/java/com/cpop/mall/web/CpopWxPayTests.java
index 403f303..a23655c 100644
--- a/Cpop-Mall/Cpop-Mall-Web/src/test/java/com/cpop/mall/web/CpopWxPayTests.java
+++ b/Cpop-Mall/Cpop-Mall-Web/src/test/java/com/cpop/mall/web/CpopWxPayTests.java
@@ -12,6 +12,7 @@ import com.cpop.system.business.service.BrandService;
import com.cpop.system.business.service.ProfitSharingService;
import com.github.binarywang.wxpay.bean.profitsharing.ProfitSharingFinishRequest;
import com.github.binarywang.wxpay.bean.profitsharing.ProfitSharingQueryRequest;
+import com.github.binarywang.wxpay.bean.profitsharing.ProfitSharingQueryResult;
import com.github.binarywang.wxpay.bean.profitsharing.ProfitSharingReceiverRequest;
import com.github.binarywang.wxpay.bean.profitsharingV3.ProfitSharingResult;
import com.github.binarywang.wxpay.bean.profitsharingV3.ProfitSharingReturnRequest;
@@ -57,13 +58,13 @@ public class CpopWxPayTests {
WxPayRefundV3Request.Amount amount = new WxPayRefundV3Request.Amount();
//退款金额(单位分)
//int refund = order.getTotalAmount().scaleByPowerOfTen(2).intValue();
- int refund = 100;
+ int refund = 500;
amount.setRefund(refund)
.setTotal(refund)
.setCurrency("CNY");
request.setSubMchid(wxPayService.getConfig().getSubMchId())
- .setTransactionId("4200002044202311178101861880")
- .setOutTradeNo("83081335475826688")
+ .setTransactionId("4200002010202311202693854147")
+ .setOutTradeNo("84052505520087040")
//.setTransactionId(order.getOutOrderNo())
//.setOutTradeNo(order.getId())
.setNotifyUrl(wxPayProperties.getNotifyRefund())
@@ -133,6 +134,21 @@ public class CpopWxPayTests {
System.out.println(wxPayOrderQueryResult);
}
+ /**
+ * @descriptions 查询分账结果
+ * @author DB
+ * @date 2023/11/20 12:35
+ * @return: void
+ */
+ @Test
+ public void getSharingInfo() throws WxPayException {
+ ProfitSharingQueryRequest profitSharingQueryRequest = new ProfitSharingQueryRequest();
+ profitSharingQueryRequest.setOutOrderNo("84064193241784320").setTransactionId("4200002009202311209353972307");
+ profitSharingQueryRequest.setSubMchId("1659765332");
+ ProfitSharingQueryResult result = wxPayService.getProfitSharingService().profitSharingQuery(profitSharingQueryRequest);
+ System.out.println(result.getResultCode());
+ }
+
/**
* @descriptions 查询分账结果
* @author DB
@@ -141,7 +157,7 @@ public class CpopWxPayTests {
*/
@Test
public void getRefundResult() throws WxPayException {
- ProfitSharingResult profitSharingResult = wxPayService.getProfitSharingV3Service().getProfitSharingResult("83081464408731648", "4200002044202311178101861880", "1659765332");
+ ProfitSharingResult profitSharingResult = wxPayService.getProfitSharingV3Service().getProfitSharingResult("84052505520087040", "4200002010202311202693854147", "1659765332");
System.out.println(profitSharingResult);
}
@@ -152,8 +168,8 @@ public class CpopWxPayTests {
@Test
public void profitSharingFinish() throws WxPayException {
ProfitSharingFinishRequest profitSharingFinishRequest = new ProfitSharingFinishRequest();
- profitSharingFinishRequest.setTransactionId("4200002044202311178101861880");
- profitSharingFinishRequest.setOutOrderNo("83081335475826688");
+ profitSharingFinishRequest.setTransactionId("4200002010202311202693854147");
+ profitSharingFinishRequest.setOutOrderNo("84052505520087040");
profitSharingFinishRequest.setDescription("结束分账");
profitSharingFinishRequest.setSubMchId("1659765332");
wxPayService.getProfitSharingService().profitSharingFinish(profitSharingFinishRequest);
diff --git a/Cpop-Mall/src/main/java/com/cpop/mall/business/service/impl/OrderServiceImpl.java b/Cpop-Mall/src/main/java/com/cpop/mall/business/service/impl/OrderServiceImpl.java
index f04841f..a1c5787 100644
--- a/Cpop-Mall/src/main/java/com/cpop/mall/business/service/impl/OrderServiceImpl.java
+++ b/Cpop-Mall/src/main/java/com/cpop/mall/business/service/impl/OrderServiceImpl.java
@@ -6,6 +6,7 @@ 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.enums.OrderSource;
import com.cpop.core.base.enums.UserType;
import com.cpop.core.base.exception.ServiceException;
import com.cpop.core.base.table.SysUser;
@@ -303,9 +304,8 @@ public class OrderServiceImpl extends ServiceImpl implements
WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
//查询是否是服务商系品牌
String brandId = loginUserInfo.getString("brandId");
- Brand brand = SpringUtils.getBean(BrandService.class).getById(brandId);
//需要分账
- if (order.getTotalAmount().scaleByPowerOfTen(2).intValue() >= 100) {
+ if (order.getTotalAmount().scaleByPowerOfTen(2).intValue() >= Math.ceil(1 / OrderSource.MALL.getRate())) {
//需要分账
orderRequest.setProfitSharing("Y");
}
@@ -529,10 +529,8 @@ public class OrderServiceImpl extends ServiceImpl implements
.where(ORDER_DETAIL.ORDER_ID.eq(orderId)).list();
//订单数量集合
Map orderNumMap = orderDetails.stream().collect(Collectors.toMap(OrderDetail::getProductRecordId, OrderDetail::getNumber));
- //查询订单信息
- Order order = this.getById(orderId);
- //需要分账(金额大于1元才分账)
- if (notifyResult.getTotalFee() >= 100) {
+ //需要分账
+ if (notifyResult.getTotalFee() >= Math.ceil(1 / OrderSource.MALL.getRate())) {
wxPayAsyncTask.asyncWxPayProfitSharing(orderId, notifyResult, wxPayService);
}
//异步更新
diff --git a/Cpop-Mall/src/main/java/com/cpop/mall/business/task/WxPayAsyncTask.java b/Cpop-Mall/src/main/java/com/cpop/mall/business/task/WxPayAsyncTask.java
index 36d4c73..b8e6b24 100644
--- a/Cpop-Mall/src/main/java/com/cpop/mall/business/task/WxPayAsyncTask.java
+++ b/Cpop-Mall/src/main/java/com/cpop/mall/business/task/WxPayAsyncTask.java
@@ -9,6 +9,7 @@ import com.cpop.core.base.exception.UtilException;
import com.cpop.core.utils.SpringUtils;
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.profitsharing.ProfitSharingReceiverRequest;
@@ -27,6 +28,7 @@ import java.util.HashMap;
import java.util.List;
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;
/**
@@ -84,18 +86,6 @@ public class WxPayAsyncTask {
mapReceiver.put("account", wxPayProperties.getSharingAccount());
mapReceiver.put("amount", ceil.longValue());
mapReceiver.put("description","分账到服务商");
- //TODO:V3版本目前发送失败
- /*
- ProfitSharingReceiverRequest profitSharingReceiver = new ProfitSharingReceiverRequest();
- profitSharingReceiver.setReceiver();
- ProfitSharingReceiver profitSharingReceiver = new ProfitSharingReceiver();
- profitSharingReceiver.setType("MERCHANT_ID");
- profitSharingReceiver.setAccount(wxPayProperties.getSharingAccount());
- profitSharingReceiver.setRelationType("SERVICE_PROVIDER");
- profitSharingReceiver.setAmount(ceil.longValue());
- profitSharingReceiver.setName("果酱盒子");
- profitSharingReceiver.setDescription("分账到服务商");
- */
List