|
|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
namespace mall\controllers;
|
|
|
|
|
|
+use biz\product\classes\ProductClass;
|
|
|
use bizHd\custom\classes\HdClass;
|
|
|
use bizHd\wx\classes\WxOpenClass;
|
|
|
use bizMall\custom\classes\CustomClass;
|
|
|
@@ -86,6 +87,51 @@ class OrderController extends BaseController
|
|
|
if (empty($productList)) {
|
|
|
util::fail('请选择商品');
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ $ids = array_unique(array_filter(array_column($productList, 'productId')));
|
|
|
+ $productInfoList = productClass::getByIds($ids, null, 'id');
|
|
|
+ if (!empty($productInfoList)) {
|
|
|
+ $presellData = [];
|
|
|
+ $nowTime = strtotime(date("Y-m-d"));
|
|
|
+ foreach ($productInfoList as $currentInfo) {
|
|
|
+ if (isset($currentInfo['mainId']) == false || $currentInfo['mainId'] != $this->mainId) {
|
|
|
+ util::fail('只能选择同一家的商品哦');
|
|
|
+ }
|
|
|
+ $currentName = $currentInfo['name'] ?? '';
|
|
|
+ $presell = $currentInfo['presell'] ?? 0;
|
|
|
+ $presellData[] = $presell;
|
|
|
+ if ($presell == 1) {
|
|
|
+ if (isset($post['reachDate']) == false || empty($post['reachDate'])) {
|
|
|
+ util::fail('预售花材,请选择配送日期');
|
|
|
+ }
|
|
|
+ $sendTimeWant = $post['reachDate'];
|
|
|
+ if (strtotime($sendTimeWant) < $nowTime) {
|
|
|
+ util::fail('不能选择过去时间');
|
|
|
+ }
|
|
|
+ $hasDateStr = $currentInfo['presellDate'] ?? [];
|
|
|
+ $hasDate = explode(',', trim($hasDateStr));
|
|
|
+ if (empty($hasDate)) {
|
|
|
+ util::fail('预售日期有问题,请提醒门店');
|
|
|
+ }
|
|
|
+ if (in_array(strtotime($sendTimeWant), $hasDate) == false) {
|
|
|
+ util::fail("{$currentName} 在{$sendTimeWant}没有预售");
|
|
|
+ }
|
|
|
+ $post['presell'] = 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (count($productInfoList) != count($ids)) {
|
|
|
+ util::fail('存在无效商品');
|
|
|
+ }
|
|
|
+ $presellData = array_unique($presellData);
|
|
|
+ if (count($presellData) > 1) {
|
|
|
+ util::fail('预售和非预售花材不能一起下单');
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ util::fail('花材不存在');
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
$connection = Yii::$app->db;
|
|
|
$transaction = $connection->beginTransaction();
|
|
|
try {
|
|
|
@@ -284,7 +330,7 @@ class OrderController extends BaseController
|
|
|
$sjName = $shop['merchantName'] ?? '';
|
|
|
$shopName = $shop['shopName'] ?? '';
|
|
|
$default = $shop['default'] ?? 0;
|
|
|
- $shop['showName'] = $default == 1 && $shopName=='首店' ? $sjName : $sjName . ' ' . $shopName;
|
|
|
+ $shop['showName'] = $default == 1 && $shopName == '首店' ? $sjName : $sjName . ' ' . $shopName;
|
|
|
|
|
|
$freight = ['first' => 5, 'add' => 2];
|
|
|
$mapKey = 'OFWBZ-2NTHP-EHNDD-LKWQY-GANM7-PXBJH';
|