宅男在线永久免费观看网直播,亚洲欧洲日产国码无码久久99,野花社区在线观看视频,亚洲人交乣女bbw,一本一本久久a久久精品综合不卡

全部
常見問題
產(chǎn)品動(dòng)態(tài)
精選推薦

商品采集參數(shù)未保存問題

管理 管理 編輯 刪除

問題說明:商品采集參數(shù)未保存

修改文件:app\services\product\product\StoreProductServices

修改方法:save()

public function save(int $id, array $data, int $type = 0, int $relation_id = 0)
    {
        if (count($data['cate_id']) < 1) throw new AdminException('請(qǐng)選擇商品分類');
        if ($type == 1 && $relation_id) {
			/** @var SystemStoreServices $storeServices */
			$storeServices = app()->make(SystemStoreServices::class);
			$storeInfo = $storeServices->getStoreInfo($relation_id);
			//有自建商品分類權(quán)限門店
            if ($storeInfo['product_category_status'] && isset($data['store_cate_id']) && count($data['store_cate_id']) < 1) {
				throw new AdminException('請(qǐng)選擇門店商品分類');
			}
        }
        if (!$data['store_name']) throw new AdminException('請(qǐng)輸入商品名稱');
        if (count($data['slider_image']) < 1) throw new AdminException('請(qǐng)上傳商品輪播圖');
        if ($data['product_type'] == 0 && isset($data['delivery_type']) && count($data['delivery_type']) < 1) throw new AdminException('請(qǐng)選擇商品配送方式');
        if (in_array($data['product_type'], [1, 2, 3, 4])) {//除普通商品外,都免運(yùn)費(fèi)
            $data['freight'] = 1;
            $data['temp_id'] = 0;
            $data['postage'] = 0;
        } else {
            if ($data['freight'] == 1) {
                $data['temp_id'] = 0;
                $data['postage'] = 0;
            } elseif ($data['freight'] == 2) {
                $data['temp_id'] = 0;
            } elseif ($data['freight'] == 3) {
                $data['postage'] = 0;
            }
            if ($data['freight'] == 2 && !$data['postage']) {
                throw new AdminException('請(qǐng)?jiān)O(shè)置運(yùn)費(fèi)金額');
            }
            if ($data['freight'] == 3 && !$data['temp_id']) {
                throw new AdminException('請(qǐng)選擇運(yùn)費(fèi)模版');
            }
        }
		////供應(yīng)商商品僅平臺(tái)
		if (isset($data['type']) && $data['type'] == 2) {
			$data['delivery_type'] = [1];
			$data['applicable_type'] = 0;
		}
        // 開啟ERP后商品編碼驗(yàn)證
        $isOpen = sys_config('erp_open');
        if ($isOpen && $data['product_type'] == 0 && empty($data['code'])) {
            throw new AdminException('請(qǐng)輸入商品編碼');
        }
        $detail = $data['attrs'];
        $attr = $data['items'];
        $coupon_ids = $data['coupon_ids'];

        //關(guān)聯(lián)補(bǔ)充信息
        $relationData = [];
        $relationData['cate_id'] = $data['cate_id'] ?? [];
        if (isset($data['store_cate_id'])) {
            $relationData['store_cate_id'] = $data['store_cate_id'] ?? [];
        }
        $relationData['brand_id'] = $data['brand_id'] ?? [];
        $relationData['store_label_id'] = $data['store_label_id'] ?? [];
        $relationData['label_id'] = $data['label_id'] ?? [];
        $relationData['ensure_id'] = $data['ensure_id'] ?? [];
        $relationData['specs_id'] = $data['specs_id'] ?? [];
        $relationData['coupon_ids'] = $data['coupon_ids'] ?? [];

        $description = $data['description'];
        $data['type'] = $type;
        $data['relation_id'] = $relation_id;
        $supplier_id = $data['supplier_id'] ?? 0;
        if ($supplier_id) {
            $data['type'] = 2;
            $data['relation_id'] = $supplier_id;
        }
        if ($data['type'] == 0) {//平臺(tái)商品不需要審核
            $data['is_verify'] = 1;
        }
        $is_copy = $data['is_copy'];
        unset($data['supplier_id'], $data['is_copy']);
        //視頻
        if ($data['video_link'] && strpos($data['video_link'], 'http') === false) {
            $data['video_link'] = sys_config('site_url') . $data['video_link'];
        }
        //品牌
        $data['brand_com'] = $data['brand_id'] ? implode(',', $data['brand_id']) : '';
        $data['brand_id'] = $data['brand_id'] ? end($data['brand_id']) : 0;
        $data['is_vip'] = $type == 0 && in_array(0, $data['is_sub']) ? 1 : 0;
        $data['is_sub'] = in_array(1, $data['is_sub']) ? 1 : 0;
        $data['product_type'] = intval($data['product_type']);
        $data['is_vip_product'] = intval($type == 0 && $data['is_vip_product']);
        if($type == 0) {
            $data['is_presale_product'] = intval($data['is_presale_product']);
            $data['presale_start_time'] = $data['is_presale_product'] ? strtotime($data['presale_time'][0]) : 0;
            $data['presale_end_time'] = $data['is_presale_product'] ? strtotime($data['presale_time'][1]) : 0;
            if ($data['presale_start_time'] && $data['presale_start_time'] < time()) {
                throw new AdminException('預(yù)售開始時(shí)間不能小于當(dāng)前時(shí)間');
            }
            if ($data['presale_end_time'] && $data['presale_end_time'] < time()) {
                throw new AdminException('預(yù)售結(jié)束時(shí)間不能小于當(dāng)前時(shí)間');
            }
        }

        $data['auto_on_time'] = $data['auto_on_time'] ? strtotime($data['auto_on_time']) : 0;
        $data['auto_off_time'] = $data['auto_off_time'] ? strtotime($data['auto_off_time']) : 0;
        if ($data['auto_on_time']) {
            $data['is_show'] = 0;
        }
        $data['is_limit'] = intval($data['is_limit']);
        if (!$data['is_limit']) {
            $data['limit_type'] = 0;
            $data['limit_num'] = 0;
        } else {
            if (!in_array($data['limit_type'], [1, 2])) throw new AdminException('請(qǐng)選擇限購類型');
            if ($data['limit_num'] <= 0) throw new AdminException('限購數(shù)量不能小于1');
        }
        $data['custom_form'] = json_encode($data['custom_form']);
        $storeLabelId = $data['store_label_id'];
        if ($data['store_label_id']) {
            $data['store_label_id'] = is_array($data['store_label_id']) ? implode(',', $data['store_label_id']) : $data['store_label_id'];
        } else {
            $data['store_label_id'] = '';
        }
        if ($data['ensure_id']) {
            $data['ensure_id'] = is_array($data['ensure_id']) ? implode(',', $data['ensure_id']) : $data['ensure_id'];
        } else {
            $data['ensure_id'] = '';
        }
        if (!$data['specs_id'] && !$data['specs']) {
            $data['specs'] = '';
        }
        if ($data['specs']) {
            $specs = [];
            if (is_array($data['specs'])) {
                /** @var StoreProductSpecsServices $storeProductSpecsServices */
                $storeProductSpecsServices = app()->make(StoreProductSpecsServices::class);
                foreach ($data['specs'] as $item) {
                    $specs[] = $storeProductSpecsServices->checkSpecsData($item);
                }
                $data['specs'] = json_encode($specs);
            }
        } else {
            $data['specs'] = '';
        }
        if ($data['spec_type'] == 0) {
            $attr = [
                [
                    'value' => '規(guī)格',
                    'detailValue' => '',
                    'attrHidden' => '',
                    'detail' => ['默認(rèn)']
                ]
            ];
            $detail[0]['value1'] = '默認(rèn)';
            $detail[0]['detail'] = ['規(guī)格' => '默認(rèn)'];
        }
        foreach ($detail as &$item) {
            if ($isOpen && $data['product_type'] == 0 && (!isset($item['code']) || !$item['code'])) {
                throw new AdminException('請(qǐng)輸入【' . ($item['values'] ?? '默認(rèn)') . '】商品編碼');
            }
            if ($type == 2 && !$item['settle_price']) {
                throw new AdminException('請(qǐng)輸入結(jié)算價(jià)');
            }
            if (isset($item['price']) && $item['price'] > 0 && $type == 2 && $item['settle_price'] > $item['price']) {
                throw new AdminException('結(jié)算價(jià)不能超過商品售價(jià)');
            }
            $item['product_type'] = $data['product_type'];
            if ($data['is_sub'] == 0) {
                $item['brokerage'] = 0;
                $item['brokerage_two'] = 0;
            }
            if (!isset($item['price'])) $item['price'] = 0;
            if (!isset($item['ot_price'])) $item['ot_price'] = 0;
            if (!isset($item['settle_price'])) $item['settle_price'] = 0;
            if (($item['brokerage'] + $item['brokerage_two']) > $item['price']) {
                throw new AdminException('一二級(jí)返傭相加不能大于商品售價(jià)');
            }
            //驗(yàn)證次卡商品數(shù)據(jù)
            if ($data['product_type'] == 4) {
                if (!isset($item['write_times']) || !$item['write_times']) {
                    throw new AdminException('請(qǐng)輸入核銷次數(shù)');
                }
                if (!isset($item['write_valid'])) {
                    throw new AdminException('請(qǐng)選擇核銷時(shí)效類型');
                }
                switch ($item['write_valid']) {
                    case 1://永久
                        $item['days'] = 0;
                        $item['section_time'] = [0, 0];
                        break;
                    case 2://購買后n天
                        $item['section_time'] = [0, 0];
                        if (!isset($item['days']) || !$item['days']) {
                            throw new AdminException('填寫時(shí)效天數(shù)');
                        }
                        break;
                    case 3://固定時(shí)間
                        $item['days'] = 0;
                        if (!isset($item['section_time']) || !$item['section_time'] || !is_array($item['section_time']) || count($item['section_time']) != 2) {
                            throw new AdminException('請(qǐng)選擇固定有效時(shí)間段或時(shí)間格式錯(cuò)誤');
                        }
                        [$start, $end] = $item['section_time'];
                        $data['start_time'] = $start ? strtotime($start) : 0;
                        $data['end_time'] = $end ? strtotime($end) : 0;
                        if ($data['start_time'] && $data['end_time'] && $data['end_time'] <= $data['start_time']) {
                            throw new AdminException('請(qǐng)重新選擇:結(jié)束時(shí)間必須大于開始時(shí)間');
                        }
                        break;
                    default:
                        throw new AdminException('請(qǐng)選擇核銷時(shí)效類型');
                        break;
                }
            }
        }
        foreach ($data['activity'] as $k => $v) {
            if ($v == '秒殺') {
                $data['activity'][$k] = 1;
            } elseif ($v == '砍價(jià)') {
                $data['activity'][$k] = 2;
            } elseif ($v == '拼團(tuán)') {
                $data['activity'][$k] = 3;
            } else {
                $data['activity'][$k] = 0;
            }
        }
        $data['activity'] = implode(',', $data['activity']);
        $data['recommend_list'] = count($data['recommend_list']) ? implode(',', $data['recommend_list']) : '';
        $data['price'] = min(array_column($detail, 'price'));
        $data['settle_price'] = min(array_column($detail, 'settle_price'));
        $data['ot_price'] = min(array_column($detail, 'ot_price'));
        $data['cost'] = min(array_column($detail, 'cost'));
        if (!$data['cost']) {
            $data['cost'] = 0;
        }
        $data['cate_id'] = implode(',', $data['cate_id']);
        if (isset($data['store_cate_id'])) {
            $data['store_cate_id'] = implode(',', $data['store_cate_id']);
        }
        $data['label_id'] = implode(',', $data['label_id']);
        $data['image'] = $data['slider_image'][0];//封面圖
        $slider_image = $data['slider_image'];
        $data['slider_image'] = json_encode($data['slider_image']);
        $data['stock'] = array_sum(array_column($detail, 'stock'));
        $stock = min(array_column($detail, 'stock'));
        //是否售罄
        $data['is_sold'] = $stock ? 0 : 1;

        unset($data['description'], $data['coupon_ids'], $data['items'], $data['attrs'], $data['recommend']);
        /** @var StoreDescriptionServices $storeDescriptionServices */
        $storeDescriptionServices = app()->make(StoreDescriptionServices::class);
        /** @var StoreProductAttrServices $storeProductAttrServices */
        $storeProductAttrServices = app()->make(StoreProductAttrServices::class);
        /** @var StoreProductCouponServices $storeProductCouponServices */
        $storeProductCouponServices = app()->make(StoreProductCouponServices::class);
        /** @var StoreDiscountsProductsServices $storeDiscountProduct */
        $storeDiscountProduct = app()->make(StoreDiscountsProductsServices::class);
        /** @var StoreProductVirtualServices $productVirtual */
        $productVirtual = app()->make(StoreProductVirtualServices::class);
        //同一鏈接不多次保存
        if (!$id && $data['soure_link']) {
            $productInfo = $this->dao->getOne(['soure_link' => $data['soure_link'], 'is_del' => 0], 'id');
            if ($productInfo) $id = (int)$productInfo['id'];
        }
        [$skuList, $id, $is_new, $data] = $this->transaction(function () use ($id, $data, $description, $storeDescriptionServices, $storeProductAttrServices, $storeProductCouponServices, $detail, $attr, $coupon_ids, $storeDiscountProduct, $productVirtual, $slider_image) {

            if ($id) {
                //上下架處理
                $this->setShow([$id], $data['is_show']);
                $oldInfo = $this->get($id)->toArray();
                if ($oldInfo['product_type'] != $data['product_type']) {
                    throw new AdminException('商品類型不能切換!');
                }
                //修改不改變商品來源
                if ($oldInfo['type']) {
                    $data['type'] = $oldInfo['type'];
                    $data['relation_id'] = $oldInfo['relation_id'];
                }
                unset($data['sales']);
                $res = $this->dao->update($id, $data);
                if (!$res) throw new AdminException('修改失敗');
                // 修改優(yōu)惠套餐商品的運(yùn)費(fèi)模版id
                $storeDiscountProduct->update(['product_id' => $id], ['temp_id' => $data['temp_id']]);
                if (!empty($coupon_ids)) {
                    $storeProductCouponServices->setCoupon($id, $coupon_ids);
                } else {
                    $storeProductCouponServices->delete(['product_id' => $id]);
                }
                if ($oldInfo['type'] == 1 && !$oldInfo['pid'] && $data['is_verify'] < 1) {
                    /** @var StoreCartServices $cartService */
                    $cartService = app()->make(StoreCartServices::class);
                    $cartService->batchUpdate([$id], ['status' => 0], 'product_id');
                }
                $is_new = 1;
            } else {
                //默認(rèn)評(píng)分
                $data['star'] = config('admin.product_default_star');
                $data['add_time'] = time();
                $data['code_path'] = '';
                $data['spu'] = $this->createSpu();
                $res = $this->dao->save($data);
                if (!$res) throw new AdminException('添加失敗');
                $id = (int)$res->id;
                if (!empty($coupon_ids)) $storeProductCouponServices->setCoupon($id, $coupon_ids);
                $is_new = 0;
            }
            //商品詳情
            $storeDescriptionServices->saveDescription($id, $description);

            $skuList = $storeProductAttrServices->validateProductAttr($attr, $detail, $id, 0, (int)$data['is_vip']);
            foreach ($skuList['valueGroup'] as &$item) {
                if (!isset($item['sum_stock']) || !$item['sum_stock']) $item['sum_stock'] = $item['stock'] ?? 0;
            }

            $proudctVipPrice = 0;
            $detailTemp = array_column($skuList['valueGroup'], 'vip_price');
            if ($detailTemp) {
                $proudctVipPrice = min($detailTemp);
            }
            $this->dao->update($id, ['vip_price' => $proudctVipPrice]);

            $valueGroup = $storeProductAttrServices->saveProductAttr($skuList, $id);
            if (!$valueGroup) throw new AdminException('添加失?。?);
            if ($data['product_type'] == 1) {
                $productVirtual->saveProductVirtual($id, $valueGroup);
            }
            return [$skuList, $id, $is_new, $data];
        });
        event('product.create', [$id, $data, $skuList, $is_new, $slider_image, $description, $is_copy, $relationData]);
    }


后臺(tái)商品詳情頁:

src/pages/product/productAdd/index.vue,找到這個(gè)文件,搜索“添加參數(shù)”,修改這段代碼。

642d4202411071026346410.jpg

src/pages/product/components/productDetails.vue,找到這個(gè)文件,搜索“添加參數(shù)”,修改這段代碼。

98185202411071027534038.png

后臺(tái)文件修改完成后需要重新打包,打包文檔: https://doc.crmeb.com/pro/crmebprov3_1/15816

請(qǐng)登錄后查看

輕煮時(shí)光 最后編輯于2024-11-07 10:28:02

快捷回復(fù)
回復(fù)
回復(fù)
回復(fù)({{post_count}}) {{!is_user ? '我的回復(fù)' :'全部回復(fù)'}}
排序 默認(rèn)正序 回復(fù)倒序 點(diǎn)贊倒序

{{item.user_info.nickname ? item.user_info.nickname : item.user_name}} LV.{{ item.user_info.bbs_level || item.bbs_level }}

作者 管理員 企業(yè)

{{item.floor}}# 同步到gitee 已同步到gitee {{item.is_suggest == 1? '取消推薦': '推薦'}}
{{item.is_suggest == 1? '取消推薦': '推薦'}}
沙發(fā) 板凳 地板 {{item.floor}}#
{{item.user_info.title || '暫無簡介'}}
附件

{{itemf.name}}

{{item.created_at}}  {{item.ip_address}}
打賞
已打賞¥{{item.reward_price}}
{{item.like_count}}
{{item.showReply ? '取消回復(fù)' : '回復(fù)'}}
刪除
回復(fù)
回復(fù)

{{itemc.user_info.nickname}}

{{itemc.user_name}}

回復(fù) {{itemc.comment_user_info.nickname}}

附件

{{itemf.name}}

{{itemc.created_at}}
打賞
已打賞¥{{itemc.reward_price}}
{{itemc.like_count}}
{{itemc.showReply ? '取消回復(fù)' : '回復(fù)'}}
刪除
回復(fù)
回復(fù)
查看更多
打賞
已打賞¥{{reward_price}}
1626
{{like_count}}
{{collect_count}}
添加回復(fù) ({{post_count}})

相關(guān)推薦

快速安全登錄

使用微信掃碼登錄
{{item.label}} 加精
{{item.label}} {{item.label}} 板塊推薦 常見問題 產(chǎn)品動(dòng)態(tài) 精選推薦 首頁頭條 首頁動(dòng)態(tài) 首頁推薦
取 消 確 定
回復(fù)
回復(fù)
問題:
問題自動(dòng)獲取的帖子內(nèi)容,不準(zhǔn)確時(shí)需要手動(dòng)修改. [獲取答案]
答案:
提交
bug 需求 取 消 確 定
打賞金額
當(dāng)前余額:¥{{rewardUserInfo.reward_price}}
{{item.price}}元
請(qǐng)輸入 0.1-{{reward_max_price}} 范圍內(nèi)的數(shù)值
打賞成功
¥{{price}}
完成 確認(rèn)打賞

微信登錄/注冊(cè)

切換手機(jī)號(hào)登錄

{{ bind_phone ? '綁定手機(jī)' : '手機(jī)登錄'}}

{{codeText}}
切換微信登錄/注冊(cè)
暫不綁定
CRMEB客服

CRMEB咨詢熱線 咨詢熱線

400-8888-794

微信掃碼咨詢

CRMEB開源商城下載 源碼下載 CRMEB幫助文檔 幫助文檔
返回頂部 返回頂部
CRMEB客服