提交 6d73ad04 authored 作者: jacksmith1988's avatar jacksmith1988

//add code

上级 f3e415a8
...@@ -141,12 +141,15 @@ public class MerchantOrder { ...@@ -141,12 +141,15 @@ public class MerchantOrder {
private MerchantOrderPayInfo payInfo; private MerchantOrderPayInfo payInfo;
@NotFound(action = NotFoundAction.IGNORE) @NotFound(action = NotFoundAction.IGNORE)
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "gathering_id", updatable = false, insertable = false, foreignKey = @ForeignKey(value = ConstraintMode.NO_CONSTRAINT)) @JoinColumn(name = "gathering_id", updatable = false, insertable = false, foreignKey = @ForeignKey(value = ConstraintMode.NO_CONSTRAINT))
private GatheringCode gatheringCode; private GatheringCode gatheringCode;
// private String gatheringId; @Column(name = "gathering_id", length = 32)
private String gatheringId;
private String remark; private String remark;
...@@ -175,12 +178,12 @@ public class MerchantOrder { ...@@ -175,12 +178,12 @@ public class MerchantOrder {
setRemark(remark); setRemark(remark);
} }
public void updateReceived(String receivedAccountId, String gatheringCodeStorageId,String gatheringId) { public void updateReceived(String receivedAccountId, String gatheringCodeStorageId,GatheringCode gatheringCode) {
this.setReceivedAccountId(receivedAccountId); this.setReceivedAccountId(receivedAccountId);
this.setGatheringCodeStorageId(gatheringCodeStorageId); this.setGatheringCodeStorageId(gatheringCodeStorageId);
this.setOrderState(Constant.商户订单状态_已接单); this.setOrderState(Constant.商户订单状态_已接单);
this.setReceivedTime(new Date()); this.setReceivedTime(new Date());
this.setGatheringId(gatheringCode.getId());
} }
public void customerCancelOrderRefund() { public void customerCancelOrderRefund() {
......
...@@ -489,9 +489,9 @@ public class MerchantOrderService { ...@@ -489,9 +489,9 @@ public class MerchantOrderService {
//todo this is temporary code 这里要匹配有资源的用户接单 //todo this is temporary code 这里要匹配有资源的用户接单
List<UserAccount> userAccounts = userAccountRepo.findAllByAccountTypeAndState(Constant.账号类型_会员, Constant.账号状态_启用).orElseThrow(() -> new BizException(BizError.系统无可用商户)); List<UserAccount> userAccounts = userAccountRepo.findAllByAccountTypeAndState(Constant.账号类型_会员, Constant.账号状态_启用).orElseThrow(() -> new BizException(BizError.系统无可用商户));
Collections.shuffle(userAccounts);
this.receiveOrder(userAccounts.get(0).getId(), merchantOrder.getId());
this.receiveOrder(userAccounts.get(RandomUtil.randomInt(0, userAccounts.size())).getId(), merchantOrder.getId());
return MerchantOrderVO.convertFor(merchantOrder); return MerchantOrderVO.convertFor(merchantOrder);
} }
...@@ -546,7 +546,7 @@ public class MerchantOrderService { ...@@ -546,7 +546,7 @@ public class MerchantOrderService {
if (setting != null && setting.getOrderPayEffectiveDuration() != null) { if (setting != null && setting.getOrderPayEffectiveDuration() != null) {
orderEffectiveDuration = setting.getOrderPayEffectiveDuration(); orderEffectiveDuration = setting.getOrderPayEffectiveDuration();
} }
platformOrder.updateReceived(userAccount.getId(), gatheringCode.getStorageId(), gatheringCode.getId()); platformOrder.updateReceived(userAccount.getId(), gatheringCode.getStorageId(), gatheringCode);
platformOrder.updateRemark(gatheringCode.getBankCode() + "_" + gatheringCode.getBankUsername() + "_" + gatheringCode.getBankAddress()); platformOrder.updateRemark(gatheringCode.getBankCode() + "_" + gatheringCode.getBankUsername() + "_" + gatheringCode.getBankAddress());
platformOrder.updateUsefulTime( platformOrder.updateUsefulTime(
DateUtil.offset(platformOrder.getReceivedTime(), DateField.MINUTE, orderEffectiveDuration)); DateUtil.offset(platformOrder.getReceivedTime(), DateField.MINUTE, orderEffectiveDuration));
......
...@@ -3,6 +3,7 @@ package me.zohar.runscore.useraccount.service; ...@@ -3,6 +3,7 @@ package me.zohar.runscore.useraccount.service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Optional;
import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.CriteriaQuery;
...@@ -60,379 +61,374 @@ import me.zohar.runscore.useraccount.vo.UserAccountInfoVO; ...@@ -60,379 +61,374 @@ import me.zohar.runscore.useraccount.vo.UserAccountInfoVO;
@Service @Service
public class UserAccountService { public class UserAccountService {
@Autowired @Autowired
private UserAccountRepo userAccountRepo; private UserAccountRepo userAccountRepo;
@Autowired @Autowired
private AccountChangeLogRepo accountChangeLogRepo; private AccountChangeLogRepo accountChangeLogRepo;
@Autowired @Autowired
private InviteCodeRepo inviteCodeRepo; private InviteCodeRepo inviteCodeRepo;
@Autowired @Autowired
private RegisterSettingRepo registerSettingRepo; private RegisterSettingRepo registerSettingRepo;
/** /**
* 更新接单状态 * 更新接单状态
* */
* @param userAccountId @Transactional
* @param receiveOrderState public void updateReceiveOrderState(@NotBlank String userAccountId, @NotBlank String receiveOrderState) {
*/ UserAccount userAccount = userAccountRepo.getOne(userAccountId);
@Transactional userAccount.setReceiveOrderState(receiveOrderState);
public void updateReceiveOrderState(@NotBlank String userAccountId, @NotBlank String receiveOrderState) { userAccountRepo.save(userAccount);
UserAccount userAccount = userAccountRepo.getOne(userAccountId); }
userAccount.setReceiveOrderState(receiveOrderState);
userAccountRepo.save(userAccount); /**
} * 更新最近登录时间
*/
/** @Transactional
* 更新最近登录时间 public void updateLatelyLoginTime(String userAccountId) {
*/ UserAccount userAccount = userAccountRepo.getOne(userAccountId);
@Transactional userAccount.setLatelyLoginTime(new Date());
public void updateLatelyLoginTime(String userAccountId) { userAccountRepo.save(userAccount);
UserAccount userAccount = userAccountRepo.getOne(userAccountId); }
userAccount.setLatelyLoginTime(new Date());
userAccountRepo.save(userAccount); @ParamValid
} @Transactional
public void updateUserAccount(UserAccountEditParam param) {
@ParamValid UserAccount existUserAccount = userAccountRepo.findByUserName(param.getUserName());
@Transactional if (existUserAccount != null && !existUserAccount.getId().equals(param.getUserAccountId())) {
public void updateUserAccount(UserAccountEditParam param) { throw new BizException(BizError.用户名已存在);
UserAccount existUserAccount = userAccountRepo.findByUserName(param.getUserName()); }
if (existUserAccount != null && !existUserAccount.getId().equals(param.getUserAccountId())) { UserAccount userAccount = userAccountRepo.getOne(param.getUserAccountId());
throw new BizException(BizError.用户名已存在); if (userAccount.getInviter() != null) {
} // 校验下级账号的返点不能大于上级账号
UserAccount userAccount = userAccountRepo.getOne(param.getUserAccountId()); if (param.getRebate() > userAccount.getInviter().getRebate()) {
if (userAccount.getInviter() != null) { throw new BizException(BizError.下级账号的返点不能大于上级账号);
// 校验下级账号的返点不能大于上级账号 }
if (param.getRebate() > userAccount.getInviter().getRebate()) { }
throw new BizException(BizError.下级账号的返点不能大于上级账号); BeanUtils.copyProperties(param, userAccount);
} userAccountRepo.save(userAccount);
} }
BeanUtils.copyProperties(param, userAccount);
userAccountRepo.save(userAccount); @Transactional(readOnly = true)
} public UserAccountDetailsInfoVO findUserAccountDetailsInfoById(String userAccountId) {
UserAccount userAccount = userAccountRepo.getOne(userAccountId);
@Transactional(readOnly = true) return UserAccountDetailsInfoVO.convertFor(userAccount);
public UserAccountDetailsInfoVO findUserAccountDetailsInfoById(String userAccountId) { }
UserAccount userAccount = userAccountRepo.getOne(userAccountId);
return UserAccountDetailsInfoVO.convertFor(userAccount); @Transactional(readOnly = true)
} public PageResult<UserAccountDetailsInfoVO> findUserAccountDetailsInfoByPage(UserAccountQueryCondParam param) {
Specification<UserAccount> spec = new Specification<UserAccount>() {
@Transactional(readOnly = true) /**
public PageResult<UserAccountDetailsInfoVO> findUserAccountDetailsInfoByPage(UserAccountQueryCondParam param) { *
Specification<UserAccount> spec = new Specification<UserAccount>() { */
/** private static final long serialVersionUID = 1L;
*
*/ public Predicate toPredicate(Root<UserAccount> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
private static final long serialVersionUID = 1L; List<Predicate> predicates = new ArrayList<Predicate>();
if (StrUtil.isNotEmpty(param.getUserName())) {
public Predicate toPredicate(Root<UserAccount> root, CriteriaQuery<?> query, CriteriaBuilder builder) { predicates.add(builder.like(root.get("userName"), "%" + param.getUserName() + "%"));
List<Predicate> predicates = new ArrayList<Predicate>(); }
if (StrUtil.isNotEmpty(param.getUserName())) { if (StrUtil.isNotEmpty(param.getRealName())) {
predicates.add(builder.like(root.get("userName"), "%" + param.getUserName() + "%")); predicates.add(builder.like(root.get("realName"), "%" + param.getRealName() + "%"));
} }
if (StrUtil.isNotEmpty(param.getRealName())) { return predicates.size() > 0 ? builder.and(predicates.toArray(new Predicate[predicates.size()])) : null;
predicates.add(builder.like(root.get("realName"), "%" + param.getRealName() + "%")); }
} };
return predicates.size() > 0 ? builder.and(predicates.toArray(new Predicate[predicates.size()])) : null; Page<UserAccount> result = userAccountRepo.findAll(spec, PageRequest.of(param.getPageNum() - 1,
} param.getPageSize(), Sort.by(Sort.Order.desc("registeredTime"))));
}; PageResult<UserAccountDetailsInfoVO> pageResult = new PageResult<>(
Page<UserAccount> result = userAccountRepo.findAll(spec, PageRequest.of(param.getPageNum() - 1, UserAccountDetailsInfoVO.convertFor(result.getContent()), param.getPageNum(), param.getPageSize(),
param.getPageSize(), Sort.by(Sort.Order.desc("registeredTime")))); result.getTotalElements());
PageResult<UserAccountDetailsInfoVO> pageResult = new PageResult<>( return pageResult;
UserAccountDetailsInfoVO.convertFor(result.getContent()), param.getPageNum(), param.getPageSize(), }
result.getTotalElements());
return pageResult; @ParamValid
} @Transactional
public void bindBankInfo(BindBankInfoParam param) {
@ParamValid UserAccount userAccount = userAccountRepo.getOne(param.getUserAccountId());
@Transactional BeanUtils.copyProperties(param, userAccount);
public void bindBankInfo(BindBankInfoParam param) { userAccount.setBankInfoLatelyModifyTime(new Date());
UserAccount userAccount = userAccountRepo.getOne(param.getUserAccountId()); userAccountRepo.save(userAccount);
BeanUtils.copyProperties(param, userAccount); }
userAccount.setBankInfoLatelyModifyTime(new Date());
userAccountRepo.save(userAccount); @ParamValid
} @Transactional
public void modifyLoginPwd(ModifyLoginPwdParam param) {
@ParamValid UserAccount userAccount = userAccountRepo.getOne(param.getUserAccountId());
@Transactional BCryptPasswordEncoder pwdEncoder = new BCryptPasswordEncoder();
public void modifyLoginPwd(ModifyLoginPwdParam param) { if (!pwdEncoder.matches(param.getOldLoginPwd(), userAccount.getLoginPwd())) {
UserAccount userAccount = userAccountRepo.getOne(param.getUserAccountId()); throw new BizException(BizError.旧的登录密码不正确);
BCryptPasswordEncoder pwdEncoder = new BCryptPasswordEncoder(); }
if (!pwdEncoder.matches(param.getOldLoginPwd(), userAccount.getLoginPwd())) { modifyLoginPwd(param.getUserAccountId(), param.getNewLoginPwd());
throw new BizException(BizError.旧的登录密码不正确); }
}
modifyLoginPwd(param.getUserAccountId(), param.getNewLoginPwd()); @Transactional
} public void modifyLoginPwd(@NotBlank String userAccountId, @NotBlank String newLoginPwd) {
UserAccount userAccount = userAccountRepo.getOne(userAccountId);
@Transactional userAccount.setLoginPwd(new BCryptPasswordEncoder().encode(newLoginPwd));
public void modifyLoginPwd(@NotBlank String userAccountId, @NotBlank String newLoginPwd) { userAccountRepo.save(userAccount);
UserAccount userAccount = userAccountRepo.getOne(userAccountId); }
userAccount.setLoginPwd(new BCryptPasswordEncoder().encode(newLoginPwd));
userAccountRepo.save(userAccount); @ParamValid
} @Transactional
public void modifyMoneyPwd(ModifyMoneyPwdParam param) {
@ParamValid UserAccount userAccount = userAccountRepo.getOne(param.getUserAccountId());
@Transactional BCryptPasswordEncoder pwdEncoder = new BCryptPasswordEncoder();
public void modifyMoneyPwd(ModifyMoneyPwdParam param) { if (!pwdEncoder.matches(param.getOldMoneyPwd(), userAccount.getMoneyPwd())) {
UserAccount userAccount = userAccountRepo.getOne(param.getUserAccountId()); throw new BizException(BizError.旧的资金密码不正确);
BCryptPasswordEncoder pwdEncoder = new BCryptPasswordEncoder(); }
if (!pwdEncoder.matches(param.getOldMoneyPwd(), userAccount.getMoneyPwd())) { String newMoneyPwd = pwdEncoder.encode(param.getNewMoneyPwd());
throw new BizException(BizError.旧的资金密码不正确); userAccount.setMoneyPwd(newMoneyPwd);
} userAccountRepo.save(userAccount);
String newMoneyPwd = pwdEncoder.encode(param.getNewMoneyPwd()); }
userAccount.setMoneyPwd(newMoneyPwd);
userAccountRepo.save(userAccount); @ParamValid
} @Transactional
public void modifyMoneyPwd(@NotBlank String userAccountId, @NotBlank String newMoneyPwd) {
@ParamValid UserAccount userAccount = userAccountRepo.getOne(userAccountId);
@Transactional userAccount.setMoneyPwd(new BCryptPasswordEncoder().encode(newMoneyPwd));
public void modifyMoneyPwd(@NotBlank String userAccountId, @NotBlank String newMoneyPwd) { userAccountRepo.save(userAccount);
UserAccount userAccount = userAccountRepo.getOne(userAccountId); }
userAccount.setMoneyPwd(new BCryptPasswordEncoder().encode(newMoneyPwd));
userAccountRepo.save(userAccount); @Transactional(readOnly = true)
} public LoginAccountInfoVO getLoginAccountInfo(String userName) {
return LoginAccountInfoVO.convertFor(userAccountRepo.findByUserName(userName));
@Transactional(readOnly = true) }
public LoginAccountInfoVO getLoginAccountInfo(String userName) {
return LoginAccountInfoVO.convertFor(userAccountRepo.findByUserName(userName)); @Transactional(readOnly = true)
} public UserAccountInfoVO getUserAccountInfo(String userAccountId) {
return UserAccountInfoVO.convertFor(userAccountRepo.getOne(userAccountId));
@Transactional(readOnly = true) }
public UserAccountInfoVO getUserAccountInfo(String userAccountId) {
return UserAccountInfoVO.convertFor(userAccountRepo.getOne(userAccountId)); @Transactional(readOnly = true)
} public BankInfoVO getBankInfo(String userAccountId) {
return BankInfoVO.convertFor(userAccountRepo.getOne(userAccountId));
@Transactional(readOnly = true) }
public BankInfoVO getBankInfo(String userAccountId) {
return BankInfoVO.convertFor(userAccountRepo.getOne(userAccountId)); @ParamValid
} @Transactional
public void addUserAccount(AddUserAccountParam param) {
@ParamValid UserAccount userAccount = userAccountRepo.findByUserName(param.getUserName());
@Transactional if (userAccount != null) {
public void addUserAccount(AddUserAccountParam param) { throw new BizException(BizError.用户名已存在);
UserAccount userAccount = userAccountRepo.findByUserName(param.getUserName()); }
if (userAccount != null) { String encodePwd = new BCryptPasswordEncoder().encode(param.getLoginPwd());
throw new BizException(BizError.用户名已存在); param.setLoginPwd(encodePwd);
} UserAccount newUserAccount = param.convertToPo();
String encodePwd = new BCryptPasswordEncoder().encode(param.getLoginPwd()); if (StrUtil.isNotBlank(param.getInviterUserName())) {
param.setLoginPwd(encodePwd); UserAccount inviter = userAccountRepo.findByUserName(param.getInviterUserName());
UserAccount newUserAccount = param.convertToPo(); if (inviter == null) {
if (StrUtil.isNotBlank(param.getInviterUserName())) { throw new BizException(BizError.邀请人不存在);
UserAccount inviter = userAccountRepo.findByUserName(param.getInviterUserName()); }
if (inviter == null) { // 校验下级账号的返点不能大于上级账号
throw new BizException(BizError.邀请人不存在); if (param.getRebate() > inviter.getRebate()) {
} throw new BizException(BizError.下级账号的返点不能大于上级账号);
// 校验下级账号的返点不能大于上级账号 }
if (param.getRebate() > inviter.getRebate()) { newUserAccount.setInviterId(inviter.getId());
throw new BizException(BizError.下级账号的返点不能大于上级账号); newUserAccount.setAccountLevel(Optional.ofNullable(inviter.getAccountLevel()).orElse(0) + 1);
} newUserAccount.setAccountLevelPath(inviter.getAccountLevelPath() + "." + newUserAccount.getId());
newUserAccount.setInviterId(inviter.getId()); }
newUserAccount.setAccountLevel(inviter.getAccountLevel() + 1); userAccountRepo.save(newUserAccount);
newUserAccount.setAccountLevelPath(inviter.getAccountLevelPath() + "." + newUserAccount.getId()); }
}
userAccountRepo.save(newUserAccount); /**
} * 账号注册
*/
/** @ParamValid
* 账号注册 @Transactional
* public void register(UserAccountRegisterParam param) {
* @param param UserAccount userAccount = userAccountRepo.findByUserName(param.getUserName());
*/ if (userAccount != null) {
@ParamValid throw new BizException(BizError.用户名已存在);
@Transactional }
public void register(UserAccountRegisterParam param) { param.setLoginPwd(new BCryptPasswordEncoder().encode(param.getLoginPwd()));
UserAccount userAccount = userAccountRepo.findByUserName(param.getUserName()); param.setMoneyPwd(new BCryptPasswordEncoder().encode(param.getMoneyPwd()));
if (userAccount != null) { UserAccount newUserAccount = param.convertToPo();
throw new BizException(BizError.用户名已存在); RegisterSetting setting = registerSettingRepo.findTopByOrderByLatelyUpdateTime();
} if (!setting.getRegisterEnabled()) {
param.setLoginPwd(new BCryptPasswordEncoder().encode(param.getLoginPwd())); throw new BizException(BizError.未开放注册功能);
param.setMoneyPwd(new BCryptPasswordEncoder().encode(param.getMoneyPwd())); }
UserAccount newUserAccount = param.convertToPo(); if (setting.getInviteRegisterEnabled()) {
RegisterSetting setting = registerSettingRepo.findTopByOrderByLatelyUpdateTime(); InviteCode inviteCode = inviteCodeRepo
if (!setting.getRegisterEnabled()) { .findTopByCodeAndPeriodOfValidityGreaterThanEqual(param.getInviteCode(), new Date());
throw new BizException(BizError.未开放注册功能); if (inviteCode == null) {
} throw new BizException(BizError.邀请码不存在或已失效);
if (setting.getInviteRegisterEnabled()) { }
InviteCode inviteCode = inviteCodeRepo newUserAccount.updateInviteInfo(inviteCode);
.findTopByCodeAndPeriodOfValidityGreaterThanEqual(param.getInviteCode(), new Date()); } else {
if (inviteCode == null) { newUserAccount.setRebate(setting.getRegitserDefaultRebate());
throw new BizException(BizError.邀请码不存在或已失效); }
} userAccountRepo.save(newUserAccount);
newUserAccount.updateInviteInfo(inviteCode); }
} else {
newUserAccount.setRebate(setting.getRegitserDefaultRebate()); @Transactional(readOnly = true)
} public PageResult<AccountChangeLogVO> findAccountChangeLogByPage(AccountChangeLogQueryCondParam param) {
userAccountRepo.save(newUserAccount); Specification<AccountChangeLog> spec = new Specification<AccountChangeLog>() {
} /**
*
@Transactional(readOnly = true) */
public PageResult<AccountChangeLogVO> findAccountChangeLogByPage(AccountChangeLogQueryCondParam param) { private static final long serialVersionUID = 1L;
Specification<AccountChangeLog> spec = new Specification<AccountChangeLog>() {
/** public Predicate toPredicate(Root<AccountChangeLog> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
* List<Predicate> predicates = new ArrayList<Predicate>();
*/ if (param.getStartTime() != null) {
private static final long serialVersionUID = 1L; predicates.add(builder.greaterThanOrEqualTo(root.get("accountChangeTime").as(Date.class),
DateUtil.beginOfDay(param.getStartTime())));
public Predicate toPredicate(Root<AccountChangeLog> root, CriteriaQuery<?> query, CriteriaBuilder builder) { }
List<Predicate> predicates = new ArrayList<Predicate>(); if (param.getEndTime() != null) {
if (param.getStartTime() != null) { predicates.add(builder.lessThanOrEqualTo(root.get("accountChangeTime").as(Date.class),
predicates.add(builder.greaterThanOrEqualTo(root.get("accountChangeTime").as(Date.class), DateUtil.endOfDay(param.getEndTime())));
DateUtil.beginOfDay(param.getStartTime()))); }
} if (StrUtil.isNotEmpty(param.getAccountChangeTypeCode())) {
if (param.getEndTime() != null) { predicates.add(builder.equal(root.get("accountChangeTypeCode"), param.getAccountChangeTypeCode()));
predicates.add(builder.lessThanOrEqualTo(root.get("accountChangeTime").as(Date.class), }
DateUtil.endOfDay(param.getEndTime()))); if (StrUtil.isNotEmpty(param.getUserAccountId())) {
} predicates.add(builder.equal(root.get("userAccountId"), param.getUserAccountId()));
if (StrUtil.isNotEmpty(param.getAccountChangeTypeCode())) { }
predicates.add(builder.equal(root.get("accountChangeTypeCode"), param.getAccountChangeTypeCode()));
} if (StrUtil.isNotEmpty(param.getUserName())) {
if (StrUtil.isNotEmpty(param.getUserAccountId())) { Join<UserAccount, AccountChangeLog> join = root.join("userAccount", JoinType.LEFT);
predicates.add(builder.equal(root.get("userAccountId"), param.getUserAccountId())); predicates.add(builder.equal(join.get("userName"), param.getUserName()));
} //predicates.add(builder.equal(root.get("userName"), param.getUserName()));
}
if (StrUtil.isNotEmpty(param.getUserName())) {
Join<UserAccount, AccountChangeLog> join = root.join("userAccount", JoinType.LEFT); return predicates.size() > 0 ? builder.and(predicates.toArray(new Predicate[predicates.size()])) : null;
predicates.add(builder.equal(join.get("userName"), param.getUserName())); }
//predicates.add(builder.equal(root.get("userName"), param.getUserName())); };
} Page<AccountChangeLog> result = accountChangeLogRepo.findAll(spec, PageRequest.of(param.getPageNum() - 1,
param.getPageSize(), Sort.by(Sort.Order.desc("accountChangeTime"), Sort.Order.desc("id"))));
return predicates.size() > 0 ? builder.and(predicates.toArray(new Predicate[predicates.size()])) : null; PageResult<AccountChangeLogVO> pageResult = new PageResult<>(AccountChangeLogVO.convertFor(result.getContent()),
} param.getPageNum(), param.getPageSize(), result.getTotalElements());
}; return pageResult;
Page<AccountChangeLog> result = accountChangeLogRepo.findAll(spec, PageRequest.of(param.getPageNum() - 1, }
param.getPageSize(), Sort.by(Sort.Order.desc("accountChangeTime"), Sort.Order.desc("id"))));
PageResult<AccountChangeLogVO> pageResult = new PageResult<>(AccountChangeLogVO.convertFor(result.getContent()), @Transactional
param.getPageNum(), param.getPageSize(), result.getTotalElements()); public void delUserAccount(@NotBlank String userAccountId) {
return pageResult; userAccountRepo.deleteById(userAccountId);
} }
@Transactional @ParamValid
public void delUserAccount(@NotBlank String userAccountId) { @Transactional
userAccountRepo.deleteById(userAccountId); public void adjustCashDeposit(AdjustCashDepositParam param) {
} UserAccount userAccount = userAccountRepo.getOne(param.getUserAccountId());
if (Constant.账变日志类型_手工增保证金.equals(param.getAccountChangeTypeCode())) {
@ParamValid Double cashDeposit = NumberUtil.round(userAccount.getCashDeposit() + param.getAccountChangeAmount(), 4)
@Transactional .doubleValue();
public void adjustCashDeposit(AdjustCashDepositParam param) { userAccount.setCashDeposit(cashDeposit);
UserAccount userAccount = userAccountRepo.getOne(param.getUserAccountId()); userAccountRepo.save(userAccount);
if (Constant.账变日志类型_手工增保证金.equals(param.getAccountChangeTypeCode())) { accountChangeLogRepo.save(
Double cashDeposit = NumberUtil.round(userAccount.getCashDeposit() + param.getAccountChangeAmount(), 4) AccountChangeLog.buildWithHandworkAdjustCashDeposit(userAccount, param.getAccountChangeAmount()));
.doubleValue(); } else if (Constant.账变日志类型_手工减保证金.equals(param.getAccountChangeTypeCode())) {
userAccount.setCashDeposit(cashDeposit); Double cashDeposit = NumberUtil.round(userAccount.getCashDeposit() - param.getAccountChangeAmount(), 4)
userAccountRepo.save(userAccount); .doubleValue();
accountChangeLogRepo.save( if (cashDeposit < 0) {
AccountChangeLog.buildWithHandworkAdjustCashDeposit(userAccount, param.getAccountChangeAmount())); throw new BizException(BizError.保证金不足无法手工减保证金);
} else if (Constant.账变日志类型_手工减保证金.equals(param.getAccountChangeTypeCode())) { }
Double cashDeposit = NumberUtil.round(userAccount.getCashDeposit() - param.getAccountChangeAmount(), 4) userAccount.setCashDeposit(cashDeposit);
.doubleValue(); userAccountRepo.save(userAccount);
if (cashDeposit < 0) { accountChangeLogRepo.save(
throw new BizException(BizError.保证金不足无法手工减保证金); AccountChangeLog.buildWithHandworkAdjustCashDeposit(userAccount, -param.getAccountChangeAmount()));
} }
userAccount.setCashDeposit(cashDeposit); }
userAccountRepo.save(userAccount);
accountChangeLogRepo.save( @ParamValid
AccountChangeLog.buildWithHandworkAdjustCashDeposit(userAccount, -param.getAccountChangeAmount())); @Transactional(readOnly = true)
} public PageResult<UserAccountDetailsInfoVO> findLowerLevelAccountDetailsInfoByPage(
} LowerLevelAccountQueryCondParam param) {
UserAccount currentAccount = userAccountRepo.getOne(param.getCurrentAccountId());
@ParamValid UserAccount lowerLevelAccount = currentAccount;
@Transactional(readOnly = true) if (StrUtil.isNotBlank(param.getUserName())) {
public PageResult<UserAccountDetailsInfoVO> findLowerLevelAccountDetailsInfoByPage( lowerLevelAccount = userAccountRepo.findByUserName(param.getUserName());
LowerLevelAccountQueryCondParam param) { if (lowerLevelAccount == null) {
UserAccount currentAccount = userAccountRepo.getOne(param.getCurrentAccountId()); throw new BizException(BizError.用户名不存在);
UserAccount lowerLevelAccount = currentAccount; }
if (StrUtil.isNotBlank(param.getUserName())) { // 说明该用户名对应的账号不是当前账号的下级账号
lowerLevelAccount = userAccountRepo.findByUserName(param.getUserName()); if (!lowerLevelAccount.getAccountLevelPath().startsWith(currentAccount.getAccountLevelPath())) {
if (lowerLevelAccount == null) { throw new BizException(BizError.不是上级账号无权查看该账号及下级的账号信息);
throw new BizException(BizError.用户名不存在); }
} }
// 说明该用户名对应的账号不是当前账号的下级账号 String lowerLevelAccountId = lowerLevelAccount.getId();
if (!lowerLevelAccount.getAccountLevelPath().startsWith(currentAccount.getAccountLevelPath())) { String lowerLevelAccountLevelPath = lowerLevelAccount.getAccountLevelPath();
throw new BizException(BizError.不是上级账号无权查看该账号及下级的账号信息);
} Specification<UserAccount> spec = new Specification<UserAccount>() {
} /**
String lowerLevelAccountId = lowerLevelAccount.getId(); *
String lowerLevelAccountLevelPath = lowerLevelAccount.getAccountLevelPath(); */
private static final long serialVersionUID = 1L;
Specification<UserAccount> spec = new Specification<UserAccount>() {
/** public Predicate toPredicate(Root<UserAccount> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
* List<Predicate> predicates = new ArrayList<Predicate>();
*/ if (Constant.下级账号查询范围_指定账号及直接下级.equals(param.getQueryScope())) {
private static final long serialVersionUID = 1L; Predicate predicate1 = builder.equal(root.get("id"), lowerLevelAccountId);
Predicate predicate2 = builder.equal(root.get("inviterId"), lowerLevelAccountId);
public Predicate toPredicate(Root<UserAccount> root, CriteriaQuery<?> query, CriteriaBuilder builder) { predicates.add(builder.or(predicate1, predicate2));
List<Predicate> predicates = new ArrayList<Predicate>(); } else {
if (Constant.下级账号查询范围_指定账号及直接下级.equals(param.getQueryScope())) { predicates.add(builder.like(root.get("accountLevelPath"), lowerLevelAccountLevelPath + "%"));
Predicate predicate1 = builder.equal(root.get("id"), lowerLevelAccountId); }
Predicate predicate2 = builder.equal(root.get("inviterId"), lowerLevelAccountId); return predicates.size() > 0 ? builder.and(predicates.toArray(new Predicate[predicates.size()])) : null;
predicates.add(builder.or(predicate1, predicate2)); }
} else { };
predicates.add(builder.like(root.get("accountLevelPath"), lowerLevelAccountLevelPath + "%")); Page<UserAccount> result = userAccountRepo.findAll(spec,
} PageRequest.of(param.getPageNum() - 1, param.getPageSize(), Sort.by(Sort.Order.asc("registeredTime"))));
return predicates.size() > 0 ? builder.and(predicates.toArray(new Predicate[predicates.size()])) : null; PageResult<UserAccountDetailsInfoVO> pageResult = new PageResult<>(
} UserAccountDetailsInfoVO.convertFor(result.getContent()), param.getPageNum(), param.getPageSize(),
}; result.getTotalElements());
Page<UserAccount> result = userAccountRepo.findAll(spec, return pageResult;
PageRequest.of(param.getPageNum() - 1, param.getPageSize(), Sort.by(Sort.Order.asc("registeredTime")))); }
PageResult<UserAccountDetailsInfoVO> pageResult = new PageResult<>(
UserAccountDetailsInfoVO.convertFor(result.getContent()), param.getPageNum(), param.getPageSize(), @Transactional(readOnly = true)
result.getTotalElements()); public PageResult<AccountChangeLogVO> findLowerLevelAccountChangeLogByPage(
return pageResult; LowerLevelAccountChangeLogQueryCondParam param) {
} UserAccount currentAccount = userAccountRepo.getOne(param.getCurrentAccountId());
UserAccount lowerLevelAccount = currentAccount;
@Transactional(readOnly = true) if (StrUtil.isNotBlank(param.getUserName())) {
public PageResult<AccountChangeLogVO> findLowerLevelAccountChangeLogByPage( lowerLevelAccount = userAccountRepo.findByUserName(param.getUserName());
LowerLevelAccountChangeLogQueryCondParam param) { if (lowerLevelAccount == null) {
UserAccount currentAccount = userAccountRepo.getOne(param.getCurrentAccountId()); throw new BizException(BizError.用户名不存在);
UserAccount lowerLevelAccount = currentAccount; }
if (StrUtil.isNotBlank(param.getUserName())) { // 说明该用户名对应的账号不是当前账号的下级账号
lowerLevelAccount = userAccountRepo.findByUserName(param.getUserName()); if (!lowerLevelAccount.getAccountLevelPath().startsWith(currentAccount.getAccountLevelPath())) {
if (lowerLevelAccount == null) { throw new BizException(BizError.不是上级账号无权查看该账号及下级的帐变日志);
throw new BizException(BizError.用户名不存在); }
} }
// 说明该用户名对应的账号不是当前账号的下级账号 String lowerLevelAccountId = lowerLevelAccount.getId();
if (!lowerLevelAccount.getAccountLevelPath().startsWith(currentAccount.getAccountLevelPath())) { String lowerLevelAccountLevelPath = lowerLevelAccount.getAccountLevelPath();
throw new BizException(BizError.不是上级账号无权查看该账号及下级的帐变日志);
} Specification<AccountChangeLog> spec = new Specification<AccountChangeLog>() {
} /**
String lowerLevelAccountId = lowerLevelAccount.getId(); *
String lowerLevelAccountLevelPath = lowerLevelAccount.getAccountLevelPath(); */
private static final long serialVersionUID = 1L;
Specification<AccountChangeLog> spec = new Specification<AccountChangeLog>() {
/** public Predicate toPredicate(Root<AccountChangeLog> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
* List<Predicate> predicates = new ArrayList<Predicate>();
*/ if (StrUtil.isNotBlank(param.getUserName())) {
private static final long serialVersionUID = 1L; predicates.add(builder.equal(root.get("userAccountId"), lowerLevelAccountId));
} else {
public Predicate toPredicate(Root<AccountChangeLog> root, CriteriaQuery<?> query, CriteriaBuilder builder) { predicates.add(builder.like(root.join("userAccount", JoinType.INNER).get("accountLevelPath"),
List<Predicate> predicates = new ArrayList<Predicate>(); lowerLevelAccountLevelPath + "%"));
if (StrUtil.isNotBlank(param.getUserName())) { }
predicates.add(builder.equal(root.get("userAccountId"), lowerLevelAccountId)); if (param.getStartTime() != null) {
} else { predicates.add(builder.greaterThanOrEqualTo(root.get("accountChangeTime").as(Date.class),
predicates.add(builder.like(root.join("userAccount", JoinType.INNER).get("accountLevelPath"), DateUtil.beginOfDay(param.getStartTime())));
lowerLevelAccountLevelPath + "%")); }
} if (param.getEndTime() != null) {
if (param.getStartTime() != null) { predicates.add(builder.lessThanOrEqualTo(root.get("accountChangeTime").as(Date.class),
predicates.add(builder.greaterThanOrEqualTo(root.get("accountChangeTime").as(Date.class), DateUtil.endOfDay(param.getEndTime())));
DateUtil.beginOfDay(param.getStartTime()))); }
} if (StrUtil.isNotBlank(param.getAccountChangeTypeCode())) {
if (param.getEndTime() != null) { predicates.add(builder.equal(root.get("accountChangeTypeCode"), param.getAccountChangeTypeCode()));
predicates.add(builder.lessThanOrEqualTo(root.get("accountChangeTime").as(Date.class), }
DateUtil.endOfDay(param.getEndTime()))); return predicates.size() > 0 ? builder.and(predicates.toArray(new Predicate[predicates.size()])) : null;
} }
if (StrUtil.isNotBlank(param.getAccountChangeTypeCode())) { };
predicates.add(builder.equal(root.get("accountChangeTypeCode"), param.getAccountChangeTypeCode())); Page<AccountChangeLog> result = accountChangeLogRepo.findAll(spec, PageRequest.of(param.getPageNum() - 1,
} param.getPageSize(), Sort.by(Sort.Order.desc("accountChangeTime"))));
return predicates.size() > 0 ? builder.and(predicates.toArray(new Predicate[predicates.size()])) : null; PageResult<AccountChangeLogVO> pageResult = new PageResult<>(AccountChangeLogVO.convertFor(result.getContent()),
} param.getPageNum(), param.getPageSize(), result.getTotalElements());
}; return pageResult;
Page<AccountChangeLog> result = accountChangeLogRepo.findAll(spec, PageRequest.of(param.getPageNum() - 1, }
param.getPageSize(), Sort.by(Sort.Order.desc("accountChangeTime"))));
PageResult<AccountChangeLogVO> pageResult = new PageResult<>(AccountChangeLogVO.convertFor(result.getContent()),
param.getPageNum(), param.getPageSize(), result.getTotalElements());
return pageResult;
}
} }
...@@ -208,14 +208,14 @@ var gatheringCodeVM = new Vue({ ...@@ -208,14 +208,14 @@ var gatheringCodeVM = new Vue({
// return; // return;
// } // }
// } // }
if (editGatheringCode.payee == null || editGatheringCode.payee == '') { /*if (editGatheringCode.payee == null || editGatheringCode.payee == '') {
layer.alert('请选择收款人', { layer.alert('请选择收款人', {
title : '提示', title : '提示',
icon : 7, icon : 7,
time : 3000 time : 3000
}); });
return; return;
} }*/
if ($('.gathering-code-pic').fileinput('getPreview').content.length != 0 || editGatheringCode.gatheringChannelCode =='bankcard') { if ($('.gathering-code-pic').fileinput('getPreview').content.length != 0 || editGatheringCode.gatheringChannelCode =='bankcard') {
that.addOrUpdateGatheringCodeInner(); that.addOrUpdateGatheringCodeInner();
......
...@@ -140,14 +140,17 @@ ...@@ -140,14 +140,17 @@
</option> </option>
</select> </select>
</div> </div>
<!--<div class="form-group"> <div class="form-group">
<label> <span> 收款金额:</span> <label> <span> 单笔最大收款金额:</span>
<div class="custom-control custom-checkbox custom-control-inline" v-on:click="switchGatheringAmountMode"> <!--<div class="custom-control custom-checkbox custom-control-inline" v-on:click="switchGatheringAmountMode">
<input type="checkbox" id="fixedGatheringAmount" class="custom-control-input" v-model="editGatheringCode.fixedGatheringAmount"> <input type="checkbox" id="fixedGatheringAmount" class="custom-control-input" v-model="editGatheringCode.fixedGatheringAmount">
<label for="fixedGatheringAmount" class="custom-control-label">固定收款金额</label> <label for="fixedGatheringAmount" class="custom-control-label">固定收款金额</label>
</div> </div>-->
</label> <input type="number" class="form-control" v-model="editGatheringCode.gatheringAmount" :disabled="!editGatheringCode.fixedGatheringAmount"> </label>
</div>--> <!--<input type="number" class="form-control" v-model="editGatheringCode.gatheringAmount" :disabled="!editGatheringCode.fixedGatheringAmount">-->
<input type="number" class="form-control" v-model="editGatheringCode.gatheringAmount" >
</div>
<div class="form-group"> <div class="form-group">
<label>收款人:</label> <input type="text" class="form-control" <label>收款人:</label> <input type="text" class="form-control"
v-model="editGatheringCode.payee"> v-model="editGatheringCode.payee">
......
This source diff could not be displayed because it is too large. You can view the blob instead.
/*
MySQL Backup
Database: runscore
Backup Time: 2021-11-13 10:39:45
*/
SET FOREIGN_KEY_CHECKS=0;
DROP VIEW IF EXISTS `runscore`.`v_merchant_month_statistical`;
DROP VIEW IF EXISTS `runscore`.`v_merchant_today_statistical`;
DROP VIEW IF EXISTS `runscore`.`v_merchant_total_statistical`;
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`%` SQL SECURITY DEFINER VIEW `v_merchant_month_statistical` AS select `po`.`merchant_id` AS `merchant_id`,round(sum(`po`.`gathering_amount`),4) AS `gathering_amount`,count(1) AS `order_num`,round(sum((case when (`po`.`order_state` = '4') then `po`.`gathering_amount` else 0 end)),4) AS `trade_amount`,sum((case when (`po`.`order_state` = '4') then 1 else 0 end)) AS `paid_order_num` from (`merchant_order` `po` left join `merchant` `ua` on((`po`.`merchant_id` = `ua`.`id`))) where ((`po`.`received_account_id` is not null) and (`po`.`submit_time` >= str_to_date(date_format(curdate(),'%Y-%m-01 00:00:00'),'%Y-%m-%d %H:%i:%s')) and (`po`.`submit_time` < (str_to_date(date_format(curdate(),'%Y-%m-01 00:00:00'),'%Y-%m-%d %H:%i:%s') + interval 1 month))) group by `po`.`merchant_id`;
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`%` SQL SECURITY DEFINER VIEW `v_merchant_today_statistical` AS select `po`.`merchant_id` AS `merchant_id`,round(sum(`po`.`gathering_amount`),4) AS `gathering_amount`,count(1) AS `order_num`,round(sum((case when (`po`.`order_state` = '4') then `po`.`gathering_amount` else 0 end)),4) AS `trade_amount`,sum((case when (`po`.`order_state` = '4') then 1 else 0 end)) AS `paid_order_num` from (`merchant_order` `po` left join `merchant` `ua` on((`po`.`merchant_id` = `ua`.`id`))) where ((`po`.`received_account_id` is not null) and (`po`.`received_time` >= str_to_date(date_format(now(),'%Y-%m-%d'),'%Y-%m-%d %H:%i:%s')) and (`po`.`received_time` < (str_to_date(date_format(now(),'%Y-%m-%d'),'%Y-%m-%d %H:%i:%s') + interval 1 day))) group by `po`.`merchant_id`;
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`%` SQL SECURITY DEFINER VIEW `v_merchant_total_statistical` AS select `po`.`merchant_id` AS `merchant_id`,round(sum(`po`.`gathering_amount`),4) AS `gathering_amount`,count(1) AS `order_num`,round(sum((case when (`po`.`order_state` = '4') then `po`.`gathering_amount` else 0 end)),4) AS `trade_amount`,sum((case when (`po`.`order_state` = '4') then 1 else 0 end)) AS `paid_order_num` from (`merchant_order` `po` left join `merchant` `ua` on((`po`.`merchant_id` = `ua`.`id`))) where (`po`.`received_account_id` is not null) group by `po`.`merchant_id`;
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论