| xqd
@@ -558,8 +558,8 @@ class AlbumController extends Controller
|
|
|
if(!empty($price)){
|
|
|
$goods->price = $price->price;
|
|
|
$goods->mobile = $price->mobile;
|
|
|
- $address = AlbumAgentModel::where('id',$userAuth->up_agent_id)->first();
|
|
|
- $goods->address = $address;
|
|
|
+ $address = AlbumAgentModel::where('id',$agent_id)->first();
|
|
|
+ $goods->address = $address->address;
|
|
|
}else{
|
|
|
$goods->price = '';
|
|
|
$goods->mobile = '';
|
| xqd
@@ -1046,7 +1046,6 @@ class AlbumController extends Controller
|
|
|
* @apiPermission none
|
|
|
* @apiVersion 0.1.0
|
|
|
* @apiParam {int} [goods_id] 商品id
|
|
|
- * @apiParam {int} [agent_id] 经销商id 模拟值为10
|
|
|
* @apiParam {int} [store_id] 商户id 模拟值为0
|
|
|
* @apiParam {int} [type] 修改类型 0 电话 1 价格
|
|
|
* @apiParam {string} [mobile] 电话号码
|
| xqd
@@ -1077,6 +1076,8 @@ class AlbumController extends Controller
|
|
|
public function albumSetPrice(Request $request)
|
|
|
{
|
|
|
$userAuth = Auth('api')->user();
|
|
|
+ $user_agent = AlbumAgentModel::where('user_id',$userAuth->id)->first();
|
|
|
+ $agent_id = $user_agent['id'];
|
|
|
$data = $request->all();
|
|
|
//print_r($data);
|
|
|
$save = array();
|
| xqd
@@ -1085,14 +1086,14 @@ class AlbumController extends Controller
|
|
|
$save['mobile'] = $data['mobile'];
|
|
|
$product = AlbumProductModel::where('store_id',$data['store_id'])->get();
|
|
|
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',$agent_id],['store_id',$data['store_id']],['product_id',$val['id']]])->first();
|
|
|
if(empty($check)){
|
|
|
$save['agent_id'] = $data['agent_id'];
|
|
|
$save['store_id'] = $data['store_id'];
|
|
|
$save['product_id'] = $val['id'];
|
|
|
$res = AlbumProductPriceModel::create($save);
|
|
|
}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',$agent_id],['store_id',$data['store_id']],['product_id',$val['id']]])->update($save);
|
|
|
}
|
|
|
if(!$res){
|
|
|
$return['msg'] = 'error';
|
| xqd
@@ -1102,7 +1103,7 @@ class AlbumController extends Controller
|
|
|
$update_agent['phone'] = $data['mobile'];
|
|
|
$update_agent['address'] = $data['address'];
|
|
|
|
|
|
- $update_res = AlbumAgentModel::where('id',$data['agent_id'])->update($update_agent);
|
|
|
+ $update_res = AlbumAgentModel::where('id',$agent_id)->update($update_agent);
|
|
|
if(!$update_res){
|
|
|
$return['msg'] = 'error';
|
|
|
return $this->api($return);
|
| xqd
@@ -1112,14 +1113,14 @@ class AlbumController extends Controller
|
|
|
$return['msg'] = 'success';
|
|
|
} elseif ($data['type'] == 1){
|
|
|
$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',$agent_id],['store_id',$data['store_id']],['product_id',$data['goods_id']]])->first();
|
|
|
if(empty($check)){
|
|
|
$save['agent_id'] = $data['agent_id'];
|
|
|
$save['store_id'] = $data['store_id'];
|
|
|
$save['product_id'] = $data['goods_id'];
|
|
|
$res = AlbumProductPriceModel::create($save);
|
|
|
}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',$agent_id],['store_id',$data['store_id']],['product_id',$data['goods_id']]])->update($save);
|
|
|
}
|
|
|
if($res){
|
|
|
$return['msg'] = 'success';
|