| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821 |
- <?php
- /**
- * Niushop商城系统 - 团队十年电商经验汇集巨献!
- * =========================================================
- * Copy riht 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
- * ----------------------------------------------
- * 官方网址: https://www.niushop.com
- * =========================================================
- */
- namespace app\shop\controller;
- use addon\form\model\Form;
- use addon\postertemplate\model\PosterTemplate as PosterTemplateModel;
- use app\model\express\Config as ExpressConfig;
- use app\model\express\ExpressTemplate as ExpressTemplateModel;
- use app\model\goods\Batch;
- use app\model\goods\Goods as GoodsModel;
- use app\model\goods\GoodsAttribute as GoodsAttributeModel;
- use app\model\goods\GoodsBrand as GoodsBrandModel;
- use app\model\goods\GoodsBrowse;
- use app\model\goods\GoodsCategory as GoodsCategoryModel;
- use app\model\goods\GoodsCollect;
- use app\model\goods\GoodsEvaluate as GoodsEvaluateModel;
- use app\model\goods\GoodsExport;
- use app\model\goods\GoodsImport;
- use app\model\goods\GoodsLabel as GoodsLabelModel;
- use app\model\goods\GoodsPoster;
- use app\model\goods\GoodsService as GoodsServiceModel;
- use app\model\store\Store as StoreModel;
- use app\model\web\Config;
- use app\model\web\Config as ConfigModel;
- /**
- * 实物商品
- * Class Goods
- * @package app\shop\controller
- */
- class Goods extends BaseShop
- {
- public function __construct()
- {
- $this->app_module = input('app_module', SHOP_MODULE);
- if ($this->app_module == 'store') {
- $this->initConstructInfo(); // 加载构造函数重要信息
- } else {
- parent::__construct();
- }
- }
- /**
- * 商品列表
- * @return mixed
- */
- public function lists()
- {
- $stockalarm = input('stockalarm', 0);
- $goods_model = new GoodsModel();
- if (request()->isAjax()) {
- $page_index = input('page', 1);
- $page_index = intval($page_index);
- $page_size = input('page_size', PAGE_LIST_ROWS);
- $search_text = input('search_text', "");
- $goods_state = input('goods_state', "");
- $start_sale = input('start_sale', 0);
- $end_sale = input('end_sale', 0);
- $start_price = input('start_price', 0);
- $end_price = input('end_price', 0);
- $sku_start_price = input('sku_start_price', 0);
- $sku_end_price = input('sku_end_price', 0);
- $goods_class = input('goods_class', "");
- $label_id = input('label_id', "");
- $brand_id = input('brand_id', "");
- $order = input('order', '');
- $sort = input('sort', 'asc');
- $sku_no = input('sku_no', '');
- $promotion_type = input('promotion_type', "");
- $category_id = input('category_id', "");
- $condition = [
- [ 'is_delete', '=', 0 ],
- [ 'site_id', '=', $this->site_id ],
- ];
- if (!empty($search_text)) {
- $condition[] = [ 'goods_name', 'like', '%' . $search_text . '%' ];
- }
- if (!empty($category_id)) {
- $condition[] = [ 'category_id', 'like', '%,' . $category_id . ',%' ];
- }
- if ($goods_class !== "") {
- $condition[] = [ 'goods_class', '=', $goods_class ];
- }
- if (!empty($label_id)) {
- $condition[] = [ 'label_id', '=', $label_id ];
- }
- if (!empty($brand_id)) {
- $condition[] = [ 'brand_id', '=', $brand_id ];
- }
- if (!empty($promotion_type)) {
- $condition[] = [ 'promotion_addon', 'like', "%{$promotion_type}%" ];
- }
- // 上架状态
- if ($goods_state !== '') {
- $condition[] = [ 'goods_state', '=', $goods_state ];
- }
- if (!empty($start_sale)) $condition[] = [ 'sale_num', '>=', $start_sale ];
- if (!empty($end_sale)) $condition[] = [ 'sale_num', '<=', $end_sale ];
- if (!empty($start_price)) $condition[] = [ 'price', '>=', $start_price ];
- if (!empty($end_price)) $condition[] = [ 'price', '<=', $end_price ];
- if (!empty($sku_start_price)) $condition[] = [ 'sku.price', '>=', $sku_start_price ];
- if (!empty($sku_end_price)) $condition[] = [ 'sku.price', '<=', $sku_end_price ];
- // 查询库存预警的商品
- if ($stockalarm) {
- $stock_alarm = $goods_model->getGoodsStockAlarm($this->site_id);
- if (!empty($stock_alarm[ 'data' ])) {
- $condition[] = [ 'goods_id', 'in', $stock_alarm[ 'data' ] ];
- } else {
- return success(0, '', [ 'page_count' => 1, 'count' => 0, 'list' => [] ]);
- }
- }
- if (!empty($sku_no)) {
- $goods_sku_list = $goods_model->getGoodsSkuList([ [ 'sku_no', 'like', '%' . $sku_no . '%' ] ], 'goods_id')[ 'data' ];
- $goods_id_arr = array_unique(array_column($goods_sku_list, 'goods_id'));
- $condition[] = [ 'goods_id', 'in', $goods_id_arr ];
- }
- $order_by = 'create_time desc';
- if ($order != '') {
- if ($order == 'sort') {
- $order_by = $order . ' ' . $sort . ',create_time desc';
- } else {
- $order_by = $order . ' ' . $sort;
- }
- }
- $field = 'goods_id,goods_name,site_id,site_name,goods_image,goods_state,price,goods_stock,goods_stock_alarm,create_time,sale_num,is_virtual,goods_class,goods_class_name,is_fenxiao,fenxiao_type,promotion_addon,sku_id,is_consume_discount,discount_config,discount_method,sort,label_id,is_delete,label_name,virtual_deliver_type';
- $res = $goods_model->getGoodsPageList($condition, $page_index, $page_size, $order_by, $field);
- $goods_promotion_type = event('GoodsPromotionType');
- if (!empty($res[ 'data' ][ 'list' ])) {
- foreach ($res[ 'data' ][ 'list' ] as $k => &$v) {
- if (!empty($v[ 'promotion_addon' ])) {
- $v[ 'promotion_addon' ] = json_decode($v[ 'promotion_addon' ], true);
- foreach ($v[ 'promotion_addon' ] as $ck => $cv) {
- foreach ($goods_promotion_type as $gk => $gv) {
- if ($gv[ 'type' ] == $ck) {
- $res[ 'data' ][ 'list' ][ $k ][ 'promotion_addon_list' ][] = $gv;
- break;
- }
- }
- }
- }
- }
- }
- return $res;
- } else {
- $goods_state = input('state', '');
- $this->assign('goods_state', $goods_state);
- //获取一级商品分类
- $goods_category_model = new GoodsCategoryModel();
- $condition = [
- [ 'pid', '=', 0 ],
- [ 'site_id', '=', $this->site_id ]
- ];
- $goods_category_list = $goods_category_model->getCategoryList($condition, 'category_id,category_name,level,commission_rate')[ 'data' ];
- $this->assign("goods_category_list", $goods_category_list);
- // 商品分组
- $goods_label_model = new GoodsLabelModel();
- $label_list = $goods_label_model->getLabelList([ [ 'site_id', '=', $this->site_id ] ], 'id,label_name', 'sort asc')[ 'data' ];
- $this->assign("label_list", $label_list);
- // 商品品牌
- $goods_brand_model = new GoodsBrandModel();
- $brand_list = $goods_brand_model->getBrandList([ [ 'site_id', '=', $this->site_id ] ], 'brand_id,brand_name', 'sort asc')[ 'data' ];
- $this->assign("brand_list", $brand_list);
- // 商品服务
- $goods_service_model = new GoodsServiceModel();
- $service_list = $goods_service_model->getServiceList([ [ 'site_id', '=', $this->site_id ] ], 'id,service_name,icon')[ 'data' ];
- $this->assign("service_list", $service_list);
- //获取运费模板
- $express_template_model = new ExpressTemplateModel();
- $express_template_list = $express_template_model->getExpressTemplateList([ [ 'site_id', "=", $this->site_id ] ], 'template_id,template_name', 'is_default desc')[ 'data' ];
- $this->assign("express_template_list", $express_template_list);
- //判断会员价插件
- $memberprice_is_exit = addon_is_exit('memberprice', $this->site_id);
- $this->assign('memberprice_is_exit', $memberprice_is_exit);
- // 获取商品排序
- $confif_model = new ConfigModel();
- $goods_sort = $confif_model->getGoodsSort($this->site_id);
- $this->assign("goods_sort", $goods_sort[ 'data' ][ 'value' ][ 'type' ]);
- // 营销活动
- $goods_promotion_type = event('GoodsPromotionType');
- $this->assign('promotion_type', $goods_promotion_type);
- $this->assign('virtualcard_exit', addon_is_exit('virtualcard', $this->site_id));
- $this->assign('stockalarm', $stockalarm);
- $this->assign('pc_domain', '');
- if (addon_is_exit('pc')) {
- $config_model = new Config();
- $config = $config_model->getPcDomainName($this->site_id);
- $this->assign('pc_domain', $config[ 'data' ][ 'value' ][ 'domain_name_pc' ] ?? '');
- }
- $this->assign('goods_class', array_column(event('GoodsClass'), null, 'goods_class'));
- $cardservice_is_exit = addon_is_exit('cardservice', $this->site_id);
- $this->assign('cardservice_is_exit', $cardservice_is_exit);
- $form_is_exit = addon_is_exit('form', $this->site_id);
- if ($form_is_exit) {
- $form_list = ( new Form() )->getFormList([ [ 'site_id', '=', $this->site_id ], [ 'form_type', '=', 'goods' ], [ 'is_use', '=', 1 ] ], 'id desc', 'id, form_name')[ 'data' ];
- $this->assign('form_list', $form_list);
- }
- $this->assign('form_is_exit', $form_is_exit);
- return $this->fetch("goods/lists");
- }
- }
- /**
- * 修改商品排序
- */
- public function modifySort()
- {
- if (request()->isAjax()) {
- $goods_model = new GoodsModel();
- $goods_id = input('goods_id', 0);
- $sort = input('sort', 0);
- return $goods_model->modifyGoodsSort($sort, $goods_id, $this->site_id);
- }
- }
- /**
- * 添加商品
- * @return mixed
- */
- public function addGoods()
- {
- if (request()->isAjax()) {
- $category_id = input("category_id", 0);// 分类id
- $category_json = json_encode($category_id);//分类字符串
- $category_id = ',' . implode(',', $category_id) . ',';
- $data = [
- 'goods_name' => input("goods_name", ""),// 商品名称,
- 'goods_attr_class' => input("goods_attr_class", ""),// 商品类型id,
- 'goods_attr_name' => input("goods_attr_name", ""),// 商品类型名称,
- 'is_limit' => input("is_limit", "0"),// 商品是否限购,
- 'limit_type' => input("limit_type", "1"),// 商品限购类型,
- 'site_id' => $this->site_id,
- 'category_id' => $category_id,
- 'category_json' => $category_json,
- 'goods_image' => input("goods_image", ""),// 商品主图路径
- 'goods_content' => input("goods_content", ""),// 商品详情
- 'goods_state' => input("goods_state", ""),// 商品状态(1.正常0下架)
- 'price' => input("price", 0),// 商品价格(取第一个sku)
- 'market_price' => input("market_price", 0),// 市场价格(取第一个sku)
- 'cost_price' => input("cost_price", 0),// 成本价(取第一个sku)
- 'sku_no' => input("sku_no", ""),// 商品sku编码
- 'weight' => input("weight", ""),// 重量
- 'volume' => input("volume", ""),// 体积
- 'goods_stock' => input("goods_stock", 0),// 商品库存(总和)
- 'goods_stock_alarm' => input("goods_stock_alarm", 0),// 库存预警
- 'is_free_shipping' => input("is_free_shipping", 1),// 是否免邮
- 'shipping_template' => input("shipping_template", 0),// 指定运费模板
- 'goods_spec_format' => input("goods_spec_format", ""),// 商品规格格式
- 'goods_attr_format' => input("goods_attr_format", ""),// 商品参数格式
- 'introduction' => input("introduction", ""),// 促销语
- 'keywords' => input("keywords", ""),// 关键词
- 'unit' => input("unit", ""),// 单位
- 'sort' => input("sort", 0),// 排序,
- 'video_url' => input("video_url", ""),// 视频
- 'goods_sku_data' => input("goods_sku_data", ""),// SKU商品数据
- 'goods_service_ids' => input("goods_service_ids", ''),// 商品服务id集合
- 'label_id' => input("label_id", ''),// 商品分组id
- 'brand_id' => input("brand_id", 0),//品牌id
- 'virtual_sale' => input("virtual_sale", 0),// 虚拟销量
- 'max_buy' => input("max_buy", 0),// 限购
- 'min_buy' => input("min_buy", 0),// 起售
- 'recommend_way' => input('recommend_way', 0), // 推荐方式,1:新品,2:精品,3;推荐
- 'timer_on' => strtotime(input('timer_on', 0)),//定时上架
- 'timer_off' => strtotime(input('timer_off', 0)),//定时下架
- 'is_consume_discount' => input('is_consume_discount', 0),//是否参与会员折扣
- 'qr_id' => input('qr_id', 0),//社群二维码id
- 'sale_show' => input('sale_show', 0),//
- 'stock_show' => input('stock_show', 0),//
- 'market_price_show' => input('market_price_show', 0),//
- 'barrage_show' => input('barrage_show', 0),//
- 'template_id' => input('template_id', 0),//商品海报id
- 'form_id' => input('form_id', 0),
- 'support_trade_type' => input('support_trade_type', ''),
- 'sale_channel' => input('sale_channel', 'all'),
- 'sale_store' => input('sale_store', 'all'),
- 'is_unify_price' => input('is_unify_price', '1'),
- ];
- $goods_model = new GoodsModel();
- $res = $goods_model->addGoods($data);
- return $res;
- } else {
- //获取一级商品分类
- $goods_category_model = new GoodsCategoryModel();
- $condition = [
- [ 'pid', '=', 0 ],
- [ 'site_id', '=', $this->site_id ]
- ];
- $goods_category_list = $goods_category_model->getCategoryList($condition, 'category_id,category_name,level,commission_rate')[ 'data' ];
- $this->assign("goods_category_list", $goods_category_list);
- //获取运费模板
- $express_template_model = new ExpressTemplateModel();
- $express_template_list = $express_template_model->getExpressTemplateList([ [ 'site_id', "=", $this->site_id ] ], 'template_id,template_name', 'is_default desc')[ 'data' ];
- $this->assign("express_template_list", $express_template_list);
- //获取商品类型
- $goods_attr_model = new GoodsAttributeModel();
- $attr_class_list = $goods_attr_model->getAttrClassList([ [ 'site_id', '=', $this->site_id ] ], 'class_id,class_name')[ 'data' ];
- $this->assign("attr_class_list", $attr_class_list);
- // 商品服务
- $goods_service_model = new GoodsServiceModel();
- $service_list = $goods_service_model->getServiceList([ [ 'site_id', '=', $this->site_id ] ], 'id,service_name,icon')[ 'data' ];
- $this->assign("service_list", $service_list);
- // 商品分组
- $goods_label_model = new GoodsLabelModel();
- $label_list = $goods_label_model->getLabelList([ [ 'site_id', '=', $this->site_id ] ], 'id,label_name', 'sort asc')[ 'data' ];
- $this->assign("label_list", $label_list);
- //商品默认排序值
- $config_model = new ConfigModel();
- $sort_config = $config_model->getGoodsSort($this->site_id, $this->app_module);
- $sort_config = $sort_config[ 'data' ][ 'value' ];
- $this->assign("sort_config", $sort_config);
- //获取品牌
- $goods_brand_model = new GoodsBrandModel();
- $brand_list = $goods_brand_model->getBrandList([ [ 'site_id', '=', $this->site_id ] ], "brand_id, brand_name")[ 'data' ];
- $this->assign("brand_list", $brand_list);
- //获取商品海报
- $poster_template_model = new PosterTemplateModel();
- $poster_list = $poster_template_model->getPosterTemplateList([ [ 'site_id', '=', $this->site_id ], [ 'template_status', '=', 1 ] ], 'template_id,poster_name,site_id');
- $this->assign('poster_list', $poster_list[ 'data' ]);
- $this->assign('virtualcard_exit', addon_is_exit('virtualcard', $this->site_id));
- $form_is_exit = addon_is_exit('form', $this->site_id);
- if ($form_is_exit) {
- $form_list = ( new Form() )->getFormList([ [ 'site_id', '=', $this->site_id ], [ 'form_type', '=', 'goods' ], [ 'is_use', '=', 1 ] ], 'id desc', 'id, form_name')[ 'data' ];
- $this->assign('form_list', $form_list);
- }
- $this->assign('form_is_exit', $form_is_exit);
- $express_type = ( new ExpressConfig() )->getEnabledExpressType($this->site_id);
- $this->assign('express_type', $express_type);
- $this->assign('all_goodsclass', event('GoodsClass'));
- $this->assign('goods_class', ( new GoodsModel() )->getGoodsClass());
- $this->assign('store_is_exit', addon_is_exit('store', $this->site_id));
- return $this->fetch("goods/add_goods");
- }
- }
- /**
- * 编辑商品
- * @return mixed
- */
- public function editGoods()
- {
- $goods_model = new GoodsModel();
- if (request()->isAjax()) {
- $category_id = input("category_id", 0);// 分类id
- $category_json = json_encode($category_id);//分类字符串
- $category_id = ',' . implode(',', $category_id) . ',';
- $data = [
- 'goods_id' => input("goods_id", 0),// 商品id
- 'goods_name' => input("goods_name", ""),// 商品名称,
- 'goods_attr_class' => input("goods_attr_class", ""),// 商品类型id,
- 'goods_attr_name' => input("goods_attr_name", ""),// 商品类型名称,
- 'is_limit' => input("is_limit", "0"),// 商品是否限购,
- 'limit_type' => input("limit_type", "1"),// 商品限购类型,
- 'site_id' => $this->site_id,
- 'category_id' => $category_id,
- 'category_json' => $category_json,
- 'goods_image' => input("goods_image", ""),// 商品主图路径
- 'goods_content' => input("goods_content", ""),// 商品详情
- 'goods_state' => input("goods_state", ""),// 商品状态(1.正常0下架)
- 'price' => input("price", 0),// 商品价格(取第一个sku)
- 'market_price' => input("market_price", 0),// 市场价格(取第一个sku)
- 'cost_price' => input("cost_price", 0),// 成本价(取第一个sku)
- 'sku_no' => input("sku_no", ""),// 商品sku编码
- 'weight' => input("weight", ""),// 重量
- 'volume' => input("volume", ""),// 体积
- 'goods_stock' => input("goods_stock", 0),// 商品库存(总和)
- 'goods_stock_alarm' => input("goods_stock_alarm", 0),// 库存预警
- 'is_free_shipping' => input("is_free_shipping", 1),// 是否免邮
- 'shipping_template' => input("shipping_template", 0),// 指定运费模板
- 'goods_spec_format' => input("goods_spec_format", ""),// 商品规格格式
- 'goods_attr_format' => input("goods_attr_format", ""),// 商品参数格式
- 'introduction' => input("introduction", ""),// 促销语
- 'keywords' => input("keywords", ""),// 关键词
- 'unit' => input("unit", ""),// 单位
- 'sort' => input("sort", 0),// 排序,
- 'video_url' => input("video_url", ""),// 视频
- 'goods_sku_data' => input("goods_sku_data", ""),// SKU商品数据
- 'goods_service_ids' => input("goods_service_ids", ''),// 商品服务id集合
- 'label_id' => input("label_id", ''),// 商品分组id
- 'brand_id' => input("brand_id", 0),//品牌id
- 'virtual_sale' => input("virtual_sale", 0),// 虚拟销量
- 'max_buy' => input("max_buy", 0),// 限购
- 'min_buy' => input("min_buy", 0),// 起售
- 'recommend_way' => input('recommend_way', 0), // 推荐方式,1:新品,2:精品,3;推荐
- 'timer_on' => strtotime(input('timer_on', 0)),//定时上架
- 'timer_off' => strtotime(input('timer_off', 0)),//定时下架
- 'spec_type_status' => input('spec_type_status', 0),
- 'is_consume_discount' => input('is_consume_discount', 0),//是否参与会员折扣
- 'qr_id' => input('qr_id', 0),//社群二维码id
- 'sale_show' => input('sale_show', 0),//
- 'stock_show' => input('stock_show', 0),//
- 'market_price_show' => input('market_price_show', 0),//
- 'barrage_show' => input('barrage_show', 0),//
- 'template_id' => input('template_id', 0),//商品海报id
- 'form_id' => input('form_id', 0),
- 'support_trade_type' => input('support_trade_type', ''),
- 'sale_channel' => input('sale_channel', 'all'),
- 'sale_store' => input('sale_store', 'all'),
- 'is_unify_price' => input('is_unify_price', '1'),
- ];
- $res = $goods_model->editGoods($data);
- return $res;
- } else {
- $goods_id = input("goods_id", 0);
- $goods_info = $goods_model->editGetGoodsInfo([ [ 'goods_id', '=', $goods_id ], [ 'site_id', '=', $this->site_id ] ])[ 'data' ];
- if (empty($goods_info)) $this->error('未获取到商品数据', addon_url('shop/goods/lists'));
- $goods_sku_list = $goods_model->getGoodsSkuList([ [ 'goods_id', '=', $goods_id ], [ 'site_id', '=', $this->site_id ] ], "sku_id,sku_name,sku_no,sku_spec_format,price,market_price,cost_price,stock,weight,volume,sku_image,sku_images,goods_spec_format,spec_name,stock_alarm,is_default", '')[ 'data' ];
- $goods_info[ 'sku_list' ] = $goods_sku_list;
- $this->assign("goods_info", $goods_info);
- //获取一级商品分类
- $goods_category_model = new GoodsCategoryModel();
- $condition = [
- [ 'pid', '=', 0 ],
- [ 'site_id', '=', $this->site_id ]
- ];
- $goods_category_list = $goods_category_model->getCategoryList($condition, 'category_id,category_name,level,commission_rate')[ 'data' ];
- $this->assign("goods_category_list", $goods_category_list);
- //获取运费模板
- $express_template_model = new ExpressTemplateModel();
- $express_template_list = $express_template_model->getExpressTemplateList([ [ 'site_id', "=", $this->site_id ] ], 'template_id,template_name', 'is_default desc')[ 'data' ];
- $this->assign("express_template_list", $express_template_list);
- //获取商品类型
- $goods_attr_model = new GoodsAttributeModel();
- $attr_class_list = $goods_attr_model->getAttrClassList([ [ 'site_id', '=', $this->site_id ] ], 'class_id,class_name')[ 'data' ];
- $this->assign("attr_class_list", $attr_class_list);
- //获取品牌
- $goods_brand_model = new GoodsBrandModel();
- $brand_list = $goods_brand_model->getBrandList([ [ 'site_id', '=', $this->site_id ] ], "brand_id, brand_name")[ 'data' ];
- $this->assign("brand_list", $brand_list);
- // 商品服务
- $goods_service_model = new GoodsServiceModel();
- $service_list = $goods_service_model->getServiceList([ [ 'site_id', '=', $this->site_id ] ], 'id,service_name,icon')[ 'data' ];
- $this->assign("service_list", $service_list);
- // 商品分组
- $goods_label_model = new GoodsLabelModel();
- $label_list = $goods_label_model->getLabelList([ [ 'site_id', '=', $this->site_id ] ], 'id,label_name', 'sort asc')[ 'data' ];
- $this->assign("label_list", $label_list);
- //获取商品海报
- $poster_template_model = new PosterTemplateModel();
- $poster_list = $poster_template_model->getPosterTemplateList([ [ 'site_id', '=', $this->site_id ], [ 'template_status', '=', 1 ], [ 'template_type', '=', 'goods' ] ], 'template_id,poster_name,site_id')[ 'data' ];
- $this->assign('poster_list', $poster_list);
- $form_is_exit = addon_is_exit('form', $this->site_id);
- if ($form_is_exit) {
- $form_list = ( new Form() )->getFormList([ [ 'site_id', '=', $this->site_id ], [ 'form_type', '=', 'goods' ], [ 'is_use', '=', 1 ] ], 'id desc', 'id, form_name')[ 'data' ];
- $this->assign('form_list', $form_list);
- }
- $this->assign('form_is_exit', $form_is_exit);
- $express_type = ( new ExpressConfig() )->getEnabledExpressType($this->site_id);
- $this->assign('express_type', $express_type);
- $store_is_exit = addon_is_exit('store', $this->site_id);
- if ($store_is_exit && $goods_info[ 'sale_store' ] != 'all') {
- $store_list = ( new StoreModel() )->getStoreList([ [ 'site_id', '=', $this->site_id ], [ 'store_id', 'in', $goods_info[ 'sale_store' ] ] ], 'store_id,store_name,status,address,full_address,is_frozen');
- $this->assign('store_list', $store_list[ 'data' ]);
- }
- $this->assign('store_is_exit', $store_is_exit);
- return $this->fetch("goods/edit_goods");
- }
- }
- /**
- * 删除商品
- */
- public function deleteGoods()
- {
- if (request()->isAjax()) {
- $goods_ids = input("goods_ids", 0);
- $goods_model = new GoodsModel();
- $res = $goods_model->modifyIsDelete($goods_ids, 1, $this->site_id);
- return $res;
- }
- }
- /**
- * 商品回收站
- */
- public function recycle()
- {
- if (request()->isAjax()) {
- $page_index = input('page', 1);
- $page_size = input('page_size', PAGE_LIST_ROWS);
- $search_keys = input('search_text', "");
- $goods_class = input('goods_class', '');
- $condition = [ [ 'is_delete', '=', 1 ], [ 'site_id', "=", $this->site_id ] ];
- if (!empty($search_keys)) {
- $condition[] = [ 'goods_name', 'like', '%' . $search_keys . '%' ];
- }
- $category_id = input('category_id', "");
- if (!empty($category_id)) {
- $condition[] = [ 'category_id', 'like', '%,' . $category_id . ',%' ];
- }
- if ($goods_class !== "") {
- $condition[] = [ 'goods_class', '=', $goods_class ];
- }
- $goods_model = new GoodsModel();
- $res = $goods_model->getGoodsPageList($condition, $page_index, $page_size);
- return $res;
- } else {
- //获取一级商品分类
- $goods_category_model = new GoodsCategoryModel();
- $condition = [
- [ 'pid', '=', 0 ],
- [ 'site_id', '=', $this->site_id ]
- ];
- $goods_category_list = $goods_category_model->getCategoryList($condition, 'category_id,category_name,level,commission_rate')[ 'data' ];
- $this->assign("goods_category_list", $goods_category_list);
- $this->assign('virtualcard_exit', addon_is_exit('virtualcard', $this->site_id));
- return $this->fetch("goods/recycle");
- }
- }
- /**
- * 商品回收站商品删除
- */
- public function deleteRecycleGoods()
- {
- if (request()->isAjax()) {
- $goods_ids = input("goods_ids", 0);
- $goods_model = new GoodsModel();
- $res = $goods_model->deleteRecycleGoods($goods_ids, $this->site_id);
- return $res;
- }
- }
- /**
- * 商品回收站商品恢复
- */
- public function recoveryRecycle()
- {
- if (request()->isAjax()) {
- $goods_ids = input("goods_ids", 0);
- $goods_model = new GoodsModel();
- $res = $goods_model->modifyIsDelete($goods_ids, 0, $this->site_id);
- return $res;
- }
- }
- /**
- * 商品下架
- */
- public function offGoods()
- {
- if (request()->isAjax()) {
- $goods_ids = input("goods_ids", 0);
- $goods_state = input("goods_state", 0);
- $goods_model = new GoodsModel();
- $res = $goods_model->modifyGoodsState($goods_ids, $goods_state, $this->site_id);
- return $res;
- }
- }
- /**
- * 商品上架
- */
- public function onGoods()
- {
- if (request()->isAjax()) {
- $goods_ids = input("goods_ids", 0);
- $goods_state = input("goods_state", 0);
- $goods_model = new GoodsModel();
- $res = $goods_model->modifyGoodsState($goods_ids, $goods_state, $this->site_id);
- return $res;
- }
- }
- /**
- * 编辑商品库存
- * @return array|\multitype
- */
- public function editGoodsStock()
- {
- if (request()->isAjax()) {
- $sku_list = input("sku_list", '');
- $model = new GoodsModel;
- $res = $model->editGoodsStock($sku_list, $this->site_id);
- return $res;
- }
- }
- /**
- * 获取商品分类列表
- * @return \multitype
- */
- public function getCategoryList()
- {
- if (request()->isAjax()) {
- $category_id = input("category_id", 0);
- $goods_category_model = new GoodsCategoryModel();
- $condition = [
- [ 'pid', '=', $category_id ],
- [ 'site_id', '=', $this->site_id ]
- ];
- $goods_category_list = $goods_category_model->getCategoryList($condition, 'category_id,category_name,level,commission_rate');
- return $goods_category_list;
- }
- }
- /**
- * 获取商品参数列表
- * @return \multitype
- */
- public function getAttributeList()
- {
- if (request()->isAjax()) {
- $goods_attr_model = new GoodsAttributeModel();
- $attr_class_id = input('attr_class_id', 0);// 商品类型id
- $attribute_list = $goods_attr_model->getAttributeList([ [ 'attr_class_id', '=', $attr_class_id ], [ 'is_spec', '=', 0 ], [ 'site_id', '=', $this->site_id ] ], 'attr_id,attr_name,attr_class_id,attr_class_name,attr_type,attr_value_format', 'sort asc');
- if (!empty($attribute_list[ 'data' ])) {
- foreach ($attribute_list[ 'data' ] as $k => $v) {
- if (!empty($v[ 'attr_value_format' ])) {
- $attribute_list[ 'data' ][ $k ][ 'attr_value_format' ] = json_decode($v[ 'attr_value_format' ], true);
- }
- }
- }
- return $attribute_list;
- }
- }
- /**
- * 获取SKU商品列表
- * @return array
- */
- public function getGoodsSkuList()
- {
- if (request()->isAjax()) {
- $goods_id = input("goods_id", 0);
- $goods_model = new GoodsModel();
- $res = $goods_model->getGoodsSkuList([ [ 'goods_id', '=', $goods_id ], [ 'site_id', '=', $this->site_id ] ], 'sku_id,sku_name,price,market_price,cost_price,stock,weight,volume,sku_no,sale_num,sku_image,spec_name,goods_id,stock_alarm,is_consume_discount,member_price,discount_method,discount_config,verify_num');
- if (!empty($res[ 'data' ])) {
- $res[ 'data' ] = $goods_model->getSkuMemberPrice($res[ 'data' ], $this->site_id);
- }
- return $res;
- }
- }
- /**
- * 商品选择组件
- * @return \multitype
- */
- public function goodsSelect()
- {
- if (request()->isAjax()) {
- $page = input('page', 1);
- $page_size = input('page_size', PAGE_LIST_ROWS);
- $search_text = input('search_text', '');
- $goods_id = input('goods_id', 0);
- $goods_ids = input('goods_ids', '');
- $is_virtual = input('is_virtual', '');// 是否虚拟类商品(0实物1.虚拟)
- $min_price = input('min_price', 0);
- $max_price = input('max_price', 0);
- $goods_class = input('goods_class', "");// 商品类型,实物、虚拟
- $category_id = input('category_id', "");// 商品分类id
- $promotion = input('promotion', '');//营销活动标识:pintuan、groupbuy、fenxiao、bargain
- $promotion_type = input('promotion_type', "");
- $label_id = input('label_id', "");
- $select_type = input('select_type', 'all');
- $usable_goods_class = input('usable_goods_class', '');
- $is_weigh = input('is_weigh', 0); // 是否支持称重
- if (!empty($promotion) && addon_is_exit($promotion)) {
- $promotion_name = input('promotion_name', '');// 营销活动
- $goods_list = event('GoodsListPromotion', [
- 'page' => $page,
- 'page_size' => $page_size,
- 'site_id' => $this->site_id,
- 'promotion' => $promotion,
- 'promotion_name' => $promotion_name,
- //筛选参数
- 'category_id' => $category_id,
- 'select_type' => $select_type,
- 'goods_ids' => $goods_ids,
- 'label_id' => $label_id,
- 'goods_class' => $goods_class,
- 'goods_name' => $search_text,
- ], true);
- } else {
- $goods_model = new GoodsModel();
- $condition = [
- [ 'is_delete', '=', 0 ],
- [ 'goods_state', '=', 1 ],
- [ 'goods_stock', '>', 0 ],
- [ 'site_id', '=', $this->site_id ]
- ];
- if ($is_weigh == 0) {
- $condition[] = [ 'goods_class', '<>', 6 ]; // 排除称重商品
- }
- if (!empty($search_text)) {
- $goods_sku_list = $goods_model->getGoodsSkuList([ [ 'sku_no', 'like', '%' . $search_text . '%' ] ], 'goods_id')[ 'data' ];
- $goods_id_arr = array_unique(array_column($goods_sku_list, 'goods_id'));
- if (!empty($goods_id_arr)) {
- $goods_ids = join(',', $goods_id_arr);
- $condition[] = [ '', 'exp', \think\facade\Db::raw("goods_name like '%{$search_text}%' or goods_id in ({$goods_ids})") ];
- } else {
- $condition[] = [ 'goods_name', 'like', "%{$search_text}%" ];
- }
- }
- if ($is_virtual !== "") {
- $condition[] = [ 'is_virtual', '=', $is_virtual ];
- }
- if (!empty($goods_id)) {
- $condition[] = [ 'goods_id', '=', $goods_id ];
- }
- if ($select_type == 'selected') {
- $condition[] = [ 'goods_id', 'in', $goods_ids ];
- }
- if (!empty($category_id)) {
- $condition[] = [ 'category_id', 'like', '%,' . $category_id . ',%' ];
- }
- if (!empty($promotion_type)) {
- $condition[] = [ 'promotion_addon', 'like', "%{$promotion_type}%" ];
- }
- if (!empty($label_id)) {
- $condition[] = [ 'label_id', '=', $label_id ];
- }
- if ($goods_class !== "") {
- $condition[] = [ 'goods_class', '=', $goods_class ];
- }
- if ($usable_goods_class != '') {
- $condition[] = [ 'goods_class', 'in', $usable_goods_class ];
- }
- if ($min_price != "" && $max_price != "") {
- $condition[] = [ 'price', 'between', [ $min_price, $max_price ] ];
- } elseif ($min_price != "") {
- $condition[] = [ 'price', '<=', $min_price ];
- } elseif ($max_price != "") {
- $condition[] = [ 'price', '>=', $max_price ];
- }
- $config_model = new ConfigModel();
- $sort_config = $config_model->getGoodsSort($this->site_id);
- $sort_config = $sort_config[ 'data' ][ 'value' ];
- $order = 'sort ' . $sort_config[ 'type' ] . ',create_time desc';
- $field = 'goods_id,goods_name,goods_class_name,goods_image,price,goods_stock,create_time,is_virtual';
- $goods_list = $goods_model->getGoodsPageList($condition, $page, $page_size, $order, $field);
- if (!empty($goods_list[ 'data' ][ 'list' ])) {
- foreach ($goods_list[ 'data' ][ 'list' ] as $k => $v) {
- $goods_list[ 'data' ][ 'list' ][ $k ][ 'sku_list' ] = $goods_model->getGoodsSkuList([ [ 'goods_id', '=', $v[ 'goods_id' ] ], [ 'site_id', '=', $this->site_id ] ], 'sku_id,sku_name,price,stock,sku_image,goods_id,goods_class_name', 'price asc')[ 'data' ];
- }
- }
- }
- return $goods_list;
- } else {
- //已经选择的商品sku数据
- $select_id = input('select_id', '');
- $mode = input('mode', 'spu');
- $max_num = input('max_num', 0);
- $min_num = input('min_num', 0);
- $is_virtual = input('is_virtual', '');
- $disabled = input('disabled', 0);
- $promotion = input('promotion', '');//营销活动标识:pintuan、groupbuy、seckill、fenxiao
- $goods_type = input('goods_type', ''); //查找商品类型
- $is_disabled_goods_type = input('is_disabled_goods_type', 0); //是否禁用商品类型筛选 0开启 1关闭
- $usable_goods_class = input('usable_goods_class', ''); // 可选择的商品类型
- $is_weigh = input('is_weigh', 0); // 是否支持称重
- $this->assign('is_disabled_goods_type', $is_disabled_goods_type);
- $this->assign('goods_type', $goods_type);
- $this->assign('select_id', $select_id);
- $this->assign('mode', $mode);
- $this->assign('max_num', $max_num);
- $this->assign('min_num', $min_num);
- $this->assign('is_virtual', $is_virtual);
- $this->assign('disabled', $disabled);
- $this->assign('promotion', $promotion);
- $this->assign('all_goodsclass', event('GoodsClass'));
- $this->assign('usable_goods_class', explode(',', $usable_goods_class));
- $this->assign('is_weigh', $is_weigh);
- // 营销活动
- $goods_promotion_type = event('GoodsPromotionType');
- $this->assign('promotion_type', $goods_promotion_type);
- // 商品分组
- $goods_label_model = new GoodsLabelModel();
- $label_list = $goods_label_model->getLabelList([ [ 'site_id', '=', $this->site_id ] ], 'id,label_name', 'sort asc')[ 'data' ];
- $this->assign("label_list", $label_list);
- //分类过滤
- if (!empty($promotion) && addon_is_exit($promotion)) {
- $category_id_arr = event('GoodsListCategoryIds', [
- 'promotion' => $promotion,
- 'site_id' => $this->site_id,
- ], true)[ 'data' ] ?? [];
- } else {
- $goods_model = new GoodsModel();
- $category_id_arr = $goods_model->getGoodsCategoryIds([
- [ 'is_delete', '=', 0 ],
- [ 'goods_state', '=', 1 ],
- [ 'goods_stock', '>', 0 ],
- [ 'site_id', '=', $this->site_id ],
- ])[ 'data' ];
- }
- $goods_category_model = new GoodsCategoryModel();
- $field = 'category_id,category_name as title,pid';
- $list = $goods_category_model->getCategoryList([
- [ 'site_id', '=', $this->site_id ],
- [ 'category_id', 'in', $category_id_arr ]
- ], $field)[ 'data' ];
- $tree = list_to_tree($list, 'category_id', 'pid', 'children', 0);
- $this->assign("category_list", $tree);
- $this->assign('virtualcard_exit', addon_is_exit('virtualcard', $this->site_id));
- $this->assign('cardservice_exit', addon_is_exit('cardservice', $this->site_id));
- $goods_model = new GoodsModel();
- $goods_model->getGoodsTotalCount();
- return $this->fetch("goods/goods_select");
- }
- }
- /***********************************************************商品评价**************************************************/
- /**
- * 商品评价
- */
- public function evaluate()
- {
- $goods_evaluate = new GoodsEvaluateModel();
- if (request()->isAjax()) {
- $page_index = input('page', 1);
- $page_size = input('page_size', PAGE_LIST_ROWS);
- $explain_type = input('explain_type', ''); //1好评2中评3差评
- $is_show = input('is_show', ''); //1显示 0隐藏
- $search_text = input('search_text', ''); //搜索值
- $search_type = input('search_type', ''); //搜索类型
- $start_time = input('start_time', '');
- $end_time = input('end_time', '');
- $goods_id = input('goods_id', '');
- $is_audit = input('is_audit', '');
- if (!empty($is_audit)) {
- if ($is_audit == 1) {
- $condition[] =
- [ "is_audit", "=", 0 ];
- } else if ($is_audit == 2) {
- $condition[] =
- [ "is_audit", "=", 1 ];
- } else if ($is_audit == 3) {
- $condition[] =
- [ "is_audit", "=", 2 ];
- }
- }
- $condition[] =
- [ "site_id", "=", $this->site_id ];
- //评分类型
- if ($explain_type != "") {
- $condition[] = [ "explain_type", "=", $explain_type ];
- }
- if ($is_show != "") {
- $condition[] = [ "is_show", "=", $is_show ];
- }
- if ($search_text != "") {
- $condition[] = [ $search_type, "like", '%' . $search_text . '%' ];
- }
- if ($goods_id != "") {
- $condition[] = [ 'goods_id', "=", $goods_id ];
- }
- if (!empty($start_time) && empty($end_time)) {
- $condition[] = [ "create_time", ">=", date_to_time($start_time) ];
- } elseif (empty($start_time) && !empty($end_time)) {
- $condition[] = [ "create_time", "<=", date_to_time($end_time) ];
- } elseif (!empty($start_time) && !empty($end_time)) {
- $condition[] = [ 'create_time', 'between', [ date_to_time($start_time), date_to_time($end_time) ] ];
- }
- return $goods_evaluate->getEvaluatePageList($condition, $page_index, $page_size, "is_audit asc, create_time desc");
- } else {
- $goods_id = input('goods_id', '');
- $this->assign('goods_id', $goods_id);
- return $this->fetch("goods/evaluate");
- }
- }
- /**
- * 商品评价删除
- */
- public function deleteEvaluate()
- {
- if (request()->isAjax()) {
- $goods_evaluate = new GoodsEvaluateModel();
- $evaluate_ids = input("evaluate_ids", 0);
- return $goods_evaluate->deleteEvaluate($evaluate_ids);
- }
- }
- /**
- * 修改商品评价审核状态
- */
- public function modifyAuditEvaluate()
- {
- if (request()->isAjax()) {
- $goods_evaluate = new GoodsEvaluateModel();
- $evaluate_ids = input("evaluate_ids", '');
- $is_audit = input('is_audit', 0);
- $data = [
- 'is_audit' => $is_audit
- ];
- $condition = [
- [ 'evaluate_id', 'in', $evaluate_ids ],
- [ 'is_audit', '=', 0 ],
- [ 'site_id', '=', $this->site_id ],
- ];
- $res = $goods_evaluate->modifyAuditEvaluate($data, $condition);
- return $res;
- }
- }
- /**
- * 修改商品追评审核状态
- */
- public function modifyAgainAuditEvaluate()
- {
- if (request()->isAjax()) {
- $goods_evaluate = new GoodsEvaluateModel();
- $evaluate_ids = input("evaluate_ids", '');
- $again_is_audit = input('again_is_audit', 0);
- $data = [
- 'again_is_audit' => $again_is_audit
- ];
- $condition = [
- [ 'evaluate_id', 'in', $evaluate_ids ],
- [ 'again_is_audit', '=', 0 ],
- [ 'site_id', '=', $this->site_id ],
- ];
- $res = $goods_evaluate->modifyAgainAuditEvaluate($data, $condition);
- return $res;
- }
- }
- /**
- * 商品推广
- * return
- */
- public function goodsUrl()
- {
- $goods_id = input('goods_id', '');
- $goods_model = new GoodsModel();
- $goods_sku_info = $goods_model->getGoodsSkuInfo([ [ 'goods_id', '=', $goods_id ] ], 'sku_id,goods_name,site_id')[ 'data' ];
- if (!empty($goods_sku_info)) {
- // $res = $goods_model->qrcode($goods_sku_info[ 'sku_id' ], $goods_sku_info[ 'goods_name' ], $goods_sku_info[ 'site_id' ]);
- $res = $goods_model->urlQrcode('/pages/goods/detail', [ 'goods_id' => $goods_id ], 'goods', $this->site_id);
- return $res;
- }
- }
- /**
- * 商品评价回复
- */
- public function evaluateApply()
- {
- if (request()->isAjax()) {
- $goods_evaluate = new GoodsEvaluateModel();
- $evaluate_id = input("evaluate_id", 0);
- $explain = input("explain", 0);
- $is_first_explain = input("is_first_explain", 0);// 是否第一次回复
- $data = [
- 'evaluate_id' => $evaluate_id
- ];
- if ($is_first_explain == 0) {
- $data[ 'explain_first' ] = $explain;
- } elseif ($is_first_explain == 1) {
- $data[ 'again_explain' ] = $explain;
- }
- return $goods_evaluate->evaluateApply($data);
- }
- }
- /**
- * 删除商品评价回复
- */
- public function deleteContent()
- {
- if (request()->isAjax()) {
- $goods_evaluate = new GoodsEvaluateModel();
- $evaluate_id = input("evaluate_id", 0);
- $is_first_explain = input("is_first", 0);// 0 第一次回复,1 追评回复
- $data = [];
- if ($is_first_explain == 0) {
- $data[ 'explain_first' ] = '';
- } elseif ($is_first_explain == 1) {
- $data[ 'again_explain' ] = '';
- }
- $condition = [
- [ 'evaluate_id', '=', $evaluate_id ],
- [ 'site_id', '=', $this->site_id ],
- ];
- return $goods_evaluate->editEvaluate($data, $condition);
- }
- }
- /**
- * 商品批量设置
- */
- public function batchSet()
- {
- if (request()->isAjax()) {
- $type = input("type", '');
- $goods_ids = input("goods_ids", '');
- $field = input("field", '');
- $data = !empty($field) ? json_decode($field, true) : [];
- $goods_model = new GoodsModel();
- $result = error(-1, '操作失败');
- try {
- if (!empty($goods_ids)) {
- switch ( $type ) {
- case 'group':
- $result = $goods_model->modifyGoodsLabel($data[ 'group' ], $this->site_id, $goods_ids);
- break;
- case 'service':
- $result = $goods_model->modifyGoodsService($data[ 'server_ids' ], $this->site_id, $goods_ids);
- break;
- case 'sale':
- $result = $goods_model->modifyGoodsVirtualSale($data[ 'sale' ], $this->site_id, $goods_ids);
- break;
- case 'purchase_limit':
- $result = $goods_model->modifyGoodsPurchaseLimit($data[ 'max_buy' ], $this->site_id, $goods_ids);
- break;
- case 'shipping':
- $result = $goods_model->modifyGoodsShippingTemplate($data[ 'is_free_shipping' ], $data[ 'shipping_template' ], $this->site_id, $goods_ids);
- break;
- case 'category':
- $result = $goods_model->modifyGoodsCategoryId($data[ 'category_id' ], $this->site_id, $goods_ids);
- //$result = ',' . implode(',', $data[ 'category_id' ]) . ',';
- break;
- case 'shop_intor':
- $result = $goods_model->modifyGoodsShopIntor($data[ 'recom_way' ], $this->site_id, $goods_ids);
- break;
- case 'member_price':
- $result = $goods_model->modifyGoodsConsumeDiscount($data[ 'is_consume_discount' ], $this->site_id, $goods_ids);
- break;
- case 'stock':
- $sku_list = $goods_model->getGoodsSkuList([ [ 'goods_id', 'in', $goods_ids ], [ 'goods_class', 'in', '1,2,4,5,6' ] ], 'sku_id,goods_id,stock,goods_class')[ 'data' ] ?? [];
- // 实物,虚拟,卡项,服务,称重
- $result = $goods_model->editGoodsSkuStock($sku_list, $data[ 'stock' ], $data[ 'stock_type' ]);
- break;
- case 'price':
- $batch_model = new Batch();
- $params = array (
- 'site_id' => $this->site_id,
- 'type' => $type,
- 'goods_ids' => $goods_ids,
- );
- $result = $batch_model->setPrice(array_merge($params, $data));
- break;
- case 'goods_form':
- $result = $goods_model->modifyGoodsForm($data[ 'form_id' ], $this->site_id, $goods_ids);
- break;
- case 'goods_brand':
- $result = $goods_model->modifyGoodsBrand($data[ 'brand_id' ], $this->site_id, $goods_ids);
- break;
- }
- }
- } catch (\Exception $e) {
- $result = error(-1, $e->getMessage());
- }
- return $result;
- }
- }
- /**
- * 热门搜索关键词
- * @return mixed
- */
- public function hotSearchWords()
- {
- $config_model = new ConfigModel();
- if (request()->isAjax()) {
- $words = input("words", []);
- $data = [
- 'words' => implode(',', $words)
- ];
- $res = $config_model->setHotSearchWords($data, $this->site_id, $this->app_module);
- return $res;
- } else {
- $this->forthMenu();
- $hot_search_words = $config_model->getHotSearchWords($this->site_id, $this->app_module);
- $hot_search_words = $hot_search_words[ 'data' ][ 'value' ];
- $words_array = [];
- if (!empty($hot_search_words[ 'words' ])) {
- $words_array = explode(',', $hot_search_words[ 'words' ]);
- }
- $hot_search_words[ 'words_array' ] = $words_array;
- $this->assign("hot_search_words", $hot_search_words);
- return $this->fetch('goods/hot_search_words');
- }
- }
- /**
- * 猜你喜欢
- * @return mixed
- */
- public function guessYouLike()
- {
- $config_model = new ConfigModel();
- if (request()->isAjax()) {
- $value = input('value', '');
- if (!empty($value)) {
- $value = json_decode($value, true);
- $res = $config_model->setGuessYouLike($value, $this->site_id, $this->app_module);
- return $res;
- }
- } else {
- $config = $config_model->getGuessYouLike($this->site_id, $this->app_module)[ 'data' ][ 'value' ];
- $this->assign("config", $config);
- $this->assign('store_is_exit', addon_is_exit('store', $this->site_id));
- return $this->fetch('goods/guess_you_like');
- }
- }
- /**
- * 商品列表配置
- * @return mixed
- */
- public function goodsListConfig()
- {
- $config_model = new ConfigModel();
- if (request()->isAjax()) {
- $value = input('value', '');
- if (!empty($value)) {
- $value = json_decode($value, true);
- $res = $config_model->setGoodsListConfig($value, $this->site_id, $this->app_module);
- return $res;
- }
- } else {
- $config = $config_model->getGoodsListConfig($this->site_id, $this->app_module)[ 'data' ][ 'value' ];
- $this->assign("config", $config);
- $this->assign('store_is_exit', addon_is_exit('store', $this->site_id));
- return $this->fetch('goods/goods_list_config');
- }
- }
- /**
- * 默认搜索关键词
- * @return mixed
- */
- public function defaultSearchWords()
- {
- $config_model = new ConfigModel();
- if (request()->isAjax()) {
- $default_data = [
- 'words' => input("default_words", "")
- ];
- $config_model->setDefaultSearchWords($default_data, $this->site_id, $this->app_module);
- $words = input("words", []);
- $data = [
- 'words' => implode(',', $words)
- ];
- $res = $config_model->setHotSearchWords($data, $this->site_id, $this->app_module);
- return $res;
- } else {
- $this->forthMenu();
- $default_search_words = $config_model->getDefaultSearchWords($this->site_id, $this->app_module);
- $default_search_words = $default_search_words[ 'data' ][ 'value' ];
- $this->assign("default_search_words", $default_search_words);
- $hot_search_words = $config_model->getHotSearchWords($this->site_id, $this->app_module);
- $hot_search_words = $hot_search_words[ 'data' ][ 'value' ];
- $words_array = [];
- if (!empty($hot_search_words[ 'words' ])) {
- $words_array = explode(',', $hot_search_words[ 'words' ]);
- }
- $hot_search_words[ 'words_array' ] = $words_array;
- $this->assign("hot_search_words", $hot_search_words);
- return $this->fetch('goods/default_search_words');
- }
- }
- /**
- * 复制商品
- * @return array
- */
- public function copyGoods()
- {
- if (request()->isAjax()) {
- $goods_id = input('goods_id', 0);
- $goods_model = new GoodsModel();
- $res = $goods_model->copyGoods($goods_id, $this->site_id);
- return $res;
- }
- }
- /**
- * 会员商品收藏
- */
- public function memberGoodsCollect()
- {
- $goods_collect_model = new GoodsCollect();
- $member_id = input('member_id', 0);
- if (request()->isAjax()) {
- $page = input('page', 1);
- $page_size = input('page_size', PAGE_LIST_ROWS);
- $condition = [];
- $condition[] = [ 'gc.site_id', '=', $this->site_id ];
- $condition[] = [ 'gc.member_id', '=', $member_id ];
- $order = 'gc.create_time desc';
- $field = 'gc.collect_id,gc.create_time,gc.member_id, gc.goods_id, gc.sku_id,gc.sku_name, gc.sku_price, gc.sku_image,g.goods_name,g.is_free_shipping,sku.promotion_type,sku.member_price,sku.discount_price,g.sale_num,g.price,g.market_price,g.is_virtual,sku.collect_num,g.goods_state';
- return $goods_collect_model->getCollectPageList($condition, $page, $page_size, $order, $field);
- } else {
- $this->forthMenu([ 'member_id' => $member_id ]);
- $this->assign('member_id', $member_id);
- return $this->fetch('goods/member_goods_collect');
- }
- }
- /**
- * 会员浏览记录
- */
- public function memberGoodsBrowse()
- {
- $member_id = input('member_id', 0);
- $goods_browse_model = new GoodsBrowse();
- if (request()->isAjax()) {
- $page = input('page', 1);
- $page_size = input('page_size', PAGE_LIST_ROWS);
- $search = input('search', '');
- $condition = [];
- $condition[] = [ 'gb.site_id', '=', $this->site_id ];
- $condition[] = [ 'gb.member_id', '=', $member_id ];
- if (!empty($search)) {
- $condition[] = [ 'gs.sku_name', 'like', '%' . $search . '%' ];
- }
- $order = 'browse_time desc';
- $field = 'gb.*,gs.sku_name,gs.sku_image,gs.price,gs.goods_state,gs.stock,gs.click_num';
- $alias = 'gb';
- $join = [
- [ 'goods_sku gs', 'gs.sku_id = gb.sku_id', 'right' ]
- ];
- return $goods_browse_model->getBrowsePageList($condition, $page, $page_size, $order, $field, $alias, $join);
- } else {
- $this->forthMenu([ 'member_id' => $member_id ]);
- $this->assign('member_id', $member_id);
- return $this->fetch('goods/member_goods_browse');
- }
- }
- /**
- * 商品浏览记录
- */
- public function goodsBrowse()
- {
- $goods_id = input('goods_id', 0);
- $goods_browse_model = new GoodsBrowse();
- if (request()->isAjax()) {
- $page = input('page', 1);
- $page_size = input('page_size', PAGE_LIST_ROWS);
- $search = input('search', '');
- $condition = [];
- $condition[] = [ 'gb.site_id', '=', $this->site_id ];
- if ($goods_id > 0) {
- $condition[] = [ 'gb.goods_id', '=', $goods_id ];
- }
- if (!empty($search))
- $condition[] = [ 'gs.sku_name', 'like', '%' . $search . '%' ];
- $order = 'browse_time desc';
- $field = 'gb.*,gs.sku_name,gs.sku_image,gs.price,gs.goods_state,gs.stock,gs.click_num,m.nickname,m.headimg';
- $alias = 'gb';
- $join = [
- [ 'goods_sku gs', 'gs.sku_id = gb.sku_id', 'left' ],
- [ 'member m', 'm.member_id = gb.member_id', 'left' ]
- ];
- $res = $goods_browse_model->getBrowsePageList($condition, $page, $page_size, $order, $field, $alias, $join);
- foreach ($res[ 'data' ][ 'list' ] as $k => $v) {
- $res[ 'data' ][ 'list' ][ $k ][ 'stock' ] = numberFormat($res[ 'data' ][ 'list' ][ $k ][ 'stock' ]);
- }
- return $res;
- } else {
- $this->assign('goods_id', $goods_id);
- return $this->fetch('goods/goods_browse');
- }
- }
- /**
- * 商品排序
- */
- public function goodssort()
- {
- $config_model = new ConfigModel();
- if (request()->isAjax()) {
- $type = input("type", 'asc');
- $default_value = input("default_value", '0');
- $data = [
- 'type' => trim($type),
- 'default_value' => trim($default_value),
- ];
- $res = $config_model->setGoodsSort($data, $this->site_id, $this->app_module);
- return $res;
- } else {
- $this->forthMenu();
- $goods_sort_confog = $config_model->getGoodsSort($this->site_id, $this->app_module);
- $goods_sort_confog = $goods_sort_confog[ 'data' ][ 'value' ];
- $this->assign("goods_sort_confog", $goods_sort_confog);
- return $this->fetch('goods/goods_sort');
- }
- }
- /**
- * 商品导入
- */
- public function import()
- {
- $import_model = new GoodsImport();
- $type = input('type');
- if (request()->isAjax()) {
- $file = request()->file('xlsx');
- if (empty($file)) {
- return $import_model->error();
- }
- $tmp_name = $file->getPathname();//获取上传缓存文件
- $data = ( new GoodsImport() )->readGoodsExcel($tmp_name);
- if ($data[ 'code' ] < 0) {
- return $data;
- }
- $result = ( new GoodsImport() )->importGoods($data[ 'data' ], $this->site_id, $type);
- return $result;
- } else {
- return $this->fetch("goods/import");
- }
- }
- public function importRecordList()
- {
- $page_index = input('page', 1);
- $page_size = input('page_size', PAGE_LIST_ROWS);
- $goodsimport_model = new GoodsImport();
- if (request()->isAjax()) {
- $start_time = input('start_time', '');
- $end_time = input('end_time', '');
- $condition = [ [ 'site_id', '=', $this->site_id ] ];
- if (!empty($start_time) && empty($end_time)) {
- $condition[] = [ "import_time", ">=", date_to_time($start_time) ];
- } elseif (empty($start_time) && !empty($end_time)) {
- $condition[] = [ "import_time", "<=", date_to_time($end_time) ];
- } elseif (!empty($start_time) && !empty($end_time)) {
- $condition[] = [ 'import_time', 'between', [ date_to_time($start_time), date_to_time($end_time) ] ];
- }
- $res = $goodsimport_model->getImportPageList($condition, $page_index, $page_size);
- if (!empty($res[ 'data' ][ 'list' ])) {
- foreach ($res[ 'data' ][ 'list' ] as $k => &$v) {
- $v[ 'import_time' ] = time_to_date($v[ 'import_time' ]);
- }
- }
- return $res;
- } else {
- return $this->fetch("goods/import_record_list");
- }
- }
- public function download()
- {
- $id = input('id', '0');
- ( new GoodsImport() )->downloadFailData($id, $this->site_id);
- }
- /**
- * 商品海报
- */
- public function poster()
- {
- $goods_poster_model = new GoodsPoster();
- if (request()->isAjax()) {
- $page = input('page', 1);
- $page_size = input('page_size', PAGE_LIST_ROWS);
- $keywords = input('keywords', '');
- if (!empty($keywords)) {
- $condition[] = [ 'poster_name', 'like', '%' . $keywords . '%' ];
- }
- $condition[] = [ 'site_id', '=', $this->site_id ];
- $result = $goods_poster_model->getPosterPageList($condition, $page, $page_size);
- return $result;
- } else {
- return $this->fetch("goods/goods_poster_list");
- }
- }
- /**
- * 商品海报添加
- */
- public function editPoster()
- {
- $goods_poster_model = new GoodsPoster();
- if (request()->isAjax()) {
- $poster_name = input('poster_name', '');
- $json_data = input('json_data', '');
- $poster_id = input('poster_id', '');
- if (empty($poster_id)) {
- $data[ 'create_time' ] = time();
- } else {
- $data[ 'modify_time' ] = time();
- }
- $data[ 'poster_id' ] = $poster_id;
- $data[ 'poster_name' ] = $poster_name;
- $data[ 'json_data' ] = $json_data;
- $data[ 'poster_type' ] = 1;
- $data[ 'site_id' ] = $this->site_id;
- $result = $goods_poster_model->addPoster($data);
- return $result;
- } else {
- $poster_id = input('poster_id', '');
- if (!empty($poster_id)) {
- $goods_poster_data = $goods_poster_model->getPosterInfo($poster_id, $this->site_id);
- $this->assign('poster_data', $goods_poster_data[ 'data' ]);
- }
- return $this->fetch("goods/goods_edit_poster");
- }
- }
- /**
- * 修改海报启用状态
- */
- public function editStatus()
- {
- $goods_poster_model = new GoodsPoster();
- $poster_id = input('poster_id', 0);
- $status = input('status', '');
- $data = [
- 'poster_id' => $poster_id,
- 'status' => $status,
- 'site_id' => $this->site_id,
- 'modify_time' => time()
- ];
- return $goods_poster_model->addPoster($data);
- }
- /**
- * 删除海报
- */
- public function deletePoster()
- {
- $goods_poster_model = new GoodsPoster();
- $poster_id = input('poster_id', 0);
- return $goods_poster_model->deletePoster($poster_id, $this->site_id);
- }
- public function verify()
- {
- $goods_id = input("goods_id", "0");
- $virtual_goods_model = new \app\model\goods\VirtualGoods();
- if (request()->isAjax()) {
- $start_time = input("start_time", '');
- $end_time = input("end_time", '');
- $nickname = input("nickname", '');
- $is_verify = input("is_verify", "all");
- $verify_code = input("verify_code", "");
- $field = 'gv.*, m.nickname,m.headimg';
- $page_index = input('page', 1);
- $page_size = input('page_size', PAGE_LIST_ROWS);
- $alias = 'gv';
- $condition = [
- [ "gv.site_id", "=", $this->site_id ],
- [ "gv.goods_id", "=", $goods_id ],
- ];
- if ($nickname) $condition[] = [ 'm.nickname', 'like', '%' . $nickname . '%' ];
- if ($verify_code) $condition[] = [ 'gv.code', '=', $verify_code ];
- $order = "gv.id desc";
- $join = [
- [
- 'member m',
- 'm.member_id = gv.member_id',
- 'left'
- ]
- ];
- if ($is_verify != "all") {
- $condition[] = [ "gv.is_veirfy", "=", $is_verify ];
- }
- $list = $virtual_goods_model->getVirtualGoodsPageList($condition, $page_index, $page_size, $order, $field, $alias, $join);
- return $list;
- }
- $this->assign('goods_id', $goods_id);
- $goods_model = new GoodsModel();
- $goods_info = $goods_model->getGoodsInfo([ [ 'goods_id', '=', $goods_id ], [ 'site_id', '=', $this->site_id ] ], 'goods_id, goods_name,goods_image,price,goods_state,goods_stock,sale_num');
- $this->assign('goods_info', $goods_info[ 'data' ]);
- $verify_count = $virtual_goods_model->getVirtualGoodsInfo([ [ 'goods_id', '=', $goods_id ], [ 'site_id', '=', $this->site_id ] ], 'count(id) as total_count, sum(verify_use_num) as verify_use_num')[ 'data' ] ?? [];
- $this->assign('total_count', $verify_count[ 'total_count' ] ?? 0);
- $this->assign('verify_use_num', $verify_count[ 'verify_use_num' ] ?? 0);
- return $this->fetch("goods/verify");
- }
- /**
- * 商品详情配置
- * @return mixed
- */
- public function goodsDetailConfig()
- {
- $config_model = new ConfigModel();
- if (request()->isAjax()) {
- $data = [
- 'nav_bar_switch' => input('nav_bar_switch', 0),
- 'introduction_color' => input('introduction_color', ''),
- ];
- $res = $config_model->setGoodsDetailConfig($data, $this->site_id, $this->app_module);
- return $res;
- } else {
- $config = $config_model->getGoodsDetailConfig($this->site_id, $this->app_module)[ 'data' ][ 'value' ];
- $this->assign("config", $config);
- return $this->fetch('goods/goods_detail_config');
- }
- }
- /**
- * 获取运费模板
- * @return array
- */
- public function getExpressTemplateList()
- {
- if (request()->isAjax()) {
- $express_template_model = new ExpressTemplateModel();
- $express_template_list = $express_template_model->getExpressTemplateList([ [ 'site_id', "=", $this->site_id ] ], 'template_id,template_name', 'is_default desc') ?? [];
- // foreach ($express_template_list[ 'data' ] as $k => $v) {
- // $template_item_condition = array (
- // [ 'template_id', '=', $v[ 'template_id' ] ],
- // );
- // $template_item_list = $express_template_model->getExpressTemplateItemList($template_item_condition)[ 'data' ] ?? [];
- // $express_template_list[ 'data' ][ $k ][ 'template_item_list' ] = $template_item_list;
- // }
- return $express_template_list;
- }
- }
- /**
- * 验证商品编码是否重复
- * @return array
- */
- public function verifySkuNo()
- {
- if (request()->isAjax()) {
- $sku_no = input('sku_no', '');
- $goods_id = input('goods_id', 0);
- $goods_model = new GoodsModel();
- $res = $goods_model->verifySkuNo([
- 'site_id' => $this->site_id,
- 'sku_no' => $sku_no,
- 'goods_id' => $goods_id
- ]);
- return $res;
- }
- }
- /**
- * 商品导出
- */
- public function exportGoods()
- {
- if (request()->isAjax()) {
- $search_text = input('search_text', "");
- $goods_state = input('goods_state', "");
- $start_sale = input('start_sale', 0);
- $end_sale = input('end_sale', 0);
- $start_price = input('start_price', 0);
- $end_price = input('end_price', 0);
- $sku_start_price = input('sku_start_price', 0);
- $sku_end_price = input('sku_end_price', 0);
- $goods_class = input('goods_class', "");
- $label_id = input('label_id', "");
- $brand_id = input('brand_id', "");
- $sku_no = input('sku_no', '');
- $promotion_type = input('promotion_type', "");
- $category_id = input('category_id', "");
- $stockalarm = input('stockalarm', 0);
- $goods_ids = input('goods_ids', '');
- $goods_model = new GoodsModel();
- $condition_desc = [];
- $condition = [
- [ 'g.is_delete', '=', 0 ],
- [ 'g.site_id', '=', $this->site_id ],
- ];
- if (!empty($goods_ids)) {
- $condition[] = [ 'g.goods_id', 'in', explode(',', $goods_ids) ];
- $condition_desc[] = [ 'name' => 'goods_id', 'value' => $goods_ids ];
- }
- if (!empty($search_text)) {
- $condition[] = [ 'g.goods_name', 'like', '%' . $search_text . '%' ];
- $condition_desc[] = [ 'name' => '商品名称', 'value' => $search_text ];
- }
- if (!empty($sku_no)) {
- $goods_sku_list = $goods_model->getGoodsSkuList([ [ 'sku_no', 'like', '%' . $sku_no . '%' ] ], 'goods_id')[ 'data' ];
- $goods_id_arr = array_unique(array_column($goods_sku_list, 'goods_id'));
- $condition[] = [ 'goods_id', 'in', $goods_id_arr ];
- $condition_desc[] = [ 'name' => '商品编码', 'value' => $sku_no ];
- }
- if (!empty($category_id)) {
- $condition[] = [ 'g.category_id', '=', $category_id ];
- $goods_category_model = new GoodsCategoryModel();
- $category_info = $goods_category_model->getCategoryInfo([
- [ 'category_id', '=', $category_id ],
- [ 'site_id', '=', $this->site_id ]
- ], 'category_name')[ 'data' ];
- if (!empty($category_info)) {
- $condition_desc[] = [ 'name' => '商品分类', 'value' => $category_info[ 'category_name' ] ];
- }
- }
- $brand_name = '全部';
- if (!empty($brand_id)) {
- $condition[] = [ 'g.brand_id', '=', $brand_id ];
- $goods_brand_model = new GoodsBrandModel();
- $goods_brand_info = $goods_brand_model->getBrandInfo([
- [ 'site_id', '=', $this->site_id ],
- ], 'brand_name')[ 'data' ];
- if (!empty($goods_brand_info)) {
- $brand_name = $goods_brand_info[ 'brand_name' ];
- }
- }
- $condition_desc[] = [ 'name' => '商品品牌', 'value' => $brand_name ];
- $goods_class_name = '全部';
- if ($goods_class !== "") {
- $condition[] = [ 'g.goods_class', '=', $goods_class ];
- $goods_class_info = array_column(event('GoodsClass'), null, 'goods_class');
- $goods_class_name = $goods_class_info[ $goods_class ][ 'goods_class_name' ];
- }
- $condition_desc[] = [ 'name' => '商品类型', 'value' => $goods_class_name ];
- $label_name = '全部';
- if (!empty($label_id)) {
- $condition[] = [ 'g.label_id', '=', $label_id ];
- $goods_label_model = new GoodsLabelModel();
- $label_info = $goods_label_model->getLabelInfo([
- [ 'site_id', '=', $this->site_id ],
- [ 'label_id', '=', $label_id ]
- ], 'label_name')[ 'data' ];
- if (!empty($label_info)) {
- $label_name = $label_info[ 'label_name' ];
- }
- }
- $condition_desc[] = [ 'name' => '商品标签', 'value' => $label_name ];
- if (!empty($promotion_type)) {
- $condition[] = [ 'g.promotion_addon', 'like', "%{$promotion_type}%" ];
- }
- // 上架状态
- if ($goods_state !== '') {
- $condition[] = [ 'g.goods_state', '=', $goods_state ];
- $condition_desc[] = [ 'name' => '商品状态', 'value' => $goods_state == 1 ? '销售中' : '仓库中' ];
- }
- if (!empty($start_sale)) $condition[] = [ 'sale_num', ' >= ', $start_sale ];
- if (!empty($end_sale)) $condition[] = [ 'sale_num', ' <= ', $end_sale ];
- if (!empty($start_price)) $condition[] = [ 'price', ' >= ', $start_price ];
- if (!empty($end_price)) $condition[] = [ 'price', ' <= ', $end_price ];
- if (!empty($sku_start_price)) $condition[] = [ 'sku.price', ' >= ', $sku_start_price ];
- if (!empty($sku_end_price)) $condition[] = [ 'sku.price', ' <= ', $sku_end_price ];
- // 查询库存预警的商品
- if ($stockalarm) {
- $stock_alarm = $goods_model->getGoodsStockAlarm($this->site_id);
- if (!empty($stock_alarm[ 'data' ])) {
- $condition[] = [ 'goods_id', 'in', $stock_alarm[ 'data' ] ];
- } else {
- return success(0, '', [ 'page_count' => 1, 'count' => 0, 'list' => [] ]);
- }
- }
- $goods_export_model = new GoodsExport();
- $result = $goods_export_model->export($condition, $condition_desc, $this->site_id);
- return $result;
- }
- }
- /**
- * 导出记录
- * @return array|mixed
- */
- public function export()
- {
- if (request()->isAjax()) {
- $page_index = input('page', 1);
- $page_size = input('page_size', PAGE_LIST_ROWS);
- $export_model = new GoodsExport();
- $condition = array (
- [ 'site_id', '=', $this->site_id ]
- );
- $result = $export_model->getExportPageList($condition, $page_index, $page_size, 'create_time desc', ' * ');
- return $result;
- } else {
- return $this->fetch('goods/export');
- }
- }
- /**
- * 删除导出记录
- * @return array
- */
- public function deleteExport()
- {
- if (request()->isAjax()) {
- $export_ids = input('export_ids', '');
- $export_model = new GoodsExport();
- $condition = array (
- [ 'site_id', '=', $this->site_id ],
- [ 'export_id', 'in', (string) $export_ids ]
- );
- $result = $export_model->deleteExport($condition);
- return $result;
- }
- }
- }
|