linxk 3 周之前
父节点
当前提交
a86a053a8b

+ 2 - 0
cif-api/src/main/java/com/txz/cif/enums/BizTypeEnum.java

@@ -23,6 +23,8 @@ public enum BizTypeEnum {
 
     SECONDARY_COMMISSION( 5005, "二级佣金"),
 
+    PROMOTION_COMMISSION( 5006, "直推佣金"),
+
     REFUND_RECHARGE( 6001, "充值返点"),
 
     WITHDRAWAL_FEE( 7001, "提现手续费"),

+ 7 - 0
cif-api/src/main/java/com/txz/cif/param/SignRedEnvelopeParam.java

@@ -6,6 +6,7 @@
 */
 package com.txz.cif.param;
 
+import com.txz.cif.enums.BizTypeEnum;
 import lombok.AllArgsConstructor;
 import lombok.Builder;
 import lombok.Data;
@@ -32,6 +33,12 @@ public class SignRedEnvelopeParam implements Serializable {
      */
     private Long userId;
 
+    /**
+     * 业务类型  5003 签到红包 5006 直推红包
+     */
+    private BizTypeEnum bizType;
+
+
     /**
      * 交易金额
      */

+ 76 - 76
cif-service/src/main/java/com/txz/cif/configurer/XxlJobConfig.java

@@ -1,76 +1,76 @@
-//package com.txz.cif.configurer;
-//
-//import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
-//import org.slf4j.Logger;
-//import org.slf4j.LoggerFactory;
-//import org.springframework.beans.factory.annotation.Value;
-//import org.springframework.context.annotation.Bean;
-//import org.springframework.context.annotation.Configuration;
-//import org.springframework.context.annotation.Profile;
-//
-///**
-// * xxl-job config
-// *
-// * @author xuxueli 2017-04-28
-// */
-//@Profile({"local","dev", "test", "pro", "pro2"})
-//@Configuration
-//public class XxlJobConfig {
-//    private Logger logger = LoggerFactory.getLogger(XxlJobConfig.class);
-//
-//    @Value("${xxl.job.admin.addresses}")
-//    private String adminAddresses;
-//
-//    @Value("${xxl.job.executor.appname}")
-//    private String appName;
-//
-//    @Value("${xxl.job.executor.ip}")
-//    private String ip;
-//
-//    @Value("${xxl.job.executor.port}")
-//    private int port;
-//
-//    @Value("${xxl.job.accessToken}")
-//    private String accessToken;
-//
-//    @Value("${xxl.job.executor.logpath}")
-//    private String logPath;
-//
-//    @Value("${xxl.job.executor.logretentiondays}")
-//    private int logRetentionDays;
-//
-//
-//    @Bean
-//    public XxlJobSpringExecutor xxlJobExecutor() {
-//        logger.info(">>>>>>>>>>> xxl-job config init.");
-//        XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
-//        xxlJobSpringExecutor.setAdminAddresses(adminAddresses);
-//        xxlJobSpringExecutor.setAppname(appName);
-//        xxlJobSpringExecutor.setIp(ip);
-//        xxlJobSpringExecutor.setPort(port);
-//        xxlJobSpringExecutor.setAccessToken(accessToken);
-//        xxlJobSpringExecutor.setLogPath(logPath);
-//        xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays);
-//
-//        return xxlJobSpringExecutor;
-//    }
-//
-//    /**
-//     * 针对多网卡、容器内部署等情况,可借助 "spring-cloud-commons" 提供的 "InetUtils" 组件灵活定制注册IP;
-//     *
-//     *      1、引入依赖:
-//     *          <dependency>
-//     *             <groupId>org.springframework.cloud</groupId>
-//     *             <artifactId>spring-cloud-commons</artifactId>
-//     *             <version>${version}</version>
-//     *         </dependency>
-//     *
-//     *      2、配置文件,或者容器启动变量
-//     *          spring.cloud.inetutils.preferred-networks: 'xxx.xxx.xxx.'
-//     *
-//     *      3、获取IP
-//     *          String ip_ = inetUtils.findFirstNonLoopbackHostInfo().getIpAddress();
-//     */
-//
-//
-//}
+package com.txz.cif.configurer;
+
+import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Profile;
+
+/**
+ * xxl-job config
+ *
+ * @author xuxueli 2017-04-28
+ */
+@Profile({"local","dev", "test", "pro", "pro2"})
+@Configuration
+public class XxlJobConfig {
+    private Logger logger = LoggerFactory.getLogger(XxlJobConfig.class);
+
+    @Value("${xxl.job.admin.addresses}")
+    private String adminAddresses;
+
+    @Value("${xxl.job.executor.appname}")
+    private String appName;
+
+    @Value("${xxl.job.executor.ip}")
+    private String ip;
+
+    @Value("${xxl.job.executor.port}")
+    private int port;
+
+    @Value("${xxl.job.accessToken}")
+    private String accessToken;
+
+    @Value("${xxl.job.executor.logpath}")
+    private String logPath;
+
+    @Value("${xxl.job.executor.logretentiondays}")
+    private int logRetentionDays;
+
+
+    @Bean
+    public XxlJobSpringExecutor xxlJobExecutor() {
+        logger.info(">>>>>>>>>>> xxl-job config init.");
+        XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
+        xxlJobSpringExecutor.setAdminAddresses(adminAddresses);
+        xxlJobSpringExecutor.setAppname(appName);
+        xxlJobSpringExecutor.setIp(ip);
+        xxlJobSpringExecutor.setPort(port);
+        xxlJobSpringExecutor.setAccessToken(accessToken);
+        xxlJobSpringExecutor.setLogPath(logPath);
+        xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays);
+
+        return xxlJobSpringExecutor;
+    }
+
+    /**
+     * 针对多网卡、容器内部署等情况,可借助 "spring-cloud-commons" 提供的 "InetUtils" 组件灵活定制注册IP;
+     *
+     *      1、引入依赖:
+     *          <dependency>
+     *             <groupId>org.springframework.cloud</groupId>
+     *             <artifactId>spring-cloud-commons</artifactId>
+     *             <version>${version}</version>
+     *         </dependency>
+     *
+     *      2、配置文件,或者容器启动变量
+     *          spring.cloud.inetutils.preferred-networks: 'xxx.xxx.xxx.'
+     *
+     *      3、获取IP
+     *          String ip_ = inetUtils.findFirstNonLoopbackHostInfo().getIpAddress();
+     */
+
+
+}

+ 5 - 1
cif-service/src/main/java/com/txz/cif/dubbo/impl/AccountDubboServiceImpl.java

@@ -183,7 +183,11 @@ public class AccountDubboServiceImpl implements AccountDubboService {
     public Result addRedEnvelope(SignRedEnvelopeParam param) {
         RedEnvelopeParam p = BeanUtil.toBean(param,RedEnvelopeParam.class);
         p.setUserIds(CollUtil.newArrayList(param.getUserId()));
-        p.setBizType(BizTypeEnum.SIGN_RED_ENVELOPE.getKey());
+        if (param.getBizType() == BizTypeEnum.SIGN_RED_ENVELOPE || param.getBizType() == BizTypeEnum.PROMOTION_COMMISSION){
+            p.setBizType(param.getBizType().getKey());
+        } else {
+            return Result.genFailResult("不支持类型");
+        }
         return redEnvelopeService.addRedEnvelope(p);
     }
 

+ 17 - 3
cif-service/src/main/java/com/txz/cif/service/impl/RedEnvelopeServiceImpl.java

@@ -60,7 +60,7 @@ public class RedEnvelopeServiceImpl extends AbstractService<RedEnvelope> impleme
      */
     @Override
     public Result addRedEnvelope(RedEnvelopeParam param) {
-        com.txz.operating.result.Result<ConfigDTO> redEnvelopeSettelDay = operatingConfigDubboServiceClient.getConfigByCode("red_envelope_settel_day");
+        com.txz.operating.result.Result<ConfigDTO> redEnvelopeSettelDay = operatingConfigDubboServiceClient.getConfigByCode("red_envelope_settel_day_"+param.getBizType());
         Integer settleDay = Integer.parseInt(redEnvelopeSettelDay.getData().getValueInfo());
         Date settleTime = DateUtil.offsetDay(param.getTransTime(),settleDay);
         List<RedEnvelope> redEnvelopes = new ArrayList<>();
@@ -75,6 +75,9 @@ public class RedEnvelopeServiceImpl extends AbstractService<RedEnvelope> impleme
         } else if (BizTypeEnum.getByKey(param.getBizType()) == BizTypeEnum.SIGN_RED_ENVELOPE){
             //签到红包
             redEnvelopes.addAll(bulidRedEnvelope(param.getUserIds().get(0),param,settleTime)) ;
+        }else if (BizTypeEnum.getByKey(param.getBizType()) == BizTypeEnum.PROMOTION_COMMISSION){
+            //直推红包
+            redEnvelopes.addAll(bulidRedEnvelope(param.getUserIds().get(0),param,settleTime)) ;
         }
         if (CollUtil.isNotEmpty(redEnvelopes)){
             save(redEnvelopes);
@@ -104,7 +107,8 @@ public class RedEnvelopeServiceImpl extends AbstractService<RedEnvelope> impleme
         //红包
         ret.add(bulidRedEnvelope2(1,userId,param,settleTime)) ;
         // 开团、参团 才有 佣金红包
-        if (param.getBizType() < 3){
+        if (BizTypeEnum.getByKey(param.getBizType()) == BizTypeEnum.OPEN_GROUP_RED_ENVELOPE
+            || BizTypeEnum.getByKey(param.getBizType()) == BizTypeEnum.JOIN_GROUP_RED_ENVELOPE ){
             //只有 开团、参团 有分佣
             User user = userService.findById(userId);
             if (user.getPid() != null){
@@ -134,6 +138,16 @@ public class RedEnvelopeServiceImpl extends AbstractService<RedEnvelope> impleme
                 .andEqualTo("bizType",2);
         List<Account> accounts = accountService.findByCondition(c);
         Account account = accounts.get(0);
+        Integer bizType = type == 1?param.getBizType(): type==2? BizTypeEnum.FIRST_COMMISSION.getKey():BizTypeEnum.SECONDARY_COMMISSION.getKey();
+        //  一级二级分佣重新计算结算时间
+        if (type > 1){
+            com.txz.operating.result.Result<ConfigDTO> redEnvelopeSettelDay = operatingConfigDubboServiceClient.getConfigByCode("red_envelope_settel_day_"+bizType);
+            Integer settleDay = Integer.parseInt(redEnvelopeSettelDay.getData().getValueInfo());
+            settleTime = DateUtil.offsetDay(param.getTransTime(),settleDay);
+        }
+
+
+
         Long id = IdUtil.getSnowflake(1,1).nextId();
         //借:营销账户(负债类201)(贷)     -100元
         //贷:个人账户(负债类202)(贷)     +100元
@@ -152,7 +166,7 @@ public class RedEnvelopeServiceImpl extends AbstractService<RedEnvelope> impleme
                 .createTime(DateUtil.date())
                 .orderNo(param.getOrderNo())
                 //类型: 1(自己) 返回  1(开团)或2(参团)  2(父亲)返回4(上级分佣)  3(爷爷)返回5(上上级分佣)
-                .bizType(type == 1?param.getBizType(): type==2? 4:5)
+                .bizType(bizType)
                 .debitAccount(MyConstants.INNER_MARKETING)
                 .creditAccount(account.getId())
                 .transTime(param.getTransTime())

+ 37 - 34
cif-service/src/main/java/com/txz/cif/task/GeneralJob.java

@@ -60,52 +60,55 @@ public class GeneralJob {
         Map<String,Object> map = new HashMap<>();
         map.put("email","351550660@qq.com");
         map.put("passwd","Lin123456");
-        HttpResponse resp = HttpRequest.post("https://chyvpn.cyou/auth/login").form(map).timeout(-1).execute();
+        HttpResponse resp = HttpRequest.post("https://chynet01.azureedge.net/auth/login").form(map).timeout(-1).execute();
         String key = resp.getCookie("key").toString();
         String expire_in = resp.getCookie("expire_in").toString();
         String cookie = "cookie:PHPSESSID=fun75tna6st563e78799552e69; cnxad_lunbo=yes; crisp-client%2Fsession%2F7850791f-bbe4-4874-9f05-c9dea3c63595=session_8a49d3eb-e9c7-43f8-9fe9-12d1560a4122; crisp-client%2Fsession%2F7850791f-bbe4-4874-9f05-c9dea3c63595%2Fc89170bf-a23d-3152-9ad4-fda9810011f7=session_8a49d3eb-e9c7-43f8-9fe9-12d1560a4122; uid=14105; email=351550660%40qq.com; ip=5f0f60145ce69c8054af6bb0a24e9c1a;"+key+"; "+expire_in;
-        String ret = HttpRequest.post("https://chyvpn.cyou/user/checkin").cookie(cookie).timeout(-1).execute().body();
+        String ret = HttpRequest.post("https://chynet01.azureedge.net/user/checkin").cookie(cookie).timeout(-1).execute().body();
         logger.error("[checkin]:"+ret);
 
-        map = new HashMap<>();
-        map.put("email","yyjt1987@126.com");
-        map.put("passwd","12345qaz");
-        resp = HttpRequest.post("https://chyvpn.cyou/auth/login").form(map).timeout(-1).execute();
-         key = resp.getCookie("key").toString();
-         expire_in = resp.getCookie("expire_in").toString();
-         cookie = "cookie:PHPSESSID=fun75tna6st563e78799552e69; cnxad_lunbo=yes; crisp-client%2Fsession%2F7850791f-bbe4-4874-9f05-c9dea3c63595=session_8a49d3eb-e9c7-43f8-9fe9-12d1560a4122; crisp-client%2Fsession%2F7850791f-bbe4-4874-9f05-c9dea3c63595%2Fc89170bf-a23d-3152-9ad4-fda9810011f7=session_8a49d3eb-e9c7-43f8-9fe9-12d1560a4122; uid=14105; email=351550660%40qq.com; ip=5f0f60145ce69c8054af6bb0a24e9c1a;"+key+"; "+expire_in;
-         ret = HttpRequest.post("https://chyvpn.cyou/user/checkin").cookie(cookie).timeout(-1).execute().body();
-        logger.error("[checkin]:"+ret);
 
 
-        JSONObject json = new JSONObject();
-        json.put("username","linxinkai");
-        json.put("password","Lin123456");
-        String ret2 = HttpUtil.post("https://c4.a0.chat/v1/user/login/",json.toString());
-        String token = JSONUtil.parseObj(ret2).getJSONObject("data").getStr("token");
-        json = new JSONObject();
-        json.put("action","sign_today");
-        ret = HttpRequest.post("https://c4.a0.chat/v1/user/info/").body(json.toString()).header("Authorization",token).timeout(-1).execute().body();
-        logger.error("[checkin]:"+ret);
+//        JSONObject json = new JSONObject();
+//        json.put("username","linxinkai");
+//        json.put("password","Lin123456");
+//        String ret2 = HttpUtil.post("https://c4.a0.chat/v1/user/login/",json.toString());
+//        String token = JSONUtil.parseObj(ret2).getJSONObject("data").getStr("token");
+//        json = new JSONObject();
+//        json.put("action","sign_today");
+//        ret = HttpRequest.post("https://c4.a0.chat/v1/user/info/").body(json.toString()).header("Authorization",token).timeout(-1).execute().body();
+//        logger.error("[checkin]:"+ret);
 
         return ReturnT.SUCCESS;
     }
 
+
+
     public static void main(String[] args) {
-        int quhao = 154;
-        int weihao = 9642;
-        String a = Hex.encodeHexString( new byte[] {(byte)((quhao>>8)&0x00FF),(byte)(quhao&0x00FF),(byte)((weihao>>8)&0x00FF),(byte)(weihao&0x00FF)});
-        System.out.println(a);
-
-        String b = Hex.encodeHexString( new byte[] {(byte)((quhao>>8)&0x00FF),(byte)(quhao&0x00FF)});
-        System.out.println(b);
-        String hex = "009a25aa";
-        int decimal = Integer.parseInt(hex, 16);
-        System.out.println(decimal); // 输出:2571
-        String str = String.format("%09d", decimal);
-        System.out.println(str); // 输出:2571
-        System.out.println(str.substring(0,6)); // 输出:2571
-        System.out.println(str.substring(6)); // 输出:2571
+//        int quhao = 154;
+//        int weihao = 9642;
+//        String a = Hex.encodeHexString( new byte[] {(byte)((quhao>>8)&0x00FF),(byte)(quhao&0x00FF),(byte)((weihao>>8)&0x00FF),(byte)(weihao&0x00FF)});
+//        System.out.println(a);
+//
+//        String b = Hex.encodeHexString( new byte[] {(byte)((quhao>>8)&0x00FF),(byte)(quhao&0x00FF)});
+//        System.out.println(b);
+//        String hex = "009a25aa";
+//        int decimal = Integer.parseInt(hex, 16);
+//        System.out.println(decimal); // 输出:2571
+//        String str = String.format("%09d", decimal);
+//        System.out.println(str); // 输出:2571
+//        System.out.println(str.substring(0,6)); // 输出:2571
+//        System.out.println(str.substring(6)); // 输出:2571
+
+        Map<String,Object> map = new HashMap<>();
+        map.put("email","351550660@qq.com");
+        map.put("passwd","Lin123456");
+        HttpResponse resp = HttpRequest.post("https://chynet01.azureedge.net/auth/login").form(map).timeout(-1).execute();
+        String key = resp.getCookie("key").toString();
+        String expire_in = resp.getCookie("expire_in").toString();
+        String cookie = "cookie:PHPSESSID=fun75tna6st563e78799552e69; cnxad_lunbo=yes; crisp-client%2Fsession%2F7850791f-bbe4-4874-9f05-c9dea3c63595=session_8a49d3eb-e9c7-43f8-9fe9-12d1560a4122; crisp-client%2Fsession%2F7850791f-bbe4-4874-9f05-c9dea3c63595%2Fc89170bf-a23d-3152-9ad4-fda9810011f7=session_8a49d3eb-e9c7-43f8-9fe9-12d1560a4122; uid=14105; email=351550660%40qq.com; ip=5f0f60145ce69c8054af6bb0a24e9c1a;"+key+"; "+expire_in;
+        String ret = HttpRequest.post("https://chynet01.azureedge.net/user/checkin").cookie(cookie).timeout(-1).execute().body();
+        logger.error("[checkin]:"+ret);
     }
 
 

+ 40 - 0
cif-service/src/main/java/com/txz/cif/web/mng/UserController.java

@@ -172,4 +172,44 @@ public class UserController extends AbstractApiController {
     }
 
 
+    @PostMapping("/myUsers")
+    @ApiOperation(value = "获取我的下级用户和下下级",httpMethod = "POST")
+    public Result<List<User>> myUsers(@RequestBody MyUserParam param, HttpServletRequest request, @RequestHeader(value = X_CLIENT_TOKEN_USERID,required = false) Long userId) {
+        PageHelper.startPage(param.getPage(), param.getSize());
+        Condition condition = new Condition(User.class);
+        Example.Criteria criteria = condition.createCriteria();
+        if (param.getType() == 1){
+            criteria.andEqualTo("pid",userId);
+        } else {
+            criteria.andEqualTo("ppid",userId);
+        }
+        if (StrUtil.isNotBlank(param.getName())) {
+            criteria.andLike("name", "%" + param.getName() + "%");
+        }
+        if (StrUtil.isNotBlank(param.getPhone())) {
+            criteria.andEqualTo("phoneNo", param.getPhone());
+        }
+        if (StrUtil.isNotBlank(param.getStartTime())) {
+            criteria.andGreaterThanOrEqualTo("createTime", param.getStartTime());
+        }
+        if (StrUtil.isNotBlank(param.getEndTime())) {
+            criteria.andLessThanOrEqualTo("createTime", param.getEndTime());
+        }
+
+        PageInfo pageInfo = null;
+        try {
+            List<User> list = userService.findByCondition(condition);
+            for (User user2 : list) {
+                user2.setPwd("******");
+                user2.setSalt("***");
+            }
+            pageInfo = new PageInfo(list);
+        } catch (Exception e) {
+            log.error("查询对象操作异常e:{}", e);
+            return ResultGenerator.genFailResult(ResultCode.INTERNAL_SERVER_ERROR);
+        }
+        return ResultGenerator.genSuccessResult(pageInfo);
+    }
+
+
 }