admin
2019-03-12 efba42a325e1cf71c1d0f7a6ac46a0141c23443a
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserAccountServiceImpl.java
@@ -4,6 +4,7 @@
import java.io.FileWriter;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -19,18 +20,15 @@
import com.google.gson.Gson;
import com.qcloud.cos.model.COSObjectSummary;
import com.qcloud.cos.model.ObjectListing;
import com.yeshi.fanli.dao.mybatis.AccountDetailsMapper;
import com.yeshi.fanli.dao.mybatis.AccountMessageMapper;
import com.yeshi.fanli.dao.mybatis.BindingAccountMapper;
import com.yeshi.fanli.dao.mybatis.MoneyRecordMapper;
import com.yeshi.fanli.dao.mybatis.PidOrderMapper;
import com.yeshi.fanli.dao.mybatis.ThreeSaleMapper;
import com.yeshi.fanli.dao.mybatis.UserConnectHistoryMapper;
import com.yeshi.fanli.dao.mybatis.UserInfoMapper;
import com.yeshi.fanli.dao.mybatis.hongbao.HongBaoMapper;
import com.yeshi.fanli.dao.mybatis.order.OrderItemMapper;
import com.yeshi.fanli.dao.mybatis.order.OrderMapper;
import com.yeshi.fanli.entity.bus.user.AccountDetails;
import com.yeshi.fanli.entity.bus.user.AccountMessage;
import com.yeshi.fanli.entity.bus.user.BindingAccount;
import com.yeshi.fanli.entity.bus.user.ForbiddenUserIdentifyCode;
@@ -48,6 +46,7 @@
import com.yeshi.fanli.exception.UserAccountException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.hongbao.HongBaoService;
import com.yeshi.fanli.service.inter.hongbao.ThreeSaleSerivce;
import com.yeshi.fanli.service.inter.msg.UserAccountMsgNotificationService;
import com.yeshi.fanli.service.inter.user.ForbiddenUserIdentifyCodeService;
import com.yeshi.fanli.service.inter.user.SpreadUserImgService;
@@ -57,7 +56,6 @@
import com.yeshi.fanli.util.FileUtil;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.TimeUtil;
import com.yeshi.fanli.util.factory.AccountDetailsFactory;
import com.yeshi.fanli.util.factory.msg.MsgAccountDetailFactory;
import com.yeshi.fanli.util.wx.WXLoginUtil;
@@ -76,9 +74,6 @@
   private UserConnectHistoryMapper userConnectHistoryMapper;
   @Resource
   private AccountDetailsMapper accountDetailsMapper;
   @Resource
   private HongBaoMapper hongBaoMapper;
   @Resource
@@ -88,7 +83,7 @@
   private OrderItemMapper orderItemMapper;
   @Resource
   private ThreeSaleMapper threeSaleMapper;
   private ThreeSaleSerivce threeSaleSerivce;
   @Resource
   private PidOrderMapper pidOrderMapper;
@@ -198,7 +193,7 @@
            if (lastUser == null) {
               if (userInfo != null) {
                  // 使分销关系生效
                  threeSaleMapper.effectThreeSale(userInfo.getId());
                  threeSaleSerivce.effective(userInfo);
                  // 更新头像与昵称
                  UserInfo updateUserInfo = new UserInfo(userInfo.getId());
                  updateUserInfo.setNickName(weiXinUser.getNickname());
@@ -274,7 +269,7 @@
                     session.removeAttribute("LAST_LOGIN_USER");
                     // 使分销关系生效
                     threeSaleMapper.effectThreeSale(userInfo.getId());
                     threeSaleSerivce.effective(userInfo);
                     return new LoginResult(LoginResult.TYPE_NORMAL, userInfo);
                  } else {// 两个账号拥有不同的UID
@@ -288,7 +283,7 @@
                     result.setLessUser(lastUser);
                     // 使分销关系生效
                     threeSaleMapper.effectThreeSale(userInfo.getId());
                     threeSaleSerivce.effective(userInfo);
                     return result;
                  }
@@ -499,9 +494,9 @@
      if (!StringUtil.isNullOrEmpty(mainUser.getPhone()) && !StringUtil.isNullOrEmpty(lessUser.getPhone()))
         throw new UserAccountException(9, "两个账号都绑定了手机号码,请解绑其中一个");
      if (lessUser.getMyHongBao().compareTo(new BigDecimal("20")) >= 0
            && mainUser.getMyHongBao().compareTo(new BigDecimal("20")) > 0)
         throw new UserAccountException(10, String.format("账户ID:%s 的资金超过20元,为保证资金安全请联系客服打通", lessUser.getId() + ""));
      if (lessUser.getMyHongBao().compareTo(new BigDecimal("10")) >= 0
            && mainUser.getMyHongBao().compareTo(new BigDecimal("10")) > 0)
         throw new UserAccountException(10, String.format("账户ID:%s 的资金超过10元,为保证资金安全请联系客服打通", lessUser.getId() + ""));
      // 判定是否绑定了同一支付宝
      List<BindingAccount> mainUserAccountList = bindingAccountMapper.selectByUid(mainUser.getId());
@@ -577,15 +572,7 @@
      // 有2个或者2个以上的新人红包
      if (addCount - subCount > 1) {
         // 扣除一个新人红包
         AccountDetails accountDetails = new AccountDetails();
         accountDetails.setCreateTime(TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss"));
         accountDetails.setExtract(null);
         accountDetails.setMoney("-" + list.get(1).getMoney().toString());
         accountDetails.setOrderItem(null);
         accountDetails.setTitle(" 账号合并扣除重复新人红包");
         accountDetails.setType(AccountDetailsFactory.TUIKUAN);
         accountDetails.setUserInfo(mainUser);
         accountDetailsMapper.insertSelective(accountDetails);
         // TODO 扣除新人红包操作
         AccountMessage accountMessage = new AccountMessage();
         accountMessage.setContent(" 账号合并扣除重复新人红包" + list.get(1).getMoney().toString() + "元");
@@ -901,8 +888,7 @@
      // 备份用户信息
      UserInfo user = userInfoMapper.selectByPrimaryKey(uid);
      // 备份资金明细
      List<AccountDetails> accountDetailsList = accountDetailsMapper.selectByUid(uid);
      // TODO 备份资金明细
      // 备份红包信息
      List<HongBao> hongBaoList = hongBaoMapper.selectByUid(uid);
      // 备份订单,子订单信息
@@ -910,7 +896,7 @@
      List<OrderItem> orderItemList = orderItemMapper.selectByUid(uid);
      // 备份邀请关系
      List<ThreeSale> threeSaleList = threeSaleMapper.selectByUid(uid);
      List<ThreeSale> threeSaleList = new ArrayList<>();
      // 备份分享赚
      List<PidOrder> pidOrderList = pidOrderMapper.selectByUid(uid);
@@ -922,9 +908,6 @@
         fw.write("#UserInfo" + "\r\n");
         fw.write(JsonUtil.getSimpleGsonWithDate().toJson(user) + "\r\n");
         fw.write("#AccountDetails" + "\r\n");
         fw.write(JsonUtil.getSimpleGsonWithDate().toJson(accountDetailsList) + "\r\n");
         fw.write("#HongBao" + "\r\n");
         fw.write(JsonUtil.getSimpleGsonWithDate().toJson(hongBaoList) + "\r\n");