瀏覽代碼

fix:修改IOS新增渠道信息时增加默认配置逻辑

zack 2 月之前
父節點
當前提交
6816e94847
共有 18 個文件被更改,包括 139 次插入45 次删除
  1. 8 3
      yt-agent/agent-service/src/main/java/com/ytpm/controller/AgentDitchController.java
  2. 2 2
      yt-agent/agent-service/src/main/java/com/ytpm/service/AgentDitchService.java
  3. 10 20
      yt-agent/agent-service/src/main/java/com/ytpm/service/impl/AgentDitchServiceImpl.java
  4. 4 0
      yt-agent/agent-service/src/main/resources/mapper/AgentDitchMapper.xml
  5. 1 1
      yt-agent/agent-service/src/main/resources/mapper/AppMapper.xml
  6. 8 0
      yt-common/src/main/java/com/ytpm/agent/model/YtDitch.java
  7. 4 0
      yt-common/src/main/java/com/ytpm/agent/param/AgentDitchParam.java
  8. 1 0
      yt-common/src/main/java/com/ytpm/agent/param/DitchListParam.java
  9. 8 3
      yt-ios-lemon/lemon-ios-feign/src/main/java/com/ytpm/lemonios/feign/LemonIosFeign.java
  10. 2 2
      yt-ios-lemon/lemon-ios-service/src/main/java/com/ytpm/lemonios/controller/DitchController.java
  11. 15 6
      yt-ios-lemon/lemon-ios-service/src/main/java/com/ytpm/lemonios/controller/WxController.java
  12. 1 1
      yt-ios-lemon/lemon-ios-service/src/main/java/com/ytpm/lemonios/dao/AppUserMapper.java
  13. 4 0
      yt-ios-lemon/lemon-ios-service/src/main/java/com/ytpm/lemonios/dao/DitchMapper.java
  14. 6 0
      yt-ios-lemon/lemon-ios-service/src/main/java/com/ytpm/lemonios/service/AppUserService.java
  15. 30 1
      yt-ios-lemon/lemon-ios-service/src/main/java/com/ytpm/lemonios/service/impl/AppUserServiceImpl.java
  16. 1 5
      yt-ios-lemon/lemon-ios-service/src/main/java/com/ytpm/lemonios/service/impl/DitchServiceImpl.java
  17. 3 1
      yt-ios-lemon/lemon-ios-service/src/main/resources/mapper/AppUserMapper.xml
  18. 31 0
      yt-ios-lemon/lemon-ios-service/src/main/resources/mapper/DitchMapper.xml

+ 8 - 3
yt-agent/agent-service/src/main/java/com/ytpm/controller/AgentDitchController.java

@@ -5,14 +5,18 @@ import com.ytpm.agent.param.AgentDitchParam;
 import com.ytpm.agent.param.DitchListParam;
 import com.ytpm.agent.view.AgentDitchView;
 import com.ytpm.agent.view.AgentUserInfo;
-import com.ytpm.app.model.YtAppDefaultConfig;
 import com.ytpm.general.Result;
 import com.ytpm.general.ResultTable;
 import com.ytpm.service.AgentDitchService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.security.core.annotation.AuthenticationPrincipal;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.GetMapping;
+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.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
 import springfox.documentation.annotations.ApiIgnore;
 
 import javax.annotation.Resource;
