| | |
| | | package com.yeshi.fanli.controller.client.v1;
|
| | |
|
| | | import java.io.PrintWriter;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RequestMethod;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | | import org.yeshi.utils.encrypt.DESUtil;
|
| | |
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
|
| | | import com.yeshi.fanli.entity.system.ConfigKeyEnum;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
|
| | | import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TaoBaoConstant;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | @Controller
|
| | | @RequestMapping("api/v1/userauth")
|
| | | public class UserAuthController {
|
| | |
|
| | | @Resource
|
| | | private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService;
|
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | |
|
| | | @Resource
|
| | | private UserInfoExtraService userInfoExtraService;
|
| | | |
| | | /**
|
| | | * 获取淘宝授权信息
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param source
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getTaoBaoAuthInfo", method = RequestMethod.POST)
|
| | | public void getUserConfig(AcceptData acceptData, Long uid, String source, Boolean first, PrintWriter out) {
|
| | |
|
| | | if (uid == null) {
|
| | | out.print(JsonUtil.loadFalseResult(2, "用户未登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(source)) {
|
| | | out.print(JsonUtil.loadFalseResult(3, "来源错误"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (first == null) {
|
| | | out.print(JsonUtil.loadFalseResult(4, "请传first"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (!"1".equalsIgnoreCase(configService.get(ConfigKeyEnum.openSpeicalAndRelationApply.getKey()))) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "暂不开放申请"));
|
| | | return;
|
| | | }
|
| | | |
| | | String inviteCode = userInfoExtraService.getInviteCodeByUid(uid);
|
| | | if (StringUtil.isNullOrEmpty(inviteCode)) {
|
| | | out.print(JsonUtil.loadFalseResult(3, "请激活邀请码"));
|
| | | return;
|
| | | }
|
| | | |
| | | |
| | | UserExtraTaoBaoInfo user = userExtraTaoBaoInfoService.getByUid(uid);
|
| | | if ("share".equalsIgnoreCase(source)) {
|
| | | if (user != null && !StringUtil.isNullOrEmpty(user.getRelationId()) && user.getRelationValid()) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "无需授权"));
|
| | | return;
|
| | | }
|
| | |
|
| | | } else if ("zigou".equalsIgnoreCase(source)) {
|
| | | if (user != null && !StringUtil.isNullOrEmpty(user.getSpecialId()) && user.getSpecialValid()) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "无需授权"));
|
| | | return;
|
| | | }
|
| | | }
|
| | |
|
| | | boolean canParse = "0".equalsIgnoreCase(configService.get(ConfigKeyEnum.autoFindTaobaoOrder.getKey())) ? false : true;
|
| | |
|
| | | String link = TaoBaoUtil.getTaoBaoUnionAuthUrl(TaoBaoConstant.TAOBAO_AUTH_APPKEY,
|
| | | "http://api.flqapp.com/fanli/client/v1/auth/callback/tb", uid, source);
|
| | |
|
| | | String orderJS = configService.get(ConfigKeyEnum.taobaoOrderParseJS.getKey());
|
| | | if (!canParse)
|
| | | orderJS = "-";
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("authLink", link);
|
| | |
|
| | | try {
|
| | | data.put("orderJS", DESUtil.encode(orderJS, StringUtil.getBase64String("YeShiFANLI889*+"),
|
| | | StringUtil.getBase64String("*M#34f?,")));
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | if (!canParse)
|
| | | data.put("orderUrl", "http://");
|
| | | else
|
| | | data.put("orderUrl", "https://buyertrade.taobao.com/trade/itemlist/list_bought_items.htm");
|
| | | if (first)
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | else
|
| | | out.print(JsonUtil.loadTrue(0, data, "淘宝授权未成功,请稍后再试"));
|
| | | }
|
| | |
|
| | | }
|
| | | package com.yeshi.fanli.controller.client.v1; |
| | | |
| | | import java.io.PrintWriter; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.yeshi.fanli.entity.SystemFunction; |
| | | import com.yeshi.fanli.util.SystemInfoUtil; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestMethod; |
| | | import org.yeshi.utils.JsonUtil; |
| | | import org.yeshi.utils.encrypt.DESUtil; |
| | | |
| | | import com.yeshi.fanli.entity.accept.AcceptData; |
| | | import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo; |
| | | import com.yeshi.fanli.entity.system.ConfigKeyEnum; |
| | | import com.yeshi.fanli.service.inter.config.ConfigService; |
| | | import com.yeshi.fanli.service.inter.user.UserInfoExtraService; |
| | | import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | import com.yeshi.fanli.util.TaoBaoConstant; |
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil; |
| | | |
| | | import net.sf.json.JSONObject; |
| | | |
| | | @Controller |
| | | @RequestMapping("api/v1/userauth") |
| | | public class UserAuthController { |
| | | |
| | | @Resource |
| | | private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService; |
| | | |
| | | @Resource |
| | | private ConfigService configService; |
| | | |
| | | @Resource |
| | | private UserInfoExtraService userInfoExtraService; |
| | | |
| | | /** |
| | | * 获取淘宝授权信息 |
| | | * |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param source |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getTaoBaoAuthInfo", method = RequestMethod.POST) |
| | | public void getUserConfig(AcceptData acceptData, Long uid, String source, Boolean first, PrintWriter out) { |
| | | |
| | | if (uid == null) { |
| | | out.print(JsonUtil.loadFalseResult(2, "用户未登录")); |
| | | return; |
| | | } |
| | | |
| | | if (StringUtil.isNullOrEmpty(source)) { |
| | | out.print(JsonUtil.loadFalseResult(3, "来源错误")); |
| | | return; |
| | | } |
| | | |
| | | if (first == null) { |
| | | out.print(JsonUtil.loadFalseResult(4, "请传first")); |
| | | return; |
| | | } |
| | | |
| | | if (!"1".equalsIgnoreCase(configService.getValue(ConfigKeyEnum.openSpeicalAndRelationApply.getKey(), SystemInfoUtil.getSystem(acceptData)))) { |
| | | out.print(JsonUtil.loadFalseResult(1, "暂不开放申请")); |
| | | return; |
| | | } |
| | | |
| | | // 邀请码不必必须激活 |
| | | // if(SystemInfoUtil.hasFunctions(acceptData.getSystem(), SystemFunction.threeSale)) { |
| | | // String inviteCode = userInfoExtraService.getInviteCodeByUid(uid); |
| | | // if (StringUtil.isNullOrEmpty(inviteCode)) { |
| | | // out.print(JsonUtil.loadFalseResult(3, "请激活邀请码")); |
| | | // return; |
| | | // } |
| | | // } |
| | | |
| | | |
| | | UserExtraTaoBaoInfo user = userExtraTaoBaoInfoService.getByUid(uid); |
| | | if ("share".equalsIgnoreCase(source)) { |
| | | if (user != null && !StringUtil.isNullOrEmpty(user.getRelationId()) && user.getRelationValid()) { |
| | | out.print(JsonUtil.loadFalseResult(1, "无需授权")); |
| | | return; |
| | | } |
| | | |
| | | } else if ("zigou".equalsIgnoreCase(source)) { |
| | | if (user != null && !StringUtil.isNullOrEmpty(user.getSpecialId()) && user.getSpecialValid()) { |
| | | out.print(JsonUtil.loadFalseResult(1, "无需授权")); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | boolean canParse = "0".equalsIgnoreCase(configService.getValue(ConfigKeyEnum.autoFindTaobaoOrder.getKey(), SystemInfoUtil.getSystem(acceptData))) ? false : true; |
| | | |
| | | String link = TaoBaoUtil.getTaoBaoAuthLink(uid, source); |
| | | |
| | | String orderJS = configService.getValue(ConfigKeyEnum.taobaoOrderParseJS.getKey(),SystemInfoUtil.getSystem(acceptData)); |
| | | if (!canParse) |
| | | orderJS = "-"; |
| | | JSONObject data = new JSONObject(); |
| | | data.put("authLink", link); |
| | | |
| | | try { |
| | | data.put("orderJS", DESUtil.encode(orderJS, StringUtil.getBase64String("YeShiFANLI889*+"), |
| | | StringUtil.getBase64String("*M#34f?,"))); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | if (!canParse) |
| | | data.put("orderUrl", "http://"); |
| | | else |
| | | data.put("orderUrl", "https://buyertrade.taobao.com/trade/itemlist/list_bought_items.htm"); |
| | | if (first) |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | else |
| | | out.print(JsonUtil.loadTrue(0, data, "淘宝授权未成功,请稍后再试")); |
| | | } |
| | | |
| | | } |