Explorar o código

Merge branch 'master' of http://git.dongkesoft.com:9001/iBOSS-2.0-Mini/iboss-server-oauth

hongxudong hai 1 ano
pai
achega
82e7b64ab2
Modificáronse 28 ficheiros con 730 adicións e 49 borrados
  1. 27 0
      src/main/java/com/dk/oauth/config/WxConfig.java
  2. 22 0
      src/main/java/com/dk/oauth/controller/CompanyController.java
  3. 20 0
      src/main/java/com/dk/oauth/controller/oauth/AccessTokenController.java
  4. 11 3
      src/main/java/com/dk/oauth/entity/Activity.java
  5. 12 0
      src/main/java/com/dk/oauth/entity/CompanyResponse.java
  6. 10 0
      src/main/java/com/dk/oauth/entity/CompanyVO.java
  7. 40 0
      src/main/java/com/dk/oauth/entity/PublicOpenUnion.java
  8. 22 0
      src/main/java/com/dk/oauth/entity/Trade.java
  9. 20 0
      src/main/java/com/dk/oauth/entity/TradeResponse.java
  10. 14 0
      src/main/java/com/dk/oauth/entity/UserLogin.java
  11. 13 0
      src/main/java/com/dk/oauth/entity/UserWxLogin.java
  12. 7 0
      src/main/java/com/dk/oauth/mapper/CompanyMapper.java
  13. 13 0
      src/main/java/com/dk/oauth/mapper/PublicOpenUnionMapper.java
  14. 20 0
      src/main/java/com/dk/oauth/mapper/UserMapper.java
  15. 32 0
      src/main/java/com/dk/oauth/scheduled/UserInfoPublicOpenIdScheduled.java
  16. 4 0
      src/main/java/com/dk/oauth/service/IAuthAccessTokenService.java
  17. 4 0
      src/main/java/com/dk/oauth/service/ICompanyService.java
  18. 7 0
      src/main/java/com/dk/oauth/service/IPublicOpenUnionService.java
  19. 85 40
      src/main/java/com/dk/oauth/service/impl/AuthAccessTokenServiceImpl.java
  20. 77 0
      src/main/java/com/dk/oauth/service/impl/CompanyServiceImpl.java
  21. 107 0
      src/main/java/com/dk/oauth/service/impl/PublicOpenUnionService.java
  22. 10 0
      src/main/resources/dev/bootstrap.yml
  23. 7 0
      src/main/resources/mapper/ActivityMapper.xml
  24. 7 2
      src/main/resources/mapper/CompanyMapper.xml
  25. 86 0
      src/main/resources/mapper/PublicOpenUnionMapper.xml
  26. 17 0
      src/main/resources/mapper/TradeMapper.xml
  27. 27 4
      src/main/resources/mapper/UserMapper.xml
  28. 9 0
      src/main/resources/test/bootstrap.yml

+ 27 - 0
src/main/java/com/dk/oauth/config/WxConfig.java

@@ -78,5 +78,32 @@ public class WxConfig {
     @Value("${upload.path}")
     private String uploadPath;
 
+    /**
+     * @desc   : 公众号appid
+     * @author : 姜永辉
+     * @date   : 2024/07/12 9:03
+     */
+    @Value("${wx.wxPublicAccountAppId}")
+    private String wxPublicAccountAppId;
+    /**
+     * @desc   : 公众号Secret
+     * @author : 姜永辉
+     * @date   : 2024/07/12 9:03
+     */
+    @Value("${wx.wxPublicAccountAppSecret}")
+    private String wxPublicAccountAppSecret;
+
+    /**
+     * @desc   : 公众号发送消息的api
+     * @author : 姜永辉
+     * @date   : 2024/07/12 9:03
+     */
+    @Value("${wx.token}")
+    private String wechatUrlToken;
+
+    @Value("${wx.user_public_openid}")
+    private String userPublicOpenid;
 
+    @Value("${wx.user_info_public_unionid}")
+    private String userInfoPublicUnionid;
 }

+ 22 - 0
src/main/java/com/dk/oauth/controller/CompanyController.java

@@ -115,6 +115,17 @@ public class CompanyController {
     }
 
     /**
+     * @desc   : 功能包保存
+     * @author : jyh
+     * @date   : 2024/5/17 14:55
+     */
+    @ApiOperation( value = "功能包保存", notes = "功能包保存" )
+    @PostMapping(value = "/save_func")
+    public ResponseResultVO<?> saveFunc(@RequestBody CompanyVO companyVO) {
+        return companyService.saveFunc(companyVO);
+    }
+
+    /**
      * @desc   : 保存功能频率
      * @author : admin
      * @date   : 2024/3/28 14:55
@@ -135,4 +146,15 @@ public class CompanyController {
     public ResponseResultVO<?> getComMenu(@PathVariable String gradeCode) {
         return companyService.getComMenu(gradeCode);
     }
+
+    /**
+     * @desc   : 商户负责人转让
+     * @author : 刘尧
+     * @date   : 2024/6/21 09:35
+     */
+    @ApiOperation( value = "商户负责人转让", notes = "商户负责人转让")
+    @PostMapping(value = "/transfer_head")
+    public ResponseResultVO transferHead(@RequestBody Map<String, Object> params){
+        return companyService.transferHead(params);
+    }
 }

+ 20 - 0
src/main/java/com/dk/oauth/controller/oauth/AccessTokenController.java

@@ -213,4 +213,24 @@ public class AccessTokenController {
         return authAccessTokenService.logout(userLogin);
     }
 
+    /**
+     * @desc : 获取公司的所有者的数量
+     * @author : jyh
+     * @date : 2023/1/5 10:09
+     */
+    @PostMapping("/oauth/wx/get_owner_count")
+    public ResponseResultVO getOwnerCount(@RequestBody UserWxLogin userLogin) {
+        return authAccessTokenService.getOwnerCount(userLogin.getUserId());
+    }
+
+    /**
+     * @desc   : 查询微信登录用户信息
+     * @author : 宋扬
+     * @date   : 2024/3/1 16:01
+     */
+    @PostMapping({"/oauth/wx/get_user/{userId}"})
+    public ResponseResultVO getUser(@PathVariable String userId) {
+        return authAccessTokenService.getUser(userId);
+    }
+
 }

+ 11 - 3
src/main/java/com/dk/oauth/entity/Activity.java

@@ -157,14 +157,22 @@ public class Activity extends PageInfo<ActivityResponse> implements Serializable
     private String gradeCode;
 
     /**
-     * 系统版本
+     * 功能
      */
