facade-lijin/src/main/java/com/ks/lijin/utils/taobao/TaoBaoOrderUtil.java
@@ -20,7 +20,7 @@ public static void main(String[] args) throws Exception { Date startTime = new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 2); Date endTime = new Date(); List<TaoBaoOrderRecord> orderRecordList = getOrderByModifyTime("124933865", startTime, endTime); List<TaoBaoOrderRecord> orderRecordList = getOrderByModifyTime("1733730164", startTime, endTime); System.out.println(orderRecordList); } @@ -28,8 +28,12 @@ private static Map<String, String> zheTaoKeSidMap = new HashMap<>(); static { //渝小妹自营店 zheTaoKeSidMap.put("472720008", "59407"); //椰视科技 zheTaoKeSidMap.put("124933865", "34097"); //省钱礼金卡 zheTaoKeSidMap.put("1733730164", "69041"); } @@ -275,4 +279,6 @@ return new BigDecimal(order.getPub_share_fee()).add(new BigDecimal(order.getSubsidy_fee())); } } facade-lijin/src/main/java/com/ks/lijin/utils/taobao/TaoKeApiUtil.java
@@ -83,6 +83,7 @@ throw new LiJinAccountException(LiJinAccountException.CODE_TLJ_NO_MONEY, "账户预算不足"); case "FAIL_CHECK_MEMBER_DAILY_SEND_ITEM_ABOVE_LIMIT_ERROR": throw new LiJinAccountException(LiJinAccountException.CODE_TLJ_NO_GOODS, "今日商品创建数已超上限,请您明日再试"); case "DAILY_DRAW_ITEM_ABOVE_LIMIT": case "FAIL_CHECK_ITEM_DAILY_SEND_NUM_CHECK_ERROR": throw new LiJinGoodsException(LiJinGoodsException.CODE_GOODS_CREATED_FULL, "今日该商品淘礼金创建数已超上限,请您明日再试"); @@ -114,23 +115,134 @@ */ public static TaoLiJinReportDTO taolijinReport(String rightsId, TaoKeAppInfo app) { Map<String, String> map = new HashMap<>(); map.put("method", "taobao.tbk.dg.vegas.tlj.instance.report"); map.put("method", "taobao.tbk.dg.vegas.tlj.report"); map.put("adzone_id", app.getPid().split("_")[3]); map.put("rights_id", rightsId); String result = baseRequestForThreeTimes(map, app); JSONObject json = JSONObject.fromObject(result); System.out.println(json); JSONObject root = json.optJSONObject("tbk_dg_vegas_tlj_instance_report_response"); if (root != null && root.optJSONObject("result") != null) { if (root.optJSONObject("result").optBoolean("success")) { JSONObject modelJson = root.optJSONObject("result").optJSONObject("model"); TaoLiJinReportDTO dto = new Gson().fromJson(modelJson.toString(), TaoLiJinReportDTO.class); return dto; } else { // 日志记录 TODO JSONObject root = json.optJSONObject("tbk_dg_vegas_tlj_report_response"); if (root != null && root.optBoolean("result_success")) { JSONObject modelJson = root.optJSONObject("model").optJSONObject("extra"); if (modelJson != null && modelJson.size() > 0) { TaoLiJinReportDTO report = new TaoLiJinReportDTO(); report.setWin_amount(new BigDecimal(modelJson.optString("win_sum_amt"))); report.setWin_num(modelJson.optInt("win_pv")); report.setRefund_amount(new BigDecimal(modelJson.optString("refund_sum_amt"))); report.setRefund_num(modelJson.optInt("refund_num")); report.setAlipay_amount(new BigDecimal(modelJson.optString("alipay_amt"))); report.setUse_amount(new BigDecimal(modelJson.optString("use_sum_amt"))); report.setUse_num(modelJson.optInt("use_num")); report.setUnfreeze_amount(new BigDecimal(modelJson.optString("remaining_amt"))); report.setUnfreeze_num(modelJson.optInt("remaining_num")); report.setPre_commission_amount(new BigDecimal(modelJson.optString("pre_pub_share_fee_for_disp"))); return report; } } // if (root != null && root.optJSONObject("result") != null) { // if (root.optJSONObject("result").optBoolean("success")) { // JSONObject modelJson = root.optJSONObject("result").optJSONObject("model"); // TaoLiJinReportDTO dto = new Gson().fromJson(modelJson.toString(), TaoLiJinReportDTO.class); // return dto; // } else { // // 日志记录 TODO // } // } return null; } // 裂淘礼金创建 public static TaoLiJinDTO createLieBianTaoLiJin(Long auctionId, String name, BigDecimal perface, int totalNum, Date sendStartTime, Date sendEndTime, Date useStartTime, Date useEndTime, TaoKeAppInfo app) throws LiJinAccountException, LiJinAmountException, LiJinException, LiJinGoodsException { Map<String, String> map = new HashMap<>(); map.put("method", "taobao.tbk.dg.vegas.lbtlj.create"); map.put("adzone_id", app.getPid().split("_")[3]); map.put("item_id", auctionId + ""); //淘礼金总个数 map.put("rights_num", totalNum + ""); //裂变淘礼金总个数 map.put("task_rights_num", totalNum + ""); //裂变单个淘礼金面额,支持两位小数,单位元 map.put("task_rights_per_face", "1.01"); //裂变淘礼金邀请人数 map.put("invite_num", "2"); //裂变淘礼金邀请时长;单位:分钟;最大120分钟 map.put("invite_time_limit", "60"); map.put("name", name); map.put("user_total_win_num_limit", "1"); map.put("security_switch", "false"); map.put("rights_per_face", perface.toString()); map.put("send_start_time", TimeUtil.getGernalTime(sendStartTime.getTime(), "yyyy-MM-dd HH:mm:ss")); if (sendEndTime != null) map.put("send_end_time", TimeUtil.getGernalTime(sendEndTime.getTime(), "yyyy-MM-dd HH:mm:ss")); if (useEndTime != null) { map.put("use_end_time", TimeUtil.getGernalTime(useEndTime.getTime(), "yyyy-MM-dd")); map.put("use_end_time_mode", "2"); } map.put("accept_start_time", TimeUtil.getGernalTime(sendStartTime.getTime(), "yyyy-MM-dd HH:mm:ss")); map.put("accept_end_time", TimeUtil.getGernalTime(sendEndTime.getTime(), "yyyy-MM-dd HH:mm:ss")); if (useStartTime != null) map.put("use_start_time", TimeUtil.getGernalTime(useStartTime.getTime(), "yyyy-MM-dd")); try { String result = baseRequestForThreeTimes(map, app); JSONObject json = JSONObject.fromObject(result); System.out.println(result); JSONObject root = json.optJSONObject("tbk_dg_vegas_tlj_create_response"); if (root != null && root.optJSONObject("result") != null) { if (root.optJSONObject("result").optBoolean("success")) { JSONObject modelJson = root.optJSONObject("result").optJSONObject("model"); TaoLiJinDTO dto = new TaoLiJinDTO(); dto.setRightsId(modelJson.optString("rights_id")); dto.setSendUrl(modelJson.optString("send_url")); return dto; } else { // 日志记录 TODO } // 接口返回异常 String msgCode = root.optJSONObject("result").optString("msg_code"); String msgInfo = root.optJSONObject("result").optString("msg_info"); if (!StringUtil.isNullOrEmpty(msgCode)) { // TLJLogHelper.info(auctionId, root.toString());// 淘礼金异常信息记录 TODO switch (msgCode) { case "FAIL_BIZ_ITEM_FORBIDDEN": throw new LiJinGoodsException(LiJinGoodsException.CODE_GOODS_NOT_SUPPORT, "该商品不支持创建淘礼金红包"); case "FAIL_BIZ_ACCOUNT_UN_PAID": throw new LiJinAccountException(LiJinAccountException.CODE_TLJ_UN_PAID, "您的淘礼金账户暂未创建,请前往资金管理页面充值"); case "PRE_FREEZE_ASSET_ACCOUNT_ERROR": throw new LiJinAccountException(LiJinAccountException.CODE_TLJ_NO_MONEY, "官方玩法钱包余额不足"); case "ASSET_ACCOUNT_BALANCE_NOT_ENOUGH": throw new LiJinAccountException(LiJinAccountException.CODE_TLJ_NO_MONEY, "账户预算不足"); case "FAIL_CHECK_MEMBER_DAILY_SEND_ITEM_ABOVE_LIMIT_ERROR": throw new LiJinAccountException(LiJinAccountException.CODE_TLJ_NO_GOODS, "今日商品创建数已超上限,请您明日再试"); case "DAILY_DRAW_ITEM_ABOVE_LIMIT": case "FAIL_CHECK_ITEM_DAILY_SEND_NUM_CHECK_ERROR": throw new LiJinGoodsException(LiJinGoodsException.CODE_GOODS_CREATED_FULL, "今日该商品淘礼金创建数已超上限,请您明日再试"); case "FAIL_CHECK_TLJ_MIN_FACE_ERROR": throw new LiJinAmountException(LiJinAmountException.CODE_LIJIN_AMOUNT_OUTOFRANGE, msgInfo); default: throw new LiJinException(1, root.toString()); } } } } catch (LiJinException e) { throw e; } return null; } @@ -635,8 +747,31 @@ public static void main(String[] args) { TaoLiJinReportDTO dto = taolijinReport("eC2%2FoV8gigdzVO5CvuRDjDVC0SEP1L7d", new TaoKeAppInfo("27743325", "527a23554f71557d7b786bc479fcd5fe")); System.out.println(dto); // TaoLiJinReportDTO dto = taolijinReport("eC2%2FoV8gigdzVO5CvuRDjDVC0SEP1L7d", new TaoKeAppInfo("27743325", "527a23554f71557d7b786bc479fcd5fe")); // System.out.println(dto); TaoKeAppInfo app = new TaoKeAppInfo("24980167", "e0a2e05deabf5ce039b52e5b492d5382", "mm_124933865_56750082_19511350325"); Long auctionId = 648785782467L; String name = "裂变淘礼金"; BigDecimal perface = new BigDecimal(1); int totalNum = 1; Date sendStartTime = new Date(); Date sendEndTime = new Date(System.currentTimeMillis() + 1000 * 60 * 60 * 4L); Date useStartTime = sendStartTime; Date useEndTime = sendEndTime; try { createLieBianTaoLiJin(auctionId, name, perface, totalNum, sendStartTime, sendEndTime, useStartTime, useEndTime, app); } catch (LiJinAccountException e) { e.printStackTrace(); } catch (LiJinAmountException e) { e.printStackTrace(); } catch (LiJinException e) { e.printStackTrace(); } catch (LiJinGoodsException e) { e.printStackTrace(); } } } pom.xml
@@ -40,6 +40,17 @@ <url>http://193.112.35.168:8081/nexus/content/groups/public/</url> </repository> <repository> <id>sonatype-nexus-snapshots</id> <url>https://oss.sonatype.org/content/repositories/snapshots</url> <releases> <enabled>false</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> <dependencies> @@ -304,6 +315,8 @@ </build> <distributionManagement> <repository> <id>java-release</id> <name>java-release</name> service-lijin/pom.xml
@@ -30,26 +30,26 @@ <version>0.0.1-SNAPSHOT</version> </dependency> <!-- <dependency> <groupId>com.ks</groupId> <artifactId>facade-app</artifactId> <version>0.0.1-SNAPSHOT</version> </dependency>--> <!-- <dependency> <groupId>com.ks</groupId> <artifactId>facade-app</artifactId> <version>0.0.1-SNAPSHOT</version> </dependency>--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <!-- <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-config</artifactId> </dependency> <!-- <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-config</artifactId> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-web</artifactId> </dependency>--> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-web</artifactId> </dependency>--> <dependency> <groupId>org.springframework.boot</groupId> @@ -120,7 +120,6 @@ </dependency> <dependency> <groupId>com.qcloud</groupId> <artifactId>cmq-http-client</artifactId> @@ -139,10 +138,10 @@ <!--devtools热部署--> <!--<dependency>--> <!--<groupId>org.springframework.boot</groupId>--> <!--<artifactId>spring-boot-devtools</artifactId>--> <!--<optional>true</optional>--> <!--<scope>true</scope>--> <!--<groupId>org.springframework.boot</groupId>--> <!--<artifactId>spring-boot-devtools</artifactId>--> <!--<optional>true</optional>--> <!--<scope>true</scope>--> <!--</dependency>--> <dependency> <groupId>com.ks</groupId> @@ -150,16 +149,6 @@ <version>0.0.1-SNAPSHOT</version> </dependency> <!--<dependency>--> <!--<groupId>log4j</groupId>--> <!--<artifactId>log4j</artifactId>--> <!--<exclusions>--> <!--<exclusion>--> <!--<groupId>*</groupId>--> <!--<artifactId>*</artifactId>--> <!--</exclusion>--> <!--</exclusions>--> <!--</dependency>--> </dependencies> @@ -175,40 +164,40 @@ </plugin> <!-- MyBatis插件 --> <!--<plugin>--> <!--<groupId>org.mybatis.generator</groupId>--> <!--<artifactId>mybatis-generator-maven-plugin</artifactId>--> <!--<version>1.3.2</version>--> <!--<configuration>--> <!--<!–配置文件的位置–>--> <!--<configurationFile>src/main/resources/generatorConfig.xml</configurationFile>--> <!--<verbose>true</verbose>--> <!--<overwrite>true</overwrite>--> <!--</configuration>--> <!--<executions>--> <!--<execution>--> <!--<id>Generate MyBatis Artifacts</id>--> <!--<goals>--> <!--<goal>generate</goal>--> <!--</goals>--> <!--</execution>--> <!--</executions>--> <!--<dependencies>--> <!--<dependency>--> <!--<groupId>org.mybatis.generator</groupId>--> <!--<artifactId>mybatis-generator-core</artifactId>--> <!--<version>1.3.2</version>--> <!--</dependency>--> <!--</dependencies>--> <!--<groupId>org.mybatis.generator</groupId>--> <!--<artifactId>mybatis-generator-maven-plugin</artifactId>--> <!--<version>1.3.2</version>--> <!--<configuration>--> <!--<!–配置文件的位置–>--> <!--<configurationFile>src/main/resources/generatorConfig.xml</configurationFile>--> <!--<verbose>true</verbose>--> <!--<overwrite>true</overwrite>--> <!--</configuration>--> <!--<executions>--> <!--<execution>--> <!--<id>Generate MyBatis Artifacts</id>--> <!--<goals>--> <!--<goal>generate</goal>--> <!--</goals>--> <!--</execution>--> <!--</executions>--> <!--<dependencies>--> <!--<dependency>--> <!--<groupId>org.mybatis.generator</groupId>--> <!--<artifactId>mybatis-generator-core</artifactId>--> <!--<version>1.3.2</version>--> <!--</dependency>--> <!--</dependencies>--> <!--</plugin>--> <!--<plugin>--> <!--<groupId>com.ks</groupId>--> <!--<artifactId>generater-maven-plugin</artifactId>--> <!--<version>1.0.0</version>--> <!--<configuration>--> <!--<!–配置文件的位置–>--> <!--<configurationFile>src/main/resources/generatorConfig.xml</configurationFile>--> <!--</configuration>--> <!--<groupId>com.ks</groupId>--> <!--<artifactId>generater-maven-plugin</artifactId>--> <!--<version>1.0.0</version>--> <!--<configuration>--> <!--<!–配置文件的位置–>--> <!--<configurationFile>src/main/resources/generatorConfig.xml</configurationFile>--> <!--</configuration>--> <!--</plugin>--> </plugins> service-lijin/src/main/java/com/ks/lijin/config/RedisConfig.java
@@ -12,7 +12,6 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; import org.springframework.data.redis.serializer.StringRedisSerializer; import org.yeshi.utils.StringUtil; import redis.clients.jedis.JedisPool; import redis.clients.jedis.JedisPoolConfig; service-lijin/src/main/java/com/ks/lijin/config/ZipkinConfiguration.java
New file @@ -0,0 +1,38 @@ package com.ks.lijin.config; import org.springframework.context.annotation.Configuration; @Configuration public class ZipkinConfiguration { // // @Value("${zipkin.http.sender.address}") // private String address; // // @Value("${zipkin.http.sender.connectTimeout}") // private int connectTimeout; // // @Value("${zipkin.http.sender.readTimeout}") // private int readTimeout; // // @Value("${zipkin.brave.name}") // private String braveName; // // // @Bean // public Tracing tracing() { // Sender sender = OkHttpSender.create(address); // AsyncReporter reporter = AsyncReporter.builder(sender) // .closeTimeout(connectTimeout, TimeUnit.MILLISECONDS) // .messageTimeout(readTimeout, TimeUnit.MILLISECONDS) // .build(); // Tracing tracing = Tracing.newBuilder() // .localServiceName(braveName) // .propagationFactory(ExtraFieldPropagation.newFactory(B3Propagation.FACTORY, "shiliew")) // .sampler(Sampler.ALWAYS_SAMPLE) // .spanReporter(reporter) // .build(); // return tracing; // } } service-lijin/src/main/java/com/ks/lijin/controller/TestController.java
@@ -1,5 +1,10 @@ package com.ks.lijin.controller; import com.google.gson.Gson; import com.ks.vip.pojo.DO.VipGrade; import com.ks.vip.pojo.Enums.VIPEnum; import com.ks.vip.service.VipGradeService; import org.apache.dubbo.config.annotation.Reference; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; @@ -15,6 +20,9 @@ @Resource private RedisTemplate redisTemplate; @Reference(version = "1.0") private VipGradeService vipGradeService; @ResponseBody @RequestMapping("redis") public String testRedis(String uid) throws Exception { @@ -30,4 +38,11 @@ } } @ResponseBody @RequestMapping("vip") public String testVip(String uid) throws Exception { VipGrade grade = vipGradeService.getByVipEnum(VIPEnum.platinum); return new Gson().toJson(grade); } } service-lijin/src/main/java/com/ks/lijin/service/manager/LiJinProviderTaoKeAccountManager.java
@@ -52,6 +52,8 @@ Jedis jedis = jedisPool.getResource(); try { todayMoney = Long.parseLong(jedis.get(accountMoneyKey) + ""); } catch (NumberFormatException e) { jedis.set(accountMoneyKey, money.multiply(new BigDecimal(100)).intValue() + ""); } finally { jedis.close(); } service-lijin/src/main/resources/application-test.yml
@@ -84,7 +84,6 @@ registry: protocol: zookeeper address: zookeeper://193.112.35.168:2182 # address: zookeeper://118.195.138.153:2181 client: curator protocol: name: dubbo service-lijin/src/test/java/com/ks/LiJinTest.java
New file @@ -0,0 +1,23 @@ package com.ks; import com.ks.lijin.pojo.DTO.taobao.TaoKeAppInfo; import com.ks.lijin.pojo.DTO.taobao.TaoLiJinReportDTO; import com.ks.lijin.utils.taobao.TaoKeApiUtil; import org.junit.Test; /** * @author hxh * @title: LiJinTest * @description: 淘礼金测试 * @date 2022/1/11 11:07 */ public class LiJinTest { @Test public void reportTest() { TaoLiJinReportDTO reportDTO = TaoKeApiUtil.taolijinReport("o7glbp2JdIvauOg1sYOH9PBHbMJeNzdw", new TaoKeAppInfo("24980167", "e0a2e05deabf5ce039b52e5b492d5382", "mm_124933865_56750082_19511350325")); System.out.println(reportDTO); } } service-vip/src/main/java/com/ks/vip/config/ZipkinConfiguration.java
New file @@ -0,0 +1,38 @@ package com.ks.vip.config; import org.springframework.context.annotation.Configuration; @Configuration public class ZipkinConfiguration { // // @Value("${zipkin.http.sender.address}") // private String address; // // @Value("${zipkin.http.sender.connectTimeout}") // private int connectTimeout; // // @Value("${zipkin.http.sender.readTimeout}") // private int readTimeout; // // @Value("${zipkin.brave.name}") // private String braveName; // // // @Bean // public Tracing tracing() { // Sender sender = OkHttpSender.create(address); // AsyncReporter reporter = AsyncReporter.builder(sender) // .closeTimeout(connectTimeout, TimeUnit.MILLISECONDS) // .messageTimeout(readTimeout, TimeUnit.MILLISECONDS) // .build(); // Tracing tracing = Tracing.newBuilder() // .localServiceName(braveName) // .propagationFactory(ExtraFieldPropagation.newFactory(B3Propagation.FACTORY, "shiliew")) // .sampler(Sampler.ALWAYS_SAMPLE) // .spanReporter(reporter) // .build(); // return tracing; // } } service-vip/src/main/resources/application-test.yml
@@ -59,6 +59,7 @@ max-idle: 200 max-total: 1024 database: 9 mybatis: mapper-locations : classpath:mapper/*.xml type-aliases-package: com.ks.vip.pojo.DO @@ -69,7 +70,7 @@ dubbo: application: name: lijin-provider name: vip-provider registry: protocol: zookeeper address: zookeeper://193.112.35.168:2182 @@ -83,6 +84,8 @@ provider: timeout: 10000 host: 127.0.0.1 retries: 0 xxl: job: accessToken: @@ -103,6 +106,9 @@ org.springframework.data.mongodb.core: DEBUG # config: classpath:logback.xml log: config: kafka: