| xqd
@@ -288,7 +288,9 @@ class AlbumController extends Controller
|
|
|
if (Auth::loginUsingId($check->id)) {
|
|
|
$userAuth = Auth::user();
|
|
|
if($check->is_dealer ==0 && $request->input('agent_id')!=0){
|
|
|
- $userAuth->up_agent_id = $request->input('agent_id');
|
|
|
+ // if($request->input('agent_id')!=0){
|
|
|
+ $userAuth->up_agent_id = $request->input('agent_id');
|
|
|
+ // }
|
|
|
$add_record['agent_id'] = $request->input('agent_id');
|
|
|
$add_record['open_id'] = $check->wechat_open_id;
|
|
|
$add_record['action'] = 4;
|
| xqd
@@ -570,11 +572,14 @@ class AlbumController extends Controller
|
|
|
$address = AlbumAgentModel::where('id',$userAuth->up_agent_id)->first();
|
|
|
$goods->address = $address->address;
|
|
|
$goods->realname = $address->realname;
|
|
|
+ $goods->avatar = $address->avatar;
|
|
|
}else{
|
|
|
+ $ma = AlbumManufacturerModel::where('store_id',$store_id)->first();
|
|
|
$goods->price = '';
|
|
|
- $goods->mobile = '';
|
|
|
- $goods->address = '';
|
|
|
- $goods->realname = '';
|
|
|
+ $goods->mobile = $ma->phone;
|
|
|
+ $goods->address = $ma->address;
|
|
|
+ $goods->realname = $ma->name;
|
|
|
+ $goods->avatar = $ma->avatar;
|
|
|
}
|
|
|
$check_favorite = AlbumFavoriteModel::where([['user_id',$userAuth->id],['store_id',$store_id],['product_id',$goods['id']]])->first();
|
|
|
//dd($check_favorite);
|
| xqd
@@ -595,8 +600,6 @@ class AlbumController extends Controller
|
|
|
}else{
|
|
|
$goods->price = '';
|
|
|
$goods->mobile = '';
|
|
|
- $goods->address = '';
|
|
|
- $goods->realname = '';
|
|
|
}
|
|
|
$address = AlbumAgentModel::where('id',$agent_id)->first();
|
|
|
$goods->address = $address->address;
|
| xqd
@@ -872,6 +875,7 @@ class AlbumController extends Controller
|
|
|
}
|
|
|
$store_id = $request->input('store_id');
|
|
|
if($userAuth->is_dealer!=1) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '该用户不是经销商!', $validator->messages());
|
|
|
+ if($userAuth->up_agent_id==0) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '未选择经销商!', $validator->messages());
|
|
|
$user_agent = AlbumAgentModel::where('user_id',$userAuth->id)->first();
|
|
|
$count_user = AlbumWatchRecord::where([['agent_id',$user_agent->id],['store_id',$store_id]])->groupBy('open_id')->get();
|
|
|
|
| xqd
@@ -1262,9 +1266,6 @@ class AlbumController extends Controller
|
|
|
* @apiVersion 0.1.0
|
|
|
* @apiParam {int} [goods_id] 商品id
|
|
|
* @apiParam {int} [store_id] 商户id 模拟值为0
|
|
|
- * @apiParam {int} [type] 修改类型 0 电话 1 价格
|
|
|
- * @apiParam {string} [mobile] 电话号码
|
|
|
- * @apiParam {string} [address] 地址
|
|
|
* @apiParam {double} [price] 价格
|
|
|
* @apiSuccessExample {json} Success-Response:
|
|
|
* HTTP/1.1 200 OK
|
| xqd
@@ -1297,36 +1298,7 @@ class AlbumController extends Controller
|
|
|
//print_r($data);
|
|
|
$save = array();
|
|
|
$return_data = array();
|
|
|
- if($data['type'] == 0) {
|
|
|
- $save['mobile'] = $data['mobile'];
|
|
|
- $product = AlbumProductModel::where('store_id',$data['store_id'])->get();
|
|
|
- foreach($product as $key=>$val){
|
|
|
- $check = AlbumProductPriceModel::where([['agent_id',$agent_id],['store_id',$data['store_id']],['product_id',$val['id']]])->first();
|
|
|
- if(empty($check)){
|
|
|
- $save['agent_id'] = $agent_id;
|
|
|
- $save['store_id'] = $data['store_id'];
|
|
|
- $save['product_id'] = $val['id'];
|
|
|
- $res = AlbumProductPriceModel::create($save);
|
|
|
- }else{
|
|
|
- $res = AlbumProductPriceModel::where([['agent_id',$agent_id],['store_id',$data['store_id']],['product_id',$val['id']]])->update($save);
|
|
|
- }
|
|
|
- if(!$res){
|
|
|
- $return['msg'] = 'error';
|
|
|
- return $this->api($return);
|
|
|
- }
|
|
|
- }
|
|
|
- $update_agent['phone'] = $data['mobile'];
|
|
|
- $update_agent['address'] = $data['address'];
|
|
|
|
|
|
- $update_res = AlbumAgentModel::where('id',$agent_id)->update($update_agent);
|
|
|
- if(!$update_res){
|
|
|
- $return['msg'] = 'error';
|
|
|
- return $this->api($return);
|
|
|
- }
|
|
|
- $return_data['mobile'] = $data['mobile'];
|
|
|
- $return_data['address'] = $data['address'];
|
|
|
- $return['msg'] = 'success';
|
|
|
- } elseif ($data['type'] == 1){
|
|
|
$save['price'] = $data['price'];
|
|
|
$check = AlbumProductPriceModel::where([['agent_id',$agent_id],['store_id',$data['store_id']],['product_id',$data['goods_id']]])->first();
|
|
|
if(empty($check)){
|
| xqd
@@ -1343,7 +1315,7 @@ class AlbumController extends Controller
|
|
|
} else {
|
|
|
$return['msg'] = 'error';
|
|
|
}
|
|
|
- }
|
|
|
+
|
|
|
$return['data'] = $return_data;
|
|
|
return $this->api($return);
|
|
|
}
|