-    @Excel(name = "系统版本")
-    @ApiModelProperty(value = "系统版本")
+    @Excel(name = "功能")
+    @ApiModelProperty(value = "功能")
     @TableField(typeHandler = UuidTypeHandler.class)
     private String funUuid;
 
     /**
+     * 功能包
+     */
+    @Excel(name = "功能包")
+    @ApiModelProperty(value = "功能包")
+    @TableField(typeHandler = UuidListTypeHandler.class)
+    private List<String> funUuids;
+
+    /**
      * 投放企业
      */
     @Excel(name = "投放企业")

+ 12 - 0
src/main/java/com/dk/oauth/entity/CompanyResponse.java

@@ -2,12 +2,15 @@ package com.dk.oauth.entity;
 
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.dk.common.infrastructure.handler.TimestampTypeHandler;
+import com.dk.common.infrastructure.handler.UuidTypeHandler;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import cn.afterturn.easypoi.excel.annotation.Excel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 import java.time.LocalDate;
+import java.util.List;
+import java.util.Map;
 
 /**
  * @author : 周兴
@@ -35,6 +38,8 @@ public class CompanyResponse {
 
     private String cpPhone;
 
+    private List<Map<String,Object>> funPackage;
+
     private Boolean vip;
 
     // 交易记录
@@ -55,6 +60,13 @@ public class CompanyResponse {
     private LocalDate userEndDate;
 
     /**
+     * 所有者 (t_wx_user)
+     */
+    @ApiModelProperty(value = "所有者 (t_wx_user)")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String owner;
+
+    /**
      * 人数上限 (可以绑定微信的员工人数)
      */
     @ApiModelProperty(value = "人数上限 (可以绑定微信的员工人数)")

+ 10 - 0
src/main/java/com/dk/oauth/entity/CompanyVO.java

@@ -22,6 +22,8 @@ import java.io.Serializable;
 import java.math.BigDecimal;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
+import java.util.List;
+import java.util.Map;
 
 /**
  * 企业
@@ -338,6 +340,14 @@ public class CompanyVO extends PageInfo<CompanyVO> implements Serializable {
      */
     private Boolean vip;
 
+    /**
+     * @desc   : 功能包
+     * @author : 姜永辉
+     * @date   : 2024/07/03 14:33
+     */
+    private List<Map<String,Object>> funPackage;
+
+
     /*
      * 相关属性
      * @TableField(exist = false)

+ 40 - 0
src/main/java/com/dk/oauth/entity/PublicOpenUnion.java

@@ -0,0 +1,40 @@
+package com.dk.oauth.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.dk.common.infrastructure.annotaiton.ExportTitle;
+import com.dk.common.infrastructure.handler.UuidTypeHandler;
+import com.dk.common.model.pojo.PageInfo;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * @author : 姜永辉
+ * @desc : 公众号的openid和unionid
+ * @date : 2023/10/24 11:34
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@EqualsAndHashCode(callSuper = true)
+@Accessors(chain = true)
+@ExportTitle("微信公众号关联")
+@TableName(value = "t_wx_public_open_union", autoResultMap = true, schema = "dkic_a")
+@ApiModel(value = "微信公众号关联", description = "表名:t_wx_public_open_union")
+public class PublicOpenUnion extends PageInfo<PublicOpenUnion> implements Serializable {
+    /**
+     * ID
+     */
+    @ApiModelProperty(value = "ID")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String id;
+    private String publicUnionId; // 公众号unionid
+    private String publicOpenId;// 公众号openid
+}

+ 22 - 0
src/main/java/com/dk/oauth/entity/Trade.java

@@ -156,6 +156,28 @@ public class Trade  extends PageInfo<Trade> implements Serializable {
      */
     private String tradeStatus;
 
+    /**
+     * @desc   : 活动Id
+     */
+    @ApiModelProperty(value = "活动Id")
+    @Excel(name = "活动Id")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String activityId;
+
+    /**
+     * @desc   : 活动明细Id
+     */
+    @ApiModelProperty(value = "活动明细Id")
+    @Excel(name = "活动明细Id")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String activityItemId;
+
+
+    /**
+     * @desc   : 交易描述
+     */
+    private String tradeDesc;
+
     /*
      * 相关属性
      * @TableField(exist = false)

+ 20 - 0
src/main/java/com/dk/oauth/entity/TradeResponse.java

@@ -134,4 +134,24 @@ public class TradeResponse   {
      */
     private String tradeStatus;
 
+    /**
+     * @desc   : 活动Id
+     */
+    @ApiModelProperty(value = "活动Id")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String activityId;
+
+    /**
+     * @desc   : 活动明细Id
+     */
+    @ApiModelProperty(value = "活动明细Id")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String activityItemId;
+
+
+    /**
+     * @desc   : 交易描述
+     */
+    private String tradeDesc;
+
 }

+ 14 - 0
src/main/java/com/dk/oauth/entity/UserLogin.java

