|
@@ -191,13 +191,13 @@ class Product extends Api{
|
|
|
// 显示
|
|
|
$map[] = ['status','=','0'];
|
|
|
// 查询
|
|
|
- $data = $Model->query()->where($map)->find($id,['id','hide_orderbtn','name','thumb','stock','spec','poster','price','business_id','market_price']);
|
|
|
+ $data = $Model->query()->where($map)->find($id,['id','hide_orderbtn','name','tag_scope','tag_exclude','thumb','stock','spec','poster','price','business_id','market_price']);
|
|
|
// 如果没有数据
|
|
|
if( !$data ) return json_send(['code'=>'error','msg'=>'产品已下架','data'=>['error'=>'产品已下架或不存在']]);
|
|
|
// 允许城市
|
|
|
$allowCity = $ProductCity->where([['product_id','=',$id]])->pluck('city_id')->toArray();
|
|
|
// 如果不是全国城市 也不是服务城市范围
|
|
|
- if ( !in_array(1,$allowCity) && !in_array($custom['city_id'],$allowCity) ) return json_send(['code'=>'error','msg'=>'您的城市不在该产品服务范围','data'=>['error'=>'您的城市不在该产品服务范围']]);
|
|
|
+ if ( !in_array(1,$allowCity) && ( isset($custom['city_id']) && !in_array($custom['city_id'],$allowCity)) ) return json_send(['code'=>'error','msg'=>'您的城市不在该产品服务范围','data'=>['error'=>'您的城市不在该产品服务范围']]);
|
|
|
// 转数组
|
|
|
$data = $data->toArray();
|
|
|
// 处理数据
|
|
@@ -292,13 +292,27 @@ class Product extends Api{
|
|
|
$data['regiment_active_id'] = null;
|
|
|
$data['regiment_type'] = 0;
|
|
|
}
|
|
|
-
|
|
|
// 查询用户标签
|
|
|
$tags = [];
|
|
|
$cityId = '';
|
|
|
if ($custom){
|
|
|
$tags = $WeiBanTags->getListByWeibanExtid($custom['weiban_extid']);
|
|
|
+ $tagsList = array_column($tags,'name');
|
|
|
$cityId = $custom['city_id'];
|
|
|
+ // 判断是不是可以参与
|
|
|
+ if( $data['tag_scope'] ) {
|
|
|
+ // 解析数组
|
|
|
+ $data['tag_scope'] = explode(',',$data['tag_scope']);
|
|
|
+ // 如果没有交集,不在参与范围内
|
|
|
+ if( !array_intersect($data['tag_scope'],$tagsList) ) return json_send(['code'=>'error','msg'=>'账号不在标签范围','data'=>['error'=>'账号不在标签范围']]);
|
|
|
+ }
|
|
|
+ // 判断是不是可以参与
|
|
|
+ if( $data['tag_exclude'] ) {
|
|
|
+ // 解析数组
|
|
|
+ $data['tag_exclude'] = explode(',',$data['tag_exclude']);
|
|
|
+ // 如果有交集,在排除范围内
|
|
|
+ if( array_intersect($data['tag_exclude'],$tagsList) ) return json_send(['code'=>'error','msg'=>'账号不在标签允许范围','data'=>['error'=>'账号不在标签允许范围']]);
|
|
|
+ }
|
|
|
}
|
|
|
//促销活动信息
|
|
|
$promoInfo = $PromoProduct->getListById($data['id']);
|