Ver Fonte

多小程序支付

ct há 2 dias atrás
pai
commit
74a4b40b6b

+ 2 - 2
fs-admin/src/main/java/com/fs/api/controller/IndexStatisticsController.java

@@ -64,10 +64,10 @@ public class IndexStatisticsController {
     @GetMapping("/trafficLog")
     public R getTrafficLog(){
         TrafficLogDTO trafficLogDTO = redisCache.getCacheObject(DATA_OVERVIEW_TRAFFIC_LOG);
-        if(trafficLogDTO == null) {
+        SysConfig sysConfig = sysConfigService.selectConfigByConfigKey("redPacket.Traffic.config");
+        if(trafficLogDTO == null || sysConfig == null) {
             return null;
         }
-        SysConfig sysConfig = sysConfigService.selectConfigByConfigKey("redPacket.Traffic.config");
         String configValue = sysConfig.getConfigValue();
         trafficLogDTO.setTraffic(configValue);
         return R.ok().put("data",trafficLogDTO);

+ 1 - 1
fs-admin/src/main/java/com/fs/his/controller/FsStoreOrderController.java

@@ -656,7 +656,7 @@ public class FsStoreOrderController extends BaseController
             if (param.getUserPhoneMk() != null && !param.getUserPhoneMk().isEmpty()) {
                 param.setUserPhone(encryptPhone(param.getUserPhoneMk()));
             }
-            List<FsStoreOrderListVO> list = fsStoreOrderService.selectFsStoreOrderListVO(param);
+            List<FsStoreOrderListVO> list = fsStoreOrderService.selectFsStoreOrderListVOByErpAccount(param);
             orderIds = list.stream().map(FsStoreOrderListVO::getOrderId).collect(Collectors.toList());
         }
         if (orderIds.isEmpty()){

+ 1 - 1
fs-company/src/main/java/com/fs/company/controller/store/FsUserController.java

@@ -67,7 +67,7 @@ public class FsUserController extends BaseController
         startPage();
         LoginUser loginUser = SecurityUtils.getLoginUser();
         fsUser.setCompanyId(loginUser.getCompany().getCompanyId());
-        if(fsUser.getPhoneMk()!=null&&fsUser.getPhone()!=""){
+        if(fsUser.getPhoneMk()!=null&&StringUtils.isBlank(fsUser.getPhone())){
             fsUser.setPhone(encryptPhone(fsUser.getPhoneMk()));
         }
 

+ 18 - 10
fs-service/src/main/java/com/fs/company/service/impl/CompanyUserServiceImpl.java

@@ -651,6 +651,7 @@ public class CompanyUserServiceImpl implements ICompanyUserService
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public void auditUsers(List<Long> userIds,Long companyId) {
         if (userIds.isEmpty()) {
             return;
@@ -677,10 +678,14 @@ public class CompanyUserServiceImpl implements ICompanyUserService
             companyUserList.stream().forEach(c->{
                 //判断角色是否为空
                 if(ObjectUtil.isNotNull(role)){
-                    CompanyUserRole userRole=new CompanyUserRole();
-                    userRole.setRoleId(role.getRoleId());
-                    userRole.setUserId(c.getUserId());
-                    companyUserRoleList.add(userRole);
+                    //判断该用户角色是否存在
+                    CompanyUserRole companyUserRole = userRoleMapper.selectCompanyUserRoleById(c.getUserId());
+                    if(companyUserRole == null || !Objects.equals(companyUserRole.getRoleId(), role.getRoleId())){
+                        CompanyUserRole userRole=new CompanyUserRole();
+                        userRole.setRoleId(role.getRoleId());
+                        userRole.setUserId(c.getUserId());
+                        companyUserRoleList.add(userRole);
+                    }
                 }
 
                 //判断部门
@@ -690,13 +695,16 @@ public class CompanyUserServiceImpl implements ICompanyUserService
 
                 //判断岗位
                 if(ObjectUtil.isNotNull(companyPost)){
-                    //添加用户岗位表
-                    CompanyUserPost userPost=new CompanyUserPost();
-                    userPost.setPostId(companyPost.getPostId());
-                    userPost.setUserId(c.getUserId());
-                    companyUserPosts.add(userPost);
+                    //判断该岗位是否存在
+                    CompanyUserPost companyUserPost = userPostMapper.selectCompanyUserPostById(c.getUserId());
+                    if(companyUserPost == null || !Objects.equals(companyUserPost.getPostId(), companyPost.getPostId())){
+                        //添加用户岗位表
+                        CompanyUserPost userPost=new CompanyUserPost();
+                        userPost.setPostId(companyPost.getPostId());
+                        userPost.setUserId(c.getUserId());
+                        companyUserPosts.add(userPost);
+                    }
                 }
-
             });
 
             //批量插入角色用户中间表

+ 1 - 1
fs-service/src/main/java/com/fs/his/param/FsPackageOrderDoPayParam.java

@@ -11,5 +11,5 @@ public class FsPackageOrderDoPayParam implements Serializable {
     Long orderId;
     Long userId;
 
-    private String appId;
+    private String appId;//小程序id
 }

+ 5 - 0
fs-service/src/main/java/com/fs/his/service/IFsUserService.java

@@ -4,9 +4,11 @@ import java.math.BigDecimal;
 import java.util.List;
 import java.util.Map;
 
+import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
 import com.fs.common.core.domain.R;
 import com.fs.common.core.domain.ResponseResult;
 import com.fs.common.core.page.TableDataInfo;
+import com.fs.common.param.LoginMaWxParam;
 import com.fs.course.param.CourseAnalysisParam;
 import com.fs.course.param.newfs.FsUserCourseBeMemberParam;
 import com.fs.course.vo.newfs.FsCourseAnalysisVO;
@@ -20,6 +22,7 @@ import com.fs.his.vo.FsUserExportListVO;
 import com.fs.his.vo.FsUserFollowDoctorVO;
 import com.fs.his.vo.UserVo;
 import com.fs.hisStore.domain.FsStoreOrderScrm;
+import com.fs.hisStore.domain.FsUserScrm;
 import com.fs.hisStore.vo.FsCompanyUserListQueryVO;
 import com.fs.qw.dto.FsUserTransferParamDTO;
 import com.fs.qw.param.QwFsUserParam;
@@ -214,4 +217,6 @@ public interface IFsUserService
     List<FsCompanyUserListQueryVO> selectFsCompanyUserListQuery(FsUser fsUser);
 
     List<FsUser> getUserListLimit(FsUser fsUser);
+
+    void handleFsUserWx(FsUser user, LoginMaWxParam param, WxMaJscode2SessionResult session);
 }

+ 16 - 22
fs-service/src/main/java/com/fs/his/service/impl/FsPackageOrderServiceImpl.java

@@ -879,37 +879,30 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
             return R.error("非法操作");
         }
 
-//        FsUser user=userService.selectFsUserByUserId(param.getUserId());
-//
-//        String json = configService.selectConfigByKey("his.pay");
-//        PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
-//
-//        String openId = Objects.isNull(user) ? "" : user.getMaOpenId();
-//        if (StringUtils.isBlank(openId)){
-//            Wrapper<FsUserWx> queryWrapper = Wrappers.<FsUserWx>lambdaQuery()
-//                    .eq(FsUserWx::getFsUserId, param.getUserId())
-//                    .eq(FsUserWx::getAppId, payConfigDTO.getAppId());
-//            FsUserWx fsUserWx = fsUserWxMapper.selectOne(queryWrapper);
-//            if (Objects.nonNull(fsUserWx)){
-//                openId = fsUserWx.getOpenId();
-//            }
-//        }
-        FsUser user = userService.selectFsUserByUserId(param.getUserId());
-        //在线支付
+        FsUser user=userService.selectFsUserByUserId(param.getUserId());
+
         String json = configService.selectConfigByKey("his.pay");
         PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
-        String openId = "";
-        if (StringUtils.isNotEmpty(param.getAppId())) {
-            FsUserWx fsUserWx = userWxService.selectByAppIdAndUserId(param.getAppId(), param.getUserId(), 1);
+
+        //金牛多小程序支付
+        String openId = null;
+        String appId = param.getAppId();
+        if (StringUtils.isNotBlank(appId)) {
+            //查询fs_user_wx的openId
+            Wrapper<FsUserWx> queryWrapper = Wrappers.<FsUserWx>lambdaQuery()
+                    .eq(FsUserWx::getFsUserId, param.getUserId())
+                    .eq(FsUserWx::getAppId, appId);
+            FsUserWx fsUserWx = fsUserWxMapper.selectOne(queryWrapper);
             if (fsUserWx != null) {
                 openId = fsUserWx.getOpenId();
             }
         } else {
+            appId = payConfigDTO.getAppId();
             openId = Objects.isNull(user) ? "" : user.getMaOpenId();
             if (StringUtils.isBlank(openId)){
                 Wrapper<FsUserWx> queryWrapper = Wrappers.<FsUserWx>lambdaQuery()
                         .eq(FsUserWx::getFsUserId, param.getUserId())
-                        .eq(FsUserWx::getAppId, payConfigDTO.getAppId());
+                        .eq(FsUserWx::getAppId, appId);
                 FsUserWx fsUserWx = fsUserWxMapper.selectOne(queryWrapper);
                 if (Objects.nonNull(fsUserWx)){
                     openId = fsUserWx.getOpenId();
@@ -945,7 +938,7 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
                         WxPayConfig payConfig = new WxPayConfig();
                         SysConfig sysConfig = sysConfigMapper.selectConfigByConfigKey("his.pay");
                         FsPayConfig fsPayConfig = new Gson().fromJson(sysConfig.getConfigValue(), FsPayConfig.class);
-                        payConfig.setAppId(fsPayConfig.getAppId());
+                        payConfig.setAppId(appId);
                         payConfig.setMchId(fsPayConfig.getWxMchId());
                         payConfig.setMchKey(fsPayConfig.getWxMchKey());
                         payConfig.setSubAppId(org.apache.commons.lang3.StringUtils.trimToNull(null));
@@ -1023,6 +1016,7 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
                         o.setReqSeqId("package-"+storePayment.getPayCode());
                         o.setTransAmt(storePayment.getPayMoney().toString());
                         o.setGoodsDesc("套餐包订单支付");
+                        o.setAppId(appId);
                         HuifuCreateOrderResult result = huiFuService.createOrder(o);
                         logger.info("创建汇付支付:"+result);
                         FsStorePayment mt=new FsStorePayment();

+ 35 - 0
fs-service/src/main/java/com/fs/his/service/impl/FsUserServiceImpl.java

@@ -9,6 +9,7 @@ import java.util.*;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 
+import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
 import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
@@ -18,6 +19,7 @@ import com.fs.common.core.domain.R;
 import com.fs.common.core.domain.ResponseResult;
 import com.fs.common.core.domain.entity.SysDictData;
 import com.fs.common.core.page.TableDataInfo;
+import com.fs.common.param.LoginMaWxParam;
 import com.fs.common.utils.DateUtils;
 import com.fs.common.utils.DictUtils;
 import com.fs.common.utils.ParseUtils;
@@ -48,12 +50,14 @@ import com.fs.his.param.FsUserAddIntegralTemplateParam;
 import com.fs.his.param.FsUserParam;
 import com.fs.his.service.IFsUserIntegralLogsService;
 import com.fs.his.service.IFsUserProjectTagService;
+import com.fs.his.service.IFsUserWxService;
 import com.fs.his.vo.FsUserVO;
 import com.fs.his.vo.FsUserExportListVO;
 import com.fs.his.vo.FsUserFollowDoctorVO;
 import com.fs.his.vo.UserVo;
 import com.fs.hisStore.domain.FsStoreOrderScrm;
 import com.fs.hisStore.domain.FsUserBillScrm;
+import com.fs.hisStore.domain.FsUserScrm;
 import com.fs.hisStore.enums.BillDetailEnum;
 import com.fs.hisStore.mapper.FsStoreOrderScrmMapper;
 import com.fs.hisStore.service.IFsUserBillScrmService;
@@ -162,6 +166,9 @@ public class FsUserServiceImpl implements IFsUserService
     @Autowired
     private FsStoreOrderScrmMapper storeOrderMapper;
 
+    @Autowired
+    private IFsUserWxService fsUserWxService;
+
 
     /**
      * 查询用户
@@ -1235,4 +1242,32 @@ public class FsUserServiceImpl implements IFsUserService
         return fsUserMapper.selectFsUserListLimit(fsUser);
     }
 
+    @Override
+    public void handleFsUserWx(FsUser user, LoginMaWxParam param, WxMaJscode2SessionResult session) {
+        if (user == null) return;
+        // 尝试更新
+        boolean updated = fsUserWxService.lambdaUpdate()
+                .eq(FsUserWx::getFsUserId, user.getUserId())
+                .eq(FsUserWx::getAppId, param.getAppId())
+                .eq(FsUserWx::getOpenId, session.getOpenid())
+                .set(FsUserWx::getCompanyId, param.getCompanyId())
+                .set(FsUserWx::getUnionId, session.getUnionid() == null ? "" : session.getUnionid())
+                .set(FsUserWx::getUpdateTime, new Date())
+                .update();
+
+        // 如果更新失败(记录不存在),则插入
+        if (!updated) {
+            FsUserWx fsUserWx = new FsUserWx();
+            fsUserWx.setType(1);
+            fsUserWx.setFsUserId(user.getUserId());
+            fsUserWx.setCompanyId(param.getCompanyId());
+            fsUserWx.setAppId(param.getAppId());
+            fsUserWx.setOpenId(session.getOpenid());
+            fsUserWx.setUnionId(session.getUnionid() == null ? "" : session.getUnionid());
+            fsUserWx.setCreateTime(new Date());
+            fsUserWx.setUpdateTime(new Date());
+            fsUserWxService.save(fsUserWx);
+        }
+    }
+
 }

+ 1 - 0
fs-service/src/main/java/com/fs/huifuPay/domain/HuiFuCreateOrder.java

@@ -19,4 +19,5 @@ public class HuiFuCreateOrder {
     String transAmt;
     String goodsDesc;
     String openid;
+    String appId; //多小程序支付
 }

+ 7 - 2
fs-service/src/main/java/com/fs/huifuPay/service/impl/HuiFuServiceImpl.java

@@ -3,6 +3,7 @@ package com.fs.huifuPay.service.impl;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.fs.common.exception.CustomException;
+import com.fs.common.utils.StringUtils;
 import com.fs.common.utils.spring.SpringUtils;
 import com.fs.his.domain.FsPayConfig;
 import com.fs.huifuPay.domain.*;
@@ -58,10 +59,14 @@ public class HuiFuServiceImpl implements HuiFuService {
             extendInfoMap.put("pay_scene", "02");
             // 传入分帐遇到优惠的处理规则
             extendInfoMap.put("term_div_coupon_type", "0");
+            String appId = order.getAppId();
+            if (StringUtils.isBlank(appId)){
+                appId = config.getAppId();
+            }
             if (order.getTradeType().equals("T_MINIAPP")||order.getTradeType().equals("T_JSAPI")){
                 JSONObject dto = new JSONObject();
                 // 子商户公众账号id
-                dto.put("sub_appid", config.getAppId());
+                dto.put("sub_appid", appId);
                 // 用户标识
                 dto.put("openid", order.getOpenid());
                 extendInfoMap.put("wx_data", dto);
@@ -69,7 +74,7 @@ public class HuiFuServiceImpl implements HuiFuService {
             if (order.getTradeType().equals("T_JSAPI")){
                 JSONObject dto = new JSONObject();
                 // 子商户公众账号id
-                dto.put("sub_appid", config.getAppId());
+                dto.put("sub_appid", appId);
                 // 用户标识
                 dto.put("sub_openid", order.getOpenid());
                 extendInfoMap.put("wx_data", dto);

+ 2 - 2
fs-service/src/main/resources/application-config-druid-hyt.yml

@@ -37,8 +37,8 @@ wx:
       port: 6379
       timeout: 2000
     configs:
-      - appId:   # 第一个公众号的appid
-        secret: 1fac75465a61f9259a0fe19795d9e80d # 公众号的appsecret
+      - appId: wx9df02b2236d4fbf2 # 第一个公众号的appid
+        secret: 4f685750d40ab334b6f2f54b7d121389 # 公众号的appsecret
         token: PPKOdAlCoMO # 接口配置里的Token值
         aesKey: Eswa6VjwtVMCcw03qZy6fWllgrv5aytIA1SZPEU0kU2 # 接口配置里的EncodingAESKey值
 aifabu:  #爱链接

+ 2 - 0
fs-service/src/main/resources/application-druid-hyt-test.yml

@@ -153,3 +153,5 @@ rocketmq:
 openIM:
     secret:
     userID:
+#是否为新商户,新商户不走mpOpenId
+isNewWxMerchant: true

+ 6 - 0
fs-service/src/main/resources/application-druid-lmjy-test.yml

@@ -148,3 +148,9 @@ rocketmq:
         group: test-group
         access-key: l # 替换为实际的 accessKey
         secret-key: l # 替换为实际的 secretKey
+ipad:
+    ipadUrl:
+    aiApi:
+openIM:
+    secret:
+    userID:

+ 6 - 0
fs-service/src/main/resources/application-druid-lmjy.yml

@@ -148,3 +148,9 @@ rocketmq:
         group: test-group
         access-key: l # 替换为实际的 accessKey
         secret-key: l # 替换为实际的 secretKey
+ipad:
+    ipadUrl:
+    aiApi:
+openIM:
+    secret:
+    userID:

+ 6 - 0
fs-user-app/src/main/java/com/fs/app/controller/WxUserController.java

@@ -10,6 +10,7 @@ import com.fs.app.annotation.Login;
 import com.fs.app.utils.JwtUtils;
 import com.fs.common.core.domain.R;
 import com.fs.common.core.redis.RedisCache;
+import com.fs.common.param.LoginMaWxParam;
 import com.fs.common.param.LoginParam;
 import com.fs.common.utils.DateUtils;
 import com.fs.common.utils.IpUtil;
@@ -174,6 +175,11 @@ public class WxUserController extends AppBaseController{
             map.put("token",token);
             user.setPhone(encryptPhone(phoneNoInfo.getPhoneNumber()));
             map.put("user",user);
+            LoginMaWxParam loginMaWxParam = new LoginMaWxParam();
+            loginMaWxParam.setAppId(appId);
+            loginMaWxParam.setCompanyId(user.getCompanyId());
+
+            userService.handleFsUserWx(user,loginMaWxParam,session);
             return R.ok(map);
         } catch (WxErrorException e) {
             //this.logger.error(e.getMessage(), e);