admin
2019-01-26 9e0b95dc01a1fc0751c257414d96907d945cdeb3
fanli/src/main/java/com/yeshi/fanli/controller/client/UserAccountController.java
@@ -9,6 +9,7 @@
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.yeshi.utils.JsonUtil;
import com.alipay.api.AlipayApiException;
import com.yeshi.fanli.entity.accept.AcceptData;
@@ -29,10 +30,9 @@
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.config.InviteGetMoneyService;
import com.yeshi.fanli.service.inter.config.SystemService;
import com.yeshi.fanli.service.inter.goods.CollectionGoodsService;
import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
import com.yeshi.fanli.service.inter.hongbao.HongBaoMessageService;
import com.yeshi.fanli.service.inter.hongbao.HongBaoService;
import com.yeshi.fanli.service.inter.hongbao.HongBaoV2Service;
import com.yeshi.fanli.service.inter.hongbao.ThreeSaleSerivce;
import com.yeshi.fanli.service.inter.order.LostOrderService;
import com.yeshi.fanli.service.inter.order.OrderItemServcie;
@@ -43,19 +43,18 @@
import com.yeshi.fanli.service.inter.user.AccountMessageService;
import com.yeshi.fanli.service.inter.user.BindingAccountService;
import com.yeshi.fanli.service.inter.user.ExtractService;
import com.yeshi.fanli.service.inter.user.MoneyRecordService;
import com.yeshi.fanli.service.inter.user.PassWordErrorRecordService;
import com.yeshi.fanli.service.inter.user.ShamUserService;
import com.yeshi.fanli.service.inter.user.SpreadUserImgService;
import com.yeshi.fanli.service.inter.user.TBPidService;
import com.yeshi.fanli.service.inter.user.UserAccountService;
import com.yeshi.fanli.service.inter.user.UserInfoService;
import com.yeshi.fanli.service.inter.user.WxDownService;
import com.yeshi.fanli.service.inter.user.UserShareGoodsRecordService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.GsonUtil;
import com.yeshi.fanli.util.RedisManager;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.account.UserUtil;
import com.yeshi.fanli.util.wx.WXLoginUtil;
import org.yeshi.utils.JsonUtil;
import net.sf.json.JSONObject;
@@ -79,7 +78,7 @@
   private HongBaoService hongBaoService;
   @Resource
   private MoneyRecordService moneyRecordService;
   private HongBaoV2Service hongBaoV2Service;
   @Resource
   private BindingAccountService bindingAccountService;
@@ -88,16 +87,10 @@
   private ExtractService extractService;
   @Resource
   private PassWordErrorRecordService passWordErrorRecordService;
   @Resource
   private ConfigService configService;
   @Resource
   private SystemService systemService;
   @Resource
   private HongBaoMessageService hongBaoMessageService;
   @Resource
   private ShamUserService shamUserService;
@@ -118,12 +111,7 @@
   private AccountMessageService accountMessageService;
   @Resource
   private CollectionGoodsService collectionGoodsService;
   @Resource
   private HongBaoManageService hongBaoManageService;
   @Resource
   private WxDownService wxDownService;
   @Resource
   private UserAccountService userAccountService;
@@ -143,6 +131,12 @@
   @Resource
   private TaoBaoUnionConfigService taoBaoUnionConfigService;
   @Resource
   private SpreadUserImgService spreadUserImgService;
   @Resource
   private UserShareGoodsRecordService userShareGoodsRecordService;
   private static final String PASSWORD_MAX_ERROR = "password_max_error";
   private static final String EXTRACT_MIN_MONEY = "extract_min_money";
   private static final String EXTRACT_MAX_MONEY = "extract_max_money";
