v1.0.30 #40
+23
-2
@@ -1,8 +1,10 @@
|
|||||||
package com.imyeyu.api.modules.gao.service.implement;
|
package com.imyeyu.api.modules.gao.service.implement;
|
||||||
|
|
||||||
|
import com.imyeyu.api.bean.ModuleCode;
|
||||||
import com.imyeyu.api.config.dbsource.TimiServerDBConfig;
|
import com.imyeyu.api.config.dbsource.TimiServerDBConfig;
|
||||||
import com.imyeyu.api.modules.common.entity.Attachment;
|
import com.imyeyu.api.modules.common.entity.Attachment;
|
||||||
import com.imyeyu.api.modules.common.service.AttachmentService;
|
import com.imyeyu.api.modules.common.service.AttachmentService;
|
||||||
|
import com.imyeyu.api.modules.gao.bean.GaoRoleCode;
|
||||||
import com.imyeyu.api.modules.gao.entity.GaoCustomerPackage;
|
import com.imyeyu.api.modules.gao.entity.GaoCustomerPackage;
|
||||||
import com.imyeyu.api.modules.gao.entity.GaoCustomerPackageItem;
|
import com.imyeyu.api.modules.gao.entity.GaoCustomerPackageItem;
|
||||||
import com.imyeyu.api.modules.gao.entity.GaoPackageDelivery;
|
import com.imyeyu.api.modules.gao.entity.GaoPackageDelivery;
|
||||||
@@ -18,6 +20,7 @@ import com.imyeyu.api.modules.gao.vo.GaoPackageDeliveryPage;
|
|||||||
import com.imyeyu.api.modules.gao.vo.GaoPackageDeliveryRevokeRequest;
|
import com.imyeyu.api.modules.gao.vo.GaoPackageDeliveryRevokeRequest;
|
||||||
import com.imyeyu.api.modules.system.entity.Logger;
|
import com.imyeyu.api.modules.system.entity.Logger;
|
||||||
import com.imyeyu.api.modules.system.service.LoggerService;
|
import com.imyeyu.api.modules.system.service.LoggerService;
|
||||||
|
import com.imyeyu.api.modules.user.service.RoleChecker;
|
||||||
import com.imyeyu.api.modules.user.service.UserLoginService;
|
import com.imyeyu.api.modules.user.service.UserLoginService;
|
||||||
import com.imyeyu.java.TimiJava;
|
import com.imyeyu.java.TimiJava;
|
||||||
import com.imyeyu.java.bean.timi.TimiCode;
|
import com.imyeyu.java.bean.timi.TimiCode;
|
||||||
@@ -55,6 +58,7 @@ public class GaoPackageDeliveryServiceImplement extends AbstractEntityService<Ga
|
|||||||
private final GaoCustomerPackageService customerPackageService;
|
private final GaoCustomerPackageService customerPackageService;
|
||||||
private final AttachmentService attachmentService;
|
private final AttachmentService attachmentService;
|
||||||
private final GaoStoreScopeService storeScopeService;
|
private final GaoStoreScopeService storeScopeService;
|
||||||
|
private final RoleChecker roleChecker;
|
||||||
private final UserLoginService userLoginService;
|
private final UserLoginService userLoginService;
|
||||||
private final LoggerService loggerService;
|
private final LoggerService loggerService;
|
||||||
|
|
||||||
@@ -156,7 +160,7 @@ public class GaoPackageDeliveryServiceImplement extends AbstractEntityService<Ga
|
|||||||
}
|
}
|
||||||
TimiException.requiredTrue(hasAttachment(request.getAttachmentList()), "发放必须上传照片");
|
TimiException.requiredTrue(hasAttachment(request.getAttachmentList()), "发放必须上传照片");
|
||||||
TimiException.requiredTrue(packageEntity.getStatus() == GaoCustomerPackage.Status.ACTIVE, "当前套餐不可发放");
|
TimiException.requiredTrue(packageEntity.getStatus() == GaoCustomerPackage.Status.ACTIVE, "当前套餐不可发放");
|
||||||
TimiException.requiredTrue(packageEntity.getPaymentStatus() == GaoCustomerPackage.PaymentStatus.PAID, "套餐未付清,不能发放");
|
checkPaymentForDelivery(packageEntity);
|
||||||
List<GaoPackageDeliveryItem> requestItemList = validateRequestItems(request.getItemList());
|
List<GaoPackageDeliveryItem> requestItemList = validateRequestItems(request.getItemList());
|
||||||
Map<String, GaoCustomerPackageItem> packageItemMap = new HashMap<>();
|
Map<String, GaoCustomerPackageItem> packageItemMap = new HashMap<>();
|
||||||
for (GaoPackageDeliveryItem requestItem : requestItemList) {
|
for (GaoPackageDeliveryItem requestItem : requestItemList) {
|
||||||
@@ -213,7 +217,7 @@ public class GaoPackageDeliveryServiceImplement extends AbstractEntityService<Ga
|
|||||||
GaoCustomerPackage packageEntity = customerPackageService.getForUpdate(delivery.getCustomerPackageId());
|
GaoCustomerPackage packageEntity = customerPackageService.getForUpdate(delivery.getCustomerPackageId());
|
||||||
TimiException.required(packageEntity, "not found customer package");
|
TimiException.required(packageEntity, "not found customer package");
|
||||||
TimiException.requiredTrue(packageEntity.getStatus() == GaoCustomerPackage.Status.ACTIVE, "当前套餐不可核销发放");
|
TimiException.requiredTrue(packageEntity.getStatus() == GaoCustomerPackage.Status.ACTIVE, "当前套餐不可核销发放");
|
||||||
TimiException.requiredTrue(packageEntity.getPaymentStatus() == GaoCustomerPackage.PaymentStatus.PAID, "套餐未付清,不能核销发放");
|
checkPaymentForDelivery(packageEntity);
|
||||||
List<GaoPackageDeliveryItem> itemList = itemMapper.selectByDeliveryId(delivery.getId());
|
List<GaoPackageDeliveryItem> itemList = itemMapper.selectByDeliveryId(delivery.getId());
|
||||||
for (GaoPackageDeliveryItem deliveryItem : itemList) {
|
for (GaoPackageDeliveryItem deliveryItem : itemList) {
|
||||||
GaoCustomerPackageItem packageItem = customerPackageService.getItemForUpdate(deliveryItem.getCustomerPackageItemId());
|
GaoCustomerPackageItem packageItem = customerPackageService.getItemForUpdate(deliveryItem.getCustomerPackageItemId());
|
||||||
@@ -400,6 +404,19 @@ public class GaoPackageDeliveryServiceImplement extends AbstractEntityService<Ga
|
|||||||
return reason != null && !reason.trim().isEmpty();
|
return reason != null && !reason.trim().isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean canDeliver(GaoCustomerPackage packageEntity) {
|
||||||
|
return safeLong(packageEntity.getSaleAmount()) == 0 || 0 < safeLong(packageEntity.getPaidAmount());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkPaymentForDelivery(GaoCustomerPackage packageEntity) {
|
||||||
|
long saleAmount = safeLong(packageEntity.getSaleAmount());
|
||||||
|
long paidAmount = safeLong(packageEntity.getPaidAmount());
|
||||||
|
TimiException.requiredTrue(canDeliver(packageEntity), "套餐未有已核销收款,不能发放");
|
||||||
|
if (0 < paidAmount && paidAmount < saleAmount) {
|
||||||
|
roleChecker.checkAny(ModuleCode.GAO, GaoRoleCode.STORE_MANAGER.name());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean sameText(String left, String right) {
|
private boolean sameText(String left, String right) {
|
||||||
return left == null ? right == null : left.equals(right);
|
return left == null ? right == null : left.equals(right);
|
||||||
}
|
}
|
||||||
@@ -407,4 +424,8 @@ public class GaoPackageDeliveryServiceImplement extends AbstractEntityService<Ga
|
|||||||
private BigDecimal decimal(BigDecimal value) {
|
private BigDecimal decimal(BigDecimal value) {
|
||||||
return value == null ? ZERO : value;
|
return value == null ? ZERO : value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private long safeLong(Long value) {
|
||||||
|
return value == null ? 0L : value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user