From d9a0c0049ba86bf7135f7f7a768e4ffa5b7a6c41 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 23 Jan 2024 17:31:23 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/Demo.php | 88 +++++++++---------- .../api/store/order/StoreProcessing.php | 4 +- 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/app/controller/api/Demo.php b/app/controller/api/Demo.php index a3c0401f..68b95bae 100644 --- a/app/controller/api/Demo.php +++ b/app/controller/api/Demo.php @@ -50,75 +50,75 @@ class Demo extends BaseController // // Queue::push(ProductCopyJob::class, ['product_id' => $item['product_id']]);//短信通知 // } - $arr=[ - ['product_id'=>171650,], - ['product_id'=>171649,], - ['product_id'=>171648,], - ['product_id'=>171647], - ]; - $mer_id=167;//导入到的商户 - $street_code=510521107;//导入到的商户 - $type_id=17;//导入到的商户分类 - $category_id=2566;//导入到的商户分类 - foreach($arr as $k=>$v){ - Queue::push(ProductCopyJob::class, ['product_id' => $v['product_id'], 'mer_id' =>$mer_id,'street_code'=>$street_code,'type_id'=>$type_id,'category_id'=>$category_id]);//短信通知 + $arr = [ + ['product_id' => 171650,], + ['product_id' => 171649,], + ['product_id' => 171648,], + ['product_id' => 171647], + ]; + $mer_id = 167; //导入到的商户 + $street_code = 510521107; //导入到的商户 + $type_id = 17; //导入到的商户分类 + $category_id = 2566; //导入到的商户分类 + foreach ($arr as $k => $v) { + Queue::push(ProductCopyJob::class, ['product_id' => $v['product_id'], 'mer_id' => $mer_id, 'street_code' => $street_code, 'type_id' => $type_id, 'category_id' => $category_id]); //短信通知 } - $mer_id=236;//导入到的商户 - $street_code=510521123;//导入到的商户 - foreach($arr as $k=>$v){ - Queue::push(ProductCopyJob::class, ['product_id' => $v['product_id'], 'mer_id' =>$mer_id,'street_code'=>$street_code,'type_id'=>$type_id,'category_id'=>$category_id]);//短信通知 + $mer_id = 236; //导入到的商户 + $street_code = 510521123; //导入到的商户 + foreach ($arr as $k => $v) { + Queue::push(ProductCopyJob::class, ['product_id' => $v['product_id'], 'mer_id' => $mer_id, 'street_code' => $street_code, 'type_id' => $type_id, 'category_id' => $category_id]); //短信通知 } - $mer_id=237;//导入到的商户 - $street_code=510521115;//导入到的商户 + $mer_id = 237; //导入到的商户 + $street_code = 510521115; //导入到的商户 - foreach($arr as $k=>$v){ - Queue::push(ProductCopyJob::class, ['product_id' => $v['product_id'], 'mer_id' =>$mer_id,'street_code'=>$street_code,'type_id'=>$type_id,'category_id'=>$category_id]);//短信通知 + foreach ($arr as $k => $v) { + Queue::push(ProductCopyJob::class, ['product_id' => $v['product_id'], 'mer_id' => $mer_id, 'street_code' => $street_code, 'type_id' => $type_id, 'category_id' => $category_id]); //短信通知 } - $mer_id=238;//导入到的商户 - $street_code=510521105;//导入到的商户 + $mer_id = 238; //导入到的商户 + $street_code = 510521105; //导入到的商户 - foreach($arr as $k=>$v){ - Queue::push(ProductCopyJob::class, ['product_id' => $v['product_id'], 'mer_id' =>$mer_id,'street_code'=>$street_code,'type_id'=>$type_id,'category_id'=>$category_id]);//短信通知 + foreach ($arr as $k => $v) { + Queue::push(ProductCopyJob::class, ['product_id' => $v['product_id'], 'mer_id' => $mer_id, 'street_code' => $street_code, 'type_id' => $type_id, 'category_id' => $category_id]); //短信通知 } - $mer_id=239;//导入到的商户 - $street_code=510521116;//导入到的商户 + $mer_id = 239; //导入到的商户 + $street_code = 510521116; //导入到的商户 - foreach($arr as $k=>$v){ - Queue::push(ProductCopyJob::class, ['product_id' => $v['product_id'], 'mer_id' =>$mer_id,'street_code'=>$street_code,'type_id'=>$type_id,'category_id'=>$category_id]);//短信通知 + foreach ($arr as $k => $v) { + Queue::push(ProductCopyJob::class, ['product_id' => $v['product_id'], 'mer_id' => $mer_id, 'street_code' => $street_code, 'type_id' => $type_id, 'category_id' => $category_id]); //短信通知 } //江阳 - $mer_id=31;//导入到的商户 - $street_code=510502108;//导入到的商户 + $mer_id = 31; //导入到的商户 + $street_code = 510502108; //导入到的商户 - foreach($arr as $k=>$v){ - Queue::push(ProductCopyJob::class, ['product_id' => $v['product_id'], 'mer_id' =>$mer_id,'street_code'=>$street_code,'type_id'=>$type_id,'category_id'=>$category_id]);//短信通知 + foreach ($arr as $k => $v) { + Queue::push(ProductCopyJob::class, ['product_id' => $v['product_id'], 'mer_id' => $mer_id, 'street_code' => $street_code, 'type_id' => $type_id, 'category_id' => $category_id]); //短信通知 } - $mer_id=32;//导入到的商户 - $street_code=510502107;//导入到的商户 + $mer_id = 32; //导入到的商户 + $street_code = 510502107; //导入到的商户 - foreach($arr as $k=>$v){ - Queue::push(ProductCopyJob::class, ['product_id' => $v['product_id'], 'mer_id' =>$mer_id,'street_code'=>$street_code,'type_id'=>$type_id,'category_id'=>$category_id]);//短信通知 + foreach ($arr as $k => $v) { + Queue::push(ProductCopyJob::class, ['product_id' => $v['product_id'], 'mer_id' => $mer_id, 'street_code' => $street_code, 'type_id' => $type_id, 'category_id' => $category_id]); //短信通知 } - $mer_id=118;//导入到的商户 - $street_code=510502106;//导入到的商户 + $mer_id = 118; //导入到的商户 + $street_code = 510502106; //导入到的商户 - foreach($arr as $k=>$v){ - Queue::push(ProductCopyJob::class, ['product_id' => $v['product_id'], 'mer_id' =>$mer_id,'street_code'=>$street_code,'type_id'=>$type_id,'category_id'=>$category_id]);//短信通知 + foreach ($arr as $k => $v) { + Queue::push(ProductCopyJob::class, ['product_id' => $v['product_id'], 'mer_id' => $mer_id, 'street_code' => $street_code, 'type_id' => $type_id, 'category_id' => $category_id]); //短信通知 } - $mer_id=39;//导入到的商户 - $street_code=510502105;//导入到的商户 + $mer_id = 39; //导入到的商户 + $street_code = 510502105; //导入到的商户 - foreach($arr as $k=>$v){ - Queue::push(ProductCopyJob::class, ['product_id' => $v['product_id'], 'mer_id' =>$mer_id,'street_code'=>$street_code,'type_id'=>$type_id,'category_id'=>$category_id]);//短信通知 + foreach ($arr as $k => $v) { + Queue::push(ProductCopyJob::class, ['product_id' => $v['product_id'], 'mer_id' => $mer_id, 'street_code' => $street_code, 'type_id' => $type_id, 'category_id' => $category_id]); //短信通知 } } diff --git a/app/controller/api/store/order/StoreProcessing.php b/app/controller/api/store/order/StoreProcessing.php index fa4c0c37..66c7a46b 100644 --- a/app/controller/api/store/order/StoreProcessing.php +++ b/app/controller/api/store/order/StoreProcessing.php @@ -66,8 +66,8 @@ class StoreProcessing extends BaseController // 'mer_id' => $order['mer_id'], // 'financial_record_sn' => $financeSn . '2' // ]; - unset($order['order_id'], $order['orderProduct'], $order['user'], $order['supply_chain_rate'], $order['logistics_code'], $order['logistics_phone']); - $order_id = Db::name('store_order_other')->insertGetId($order); + unset($order['order_id'], $order['orderProduct'], $order['user'], $order['supply_chain_rate'], $order['logistics_code'], $order['logistics_phone'],$order['consumption_money']); + $order_id = Db::name('store_order_other')->strict(false)->insertGetId($order); foreach ($arr as $key => $value) { $arr[$key]['order_id'] = $order_id; From 93edb83ba37b9bed2ac9a2f30fcb80093d0dd409 Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Tue, 23 Jan 2024 17:46:39 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BA=91=E4=BB=93?= =?UTF-8?q?=E5=95=86=E5=93=81=E5=88=97=E8=A1=A8=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/dao/store/product/SpuDao.php | 9 ++++++++- app/common/repositories/store/product/SpuRepository.php | 4 ++++ app/controller/api/store/product/CloudWarehouse.php | 9 +++------ 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/app/common/dao/store/product/SpuDao.php b/app/common/dao/store/product/SpuDao.php index 2470a86b..0ff7eda5 100644 --- a/app/common/dao/store/product/SpuDao.php +++ b/app/common/dao/store/product/SpuDao.php @@ -20,6 +20,9 @@ use crmeb\services\VicWordService; class SpuDao extends BaseDao { + + public $orderField; + public function getModel(): string { return Spu::class; @@ -43,6 +46,9 @@ class SpuDao extends BaseDao $order = 'S.'. (($where['order'] !== '') ?$where['order']: 'star' ).' DESC'; } } + if (!empty($this->orderField)) { + $order = "field(P.product_id,{$this->orderField})"; + } $order .= ',S.create_time DESC'; if(isset($where['order']) && $where['order'] === 'none'){ $order = ''; @@ -183,7 +189,8 @@ class SpuDao extends BaseDao ->when(isset($where['svip']) && $where['svip'] !== '',function($query)use($where){ $query->where('svip_price_type','>',0)->where('mer_svip_status',1); }); - return $query->order($order); + + return $query->orderRaw($order); } public function findOrCreateAll(array $where) diff --git a/app/common/repositories/store/product/SpuRepository.php b/app/common/repositories/store/product/SpuRepository.php index d7745db0..a360d174 100644 --- a/app/common/repositories/store/product/SpuRepository.php +++ b/app/common/repositories/store/product/SpuRepository.php @@ -38,6 +38,7 @@ class SpuRepository extends BaseRepository public $productFiled = 'P.bar_code,S.product_id,S.store_name,S.image,activity_id,S.keyword,S.price,S.mer_id,spu_id,S.status,store_info,brand_id,cate_id,unit_name,S.star,S.rank,S.sort,sales,S.product_type,rate,reply_count,extension_type,S.sys_labels,S.mer_labels,P.delivery_way,P.delivery_free,P.ot_price,svip_price_type,stock,mer_svip_status'; public $userInfo; + public $orderField; public function __construct(SpuDao $dao) { @@ -143,6 +144,9 @@ class SpuRepository extends BaseRepository } } $where = array_merge(Product::searchEnable(), $where); + if (!empty($this->orderField)) { + $this->dao->orderField = $this->orderField; + } $query = $this->dao->search($where); $query->with([ diff --git a/app/controller/api/store/product/CloudWarehouse.php b/app/controller/api/store/product/CloudWarehouse.php index eb1cb8d4..87f7cac0 100644 --- a/app/controller/api/store/product/CloudWarehouse.php +++ b/app/controller/api/store/product/CloudWarehouse.php @@ -76,7 +76,7 @@ class CloudWarehouse extends BaseController $cloud_product_arr = $query->where(function($query){ $query->where('mer_labels', '') ->whereOr('mer_labels',',5,'); - })->page($page)->field('product_id,mer_labels')->select(); + })->page($page)->field("product_id,mer_labels,st_distance_sphere(point(`long`,`lat`), point({$lng}, {$lat})) as distance")->order('distance')->select(); $cloud_product = []; foreach ($cloud_product_arr as $key => $value) { $cloud_product[] = $value['product_id']; @@ -93,10 +93,7 @@ class CloudWarehouse extends BaseController if (!$cloud_product) { return app('json')->success(['count' => 0, 'list' => []]); } - $count = $query->where(function($query){ - $query->whereOr('mer_labels', '') - ->whereOr('mer_labels',',5,'); - })->count(); + $this->spuRepository->orderField = implode(',', $cloud_product); $products = $this->spuRepository->getApiSearch($where, $page, 0, false, true); if ($products['list']) { $list = $products['list']; @@ -112,7 +109,7 @@ class CloudWarehouse extends BaseController } } } - return app('json')->success(['count' => $count, 'list' => $list]); + return app('json')->success(['count' => $products['count'], 'list' => $list]); } /**