| | |
| | | try {
|
| | | userShareGoodsRecordService.takeEffectShareRecord(acceptData, shareId);
|
| | | } catch (UserShareGoodsRecordException eu) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(eu);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | |
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | |
| | | da.setMac(mac);
|
| | | deviceActiveService.addDeviceActive(da);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | // 用户等级更新
|
| | |
| | | import com.yeshi.fanli.entity.bus.user.ShamUser;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserMoneyExtra;
|
| | | import com.yeshi.fanli.entity.common.JumpDetailV2;
|
| | | import com.yeshi.fanli.entity.goods.CollectionGoodsV2;
|
| | | import com.yeshi.fanli.entity.jd.JDGoods;
|
| | | import com.yeshi.fanli.entity.system.BusinessSystem;
|
| | |
| | | @Repository
|
| | | public class DouYinClickEventDao extends MongodbBaseDao<DouYinClickEvent> {
|
| | |
|
| | | public DouYinClickEvent selectByAid(String aid) {
|
| | | public DouYinClickEvent selectByCallBack(String callback) {
|
| | | Query query = new Query();
|
| | | query.addCriteria(Criteria.where("aid").is(aid));
|
| | | query.addCriteria(Criteria.where("callback").is(callback));
|
| | | return findOne(query);
|
| | | }
|
| | |
|
| | |
| | | public final static int TYPE_DEVICE = 2;
|
| | |
|
| | | private int type;
|
| | | private String aid;
|
| | | private String callback;
|
| | | private String device;
|
| | | private int platform;
|
| | |
|
| | | public DouYinDeviceActiveQueueDTO() {
|
| | | }
|
| | |
|
| | | public DouYinDeviceActiveQueueDTO(int type, String aid) {
|
| | | public DouYinDeviceActiveQueueDTO(int type, String callback) {
|
| | | this.type = type;
|
| | | this.aid = aid;
|
| | | this.callback = callback;
|
| | | }
|
| | |
|
| | | public DouYinDeviceActiveQueueDTO(int type, String device, int platform) {
|
| | |
| | | this.type = type;
|
| | | }
|
| | |
|
| | | public String getAid() {
|
| | | return aid;
|
| | | }
|
| | |
|
| | | public void setAid(String aid) {
|
| | | this.aid = aid;
|
| | | }
|
| | |
|
| | | public String getDevice() {
|
| | | return device;
|
| | | }
|
| | |
| | | public void setDevice(String device) {
|
| | | this.device = device;
|
| | | }
|
| | |
|
| | | public String getCallback() {
|
| | | return callback;
|
| | | }
|
| | |
|
| | | public void setCallback(String callback) {
|
| | | this.callback = callback;
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | public final static String MONITOR__LINK__PARAMS = "aid=__AID__&aidName=__AID__NAME__&campaignId=__CAMPAIGN__ID__&cid=__CID__&csite=__CSITE__&ctype=__CTYPE__&mac=__MAC__&mac1=__MAC1__&ua=__UA__&idfa=__IDFA__&imei=__IMEI__&uuid=__UUID__&androidId=__ANDROIDID__&openUDID=__OPENUDID__&os=__OS__&ip=__IP__&ts=__TS__&convertId=__CONVERT__ID __&callback=__CALLBACK__PARAM __";// 监测链接
|
| | |
|
| | | @Id
|
| | | @Field
|
| | | private String aid; // 广告计划id 原值
|
| | | @Field
|
| | |
| | | @Field
|
| | | private int ctype; // 创意样式 2=小图模式 3=大图模式 4=组图模式 5=视频
|
| | | @Field
|
| | | private String mac; // MAC地址 去除分隔符 ":",(采用获取原始值)取 md5sum // 摘要(备注:入网硬件地址)例:38978B891A08
|
| | | private String mac; // MAC地址 去除分隔符 ":",(采用获取原始值)取 md5sum //
|
| | | // 摘要(备注:入网硬件地址)例:38978B891A08
|
| | | @Field
|
| | | private String mac1; // 用户终端的eth0接口的MAC地址 保留分隔符 ":",(采用获取原始值)取 md5sum
|
| | | @Field // 摘要(备注:入网硬件地址) 例:38:97:8B:89:1A:08
|
| | |
| | | private long ts; // 客户端发生广告点击事件的时间 UNIX时间戳
|
| | | @Field
|
| | | private String convertId; // 转化id 原值
|
| | | @Id
|
| | | @Field
|
| | | private String callback;// 回调参数(方案二) 见后文
|
| | |
|
| | |
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="ipInfo != null">#{ipInfo,jdbcType=VARCHAR},</if> |
| | | <if test="channel != null">#{channel,jdbcType=VARCHAR}</if> |
| | | <if test="imei != null">#{imei,jdbcType=VARCHAR}</if> |
| | | <if test="idfa != null">#{idfa,jdbcType=VARCHAR}</if> |
| | | <if test="mac != null">#{mac,jdbcType=VARCHAR}</if> |
| | | <if test="channel != null">#{channel,jdbcType=VARCHAR},</if> |
| | | <if test="imei != null">#{imei,jdbcType=VARCHAR},</if> |
| | | <if test="idfa != null">#{idfa,jdbcType=VARCHAR},</if> |
| | | <if test="mac != null">#{mac,jdbcType=VARCHAR},</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.push.DeviceActive">update |
| | |
| | | @Override
|
| | | public void save(DouYinClickEvent event) {
|
| | | // 查询
|
| | | DouYinClickEvent old = douYinClickEventDao.selectByAid(event.getAid());
|
| | | DouYinClickEvent old = douYinClickEventDao.selectByCallBack(event.getCallback());
|
| | | if (old == null) {
|
| | | douYinClickEventDao.save(event);
|
| | | DouYinDeviceActiveCMQManager.getInstance().addAdActive(event.getAid());
|
| | | DouYinDeviceActiveCMQManager.getInstance().addAdActive(event.getCallback());
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public DouYinClickEvent selectByAid(String aid) {
|
| | | return douYinClickEventDao.selectByAid(aid);
|
| | | public DouYinClickEvent selectByCallback(String callback) {
|
| | | return douYinClickEventDao.selectByCallBack(callback);
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | hongBaoV2Service.updateByPrimaryKeySelective(update);
|
| | | }
|
| | | }
|
| | | } else if (hongBaoOder.getHongBaoV2() != null
|
| | | && hongBaoOder.getHongBaoV2().getState() == HongBaoV2.STATE_YILINGQU) {
|
| | | List<HongBaoV2> childList = hongBaoV2Service.listChildrenById(hongBaoOder.getHongBaoV2().getId());
|
| | | for (HongBaoV2 child : childList) {
|
| | | if ((child.getState() == HongBaoV2.STATE_BUKELINGQU
|
| | | || child.getState() == HongBaoV2.STATE_KELINGQU)) {
|
| | | //未到账的子红包也需要失效
|
| | | HongBaoV2 update = new HongBaoV2(child.getId());
|
| | | update.setUpdateTime(new Date());
|
| | | update.setState(HongBaoV2.STATE_SHIXIAO);
|
| | | update.setBeizhu("联盟违规");
|
| | | hongBaoV2Service.updateByPrimaryKeySelective(update);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | * @param aid
|
| | | * @return
|
| | | */
|
| | | public DouYinClickEvent selectByAid(String aid);
|
| | | public DouYinClickEvent selectByCallback(String callback);
|
| | |
|
| | | /**
|
| | | * 根据androidID查询
|
| | |
| | | String key = its.next();
|
| | | DouYinDeviceActiveQueueDTO active = map.get(key);
|
| | | if (active.getType() == DouYinDeviceActiveQueueDTO.TYPE_AD) {// 抖音
|
| | | DouYinClickEvent event = douYinClickEventService.selectByAid(active.getAid());
|
| | | DouYinClickEvent event = douYinClickEventService.selectByCallback(active.getCallback());
|
| | | if (event != null) {
|
| | | if (event.getOs() == 0) {
|
| | | DeviceActive deviceActive = deviceActiveService
|
New file |
| | |
| | | package com.yeshi.fanli.util.charge;
|
| | |
|
| | | import java.io.IOException;
|
| | | import java.util.Arrays;
|
| | | import java.util.HashMap;
|
| | | import java.util.Map;
|
| | |
|
| | | import org.apache.commons.httpclient.HttpClient;
|
| | | import org.apache.commons.httpclient.HttpException;
|
| | | import org.apache.commons.httpclient.methods.PostMethod;
|
| | |
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | /**
|
| | | * 福录开放平台API入口(open.fulu.com)
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | public class FuLuChargeApiUtil {
|
| | | //测试
|
| | | // private final static String APP_KEY = "i4esv1l+76l/7NQCL3QudG90Fq+YgVfFGJAWgT+7qO1Bm9o/adG/1iwO2qXsAXNB";
|
| | | // private final static String APP_SECRET = "0a091b3aa4324435aab703142518a8f7";
|
| | | //正式
|
| | | private final static String APP_KEY = "CrtDnTh1E5eYY5D42T8uArVrl4GWq9AWR9ZrNC2qvXYIBMwOTuiJQy7YYaJSYlb6";
|
| | | private final static String APP_SECRET = "a5f6c827903e4b1eac6eb2ba2cf715be";
|
| | |
|
| | | @SuppressWarnings("deprecation")
|
| | | private static String post(String url, String body) {
|
| | | HttpClient client = new HttpClient();
|
| | | client.getHostConfiguration().setProxy("192.168.1.122", 8888);
|
| | | PostMethod method = new PostMethod(url);
|
| | | method.addRequestHeader("Content-Type", "application/json;charset=UTF-8");
|
| | | method.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
|
| | | method.setRequestBody(body);
|
| | | try {
|
| | | client.executeMethod(method);
|
| | | return method.getResponseBodyAsString();
|
| | | } catch (HttpException e) {
|
| | | e.printStackTrace();
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | private static void baseRequest(String method, JSONObject bizContent) {
|
| | | // String url = "http://pre.openapi.fulu.com/api/getway";
|
| | | String url="http://openapi.fulu.com/api/getway";
|
| | | Map<String, String> params = new HashMap<>();
|
| | | params.put("app_key", APP_KEY);
|
| | | params.put("method", method);
|
| | | params.put("timestamp", TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss"));
|
| | | params.put("version", "2.0");
|
| | | params.put("format", "json");
|
| | | params.put("charset", "utf-8");
|
| | | params.put("sign_type", "md5");
|
| | | params.put("app_auth_token", "");
|
| | | params.put("biz_content", bizContent.toString());
|
| | | JSONObject resultJson = JSONObject.fromObject(params);
|
| | | char[] s = resultJson.toString().toCharArray();
|
| | | Arrays.sort(s);
|
| | | String outputSignOriginalStr = new String(s) + APP_SECRET;
|
| | | String sign = StringUtil.Md5(outputSignOriginalStr);
|
| | | params.put("sign", sign);
|
| | | String result = post(url, JSONObject.fromObject(params).toString());
|
| | | System.out.println(result);
|
| | | }
|
| | |
|
| | | public static void charge(String goodsNo, String orderId, String account) {
|
| | | JSONObject json = new JSONObject();
|
| | | json.put("charge_type", "爱奇艺会员");
|
| | | json.put("customer_order_no", orderId);
|
| | | json.put("product_id", goodsNo);
|
| | | json.put("charge_account", account);
|
| | | json.put("buy_num", "1");
|
| | | baseRequest("fulu.order.direct.add", json);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | cmqUtil.sendMsg(DOUYIN_DEVICE_ACTIVE, new Gson().toJson(dto));
|
| | | }
|
| | |
|
| | | public void addAdActive(String aid) {
|
| | | if (StringUtil.isNullOrEmpty(aid))
|
| | | public void addAdActive(String callback) {
|
| | | if (StringUtil.isNullOrEmpty(callback))
|
| | | return;
|
| | | DouYinDeviceActiveQueueDTO dto = new DouYinDeviceActiveQueueDTO(DouYinDeviceActiveQueueDTO.TYPE_AD, aid);
|
| | | DouYinDeviceActiveQueueDTO dto = new DouYinDeviceActiveQueueDTO(DouYinDeviceActiveQueueDTO.TYPE_AD, callback);
|
| | | cmqUtil.sendMsg(DOUYIN_DEVICE_ACTIVE, new Gson().toJson(dto));
|
| | | }
|
| | |
|
| | |
| | | package com.yeshi.fanli.util.vip;
|
| | |
|
| | | import java.io.IOException;
|
| | | import java.io.UnsupportedEncodingException;
|
| | | import java.net.URLEncoder;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Collections;
|
| | | import java.util.HashMap;
|
| | | import java.util.Iterator;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import org.apache.commons.httpclient.HttpClient;
|
| | | import org.apache.commons.httpclient.HttpException;
|
| | | import org.apache.commons.httpclient.methods.PostMethod;
|
| | | import org.yeshi.utils.StringUtil;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | /**
|
| | | * TODO 未完成 唯品会接口
|
| | |
| | | private final static String appKey = "f9e7f22f";
|
| | | private final static String appSecret = "9B2291352497FAF42B2DF44BFCF62316";
|
| | |
|
| | | private static String getSign() {
|
| | |
|
| | | return null;
|
| | | /**
|
| | | * 获取签名
|
| | | * |
| | | * @param params
|
| | | * @return
|
| | | */
|
| | | private static String getSign(Map<String, String> systemParams, JSONObject taskParams) {
|
| | | List<String> list = new ArrayList<>();
|
| | | for (Iterator<String> its = systemParams.keySet().iterator(); its.hasNext();) {
|
| | | String key = its.next();
|
| | | String value = systemParams.get(key);
|
| | | list.add(key + value);
|
| | | }
|
| | | Collections.sort(list);
|
| | | String source = "";
|
| | | for (String st : list)
|
| | | source += st;
|
| | | source += taskParams.toString();
|
| | | return StringUtil.MD5Hmac(source, appSecret);
|
| | | }
|
| | |
|
| | | private static Map<String, String> getBaseParams(String service, String method) {
|
| | | private static Map<String, String> getSystemParams(String service, String method) {
|
| | | Map<String, String> params = new HashMap<String, String>();
|
| | | params.put("service", service);
|
| | | params.put("method", method);
|
| | |
| | | params.put("timestamp", System.currentTimeMillis() / 1000 + "");
|
| | | params.put("format", "json");
|
| | | params.put("appKey", appKey);
|
| | | params.put("sign", null);
|
| | | return params;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 基础请求
|
| | | * |
| | | * @param service
|
| | | * @param method
|
| | | * @param taskParams
|
| | | * @return
|
| | | */
|
| | | private static String baseRequest(String service, String method, Map<String, String> taskParams) {
|
| | | Map<String, String> systemParams = getSystemParams(service, method);
|
| | | JSONObject json = new JSONObject();
|
| | | for (Iterator<String> its = taskParams.keySet().iterator(); its.hasNext();) {
|
| | | String key = its.next();
|
| | | String value = taskParams.get(key);
|
| | | json.put(key, value);
|
| | | }
|
| | | JSONObject root = new JSONObject();
|
| | | root.put("request",json);
|
| | | |
| | | String sign = getSign(systemParams, root);
|
| | | systemParams.put("sign", sign);
|
| | | String baseUrl = "https://gw.vipapis.com";
|
| | | baseUrl += "?";
|
| | | for (Iterator<String> its = systemParams.keySet().iterator(); its.hasNext();) {
|
| | | String key = its.next();
|
| | | String value = "";
|
| | | try {
|
| | | value = URLEncoder.encode(systemParams.get(key), "UTF-8");
|
| | | } catch (UnsupportedEncodingException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | baseUrl += key + "=" + value + "&";
|
| | | }
|
| | | baseUrl = baseUrl.endsWith("&") ? baseUrl.substring(0, baseUrl.length() - 1) : baseUrl;
|
| | | String result = post(baseUrl, root.toString());
|
| | | return result;
|
| | | }
|
| | |
|
| | | @SuppressWarnings("deprecation")
|
| | | private static String post(String url, String body) {
|
| | | HttpClient client = new HttpClient();
|
| | | PostMethod method = new PostMethod(url);
|
| | | method.addRequestHeader("Content-Type", "application/json;charset=UTF-8");
|
| | | method.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
|
| | | method.setRequestBody(body);
|
| | | try {
|
| | | client.executeMethod(method);
|
| | | return method.getResponseBodyAsString();
|
| | | } catch (HttpException e) {
|
| | | e.printStackTrace();
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | public static void search() {
|
| | | Map<String, String> taskParams = new HashMap<>();
|
| | | taskParams.put("keyword","笔记本");
|
| | | taskParams.put("page", "1");
|
| | | taskParams.put("pageSize", "20");
|
| | | taskParams.put("requestId", System.currentTimeMillis() + "");
|
| | | // taskParams.put("priceStart", "");
|
| | | // taskParams.put("priceEnd", "");
|
| | | String result = baseRequest("com.vip.adp.api.open.service.UnionGoodsService", "query", taskParams);
|
| | | System.out.println(result);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | package org.yeshi.utils;
|
| | |
|
| | | import java.io.IOException;
|
| | | import java.io.UnsupportedEncodingException;
|
| | | import java.lang.reflect.Method;
|
| | | import java.security.InvalidKeyException;
|
| | | import java.security.MessageDigest;
|
| | | import java.security.NoSuchAlgorithmException;
|
| | | import java.util.regex.Matcher;
|
| | | import java.util.regex.Pattern;
|
| | |
|
| | | import org.apache.commons.codec.binary.Base64;
|
| | | import org.yeshi.utils.encrypt.HmacUtils;
|
| | |
|
| | | import sun.misc.BASE64Encoder;
|
| | |
|
| | |
| | | return null;
|
| | | }
|
| | |
|
| | | public static String MD5Hmac(String st, String key) {
|
| | | try {
|
| | | return HmacUtils.byte2hex(HmacUtils.encryptHMAC(st, key));
|
| | | } catch (InvalidKeyException e) {
|
| | | e.printStackTrace();
|
| | | } catch (NoSuchAlgorithmException e) {
|
| | | e.printStackTrace();
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 将null转为空字符串
|
| | | *
|
New file |
| | |
| | | package org.yeshi.utils.encrypt;
|
| | |
|
| | | import java.io.IOException;
|
| | | import java.security.InvalidKeyException;
|
| | | import java.security.NoSuchAlgorithmException;
|
| | | import javax.crypto.Mac;
|
| | | import javax.crypto.SecretKey;
|
| | | import javax.crypto.spec.SecretKeySpec;
|
| | |
|
| | | /**
|
| | | * hmac公用方法类
|
| | | * |
| | | * @author weihui.tang
|
| | | * |
| | | */
|
| | | public class HmacUtils {
|
| | | public static final String CHARSET_UTF8 = "UTF-8";
|
| | |
|
| | | public static final String KEY_MAC = "HmacMD5";
|
| | |
|
| | | private static final String HEXSTR = "0123456789ABCDEF";
|
| | |
|
| | | private static String[] binaryArray = { "0000", "0001", "0010", "0011",
|
| | | "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011",
|
| | | "1100", "1101", "1110", "1111" };
|
| | |
|
| | | |
| | |
|
| | | /**
|
| | | * hmac-md5签名
|
| | | * |
| | | * @param data
|
| | | * @param secret
|
| | | * @return
|
| | | * @throws IOException
|
| | | * @throws NoSuchAlgorithmException |
| | | * @throws InvalidKeyException |
| | | */
|
| | | public static byte[] encryptHMAC(String data, String secret)
|
| | | throws IOException, NoSuchAlgorithmException, InvalidKeyException {
|
| | | byte[] bytes = null;
|
| | | SecretKey secretKey = new SecretKeySpec(secret.getBytes(CHARSET_UTF8),
|
| | | KEY_MAC);
|
| | | Mac mac = Mac.getInstance(secretKey.getAlgorithm());
|
| | | mac.init(secretKey);
|
| | | bytes = mac.doFinal(data.getBytes(CHARSET_UTF8));
|
| | | return bytes;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 将byte转化为十六进制字符串
|
| | | * |
| | | * @param bytes
|
| | | * @return
|
| | | */
|
| | | public static String byte2hex(byte[] bytes) {
|
| | | StringBuilder sign = new StringBuilder();
|
| | | for (int i = 0; i < bytes.length; i++) {
|
| | | sign.append(String.valueOf(HEXSTR.charAt((bytes[i] & 0xF0) >> 4))); // 字节高4位
|
| | | sign.append(String.valueOf(HEXSTR.charAt(bytes[i] & 0x0F))); // 字节低4位
|
| | | }
|
| | | return sign.toString().toUpperCase();
|
| | | }
|
| | |
|
| | | /**
|
| | | * |
| | | * @param hexString
|
| | | * @return 将十六进制转换为字节数组
|
| | | */
|
| | | public static byte[] hexToBinary(String hexString) {
|
| | | // hexString的长度对2取整,作为bytes的长度
|
| | | int len = hexString.length() / 2;
|
| | | byte[] bytes = new byte[len];
|
| | | for (int i = 0; i < len; i++) {
|
| | | // 右移四位得到高位
|
| | | byte high = (byte) ((HEXSTR.indexOf(hexString.charAt(2 * i))) << 4);// 字节高四位
|
| | | byte low = (byte) HEXSTR.indexOf(hexString.charAt(2 * i + 1));// 字节低四位
|
| | | bytes[i] = (byte) (high | low);// 高地位做或运算
|
| | | }
|
| | | return bytes;
|
| | | }
|
| | |
|
| | | /**
|
| | | * |
| | | * @param str
|
| | | * @return 转换为二进制字符串
|
| | | */
|
| | | public static String bytes2BinaryStr(byte[] bArray) {
|
| | | String outStr = "";
|
| | | for (byte b : bArray) {
|
| | | // 高四位
|
| | | int pos = (b & 0xF0) >> 4;
|
| | | outStr += binaryArray[pos];
|
| | | // 低四位
|
| | | pos = b & 0x0F;
|
| | | outStr += binaryArray[pos];
|
| | | }
|
| | | return outStr;
|
| | |
|
| | | }
|
| | | }
|