@@ -93,6 +93,20 @@ public class UserLogin extends PageInfo<UserLogin> implements Serializable {
     private String tokenKey;
 
     /**
+     * 微信UnionID
+     */
+    @Excel(name = "微信UnionID")
+    @ApiModelProperty(value = "微信UnionID")
+    private String unionId;
+
+    /**
+     * 公账号openid
+     */
+    @Excel(name = "公账号openid")
+    @ApiModelProperty(value = "公账号openid")
+    private String publicOpenId;
+
+    /**
      * 更新时间
      */
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")

+ 13 - 0
src/main/java/com/dk/oauth/entity/UserWxLogin.java

@@ -1,5 +1,6 @@
 package com.dk.oauth.entity;
 
+import cn.afterturn.easypoi.excel.annotation.Excel;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
@@ -40,4 +41,16 @@ public class UserWxLogin {
     @ApiModelProperty(value = "加入的公司")
     @TableField(typeHandler = IntListTypeHandler.class)
     private List<Integer> joinedCps;
+
+    /**
+     * 微信UnionID
+     */
+    @ApiModelProperty(value = "微信UnionID")
+    private String unionId;
+
+    /**
+     * 公账号openid
+     */
+    @ApiModelProperty(value = "公账号openid")
+    private String publicOpenId;
 }

+ 7 - 0
src/main/java/com/dk/oauth/mapper/CompanyMapper.java

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * @author : 洪旭东
@@ -71,4 +72,10 @@ public interface CompanyMapper extends BaseMapper<Company> {
      */
     int updateCompanyLicense(Company Company);
 
+    /**
+     * @desc : 更新企业所有者信息
+     * @author : 刘尧
+     * @date : 2024-06-21 10:51
+     */
+    boolean updateOwner(Map<String,Object> company);
 }

+ 13 - 0
src/main/java/com/dk/oauth/mapper/PublicOpenUnionMapper.java

@@ -0,0 +1,13 @@
+package com.dk.oauth.mapper;
+
+import com.dk.common.mapper.BaseMapper;
+import com.dk.oauth.entity.PublicOpenUnion;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface PublicOpenUnionMapper extends BaseMapper<PublicOpenUnion> {
+    PublicOpenUnion selectByOpenId(@Param("publicOpenId") String publicOpenId);
+
+    PublicOpenUnion selectByUnionId(@Param("publicUnionId") String publicUnionId);
+}

+ 20 - 0
src/main/java/com/dk/oauth/mapper/UserMapper.java

@@ -52,6 +52,13 @@ public interface UserMapper  extends BaseMapper<UserLogin> {
     int updateWxid(@Param("userId") String userId, @Param("userWxid") String userWxid);
 
     /**
+     * @desc : 通过id更新unionId
+     * @author : 洪旭东
+     * @date : 2024-02-20 14:12
+     */
+    int updateWxUnionid(@Param("userId") String userId, @Param("unionId") String unionId, @Param("publicOpenId") String publicOpenId);
+
+    /**
      * @desc : 通过id更新手机号
      * @author : 洪旭东
      * @date : 2024-02-20 14:12
@@ -99,4 +106,17 @@ public interface UserMapper  extends BaseMapper<UserLogin> {
      * @date : 2023/2/7 14:45
      */
     Map<String, Object> selectUserLogin(@Param("userId") String userId,String appCode);
+
+    /**
+     * @desc : 通过商户号注销当前负责人
+     * @author : 刘尧
+     * @date : 2024/6/21 10:21
+     */
+    boolean updateFlgInit(Map<String, Object> company);
+    /**
+     * @desc : 通过用户id更新负责人
+     * @author : 刘尧
+     * @date : 2024/6/21 10:43
+     */
+    boolean updateFlgInitById(@Param("userId")String newHeadId);
 }

+ 32 - 0
src/main/java/com/dk/oauth/scheduled/UserInfoPublicOpenIdScheduled.java

@@ -0,0 +1,32 @@
+package com.dk.oauth.scheduled;
+
+import com.dk.oauth.service.IPublicOpenUnionService;
+import com.dk.oauth.service.impl.PublicOpenUnionService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+/**
+ * @desc   : 定时任务
+ * @author : 姜永辉
+ * @date   : 2023/10/24 13:31
+ */
+@Slf4j
+@Component
+public class UserInfoPublicOpenIdScheduled {
+    @Autowired
+    IPublicOpenUnionService service;
+
+    // 添加定时任务 每天凌晨 1 点执行一次
+    @Scheduled(cron = "0 0 1 * * ?")
+    public void updateUserPublicOpenIds(){
+        log.info("准备获取微信公账号的openid");
+        try {
+            service.updateUserPublicOpenIds();
+        }catch (Exception e){
+            log.info("获取微信公账号的openid异常" + e.getMessage());
+        }
+        log.info("准备获取微信公账号的openid完成");
+    }
+}

+ 4 - 0
src/main/java/com/dk/oauth/service/IAuthAccessTokenService.java

@@ -47,4 +47,8 @@ public interface IAuthAccessTokenService extends IService<AuthAccessToken> {
     ResponseResultVO<?> getWxQrCode(Map<String,Object> map);
 
     ResponseResultVO logout(UserWxLogin userWxLogin);
+
+    ResponseResultVO<?> getOwnerCount(String uuid);
+
+    ResponseResultVO<?> getUser(String userId);
 }

+ 4 - 0
src/main/java/com/dk/oauth/service/ICompanyService.java

@@ -21,6 +21,8 @@ public interface ICompanyService  extends IService<Company> {
 
     ResponseResultVO reNewCompany(CompanyVO companyVO);
 
+    ResponseResultVO saveFunc(CompanyVO companyVO);
+
     ResponseResultVO selectById(Integer id);
 
     ResponseResultVO updateWxUserCompany(Map<String,Object> map);
@@ -36,4 +38,6 @@ public interface ICompanyService  extends IService<Company> {
     ResponseResultVO updateCompanyCurStaffNum(Map<String,Object> map);
 
     ResponseResultVO getComMenu(String gradeCode);
+
+    ResponseResultVO transferHead(Map<String, Object> params);
 }

+ 7 - 0
src/main/java/com/dk/oauth/service/IPublicOpenUnionService.java

@@ -0,0 +1,7 @@
+package com.dk.oauth.service;
+
+import com.dk.common.response.ResponseResultVO;
+
+public interface IPublicOpenUnionService {
+    public ResponseResultVO updateUserPublicOpenIds() ;
+}

+ 85 - 40
src/main/java/com/dk/oauth/service/impl/AuthAccessTokenServiceImpl.java

@@ -20,10 +20,7 @@ import com.dk.oauth.config.WxConfig;
 import com.dk.oauth.dto.AuthAccessTokenDto;
 import com.dk.oauth.entity.*;
 import com.dk.oauth.feign.service.StaffFeign;
-import com.dk.oauth.mapper.AuthAccessTokenMapper;
-import com.dk.oauth.mapper.CompanyMapper;
-import com.dk.oauth.mapper.TradeMapper;
-import com.dk.oauth.mapper.UserMapper;
+import com.dk.oauth.mapper.*;
 import com.dk.oauth.service.IAuthAccessTokenService;
 import com.dk.oauth.shiro.jwt.JWTGenerator;
 import com.dk.oauth.util.AESSecurityUtil;
@@ -83,6 +80,9 @@ public class AuthAccessTokenServiceImpl extends ServiceImpl<AuthAccessTokenMappe
     @Autowired
     private TradeMapper tradeMapper;
 
+    @Autowired
+    private PublicOpenUnionMapper publicOpenUnionMapper;
+
     @Resource
     private StaffFeign staffFeign;
 
@@ -146,7 +146,7 @@ public class AuthAccessTokenServiceImpl extends ServiceImpl<AuthAccessTokenMappe
         try {
             // 设置应用代码
             userLogin.setAppCode(Constant.AppCode.WEB.getCode());
-            return createToken(userLogin,true);
+            return createToken(userLogin, true);
         } catch (Exception e) {
             log.error("获取accessToken发生异常=", e);
             return ResponseResultUtil.error(HttpServletResponse.SC_BAD_REQUEST, e.getMessage());
@@ -163,15 +163,25 @@ public class AuthAccessTokenServiceImpl extends ServiceImpl<AuthAccessTokenMappe
         // todo
 //        userWxLogin.setUserWxid("1");
         UserLogin userLogin = userMapper.getByWxid(userWxLogin.getUserWxid());
-            if (userLogin == null) {
-                //无用户
-                return ResponseResultUtil.error(ErrorCodeEnum.USER_NOT_EXIST.getCode(), ErrorCodeEnum.USER_NOT_EXIST.getMessage());
-            }
-            userLogin.checkUserLogin();
-            try {
-                // 设置应用代码
-                userLogin.setAppCode(Constant.AppCode.WEIXIN.getCode());
-            return createToken(userLogin,true);
+        if (userLogin == null) {
+            //无用户
+            return ResponseResultUtil.error(ErrorCodeEnum.USER_NOT_EXIST.getCode(), ErrorCodeEnum.USER_NOT_EXIST.getMessage());
+        }
+        // 判断 unionid是否为空 如果为空更新unionid  231023
+        if ((userLogin.getUnionId() == null || userLogin.getPublicOpenId() == null) && userWxLogin.getUnionId()!=null) {
+            // 查询已经 获取的unionid
+            PublicOpenUnion publicOpenUnion = publicOpenUnionMapper.selectByUnionId(userWxLogin.getUnionId());
+            String publicOpenId = (publicOpenUnion == null ? null : publicOpenUnion.getPublicOpenId());
+            //通过手机号查到了用户,但是openid是空,更新上当前的openid
+            userMapper.updateWxUnionid(userLogin.getUserId(), userWxLogin.getUnionId(),publicOpenId);
+            userLogin.setUnionId(userWxLogin.getUnionId());
+            userLogin.setPublicOpenId(publicOpenId);
+        }
+        userLogin.checkUserLogin();
+        try {
+            // 设置应用代码
+            userLogin.setAppCode(Constant.AppCode.WEIXIN.getCode());
+            return createToken(userLogin, true);
         } catch (Exception e) {
             log.error("获取accessToken发生异常=", e);
             return ResponseResultUtil.error(HttpServletResponse.SC_BAD_REQUEST, e.getMessage());
@@ -221,32 +231,36 @@ public class AuthAccessTokenServiceImpl extends ServiceImpl<AuthAccessTokenMappe
             if (company != null) {
                 // 解析license信息
                 String licenseStr = AESUtil.desEncrypt(company.getLicense());
-                if(licenseStr != null ){
-                    Map<String,Object> licenseMap = JSON.parseObject(licenseStr,Map.class);
+                if (licenseStr != null) {
+                    Map<String, Object> licenseMap = JSON.parseObject(licenseStr, Map.class);
                     LocalDate endDate = LocalDate.parse(licenseMap.get("end_date").toString());
                     // 判断是否到期
                     LocalDate nowDate = LocalDate.now();
-                    if(endDate.isBefore(nowDate)){
+                    if (endDate.isBefore(nowDate)) {
                         return ResponseResultUtil.error(ErrorCodeEnum.LICENSE_OVER_DATE.getCode(), ErrorCodeEnum.LICENSE_OVER_DATE.getMessage());
                     }
-                    if(licenseMap.get("web_max_num") != null){
+                    if (licenseMap.get("web_max_num") != null) {
                         company.setWebMaxNum(Integer.parseInt(licenseMap.get("web_max_num").toString()));
                     }
-                    if(licenseMap.get("wx_max_num") != null){
+                    if (licenseMap.get("wx_max_num") != null) {
                         company.setWxMaxNum(Integer.parseInt(licenseMap.get("wx_max_num").toString()));
                     }
                     company.setEndDate(endDate);
-                    if(licenseMap.get("user_end_date") != null){
+                    if (licenseMap.get("user_end_date") != null) {
                         company.setUserEndDate(LocalDate.parse(licenseMap.get("user_end_date").toString()));
                     }
-                    if(licenseMap.get("vip") != null){
+                    if (licenseMap.get("vip") != null) {
                         company.setVip(Boolean.parseBoolean(licenseMap.get("vip").toString()));
                     }
+                    if (licenseMap.get("fun_package") != null) {
+//                        company.setFunPackage(JSON.parseArray(JSON.toJSONString(licenseMap.get("fun_package")),Activity.class));
+                        company.setFunPackage((List<Map<String, Object>>) licenseMap.get("fun_package"));
+                    }
                     company.setGradeCode(licenseMap.get("grade_code").toString());
-                }else{
+                } else {
                     // 获取最近一次的交易记录
                     List<TradeResponse> tradeResponses = tradeMapper.selectTrade(new Trade().setCpId(company.getCpId()));
-                    if(tradeResponses != null && tradeResponses.size() >0){
+                    if (tradeResponses != null && tradeResponses.size() > 0) {
                         company.setTrade(tradeResponses.get(0));
                     }
                 }
@@ -300,8 +314,7 @@ public class AuthAccessTokenServiceImpl extends ServiceImpl<AuthAccessTokenMappe
         UserLoginSuccess userLoginSuccess = new UserLoginSuccess()
                 .setByUserLogin(userLogin)
                 .setAccessToken(accessToken)
-                .setCompany(company)
-                ;
+                .setCompany(company);
 
         return ResponseResultUtil.success(userLoginSuccess);
     }
@@ -426,7 +439,7 @@ public class AuthAccessTokenServiceImpl extends ServiceImpl<AuthAccessTokenMappe
 
         userLogin.checkUserLogin();
         try {
-            return createToken(userLogin,false);
+            return createToken(userLogin, false);
         } catch (Exception e) {
             log.error("获取accessToken发生异常=", e);
             return ResponseResultUtil.error(HttpServletResponse.SC_BAD_REQUEST, e.getMessage());
@@ -440,7 +453,9 @@ public class AuthAccessTokenServiceImpl extends ServiceImpl<AuthAccessTokenMappe
      */
     @Transactional(rollbackFor = Exception.class)
     public ResponseResultVO logout(UserWxLogin userWxLogin) {
-        userMapper.updateWxid(userWxLogin.getUserId(), null);
+//        userMapper.updateWxid(userWxLogin.getUserId(), null);
+//        更新cpid为空 240701
+        userMapper.updateCpid(userWxLogin.getUserId(), null, null);
         return ResponseResultUtil.success();
     }
 
@@ -460,7 +475,7 @@ public class AuthAccessTokenServiceImpl extends ServiceImpl<AuthAccessTokenMappe
             }
             userLogin.checkUserLogin();
             try {
-                return createToken(userLogin,false);
+                return createToken(userLogin, false);
             } catch (OAuthSystemException e) {
                 e.printStackTrace();
                 log.error("获取accessToken发生异常=", e);
@@ -539,7 +554,7 @@ public class AuthAccessTokenServiceImpl extends ServiceImpl<AuthAccessTokenMappe
      * @author : 洪旭东
      * @date : 2024-02-20 10:31
      */
-    private ResponseResultVO<?> createToken(UserLogin userLogin,Boolean checkOverDate) throws OAuthSystemException {
+    private ResponseResultVO<?> createToken(UserLogin userLogin, Boolean checkOverDate) throws OAuthSystemException {
         String clientId = "dkic";
         AuthAccessToken authAccessToken = new AuthAccessToken();
 
@@ -559,34 +574,38 @@ public class AuthAccessTokenServiceImpl extends ServiceImpl<AuthAccessTokenMappe
             if (company != null) {
                 // 解析license信息
                 String licenseStr = AESUtil.desEncrypt(company.getLicense());
-                if(licenseStr != null ){
-                    Map<String,Object> licenseMap = JSON.parseObject(licenseStr,Map.class);
+                if (licenseStr != null) {
+                    Map<String, Object> licenseMap = JSON.parseObject(licenseStr, Map.class);
                     LocalDate endDate = LocalDate.parse(licenseMap.get("end_date").toString());
-                    if(checkOverDate){
+                    if (checkOverDate) {
                         // 判断是否到期
                         LocalDate nowDate = LocalDate.now();
-                        if(endDate.isBefore(nowDate)){
-                            return ResponseResultUtil.error(ErrorCodeEnum.LICENSE_OVER_DATE.getCode(), ErrorCodeEnum.LICENSE_OVER_DATE.getMessage());
+                        if (endDate.isBefore(nowDate)) {
+                            return ResponseResultUtil.error(ErrorCodeEnum.LICENSE_OVER_DATE.getCode(), ErrorCodeEnum.LICENSE_OVER_DATE.getMessage(), userLogin);
                         }
                     }
-                    if(licenseMap.get("web_max_num") != null){
+                    if (licenseMap.get("web_max_num") != null) {
                         company.setWebMaxNum(Integer.parseInt(licenseMap.get("web_max_num").toString()));
                     }
-                    if(licenseMap.get("wx_max_num") != null){
+                    if (licenseMap.get("wx_max_num") != null) {
                         company.setWxMaxNum(Integer.parseInt(licenseMap.get("wx_max_num").toString()));
                     }
                     company.setEndDate(endDate);
-                    if(licenseMap.get("user_end_date") != null){
+                    if (licenseMap.get("user_end_date") != null) {
                         company.setUserEndDate(LocalDate.parse(licenseMap.get("user_end_date").toString()));
                     }
-                    if(licenseMap.get("vip") != null){
+                    if (licenseMap.get("vip") != null) {
                         company.setVip(Boolean.parseBoolean(licenseMap.get("vip").toString()));
                     }
+                    if (licenseMap.get("fun_package") != null) {
+//                        company.setFunPackage(JSON.parseArray(JSON.toJSONString(licenseMap.get("fun_package")),Activity.class));
+                        company.setFunPackage((List<Map<String, Object>>) licenseMap.get("fun_package"));
+                    }
                     company.setGradeCode(licenseMap.get("grade_code").toString());
-                }else{
+                } else {
                     // 获取最近一次的交易记录
                     List<TradeResponse> tradeResponses = tradeMapper.selectTrade(new Trade().setCpId(company.getCpId()));
-                    if(tradeResponses != null && tradeResponses.size() >0){
+                    if (tradeResponses != null && tradeResponses.size() > 0) {
                         company.setTrade(tradeResponses.get(0));
                     }
                 }
@@ -756,4 +775,30 @@ public class AuthAccessTokenServiceImpl extends ServiceImpl<AuthAccessTokenMappe
         return base + "/";
     }
 
+
+    /**
+     * @desc : 获取公司的所有者的数量
+     * @author : jyh
+     * @date : 2024-02-20 17:00
+     */
+    public ResponseResultVO<?> getOwnerCount(String uuid) {
+        Company company = new Company().setOwner(uuid).setFlgValid(true);
+        List<Company> companies = companyMapper.selectByCond(company);
+        int count = (companies != null && companies.size() > 0) ? companies.size() : 0;
+        return ResponseResultUtil.success(count);
+    }
+
+    /**
+     * @desc : 查询微信登录用户信息
+     * @author : jyh
+     * @date : 2024-02-20 17:00
+     */
+    public ResponseResultVO<?> getUser(String userId) {
+        UserLogin userLogin = userMapper.getByWxid(userId);
+        Map<String, Object> map = new HashMap<>();
+        map.put("publicOpenId",userLogin.getPublicOpenId());
+        return ResponseResultUtil.success(map);
+    }
+
+
 }

+ 77 - 0
src/main/java/com/dk/oauth/service/impl/CompanyServiceImpl.java

@@ -1,6 +1,7 @@
 package com.dk.oauth.service.impl;
 
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.dk.common.exception.BaseBusinessException;
 import com.dk.common.infrastructure.constant.Constant;
@@ -13,6 +14,7 @@ import com.dk.common.response.ResponseCodeEnum;
 import com.dk.common.response.ResponseResultUtil;
 import com.dk.common.response.ResponseResultVO;
 import com.dk.common.util.AESUtil;
+import com.dk.common.util.HaipHttpUtils;
 import com.dk.oauth.convert.CompanyConvert;
 import com.dk.oauth.entity.*;
 import com.dk.oauth.feign.service.OrgFeign;
@@ -507,6 +509,48 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
     }
 
     /**
+     * @desc : 功能包保存
+     * @author : 姜永辉
+     * @date : 2024-05-17 13:55
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public ResponseResultVO saveFunc(CompanyVO companyVO) {
+        // 转实体
+        Company company = companyConvert.convertToPo(companyVO);
+        // 生成临时license授权
+        Map<String, Object> licenseMap = new HashMap<>();
+        licenseMap.put("grade_code", company.getGradeCode());
+        licenseMap.put("end_date", company.getEndDate());
+        licenseMap.put("user_end_date", companyVO.getUserEndDate());
+        licenseMap.put("web_max_num", companyVO.getWebMaxNum());
+        licenseMap.put("wx_max_num", companyVO.getWxMaxNum());
+        licenseMap.put("vip", companyVO.getVip());
+        licenseMap.put("fun_package", companyVO.getFunPackage() );
+        company.setLicenseSocial(AESUtil.aesEncrypt(JSON.toJSONString(licenseMap)));
+        companyMapper.updateById(company);
+        // 生成交易记录
+        Trade trade = new Trade();
+        trade.setTradeNo(companyVO.getTradeNo());
+        trade.setCpId(companyVO.getCpId());
+        trade.setWxUserId(companyVO.getWxUserId());
+        trade.setTradeAmount(companyVO.getTradeAmount());
+        trade.setTradeType(Constant.TradeType.FUNTION.getName());
+        trade.setBuyLong(companyVO.getBuyLong());
+        trade.setBuyBeginDate(companyVO.getBuyBeginDate());
+        trade.setBuyEndDate(companyVO.getBuyEndDate());
+        trade.setExtendDays(companyVO.getExtendDays());
+        trade.setBuyGradeCode(companyVO.getGradeCode());
+        trade.setTradeStatus(Constant.TradeStatus.INEFFECTIVE.getName());
+        trade.setActivityId(companyVO.getActivityId());
+        trade.setActivityItemId(companyVO.getActivityItemId());
+        trade.setTradeDesc(companyVO.getRemarks());
+        //积分 后期要加字段
+
+        tradeMapper.insert(trade);
+        return ResponseResultUtil.success(trade);
+    }
+
+    /**
      * @desc : 保存用户功能频率表
      * @author : 周兴
      * @date : 2024/3/28 9:39
@@ -536,4 +580,37 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
         List<ComMenu> comMenus = comMenuMapper.selectByCond(new ComMenu().setGradeCode(gradeCode));
         return ResponseResultUtil.success(comMenus);
     }
+
+    @Autowired
+    private HaipHttpUtils haipHttpUtils;
+
+    /**
+     * @desc   : 商户负责人转让
+     * @author : 刘尧
+     * @date   : 2024/6/21 09:35
+     */
+    @Override
+    public ResponseResultVO transferHead(Map<String,Object> params) {
+
+//        HaipHttpUtils haipHttpUtils = new HaipHttpUtils();
+
+        String requestUrl = "http://" + params.get("svcIp") + ":"+ params.get("svcPort") +"/"
+                + Constant.MDM_PREFIX
+                + Constant.SERVER + "-"
+                + params.get("svcCode")
+                + Constant.MST_STAFF
+                + "/update_flgInit";
+        JSONObject JsonObject = haipHttpUtils.doPostRequest(requestUrl, params, String.valueOf(params.get("svcIp")), String.valueOf(params.get("svcPort")));
+        // 如果没有成功返回
+        if (JsonObject.get("code") == null || !ResponseCodeEnum.SUCCESS.getCode().equals(JsonObject.get("code"))){
+            return ResponseResultUtil.error();
+        }else{
+            boolean b = companyMapper.updateOwner(params);
+            if (b) {
+                return ResponseResultUtil.success(200, "更新成功");
+            }else {
+                return ResponseResultUtil.error();
+            }
+        }
+    }
 }

+ 107 - 0
src/main/java/com/dk/oauth/service/impl/PublicOpenUnionService.java

@@ -0,0 +1,107 @@
+package com.dk.oauth.service.impl;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.dk.common.exception.BaseBusinessException;
+import com.dk.common.mapper.BaseMapper;
+import com.dk.common.response.ResponseCodeEnum;
+import com.dk.common.response.ResponseResultUtil;
+import com.dk.common.response.ResponseResultVO;
+import com.dk.common.util.HttpUtils;
+import com.dk.oauth.config.WxConfig;
+import com.dk.oauth.entity.PublicOpenUnion;
+import com.dk.oauth.mapper.PublicOpenUnionMapper;
+import com.dk.oauth.service.IPublicOpenUnionService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.HashMap;
+
+/**
+ * 公众号unionid和公众号openid API接口
+ *
+ * @author admin
+ * @since 2023-07-01 09:41:05
+ */
+@Transactional
+@Slf4j
+@Service("publicOpenUnionService")
+public class PublicOpenUnionService extends ServiceImpl<PublicOpenUnionMapper,
+            PublicOpenUnion> implements IPublicOpenUnionService {
+    @Autowired
+    private PublicOpenUnionMapper publicOpenUnionMapper;
+
+    @Autowired
+    private WxConfig config;
+
+    /**
+     * @author : jyh
+     * @date : 2023-10-11 16:23
+     * @desc : 调用中控服务获取公众号的token
+     */
+    public String getWxPublicAccountToken() {
+        ResponseResultVO<JSONObject> res = HttpUtils.post(config.getWechatUrlToken(),
+                new HashMap() {{
+                    put("appId", config.getWxPublicAccountAppId());
+                    put("appSecret", config.getWxPublicAccountAppSecret());
+                }});
+        if (res.getCode() == 200 && JSON.parseObject(JSON.toJSONString(res.getData())).get("code").toString().equals("200")) {
+            return JSON.parseObject(JSON.toJSONString(res.getData())).get("data").toString();
+        } else {
+            throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), res.getMessage());
+        }
+    }
+
+
+    /**
+     * @desc : 准备获取微信公账号的openid unionid
+     * @author : 姜永辉
+     * @date : 2023/10/24 13:34
+     */
+    public ResponseResultVO updateUserPublicOpenIds() {
+        // 3.获取token 231011
+        String token = this.getWxPublicAccountToken();
+        log.info("当前微信公账号-----token:{}", token);
+        String nextOpenid = "";
+        ResponseResultVO<JSONObject> res = HttpUtils.post(config.getUserPublicOpenid() + token + "&next_openid="
+                + nextOpenid, null);
+        if (res.getCode() == ResponseCodeEnum.SUCCESS.getCode()  ) {
+            log.info("获取用户列表成功:{}", res);
+            JSONArray array = res.getData().getJSONObject("data").getJSONArray("openid");
+            if (array != null && array.size() > 0) {
+                String openid = "";
+                for (int i = 0; i < array.size(); i++) {
+                    openid = array.get(i).toString();
+                    nextOpenid = openid;
+                    // 查询数据库里是否有openid
+                    PublicOpenUnion pou = publicOpenUnionMapper.selectByOpenId(openid);
+                    if (pou != null) {
+                        continue;
+                    }
+                    // 获取用户基本信息(包括UnionID机制)
+                    ResponseResultVO<JSONObject> resUnionid = HttpUtils.post(config.getUserInfoPublicUnionid() +
+                            token + "&openid=" + openid + "&lang=zh_CN", null);
+                    if (resUnionid.getCode() == ResponseCodeEnum.SUCCESS.getCode() ) {
+                        log.info("获取用户基本信息(包括UnionID机制):{}", resUnionid);
+                        String unionid = resUnionid.getData().getString("unionid");
+                        PublicOpenUnion publicOpenUnion = new PublicOpenUnion();
+                        publicOpenUnion.setPublicOpenId(openid);
+                        publicOpenUnion.setPublicUnionId(unionid);
+                        publicOpenUnionMapper.insert(publicOpenUnion);
+                    } else {
+                        log.error("获取用户基本信息(包括UnionID机制)失败:{}", resUnionid.getData().toJSONString());
+                    }
+                }
+            }
+
+            return ResponseResultUtil.success();
+        } else {
+            log.error("获取用户列表失败:{}", res.getData().toJSONString());
+            return ResponseResultUtil.error(res.getData().toJSONString());
+        }
+    }
+}

+ 10 - 0
src/main/resources/dev/bootstrap.yml

@@ -97,6 +97,16 @@ wx:
   offiAccountAppId: wx6bb9335b534f7b28
   offiAccountAppSecret: 78a99837c113756599d1748b813ca698
   unlimitedQRCode: https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=
+  # 公众号发送消息的api-对应获取token
+  token: http://ibossmp.dongkesoft.com:9000/get_access_token
+  # 公众号的appid appSecret 东科软件 公众号
+  wxPublicAccountAppId: wx6bb9335b534f7b28
+  wxPublicAccountAppSecret: 78a99837c113756599d1748b813ca698
+  # 公众号可通过本接口来获取账号的关注者列表 231024
+  user_public_openid: https://api.weixin.qq.com/cgi-bin/user/get?access_token=
+  # 可通过OpenID来获取用户基本信息 获取用户基本信息(包括UnionID机制) 231024
+  user_info_public_unionid: https://api.weixin.qq.com/cgi-bin/user/info?access_token=
+
   # 支付的信息240327 从mdm迁移过来的
   pay:
     # 商户号 微信支付

+ 7 - 0
src/main/resources/mapper/ActivityMapper.xml

@@ -75,6 +75,13 @@
             ti.wx_price  AS "wxPrice",
             ti.valid_long  AS "validLong",
             ti.extra_long AS "extraLong",
+            T.fun_ids  AS "funUuids",
+            (SELECT json_agg(t.*)  from dkic_a.t_cp_trade t
+            where activity_id = ti.activity_id
+              and activity_item_id = ti.item_id
+               and trade_status = '交易状态-生效'
+                and cp_id = #{cpId} ) AS "trade",
+            (SELECT json_agg(m.*)  from sys.t_app_menu m where fun_uuid = ANY(T.fun_ids::uuid[])) AS "funIds",
             T.activity_type AS "activityType"
         FROM
             dkic_a.t_mst_activity_item ti

+ 7 - 2
src/main/resources/mapper/CompanyMapper.xml

@@ -24,6 +24,7 @@
         <result column="license" property="license"/>
         <result column="cp_manager" property="cpManager"/>
         <result column="cp_phone" property="cpPhone"/>
+        <result column="owner" property="owner" typeHandler="UuidTypeHandler"/>
     </resultMap>
 
     <resultMap type="com.dk.oauth.entity.MenuFrequency" id="ResultMenuMap">
@@ -73,7 +74,7 @@
                tac.cp_phone,
 --                tac.grade_code,
 --                tac.end_date,
---                tac.max_staff_num,
+               tac.owner,
                tac.cur_staff_num,
                tss.svc_ip,
                tss.svc_port
@@ -140,7 +141,7 @@
                 AND t.op_db_user = #{opDbUser}
             </if>
             <if test="owner != null and owner != ''">
-                AND t.owner = #{owner}
+                AND t.owner = #{owner}::uuid
             </if>
         </where>
     </sql>
@@ -225,6 +226,10 @@
     <update id="updateCompanyLicense">
         update dkic_a.t_a_company set license = license_social,license_social = null where cp_id = #{cpId}
     </update>
+    <!--更新企业所有者信息-->
+    <update id="updateOwner">
+        UPDATE dkic_a.t_a_company set owner = #{owner}::uuid, cp_manager = #{cpManager}, cp_phone = #{cpPhone} WHERE cp_id = #{cpId}
+    </update>
 
     <!-- 获取商户的地址服务 -->
     <select id="selectServiceAllot" resultType="String">

+ 86 - 0
src/main/resources/mapper/PublicOpenUnionMapper.xml

@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.dk.oauth.mapper.PublicOpenUnionMapper">
+    <resultMap id="BaseResultMap" type="com.dk.oauth.entity.PublicOpenUnion">
+        <id column="id" jdbcType="BIGINT" property="id" />
+        <result column="public_open_id" jdbcType="VARCHAR" property="publicOpenId" />
+        <result column="public_union_id" jdbcType="VARCHAR" property="publicUnionId" />
+    </resultMap>
+    <sql id="Base_Column_List">
+        id, public_union_id,public_open_id
+    </sql>
+
+    <select id="selectByCond" parameterType="com.dk.oauth.entity.PublicOpenUnion" resultMap="BaseResultMap">
+        select
+        <include refid="Base_Column_List" />,
+
+        <include refid="cond"/>
+        order by tmpou.id desc
+
+    </select>
+    <select id="countByCond" parameterType="com.dk.oauth.entity.PublicOpenUnion" resultType="Long">
+        select
+        count(1)
+        <include refid="cond"/>
+    </select>
+    <sql id="cond">
+        from dkic_a.t_wx_public_open_union tmpou
+        <where>
+            <if test="param!=null and param.publicUnionId">
+                and tmpou.public_union_id = #{param.publicUnionId}
+            </if>
+            <if test="param!=null and param.publicOpenId">
+                and tmpou.pulic_open_id = #{param.publicOpenId}
+            </if>
+        </where>
+    </sql>
+
+    <select id="selectByOpenId" parameterType="String" resultMap="BaseResultMap">
+        select
+        <include refid="Base_Column_List" />
+        from dkic_a.t_wx_public_open_union
+        where public_open_id = #{publicOpenId}
+    </select>
+
+    <select id="selectByUnionId" parameterType="String" resultMap="BaseResultMap">
+        select
+        <include refid="Base_Column_List" />
+        from dkic_a.t_wx_public_open_union
+        where public_union_id = #{publicUnionId}
+    </select>
+
+
+    <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.dk.oauth.entity.PublicOpenUnion" useGeneratedKeys="true">
+        insert into dkic_a.t_wx_public_open_union
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+
+            <if test="publicUnionId != null">
+                public_union_id,
+            </if>
+            <if test="publicOpenId != null">
+                public_open_id,
+            </if>
+
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="publicUnionId != null">
+                #{publicUnionId,jdbcType=VARCHAR},
+            </if>
+            <if test="publicOpenId != null">
+                #{publicOpenId,jdbcType=VARCHAR},
+            </if>
+        </trim>
+    </insert>
+    <update id="update" parameterType="com.dk.oauth.entity.PublicOpenUnion">
+        update dkic_a.t_wx_public_open_union
+        <set>
+            <if test="publicUnionId != null">
+                public_union_id = #{publicUnionId,jdbcType=VARCHAR},
+            </if>
+            <if test="publicOpenId != null">
+                public_open_id = #{publicOpenId,jdbcType=VARCHAR},
+            </if>
+        </set>
+        where id = #{id,jdbcType=BIGINT}
+    </update>
+</mapper>

+ 17 - 0
src/main/resources/mapper/TradeMapper.xml

@@ -21,6 +21,10 @@
         ,t.wx_trade_no
         ,t.extend_days
         ,t.dk_user_id
+        ,t.activity_id
+        ,t.trade_status
+        ,t.activity_item_id
+        ,t.trade_desc
     </sql>
 
     <resultMap type="com.dk.oauth.entity.Trade" id="ResultMap">
@@ -39,6 +43,9 @@
         <result column="wx_trade_no" property="wxTradeNo"/>
         <result column="extend_days" property="extendDays"/>
         <result column="dk_user_id" property="dkUserId" typeHandler="UuidTypeHandler"/>
+        <result column="activity_id" property="activityId" typeHandler="UuidTypeHandler"/>
+        <result column="activity_item_id" property="activityItemId" typeHandler="UuidTypeHandler"/>
+        <result column="trade_desc" property="tradeDesc"/>
     </resultMap>
 
     <!-- 通用查询映射结果 -->
@@ -58,6 +65,10 @@
         <result column="wx_trade_no" property="wxtradeNo"/>
         <result column="extend_days" property="extendDays"/>
         <result column="dk_user_id" property="dkUserId" typeHandler="UuidTypeHandler"/>
+        <result column="dk_user_id" property="dkUserId" typeHandler="UuidTypeHandler"/>
+        <result column="activity_id" property="activityId" typeHandler="UuidTypeHandler"/>
+        <result column="activity_item_id" property="activityItemId" typeHandler="UuidTypeHandler"/>
+        <result column="trade_desc" property="tradeDesc"/>
     </resultMap>
 
     <!-- 通用条件列 -->
@@ -81,6 +92,12 @@
             <if test="dkUserId != null  and dkUserId != ''">
                 AND t.dk_user_id = #{dkUserId}::uuid
             </if>
+            <if test="activityId != null  and activityId != ''">
+                AND t.activity_id = #{activityId}::uuid
+            </if>
+            <if test="activityItemId != null  and activityItemId != ''">
+                AND t.activity_item_id = #{activityItemId}::uuid
+            </if>
 
         </where>
     </sql>

+ 27 - 4
src/main/resources/mapper/UserMapper.xml

@@ -12,7 +12,10 @@
         <result column="joined_cps" property="joinedCps"
                 typeHandler="com.dk.common.infrastructure.handler.IntListTypeHandler"/>
         <result column="flg_valid" property="flgValid"/>
+        <result column="union_id" property="unionId"/>
+        <result column="public_open_id" property="publicOpenId"/>
         <collection property="joinedCpList" columnPrefix="join_" resultMap="companyMap"/>
+
     </resultMap>
 
     <!-- 查询条件设置通用查询映射结果 -->
@@ -60,7 +63,9 @@
                txu.user_pwd,
                txu.current_cp,
                txu.joined_cps,
-               txu.flg_valid
+               txu.flg_valid,
+               txu.union_id,
+               txu.public_open_id
         FROM dkic_a.t_wx_user txu
         where txu.user_wxid = #{userWxid}
           AND txu.flg_valid
@@ -74,14 +79,16 @@
                user_pwd,
                current_cp,
                joined_cps,
-               flg_valid
+               flg_valid,
+               union_id,
+               public_open_id
         FROM dkic_a.t_wx_user
         where user_id = #{id}::uuid
     </select>
 
     <insert id="insert" useGeneratedKeys="true" keyProperty="userId" keyColumn="user_id" parameterType="com.dk.oauth.entity.UserWxLogin">
-        insert into dkic_a.t_wx_user (user_wxid, user_name, user_phone, user_pwd,current_cp,joined_cps)
-        values (#{userWxid}, #{userName}, #{userPhone}, md5('123'),#{currentCp}, #{joinedCps,typeHandler=IntListTypeHandler})
+        insert into dkic_a.t_wx_user (user_wxid, user_name, user_phone, user_pwd,current_cp,joined_cps,union_id,public_open_id)
+        values (#{userWxid}, #{userName}, #{userPhone}, md5('123'),#{currentCp}, #{joinedCps,typeHandler=IntListTypeHandler},#{unionId},#{publicOpenId})
     </insert>
 
     <update id="cleanPhone">
@@ -96,6 +103,12 @@
         where user_id = #{userId}::uuid
     </update>
 
+    <update id="updateWxUnionid">
+        update dkic_a.t_wx_user
+        set union_id = #{unionId},public_open_id = #{publicOpenId}
+        where user_id = #{userId}::uuid
+    </update>
+
     <update id="updatePhone">
         update dkic_a.t_wx_user
         set user_phone = #{userPhone}
@@ -123,6 +136,16 @@
         update dkic_a.t_wx_user set current_cp = #{currentCp}
         where user_wxid = #{userWxid}
     </update>
+    <!--根据商户号注销当前商户的负责人-->
+    <update id="updateFlgInit">
+        UPDATE dkic_b.t_mst_staff SET flg_init = false
+        WHERE cp_id = #{cpId}
+    </update>
+    <!--通过用户id更新负责人-->
+    <update id="updateFlgInitById">
+        UPDATE dkic_b.t_mst_staff SET flg_init = true
+        WHERE staff_id = #{userId}::uuid
+    </update>
 
     <!--新建用户状态表-->
     <insert id="insertOrUpdateUserLogin">

+ 9 - 0
src/main/resources/test/bootstrap.yml

@@ -98,6 +98,15 @@ wx:
   offiAccountAppId: wx6bb9335b534f7b28
   offiAccountAppSecret: 78a99837c113756599d1748b813ca698
   unlimitedQRCode: https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=
+  # 公众号发送消息的api-对应获取token
+  token: http://ibossmp.dongkesoft.com:9000/get_access_token
+  # 公众号的appid appSecret 东科软件 公众号
+  wxPublicAccountAppId: wx6bb9335b534f7b28
+  wxPublicAccountAppSecret: 78a99837c113756599d1748b813ca698
+  # 公众号可通过本接口来获取账号的关注者列表 231024
+  user_public_openid: https://api.weixin.qq.com/cgi-bin/user/get?access_token=
+  # 可通过OpenID来获取用户基本信息 获取用户基本信息(包括UnionID机制) 231024
+  user_info_public_unionid: https://api.weixin.qq.com/cgi-bin/user/info?access_token=
   # 支付的信息240327 从mdm迁移过来的
   pay:
     # 商户号 微信支付