Merge pull request 'dev' (#133) from dev into master

Reviewed-on: #133
This commit is contained in:
mkm 2024-01-23 17:55:37 +08:00
commit 0555572ac1
5 changed files with 61 additions and 53 deletions

View File

@ -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)

View File

@ -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([

View File

@ -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]); //短信通知
}
}

View File

@ -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;

View File

@ -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]);
}
/**