全部
常见问题
产品动态
精选推荐

进店规则获取门店和商品所在门店冲突问题

管理 管理 编辑 删除

问题说明:进店规则获取门店和商品所在门店冲突造成没获取到门店信息

修改文件:app/services/store/SystemStoreServices.php

修改方法:getStoreList()

public function getStoreList(array $where, array $field = ['*'], string $latitude = '', string $longitude = '', int $product_id = 0, array $with = [], int $type = 0, $store_id = 0)
    {
        $order = 0;
        if (isset($where['order_id']) && $where['order_id']) {
            /** @var StoreOrderServices $storeOrderServices */
            $storeOrderServices = app()->make(StoreOrderServices::class);
            $user_location = $storeOrderServices->value(['id' => $where['order_id']], 'user_location');
			if ($user_location) {
				[$longitude, $latitude] = explode(' ', $user_location);
			}
        }
        if ($longitude && $latitude) {
            $order = 1;
        }
        $list = [];
        $count = 0;
        //移动端定位选择门店
        if ($store_id) {
            $where['ids'] = [$store_id];
        }
        //该商品上架的门店
        if ($product_id) {
            /** @var StoreBranchProductServices $productServices */
            $productServices = app()->make(StoreBranchProductServices::class);
            [$ids, $applicableType, $productType] = $productServices->getApplicableStoreIds($product_id, $type);
            if ($ids) {
				if ($productType == 1) {//门店商品
					$where['ids'] = $ids;
				} else {
					if ($store_id && !in_array($store_id, $ids)) {
						return compact('list', 'count');
					}
					if (isset($where['ids']) && $where['ids']) {
						$ids = array_intersect($where['ids'], $ids);
					}
					if ($ids) {
						$where['ids'] = $ids;
					} else {
						return compact('list', 'count');
					}
					$where['ids'] = isset($where['ids']) && $where['ids'] ? array_intersect($where['ids'], $ids) : $ids;
				}
            } else {
                if ($applicableType != 1) {//不是所有门店
                    return compact('list', 'count');
                }
            }
        }
        $oid = (int)($where['order_id'] ?? 0);
        unset($where['order_id']);
       if (isset($where['ids'])) {//有选择门店 || 商品适用门店情况
			if (isset($where['id']) && $where['id']) {//合并进店规则进入门店
				$where['ids'] = array_merge($where['ids'], is_array($where['id']) ? $where['id'] :[$where['id']]);
				unset($where['id']);
			}
            $where['ids'] = array_unique(array_diff($where['ids'], [0]));
        }
		if ($oid || $product_id) {//不分页
			$page = $limit = 0;
		} else {
			[$page, $limit] = $this->getPageValue();
		}
		$storeList = $this->dao->getStoreList($where, $field, $page, $limit, $with, $latitude, $longitude, $order);
        if ($storeList) {
            $storeIds = [];
            if ($oid) {
                [$storeIds, $cartInfo] = $this->checkOrderProductShare($oid, $storeList, 2);
            }
            $prefix = config('admin.store_prefix');
            $regionIds = array_column($storeList, 'region_id');
            if ($regionIds) {
                /** @var SystemRegionAgentServices $storeRegionServices */
                $storeRegionServices = app()->make(SystemRegionAgentServices::class);
                $regionNames = $storeRegionServices->getColumn([['id', 'in', $regionIds], ['is_del', '=', 0]], 'name', 'id');
            }
			$now = date('Hi');
            foreach ($storeList as &$item) {
				$item['type_name'] = '';
				if (isset($item['type'])) {
					$item['type_name'] = $this->typeName[$item['type']] ?? '';
				}
                if (isset($item['distance'])) {
                    $item['range'] = bcdiv($item['distance'], '1000', 1);
                } else {
                    $item['range'] = 0;
                }
				$item['business_status'] = 0;
                if ($item['is_show'] == 1) {
                    $item['status_name'] = '营业中';
					if ($item['day_start'] && $item['day_end']) {
						$start = date('Hi', strtotime($item['day_start']));
						$end = date('Hi', strtotime($item['day_end']));
						if ($now >= $start && $now <= $end) {
							$item['business_status'] = 1;
						}
					}
                } else {
                    $item['status_name'] = '已停业';
                }

                $item['prefix'] = $prefix;
                $item['recommend_region_name'] = '';
                if (isset($item['region_id']) && $item['region_id']) {
                    $item['recommend_region_name'] = $regionNames[$item['region_id']] ?? '';
                }
                if ($oid) {
                    if (in_array($item['id'], $storeIds)) {
                        $list[] = $item;
                    }
                } else {
                    $list[] = $item;
                }
            }
            if (count($list) && $store_id) {
                $arr = [];
                foreach ($list as $key => $value) {
                    if ($value['id'] == $store_id) {
                        $arr = $value;
                        unset($list[$key]);
                    }
                }
                if ($arr) array_unshift($list, $arr);
            }
            if ($oid) {
                $count = count($list);
            } else {
                $count = $this->dao->count($where);
            }
        }

        return compact('list', 'count');
    }



请登录后查看

全 最后编辑于2025-10-23 16:41:44

快捷回复
回复
回复
回复({{post_count}}) {{!is_user ? '我的回复' :'全部回复'}}
排序 默认正序 回复倒序 点赞倒序

{{item.user_info.nickname ? item.user_info.nickname : item.user_name}} LV.{{ item.user_info.bbs_level || item.bbs_level }}

作者 管理员 企业

{{item.floor}}# 同步到gitee 已同步到gitee {{item.is_suggest == 1? '取消推荐': '推荐'}}
{{item.is_suggest == 1? '取消推荐': '推荐'}} 【已收集】
沙发 板凳 地板 {{item.floor}}# 【已收集】
{{item.user_info.title || '暂无简介'}}
附件

{{itemf.name}}

{{item.created_at}}  {{item.ip_address}}
打赏
已打赏¥{{item.reward_price}}
{{item.like_count}}
{{item.showReply ? '取消回复' : '回复'}}
删除
回复
回复

{{itemc.user_info.nickname}}

{{itemc.user_name}}

回复 {{itemc.comment_user_info.nickname}}

附件

{{itemf.name}}

{{itemc.created_at}}
打赏
已打赏¥{{itemc.reward_price}}
{{itemc.like_count}}
{{itemc.showReply ? '取消回复' : '回复'}}
删除
回复
回复
查看更多
打赏
已打赏¥{{reward_price}}
78
{{like_count}}
{{collect_count}}
添加回复 ({{post_count}})

相关推荐

快速安全登录

使用微信扫码登录
{{item.label}} 加精
{{item.label}} {{item.label}} 板块推荐 常见问题 产品动态 精选推荐 首页头条 首页动态 首页推荐
取 消 确 定
回复
回复
问题:
问题自动获取的帖子内容,不准确时需要手动修改. [获取答案]
答案:
提交
bug 需求 取 消 确 定
打赏金额
当前余额:¥{{rewardUserInfo.reward_price}}
{{item.price}}元
请输入 0.1-{{reward_max_price}} 范围内的数值
打赏成功
¥{{price}}
完成 确认打赏

微信登录/注册

切换手机号登录

{{ bind_phone ? '绑定手机' : '手机登录'}}

{{codeText}}
切换微信登录/注册
暂不绑定
CRMEB客服

CRMEB咨询热线 咨询热线

400-8888-794

微信扫码咨询

CRMEB开源商城下载 源码下载 CRMEB帮助文档 帮助文档
返回顶部 返回顶部
CRMEB客服