fanli/src/main/java/com/yeshi/fanli/entity/bus/user/Order.java
@@ -1,9 +1,7 @@ package com.yeshi.fanli.entity.bus.user; import java.math.BigDecimal; import java.util.ArrayList; import java.util.Date; import java.util.List; import javax.persistence.Column; import javax.persistence.Entity; @@ -12,14 +10,11 @@ import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.JoinTable; import javax.persistence.ManyToOne; import javax.persistence.OneToMany; import javax.persistence.Table; import javax.persistence.UniqueConstraint; import com.google.gson.annotations.Expose; import com.yeshi.fanli.dto.order.OrderItem; /** * 订单 @@ -121,10 +116,10 @@ @org.yeshi.utils.mybatis.Column(name = "version") private Integer version; @OneToMany(fetch = FetchType.EAGER) @JoinTable(name = "yeshi_ec_order_item", joinColumns = { @JoinColumn(name = "oid") }, inverseJoinColumns = { @JoinColumn(name = "id") }) private List<OrderItem> orderItemList = new ArrayList<OrderItem>(); // @OneToMany(fetch = FetchType.EAGER) // @JoinTable(name = "yeshi_ec_order_item", joinColumns = { @JoinColumn(name = "oid") }, inverseJoinColumns = { // @JoinColumn(name = "id") }) // private List<OrderItem> orderItemList = new ArrayList<OrderItem>(); public Order() { money = BigDecimal.valueOf(0); @@ -142,13 +137,13 @@ return id; } public List<OrderItem> getOrderItemList() { return orderItemList; } public void setOrderItemList(List<OrderItem> orderItemList) { this.orderItemList = orderItemList; } // public List<OrderItem> getOrderItemList() { // return orderItemList; // } // // public void setOrderItemList(List<OrderItem> orderItemList) { // this.orderItemList = orderItemList; // } public void setId(Long id) { this.id = id; fanli/src/main/java/com/yeshi/fanli/service/impl/user/BindingAccountServiceImpl.java
@@ -1,6 +1,5 @@ package com.yeshi.fanli.service.impl.user; import java.io.Serializable; import java.math.BigDecimal; import java.util.Calendar; import java.util.Date; @@ -9,11 +8,6 @@ import javax.annotation.Resource; import org.hibernate.HibernateException; import org.hibernate.Query; import org.hibernate.Session; import org.hibernate.Transaction; import org.springframework.orm.hibernate4.HibernateCallback; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -26,7 +20,6 @@ import com.yeshi.fanli.dao.mybatis.BindingAccountMapper; import com.yeshi.fanli.dao.mybatis.UserInfoMapper; import com.yeshi.fanli.dao.mybatis.money.UserMoneyDetailMapper; import com.yeshi.fanli.dao.user.BindingAccountDao; import com.yeshi.fanli.entity.bus.user.AlipayAccountValidNormalHistory; import com.yeshi.fanli.entity.bus.user.BindingAccount; import com.yeshi.fanli.entity.bus.user.UserInfo; @@ -46,61 +39,46 @@ @Service public class BindingAccountServiceImpl implements BindingAccountService { @Resource private BindingAccountDao bindingAccountDao; @Resource private BindingAccountMapper bindingAccountMapper; @Resource private AlipayAccountValidNormalHistoryMapper alipayAccountValidNormalHistoryMapper; @Resource private UserInfoMapper userInfoMapper; @Resource private UserNotificationService userNotificationService; @Resource private UserMoneyDetailMapper userMoneyDetailMapper; public List<BindingAccount> getBindingAccountByUid(long uid) { return bindingAccountDao.list("from BindingAccount ba where ba.userInfo.id=?", new Serializable[] { uid }); return bindingAccountMapper.selectByUid(uid); } public void addBindingAccount(BindingAccount addAccount) throws BindingAccountException { List<BindingAccount> list = bindingAccountDao.list( "from BindingAccount ba where ba.userInfo.id=? and ba.type=?", new Serializable[] { addAccount.getUserInfo().getId(), addAccount.getType() }); if (list == null || list.size() == 0) { bindingAccountDao.save(addAccount); BindingAccount account = bindingAccountMapper.selectByUidAndType(addAccount.getUserInfo().getId(), addAccount.getType()); if (account == null) { bindingAccountMapper.insertSelective(addAccount); } else { throw new BindingAccountException(Constant.BA_EXIST); } } public Integer deleteBindingAccount(final BindingAccount account) { return (Integer) bindingAccountDao.excute(new HibernateCallback() { public Integer doInHibernate(Session session) throws HibernateException { Transaction transaction = session.beginTransaction(); Query delete = session.createQuery("delete BindingAccount ba where ba.userInfo.id=? and ba.type=?"); delete.setLong(0, account.getUserInfo().getId()); delete.setInteger(1, account.getType()); int update = delete.executeUpdate(); transaction.commit(); return update; } }); @Transactional public Integer deleteBindingAccount(BindingAccount account) { BindingAccount oldAccount = bindingAccountMapper.selectByUidAndType(account.getUserInfo().getId(), account.getType()); if (oldAccount != null) bindingAccountMapper.deleteByPrimaryKey(oldAccount.getId()); return 1; } public BindingAccount getBindingAccountByUidAndType(long uid, int type) { List<BindingAccount> list = bindingAccountDao .list("from BindingAccount ba where ba.userInfo.id=? and ba.type=?", new Serializable[] { uid, type }); if (list != null && list.size() != 0) { return list.get(0); } return null; BindingAccount account = bindingAccountMapper.selectByUidAndType(uid, type); return account; } @Override @@ -113,11 +91,11 @@ bindingAccount.setName(name); bindingAccount.setType(BindingAccount.TYPE_ALIPAY); bindingAccount.setUserInfo(new UserInfo(uid)); bindingAccountDao.create(bindingAccount); bindingAccountMapper.insertSelective(bindingAccount); } else { bindingAccount.setName(name); bindingAccount.setAccount(account); bindingAccountDao.update(bindingAccount); bindingAccountMapper.updateByPrimaryKeySelective(bindingAccount); } return bindingAccount; } fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserAccountServiceImpl.java
@@ -21,15 +21,12 @@ import com.qcloud.cos.model.COSObjectSummary; import com.qcloud.cos.model.ObjectListing; import com.yeshi.fanli.dao.mybatis.AccountMessageMapper; import com.yeshi.fanli.dao.mybatis.BindingAccountMapper; import com.yeshi.fanli.dao.mybatis.UserConnectHistoryMapper; import com.yeshi.fanli.dao.mybatis.UserInfoMapper; import com.yeshi.fanli.dao.mybatis.order.OrderMapper; import com.yeshi.fanli.entity.bus.user.BindingAccount; import com.yeshi.fanli.entity.bus.user.ForbiddenUserIdentifyCode; import com.yeshi.fanli.entity.bus.user.ForbiddenUserIdentifyCode.ForbiddenUserIdentifyCodeTypeEnum; import com.yeshi.fanli.entity.bus.user.LoginResult; import com.yeshi.fanli.entity.bus.user.Order; import com.yeshi.fanli.entity.bus.user.ThreeSale; import com.yeshi.fanli.entity.bus.user.UserConnectHistory; import com.yeshi.fanli.entity.bus.user.UserInfo; @@ -38,6 +35,7 @@ import com.yeshi.fanli.log.LogHelper; import com.yeshi.fanli.service.inter.hongbao.ThreeSaleSerivce; import com.yeshi.fanli.service.inter.msg.UserAccountMsgNotificationService; import com.yeshi.fanli.service.inter.user.BindingAccountService; import com.yeshi.fanli.service.inter.user.ForbiddenUserIdentifyCodeService; import com.yeshi.fanli.service.inter.user.SpreadUserImgService; import com.yeshi.fanli.service.inter.user.UserAccountService; @@ -58,13 +56,10 @@ private UserInfoMapper userInfoMapper; @Resource private BindingAccountMapper bindingAccountMapper; private BindingAccountService bindingAccountService; @Resource private UserConnectHistoryMapper userConnectHistoryMapper; @Resource private OrderMapper orderMapper; @Resource private ThreeSaleSerivce threeSaleSerivce; @@ -475,27 +470,16 @@ throw new UserAccountException(10, String.format("账户ID:%s 的资金超过10元,为保证资金安全请联系客服打通", lessUser.getId() + "")); // 判定是否绑定了同一支付宝 List<BindingAccount> mainUserAccountList = bindingAccountMapper.selectByUid(mainUser.getId()); if (mainUserAccountList != null) for (int i = 0; i < mainUserAccountList.size(); i++) { if (mainUserAccountList.get(i).getType() == BindingAccount.TYPE_WXPAY) { mainUserAccountList.remove(i); i--; } } List<BindingAccount> lessUserAccountList = bindingAccountMapper.selectByUid(lessUser.getId()); if (lessUserAccountList != null) for (int i = 0; i < lessUserAccountList.size(); i++) { if (lessUserAccountList.get(i).getType() == BindingAccount.TYPE_WXPAY) { lessUserAccountList.remove(i); i--; } } BindingAccount mainUserAccount = bindingAccountService.getBindingAccountByUidAndType(mainUser.getId(), BindingAccount.TYPE_ALIPAY); BindingAccount lessUserAccount = bindingAccountService.getBindingAccountByUidAndType(lessUser.getId(), BindingAccount.TYPE_ALIPAY); // 有不同的支付宝账号 boolean hasDiffrentAlipayAccount = false; if (mainUserAccountList != null && mainUserAccountList.size() > 0 && lessUserAccountList != null && lessUserAccountList.size() > 0) { if (!mainUserAccountList.get(0).getAccount().equalsIgnoreCase(lessUserAccountList.get(0).getAccount())) if (mainUserAccount != null && lessUserAccount != null) { if (!mainUserAccount.getAccount().equalsIgnoreCase(lessUserAccount.getAccount())) hasDiffrentAlipayAccount = true; } @@ -828,8 +812,6 @@ UserInfo user = userInfoMapper.selectByPrimaryKey(uid); // TODO 备份资金明细 // 备份订单,子订单信息 List<Order> orderList = orderMapper.selectByUid(uid); // 备份邀请关系 List<ThreeSale> threeSaleList = new ArrayList<>(); @@ -841,9 +823,6 @@ fw.write("#UserInfo" + "\r\n"); fw.write(JsonUtil.getSimpleGsonWithDate().toJson(user) + "\r\n"); fw.write("#Order" + "\r\n"); fw.write(JsonUtil.getSimpleGsonWithDate().toJson(orderList) + "\r\n"); fw.write("#ThreeSale" + "\r\n"); fw.write(JsonUtil.getSimpleGsonWithDate().toJson(threeSaleList) + "\r\n");