From fb2b83f60f286a9aaab19ae4cf7410af3548a935 Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Mon, 22 Jan 2024 10:11:40 +0800 Subject: [PATCH 01/12] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=8C=E7=BB=B4?= =?UTF-8?q?=E7=A0=81=E7=94=9F=E6=88=90=E7=9A=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crmeb/services/QrcodeService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crmeb/services/QrcodeService.php b/crmeb/services/QrcodeService.php index 0fba8528..1a90396c 100644 --- a/crmeb/services/QrcodeService.php +++ b/crmeb/services/QrcodeService.php @@ -29,7 +29,7 @@ class QrcodeService * @param $name * @return array|bool|string */ - public function getQRCodePath($url, $name,$data) + public function getQRCodePath($url, $name,$data = []) { if (!strlen(trim($url)) || !strlen(trim($name))) return false; try { From aa07cc9a5030aa85c2e05d2dd881c8315ae26cce Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 22 Jan 2024 10:37:04 +0800 Subject: [PATCH 02/12] =?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 | 70 +++-------------------------------- crmeb/jobs/ProductCopyJob.php | 17 +++++++-- 2 files changed, 20 insertions(+), 67 deletions(-) diff --git a/app/controller/api/Demo.php b/app/controller/api/Demo.php index 1c018e87..05be8965 100644 --- a/app/controller/api/Demo.php +++ b/app/controller/api/Demo.php @@ -30,73 +30,15 @@ use crmeb\jobs\ProductCopyJob; class Demo extends BaseController { public function index() - { - return app('json')->success('修改成功'); - $arr=Db::name('store_product')->whereIn('mer_id',[110,116,149,227,226,35,117,148,156,104,137,151,136,183,140,229,79,133,235])->where('status',1)->where('is_show',0)->field('product_id')->select(); - $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]);//短信通知 - } + { return app('json')->success('修改成功'); + // $arr=Db::name('store_product')->whereIn('mer_id',[110,116,149,227,226,35,117,148,156,104,137,151,136,183,140,229,79,133,235])->where('is_del',1)->field('product_id')->select(); + // foreach($arr as $item){ - $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]);//短信通知 - } + // Queue::push(ProductCopyJob::class, ['product_id' => $item['product_id']]);//短信通知 - $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]);//短信通知 - } - - $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]);//短信通知 - } - - $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]);//短信通知 - } - - //江阳 - $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]);//短信通知 - } - - $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]);//短信通知 - } - - $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]);//短信通知 - } - - $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]);//短信通知 - } + // } + } public function transcoding($fileName) diff --git a/crmeb/jobs/ProductCopyJob.php b/crmeb/jobs/ProductCopyJob.php index afca7931..111d9fb7 100644 --- a/crmeb/jobs/ProductCopyJob.php +++ b/crmeb/jobs/ProductCopyJob.php @@ -16,15 +16,26 @@ namespace crmeb\jobs; use crmeb\interfaces\JobInterface; use app\controller\admin\store\StoreProduct; +use think\facade\Db; - +/** + * 本地跑远程线程专门使用 + */ class ProductCopyJob implements JobInterface { public function fire($job, $data) { - $make = app()->make(StoreProduct::class); - $make->copy($data['product_id'],$data['mer_id'],$data['street_code'],$data['type_id'],$data['category_id']); + // $arrs= Db::name('store_product')->where('old_product_id',$data['product_id'])->select(); + // foreach($arrs as $it){ + // $res= Db::name('store_product')->where('product_id',$it['product_id'])->update(['is_del'=>1,'is_show'=>0,'is_used'=>0,'status'=>-2]); + // if($res){ + // Db::name('cloud_product')->where('product_id',$it['product_id'])->delete(); + + // } + // } + // $make = app()->make(StoreProduct::class); + // $make->copy($data['product_id'],$data['mer_id'],$data['street_code'],$data['type_id'],$data['category_id']); $job->delete(); } From ab0d2e62fe0d592021db7e3233307dd286b6cdc0 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 22 Jan 2024 10:48:44 +0800 Subject: [PATCH 03/12] =?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 | 13 ++++++++----- app/controller/api/store/product/CloudWarehouse.php | 2 +- app/controller/merchant/store/product/Product.php | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/controller/api/Demo.php b/app/controller/api/Demo.php index 05be8965..019ae041 100644 --- a/app/controller/api/Demo.php +++ b/app/controller/api/Demo.php @@ -30,14 +30,17 @@ use crmeb\jobs\ProductCopyJob; class Demo extends BaseController { public function index() - { return app('json')->success('修改成功'); + { + return app('json')->success('修改成功'); + //[31,32,118,39,167,236,237,238,239] + // return app('json')->success('修改成功');>whereIn('mer_id',[110,116,149,227,226,35,117,148,156,104,137,151,136,183,140,229,79,133,235])-> - // $arr=Db::name('store_product')->whereIn('mer_id',[110,116,149,227,226,35,117,148,156,104,137,151,136,183,140,229,79,133,235])->where('is_del',1)->field('product_id')->select(); - // foreach($arr as $item){ + $arr=Db::name('store_product')->whereIn('mer_id',[31,32,118,39,167,236,237,238,239])->where('is_show',1)->where('stock',0)->field('product_id')->select(); + foreach($arr as $item){ - // Queue::push(ProductCopyJob::class, ['product_id' => $item['product_id']]);//短信通知 + Queue::push(ProductCopyJob::class, ['product_id' => $item['product_id']]);//短信通知 - // } + } } diff --git a/app/controller/api/store/product/CloudWarehouse.php b/app/controller/api/store/product/CloudWarehouse.php index eebcc1ce..6e867c11 100644 --- a/app/controller/api/store/product/CloudWarehouse.php +++ b/app/controller/api/store/product/CloudWarehouse.php @@ -90,7 +90,7 @@ class CloudWarehouse extends BaseController if ($value['mer_labels'] == ',5,') { $list[$k]['mer_labels_name'] = '五日达'; } else { - $list[$k]['mer_labels_name'] = '次日达'; + $list[$k]['mer_labels_name'] = '同城'; } } } diff --git a/app/controller/merchant/store/product/Product.php b/app/controller/merchant/store/product/Product.php index e810819a..db78e094 100644 --- a/app/controller/merchant/store/product/Product.php +++ b/app/controller/merchant/store/product/Product.php @@ -468,7 +468,7 @@ class Product extends BaseController if ($value['mer_labels'] == ',5,') { $select[$k]['mer_labels_name'] = '五日达'; } else { - $select[$k]['mer_labels_name'] = '次日达'; + $select[$k]['mer_labels_name'] = '同城'; } } } From aa368d25203ffa4aa528c3e2e9c0781e595f0141 Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Mon, 22 Jan 2024 13:56:38 +0800 Subject: [PATCH 04/12] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dao/system/merchant/MerchantDao.php | 25 ++++++++++++++++ .../api/store/product/CloudWarehouse.php | 24 ++++++++------- app/controller/api/store/product/StoreSpu.php | 29 +++++++++++++++---- 3 files changed, 62 insertions(+), 16 deletions(-) diff --git a/app/common/dao/system/merchant/MerchantDao.php b/app/common/dao/system/merchant/MerchantDao.php index a6bdd26b..ba28d4bc 100644 --- a/app/common/dao/system/merchant/MerchantDao.php +++ b/app/common/dao/system/merchant/MerchantDao.php @@ -315,4 +315,29 @@ class MerchantDao extends BaseDao return $this->getModel()::getInstance()->where($where); } + /** + * 按距离获取有效的商户 + * @param $lat + * @param $lng + * @param $distance 距离,单位米 + * @return mixed + */ + public function getValidMerchantByDistance($lat, $lng, $distance = 2000) + { + $merchant = Merchant::where('type_id', 'IN', ["10", "17"]) + ->where(['is_del' => 0, 'mer_state' => 1]) + ->whereNotNull('lat') + ->whereNotNull('long') + ->field("mer_id,st_distance_sphere(point(`long`,`lat`), point({$lng}, {$lat})) as distance") + ->having("distance <= {$distance}") + ->limit(50)->select(); + if (empty($merchant)) { + $merchant = $this->getValidMerchantByDistance($lat, $lng, 5000); + } + if (!empty($merchant)) { + return array_column($merchant->toArray(), 'mer_id'); + } + return []; + } + } diff --git a/app/controller/api/store/product/CloudWarehouse.php b/app/controller/api/store/product/CloudWarehouse.php index eebcc1ce..bbc0146f 100644 --- a/app/controller/api/store/product/CloudWarehouse.php +++ b/app/controller/api/store/product/CloudWarehouse.php @@ -3,6 +3,7 @@ namespace app\controller\api\store\product; use app\common\dao\system\merchant\MerchantDao; +use app\common\model\store\GeoStreet; use app\common\model\system\merchant\Merchant; use app\common\repositories\store\product\SpuRepository; use think\facade\Db; @@ -45,18 +46,23 @@ class CloudWarehouse extends BaseController */ public function index($street_code, $page = 1, $category_id = 0, $cate_pid = 0,$cate_id = 0,$location = '') { - - $cloud_where['street_code']=$street_code; - $cloud_where['status']=1; + $query = Db::name('cloud_product')->where('status', 1); + if (!empty($street_code)) { + $location = GeoStreet::where('street_code', $street_code)->field('lng,lat')->find(); + if (!empty($location)) { + $merIds = (new MerchantDao())->getValidMerchantByDistance($location['lat'], $location['lng']); + if (!empty($merIds)) { + $query->whereIn('mer_id', $merIds); + } + } + } if($cate_pid!=0){ $cate_id=Db::name('store_category')->where('pid',$cate_pid)->where('is_show',1)->column('store_category_id'); } if($cate_id>0){ - $cloud_where['cate_id']=$cate_id; + $query->where('cate_id', $cate_id); } - $cloud_product_arr = Db::name('cloud_product') - ->where($cloud_where) - ->where(function($query){ + $cloud_product_arr = $query->where(function($query){ $query->whereOr('mer_labels', '') ->whereOr('mer_labels',',5,'); })->page($page)->field('product_id,mer_labels')->select(); @@ -75,9 +81,7 @@ class CloudWarehouse extends BaseController if (!$cloud_product) { return app('json')->success(['count' => 0, 'list' => []]); } - $count = Db::name('cloud_product') - ->where($cloud_where) - ->where(function($query){ + $count = $query->where(function($query){ $query->whereOr('mer_labels', '') ->whereOr('mer_labels',',5,'); })->count(); diff --git a/app/controller/api/store/product/StoreSpu.php b/app/controller/api/store/product/StoreSpu.php index 47388952..31cd4c4f 100644 --- a/app/controller/api/store/product/StoreSpu.php +++ b/app/controller/api/store/product/StoreSpu.php @@ -10,6 +10,8 @@ // +---------------------------------------------------------------------- namespace app\controller\api\store\product; +use app\common\dao\system\merchant\MerchantDao; +use app\common\model\store\GeoStreet; use app\common\model\system\merchant\Merchant; use app\common\repositories\store\product\ProductRepository; use app\common\repositories\store\StoreCategoryRepository; @@ -62,23 +64,38 @@ class StoreSpu extends BaseController 'street_id', 'category_id', 'type_code', - 'village_id' + 'village_id', + 'location' ]); if ($where['type_id']||$where['type_code']) { $arr = ['status' => 1, 'mer_state' => 1, 'is_del' => 0]; - if ($where['street_id']) { - $arr['street_id'] = $where['street_id']; + $query = Merchant::where($arr); + if ($where['location']) { + [$lat, $lng] = explode(',', $where['location']); + $merIds = (new MerchantDao())->getValidMerchantByDistance($lat, $lng); + if (!empty($merIds)) { + $query->whereIn('mer_id', $merIds); + } + } + if ($where['street_id'] && empty($where['location'])) { + $location = GeoStreet::where('street_code', $where['street_id'])->field('lng,lat')->find(); + if (!empty($location)) { + $merIds = (new MerchantDao())->getValidMerchantByDistance($location['lat'], $location['lng']); + if (!empty($merIds)) { + $query->whereIn('mer_id', $merIds); + } + } } if ($where['village_id']) { - $arr['village_id'] = $where['village_id']; + $query->where('village_id', $where['village_id']); } if($where['type_code']){ $mer_type_id=Db::name('merchant_type')->where('type_code',$where['type_code'])->value('mer_type_id'); if($mer_type_id){ - $where['type_id'] = $mer_type_id; + $query->where('type_id', $mer_type_id); } } - $where['mer_ids'] = Merchant::getInstance()->whereIn('type_id', explode(',', $where['type_id']))->where($arr)->column('mer_id'); + $where['mer_ids'] = $query->whereIn('type_id', explode(',', $where['type_id']))->column('mer_id'); } unset($where['type_id'], $where['street_id'],$where['type_code'],$where['village_id']); From d4094ba1c37ba2d7bfd39ce66beeeb5b2c845ab9 Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Mon, 22 Jan 2024 14:11:53 +0800 Subject: [PATCH 05/12] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/dao/system/merchant/MerchantDao.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/common/dao/system/merchant/MerchantDao.php b/app/common/dao/system/merchant/MerchantDao.php index ba28d4bc..1195fd73 100644 --- a/app/common/dao/system/merchant/MerchantDao.php +++ b/app/common/dao/system/merchant/MerchantDao.php @@ -330,12 +330,12 @@ class MerchantDao extends BaseDao ->whereNotNull('long') ->field("mer_id,st_distance_sphere(point(`long`,`lat`), point({$lng}, {$lat})) as distance") ->having("distance <= {$distance}") - ->limit(50)->select(); - if (empty($merchant)) { + ->limit(50)->select()->toArray(); + if (empty($merchant) && $distance < 5000) { $merchant = $this->getValidMerchantByDistance($lat, $lng, 5000); } if (!empty($merchant)) { - return array_column($merchant->toArray(), 'mer_id'); + return array_column($merchant, 'mer_id'); } return []; } From 13403e44e7cb81bf5b7cc83f9285bf1a5dcb0f38 Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Mon, 22 Jan 2024 14:22:09 +0800 Subject: [PATCH 06/12] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/store/product/CloudWarehouse.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controller/api/store/product/CloudWarehouse.php b/app/controller/api/store/product/CloudWarehouse.php index 6a0090bf..c0f4d3f1 100644 --- a/app/controller/api/store/product/CloudWarehouse.php +++ b/app/controller/api/store/product/CloudWarehouse.php @@ -60,7 +60,7 @@ class CloudWarehouse extends BaseController $cate_id=Db::name('store_category')->where('pid',$cate_pid)->where('is_show',1)->column('store_category_id'); } if($cate_id>0){ - $query->where('cate_id', $cate_id); + $query->whereIn('cate_id', $cate_id); } $cloud_product_arr = $query->where(function($query){ $query->whereOr('mer_labels', '') From 07a4dba152ee17bf0bb9fb37d7cbd92b08b813eb Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Mon, 22 Jan 2024 15:18:30 +0800 Subject: [PATCH 07/12] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dao/system/merchant/MerchantDao.php | 19 ++++++++++++------- .../api/store/product/CloudWarehouse.php | 4 ++++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/app/common/dao/system/merchant/MerchantDao.php b/app/common/dao/system/merchant/MerchantDao.php index 1195fd73..49de4657 100644 --- a/app/common/dao/system/merchant/MerchantDao.php +++ b/app/common/dao/system/merchant/MerchantDao.php @@ -319,20 +319,25 @@ class MerchantDao extends BaseDao * 按距离获取有效的商户 * @param $lat * @param $lng + * @param $sort 是否按距离排序 * @param $distance 距离,单位米 * @return mixed */ - public function getValidMerchantByDistance($lat, $lng, $distance = 2000) + public function getValidMerchantByDistance($lat, $lng, $sort = false, $distance = 2000) { - $merchant = Merchant::where('type_id', 'IN', ["10", "17"]) + $query = Merchant::where('type_id', 'IN', ["10", "17"]) ->where(['is_del' => 0, 'mer_state' => 1]) ->whereNotNull('lat') ->whereNotNull('long') - ->field("mer_id,st_distance_sphere(point(`long`,`lat`), point({$lng}, {$lat})) as distance") - ->having("distance <= {$distance}") - ->limit(50)->select()->toArray(); - if (empty($merchant) && $distance < 5000) { - $merchant = $this->getValidMerchantByDistance($lat, $lng, 5000); + ->field("mer_id,st_distance_sphere(point(`long`,`lat`), point({$lng}, {$lat})) as distance"); + if ($sort) { + $query->order('distance')->limit(20); + } else { + $query->having("distance <= {$distance}")->limit(50); + } + $merchant = $query->select()->toArray(); + if (empty($merchant) && $distance < 5000 && !$sort) { + $merchant = $this->getValidMerchantByDistance($lat, $lng, $sort, 5000); } if (!empty($merchant)) { return array_column($merchant, 'mer_id'); diff --git a/app/controller/api/store/product/CloudWarehouse.php b/app/controller/api/store/product/CloudWarehouse.php index c0f4d3f1..2c779e82 100644 --- a/app/controller/api/store/product/CloudWarehouse.php +++ b/app/controller/api/store/product/CloudWarehouse.php @@ -56,6 +56,10 @@ class CloudWarehouse extends BaseController } } } + if (empty($merIds)) { + $merIds = (new MerchantDao())->getValidMerchantByDistance($location['lat'], $location['lng'], true); + $query->whereIn('mer_id', $merIds); + } if($cate_pid!=0){ $cate_id=Db::name('store_category')->where('pid',$cate_pid)->where('is_show',1)->column('store_category_id'); } From e39c96e65c21bbb0617566f197a02c2cc97b924e Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Mon, 22 Jan 2024 16:31:33 +0800 Subject: [PATCH 08/12] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/store/product/CloudWarehouse.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/app/controller/api/store/product/CloudWarehouse.php b/app/controller/api/store/product/CloudWarehouse.php index 2c779e82..7a8da07e 100644 --- a/app/controller/api/store/product/CloudWarehouse.php +++ b/app/controller/api/store/product/CloudWarehouse.php @@ -47,13 +47,19 @@ class CloudWarehouse extends BaseController public function index($street_code, $page = 1, $category_id = 0, $cate_pid = 0,$cate_id = 0,$location = '') { $query = Db::name('cloud_product')->where('status', 1); - if (!empty($street_code)) { + if (!empty($location)) { + [$lat, $lng] = explode(',', $location); + } + if (!empty($street_code) && empty($location)) { $location = GeoStreet::where('street_code', $street_code)->field('lng,lat')->find(); if (!empty($location)) { - $merIds = (new MerchantDao())->getValidMerchantByDistance($location['lat'], $location['lng']); - if (!empty($merIds)) { - $query->whereIn('mer_id', $merIds); - } + [$lat, $lng] = [$location['lat'], $location['lng']]; + } + } + if (!empty($lat)) { + $merIds = (new MerchantDao())->getValidMerchantByDistance($lat, $lng); + if (!empty($merIds)) { + $query->whereIn('mer_id', $merIds); } } if (empty($merIds)) { From 1af1b7570b0d12b149fee17e83b7aed18b60d2ba Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Mon, 22 Jan 2024 16:42:18 +0800 Subject: [PATCH 09/12] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/store/product/CloudWarehouse.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/controller/api/store/product/CloudWarehouse.php b/app/controller/api/store/product/CloudWarehouse.php index 7a8da07e..f8acf07f 100644 --- a/app/controller/api/store/product/CloudWarehouse.php +++ b/app/controller/api/store/product/CloudWarehouse.php @@ -47,10 +47,12 @@ class CloudWarehouse extends BaseController public function index($street_code, $page = 1, $category_id = 0, $cate_pid = 0,$cate_id = 0,$location = '') { $query = Db::name('cloud_product')->where('status', 1); - if (!empty($location)) { + if (!empty($location) && $location != ',') { [$lat, $lng] = explode(',', $location); } - if (!empty($street_code) && empty($location)) { + if (!empty($street_code) && (empty($location) || $location == ',')) { + + $location = GeoStreet::where('street_code', $street_code)->field('lng,lat')->find(); if (!empty($location)) { [$lat, $lng] = [$location['lat'], $location['lng']]; @@ -62,8 +64,8 @@ class CloudWarehouse extends BaseController $query->whereIn('mer_id', $merIds); } } - if (empty($merIds)) { - $merIds = (new MerchantDao())->getValidMerchantByDistance($location['lat'], $location['lng'], true); + if (empty($merIds) && !empty($lat)) { + $merIds = (new MerchantDao())->getValidMerchantByDistance($lat, $lng, true); $query->whereIn('mer_id', $merIds); } if($cate_pid!=0){ From 0c0432f01fc905866a9a12ded241ceebd0380f5d Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Mon, 22 Jan 2024 17:27:50 +0800 Subject: [PATCH 10/12] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=B8=8B=E5=8D=95?= =?UTF-8?q?=E5=89=8D=E7=BD=AE=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repositories/store/order/StoreOrderCreateRepository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/common/repositories/store/order/StoreOrderCreateRepository.php b/app/common/repositories/store/order/StoreOrderCreateRepository.php index 73c6e7f2..49943840 100644 --- a/app/common/repositories/store/order/StoreOrderCreateRepository.php +++ b/app/common/repositories/store/order/StoreOrderCreateRepository.php @@ -79,7 +79,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository foreach ($merchantCartList as $merchantCart) { if (($merchantCart['type_id'] != Merchant::TypeSupplyChain) && $address) { - if ($merchantCart['street_id'] != $address['street_code']) { + if ($merchantCart['street_id'] != $address['street_code'] && $createOrder) { throw new ValidateException('不支持跨区域购买,请在【我的】-【地址管理】更改后重新购买'); } } From ebac1ec22bc5336883581668af871d32865c44c7 Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Mon, 22 Jan 2024 17:41:36 +0800 Subject: [PATCH 11/12] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=B8=8B=E5=8D=95?= =?UTF-8?q?=E5=89=8D=E7=BD=AE=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/StoreOrderCreateRepository.php | 3 +- .../store/order/StoreOrderRepository.php | 30 ++++++++++--------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/app/common/repositories/store/order/StoreOrderCreateRepository.php b/app/common/repositories/store/order/StoreOrderCreateRepository.php index 49943840..b7201b1d 100644 --- a/app/common/repositories/store/order/StoreOrderCreateRepository.php +++ b/app/common/repositories/store/order/StoreOrderCreateRepository.php @@ -77,9 +77,8 @@ class StoreOrderCreateRepository extends StoreOrderRepository //检查商品类型, 活动商品只能单独购买 $allowDelivery = true; foreach ($merchantCartList as $merchantCart) { - if (($merchantCart['type_id'] != Merchant::TypeSupplyChain) && $address) { - if ($merchantCart['street_id'] != $address['street_code'] && $createOrder) { + if ($merchantCart['street_id'] != $address['street_code'] && $createOrder && !in_array($merchantCart['mer_id'], $takes)) { throw new ValidateException('不支持跨区域购买,请在【我的】-【地址管理】更改后重新购买'); } } diff --git a/app/common/repositories/store/order/StoreOrderRepository.php b/app/common/repositories/store/order/StoreOrderRepository.php index b3cc6d69..c9031ae7 100644 --- a/app/common/repositories/store/order/StoreOrderRepository.php +++ b/app/common/repositories/store/order/StoreOrderRepository.php @@ -352,20 +352,22 @@ class StoreOrderRepository extends BaseRepository $merchantRepo->forceMargin = false; [$_payCityPrice, $finance, $increase] = $merchantRepo->autoMargin($_payPrice, $order, $finance, $financeSn, $i++); } - $finance[] = [ - 'order_id' => $order->order_id, - 'order_sn' => $order->order_sn, - 'user_info' => $groupOrder->user->nickname, - 'user_id' => $uid, - 'financial_type' => 'order_true', - 'financial_pm' => 0, - 'type' => 2, - 'number' => $_payCityPrice, - 'mer_id' => $product_mer_id, - 'financial_record_sn' => $financeSn . (($i++)+2) - ]; - if (!$is_combine) { - app()->make(MerchantRepository::class)->addLockMoney($product_mer_id, 'order', $order->order_id, $_payCityPrice); + if (isset($_payCityPrice)) { + $finance[] = [ + 'order_id' => $order->order_id, + 'order_sn' => $order->order_sn, + 'user_info' => $groupOrder->user->nickname, + 'user_id' => $uid, + 'financial_type' => 'order_true', + 'financial_pm' => 0, + 'type' => 2, + 'number' => $_payCityPrice, + 'mer_id' => $product_mer_id, + 'financial_record_sn' => $financeSn . (($i++)+2) + ]; + if (!$is_combine) { + app()->make(MerchantRepository::class)->addLockMoney($product_mer_id, 'order', $order->order_id, $_payCityPrice); + } } } From 2bab5ff6925279e94ecf4ec3821d0b1a90971855 Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Mon, 22 Jan 2024 18:03:01 +0800 Subject: [PATCH 12/12] =?UTF-8?q?=E6=B2=A1=E6=9C=89=E5=85=B3=E8=81=94?= =?UTF-8?q?=E4=BE=9B=E5=BA=94=E9=93=BE=E7=9A=84=E5=95=86=E5=93=81=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E4=B8=8B=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/repositories/store/product/ProductRepository.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/common/repositories/store/product/ProductRepository.php b/app/common/repositories/store/product/ProductRepository.php index fa3c25e0..fade4dae 100644 --- a/app/common/repositories/store/product/ProductRepository.php +++ b/app/common/repositories/store/product/ProductRepository.php @@ -16,6 +16,7 @@ namespace app\common\repositories\store\product; use app\common\dao\store\order\StoreCartDao; use app\common\model\store\order\StoreOrder; use app\common\model\store\order\StoreOrderProduct; +use app\common\model\store\product\CloudProduct; use app\common\model\store\product\ProductAttrValue; use app\common\model\store\product\ProductLabel; use app\common\model\store\product\PurchaseRecord; @@ -1951,6 +1952,10 @@ class ProductRepository extends BaseRepository $product = $this->dao->search(null, $where)->find(); if (!$product) throw new ValidateException('商品已下架'); + if ($data['source'] == 103 && empty($product['old_product_id'])) { + CloudProduct::where('product_id', $product['product_id'])->update(['status' => 0]); + throw new ValidateException('商品已下架'); + } if ($product['type'] && !$data['is_new']) throw new ValidateException('虚拟商品不可加入购物车'); $value_make = app()->make(ProductAttrValueRepository::class); $sku = $value_make->getOptionByUnique($data['product_attr_unique']);