@@ -157,19 +151,20 @@
    * @param tbOpenid
    * @param tbNickName
    * @param tbPortrait
    * @param tbSession(淘宝session数据,加密)
    * @param out
    */
   @RequestMapping(value = "login")
   public void login(AcceptData acceptData, String code, String vcode, String phone, boolean wxinstall,
         String tbOpenid, String tbNickName, String tbPortrait, int loginType, Boolean first, HttpSession session,
         PrintWriter out) {
         String tbOpenid, String tbNickName, String tbPortrait, String tbSession, int loginType, Boolean first,
         HttpSession session, HttpServletRequest request, PrintWriter out) {
      System system = systemService.getSystemCache(acceptData.getPlatform(), acceptData.getPackages());
      if (system == null) {
         out.print(JsonUtil.loadFalseResult("系统不存在"));
         return;
      }
      if (loginType == 3)// 验证短信验证码
      if (loginType == 3 && !Constant.IS_TEST)// 验证短信验证码
      {
         String oldVcode = redisManager.getSMSVCode(phone, SMSHistory.TYPE_LOGIN);
         if (StringUtil.isNullOrEmpty(oldVcode) || !oldVcode.equalsIgnoreCase(vcode)) {
@@ -185,7 +180,7 @@
      tbUserInfo.setTbName(tbNickName);
      tbUserInfo.setTbPic(tbPortrait);
      try {
         LoginResult result = userAccountService.login(session, first, system.getAppid(), code, phone, tbUserInfo,
         LoginResult result = userAccountService.login(request, first, system.getAppid(), code, phone, tbUserInfo,
               wxinstall, loginType);
         if (result == null)
            LogHelper.error("login-result为空值");
@@ -204,6 +199,11 @@
         root.put("data", data);
         out.print(JsonUtil.loadTrueResult(root));
      } catch (UserAccountException e) {
         try {
            LogHelper.cookieLog("登录出错:" + e.getCode() + "-" + e.getMessage());
         } catch (Exception e1) {
            e1.printStackTrace();
         }
         out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
      }
   }
@@ -328,11 +328,35 @@
            out.print(JsonUtil.loadFalseResult(1, "获取微信用户信息失败"));
            return;
         }
         user = userAccountService.getUserInfoByWXUnionId(system.getAppid(), weiXinUser.getUnionid());
         try {
            user = userAccountService.getUserInfoByWXUnionId(system.getAppid(), weiXinUser.getUnionid());
         } catch (UserAccountException e) {
            try {
               LogHelper.errorDetailInfo(e, null, "获取用户信息出错");
            } catch (Exception e1) {
               e1.printStackTrace();
            }
         }
      } else if (!StringUtil.isNullOrEmpty(tbOpenid)) {
         user = userAccountService.getUserInfoByTaoBaoOpenId(system.getAppid(), tbOpenid);
         try {
            user = userAccountService.getUserInfoByTaoBaoOpenId(system.getAppid(), tbOpenid);
         } catch (UserAccountException e) {
            try {
               LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
               e1.printStackTrace();
            }
         }
      } else if (!StringUtil.isNullOrEmpty(phone)) {
         user = userAccountService.getUserInfoByPhone(system.getAppid(), phone);
         try {
            user = userAccountService.getUserInfoByPhone(system.getAppid(), phone);
         } catch (UserAccountException e) {
            try {
               LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
               e1.printStackTrace();
            }
         }
      }
      if (user == null) {
@@ -430,16 +454,25 @@
    * @param tbOpenid
    * @param tbNickName
    * @param tbPortrait
    * @param tbSession
    *            -淘宝授权session
    * @param out
    */
   @RequestMapping(value = "bindTaoBao")
   public void bindTaoBao(AcceptData acceptData, Long uid, String tbOpenid, String tbNickName, String tbPortrait,
         PrintWriter out) {
         String tbSession, PrintWriter out) {
      System system = systemService.getSystemCache(acceptData.getPlatform(), acceptData.getPackages());
      if (system == null) {
         out.print(JsonUtil.loadFalseResult("系统不存在"));
         return;
      }
      if (!StringUtil.isNullOrEmpty(tbSession)) {
         JSONObject session = JSONObject.fromObject(tbSession);
         tbOpenid = session.optString("openId");
         tbNickName = session.optString("nick");
         tbPortrait = session.optString("avatarUrl");
      }
      try {
@@ -723,9 +756,7 @@
         redisManager.removeCommonString(key);
      }
   }
   @RequestMapping(value = "bindalipaywithverifynew")
   public void bindAlipayWithVerifyNew(AcceptData acceptData, Long uid, String name, String account, PrintWriter out) {
@@ -771,7 +802,8 @@
            "PERMIT_CHECK_PERM_IDENTITY_THEFT", "PERMIT_NON_BANK_LIMIT_PAYEE", "EXCEED_LIMIT_UNRN_DM_AMOUNT" };
      try {
         BindingAccount bindingAccount = bindingAccountService.changeAlipayBindingWithVerify(uid, name, account);
         out.print(JsonUtil.loadTrue(0, JsonUtil.getGson().toJson(bindingAccount), "系统已成功转账0.1元到提现账号中,提现账号验证通过,恭喜你!可以提现了。"));
         out.print(JsonUtil.loadTrue(0, JsonUtil.getGson().toJson(bindingAccount),
               "系统已成功转账0.1元到提现账号中,提现账号验证通过,恭喜你!可以提现了。"));
      } catch (AlipayTransferException e1) {
         if (e1.getSubCode().equalsIgnoreCase("PAYEE_NOT_EXIST")) {
            String msg = "系统未能成功转账0.1元,提现账号信息有误,请核对后重新填写。";
@@ -815,7 +847,6 @@
         redisManager.removeCommonString(key);
      }
   }
   /**
    * 获取用户资金详情
@@ -826,6 +857,7 @@
    */
   @RequestMapping(value = "getusermoney")
   public void getMoneyDetail(AcceptData acceptData, Long uid, PrintWriter out) {
      UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
      if (user == null) {
         out.print(JsonUtil.loadFalseResult(2, "用户不存在"));
@@ -841,32 +873,42 @@
      }
      BigDecimal moneyLastMonth = inviteGetMoneyService.getMoneyLastMonth(uid + "");
      BigDecimal unOpenmoney = hongBaoService.getUnOpenHongBaoByUid(uid);
      BigDecimal totalFanMoney = hongBaoService.getMyTotalHongBaoByUid(user.getId());
      BigDecimal unOpenmoney = hongBaoV2Service.getUnRecievedFanLiMoney(uid);
      BigDecimal totalFanMoney = hongBaoV2Service.getTotalFanLiMoney(uid);
      JSONObject data = new JSONObject();
      int spreadImgCount = spreadUserImgService.countUserSpreadImg(uid);
      long shareCount = userShareGoodsRecordService.countShareRecordByUid(uid);
      // IOS端数字按照字符串处理
      if ("ios".equalsIgnoreCase(acceptData.getPlatform()) && Integer.parseInt(acceptData.getVersion()) > 33) {
         data.put("moneyToday", moneyToday.setScale(2, BigDecimal.ROUND_DOWN).toString());
         data.put("moneyMonth", moneyMonth.setScale(2, BigDecimal.ROUND_DOWN).toString());
         data.put("moneyLastMonth", moneyLastMonth.toString());
         data.put("money", user.getMyHongBao().toString());
         data.put("unGetMoney", unOpenmoney.toString());
         data.put("totalFanLiMoney", totalFanMoney.toString());// 累计返利
         data.put("totalTiChengMoney", hongBaoService.getTotalTiChengMoney(uid).toString());// 累计提成
         data.put("totalUnGetTiChengMoney", hongBaoService.getUnGetTiChengMoney(uid).toString()); // 未到账提成
         data.put("moneyLastMonth", moneyLastMonth.setScale(2, BigDecimal.ROUND_DOWN).toString());
         data.put("money", user.getMyHongBao().setScale(2, BigDecimal.ROUND_DOWN).toString());
         data.put("unGetMoney", unOpenmoney.setScale(2, BigDecimal.ROUND_DOWN).toString());
         data.put("totalFanLiMoney", totalFanMoney.setScale(2, BigDecimal.ROUND_DOWN).toString());// 累计返利
         data.put("totalTiChengMoney",
               hongBaoV2Service.getTotalTiChengMoney(uid).setScale(2, BigDecimal.ROUND_DOWN).toString());// 累计提成
         data.put("totalUnGetTiChengMoney",
               hongBaoV2Service.getUnGetTiChengMoney(uid).setScale(2, BigDecimal.ROUND_DOWN).toString()); // 未到账提成
         // 展示提成数据
         data.put("showTiCheng", hongBaoService.getTotalTiChengCount(uid) > 0);
         if (configService.iosOnLining(Integer.parseInt(acceptData.getVersion())))
            data.put("showTiCheng", false);
         else
            data.put("showTiCheng", spreadImgCount + shareCount > 0);
      } else {
         data.put("moneyToday", moneyToday.setScale(2, BigDecimal.ROUND_DOWN));
         data.put("moneyMonth", moneyMonth.setScale(2, BigDecimal.ROUND_DOWN));
         data.put("moneyLastMonth", moneyLastMonth);
         data.put("money", user.getMyHongBao());
         data.put("unGetMoney", unOpenmoney);
         data.put("totalFanLiMoney", totalFanMoney);// 累计返利
         data.put("totalTiChengMoney", hongBaoService.getTotalTiChengMoney(uid));// 累计提成
         data.put("totalUnGetTiChengMoney", hongBaoService.getUnGetTiChengMoney(uid)); // 未到账提成
         data.put("moneyLastMonth", moneyLastMonth.setScale(2, BigDecimal.ROUND_DOWN));
         data.put("money", user.getMyHongBao().setScale(2, BigDecimal.ROUND_DOWN));
         data.put("unGetMoney", unOpenmoney.setScale(2, BigDecimal.ROUND_DOWN));
         data.put("totalFanLiMoney", totalFanMoney.setScale(2, BigDecimal.ROUND_DOWN));// 累计返利
         data.put("totalTiChengMoney",
               hongBaoV2Service.getTotalTiChengMoney(uid).setScale(2, BigDecimal.ROUND_DOWN));// 累计提成
         data.put("totalUnGetTiChengMoney",
               hongBaoV2Service.getUnGetTiChengMoney(uid).setScale(2, BigDecimal.ROUND_DOWN)); // 未到账提成
         // 展示提成数据
         data.put("showTiCheng", hongBaoService.getTotalTiChengCount(uid) > 0);
         data.put("showTiCheng", spreadImgCount + shareCount > 0);
      }
      user.setNoOpenHongBao(unOpenmoney);