diff --git a/app/admin/controller/Controller.php b/app/admin/controller/Controller.php index 604966a8..9fcad99f 100644 --- a/app/admin/controller/Controller.php +++ b/app/admin/controller/Controller.php @@ -79,8 +79,8 @@ class Controller extends BaseController if (strpos($this->admin['user']['channel'], 'jd') !== false) { $list = Channel::where('status', 1)->whereIn('code',[$this->admin['user']['channel'],'zy'])->select(); //苏宁账号可以看到苏宁和自营的 - } elseif($this->admin['user']['channel'] == 'sn'){ - $list = Channel::where('status', 1)->whereIn('code',['sn','zy'])->select(); + } elseif(strpos($this->admin['user']['channel'], 'sn') !== false){ + $list = Channel::where('status', 1)->whereIn('code',[$this->admin['user']['channel'],'zy'])->select(); //新阙通信账号可以看到新阙通信和自营的 } elseif($this->admin['user']['channel'] == 'xqtx'){ $list = Channel::where('status', 1)->whereIn('code',['xqtx','zy'])->select(); diff --git a/app/admin/controller/Goods.php b/app/admin/controller/Goods.php index e161e755..cdc7d1ac 100644 --- a/app/admin/controller/Goods.php +++ b/app/admin/controller/Goods.php @@ -19,6 +19,7 @@ use app\store\model\Goods as GoodsModel; use app\store\model\GoodsCategoryRel; use app\store\model\GoodsSku; use app\store\model\goods\Import as ImportModel; +use app\job\controller\goods\GoodsAddPrice as GoodsAddPriceJob; /** * 商品管理控制器 @@ -132,7 +133,7 @@ class Goods extends Controller // 商品详情 $model = GoodsModel::detail($goodsId); // echo "
"; - // print_r($this->postForm()); + // print_r($model); // exit(); // 更新记录 if ($model->edit($this->postForm(), $model)) { @@ -144,7 +145,18 @@ class Goods extends Controller return $this->renderSuccess('更新成功'); } $goods_sku = GoodsModel::where('goods_id', $goodsId)->where('store_id', 0)->find(); - + // var_dump($goods_sku->cost_price_min); + // var_dump($goods_sku->markup_rate); + //成本价加价之后的处理 + list($cost_price, $profit, $profit_rate) = getGoodsCostAndProfitAndProfitRate($goods_sku->goods_price_min, $goods_sku->cost_price_min, $goods_sku->markup_rate); + $goods_sku->cost_price_min = $cost_price; + $goods_sku->profit = $profit; + $goods_sku->profit_rate = $profit_rate; + + // var_dump($cost_price); + // var_dump($profit); + // var_dump($profit_rate); + // exit(); $goods_data = [ 'goods_name' => $goods_sku->name, 'content' => $goods_sku->content, @@ -159,8 +171,16 @@ class Goods extends Controller 'goods_source' => $goods_sku->goods_source, 'is_check' => $goods_sku->is_check, 'delivery_time' => $goods_sku->delivery_time, + // 'is_pool' => $goods_sku->is_pool, + // 'is_sale' => $goods_sku->is_sale, 'update_time' => time(), ]; + if ($goods_sku->is_pool == 0 || $goods_sku->is_sale == 0) { + $goods_data['status'] = 20; + } + if ($goods_sku->is_pool == 1 && $goods_sku->is_sale == 1) { + $goods_data['status'] = 10; + } GoodsModel::where('origin_goods_id', $goodsId)->update($goods_data); $goods_sku_data = [ 'goods_price' => $goods_sku->goods_price_min, @@ -335,36 +355,38 @@ class Goods extends Controller * @param int $rate [description] */ public function addPrice(array $categoryIds, int $rate){ - ini_set('memory_limit', '1024M'); - set_time_limit(0); - $goods = GoodsCategoryRel::whereIn('category_id',$categoryIds)->where('store_id', 0)->select()->toArray(); - if (!$goods) { - return $this->renderSuccess('没有需要加价的商品'); - } - $goods = GoodsModel::whereIn('goods_id', array_column($goods, "goods_id"))->where('store_id', 0)->select()->toArray(); - if (!$goods) { + // ini_set('memory_limit', '1024M'); + // set_time_limit(0); + $platform = $this->getUserPlatform(); + $channels = $platform ? array_column($platform->toArray(), "code") : []; + $goodsList = GoodsModel::alias('g') + ->join('goods_category_rel c', 'g.goods_id = c.goods_id') + ->where('c.store_id',0) + ->where('g.is_delete',0) + ->whereIn('c.category_id',$categoryIds) + ->whereIn('g.channel', $channels) + ->field(['g.goods_id','g.cost_price_min']) + ->group('g.goods_id') + ->order("g.goods_id asc") + // ->limit(100) + ->select() + ->toArray(); + if (!$goodsList) { return $this->renderSuccess('没有需要加价的商品'); } - foreach ($goods as $key => $value) { - $net_price = round($value['goods_price_min'] / (1 - ($rate / 100)), 0); - $profit = (float)$net_price - (float)$value['cost_price_min']; - $profit_rate = (float)$net_price > 0 ? bcmul((string)($profit / (float)$net_price) , (string)100, 2) : 0.00; - $goodsData = [ - 'goods_price_min' => $net_price, - 'goods_price_max' => $net_price, - 'line_price_min' => $net_price, - 'line_price_max' => $net_price, - 'profit_rate' => $profit_rate, - 'profit' => $profit, - 'update_time' => time() - ]; - GoodsModel::where('goods_id', $value['goods_id'])->where('store_id', 0)->update($goodsData); - $goodsSkuData = [ - 'goods_price' => $net_price, - 'update_time' => time() - ]; - GoodsSku::where('goods_id', $value['goods_id'])->where('store_id', 0)->update(); + // 分批每次导入20条 + $limit = 50; + // 根据商品总数量计算需要的队列任务数量 + $jobCount = \count($goodsList) / $limit; + // 逐次发布队列任务 + for ($i = 0; $i < $jobCount; $i++) { + $data = array_slice($goodsList, $i * $limit, $limit); + GoodsAddPriceJob::dispatch([ + 'list' => $data, + 'rate' => $rate, + ]); } + return $this->renderSuccess('加价成功'); } diff --git a/app/api/controller/Category.php b/app/api/controller/Category.php index 7a90e60b..779ef358 100644 --- a/app/api/controller/Category.php +++ b/app/api/controller/Category.php @@ -15,6 +15,7 @@ namespace app\api\controller; use app\common\model\GoodsCategoryRel; use think\response\Json; use app\api\model\Category as CategoryModel; +use think\facade\Cache; /** * 商品分类控制器 @@ -32,13 +33,20 @@ class Category extends Controller */ public function list(): Json { + $cache_key = "Category_list".$this->storeId; + if(Cache::has($cache_key)) { + $list = Cache::get($cache_key); + return $this->renderSuccess(compact('list')); + } $model = new CategoryModel; $list = $model->getListPublic($this->request->param()); + Cache::set($cache_key, $list, 86400); return $this->renderSuccess(compact('list')); } public function childrenList(): Json { + $model = new CategoryModel; $list = $model->getChildrenList($this->request->param()); return $this->renderSuccess(compact('list')); diff --git a/app/api/controller/Dealer.php b/app/api/controller/Dealer.php index a49659df..951ad334 100644 --- a/app/api/controller/Dealer.php +++ b/app/api/controller/Dealer.php @@ -28,7 +28,7 @@ class Dealer extends Controller { // 当前用户信息 /* @var UserModel $user */ - private UserModel $user; + public $user; // 当前分销商信息 private ?DealerUserModel $dealer; diff --git a/app/api/controller/Goods.php b/app/api/controller/Goods.php index c1fe2ced..0ef059ad 100644 --- a/app/api/controller/Goods.php +++ b/app/api/controller/Goods.php @@ -148,6 +148,7 @@ class Goods extends Controller ]; break; default: + if ($goods->stock_total >= ($value['num'] ?? 1)) { $res = "有货"; } diff --git a/app/api/controller/Store.php b/app/api/controller/Store.php index 01889344..402c180b 100644 --- a/app/api/controller/Store.php +++ b/app/api/controller/Store.php @@ -115,10 +115,17 @@ class Store extends Controller { $storeid = request()->header()['storeid']; $info = StoreInfoModel::where('store_id', $storeid)->find()->toArray(); - $file = UploadFile::where('file_id', '=', $info['group_share_img_id'])->find(); - $info['group_share_img'] = $file->preview_url; - $file = UploadFile::where('file_id', '=', $info['logo_image_id'])->find(); - $info['logo_image'] = $file->preview_url; + $info['group_share_img'] = ""; + if ($info['group_share_img_id']) { + $file = UploadFile::where('file_id', '=', $info['group_share_img_id'])->find(); + $info['group_share_img'] = $file->preview_url; + } + $info['logo_image'] = ""; + if ($info['logo_image_id']) { + $file = UploadFile::where('file_id', '=', $info['logo_image_id'])->find(); + $info['logo_image'] = $file->preview_url; + } + return $this->renderSuccess($info); } diff --git a/app/api/controller/dealer/Withdraw.php b/app/api/controller/dealer/Withdraw.php index 7315cb77..799f6775 100644 --- a/app/api/controller/dealer/Withdraw.php +++ b/app/api/controller/dealer/Withdraw.php @@ -57,7 +57,7 @@ class Withdraw extends Controller // 提交提现申请 $model = new WithdrawModel; $data = $this->request->post(); - if ($model->submit($dealer, $data)) { + if ($model->submit($dealer, $data['form'])) { return $this->renderSuccess([], '提现申请已提交成功,请等待审核'); } return $this->renderError($model->getError() ?: '提交失败'); diff --git a/app/api/model/Order.php b/app/api/model/Order.php index 2eb0b14e..b284477b 100644 --- a/app/api/model/Order.php +++ b/app/api/model/Order.php @@ -141,6 +141,11 @@ class Order extends OrderModel $info = $info['storeInfo']->toArray(); foreach ($list['data'] as &$v) { $v['storeInfo'] = $info; + $total_num = 0; + foreach ($v['goods'] as $value) { + $total_num += $value['total_num'] ?? 0; + } + $v['total_num'] = $total_num; $v['delivery'] = DeliveryModel::where('order_id', $v['order_id'])->find(); } } @@ -179,6 +184,17 @@ class Order extends OrderModel $this->error = $orderSource->getError(); return false; } + //订单已取消提示 + if ($this['order_status'] == OrderStatusEnum::CANCELLED) { + $this->error = '订单已取消成功,无需重复操作'; + return false; + } + + if ($this['order_status'] == OrderStatusEnum::APPLY_CANCEL) { + $this->error = '订单已申请取消,需等待后台审核'; + return false; + } + // 订单是否已支付 $isPay = $this['pay_status'] == PayStatusEnum::SUCCESS; // 提示信息 @@ -480,6 +496,15 @@ class Order extends OrderModel if (!empty($info['storeInfo'])) { $order->storeInfo = $info['storeInfo']->toArray(); } + $total_num = 0; + if (isset($order->goods) && $order->goods) { + foreach ($order->goods as $value) { + $total_num += $value->total_num ?? 0; + } + } + + + $order->total_num = $total_num; return $order; } diff --git a/app/api/model/Setting.php b/app/api/model/Setting.php index a81bd165..63c6d651 100644 --- a/app/api/model/Setting.php +++ b/app/api/model/Setting.php @@ -55,7 +55,8 @@ class Setting extends SettingModel */ public static function getFinanceCommission() { - return static::getItem(SettingEnum::TRADE)['finance_process']; + $return = empty(static::getItem(SettingEnum::TRADE)['finance_process'])?'':static::getItem(SettingEnum::TRADE)['finance_process']; + return $return; } /** diff --git a/app/api/model/dealer/Withdraw.php b/app/api/model/dealer/Withdraw.php index a40c2c99..36ece79e 100644 --- a/app/api/model/dealer/Withdraw.php +++ b/app/api/model/dealer/Withdraw.php @@ -76,7 +76,7 @@ class Withdraw extends WithdrawModel //手续费 if (empty($data['is_invoice'])) { $commission = \app\api\model\Setting::getFinanceCommission(); - if (empty($commission)) { + if (!empty($commission)) { $data['commission_price'] = bcmath($data['money'], $commission / 100, 2); } } diff --git a/app/command/SyncGoodsToEs.php b/app/command/SyncGoodsToEs.php new file mode 100644 index 00000000..136cfedf --- /dev/null +++ b/app/command/SyncGoodsToEs.php @@ -0,0 +1,28 @@ +setName('syncGoodsToEs') + ->setDescription('同步商品数据到ES'); + } + + + protected function execute(Input $input, Output $output) + { + $goodsService = new GoodsEs(); + $goods = $goodsService->list([]); + var_dump($goods); + } + +} \ No newline at end of file diff --git a/app/common.php b/app/common.php index 53199696..98c782b0 100644 --- a/app/common.php +++ b/app/common.php @@ -594,3 +594,21 @@ function httpRequest($url, $method="GET", $postfields = null, $headers = array() return json_decode($response, true); //return array($http_code, $response,$requestinfo); } + + + +/** + * 获取加价之后的成本价 + * [getGoodsCostPrice description] + * @param [type] $cost_price [description] + * @param [type] $rate [description] + * @return [type] [description] + */ +function getGoodsCostAndProfitAndProfitRate($net_price, $cost_price, $rate){ + if ($rate > 0) { + $cost_price = round($cost_price / (1 - ($rate / 100)), 0); + } + $profit = (float)$net_price - (float)$cost_price; + $profit_rate = (float)$net_price > 0 ? bcmul(bcdiv((string)$profit, (string)$net_price, 4), (string)100, 2) : 0.00; + return [$cost_price, $profit, $profit_rate]; +} diff --git a/app/common/library/elasticsearch/Client.php b/app/common/library/elasticsearch/Client.php new file mode 100644 index 00000000..5c042c22 --- /dev/null +++ b/app/common/library/elasticsearch/Client.php @@ -0,0 +1,751 @@ +client = ClientBuilder::create()->setHosts([self::ES_HOST_NAME])->build(); + } + + + private function __clone() { + + } + + public static function getInstance(){ + if (is_null(self::$instance)) { + self::$instance = new self(); + } + return self::$instance; + } + + /** + * 查询条件 + * @param $params + * @return $this + */ + public function select($params = '') + { + $this->queryParams['select'] = str_replace(' ', '', trim($params, " ,\t\r\n")); + return $this; + } + + /** + * 分页 + * @param $number + * @return $this + */ + public function from($number = 0) + { + $this->queryParams['from'] = $number ? ($number-1)*10 : 0; + return $this; + } + + /** + * 页码 + * @param $number + * @return $this + */ + public function size($number = 10) + { + $this->queryParams['size'] = $number; + return $this; + } + + public function equal($params = []) + { + $this->queryParams['equal'][] = $params; + return $this; + } + + public function in($params = []) + { + $this->queryParams['in'][] = $params; + return $this; + } + + public function like($params = []) + { + $this->queryParams['like'][] = $params; + return $this; + } + + public function orlike($params = []) + { + $this->queryParams['orlike'][] = $params; + return $this; + } + + public function order($params = []) + { + $this->queryParams['order'][] = $params; + return $this; + } + + /** + * 根据条件删除文档 + * @param array $params + * @return array + */ + + public function deleteDoc($params = []) + { + return $this->client->deleteByQuery($params); + } + + + public function existsIndex(String $index_name) { + $params = [ + 'index' => $index_name + ]; + return $this->client->indices()->exists($params); + } + + /** + * 创建索引 + */ + public function createIndex(String $index_name, array $mapping = []): array + { + if ($this->existsIndex($index_name)) { + throw new Exception('索引已存在'. $index_name); + } + + //只能创建一次 + $params = [ + 'index' => $index_name, + 'body' => [ + 'settings' => [ + 'number_of_shards' => 5, + 'number_of_replicas' => 1 + ], + 'mappings' => $mapping + ] + ]; + return $this->client->indices()->create($params); + } + + /** + * 删除索引 + */ + public function deleteIndex(String $index_name = ''): array{ + $params = ['index' => $index_name]; + return $this->client->indices()->delete($params); + } + + /** + * 根据id删除文档 + * @param int $id + * @return array + */ + public function deleteDocById($id = 0) + { + $params = [ + 'index' => $this->index, + 'id' => $id + ]; + $response = $this->client->delete($params); + return $response; + } + + /** + * 组装查询条件 + * @param array $params + * @return $this + */ + private function parseQueryParams() + { + $queryParams = [ + 'index' => $this->index, + 'body' => [ + 'query' => [ + 'bool' => [ + 'must' => [], + 'filter' => [] + ] + ] + ], + 'from' => $this->queryParams['from'] ?? 0, + 'size' => $this->queryParams['size'] ?? 10 + ]; + + $filter = $must = []; + if (!empty($this->queryParams['select'])) { + $queryParams['_source'] = explode(',', $this->queryParams['select']); + } + + if (!empty($this->queryParams['equal'])) { + foreach ($this->queryParams['equal'] as $key => $row) { + foreach ($row as $filed => $value) { + $filter[] = [ + 'term' => [$filed => $value] + ]; + } + } + } + + if (!empty($this->queryParams['in'])) { + foreach ($this->queryParams['in'] as $key => $row) { + foreach ($row as $filed => $value) { + $filter[] = [ + 'terms' => [$filed => array_values(array_unique(array_filter($value)))] + ]; + } + } + } + + if (!empty($this->queryParams['like'])) { + foreach ($this->queryParams['like'] as $key => $row) { + foreach ($row as $filed => $value) { + /*$must[] = [ + + 'wildcard' => [$filed => '*'. $value. '*'] + + ];*/ + $must[] = [ +// 'match' => [$filed => $value] + 'match_phrase' => [$filed => $value] + ]; + } + } + + $queryParams['body']['query']['bool']['must'] = $must; + + } + + if (!empty($this->queryParams['orlike'])) { + foreach ($this->queryParams['orlike'] as $key => $row) { + foreach ($row as $filed => $value) { + $orlike[] = [ + 'match_phrase' => [$filed => $value] + ]; + } + } + + $queryParams['body']['query']['bool']['must']['bool']['should'] = $orlike; + } + + if (!empty($this->queryParams['order'])) { + $queryParams['body']['sort'] = [ + key($this->queryParams['order']) => [ + 'order' => current($this->queryParams['order']) + ] + ]; + } + + $queryParams['body']['query']['bool']['filter'] = $filter; + + $this->queryParams = $queryParams; + + return $this; + + } + + + /** + * @param bool $isTotal isTotal=true时, 返回总数 + * @return array|string + */ + + public function query($isTotal = false) + { + try { + $this->parseQueryParams(); + + if ($this->debug) { + return \GuzzleHttp\json_encode($this->queryParams); + } + + if ($isTotal === true) { + + unset( + + $this->queryParams['from'], + + $this->queryParams['size'], + + $this->queryParams['_source'] + + ); + + $count = $this->client->count($this->queryParams); + + return (int)$count['count']; + + } + + if (!empty($this->queryParams)) { + + $result = $this->client->search($this->queryParams); + + if (!empty($result['hits']['hits'])) { + + $return = []; + + foreach ($result['hits']['hits'] as $row) { + + $return[] = $row['_source']; + + } + + return $return; + + } else { + + return []; + + } + + } + + } catch (\Exception $e) { + + $msg = $e->getMessage(); + + $msg = '服务器开小差了~'; + + throw new Exception($msg); + + } + } + + /** + * 添加文档 + * @param $id + * @param $doc ['id'=>100, 'title'=>'phone'] + * @param string $index_name + * @param string $type_name + */ + public function addDoc($id, $doc, string $index_name = 'gyx_ik', string $type_name = '_doc'): array + { + $params = [ + 'index' => $index_name, + 'type' => $type_name, + 'id' => $id, + 'body' => $doc + ]; + + return $this->client->index($params); + } + + public function getIndex() + { + return $this->index; + } + + /** + * 返回ES实例 + */ + + public static function setEs($index = '') + { + $class = get_called_class(); + if (!self::$instance || !self::$instance instanceof $class) { + self::$instance = new static(); + } + if ($index) { + self::$instance->index = $index; + } + return self::$instance; + + } + + protected function settings() + { + return [ + 'number_of_shards' => 1, + 'number_of_replicas' => 0 + ]; + } + + /** + * 判断文档存在 + * @param int $id + * @param string $index_name + * @param string $type_name + * @return bool + */ + public function existsDoc(int $id = 1, string $index_name = 'gyx_ik', string $type_name = '_doc'): bool + { + $params = [ + 'index' => $index_name, + 'type' => $type_name, + 'id' => $id + ]; + + return $this->client->exists($params); + + } + + /** + * 获取文档 + * @param int $id + * @param string $index_name + * @param string $type_name + * @return array + */ + public function getDoc(int $id = 1, string $index_name = 'gyx_ik', string $type_name = '_doc'): array + { + $params = [ + 'index' => $index_name, + 'type' => $type_name, + 'id' => $id + ]; + + return $this->client->get($params); + } + + /** + * 更新文档 + * @param int $id + * @param string $index_name + * @param string $type_name + * @param array $body + * @return array + */ + public function updateDoc(int $id = 1, array $body = [], string $index_name = 'gyx_ik', string $type_name = '_doc'): array + { + // 可以灵活添加新字段,最好不要乱添加 + $params = [ + 'index' => $index_name, + 'type' => $type_name, + 'id' => $id, + 'body' => $body + ]; + + return $this->client->update($params); + } + + + /** + * 搜索文档:分页,排序,权重,过滤 + * @param string $index_name + * @param string $type_name + * @param array $body + * @return array + */ + public function searchDoc(array $body = [], string $index_name = "goods_list", string $type_name = "_doc"): array + { + $params = [ + 'index' => $index_name, + 'type' => $type_name, + 'body' => $body + ]; + + return $this->client->search($params); + } + + /** + + * @return bool + + * @throws Exception + + */ + + public function createIndexNew($mapping) + { + try { + $params = [ + 'index' => $this->index + ]; + + $check = $this->indices()->exists($params); + + if ($check) { + throw new Exception('index: ' . $this->index . ' already exists'); + } + + $params = [ + 'index' => $this->index, + 'body' => [ + 'settings' => $this->settings(), + 'mappings' => [ + '_source' => [ + 'enabled' => true, + ], + 'properties' => $mapping + ] + ] + ]; + + $result = $this->indices()->create($params); + + return $result['acknowledged'] === true; + + } catch (\Exception $e) { + + throw new Exception($e->getMessage()); + + } + + } + + /** + + * 删除索引 + + * + + * @return bool + + * @throws Missing404Exception + + */ + + public function deleteIndexNew() + { + + try { + + $params = [ + + 'index' => $this->index + + ]; + + $check = $this->indices()->exists($params); + + if (!$check) { + + return true; + + } + + $result = $this->indices()->delete([ + + 'index' => $this->index + + ]); + + return $result['acknowledged'] === true; + + } catch (Missing404Exception $e) { + + throw new Missing404Exception('no such index ' . $this->index); + + } + + } + + /** + + * 批量写入 + + * type 1.增加/修改 2.删除 + + * $data = [ + + * ['id' => 1, 'name' => 'llf', 'age' => 30], + + * ['id' => 1, 'name' => 'llf', 'age' => 30], + + * ['id' => 1, 'name' => 'llf', 'age' => 30], + + * ['id' => 1, 'name' => 'llf', 'age' => 30], + + * ]; + + * @param array $data + + */ + + public function doBulkDocument($type = 1,$data = []) + + { + + try { + + $params = ['body' => []]; + + if($type == 1){ + + foreach ($data as $key => $row) { + + $params['body'][] = [ + + 'index' => [ + + '_index' => $this->index, + + '_id' => $row['info_id'].'-'.$row['info_type'] + + ] + + ]; + + $params['body'][] = $row; + + if (($key+1)%10000 == 0) { + + $this->client->bulk($params); + + $params = ['body' => []]; + + } + + } + + }else{ + + foreach ($data as $key => $row) { + + $params['body'][] = [ + + 'delete' => [ + + '_index' => $this->index, + + '_id' => $row['info_id'].'-'.$row['info_type'] + + ] + + ]; + + } + + } + + if (!empty($params['body'])) { + + $this->client->bulk($params); + + return true; + + } + + } catch (\Exception $e) { + + throw new Exception($e->getMessage()); + + } + + } + + /** + + * @return array @todo + + */ + + public function updateIndex() + + { + + $putParams = [ + + 'index' => $this->index, + + //'type' => '_doc', + + 'body' => [ + + 'properties' => $this->mappings() + + ] + + ]; + + return $this->indices()->putMapping($putParams); + + } + + /** + + * 方便调试, 直接返回拼接的query + + * @return $this + + */ + + public function setDebug() + + { + + $this->debug = true; + + return $this; + + } + + private function indices() + + { + + return $this->client->indices(); + + } + + public function analyze($text = '') + + { + + $params = [ + + 'index' => $this->index, + + 'body' => [ + + 'analyzer' => 'ik_smart', + + 'text' => $text + + ] + + ]; + + return $this->indices()->analyze($params); + + } + + public function update($id = 0, $updateParams = []) + + { + + $params = [ + + 'index' => $this->index, + + 'id' => $id, + + 'body' => [ + + 'doc' => $updateParams + + ] + + ]; + + return $this->client->update($params); + } +} diff --git a/app/common/model/Goods.php b/app/common/model/Goods.php index ee3459eb..db2b2822 100644 --- a/app/common/model/Goods.php +++ b/app/common/model/Goods.php @@ -208,7 +208,7 @@ class Goods extends BaseModel // 执行查询 $list = $query ->alias($this->name) - ->field(['goods.goods_id', 'goods.goods_name', 'cmmdty_model', 'remark', 'cost_price_min', 'stock_total', 'is_check', 'goods_price_min','goods_no','goods_source','delivery_time','delivery_id','status','link','link_other']) + ->field(['goods.goods_id', 'goods.goods_name', 'cmmdty_model', 'remark', 'cost_price_min', 'stock_total', 'is_check', 'goods_price_min','goods_no','goods_source','delivery_time','delivery_id','status','link','link_other','channel']) ->where('is_delete', '=', 0) ->order($sort) ->paginate($listRows); @@ -254,7 +254,13 @@ class Goods extends BaseModel ->paginate($listRows); // 整理列表数据并返回 - return $this->setGoodsListData($list); + + foreach ($list as &$goods) { + $goods['dic'] = 'admin'; + $goods = $this->setGoodsData($goods, null); + } + return $list; + //return $this->setGoodsListData($list); } /** @@ -272,17 +278,26 @@ class Goods extends BaseModel // 设置显示的销量 goods_sales $query->field(['(sales_initial + sales_actual) as goods_sales', '(line_price_max - goods_price_min) as discount']); // 排序条件 - $sort = $this->setQuerySort($param); + $sort1 = $this->setQuerySort($param); + // var_dump($sort); + // exit(); $order = request()->get()['order'] ?? ''; $sort = request()->get()['sort'] ?? ''; + //商家端商品列表排序 if ($order && $sort) { $sort = [ $sort => $order, ]; } else { - $sort = [ - $this->getPk() => 'desc', - ]; + //小程序前台商品排序 + if ($sort1) { + $sort = $sort1; + } else { + $sort = [ + $this->getPk() => 'desc', + ]; + } + } // if (!empty($order)) { // if ($order == 1) { @@ -347,6 +362,7 @@ class Goods extends BaseModel ->field($field) ->where('is_delete', '=', 0) ->where($str) + ->group("goods.goods_id") ->order($sort) ->paginate($listRows); } else { @@ -355,6 +371,7 @@ class Goods extends BaseModel ->alias($this->name) ->field($field) ->where('is_delete', '=', 0) + ->group("goods.goods_id") ->order($sort) ->paginate($listRows); } @@ -448,12 +465,15 @@ class Goods extends BaseModel $params['status'] > 0 && $filter[] = ['status', '=', (int)$params['status']]; $a = 1; // 商品分类 - if ($params['categoryId'] > 0) { + if ($params['categoryId'] > 0 || (isset($params['fliter_condition']) && $params['fliter_condition'])) { // 关联商品与分类关系记录表 $GoodsCategoryRelName = (new GoodsCategoryRelModel())->getName(); $query->join($GoodsCategoryRelName, "{$GoodsCategoryRelName}.goods_id = {$this->name}.goods_id"); - // 设置分类ID条件 - $query->where('goods_category_rel.category_id', 'in', explode(",", (string)$params['categoryId'])); + if ($params['categoryId'] > 0) { + // 设置分类ID条件 + $query->where('goods_category_rel.category_id', 'in', explode(",", (string)$params['categoryId'])); + } + } if (isset($param['goodsIds']) && $param['goodsIds'] !== '') { @@ -589,13 +609,21 @@ class Goods extends BaseModel protected function setGoodsData($goodsInfo, callable $callback = null) { $channel = Channel::withoutGlobalScope()->where('code', $goodsInfo['channel'])->find(); - $goodsInfo['channel_name'] = $channel['alias'] ?? ""; + if (isset($goodsInfo['dic']) && $goodsInfo['dic'] == 'admin') { + $goodsInfo['channel_name'] = (isset($channel['name'])&& $channel['name']) ? $channel['alias']."-".$channel['name'] : ""; + } else { + $goodsInfo['channel_name'] = $channel['alias'] ?? ""; + } + $goodsInfo['goods_images'] = helper::getArrayColumn($goodsInfo['images'], 'file'); // 商品主图 $goodsInfo['goods_image'] = $goodsInfo['goods_images'] ? current($goodsInfo['goods_images'])['preview_url'] : ""; // 商品销量(实际显示=初始虚拟销量+实际销量) $goodsInfo['goods_sales'] = $goodsInfo['sales_initial'] + $goodsInfo['sales_actual']; + if (in_array($goodsInfo['channel'], ['sn','sn1']) && $goodsInfo['link_other']) { + $goodsInfo['link'] = $goodsInfo['link_other']; + } // //商品价格判断 // if (UserService::isLogin()) { // if (UserService::isStore()) {//店主 diff --git a/app/common/model/sharp/Goods.php b/app/common/model/sharp/Goods.php index a58523f2..084920a2 100644 --- a/app/common/model/sharp/Goods.php +++ b/app/common/model/sharp/Goods.php @@ -112,7 +112,7 @@ class Goods extends BaseModel $item['goods_image'] = !empty($item['goods']['goods_image']) ? $item['goods']['goods_image'] : ''; // 秒杀商品原价 (获取主商品价格) //$item['original_price'] = !empty($item['goods']['original_price']) ? $item['goods']['original_price']: $item['goods']['goods_price_min']; - $item['original_price'] = !empty($item['goods']['original_price']) ?? $item['goods']['goods_price_min']; + $item['original_price'] = isset($item['goods']['original_price']) ? $item['goods']['original_price'] : $item['goods']['goods_price_min']; // 回调函数 is_callable($callback) && call_user_func($callback, $item); } diff --git a/app/common/service/GoodsEs.php b/app/common/service/GoodsEs.php new file mode 100644 index 00000000..f5106e6f --- /dev/null +++ b/app/common/service/GoodsEs.php @@ -0,0 +1,163 @@ +esService = Client::setEs('goods_List'); + } + + /** + * 查询商品列表 + * @param $params + * @return + */ + public function list($params) + { + $page = 1; + $limit = 10; + $body = [ + 'query' => [ + 'match_all' => [] + ], + 'from' => ($page - 1) * $limit, + 'size' => $limit, + 'sort' => [ + 'id' => [ + 'order' => 'desc' + ] + ] + ]; + + return $this->esService + ->equal(['title' => 1]) + ->from(0) + ->size(10) + ->order(['id' => 'desc']) + ->query($body); + } + + + + + /** + * 更新商品 + */ + public function update($goods_id) + { + $goods_id = 1; + $doc = [ + 'id' => $goods_id, + 'video_title' => '少爷的甜蜜良药', + 'director' => '吴宇森', + 'intro' => '吴宇森导演的《少爷的甜蜜良药》是吴宇森导演的经典作品,讲述了一个boyfriend和girlfriend的故事,boyfriend因为工作原因,被拒了girlfriend的offer,然后boyfriend和girlfriend一起去一个地方,然后boyfriend和girlfriend', + 'cover' => 'https://oss-duanju-file.luochen.com/cover/202404/62249c6a-5f57-45cf-90ac-be6de5890ce0.jpg?x-oss-process=image/resize,m_fixed,h_400,w_360', + 'episode_count' => '12', + 'wechat_vid' => 'wx_vid_1', + 'duration' => '01:02:03', + 'service_types' => '2,3', + ]; + $res = $this->esService->updateDoc($goods_id, $doc); + var_dump($res); + } + + /** + * 查询商品详情 + */ + public function detail($goods_id) + { + $goods_id = 1; + $res = $this->esService->getDoc($goods_id); + var_dump($res); + } + + + /** + * 创建商品 + * @return + */ + public function create($goods_id) + { + $goods_id = 1; + $doc = [ + 'id' => $goods_id, + 'video_title' => '少爷的甜蜜良药', + 'director' => '吴宇森', + 'intro' => '吴宇森导演的《少爷的甜蜜良药》是吴宇森导演的经典作品,讲述了一个boyfriend和girlfriend的故事,boyfriend因为工作原因,被拒了girlfriend的offer,然后boyfriend和girlfriend一起去一个地方,然后boyfriend和girlfriend', + 'cover' => 'https://oss-duanju-file.luochen.com/cover/202404/62249c6a-5f57-45cf-90ac-be6de5890ce0.jpg?x-oss-process=image/resize,m_fixed,h_400,w_360', + 'episode_count' => '12', + 'wechat_vid' => 'wx_vid_1', + 'duration' => '01:02:03', + 'service_types' => '2,3', + ]; + $res = $this->esService->addDoc($goods_id, $doc); + var_dump($res); + } + + /** + * 删除商品 + */ + public function delete($goods_id) + { + $res = $this->esService->deleteDoc($goods_id); + var_dump($res); + } + + + + /** + * 创建商品Index + * @return void + * @throws Exception + */ + function createGoodsIndex() + { + $mapping = [ + 'properties' => [ + 'goods_id' => [ + 'type' => 'integer' + ], + 'goods_type' => [ + 'type' => 'keyword' + ], + 'director' => [ + 'type' => 'text', + "analyzer" => "ik_smart" + ], + 'intro' => [ + 'type' => 'text', + "analyzer" => "ik_smart" + ], + 'cover' => [ + 'type' => 'keyword' + ], + 'episode_count' => [ + 'type' => 'keyword' + ], + 'wechat_vid' => [ + 'type' => 'keyword' + ], + 'duration' => [ + 'type' => 'keyword' + ], + 'service_types' => [ + 'type' => 'keyword' + ], + ] + ]; + + $res = $this->esService->createIndex($this->index_name, $mapping); + var_dump($res); + } + + + +} \ No newline at end of file diff --git a/app/job/controller/goods/GoodsAddPrice.php b/app/job/controller/goods/GoodsAddPrice.php new file mode 100644 index 00000000..c3d24f2c --- /dev/null +++ b/app/job/controller/goods/GoodsAddPrice.php @@ -0,0 +1,49 @@ + +// +---------------------------------------------------------------------- +declare (strict_types=1); + +namespace app\job\controller\goods; + +use app\job\service\goods\GoodsAddPrice as GoodsAddPriceService; +use cores\BaseJob; +use cores\traits\QueueTrait; +use cores\exception\BaseException; +use think\db\exception\DataNotFoundException; +use think\db\exception\DbException; +use think\db\exception\ModelNotFoundException; + +/** + * 队列任务:商品批量导入 + * Class Import + * @package app\job\controller + */ +class GoodsAddPrice extends BaseJob +{ + use QueueTrait; + + /** + * 消费队列任务:商品导入 + * @param array $data 参数 [index队列顺序;totalCount商品总数量;list商品列表;storeId商城ID] + * @return bool 返回结果 + * @throws BaseException + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException + */ + public function handle(array $data): bool + { + $time = date('H:i:s'); + echo "\n ---- GoodsAddPrice ---- {$time} ---- \n"; + + $service = new GoodsAddPriceService; + return $service->batch($data['list'], $data['rate']); + } +} \ No newline at end of file diff --git a/app/job/service/goods/Collector.php b/app/job/service/goods/Collector.php index b59078f1..62fdc707 100644 --- a/app/job/service/goods/Collector.php +++ b/app/job/service/goods/Collector.php @@ -260,7 +260,8 @@ class Collector extends BaseService $original['cost_price'] = $form['cost_price_min']; $data['link_other'] = $url; - $data['goods_no'] = $original['goods_sku_no']; + + $data['content'] = $original['content']; //重新计算利润和利润率 @@ -285,6 +286,7 @@ class Collector extends BaseService ]; //新阙通信的数据 if ($goods->channel == "xqtx") { + $data['goods_no'] = $original['goods_sku_no']; //goods $data['stock_total'] = $form['stock_total']; $data['goods_name'] = $original['goods_name']; @@ -294,11 +296,15 @@ class Collector extends BaseService $profit_rate = (float)$original['goods_price'] > 0 ? ($original['goods_price'] - $original['cost_price']) / $original['goods_price'] : 0.00; $profit_rate = $profit_rate > 0.0001 ? bcmul((string)$profit_rate, "100", 2) : 0.00; $data['profit_rate'] = $profit_rate; + $data['link'] = $data['link_other']; unset($data['link_other']); //sku $goodsSku['stock_num'] = $form['stock_total']; //unset($goodsSku['goods_price']); + } else { + //京东价拖 + $data['goods_no_other'] = $original['goods_sku_no']; } // var_dump($data); // var_dump($goodsSku); diff --git a/app/job/service/goods/GoodsAddPrice.php b/app/job/service/goods/GoodsAddPrice.php new file mode 100644 index 00000000..dabd7ded --- /dev/null +++ b/app/job/service/goods/GoodsAddPrice.php @@ -0,0 +1,99 @@ + +// +---------------------------------------------------------------------- +declare (strict_types=1); + +namespace app\job\service\goods; + +use app\common\library\helper; +use app\common\service\BaseService; +use app\common\model\Goods as GoodsModel; +use app\common\model\GoodsSku; +use app\store\model\GoodsCategoryRel; +use cores\exception\BaseException; +use think\facade\Log; +use app\common\model\Channel; +use app\common\model\Region; +/** + * 服务类:商品批量导入 + * Class Import + * @package app\job\service\goods + */ +class GoodsAddPrice extends BaseService +{ + /** + * 批量导入商品 + * @param array $list + * @param int $recordId + * @param int $storeId + * @return bool + * @throws BaseException + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function batch(array $goods, int $rate): bool + { + // ini_set('memory_limit', '1024M'); + // set_time_limit(0); + // $goods = GoodsModel::alias('g') + // ->join('goods_category_rel c', 'g.goods_id = c.goods_id') + // ->where('c.store_id',0) + // ->where('g.is_delete',0) + // ->whereIn('c.category_id', $categoryIds) + // ->whereIn('g.channel',$channels) + // ->order("g.goods_id asc") + // ->select() + // ->toArray(); + if (!$goods) { + return true; + } + //更新总后台当前商品的价格 + GoodsModel::whereIn('goods_id', array_column($goods, "goods_id"))->update(['markup_rate' => $rate, 'update_time' => time()]); + foreach ($goods as $key => $value) { + //更新origin_goods_id为当前商品id的价格 + $goods_list = GoodsModel::where('origin_goods_id', $value['goods_id']) + ->where('is_delete', 0) + ->field(['goods_id','cost_price_min','goods_price_min','markup_rate']) + ->select() + ->toArray(); + + if (!$goods_list) { + continue; + } + $item = $goods_list[0]; + // if ($item['markup_rate'] > 0) { + // $item['cost_price_min'] = round($item['cost_price_min'] * (1 - ($rate / 100)), 0); + // } + $item['cost_price_min'] = $value['cost_price_min'];//设置原始数据的成本价 + $cost_price = round($item['cost_price_min'] / (1 - ($rate / 100)), 0); + $profit = (float)$item['goods_price_min'] - (float)$cost_price; + $profit_rate = (float)$item['goods_price_min'] > 0 ? bcmul((string)($profit / (float)$item['goods_price_min']) , (string)100, 2) : 0.00; + $goodsData = [ + 'cost_price_min' => $cost_price, + 'profit_rate' => $profit_rate, + 'profit' => $profit, + 'markup_rate' => $rate, + 'update_time' => time() + ]; + GoodsModel::whereIn('goods_id', array_column($goods_list, "goods_id"))->update($goodsData); + $goodsSkuData = [ + 'cost_price' => $cost_price, + 'update_time' => time() + ]; + GoodsSku::whereIn('goods_id', array_column($goods_list, "goods_id"))->update($goodsSkuData); + + } + + return true; + } + + +} \ No newline at end of file diff --git a/app/store/controller/Goods.php b/app/store/controller/Goods.php index 850a5f9d..d42db05c 100644 --- a/app/store/controller/Goods.php +++ b/app/store/controller/Goods.php @@ -207,12 +207,24 @@ class Goods extends Controller $params['store_id'] = $this->storeId; $perSize = 10000; $params['page'] = 1; - $params['channels'] = ['zy']; + //$params['channels'] = ['zy']; + // echo ""; + // print_r($params); + //exit(); $data = $model->getAdminListExport($params, $perSize)->toArray(); // echo ""; // print_r($data['data']); + // exit(); if ($data['data']) { foreach ($data['data'] as &$value) { + if (!in_array($value['channel'], ['zy'])) { + $value['goods_price_min'] = self::$show_content; + $value['goods_price_max'] = self::$show_content; + $value['line_price_max'] = self::$show_content; + $value['line_price_min'] = self::$show_content; + $value['cost_price_min'] = self::$show_content; + $value['goods_no'] = self::$show_content; + } $cates = GoodsCategoryRel::where('goods_id', $value['goods_id'])->select()->toArray(); $value['category_id'] = $cates ? implode(",", array_column($cates, "category_id")) : ""; } diff --git a/app/store/model/goods/Import.php b/app/store/model/goods/Import.php index 15ef06a6..e5927c1a 100644 --- a/app/store/model/goods/Import.php +++ b/app/store/model/goods/Import.php @@ -231,28 +231,48 @@ class Import extends ImportModel self::$storeId = $form['store_id'] ?? 0; foreach ($execlData as $key => $value) { + $upData = [ 'goods_name'=> $value['B'], 'cmmdty_model'=> $value['C'], 'goods_source'=> $value['D'], - 'goods_no'=> $value['E'], + //'goods_no'=> $value['E'], 'delivery_time'=> $value['G'], 'is_check'=> $value['H'], 'delivery_id'=> $value['I'], 'status'=> $value['J'], - 'cost_price_min'=> $value['K'], - 'goods_price_min'=> $value['L'], - 'goods_price_max'=> $value['L'], - 'line_price_min'=> $value['L'], - 'line_price_max'=> $value['L'], + // 'cost_price_min'=> $value['K'], + // 'goods_price_min'=> $value['L'], + // 'goods_price_max'=> $value['L'], + // 'line_price_min'=> $value['L'], + // 'line_price_max'=> $value['L'], 'stock_total'=> $value['M'], 'remark'=> $value['N'], ]; + $goods = GoodsModel::where('goods_id', $value['A'])->find(); + if (!$goods) { + continue; + } + //自营数据才能更新价格 + if (in_array($goods['channel'], ['zy'])) { + $upData['goods_no'] = $value['E']; + $upData['cost_price_min'] = $value['K']; + $upData['goods_price_min' ]= $value['L']; + $upData['goods_price_max'] = $value['L']; + $upData['line_price_min'] = $value['L']; + $upData['line_price_max'] = $value['L']; + $profit = (float)$upData['goods_price_min'] - (float)$upData['cost_price_min']; + $profit_rate = (float)$upData['goods_price_min'] > 0 ? bcmul(bcdiv((string)$profit, (string)$upData['goods_price_min'], 2), (string)100, 2) : 0.00; + $upData['profit'] = $profit; + $upData['profit_rate'] = $profit_rate; + GoodsSkuModel::where('goods_id', $value['A'])->update(['cost_price' => $value['K'], 'goods_price' => $value['L']]); + } + // echo ""; // print_r(explode(",", $value['F'])); // exit(); GoodsModel::where('goods_id', $value['A'])->update($upData); - GoodsSkuModel::where('goods_id', $value['A'])->update(['cost_price' => $value['K'], 'goods_price' => $value['L']]); + GoodsCategoryRelModel::updates((int)$value['A'], explode(",", $value['F'])); } return true; diff --git a/composer.json b/composer.json index d87578df..71f1ccae 100644 --- a/composer.json +++ b/composer.json @@ -53,7 +53,8 @@ "overtrue/easy-sms": "^2.0", "overtrue/wechat": "~4.0", "alipaysdk/easysdk": "^2.2", - "wechatpay/wechatpay": "^1.4" + "wechatpay/wechatpay": "^1.4", + "elasticsearch/elasticsearch": "v8.6.0" }, "require-dev": { "symfony/var-dumper": "^4.2" diff --git a/composer.lock b/composer.lock index 2059ec81..f0edd536 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "6a7996d88fd82c5b30b1a2ce37fdcce9", + "content-hash": "b5ed7820a7c4b5d436edd224b891a3ba", "packages": [ { "name": "adbario/php-dot-notation", @@ -432,6 +432,117 @@ }, "time": "2021-07-05T04:03:22+00:00" }, + { + "name": "elastic/transport", + "version": "v8.8.0", + "source": { + "type": "git", + "url": "https://github.com/elastic/elastic-transport-php.git", + "reference": "cdf9f63a16ec6bfb4c881ab89aa0e2a61fb7c20b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/elastic/elastic-transport-php/zipball/cdf9f63a16ec6bfb4c881ab89aa0e2a61fb7c20b", + "reference": "cdf9f63a16ec6bfb4c881ab89aa0e2a61fb7c20b", + "shasum": "" + }, + "require": { + "composer-runtime-api": "^2.0", + "php": "^7.4 || ^8.0", + "php-http/discovery": "^1.14", + "php-http/httplug": "^2.3", + "psr/http-client": "^1.0", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.0 || ^2.0", + "psr/log": "^1 || ^2 || ^3" + }, + "require-dev": { + "nyholm/psr7": "^1.5", + "php-http/mock-client": "^1.5", + "phpstan/phpstan": "^1.4", + "phpunit/phpunit": "^9.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Elastic\\Transport\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "HTTP transport PHP library for Elastic products", + "keywords": [ + "PSR_17", + "elastic", + "http", + "psr-18", + "psr-7", + "transport" + ], + "support": { + "issues": "https://github.com/elastic/elastic-transport-php/issues", + "source": "https://github.com/elastic/elastic-transport-php/tree/v8.8.0" + }, + "time": "2023-11-08T10:51:51+00:00" + }, + { + "name": "elasticsearch/elasticsearch", + "version": "v8.6.0", + "source": { + "type": "git", + "url": "https://github.com/elastic/elasticsearch-php.git", + "reference": "03b145a3fd1dc984d7c2c79638c9257b1a17f8b7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/elastic/elasticsearch-php/zipball/03b145a3fd1dc984d7c2c79638c9257b1a17f8b7", + "reference": "03b145a3fd1dc984d7c2c79638c9257b1a17f8b7", + "shasum": "" + }, + "require": { + "elastic/transport": "^8.5", + "guzzlehttp/guzzle": "^7.0", + "php": "^7.4 || ^8.0", + "psr/http-client": "^1.0", + "psr/http-message": "^1.0", + "psr/log": "^1|^2|^3" + }, + "require-dev": { + "ext-yaml": "*", + "ext-zip": "*", + "mockery/mockery": "^1.5", + "nyholm/psr7": "^1.5", + "php-http/mock-client": "^1.5", + "phpstan/phpstan": "^1.4", + "phpunit/phpunit": "^9.5", + "symfony/finder": "~4.0", + "symfony/http-client": "^5.0|^6.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Elastic\\Elasticsearch\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHP Client for Elasticsearch", + "keywords": [ + "client", + "elastic", + "elasticsearch", + "search" + ], + "support": { + "issues": "https://github.com/elastic/elasticsearch-php/issues", + "source": "https://github.com/elastic/elasticsearch-php/tree/v8.6.0" + }, + "time": "2022-10-18T13:38:48+00:00" + }, { "name": "ezyang/htmlpurifier", "version": "v4.14.0", @@ -1983,6 +2094,194 @@ "abandoned": "w7corp/easywechat", "time": "2021-12-27T13:56:47+00:00" }, + { + "name": "php-http/discovery", + "version": "1.19.4", + "source": { + "type": "git", + "url": "https://github.com/php-http/discovery.git", + "reference": "0700efda8d7526335132360167315fdab3aeb599" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/discovery/zipball/0700efda8d7526335132360167315fdab3aeb599", + "reference": "0700efda8d7526335132360167315fdab3aeb599", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0|^2.0", + "php": "^7.1 || ^8.0" + }, + "conflict": { + "nyholm/psr7": "<1.0", + "zendframework/zend-diactoros": "*" + }, + "provide": { + "php-http/async-client-implementation": "*", + "php-http/client-implementation": "*", + "psr/http-client-implementation": "*", + "psr/http-factory-implementation": "*", + "psr/http-message-implementation": "*" + }, + "require-dev": { + "composer/composer": "^1.0.2|^2.0", + "graham-campbell/phpspec-skip-example-extension": "^5.0", + "php-http/httplug": "^1.0 || ^2.0", + "php-http/message-factory": "^1.0", + "phpspec/phpspec": "^5.1 || ^6.1 || ^7.3", + "sebastian/comparator": "^3.0.5 || ^4.0.8", + "symfony/phpunit-bridge": "^6.4.4 || ^7.0.1" + }, + "type": "composer-plugin", + "extra": { + "class": "Http\\Discovery\\Composer\\Plugin", + "plugin-optional": true + }, + "autoload": { + "psr-4": { + "Http\\Discovery\\": "src/" + }, + "exclude-from-classmap": [ + "src/Composer/Plugin.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations", + "homepage": "http://php-http.org", + "keywords": [ + "adapter", + "client", + "discovery", + "factory", + "http", + "message", + "psr17", + "psr7" + ], + "support": { + "issues": "https://github.com/php-http/discovery/issues", + "source": "https://github.com/php-http/discovery/tree/1.19.4" + }, + "time": "2024-03-29T13:00:05+00:00" + }, + { + "name": "php-http/httplug", + "version": "2.4.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/httplug.git", + "reference": "625ad742c360c8ac580fcc647a1541d29e257f67" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/httplug/zipball/625ad742c360c8ac580fcc647a1541d29e257f67", + "reference": "625ad742c360c8ac580fcc647a1541d29e257f67", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0", + "php-http/promise": "^1.1", + "psr/http-client": "^1.0", + "psr/http-message": "^1.0 || ^2.0" + }, + "require-dev": { + "friends-of-phpspec/phpspec-code-coverage": "^4.1 || ^5.0 || ^6.0", + "phpspec/phpspec": "^5.1 || ^6.0 || ^7.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Http\\Client\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Eric GELOEN", + "email": "geloen.eric@gmail.com" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://sagikazarmark.hu" + } + ], + "description": "HTTPlug, the HTTP client abstraction for PHP", + "homepage": "http://httplug.io", + "keywords": [ + "client", + "http" + ], + "support": { + "issues": "https://github.com/php-http/httplug/issues", + "source": "https://github.com/php-http/httplug/tree/2.4.0" + }, + "time": "2023-04-14T15:10:03+00:00" + }, + { + "name": "php-http/promise", + "version": "1.3.1", + "source": { + "type": "git", + "url": "https://github.com/php-http/promise.git", + "reference": "fc85b1fba37c169a69a07ef0d5a8075770cc1f83" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/promise/zipball/fc85b1fba37c169a69a07ef0d5a8075770cc1f83", + "reference": "fc85b1fba37c169a69a07ef0d5a8075770cc1f83", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "friends-of-phpspec/phpspec-code-coverage": "^4.3.2 || ^6.3", + "phpspec/phpspec": "^5.1.2 || ^6.2 || ^7.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "Http\\Promise\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Joel Wurtz", + "email": "joel.wurtz@gmail.com" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "Promise used for asynchronous HTTP requests", + "homepage": "http://httplug.io", + "keywords": [ + "promise" + ], + "support": { + "issues": "https://github.com/php-http/promise/issues", + "source": "https://github.com/php-http/promise/tree/1.3.1" + }, + "time": "2024-03-15T13:55:21+00:00" + }, { "name": "phpoffice/phpspreadsheet", "version": "1.22.0", diff --git a/config/console.php b/config/console.php index d64e0746..09465dc3 100644 --- a/config/console.php +++ b/config/console.php @@ -12,5 +12,6 @@ return [ 'CalDealerTime' => 'app\command\CalDealerTime', 'UpdateCollectGoodsPrice' => 'app\command\UpdateCollectGoodsPrice', 'SyncStoreBasicData' => 'app\command\SyncStoreBasicData', + 'syncGoodsToEs' => 'app\command\SyncGoodsToEs', ], ]; diff --git a/config/log.php b/config/log.php index 0bdb0303..6fe24583 100644 --- a/config/log.php +++ b/config/log.php @@ -7,7 +7,7 @@ return [ // 默认日志记录通道 'default' => env('log.channel', 'file'), // 日志记录级别 - 'level' => [], + 'level' => ['error', 'sql', 'info'], // 日志类型记录的通道 ['error'=>'email',...] 'type_channel' => [], // 关闭全局日志写入 diff --git a/config/queue.php b/config/queue.php index 7982d77c..52900d43 100644 --- a/config/queue.php +++ b/config/queue.php @@ -27,7 +27,7 @@ return [ 'host' => env('redis.hostname', '127.0.0.1'), 'port' => env('redis.hostport', '6379'), 'password' => env('redis.password', ''), - 'select' => env('redis.select', '0'), + 'select' => 1,//env('redis.select', '0'), 'timeout' => 0, 'persistent' => false, 'retry_after' => 60, // 队列任务无响应时(例如die exit)重试的间隔时间, 默认60秒 diff --git a/vendor/services.php b/vendor/services.php index 846f604f..face640b 100755 --- a/vendor/services.php +++ b/vendor/services.php @@ -1,6 +1,6 @@ - 'think\\app\\Service', 1 => 'think\\queue\\Service',