配置修改

This commit is contained in:
2026-07-13 16:33:09 +08:00
parent 9998f4651b
commit d1a15a4c42
15 changed files with 348 additions and 38 deletions

View File

@ -4,12 +4,13 @@ namespace app\api\controller;
use app\common\basics\Api;
use app\api\logic\IndexLogic;
use app\common\logic\ChatLogic;
use app\common\logic\CityLogic;
use app\common\logic\RegionLogic;
use app\common\server\JsonServer;
class Index extends Api
{
public $like_not_need_login = ['index','hotCity', 'indexCategory', 'config','copyright','city','geocoder'];
public $like_not_need_login = ['index','hotCity', 'indexCategory', 'config','copyright','city','geocoder','getEntryCity'];
// 首页
public function index()
@ -114,4 +115,18 @@ class Index extends Api
}
return JsonServer::success('',$result);
}
/**
* 小程序进入时获取应展示的城市商城
* 未扫码:上海总部;扫码:码主人所属城市
*/
public function getEntryCity()
{
$params = [
'invite_code' => $this->request->get('invite_code', ''),
'user_id' => $this->request->get('user_id/d', 0),
];
$data = CityLogic::getEntryCity($params);
return JsonServer::success('获取成功', $data);
}
}

View File

@ -51,8 +51,7 @@ class Shop extends Api
public function getShopCityInfo()
{
if($this->request->isGet()) {
$city_id = $this->request->get('city_id', 0);
$data = ShopLogic::getShopCityInfo($city_id, $this->user_id, input());
$data = ShopLogic::getShopCityInfo(0, $this->user_id, input());
return JsonServer::success('获取店铺信息成功', $data);
}else{
return JsonServer::error('请求类型错误');

View File

@ -46,8 +46,7 @@ class ShopGoodsCategory extends Api
public function getCityGoodsCategory()
{
if($this->request->isGet()) {
$city_id = $this->request->get('city_id', 0);
$data = ShopGoodsCategoryLogic::getCityGoodsCategory($city_id);
$data = ShopGoodsCategoryLogic::getCityGoodsCategory(0, input());
return JsonServer::success('获取店铺分类成功', $data);
}else{
return JsonServer::error('请求类型错误');

View File

@ -27,6 +27,7 @@ use app\common\model\distribution\Distribution;
use app\common\model\distribution\DistributionLevel;
use app\common\server\ConfigServer;
use app\common\model\user\UserDistribution;
use app\common\logic\CityLogic;
use app\common\model\user\User;
use app\common\model\distribution\DistributionMemberApply;
use app\common\model\distribution\DistributionOrderGoods;
@ -133,7 +134,11 @@ class DistributionLogic extends Logic
'update_time' => $time,
];
DistributionMemberApply::create($data);
User::where("id",$user_id)->update(['url'=>$url['data']['qr_code']]);
$userUpdate = ['url' => $url['data']['qr_code']];
if (!empty($post['city'])) {
$userUpdate['city_id'] = (int)$post['city'];
}
User::where("id", $user_id)->update($userUpdate);
$distribution = Distribution::where("user_id",$user_id)->find();
$defaultLevelId = DistributionLevel::where('is_default', 1)->value('id');
$data = [
@ -263,7 +268,7 @@ class DistributionLogic extends Logic
try {
Db::startTrans();
$firstLeader = User::field(['id', 'first_leader', 'second_leader', 'third_leader', 'ancestor_relation','user_integral'])
$firstLeader = User::field(['id', 'first_leader', 'second_leader', 'third_leader', 'ancestor_relation','user_integral', 'city_id'])
->where(['distribution_code' => $post['code']])
->findOrEmpty();
if($firstLeader->isEmpty()) {
@ -298,6 +303,12 @@ class DistributionLogic extends Logic
'update_time' => time()
];
// 扫码进入时继承码主人的所属城市
$ownerCityId = CityLogic::getUserCityId((int)$firstLeader['id']);
if ($ownerCityId > 0) {
$data['city_id'] = $ownerCityId;
}
// 更新当前用户的分销关系
User::where(['id' => $post['user_id']])->update($data);
@ -368,7 +379,7 @@ class DistributionLogic extends Logic
try {
Db::startTrans();
$firstLeader = User::field(['id', 'first_leader', 'second_leader', 'third_leader', 'ancestor_relation','user_integral'])
$firstLeader = User::field(['id', 'first_leader', 'second_leader', 'third_leader', 'ancestor_relation','user_integral', 'city_id'])
->where(['id' => $post['user_id']])
->findOrEmpty();
if($firstLeader->isEmpty()) {
@ -389,6 +400,11 @@ class DistributionLogic extends Logic
'update_time' => time()
];
$ownerCityId = CityLogic::getUserCityId((int)$firstLeader['id']);
if ($ownerCityId > 0) {
$data['city_id'] = $ownerCityId;
}
// 更新当前用户的分销关系
User::where(['id' => $user_id])->update($data);
//通知用户

View File

@ -2,6 +2,7 @@
namespace app\api\logic;
use app\common\basics\Logic;
use app\common\logic\CityLogic;
use app\common\model\shop\Shop;
use app\common\model\shop\ShopGoodsCategory;
@ -27,18 +28,21 @@ class ShopGoodsCategoryLogic extends Logic
return $data;
}
public static function getCityGoodsCategory($city_id)
public static function getCityGoodsCategory($city_id, $params = [])
{
$shop_msg = Shop::where("city_id",$city_id)
->where("is_run",1)
->where("is_freeze",0)
->where("del",0)
->find();
$c = "";
if($shop_msg == null){
$shopId = 1;
}else{
$shopId = $shop_msg['id'];
$entryCity = CityLogic::getEntryCity([
'invite_code' => $params['invite_code'] ?? '',
'user_id' => (int)($params['user_id'] ?? 0),
]);
$shopId = (int)($entryCity['shop_id'] ?? 0);
if ($shopId <= 0) {
$city_id = (int)($entryCity['id'] ?? 0);
$shop_msg = Shop::where("city_id", $city_id)
->where("is_run", 1)
->where("is_freeze", 0)
->where("del", 0)
->find();
$shopId = $shop_msg == null ? 1 : (int)$shop_msg['id'];
}
$where = [
'del' => 0,

View File

@ -5,6 +5,7 @@ use app\common\basics\Logic;
use app\common\enum\GoodsEnum;
use app\common\enum\ShopAdEnum;
use app\common\enum\ShopEnum;
use app\common\logic\CityLogic;
use app\common\logic\QrCodeLogic;
use app\common\model\dev\DevRegion;
use app\common\model\shop\ShopAd;
@ -108,21 +109,32 @@ class ShopLogic extends Logic
return $shop;
}
public static function getShopCityInfo($city_id,$userId, $params = [])
public static function getShopCityInfo($city_id, $userId, $params = [])
{
// 未扫码进入:上海总部;扫码进入:码主人所属城市(忽略定位 city_id
$entryCity = CityLogic::getEntryCity([
'invite_code' => $params['invite_code'] ?? '',
'user_id' => (int)($params['user_id'] ?? 0),
]);
$city_id = (int)($entryCity['id'] ?? 0);
$entryShopId = (int)($entryCity['shop_id'] ?? 0);
// 记录统计信息(访问商铺用户量)
Event::listen('ShopStat', 'app\common\listener\ShopStat');
$shop_msg = Shop::where("city_id",$city_id)
->where("is_run",1)
->where("is_freeze",0)
->where("del",0)
->find();
$c = "";
if($shop_msg == null){
$c = "id = 1";
}else{
$c = "city_id = ".$city_id."";
if ($entryShopId > 0) {
$c = 'id = ' . $entryShopId;
} else {
$shop_msg = Shop::where("city_id", $city_id)
->where("is_run", 1)
->where("is_freeze", 0)
->where("del", 0)
->find();
if ($shop_msg == null) {
$c = "id = 1";
} else {
$c = "city_id = " . $city_id . "";
}
}
$field = [
@ -199,6 +211,8 @@ class ShopLogic extends Logic
'mobile' => ShopAd::where($adWhere)->where('terminal', ShopAdEnum::TERMINAL_MOBILE)->append([ 'link_path', 'link_query' ])->order('sort desc,id desc')->select()->toArray(),
];
$shop['entry_city'] = $entryCity;
return $shop;
}