|
@@ -158,6 +158,7 @@ class AlbumController extends Controller
|
|
* @apiPermission none
|
|
* @apiPermission none
|
|
* @apiVersion 0.1.0
|
|
* @apiVersion 0.1.0
|
|
* @apiParam {int} [code]
|
|
* @apiParam {int} [code]
|
|
|
|
+ * @apiParam {int} [agent_id] 经销商id
|
|
* @apiParam {int} [store_id] 商户id
|
|
* @apiParam {int} [store_id] 商户id
|
|
* @apiSuccessExample {json} Success-Response:
|
|
* @apiSuccessExample {json} Success-Response:
|
|
* HTTP/1.1 200 OK
|
|
* HTTP/1.1 200 OK
|
|
@@ -226,15 +227,13 @@ class AlbumController extends Controller
|
|
$add['store_id'] = $datas['store_id'];
|
|
$add['store_id'] = $datas['store_id'];
|
|
$res = AlbumXyxUserModel::create($add);
|
|
$res = AlbumXyxUserModel::create($add);
|
|
if($res){
|
|
if($res){
|
|
- $data_user = AlbumXyxUserModel::where('wechat_open_id',$res['openid'])->first();
|
|
|
|
|
|
+ $check = AlbumXyxUserModel::where('wechat_open_id',$res['openid'])->first();
|
|
$user = [
|
|
$user = [
|
|
-
|
|
|
|
- 'user_id'=>$data_user['id'],
|
|
|
|
- 'avatar'=>$data_user['avatar'],
|
|
|
|
- 'username'=>$data_user['username'],
|
|
|
|
|
|
+ 'user_id'=>$check['id'],
|
|
|
|
+ 'avatar'=>$check['avatar'],
|
|
|
|
+ 'username'=>$check['username'],
|
|
'is_agent'=>0,
|
|
'is_agent'=>0,
|
|
'agent_id'=>'',
|
|
'agent_id'=>'',
|
|
-
|
|
|
|
];
|
|
];
|
|
}else{
|
|
}else{
|
|
$user=[
|
|
$user=[
|
|
@@ -266,7 +265,16 @@ class AlbumController extends Controller
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- return $this->api($user);
|
|
|
|
|
|
+ if (Auth::loginUsingId($check->id)) {
|
|
|
|
+ $userAuth = Auth::user();
|
|
|
|
+ $save['up_agent_id'] = $request->input('agent_id');
|
|
|
|
+ $user->save();
|
|
|
|
+ $token = $userAuth->createToken($userAuth->id . '-' . $userAuth->openid)->accessToken;
|
|
|
|
+ return $this->api(compact('token', 'user', 'session_key'));
|
|
|
|
+ } else {
|
|
|
|
+
|
|
|
|
+ return $this->error(ErrorCode::INCORRECT_USER_OR_PASS);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -314,7 +322,6 @@ class AlbumController extends Controller
|
|
* @apiParam {int} [status] 状态 1 只选择热销 2 只选择最新上市 3只选择一个风格 4 同时选择热销和最新上市 5同时选择热销和风格 6同时选择最新上市和风格 7全选 0全不选
|
|
* @apiParam {int} [status] 状态 1 只选择热销 2 只选择最新上市 3只选择一个风格 4 同时选择热销和最新上市 5同时选择热销和风格 6同时选择最新上市和风格 7全选 0全不选
|
|
* @apiParam {int} [style] 风格
|
|
* @apiParam {int} [style] 风格
|
|
* @apiParam {int} [store_id] 商户id
|
|
* @apiParam {int} [store_id] 商户id
|
|
- * @apiParam {int} [agent_id] 经销商id
|
|
|
|
* @apiSuccessExample {json} Success-Response:
|
|
* @apiSuccessExample {json} Success-Response:
|
|
* HTTP/1.1 200 OK
|
|
* HTTP/1.1 200 OK
|
|
* {
|
|
* {
|
|
@@ -339,6 +346,7 @@ class AlbumController extends Controller
|
|
*/
|
|
*/
|
|
public function albumGoods(Request $request)
|
|
public function albumGoods(Request $request)
|
|
{
|
|
{
|
|
|
|
+ $userAuth = Auth('api')->user();
|
|
$validator = Validator::make($request->all(), [
|
|
$validator = Validator::make($request->all(), [
|
|
'cat_id' => 'required',
|
|
'cat_id' => 'required',
|
|
'store_id' => 'required',
|
|
'store_id' => 'required',
|
|
@@ -379,7 +387,7 @@ class AlbumController extends Controller
|
|
foreach($goods as $key =>$val){
|
|
foreach($goods as $key =>$val){
|
|
if(isset($data['agent_id'])){
|
|
if(isset($data['agent_id'])){
|
|
// dd(111);
|
|
// dd(111);
|
|
- $check = AlbumProductPriceModel::where([['agent_id',$data['agent_id']],['store_id',$data['store_id']],['product_id',$val['id']]])->first();
|
|
|
|
|
|
+ $check = AlbumProductPriceModel::where([['agent_id',$userAuth->up_agent_id],['store_id',$data['store_id']],['product_id',$val['id']]])->first();
|
|
if($check){
|
|
if($check){
|
|
$goods[$key]['price'] = $check->price;
|
|
$goods[$key]['price'] = $check->price;
|
|
}else{
|
|
}else{
|
|
@@ -403,7 +411,6 @@ class AlbumController extends Controller
|
|
* @apiPermission none
|
|
* @apiPermission none
|
|
* @apiVersion 0.1.0
|
|
* @apiVersion 0.1.0
|
|
* @apiParam {int} [goods_id] 商品id
|
|
* @apiParam {int} [goods_id] 商品id
|
|
- * @apiParam {int} [agent_id] 经销商id 模拟值为10
|
|
|
|
* @apiParam {int} [store_id] 商户id 模拟值为0
|
|
* @apiParam {int} [store_id] 商户id 模拟值为0
|
|
* @apiParam {int} [user_id] 用户id
|
|
* @apiParam {int} [user_id] 用户id
|
|
* @apiSuccessExample {json} Success-Response:
|
|
* @apiSuccessExample {json} Success-Response:
|
|
@@ -427,6 +434,7 @@ class AlbumController extends Controller
|
|
*/
|
|
*/
|
|
public function albumGoodsDetail(Request $request)
|
|
public function albumGoodsDetail(Request $request)
|
|
{
|
|
{
|
|
|
|
+ $userAuth = Auth('api')->user();
|
|
$validator = Validator::make($request->all(), [
|
|
$validator = Validator::make($request->all(), [
|
|
'goods_id' => 'required',
|
|
'goods_id' => 'required',
|
|
'user_id' => 'required',
|
|
'user_id' => 'required',
|
|
@@ -443,7 +451,7 @@ class AlbumController extends Controller
|
|
$user_id = request('user_id');
|
|
$user_id = request('user_id');
|
|
$goods = AlbumProductModel::where([['id',$goods_id],['store_id',$store_id]])->first();
|
|
$goods = AlbumProductModel::where([['id',$goods_id],['store_id',$store_id]])->first();
|
|
if(!empty($goods) && $agent_id != ''){
|
|
if(!empty($goods) && $agent_id != ''){
|
|
- $price = DB::table('album_product_price')->where([['agent_id',$agent_id],['store_id',$store_id],['product_id',$goods['id']]])->first();
|
|
|
|
|
|
+ $price = DB::table('album_product_price')->where([['agent_id',$userAuth->up_agent_id],['store_id',$store_id],['product_id',$goods['id']]])->first();
|
|
if(!empty($price)){
|
|
if(!empty($price)){
|
|
$goods->price = $price->price;
|
|
$goods->price = $price->price;
|
|
$goods->mobile = $price->mobile;
|
|
$goods->mobile = $price->mobile;
|
|
@@ -817,6 +825,7 @@ class AlbumController extends Controller
|
|
*/
|
|
*/
|
|
public function albumSetPrice(Request $request)
|
|
public function albumSetPrice(Request $request)
|
|
{
|
|
{
|
|
|
|
+ $userAuth = Auth('api')->user();
|
|
$data = $request->all();
|
|
$data = $request->all();
|
|
//print_r($data);
|
|
//print_r($data);
|
|
$save = array();
|
|
$save = array();
|
|
@@ -825,14 +834,14 @@ class AlbumController extends Controller
|
|
$save['mobile'] = $data['mobile'];
|
|
$save['mobile'] = $data['mobile'];
|
|
$product = AlbumProductModel::where('store_id',$data['store_id'])->get();
|
|
$product = AlbumProductModel::where('store_id',$data['store_id'])->get();
|
|
foreach($product as $key=>$val){
|
|
foreach($product as $key=>$val){
|
|
- $check = AlbumProductPriceModel::where([['agent_id',$data['agent_id']],['store_id',$data['store_id']],['product_id',$val['id']]])->first();
|
|
|
|
|
|
+ $check = AlbumProductPriceModel::where([['agent_id',$userAuth->up_agent_id],['store_id',$data['store_id']],['product_id',$val['id']]])->first();
|
|
if(empty($check)){
|
|
if(empty($check)){
|
|
$save['agent_id'] = $data['agent_id'];
|
|
$save['agent_id'] = $data['agent_id'];
|
|
$save['store_id'] = $data['store_id'];
|
|
$save['store_id'] = $data['store_id'];
|
|
$save['product_id'] = $val['id'];
|
|
$save['product_id'] = $val['id'];
|
|
$res = AlbumProductPriceModel::create($save);
|
|
$res = AlbumProductPriceModel::create($save);
|
|
}else{
|
|
}else{
|
|
- $res = AlbumProductPriceModel::where([['agent_id',$data['agent_id']],['store_id',$data['store_id']],['product_id',$val['id']]])->update($save);
|
|
|
|
|
|
+ $res = AlbumProductPriceModel::where([['agent_id',$userAuth->up_agent_id],['store_id',$data['store_id']],['product_id',$val['id']]])->update($save);
|
|
}
|
|
}
|
|
if(!$res){
|
|
if(!$res){
|
|
$return['msg'] = 'error';
|
|
$return['msg'] = 'error';
|
|
@@ -852,14 +861,14 @@ class AlbumController extends Controller
|
|
$return['msg'] = 'success';
|
|
$return['msg'] = 'success';
|
|
} elseif ($data['type'] == 1){
|
|
} elseif ($data['type'] == 1){
|
|
$save['price'] = $data['price'];
|
|
$save['price'] = $data['price'];
|
|
- $check = AlbumProductPriceModel::where([['agent_id',$data['agent_id']],['store_id',$data['store_id']],['product_id',$data['goods_id']]])->first();
|
|
|
|
|
|
+ $check = AlbumProductPriceModel::where([['agent_id',$userAuth->up_agent_id],['store_id',$data['store_id']],['product_id',$data['goods_id']]])->first();
|
|
if(empty($check)){
|
|
if(empty($check)){
|
|
$save['agent_id'] = $data['agent_id'];
|
|
$save['agent_id'] = $data['agent_id'];
|
|
$save['store_id'] = $data['store_id'];
|
|
$save['store_id'] = $data['store_id'];
|
|
$save['product_id'] = $data['goods_id'];
|
|
$save['product_id'] = $data['goods_id'];
|
|
$res = AlbumProductPriceModel::create($save);
|
|
$res = AlbumProductPriceModel::create($save);
|
|
}else{
|
|
}else{
|
|
- $res = AlbumProductPriceModel::where([['agent_id',$data['agent_id']],['store_id',$data['store_id']],['product_id',$data['goods_id']]])->update($save);
|
|
|
|
|
|
+ $res = AlbumProductPriceModel::where([['agent_id',$userAuth->up_agent_id],['store_id',$data['store_id']],['product_id',$data['goods_id']]])->update($save);
|
|
}
|
|
}
|
|
if($res){
|
|
if($res){
|
|
$return['msg'] = 'success';
|
|
$return['msg'] = 'success';
|