|
|
@@ -21,6 +21,8 @@ import com.uas.platform.b2c.trade.order.dao.PurchaseDetailDao;
|
|
|
import com.uas.platform.b2c.trade.order.model.Order;
|
|
|
import com.uas.platform.b2c.trade.order.model.Purchase;
|
|
|
import com.uas.platform.b2c.trade.order.model.PurchaseDetail;
|
|
|
+import com.uas.platform.b2c.trade.support.CodeType;
|
|
|
+import com.uas.platform.b2c.trade.support.ResultMap;
|
|
|
import com.uas.platform.core.exception.IllegalOperatorException;
|
|
|
import com.uas.platform.core.util.mq.MessageType;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
@@ -238,8 +240,12 @@ public class InstallmentServiceImpl implements InstallmentService{
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void deleteInstallment(Long purchaseId) {
|
|
|
- validatePurchase(purchaseId);
|
|
|
+ public ResultMap deleteInstallment(Long purchaseId) {
|
|
|
+ ResultMap resultMap = validatePurchase(purchaseId);// 验证采购订单
|
|
|
+ if (1 != resultMap.getCode()) {// 验证错误
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+
|
|
|
Purchase purchase = purchaseDao.findOne(purchaseId);
|
|
|
Order order = orderDao.findByOrderid(purchase.getOrderid());
|
|
|
|
|
|
@@ -254,6 +260,7 @@ public class InstallmentServiceImpl implements InstallmentService{
|
|
|
purchaseDao.save(purchase);
|
|
|
|
|
|
installmentDao.delete(installment.getId());
|
|
|
+ return resultMap;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -316,17 +323,27 @@ public class InstallmentServiceImpl implements InstallmentService{
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public String validationEnableInstallment(Long purchaseId) {
|
|
|
- validatePurchase(purchaseId);// 验证采购单、订单信息
|
|
|
- validateBankInfo(Type.SUP.value(), Status.ALLOW.value());// 验证银行账户信息
|
|
|
- validateInstallmentStore();// 验证是否设置分期权限
|
|
|
- return "success";
|
|
|
+ public ResultMap validationEnableInstallment(Long purchaseId) {
|
|
|
+ ResultMap resultMap = validatePurchase(purchaseId);// 验证采购单、订单信息 return error code 5 7 6
|
|
|
+ if (1 != resultMap.getCode()) {
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ resultMap = validateBankInfo(Type.SUP.value(), Status.ALLOW.value());// 验证银行账户信息 return error code 3
|
|
|
+ if (1 != resultMap.getCode()) {
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ resultMap = validateInstallmentStore();// 验证是否设置分期权限 return error code 13
|
|
|
+ return resultMap;
|
|
|
}
|
|
|
|
|
|
- void validateInstallmentStore() {
|
|
|
+ ResultMap validateInstallmentStore() {
|
|
|
InstallmentStore installmentStore = installmentStoreDao.findByEnuuAndEnable(SystemSession.getUser().getEnterprise().getUu(), (short) 1);
|
|
|
- if (installmentStore == null)
|
|
|
- throw new IllegalOperatorException("当前企业没有设置分期功能权限,如有需要请联系客服");
|
|
|
+ if (installmentStore == null) {
|
|
|
+ return new ResultMap(CodeType.NO_AUTHORITY.code(), "当前企业没有设置分期功能权限,如有需要请联系客服");
|
|
|
+ }
|
|
|
+ return ResultMap.success(null);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -334,32 +351,44 @@ public class InstallmentServiceImpl implements InstallmentService{
|
|
|
* @param type
|
|
|
* @param status
|
|
|
*/
|
|
|
- void validateBankInfo(Integer type, Integer status) {
|
|
|
+ ResultMap validateBankInfo(Integer type, Integer status) {
|
|
|
List<BankInfo> bankInfos = bankInfoService.getEnterpriseBankInfoContainsStatus(type, status);
|
|
|
- if (CollectionUtils.isEmpty(bankInfos))
|
|
|
- throw new IllegalOperatorException("当前企业没有设置收款账户,请在 结算中心--收款账户信息 管理您的收款账户信息");
|
|
|
+ if (CollectionUtils.isEmpty(bankInfos)) {
|
|
|
+ return new ResultMap(CodeType.NOT_COMPLETE_INFO.code(), "当前企业没有设置收款账户,请在 结算中心--收款账户信息 管理您的收款账户信息");
|
|
|
+ }
|
|
|
+ return ResultMap.success(null);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 验证采购单、订单信息
|
|
|
* @param purchaseId
|
|
|
*/
|
|
|
- void validatePurchase(Long purchaseId) {
|
|
|
- if (SystemSession.getUser().getEnterprise() == null)
|
|
|
- throw new IllegalOperatorException("当前账户为个人账户,请选择企业后再执行此操作");
|
|
|
+ ResultMap validatePurchase(Long purchaseId) {
|
|
|
+ if (SystemSession.getUser().getEnterprise() == null) {
|
|
|
+ return new ResultMap(CodeType.ERROR_STATE.code(), "当前账户为个人账户,请选择企业后再执行此操作");
|
|
|
+ }
|
|
|
|
|
|
Purchase purchase = purchaseDao.findOne(purchaseId);
|
|
|
- if (purchase == null)
|
|
|
- throw new IllegalOperatorException("订单不存在,请重新确认订单信息");
|
|
|
- if (!SystemSession.getUser().getEnterprise().getUu().equals(purchase.getSellerenuu()))
|
|
|
- throw new IllegalOperatorException("此订单不属于当前企业,请重新确认订单信息");
|
|
|
- if (Status.TOBECONFIRMED.value() != purchase.getStatus().intValue())
|
|
|
- throw new IllegalOperatorException("此订单状态不为待付款,不可修改分期信息");
|
|
|
+ if (purchase == null) {
|
|
|
+ return new ResultMap(CodeType.NOT_EXiST.code(), "订单不存在,请重新确认订单信息");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!SystemSession.getUser().getEnterprise().getUu().equals(purchase.getSellerenuu())) {
|
|
|
+ return new ResultMap(CodeType.NOT_PERMIT.code(), "此订单不属于当前企业,请重新确认订单信息");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Status.TOBECONFIRMED.value() != purchase.getStatus().intValue()) {
|
|
|
+ return new ResultMap(CodeType.ERROR_STATE.code(), "此订单状态不为待付款,不可修改分期信息");
|
|
|
+ }
|
|
|
|
|
|
Order order = orderDao.findByOrderid(purchase.getOrderid());
|
|
|
- if (order == null)
|
|
|
- throw new IllegalOperatorException("订单不存在,请重新确认订单信息");
|
|
|
- if (Status.TOBEPAID.value() != order.getStatus().intValue() && Status.TOBECONFIRMED.value() != order.getStatus().intValue())
|
|
|
- throw new IllegalOperatorException("此订单状态不为待付款,不可修改分期信息");
|
|
|
+ if (order == null) {
|
|
|
+ return new ResultMap(CodeType.NOT_EXiST.code(), "订单不存在,请重新确认订单信息");
|
|
|
+ }
|
|
|
+ if (Status.TOBEPAID.value() != order.getStatus().intValue() && Status.TOBECONFIRMED.value() != order.getStatus().intValue()) {
|
|
|
+ return new ResultMap(CodeType.ERROR_STATE.code(), "此订单状态不为待付款,不可修改分期信息");
|
|
|
+ }
|
|
|
+
|
|
|
+ return ResultMap.success(null);
|
|
|
}
|
|
|
}
|