fanli/libs/opush-server-sdk-1.0.3.jar | 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/GoodsController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli/src/main/java/com/yeshi/fanli/controller/wxpay/WXAPPInfo.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli/src/main/java/com/yeshi/fanli/controller/wxpay/WXPayController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli/src/main/java/com/yeshi/fanli/job/order/taobao/UpdateOrderJob.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli/src/main/java/com/yeshi/fanli/mapping/user/UserActiveLogMapper.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli/src/main/java/com/yeshi/fanli/util/push/OPPOPushUtil.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeApiUtil.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
fanli/libs/opush-server-sdk-1.0.3.jarBinary files differ
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/GoodsController.java
@@ -42,6 +42,7 @@ import com.yeshi.fanli.util.StringUtil; import com.yeshi.fanli.util.TaoBaoConstant; import com.yeshi.fanli.util.TimeUtil; import com.yeshi.fanli.util.VersionUtil; import com.yeshi.fanli.util.factory.MonitorFactory; import com.yeshi.fanli.util.taobao.TaoKeApiUtil; @@ -175,6 +176,19 @@ return; } ClientTBPid clientTBPid = null; String dpid = null; if (goods.getMaterialLibType() != null && goods.getMaterialLibType() > 0) { dpid = TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT; } else { dpid = TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID; } String psiteId = dpid.split("_")[2]; String padzoneId = dpid.split("_")[3]; TaoBaoUnionConfig config1 = taoBaoUnionConfigService.getConfigByAppIdCache(psiteId); clientTBPid = new ClientTBPid(config1.getAppKey(), dpid, psiteId, padzoneId); JSONObject data = new JSONObject(); boolean isNative = false; String pid = null; @@ -287,6 +301,8 @@ link.put("couponUrl", taoBaoLink.getCouponLink()); data.put("type", 1); data.put("link", link); if (clientTBPid != null) data.put("tbPidInfo", clientTBPid); out.print(JsonUtil.loadTrueResult(data)); // 获得金币 @@ -335,9 +351,9 @@ String siteId = tbPid.getPid().split("_")[2]; String adzoneId = tbPid.getPid().split("_")[3]; TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppIdCache(siteId); ClientTBPid clientTBPid = new ClientTBPid(config.getAppKey(), tbPid.getPid(), siteId, adzoneId); ClientTBPid clientTBPid1 = new ClientTBPid(config.getAppKey(), tbPid.getPid(), siteId, adzoneId); data.put("type", 2); data.put("tbPidInfo", clientTBPid); data.put("tbPidInfo", clientTBPid1); data.put("native", true); } fanli/src/main/java/com/yeshi/fanli/controller/wxpay/WXAPPInfo.java
New file @@ -0,0 +1,53 @@ package com.yeshi.fanli.controller.wxpay; public class WXAPPInfo { private String appId; private String appSecret; private String mchId; public WXAPPInfo(String appId, String appSecret, String mchId, String mchKey) { this.appId = appId; this.appSecret = appSecret; this.mchId = mchId; this.mchKey = mchKey; } public WXAPPInfo() { } private String mchKey; public String getAppId() { return appId; } public void setAppId(String appId) { this.appId = appId; } public String getAppSecret() { return appSecret; } public void setAppSecret(String appSecret) { this.appSecret = appSecret; } public String getMchId() { return mchId; } public void setMchId(String mchId) { this.mchId = mchId; } public String getMchKey() { return mchKey; } public void setMchKey(String mchKey) { this.mchKey = mchKey; } } fanli/src/main/java/com/yeshi/fanli/controller/wxpay/WXPayController.java
New file @@ -0,0 +1,116 @@ package com.yeshi.fanli.controller.wxpay; import java.math.BigDecimal; import java.net.URLEncoder; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; import org.yeshi.utils.HttpUtil; import org.yeshi.utils.wx.WXUtil; import com.yeshi.fanli.util.StringUtil; import net.sf.json.JSONObject; @Controller @RequestMapping("pay") public class WXPayController { // 板栗快省 private WXAPPInfo app = new WXAPPInfo("wxa99686bb65a9f466", "57390718ddedaa1591f6876cdcf96f43", "1520950211", "XYJkJ2018FAfaodCCx899mLl138rfGVd"); @RequestMapping("login") public String login() { return "wxpay/login"; } @RequestMapping("loginCallBack") public void loginCallBack(String code, HttpServletRequest request, HttpServletResponse response) { System.out.println("code:" + code); String url = String.format( "https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&secret=%s&code=%s&grant_type=authorization_code", app.getAppId(), app.getAppSecret(), code); String result = HttpUtil.get(url); System.out.println("result:" + result); JSONObject json = JSONObject.fromObject(result); String openId = json.optString("openid"); String orderNo = System.currentTimeMillis() + ""; double d = 0.1 + 0.5 * Math.random(); BigDecimal money = new BigDecimal((int) (d * 100)).divide(new BigDecimal(100)); Map<String, String> resultMap = produceOrder(orderNo, money, openId, "板栗快省支付", app); if (resultMap != null) { System.out.println("统一下单成功:" + resultMap.get("prepay_id")); Map<String, String> payParams = new HashMap<>(); payParams.put("appId", app.getAppId()); payParams.put("timeStamp", System.currentTimeMillis() / 1000 + ""); payParams.put("nonceStr", StringUtil.getRandomCode(32)); payParams.put("package", "prepay_id=" + resultMap.get("prepay_id")); payParams.put("signType", "MD5"); payParams.put("paySign", WXUtil.getSignMD5(payParams, app.getMchKey())); JSONObject jaon = new JSONObject(); for (Iterator<String> its = payParams.keySet().iterator(); its.hasNext();) { String key = its.next(); jaon.put(key, payParams.get(key)); } try { response.sendRedirect("pay?data=" + URLEncoder.encode(jaon.toString(), "UTF-8")); } catch (Exception e) { } } } @RequestMapping("pay") public ModelAndView pay(String data) { JSONObject jsonObject = JSONObject.fromObject(data); ModelAndView modelAndView = new ModelAndView("wxpay/pay"); for (Iterator<String> its = jsonObject.keySet().iterator(); its.hasNext();) { String key = its.next(); modelAndView.addObject(key, jsonObject.optString(key)); } return modelAndView; } @RequestMapping("test") public ModelAndView test() { ModelAndView modelAndView = new ModelAndView("test"); WXAPPInfo wxappInfo = new WXAPPInfo(); wxappInfo.setAppId("appId"); modelAndView.addObject(wxappInfo); // modelAndView.addObject("test", 123123); return modelAndView; } private static Map<String, String> produceOrder(String orderNo, BigDecimal fee, String openId, String body, WXAPPInfo info) { Map<String, String> map = new HashMap<String, String>(); map.put("appid", info.getAppId()); map.put("mch_id", info.getMchId()); map.put("nonce_str", StringUtil.getRandomCode(32)); map.put("body", body); map.put("out_trade_no", orderNo); map.put("total_fee", "" + fee.multiply(new BigDecimal(100)).intValue()); map.put("spbill_create_ip", "119.85.112.210"); map.put("notify_url", "https://banli.xiaoxiangyingji.com/pay/paySuccess"); map.put("trade_type", "JSAPI"); map.put("openid", openId); map.put("sign", WXUtil.getSignMD5(map, info.getMchKey())); String entity = WXUtil.loadWXMessage(map); String result = HttpUtil.post("https://api.mch.weixin.qq.com/pay/unifiedorder", entity); System.out.println("统一下单结果:" + result); Map<String, String> resultMap = WXUtil.parseXML(result); return resultMap; } } fanli/src/main/java/com/yeshi/fanli/job/order/taobao/UpdateOrderJob.java
@@ -119,34 +119,6 @@ } /** * 爬取三方订单 * * @param startTime * @param endTime * @return */ public static List<TaoBaoOrder> getThirdCommonOrder(long startTime, long endTime) { List<TaoBaoOrder> orderList = new ArrayList<>(); long span = (endTime - startTime) % 1000 == 0 ? (endTime - startTime) / 1000 : (endTime - startTime) / 1000 + 1; int count = (int) (span / 1200); if (span % 1200 != 0) count++; for (int i = 0; i < count; i++) { long startT = startTime + i * 1200 * 1000L; int s = 1200; if (endTime < startT + 1200 * 1000L) { s = (int) ((endTime - startT) / 1000) + 1; if (s < 60) s = 60; } List<TaoBaoOrder> tempOrderList = getThirdCommonOrder(startT, s); if (tempOrderList != null && tempOrderList.size() > 0) orderList.addAll(tempOrderList); } return orderList; } /** * 按天获取普通订单(新版) * * @param date @@ -193,9 +165,6 @@ // orderList.addAll(thirdOrderList); // 新版本处理方式 List<TaoBaoOrder> orderList = getCommonOrder(startTime, endTime); List<TaoBaoOrder> tempOrderList2 = getThirdCommonOrder(startTime, endTime); if (tempOrderList2 != null && tempOrderList2.size() > 0) orderList.addAll(tempOrderList2); LogHelper.orderInfo("正在执行订单爬取结束,共有订单:" + orderList.size()); addOrder(orderList); fanli/src/main/java/com/yeshi/fanli/mapping/user/UserActiveLogMapper.xml
@@ -72,7 +72,7 @@ <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if> <if test="deviceType != null">#{deviceType,jdbcType=VARCHAR},</if> <if test="osVersion != null">#{osVersion,jdbcType=VARCHAR}</if> <if test="osVersion != null">#{osVersion,jdbcType=VARCHAR},</if> <if test="device != null">#{device,jdbcType=VARCHAR}</if> </trim> </insert> fanli/src/main/java/com/yeshi/fanli/util/push/OPPOPushUtil.java
New file @@ -0,0 +1,347 @@ package com.yeshi.fanli.util.push; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Properties; import java.util.UUID; import javax.annotation.PostConstruct; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.yeshi.utils.annotation.MapUtil; import com.alibaba.fastjson.JSONObject; import com.oppo.push.server.Notification; import com.oppo.push.server.Result; import com.oppo.push.server.Sender; import com.oppo.push.server.Target; import com.yeshi.fanli.entity.config.push.HWPushConfig; import com.yeshi.fanli.exception.push.PushException; import com.yeshi.fanli.service.inter.config.BusinessSystemService; import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.taobao.TaoBaoUtil; @Component public class OPPOPushUtil { private static OPPOPushUtil hWPushUtil; @Autowired private BusinessSystemService businessSystemService; @PostConstruct public void init() { hWPushUtil = this; hWPushUtil.businessSystemService = this.businessSystemService; } private static String appkey = ""; private static String masterSecret = ""; static { Properties ps = org.yeshi.utils.PropertiesUtil .getProperties(TaoBaoUtil.class.getClassLoader().getResourceAsStream("push_hw.properties")); HWPushConfig config = (HWPushConfig) MapUtil.parseMap(HWPushConfig.class, ps); appkey = config.getAppId(); masterSecret = config.getAppSecret(); } private static Map<String, String> getParams(String type, String activity, String url, String webUrl, Long id) { Map<String, String> data = new HashMap<>(); if (type != null) data.put("type", type); if (activity != null) data.put("activity", activity); if (url != null) data.put("url", url); if (webUrl != null) data.put("webUrl", webUrl); if (id != null) data.put("id", id + ""); return data; } /** * 推送商品 * * @param registerIds * -最大值1000 * @param title * @param content * @param goodsType * @param goodsId * @throws PushException */ public static void pushGoods(List<String> registerIds, String title, String content, int goodsType, Long goodsId) throws PushException { if (registerIds != null && registerIds.size() > 100) throw new PushException(1, "设备数不能超过100个"); String activity = Constant.systemCommonConfig.getAndroidBaseactivityName() + ".ui.recommend.GoodsBrowserActivity"; Map<String, String> params = getParams("goodsdetail", activity, null, null, goodsId); try { boolean success = push(registerIds, title, content, params); if (!success) throw new PushException(2, "推送失败"); } catch (Exception e) { e.printStackTrace(); } } /** * 网页推送 * * @param registerIds * 最大值1000 * @param title * @param content * @param url * -网页链接 * @throws PushException */ public static void pushUrl(List<String> registerIds, String title, String content, String url) throws PushException { if (registerIds != null && registerIds.size() > 100) throw new PushException(1, "设备数不能超过1000个"); String activity = Constant.systemCommonConfig.getAndroidBaseactivityName() + ".ui.invite.ShareBrowserActivity"; Map<String, String> params = getParams("url", activity, null, url, null); try { boolean success = push(registerIds, title, content, params); if (!success) throw new PushException(2, "推送失败"); } catch (Exception e) { e.printStackTrace(); } } /** * 站内信推送 * * @param registerIds * 最大值1000 * @param title * @param content * @param url * -网页链接 * @throws PushException */ public static void pushZNX(List<String> registerIds, String title, String content) throws PushException { if (registerIds != null && registerIds.size() > 100) throw new PushException(1, "设备数不能超过100个"); Map<String, String> params = getParams("ZNX", null, null, null, null); if (params == null) return; try { boolean success = push(registerIds, title, content, params); if (!success) throw new PushException(2, "推送失败"); } catch (Exception e) { e.printStackTrace(); } } public static void pushWEEX(List<String> registerIds, String title, String content, String weexUrl) throws PushException { String activity = Constant.systemCommonConfig.getAndroidBaseactivityName() + ".ui.mine.weex.WeexApplicationActivity"; Map<String, String> params = getParams("weex", activity, weexUrl, weexUrl, null); if (params == null) return; try { boolean success = push(registerIds, title, content, params); if (!success) throw new PushException(2, "推送失败"); } catch (Exception e) { e.printStackTrace(); } } public static void pushBaiChuanUrl(List<String> registerIds, String title, String content, String url) throws PushException { Map<String, String> params = getParams("baichuan", null, url, null, null); if (params == null) return; try { boolean success = push(registerIds, title, content, params); if (!success) throw new PushException(2, "推送失败"); } catch (Exception e) { e.printStackTrace(); } } public static void pushWelfareCenter(List<String> registerIds, String title, String content) throws PushException { String activity = Constant.systemCommonConfig.getAndroidBaseactivityName() + ".ui.mine.WelfareCenterActivity"; Map<String, String> params = getParams("welfare", activity, null, null, null); if (params == null) return; try { boolean success = push(registerIds, title, content, params); if (!success) throw new PushException(2, "推送失败"); } catch (Exception e) { e.printStackTrace(); } } public static void pushUserSignInNotification(List<String> registerIds, String title, String content) throws PushException { String activity = Constant.systemCommonConfig.getAndroidBaseactivityName() + ".ui.goldtask.GoldTaskActivity"; Map<String, String> params = getParams("signin", activity, null, null, null); if (params == null) return; try { boolean success = push(registerIds, title, content, params); if (!success) throw new PushException(2, "推送失败"); } catch (Exception e) { e.printStackTrace(); } } /** * * @param list * 最大为1000 */ public static boolean push(List<String> list, String title, String content, Map<String, String> dataParams) { Map<String, String> params = null; if (dataParams != null) { params = new HashMap<>(); JSONObject json = new JSONObject(); for (Iterator<String> its = dataParams.keySet().iterator(); its.hasNext();) { String key = its.next(); json.put(key, dataParams.get(key)); } params.put("data", json.toJSONString()); } try { Sender sender = new Sender("f14S6P4sCrW4gs0WCO80w80cW", "E7976fe3d1758bf0c3480d8DcE4236e2"); Notification notifyCation = getNotification(title, content, "com.yeshi.ec.rebate.myapplication.ui.OPPOPushMessageActivity", params); if (list.size() == 1) { Result result = sender.unicastNotification(notifyCation, Target.build(list.get(0))); result.getStatusCode(); // 获取http请求状态码 result.getReturnCode(); // 获取平台返回码 System.out.println(result.getStatusCode() + "-" + result.getReturnCode()); if (result.getReturnCode().getCode() == 0) return true; else return false; } else { Map<Target, Notification> batch = new HashMap<Target, Notification>(); // batch最大为1000 for (String registerId : list) { batch.put(Target.build(registerId), notifyCation); } Result result = sender.unicastBatchNotification(batch); // 发送批量单推消息 result.getStatusCode(); // 获取http请求状态码 result.getReturnCode(); // 获取平台返回码 System.out.println(result.getStatusCode() + "-" + result.getReturnCode()); if (result.getReturnCode().getCode() == 0) return true; else return false; } // List<Result.UnicastBatchResult> batchResult = // result.getUnicastBatchResults(); // 批量单推结果 // for (Result.UnicastBatchResult record : batchResult) { // record.getErrorCode(); // record.getErrorMessage(); // record.getMessageId(); // record.getTargetValue(); // } } catch (Exception e) { e.printStackTrace(); } return false; } private static Notification getNotification(String title, String content, String activity, Map<String, String> params) { Notification notification = new Notification(); /** * * 以下参数必填项 * */ notification.setTitle(title); notification.setSubTitle(title); notification.setContent(content); /** * * 以下参数非必填项, 如果需要使用可以参考OPPO push服务端api文档进行设置 * */ // App开发者自定义消息Id,OPPO推送平台根据此ID做去重处理,对于广播推送相同appMessageId只会保存一次,对于单推相同appMessageId只会推送一次 notification.setAppMessageId(UUID.randomUUID().toString()); // 应用接收消息到达回执的回调URL,字数限制200以内,中英文均以一个计算 // notification.setCallBackUrl("http://www.test.com"); // App开发者自定义回执参数,字数限制50以内,中英文均以一个计算 // notification.setCallBackParameter(""); // 点击动作类型0,启动应用;1,打开应用内页(activity的intent // action);2,打开网页;4,打开应用内页(activity);【非必填,默认值为0】;5,Intent scheme URL notification.setClickActionType(4); // 应用内页地址【click_action_type为1或4时必填,长度500】 notification.setClickActionActivity(activity); // 网页地址【click_action_type为2必填,长度500】 // notification.setClickActionUrl("http://www.test.com"); // 动作参数,打开应用内页或网页时传递给应用或网页【JSON格式,非必填】,字符数不能超过4K,示例:{"key1":"value1","key2":"value2"} JSONObject paramsData = new JSONObject(); if (params != null) for (Iterator<String> its = params.keySet().iterator(); its.hasNext();) { String key = its.next(); paramsData.put(key, params.get(key)); } notification.setActionParameters(paramsData.toJSONString()); // 展示类型 (0, “即时”),(1, “定时”) notification.setShowTimeType(0); // 定时展示开始时间(根据time_zone转换成当地时间),时间的毫秒数 // notification.setShowStartTime(System.currentTimeMillis() + 1000 * 60 // * 3); // 定时展示结束时间(根据time_zone转换成当地时间),时间的毫秒数 // notification.setShowEndTime(System.currentTimeMillis() + 1000 * 60 * // 5); // 是否进离线消息,【非必填,默认为True】 notification.setOffLine(true); // 离线消息的存活时间(time_to_live) (单位:秒), 【off_line值为true时,必填,最长3天】 notification.setOffLineTtl(24 * 3600); // 时区,默认值:(GMT+08:00)北京,香港,新加坡 notification.setTimeZone("GMT+08:00"); // 0:不限联网方式, 1:仅wifi推送 notification.setNetworkType(0); return notification; } } fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeApiUtil.java
@@ -127,7 +127,7 @@ map.put("method", "taobao.tbk.item.info.get"); map.put("num_iids", id + ""); String resultStr = TaoKeBaseUtil.baseRequestForThreeTimes(map, true); // System.out.println(resultStr); System.out.println(resultStr); JSONObject data = JSONObject.fromObject(resultStr); // 商品下架 if (data.optJSONObject("error_response") != null && data.optJSONObject("error_response").optInt("code") == 15 @@ -190,9 +190,15 @@ if (item.optBoolean("free_shipment")) goods.setFreeShipment(1); if (!StringUtil.isNullOrEmpty(item.optString("material_lib_type"))) goods.setMaterialLibType(item.optInt("material_lib_type")); else if (!StringUtil.isNullOrEmpty(item.optString("material_lib_type"))) { try { String materialLibType = item.optString("material_lib_type"); goods.setMaterialLibType(Integer.parseInt(materialLibType.split(",")[0])); } catch (Exception e) { goods.setMaterialLibType(0); } } else goods.setMaterialLibType(0); return goods; @@ -693,7 +699,7 @@ } String resultStr = TaoKeBaseUtil.baseRequestForThreeTimes(map, true); // System.out.println("resultStr"+ resultStr); // System.out.println("resultStr"+ resultStr); JSONObject data = JSONObject.fromObject(resultStr); if (data.optJSONObject("tbk_dg_material_optional_response") != null && data.optJSONObject("tbk_dg_material_optional_response").optJSONObject("result_list") != null) { @@ -1242,7 +1248,7 @@ dto.setPage(pageEntity); return dto; } /** * 店铺搜索 * @@ -1260,15 +1266,15 @@ map.put("method", "taobao.tbk.shop.get"); map.put("fields", "user_id,shop_title,shop_type,seller_nick,pict_url,shop_url"); map.put("q", filter.getKey()); map.put("page_size", filter.getPageSize()+ ""); map.put("page_size", filter.getPageSize() + ""); map.put("page_no", filter.getPage() + ""); if(!StringUtil.isNullOrEmpty(filter.getSort())) if (!StringUtil.isNullOrEmpty(filter.getSort())) map.put("sort", filter.getSort()); if(filter.getTmall() != null) if (filter.getTmall() != null) map.put("is_tmall", filter.getTmall() + ""); String resultStr = TaoKeBaseUtil.baseRequestForThreeTimes(map, true); JSONObject resultDate = JSONObject.fromObject(resultStr); if (resultDate.optJSONObject("tbk_shop_get_response") != null @@ -1290,7 +1296,6 @@ } return list; } /** * 品牌券获取 @@ -1955,7 +1960,7 @@ // 淘礼金创建 public static TaoLiJinDTO createTaoLiJin(Long auctionId, String name, BigDecimal perface, int totalNum, Date sendStartTime, Date sendEndTime, Date useStartTime, Date useEndTime, TaoKeAppInfo app) throws TaoLiJinCreateException,TaoKeApiException { throws TaoLiJinCreateException, TaoKeApiException { Map<String, String> map = new HashMap<>(); map.put("method", "taobao.tbk.dg.vegas.tlj.create"); map.put("adzone_id", app.getPid().split("_")[3]);