配置修改
This commit is contained in:
@ -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);
|
||||
//通知用户
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user