|
|
@@ -99,15 +99,58 @@ class PurchaseController extends BaseController
|
|
|
util::fail('本店已休息,请选择其它门店');
|
|
|
}
|
|
|
|
|
|
- $sendTimeWant = isset($post['sendTimeWant']) && !empty($post['sendTimeWant']) ? $post['sendTimeWant'] : date("Y-m-d");
|
|
|
- $future = date("Y-m-d", strtotime('+2 day'));
|
|
|
if ($book == 1) {
|
|
|
+ $sendTimeWant = isset($post['sendTimeWant']) && !empty($post['sendTimeWant']) ? $post['sendTimeWant'] : date("Y-m-d");
|
|
|
+ $future = date("Y-m-d", strtotime('+2 day'));
|
|
|
if (strtotime($sendTimeWant) < strtotime($future)) {
|
|
|
util::fail('请选择未来二天或更后时间');
|
|
|
}
|
|
|
+ $nowTime = time();
|
|
|
+ if (strtotime($sendTimeWant) < $nowTime) {
|
|
|
+ util::fail('送花时间不能选择过去时间');
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- ProductClass::valid($productList, $ghsMainId);
|
|
|
+ $ids = array_unique(array_filter(array_column($productList, 'productId')));
|
|
|
+ $productInfoList = productClass::getByIds($ids, null, 'id');
|
|
|
+ if (!empty($productInfoList)) {
|
|
|
+ $presellData = [];
|
|
|
+ $nowTime = time();
|
|
|
+ $sendTimeWant = $post['sendTimeWant'];
|
|
|
+ if (strtotime($sendTimeWant) < $nowTime) {
|
|
|
+ util::fail('送花时间不能选择过去时间');
|
|
|
+ }
|
|
|
+ foreach ($productInfoList as $currentInfo) {
|
|
|
+ if (isset($currentInfo['mainId']) == false || $currentInfo['mainId'] != $ghsMainId) {
|
|
|
+ util::fail('只能选择同一家的商品哦');
|
|
|
+ }
|
|
|
+ $currentName = $currentInfo['name'] ?? '';
|
|
|
+ $presell = $currentInfo['presell'] ?? 0;
|
|
|
+ $presellData[] = $presell;
|
|
|
+ if ($presell == 1) {
|
|
|
+ if (isset($post['sendTimeWant']) == false || empty($post['sendTimeWant'])) {
|
|
|
+ util::fail('有预售花材,请选择送花日期');
|
|
|
+ }
|
|
|
+ $hasDateStr = $currentInfo['presellDateList'] ?? '';
|
|
|
+ $hasDate = json_decode($hasDateStr, true);
|
|
|
+ if (empty($hasDate)) {
|
|
|
+ util::fail('预售日期有问题,请提醒门店');
|
|
|
+ }
|
|
|
+ if (in_array($sendTimeWant, $hasDate) == false) {
|
|
|
+ util::fail('您填的送花时间不在预售范围,花材:' . $currentName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (count($productInfoList) != count($ids)) {
|
|
|
+ util::fail('存在无效商品');
|
|
|
+ }
|
|
|
+ $presellData = array_unique($presellData);
|
|
|
+ if (count($presellData) > 1) {
|
|
|
+ util::fail('预售和预售花材不能一起下单');
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ util::fail('花材不存在');
|
|
|
+ }
|
|
|
|
|
|
//供货商预订单最低公斤数要求和每公斤服务费
|
|
|
$ghsInfo['kiloFee'] = $ghsShopInfo->kiloFee ?? 0;
|