Bladeren bron

细节优化

萤火科技 1 jaar geleden
bovenliggende
commit
14b730f761
5 gewijzigde bestanden met toevoegingen van 28 en 4 verwijderingen
  1. 1 1
      app/api/model/Coupon.php
  2. 21 0
      app/common.php
  3. 1 1
      app/common/model/Goods.php
  4. 2 2
      app/common/model/GoodsSku.php
  5. 3 0
      数据库修改记录/dev.txt

+ 1 - 1
app/api/model/Coupon.php

@@ -62,7 +62,7 @@ class Coupon extends CouponModel
         // 指定优惠券ID集
         if (!empty($couponIds)) {
             $query->where('coupon_id', 'in', $couponIds);
-            $query->orderRaw('field(coupon_id, ' . implode(',', $couponIds) . ')');
+            $query->orderRaw('field(coupon_id, ' . \implode_int($couponIds) . ')');
         } else {
             $limit > 0 && $query->limit($limit);
             $query->order(['sort', 'create_time' => 'desc']);

+ 21 - 0
app/common.php

@@ -384,6 +384,27 @@ function filter_emoji($text)
     return preg_replace('/[\xf0-\xf7].{3}/', '', $text);
 }
 
+/**
+ * 过滤int类型的数组
+ * @param array $data
+ * @return array
+ */
+function filter_array_int(array $data): array
+{
+    return array_filter(array_map(fn($val) => (int)$val, $data));
+}
+
+/**
+ * 分割int类型的数组
+ * @param array $data
+ * @param string $separator
+ * @return string
+ */
+function implode_int(array $data, string $separator = ','): string
+{
+    return implode($separator, filter_array_int($data));
+}
+
 /**
  * 根据指定长度截取字符串
  * @param $str

+ 1 - 1
app/common/model/Goods.php

@@ -309,7 +309,7 @@ class Goods extends BaseModel
             ->with(['images.file'])
             ->where($filter)
             ->where('is_delete', '=', 0)
-            ->orderRaw('field(goods_id, ' . implode(',', $goodsIds) . ')')
+            ->orderRaw('field(goods_id, ' . \implode_int($goodsIds) . ')')
             ->select();
         // 整理列表数据并返回
         return $this->setGoodsListData($data);

+ 2 - 2
app/common/model/GoodsSku.php

@@ -230,7 +230,7 @@ class GoodsSku extends BaseModel
      */
     public static function getGoodsPrices(array $skuList): array
     {
-        $goodsPriceArr = helper::getArrayColumn($skuList, 'goods_price');
+        $goodsPriceArr = \array_filter(helper::getArrayColumn($skuList, 'goods_price'));
         return empty($goodsPriceArr) ? [0, 0] : [min($goodsPriceArr), max($goodsPriceArr)];
     }
 
@@ -241,7 +241,7 @@ class GoodsSku extends BaseModel
      */
     public static function getLinePrices(array $skuList): array
     {
-        $linePriceArr = helper::getArrayColumn($skuList, 'line_price');
+        $linePriceArr = \array_filter(helper::getArrayColumn($skuList, 'line_price'));
         return empty($linePriceArr) ? [0, 0] : [min($linePriceArr), max($linePriceArr)];
     }
 }

+ 3 - 0
数据库修改记录/dev.txt

@@ -5,6 +5,9 @@
 ALTER TABLE `yoshop_store`
 ADD COLUMN `remark` varchar(500) NOT NULL DEFAULT '' COMMENT '备注信息' AFTER `logo_image_id`;
 
+ALTER TABLE `yoshop_store`
+ADD COLUMN `custom_domain` varchar(100) NOT NULL DEFAULT '' COMMENT '自定义H5域名' AFTER `remark`;
+
 DELETE FROM `yoshop_store_menu` WHERE (`menu_id`='10075');
 DELETE FROM `yoshop_store_menu` WHERE (`menu_id`='10076');
 UPDATE `yoshop_store_menu` SET `sort`='120' WHERE (`menu_id`='10078');