@@ -44,10 +48,11 @@ public class AgentDitchController {
     public Result<?> addOne(@RequestBody AgentDitchParam param, @ApiIgnore @AuthenticationPrincipal AgentUserInfo userInfo){
         YtDitch ytDitch = new YtDitch();
         ytDitch.setDitchName(param.getDitchName());
+        ytDitch.setAppType(param.getDitchType());
         ytDitch.setCreateTime(new Date());
         ytDitch.setUserId(userInfo.getUserId());
         if (!param.getDitchType().isEmpty() && param.getDitchType().equals("2")){
-            return agentDitchService.addDefaultConfig(ytDitch);
+            return agentDitchService.addDefaultConfig(ytDitch, userInfo);
         } else {
             return agentDitchService.addOne(ytDitch);
         }

+ 2 - 2
yt-agent/agent-service/src/main/java/com/ytpm/service/AgentDitchService.java

@@ -1,9 +1,9 @@
 package com.ytpm.service;
 
 import com.ytpm.agent.model.YtDitch;
-import com.ytpm.agent.param.AgentDitchParam;
 import com.ytpm.agent.param.DitchListParam;
 import com.ytpm.agent.view.AgentDitchView;
+import com.ytpm.agent.view.AgentUserInfo;
 import com.ytpm.general.Result;
 import com.ytpm.general.ResultTable;
 
@@ -42,5 +42,5 @@ public interface AgentDitchService {
      * @param param
      * @return
      */
-    Result<?> addDefaultConfig(YtDitch param);
+    Result<?> addDefaultConfig(YtDitch param, AgentUserInfo userInfo);
 }

+ 10 - 20
yt-agent/agent-service/src/main/java/com/ytpm/service/impl/AgentDitchServiceImpl.java

@@ -6,8 +6,7 @@ import com.ytpm.agent.model.YtApp;
 import com.ytpm.agent.model.YtDitch;
 import com.ytpm.agent.param.DitchListParam;
 import com.ytpm.agent.view.AgentDitchView;
-import com.ytpm.app.model.YtAppDefaultConfig;
-import com.ytpm.app.view.WxDefaultConfig;
+import com.ytpm.agent.view.AgentUserInfo;
 import com.ytpm.dao.AgentDitchMapper;
 import com.ytpm.dao.AppMapper;
 import com.ytpm.general.RepMessage;
@@ -78,26 +77,17 @@ public class AgentDitchServiceImpl implements AgentDitchService {
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public Result<?> addDefaultConfig(YtDitch param) {
+    public Result<?> addDefaultConfig(YtDitch param, AgentUserInfo userInfo) {
         param.setIsDelete(0);
-        agentDitchMapper.insertOne(param);
 
-        WxDefaultConfig lastOne = lemonIosFeign.getLastOne();
-        YtAppDefaultConfig appDefaultConfig = new YtAppDefaultConfig();
-        appDefaultConfig.setConfigName(param.getDitchName());
-        appDefaultConfig.setDitchId(param.getDitchId().toString());
-        appDefaultConfig.setOpenId("");
-        appDefaultConfig.setSecret(lastOne.getSecret());
-        appDefaultConfig.setAppKey("");
-        appDefaultConfig.setAppType(lastOne.getAppType());
-        appDefaultConfig.setAppId(lastOne.getAppId());
-        appDefaultConfig.setCanUseRoot(lastOne.getCanUseRoot());
-        appDefaultConfig.setCanUseAdb(lastOne.getCanUseAdb());
-        appDefaultConfig.setCanAccumulation(lastOne.getCanAccumulation());
-        appDefaultConfig.setCanSimulator(lastOne.getCanSimulator());
-        appDefaultConfig.setPowerWaitTime(lastOne.getPowerWaitTime());
-        appDefaultConfig.setInterstitialIntervalTime(lastOne.getInterstitialIntervalTime());
-        lemonIosFeign.saveAppConfig(appDefaultConfig);
+        List<YtApp> appList = appMapper.queryAll(userInfo.getUserId());
+        String appId = "";
+        if(appList != null && appList.size() > 0){
+            appId = appList.get(0).getSuperiorId();
+        }
+        param.setAppId(appId);
+        agentDitchMapper.insertOne(param);
+        lemonIosFeign.getLastOne(param);
         return Result.resultOk(RepMessage.SAVE_SUCCESS);
     }
 }

+ 4 - 0
yt-agent/agent-service/src/main/resources/mapper/AgentDitchMapper.xml

@@ -7,6 +7,8 @@
             ditch_id,
             ditch_name,
             user_id,
+            app_type,
+            app_id,
             is_delete,
             create_time
         )
@@ -15,6 +17,8 @@
                 #{ditchId},
                 #{ditchName},
                 #{userId},
+                #{appType},
+                #{appId},
                 #{isDelete},
                 #{createTime}
             )

+ 1 - 1
yt-agent/agent-service/src/main/resources/mapper/AppMapper.xml

@@ -136,7 +136,7 @@
     </select>
     <select id="queryAll" resultType="com.ytpm.agent.model.YtApp">
         select
-            app_id, ditch_id, ditch_name, app_key, app_name, user_id, app_type, apk_url, qr_code, version_code, update_tips, enabled, store_on_sale, store_type, store_url, package_name, domain, category, sub_category, coppa, screen_orientation, ccpa
+            app_id, ditch_id, ditch_name, app_key, app_name, user_id, app_type, apk_url, qr_code, version_code, update_tips, enabled, store_on_sale, store_type, store_url, package_name, domain, category, sub_category, coppa, screen_orientation, ccpa, superior_id
         from yt_app
         where user_id = #{userId}
     </select>

+ 8 - 0
yt-common/src/main/java/com/ytpm/agent/model/YtDitch.java

@@ -18,6 +18,14 @@ public class YtDitch {
      * 用户id
      */
     private String userId;
+    /**
+     * 应用类型
+     */
+    private String appType;
+    /**
+     * appId
+     */
+    private String appId;
     /**
      * 是否删除 0-正常 1-已删除
      */

+ 4 - 0
yt-common/src/main/java/com/ytpm/agent/param/AgentDitchParam.java

@@ -11,4 +11,8 @@ public class AgentDitchParam {
     private Long ditchId;
     @ApiModelProperty("渠道类型")
     private String ditchType;
+    @ApiModelProperty("应用类型")
+    private String appType;
+    @ApiModelProperty("应用ID")
+    private String appId;
 }

+ 1 - 0
yt-common/src/main/java/com/ytpm/agent/param/DitchListParam.java

@@ -15,4 +15,5 @@ import lombok.NoArgsConstructor;
 public class DitchListParam extends PageMeta {
     private String ditchName;
     private String userId;
+    private String appId;
 }

+ 8 - 3
yt-ios-lemon/lemon-ios-feign/src/main/java/com/ytpm/lemonios/feign/LemonIosFeign.java

@@ -1,12 +1,17 @@
 package com.ytpm.lemonios.feign;
 
+import com.ytpm.agent.model.YtDitch;
 import com.ytpm.agent.param.AuditCheckParam;
 import com.ytpm.agent.view.AgentAdGroupStaticsVO;
 import com.ytpm.agent.view.AgentTopCountView;
 import com.ytpm.app.model.YtAppDefaultConfig;
 import com.ytpm.app.model.YtDyzAdRecord;
 import com.ytpm.app.model.YtDyzUser;
-import com.ytpm.app.param.*;
+import com.ytpm.app.param.AppQueryUserTodayTimeParam;
+import com.ytpm.app.param.AppUserParam;
+import com.ytpm.app.param.AppUserQueryParam;
+import com.ytpm.app.param.AppUserTodayBannedParam;
+import com.ytpm.app.param.YtAppUserListParam;
 import com.ytpm.app.view.WxDefaultConfig;
 import com.ytpm.app.view.YtAppUserListView;
 import com.ytpm.general.Result;
@@ -71,8 +76,8 @@ public interface LemonIosFeign {
     @GetMapping("/wx/getConfigs")
     List<WxDefaultConfig> getConfigs(@RequestParam(name = "appIds")String appIds);
 
-    @GetMapping("/wx/getLastOne")
-    WxDefaultConfig getLastOne();
+    @PostMapping("/wx/getLastOne")
+    WxDefaultConfig getLastOne(@RequestBody YtDitch param);
 
     @PostMapping("/user/queryTodayBanned")
     List<YtDyzUser> queryTodayBanned(@RequestBody AppUserTodayBannedParam appUserTodayBannedParam);

+ 2 - 2
yt-ios-lemon/lemon-ios-service/src/main/java/com/ytpm/lemonios/controller/DitchController.java

@@ -28,8 +28,8 @@ public class DitchController {
     @PostMapping("/list")
     public Result<List<AgentDitchView>> list(@RequestBody DitchListForIosParam param) {
         param.setAppId(param.getAppId());
-        DitchListParam ditchListParam = new  DitchListParam();
-        ditchListParam.setUserId(param.getAppId());
+        DitchListParam ditchListParam = new DitchListParam();
+        ditchListParam.setAppId(param.getAppId());
         return Result.resultOk(RepMessage.QUERY_SUCCESS, agentDitchService.ditchList(ditchListParam));
     }
 

+ 15 - 6
yt-ios-lemon/lemon-ios-service/src/main/java/com/ytpm/lemonios/controller/WxController.java

@@ -5,14 +5,18 @@ import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.http.HttpUtil;
 import com.alibaba.fastjson.JSON;
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ytpm.agent.model.YtDitch;
 import com.ytpm.app.enums.AppTypeEnums;
 import com.ytpm.app.model.YtAppDefaultConfig;
 import com.ytpm.app.model.YtDyzPowerRecord;
 import com.ytpm.app.model.YtDyzUser;
 import com.ytpm.app.param.IosLoginParam;
 import com.ytpm.app.param.WxLoginParam;
-import com.ytpm.app.view.*;
+import com.ytpm.app.view.IosPowerResView;
+import com.ytpm.app.view.IosUserInfo;
+import com.ytpm.app.view.WxDefaultConfig;
+import com.ytpm.app.view.WxLoginResult;
+import com.ytpm.app.view.WxUserInfo;
 import com.ytpm.feign.RiskFeign;
 import com.ytpm.general.RepMessage;
 import com.ytpm.general.Result;
@@ -24,7 +28,12 @@ import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.GetMapping;
+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.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.http.HttpServletRequest;
 import java.text.SimpleDateFormat;
@@ -111,11 +120,11 @@ public class WxController {
         return Result.resultOk(RepMessage.QUERY_SUCCESS, defaultConfig);
     }
 
-    @GetMapping("/getLastOne")
+    @PostMapping("/getLastOne")
     @ApiOperation("获取最近一条默认配置")
     @Transactional
-    public WxDefaultConfig getLastOne(){
-        return appUserMapper.getLastOne();
+    public Result<?> getLastOne(@RequestBody YtDitch param){
+        return appUserService.addDefaultConfig(param);
     }
 
     private String getClientIp(HttpServletRequest request) {

+ 1 - 1
yt-ios-lemon/lemon-ios-service/src/main/java/com/ytpm/lemonios/dao/AppUserMapper.java

@@ -113,7 +113,7 @@ public interface AppUserMapper {
     /**
      * 获取最近一条默认配置
      */
-    WxDefaultConfig getLastOne();
+    WxDefaultConfig getLastOne(@Param("appId") String appId);
 
     /**
      * 根据微信openid查询用户

+ 4 - 0
yt-ios-lemon/lemon-ios-service/src/main/java/com/ytpm/lemonios/dao/DitchMapper.java

@@ -10,5 +10,9 @@ import java.util.List;
 public interface DitchMapper {
     List<AgentDitchView> ditchList(DitchListParam param);
 
+    List<AgentDitchView> ditchListForIos(@Param("appId") String appId);
+
+    Integer insertOne(YtDitch ytDitch);
+
     YtDitch selectById(@Param("ditchId") Long ditchId);
 }

+ 6 - 0
yt-ios-lemon/lemon-ios-service/src/main/java/com/ytpm/lemonios/service/AppUserService.java

@@ -1,11 +1,13 @@
 package com.ytpm.lemonios.service;
 
+import com.ytpm.agent.model.YtDitch;
 import com.ytpm.app.model.YtDyzUser;
 import com.ytpm.app.param.IosLoginParam;
 import com.ytpm.app.param.WxLoginParam;
 import com.ytpm.app.view.IosUserInfo;
 import com.ytpm.app.view.WxLoginResult;
 import com.ytpm.app.view.WxUserInfo;
+import com.ytpm.general.Result;
 
 public interface AppUserService {
     /**
@@ -22,4 +24,8 @@ public interface AppUserService {
      * 子事务处理用户crud
      */
     YtDyzUser crudForNewTransIos(IosLoginParam param, IosUserInfo userInfo);
+
+    Result<?> addDefaultConfig(YtDitch param);
+
+
 }

+ 30 - 1
yt-ios-lemon/lemon-ios-service/src/main/java/com/ytpm/lemonios/service/impl/AppUserServiceImpl.java

@@ -4,17 +4,23 @@ import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.RandomUtil;
 import cn.hutool.core.util.StrUtil;
 import com.ytpm.agent.enums.UserStatusEnum;
+import com.ytpm.agent.model.YtDitch;
+import com.ytpm.app.model.YtAppDefaultConfig;
 import com.ytpm.app.model.YtDyzAnswerRecord;
 import com.ytpm.app.model.YtDyzLoginRecord;
 import com.ytpm.app.model.YtDyzUser;
 import com.ytpm.app.param.IosLoginParam;
 import com.ytpm.app.param.WxLoginParam;
 import com.ytpm.app.view.IosUserInfo;
+import com.ytpm.app.view.WxDefaultConfig;
 import com.ytpm.app.view.WxLoginResult;
 import com.ytpm.app.view.WxUserInfo;
 import com.ytpm.constant.StrConstant;
+import com.ytpm.general.RepMessage;
+import com.ytpm.general.Result;
 import com.ytpm.handle.CustomerException;
 import com.ytpm.lemonios.dao.AppUserMapper;
+import com.ytpm.lemonios.dao.DitchMapper;
 import com.ytpm.lemonios.dao.LoginRecordMapper;
 import com.ytpm.lemonios.dao.QuestionMapper;
 import com.ytpm.lemonios.redis.RedisService;
@@ -29,7 +35,6 @@ import org.springframework.transaction.annotation.Transactional;
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.Date;
 import java.util.List;
 import java.util.Objects;
@@ -48,6 +53,8 @@ public class AppUserServiceImpl implements AppUserService {
     private RedisService redisService;
     @Value("${risk.config.banned.tips}")
     private String tips;
+    @Autowired
+    private DitchMapper ditchMapper;
 
     /**
      * openid查询用户信息
@@ -91,6 +98,28 @@ public class AppUserServiceImpl implements AppUserService {
         return old;
     }
 
+    @Override
+    public Result<?> addDefaultConfig(YtDitch param) {
+        ditchMapper.insertOne(param);
+        WxDefaultConfig lastOne = appUserMapper.getLastOne(param.getAppId());
+        YtAppDefaultConfig appDefaultConfig = new YtAppDefaultConfig();
+        appDefaultConfig.setConfigName(param.getDitchName());
+        appDefaultConfig.setDitchId(param.getDitchId().toString());
+        appDefaultConfig.setOpenId("");
+        appDefaultConfig.setSecret(lastOne.getSecret());
+        appDefaultConfig.setAppKey("");
+        appDefaultConfig.setAppType(lastOne.getAppType());
+        appDefaultConfig.setAppId(lastOne.getAppId());
+        appDefaultConfig.setCanUseRoot(lastOne.getCanUseRoot());
+        appDefaultConfig.setCanUseAdb(lastOne.getCanUseAdb());
+        appDefaultConfig.setCanAccumulation(lastOne.getCanAccumulation());
+        appDefaultConfig.setCanSimulator(lastOne.getCanSimulator());
+        appDefaultConfig.setPowerWaitTime(lastOne.getPowerWaitTime());
+        appDefaultConfig.setInterstitialIntervalTime(lastOne.getInterstitialIntervalTime());
+        appUserMapper.saveAppConfig(appDefaultConfig);
+        return Result.resultOk(RepMessage.ADD_SUCCESS);
+    }
+
     /**
      * 设置扩展信息
      */

+ 1 - 5
yt-ios-lemon/lemon-ios-service/src/main/java/com/ytpm/lemonios/service/impl/DitchServiceImpl.java

@@ -1,10 +1,7 @@
 package com.ytpm.lemonios.service.impl;
 
-import com.github.pagehelper.PageHelper;
-import com.github.pagehelper.PageInfo;
 import com.ytpm.agent.param.DitchListParam;
 import com.ytpm.agent.view.AgentDitchView;
-import com.ytpm.general.ResultTable;
 import com.ytpm.lemonios.dao.DitchMapper;
 import com.ytpm.lemonios.service.DitchService;
 import org.springframework.stereotype.Service;
@@ -21,7 +18,6 @@ public class DitchServiceImpl implements DitchService {
 
     @Override
     public List<AgentDitchView> ditchList(DitchListParam param) {
-        List<AgentDitchView> agentDitchViews = agentDitchMapper.ditchList(param);
-        return agentDitchViews;
+        return agentDitchMapper.ditchListForIos(param.getAppId());
     }
 }

+ 3 - 1
yt-ios-lemon/lemon-ios-service/src/main/resources/mapper/AppUserMapper.xml

@@ -255,6 +255,7 @@
             user_id, app_id,phone,device_id, ditch_id, nick_name,head_img, power, registry_time, last_login_time, last_login_ip, login_days, total_video, total_income, red_packet_balance, red_packet_amount, points_balance, points_total, withdraw_total, sign_days, user_status, risk_reason, wx_open_id, ios_id, platform_id
         from yt_dyz_user
         where ios_id = #{iosId}
+        Limit 1
     </select>
     <select id="getYtAppUserForIos" resultType="com.ytpm.app.model.YtDyzUser">
         select
@@ -472,7 +473,8 @@
             config_id, config_name, open_id, secret, app_id, app_key, app_type,user_path,login_path,ad_path,answer_path,power_path
              ,can_simulator,taku_app_id,taku_key,taku_banner_pid,taku_interstitial_pid,taku_reward_pid,taku_native_pid,can_use_adb,can_accumulation,can_use_float,can_use_root,ditch_id,power_wait_time,interstitial_interval_time
         from yt_app_default_config
-        LIMIT 1
+        where app_id =  #{appId}
+        limit 1
     </select>
     <select id="getSecretByAppId" resultType="java.lang.String">
         select

+ 31 - 0
yt-ios-lemon/lemon-ios-service/src/main/resources/mapper/DitchMapper.xml

@@ -1,6 +1,28 @@
 <?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.ytpm.lemonios.dao.DitchMapper">
+    <insert id="insertOne" keyProperty="ditchId" useGeneratedKeys="true">
+        insert into yt_ditch
+        (
+            ditch_id,
+            ditch_name,
+            user_id,
+            app_type,
+            app_id,
+            is_delete,
+            create_time
+        )
+        values
+            (
+                #{ditchId},
+                #{ditchName},
+                #{userId},
+                #{appType},
+                #{appId},
+                #{isDelete},
+                #{createTime}
+            )
+    </insert>
     <select id="ditchList" resultType="com.ytpm.agent.view.AgentDitchView">
         select
         ditch_id, ditch_name, create_time
@@ -10,6 +32,15 @@
             and is_delete=0
         </where>
     </select>
+    <select id="ditchListForIos" resultType="com.ytpm.agent.view.AgentDitchView">
+        select
+        ditch_id, ditch_name, create_time
+        from yt_ditch
+        <where>
+            app_id = #{appId}
+            and is_delete=0
+        </where>
+    </select>
     <select id="selectById" resultType="com.ytpm.agent.model.YtDitch">
         select
             ditch_id, ditch_name, user_id, is_delete, create_time