| xqd
@@ -2366,15 +2366,17 @@ class AlbumController extends Controller
|
|
|
public function albumCustomerGoodsDetail(Request $request)
|
|
|
{
|
|
|
$userAuth = Auth('api')->user();
|
|
|
- if(!$userAuth) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '未登录!');
|
|
|
+ if (!$userAuth) {
|
|
|
+ return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '未登录!');
|
|
|
+ }
|
|
|
$validator = Validator::make($request->all(), [
|
|
|
'store_id' => 'required',
|
|
|
- 'open_id'=>'required',
|
|
|
+ 'open_id' => 'required',
|
|
|
// 'end' => 'required',
|
|
|
// 'start' => 'required',
|
|
|
],[
|
|
|
- 'store_id.required'=>'缺少商户参数',
|
|
|
- 'open_id.required'=>'缺少用户参数',
|
|
|
+ 'store_id.required' => '缺少商户参数',
|
|
|
+ 'open_id.required' => '缺少用户参数',
|
|
|
// 'end.required'=>'缺少结束时间参数',
|
|
|
// 'start.required'=>'缺少开始时间参数',
|
|
|
]);
|
| xqd
@@ -2394,19 +2396,23 @@ class AlbumController extends Controller
|
|
|
}
|
|
|
$end= date('Y-m-d H:i:s',$end);
|
|
|
$start= date('Y-m-d H:i:s',$start);
|
|
|
- if($userAuth->is_dealer!=1) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '该用户不是经销商!', $validator->messages());
|
|
|
-
|
|
|
+ if ($userAuth->is_dealer!=1) {
|
|
|
+ return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '该用户不是经销商!', $validator->messages());
|
|
|
+ }
|
|
|
$user_agent = AlbumAgentModel::where('user_id',$userAuth->id)->first();
|
|
|
- if($user_agent) $res = AlbumWatchRecord::where([['action',3],['store_id',$store_id],['open_id',$open_id],['agent_id',$user_agent->id],['updated_at','>=',$start],['updated_at','<=',$end]])->orderByDesc('id')->get(['detail','created_at'])->toArray();
|
|
|
|
|
|
+ $res = AlbumWatchRecord::where([['action',3],['store_id',$store_id],['open_id',$open_id],['agent_id',$user_agent->id],['updated_at','>=',$start],['updated_at','<=',$end]])->orderByDesc('id')->get(['detail','created_at'])->toArray();
|
|
|
+ if (!$res) {
|
|
|
+ return $this->api([],0,'success');
|
|
|
+ }
|
|
|
$arr = array();
|
|
|
- foreach ($res as $key=>$val){
|
|
|
- $detail = json_decode($val['detail'],true);
|
|
|
+ foreach ($res as $key => $val) {
|
|
|
+ $detail = json_decode($val['detail'], true);
|
|
|
//dd($detail);die;
|
|
|
$goods_id = $detail['goods_id'];
|
|
|
- $goods = AlbumProductModel::where([['id',$goods_id]])->first();
|
|
|
+ $goods = AlbumProductModel::where([['id', $goods_id]])->first();
|
|
|
if($goods){
|
|
|
- $cat = AlbumCatModel::where([['store_id',$store_id],['id',$goods->cat_id]])->first();
|
|
|
+ $cat = AlbumCatModel::where([['store_id', $store_id],['id', $goods->cat_id]])->first();
|
|
|
|
|
|
if (!$cat) {
|
|
|
continue;
|