|
@@ -226,6 +226,8 @@ import static com.fs.hisStore.constants.UserAppsLockConstant.LOCK_KEY_PAY;
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
|
|
|
|
|
|
|
+ private static final String STORE_ORDER_CREATE_STATUS_CHECK = "store_order_create_status_check";
|
|
|
|
|
+
|
|
|
Logger logger = LoggerFactory.getLogger(getClass());
|
|
Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private CompanyMoneyLogsMapper moneyLogsMapper;
|
|
private CompanyMoneyLogsMapper moneyLogsMapper;
|
|
@@ -1095,6 +1097,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional
|
|
@Transactional
|
|
|
public R createOrder(long userId, FsStoreOrderCreateParam param) {
|
|
public R createOrder(long userId, FsStoreOrderCreateParam param) {
|
|
|
|
|
+ boolean orderCreateStatusCheck = isOrderCreateStatusCheckEnabled();
|
|
|
|
|
|
|
|
FsUserCompanyUser fsUserCompanyUser = fsUserCompanyUserMapper.selectFsUserCompanyUserByUserId(userId);
|
|
FsUserCompanyUser fsUserCompanyUser = fsUserCompanyUserMapper.selectFsUserCompanyUserByUserId(userId);
|
|
|
if (ObjectUtil.isNotEmpty(fsUserCompanyUser) && param.getVideoId()!=null && param.getCompanyId() == null){
|
|
if (ObjectUtil.isNotEmpty(fsUserCompanyUser) && param.getVideoId()!=null && param.getCompanyId() == null){
|
|
@@ -1132,6 +1135,13 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
//获取购物车列表
|
|
//获取购物车列表
|
|
|
List<FsStoreCartQueryVO> carts = redisCache.getCacheObject("orderCarts:" + param.getOrderKey());
|
|
List<FsStoreCartQueryVO> carts = redisCache.getCacheObject("orderCarts:" + param.getOrderKey());
|
|
|
|
|
|
|
|
|
|
+ if (orderCreateStatusCheck && carts != null) {
|
|
|
|
|
+ R offShelfError = validateOrderProductOnShelf(carts);
|
|
|
|
|
+ if (offShelfError != null) {
|
|
|
|
|
+ return offShelfError;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 校验:购物车商品是否在活动期间,活动期间不允许走普通下单
|
|
// 校验:购物车商品是否在活动期间,活动期间不允许走普通下单
|
|
|
if (carts != null) {
|
|
if (carts != null) {
|
|
|
long now = System.currentTimeMillis();
|
|
long now = System.currentTimeMillis();
|
|
@@ -7900,4 +7910,43 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
return R.ok();
|
|
return R.ok();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private boolean isOrderCreateStatusCheckEnabled() {
|
|
|
|
|
+ List<SysDictData> dictList = sysDictTypeService.selectDictDataByType(STORE_ORDER_CREATE_STATUS_CHECK);
|
|
|
|
|
+ if (dictList == null || dictList.isEmpty()) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ return dictList.stream()
|
|
|
|
|
+ .filter(item -> "0".equals(item.getStatus()))
|
|
|
|
|
+ .anyMatch(item -> "1".equals(StringUtils.trimToEmpty(item.getDictValue())));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private R validateOrderProductOnShelf(List<FsStoreCartQueryVO> carts) {
|
|
|
|
|
+ List<String> offShelfNames = new ArrayList<>();
|
|
|
|
|
+ for (FsStoreCartQueryVO cart : carts) {
|
|
|
|
|
+ FsStoreProductScrm product = productService.selectFsStoreRedisProductById(cart.getProductId());
|
|
|
|
|
+ if (isProductOffShelf(product)) {
|
|
|
|
|
+ String productName = product != null && StrUtil.isNotBlank(product.getProductName())
|
|
|
|
|
+ ? product.getProductName() : cart.getProductName();
|
|
|
|
|
+ if (StrUtil.isNotBlank(productName)) {
|
|
|
|
|
+ offShelfNames.add(productName);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (offShelfNames.isEmpty()) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ String names = offShelfNames.stream().map(name -> "【" + name + "】").collect(Collectors.joining(""));
|
|
|
|
|
+ return R.error("商品已下架");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private boolean isProductOffShelf(FsStoreProductScrm product) {
|
|
|
|
|
+ if (product == null) {
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (product.getIsShow() == null || product.getIsShow() != 1) {
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ return !"1".equals(product.getIsAudit());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|