fanli/src/main/java/com/yeshi/fanli/controller/AuthCallBackController.java
@@ -15,8 +15,10 @@ import com.yeshi.fanli.entity.bus.user.UserInfo; import com.yeshi.fanli.entity.taobao.TaoBaoUnionAuthRecord; import com.yeshi.fanli.exception.taobao.TaoBaoAuthException; import com.yeshi.fanli.exception.user.UserExtraTaoBaoInfoException; import com.yeshi.fanli.log.LogHelper; import com.yeshi.fanli.service.inter.msg.UserAccountMsgNotificationService; import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionAuthRecordService; import com.yeshi.fanli.service.inter.user.UserExtraTaoBaoInfoService; import com.yeshi.fanli.util.AESUtil; @@ -44,6 +46,9 @@ @Resource private TaoBaoUnionAuthRecordService taoBaoUnionAuthRecordService; @Resource private UserAccountMsgNotificationService userAccountMsgNotificationService; @Resource private RedisManager redisManager; @@ -102,12 +107,20 @@ } catch (Exception e) { } final String name = nickName; LogHelper.test("uid:" + uid + "\n accessToken:" + accessToken); LogHelper.test("uid:" + uid + "\n accessToken:" + accessToken); // 获取渠道ID与会员ID if ("share".equalsIgnoreCase(source)) { String relationId = TaoKeApiUtil.getRelationId(accessToken, TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET);// 渠道ID String relationId = null; try { TaoKeApiUtil.getRelationId(accessToken, TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET);// 渠道ID } catch (TaoBaoAuthException e) { if (e.getCode() == TaoBaoAuthException.CODE_NOT_REAL_NAME) userAccountMsgNotificationService.taoBaoAuthFail(uid, name, "淘宝账号未实名"); } if (StringUtil.isNullOrEmpty(relationId)) LogHelper.test(uid + "渠道备案失败"); try { @@ -121,8 +134,13 @@ @Override public void run() { String specialId = TaoKeApiUtil.getSpecialId(accessToken, TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET); String specialId = null; try { specialId = TaoKeApiUtil.getSpecialId(accessToken, TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET); } catch (TaoBaoAuthException e1) { } if (StringUtil.isNullOrEmpty(specialId)) LogHelper.test(uid + "会员备案失败"); @@ -135,8 +153,15 @@ }); } else if ("zigou".equalsIgnoreCase(source)) { String specialId = TaoKeApiUtil.getSpecialId(accessToken, TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET); String specialId = null; try { specialId = TaoKeApiUtil.getSpecialId(accessToken, TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET); } catch (TaoBaoAuthException e) { if (e.getCode() == TaoBaoAuthException.CODE_NOT_REAL_NAME) userAccountMsgNotificationService.taoBaoAuthFail(uid, name, "淘宝账号未实名"); } if (StringUtil.isNullOrEmpty(specialId)) LogHelper.test(uid + "会员备案失败"); @@ -152,8 +177,12 @@ @Override public void run() { String relationId = TaoKeApiUtil.getRelationId(accessToken, TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET);// 渠道ID String relationId = null; try { relationId = TaoKeApiUtil.getRelationId(accessToken, TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET); } catch (TaoBaoAuthException e1) { } // 渠道ID if (StringUtil.isNullOrEmpty(relationId)) LogHelper.test(uid + "渠道备案失败"); try { @@ -168,8 +197,16 @@ boolean bindInfo = true; // 绑定淘宝:V1.5.3 String relationId = TaoKeApiUtil.getRelationId(accessToken, Constant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET);// 渠道ID String relationId = null; int tbErrorCode = 0; try { relationId = TaoKeApiUtil.getRelationId(accessToken, Constant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET);// 渠道ID } catch (TaoBaoAuthException e) { tbErrorCode = e.getCode(); } if (StringUtil.isNullOrEmpty(relationId)) { LogHelper.test(uid + "渠道备案失败"); bindInfo = false; @@ -177,8 +214,12 @@ String specialId = null; if (bindInfo) { specialId = TaoKeApiUtil.getSpecialId(accessToken, Constant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET); try { specialId = TaoKeApiUtil.getSpecialId(accessToken, Constant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET); } catch (TaoBaoAuthException e) { tbErrorCode = e.getCode(); } if (StringUtil.isNullOrEmpty(specialId)) { LogHelper.test(uid + "会员备案失败"); bindInfo = false; @@ -186,6 +227,9 @@ } if (!bindInfo) { if (tbErrorCode == TaoBaoAuthException.CODE_NOT_REAL_NAME) { userAccountMsgNotificationService.taoBaoAuthFail(uid, name, "淘宝账号未实名"); } errCode = 5;// 信息获取不全 } else { try { fanli/src/main/java/com/yeshi/fanli/controller/client/v1/CommonContentController.java
@@ -88,7 +88,7 @@ } CommonContentResult result = commonTemplateContentService.getContentList(CommonContentTypeEnum.valueOf(key), cid, page, Constant.PAGE_SIZE); cid, page, 10); // 保留暂时不开启,待后续开启 List<SwiperPicture> bannerList = new ArrayList<>(); fanli/src/main/java/com/yeshi/fanli/entity/bus/msg/MsgAccountDetail.java
@@ -16,7 +16,7 @@ @Table("yeshi_ec_msg_account") public class MsgAccountDetail { public enum MsgTypeAccountTypeEnum { bingding("账号绑定"), cancelBinding("取消绑定"), bingdingChange("绑定更换"), update("账号修改"), level("账号等级"), connect("账号合并"); bingding("账号绑定"), cancelBinding("取消绑定"), bingdingChange("绑定更换"), update("账号修改"), level("账号等级"), connect("账号合并"),taoBaoAuthFail("账号绑定"); private final String desc; private MsgTypeAccountTypeEnum(String desc) { fanli/src/main/java/com/yeshi/fanli/exception/taobao/TaoBaoAuthException.java
New file @@ -0,0 +1,37 @@ package com.yeshi.fanli.exception.taobao; //淘宝商品下架 public class TaoBaoAuthException extends Exception { public static int CODE_NOT_REAL_NAME = 1;// 未实名 public static int CODE_OUT_OF_RULE = 2;// 违规 public static int CODE_OTHER = 3;// 其他错误 /** * */ private static final long serialVersionUID = 1L; private int code; private String msg; public int getCode() { return code; } public String getMsg() { return msg; } public TaoBaoAuthException(int code, String msg) { this.code = code; this.msg = msg; } public TaoBaoAuthException() { } @Override public String getMessage() { return this.msg; } } fanli/src/main/java/com/yeshi/fanli/service/impl/msg/UserAccountMsgNotificationServiceImpl.java
@@ -66,4 +66,14 @@ } } @Override public void taoBaoAuthFail(Long uid, String taoBaoNickName, String reason) { MsgAccountDetail detail = MsgAccountDetailFactory.createTaoBaoAuthFail(uid, taoBaoNickName, reason); try { msgAccountDetailService.addMsgAccountDetail(detail); } catch (MsgAccountDetailException e) { e.printStackTrace(); } } } fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TLJBuyGoodsServiceImpl.java
@@ -62,16 +62,17 @@ @Cacheable(value = "commonContentCache", key = "'tljBuy-listByDay'+#day") @Override public List<TLJBuyGoods> listByDay(String day) { List<TLJBuyGoods> list = listByDay(day, 30); if (list.size() <= 10) return list; else { List<TLJBuyGoods> newList = new ArrayList<>(); for (int i = 0; i < 10; i++) { newList.add(list.get(i)); } return newList; } List<TLJBuyGoods> list = listByDay(day, 10); // if (list.size() <= 10) // return list; // else { // List<TLJBuyGoods> newList = new ArrayList<>(); // for (int i = 0; i < 10; i++) { // newList.add(list.get(i)); // } // return newList; // } return list; } @Override fanli/src/main/java/com/yeshi/fanli/service/inter/msg/UserAccountMsgNotificationService.java
@@ -51,4 +51,13 @@ */ public void userRank(Long uid, String orderType, int orderCount, String rankName); /** * 淘宝授权失败 * * @param uid * @param taoBaoNickName * @param reason */ public void taoBaoAuthFail(Long uid, String taoBaoNickName, String reason); } fanli/src/main/java/com/yeshi/fanli/util/factory/msg/MsgAccountDetailFactory.java
@@ -7,6 +7,9 @@ import com.yeshi.fanli.entity.bus.user.UserInfo; import com.yeshi.fanli.util.StringUtil; import net.sf.json.JSONArray; import net.sf.json.JSONObject; public class MsgAccountDetailFactory { public final static int TYPE_WX = 1;// 微信 public final static int TYPE_TB = 2;// 淘宝 @@ -141,4 +144,31 @@ return detail; } // 淘宝授权失败 public static MsgAccountDetail createTaoBaoAuthFail(Long uid, String taoBaoNickName, String reason) { if (uid == null || reason == null) return null; JSONArray msg = new JSONArray(); JSONObject item = new JSONObject(); item.put("name", "账号"); item.put("content", String.format("淘宝昵称[%s]", taoBaoNickName)); msg.add(item); item = new JSONObject(); item.put("name", "原因"); item.put("content", reason); msg.add(item); MsgAccountDetail detail = new MsgAccountDetail(); detail.setBeiZhu("无"); detail.setContent(msg.toString()); detail.setTitle("淘宝账号授权失败"); detail.setType(MsgTypeAccountTypeEnum.taoBaoAuthFail); detail.setUser(new UserInfo(uid)); detail.setCreateTime(new Date()); detail.setRead(false); return detail; } } fanli/src/main/java/com/yeshi/fanli/util/factory/msg/UserMsgVOFactory.java
@@ -15,6 +15,7 @@ import com.yeshi.fanli.entity.bus.msg.MsgOrderDetail; import com.yeshi.fanli.entity.bus.msg.MsgOrderDetail.MsgTypeOrderTypeEnum; import com.yeshi.fanli.entity.bus.msg.MsgOtherDetail; import com.yeshi.fanli.entity.bus.msg.MsgAccountDetail.MsgTypeAccountTypeEnum; import com.yeshi.fanli.entity.bus.msg.MsgOtherDetail.MsgTypeOtherTypeEnum; import com.yeshi.fanli.entity.bus.user.BindingAccount; import com.yeshi.fanli.entity.bus.user.Extract; @@ -27,6 +28,7 @@ import com.yeshi.fanli.vo.msg.CommonMsgItemVO; import com.yeshi.fanli.vo.msg.UserMsgVO; import net.sf.json.JSONArray; import net.sf.json.JSONObject; public class UserMsgVOFactory { @@ -79,7 +81,7 @@ } else { contentList.add(new ClientTextStyleVO(msg.getOrderId(), COLOR_CONTENT)); items.add(new CommonMsgItemVO(new ClientTextStyleVO("订单号", COLOR_TITLE), contentList,true)); items.add(new CommonMsgItemVO(new ClientTextStyleVO("订单号", COLOR_TITLE), contentList, true)); contentList = new ArrayList<>(); contentList.add(new ClientTextStyleVO("共", COLOR_CONTENT)); @@ -385,13 +387,13 @@ return new UserMsgVO("http://img.flqapp.com/resource/msg/icon_msg_order_reward.png", msg.getMsgType().getDesc(), msg.getUpdateTime() == null ? msg.getCreateTime() : msg.getUpdateTime(), items); }else if (msg.getMsgType() == MsgTypeMoneyTypeEnum.systemEqualize ) {// 奖励订单 } else if (msg.getMsgType() == MsgTypeMoneyTypeEnum.systemEqualize) {// 奖励订单 contentList = new ArrayList<>(); contentList.add(new ClientTextStyleVO("¥" + filterMoney(msg.getMoney()) + "", COLOR_HIGHLIGHT_CONTENT)); items.add(new CommonMsgItemVO(new ClientTextStyleVO("补齐金额", COLOR_TITLE), contentList)); contentList = new ArrayList<>(); contentList.add(new ClientTextStyleVO(msg.getOrderId()+ "", COLOR_CONTENT)); contentList.add(new ClientTextStyleVO(msg.getOrderId() + "", COLOR_CONTENT)); items.add(new CommonMsgItemVO(new ClientTextStyleVO("补齐原因", COLOR_TITLE), contentList)); contentList = new ArrayList<>(); @@ -421,7 +423,7 @@ List<CommonMsgItemVO> items = new ArrayList<>(); List<ClientTextStyleVO> contentList = new ArrayList<>(); contentList.add(new ClientTextStyleVO(msg.getType().getDesc() + "", COLOR_CONTENT)); contentList.add(new ClientTextStyleVO(msg.getTitle() + "", COLOR_CONTENT)); items.add(new CommonMsgItemVO(new ClientTextStyleVO("事项", COLOR_TITLE), contentList)); // 状态修改 @@ -430,24 +432,36 @@ int fromIndex = 0; int toIndex = 0; String stateDesc = msg.getContent(); while (stateDesc.indexOf("<highlight>") > -1) { fromIndex = stateDesc.indexOf("<highlight>"); toIndex = stateDesc.indexOf("</highlight>"); String content1 = stateDesc.substring(0, fromIndex); String content2 = stateDesc.substring(fromIndex + "<highlight>".length(), toIndex); stateDesc = stateDesc.substring(toIndex + "</highlight>".length(), stateDesc.length()); if (msg.getType() == MsgTypeAccountTypeEnum.taoBaoAuthFail) {// 淘宝授权失败 JSONArray array = JSONArray.fromObject(stateDesc); for (int i = 0; i < array.size(); i++) { String name = array.optJSONObject(i).optString("name"); String content = array.optJSONObject(i).optString("content"); contentList = new ArrayList<>(); contentList.add(new ClientTextStyleVO(content, i > 0 ? COLOR_HIGHLIGHT_CONTENT : COLOR_CONTENT)); items.add(new CommonMsgItemVO(new ClientTextStyleVO(name, COLOR_TITLE), contentList)); } if (!StringUtil.isNullOrEmpty(content1)) { contentList.add(new ClientTextStyleVO(content1, COLOR_CONTENT)); } else { while (stateDesc.indexOf("<highlight>") > -1) { fromIndex = stateDesc.indexOf("<highlight>"); toIndex = stateDesc.indexOf("</highlight>"); String content1 = stateDesc.substring(0, fromIndex); String content2 = stateDesc.substring(fromIndex + "<highlight>".length(), toIndex); stateDesc = stateDesc.substring(toIndex + "</highlight>".length(), stateDesc.length()); if (!StringUtil.isNullOrEmpty(content1)) { contentList.add(new ClientTextStyleVO(content1, COLOR_CONTENT)); } if (!StringUtil.isNullOrEmpty(content2)) { contentList.add(new ClientTextStyleVO(content2, COLOR_HIGHLIGHT_CONTENT)); } } if (!StringUtil.isNullOrEmpty(content2)) { contentList.add(new ClientTextStyleVO(content2, COLOR_HIGHLIGHT_CONTENT)); if (!StringUtil.isNullOrEmpty(stateDesc)) { contentList.add(new ClientTextStyleVO(stateDesc, COLOR_CONTENT)); } items.add(new CommonMsgItemVO(new ClientTextStyleVO("状态", COLOR_TITLE), contentList)); } if (!StringUtil.isNullOrEmpty(stateDesc)) { contentList.add(new ClientTextStyleVO(stateDesc, COLOR_CONTENT)); } items.add(new CommonMsgItemVO(new ClientTextStyleVO("状态", COLOR_TITLE), contentList)); contentList = new ArrayList<>(); contentList.add(new ClientTextStyleVO(StringUtil.isNullOrEmpty(msg.getBeiZhu()) ? "无" : msg.getBeiZhu() + "", @@ -587,7 +601,7 @@ contentList.add(new ClientTextStyleVO(dto.getSource() + "", COLOR_CONTENT)); items.add(new CommonMsgItemVO(new ClientTextStyleVO("来源", COLOR_TITLE), contentList)); } if (!StringUtil.isNullOrEmpty(dto.getTimeDesc())) { contentList = new ArrayList<>(); contentList.add(new ClientTextStyleVO(dto.getTimeDesc() + "", COLOR_CONTENT)); @@ -601,19 +615,18 @@ items.add(new CommonMsgItemVO(new ClientTextStyleVO("面额", COLOR_TITLE), contentList)); } if (!StringUtil.isNullOrEmpty(dto.getReason())) { contentList = new ArrayList<>(); contentList.add(new ClientTextStyleVO(dto.getReason() + "", COLOR_CONTENT)); items.add(new CommonMsgItemVO(new ClientTextStyleVO("原因", COLOR_TITLE), contentList)); } if (!StringUtil.isNullOrEmpty(dto.getResult())) { contentList = new ArrayList<>(); contentList.add(new ClientTextStyleVO(dto.getResult() + "", COLOR_CONTENT)); items.add(new CommonMsgItemVO(new ClientTextStyleVO("结果", COLOR_TITLE), contentList)); } contentList = new ArrayList<>(); contentList.add(new ClientTextStyleVO(StringUtil.isNullOrEmpty(msg.getBeiZhu()) ? "无" : msg.getBeiZhu(), COLOR_CONTENT)); fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeApiUtil.java
@@ -22,6 +22,7 @@ import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult; import com.yeshi.fanli.entity.taobao.TaoBaoShopInfo; import com.yeshi.fanli.entity.taobao.TaoKeAppInfo; import com.yeshi.fanli.exception.taobao.TaoBaoAuthException; import com.yeshi.fanli.exception.taobao.TaoKeApiException; import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException; import com.yeshi.fanli.log.LogHelper; @@ -1646,7 +1647,7 @@ return null; } public static String getRelationId(String accessToken, String appKey, String appSecret) { public static String getRelationId(String accessToken, String appKey, String appSecret) throws TaoBaoAuthException { Map<String, String> map = new HashMap<>(); map.put("method", "taobao.tbk.sc.publisher.info.save"); map.put("session", accessToken); @@ -1662,14 +1663,19 @@ return resultJSON.optJSONObject("tbk_sc_publisher_info_save_response").optJSONObject("data") .optString("relation_id"); } catch (TaoKeApiException e) { e.printStackTrace(); LogHelper.error("渠道ID申请出错:" + e.getMsg()); JSONObject errorJSON = JSONObject.fromObject(e.getMsg()).optJSONObject("error_response"); if (errorJSON.optInt("code") == 15 && errorJSON.optInt("sub_code") == 1)// 未实名 { throw new TaoBaoAuthException(TaoBaoAuthException.CODE_NOT_REAL_NAME, errorJSON.optString("sub_msg")); } else { e.printStackTrace(); LogHelper.error("渠道ID申请出错:" + e.getMsg()); throw new TaoBaoAuthException(TaoBaoAuthException.CODE_OTHER, errorJSON.optString("sub_msg")); } } return null; } public static String getSpecialId(String accessToken, String appKey, String appSecret) { public static String getSpecialId(String accessToken, String appKey, String appSecret) throws TaoBaoAuthException { Map<String, String> map = new HashMap<>(); map.put("method", "taobao.tbk.sc.publisher.info.save"); map.put("session", accessToken); @@ -1685,11 +1691,16 @@ return resultJSON.optJSONObject("tbk_sc_publisher_info_save_response").optJSONObject("data") .optString("special_id"); } catch (TaoKeApiException e) { e.printStackTrace(); LogHelper.error("会员运营ID申请出错:" + resultJSON); JSONObject errorJSON = JSONObject.fromObject(e.getMsg()).optJSONObject("error_response"); if (errorJSON.optInt("code") == 15 && errorJSON.optInt("sub_code") == 1)// 未实名 { throw new TaoBaoAuthException(TaoBaoAuthException.CODE_NOT_REAL_NAME, errorJSON.optString("sub_msg")); } else { e.printStackTrace(); LogHelper.error("会员运营ID申请出错:" + e.getMsg()); throw new TaoBaoAuthException(TaoBaoAuthException.CODE_OTHER, errorJSON.optString("sub_msg")); } } return null; } public static void specialConvertItem(Long auctionId, TaoKeAppInfo app) {