|
@@ -0,0 +1,76 @@
|
|
|
+<?php namespace App\Http\Controllers\Api\Lottery;
|
|
|
+
|
|
|
+use App\Http\Controllers\Api\Api;
|
|
|
+use App\Models\Lottery\ScoreRecord as Model;
|
|
|
+use App\Http\Requests\Api\Lottery\ScoreRecord as Request;
|
|
|
+use App\Models\CustomAddr;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 积分抽奖记录
|
|
|
+ *
|
|
|
+ * @author 刘相欣
|
|
|
+ *
|
|
|
+ * */
|
|
|
+class ScoreRecord extends Api{
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取抽奖配置 /api/lottery_score_record/get_list
|
|
|
+ *
|
|
|
+ * */
|
|
|
+ public function get_list(Request $request,Model $Model){
|
|
|
+ // 接口验签
|
|
|
+ // $this->verify_sign();
|
|
|
+ // 验证参数
|
|
|
+ $request->scene('get_list')->validate();
|
|
|
+ // 检查登录
|
|
|
+ $uid = $this->checkLogin();
|
|
|
+ // 接受参数
|
|
|
+ $lotteryId = request('lottery_id',0);
|
|
|
+ //
|
|
|
+ $map = [['custom_uid','=',$uid],['lottery_id','=',$lotteryId]];
|
|
|
+ // 获取客户城市的数据
|
|
|
+ $list = $Model->query()->where($map)->orderByDesc('id')->get(['id','reward_name','contact_addr','status','insert_time'])->toArray();
|
|
|
+ // 处理请求
|
|
|
+ foreach ($list as $key => $value ) {
|
|
|
+ // 处理数据
|
|
|
+ $value['insert_time'] = date('m/d H:i',$value['insert_time']);
|
|
|
+ $value['state'] = $Model->getRecordState($value['status'],'name');
|
|
|
+ // 重组数据
|
|
|
+ $list[$key] = $value;
|
|
|
+ }
|
|
|
+ // 返回结果
|
|
|
+ return json_send(['code'=>'success','msg'=>'获取成功','data'=>$list]);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取抽奖配置 /api/lottery_score_record/set_addr
|
|
|
+ *
|
|
|
+ * */
|
|
|
+ public function set_addr(Request $request,Model $Model,CustomAddr $CustomAddr){
|
|
|
+ // 接口验签
|
|
|
+ // $this->verify_sign();
|
|
|
+ // 验证参数
|
|
|
+ $request->scene('set_addr')->validate();
|
|
|
+ // 检查登录
|
|
|
+ $uid = $this->checkLogin();
|
|
|
+ // 接受参数
|
|
|
+ $id = request('id',0);
|
|
|
+ $addrId = request('addr_id',0);
|
|
|
+ // 获取地址
|
|
|
+ $addr = $CustomAddr->getOne($addrId);
|
|
|
+ // 如果不存在数据
|
|
|
+ if( !$addr ) return json_send(['code'=>'error','msg'=>'地址有误,请核对','data'=>['error'=>'没有找到对应的地址']]);
|
|
|
+ // 重组数据
|
|
|
+ $addr = ['status'=>1,'contact_name'=>$addr['contact_name'],'contact_shop'=>$addr['contact_shop'],'contact_phone'=>$addr['contact_phone'],'contact_province'=>$addr['contact_province'],'contact_city'=>$addr['contact_city'],'contact_area'=>$addr['contact_area'],'contact_addr'=>$addr['contact_addr'],'update_time'=>time()];
|
|
|
+ // 组合条件
|
|
|
+ $map = [['custom_uid','=',$uid],['id','=',$id]];
|
|
|
+ // 获取客户城市的数据
|
|
|
+ $result = $Model->query()->where($map)->update($addr);
|
|
|
+ // 成功
|
|
|
+ if( !$result ) return json_send(['code'=>'error','msg'=>'地址填写失败','data'=>['error'=>'地址填写失败']]);
|
|
|
+ // 返回结果
|
|
|
+ return json_send(['code'=>'success','msg'=>'获取成功','data'=>['id'=>$id]]);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|