123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- <?php
- namespace App\Http\Controllers;
- use App\Models\BigGiftApply;
- use Carbon\Carbon;
- use Illuminate\Http\Request;
- use Illuminate\Support\Facades\Auth;
- use Illuminate\Support\Facades\DB;
- use Illuminate\Support\Facades\Log;
- class BigGiftApplyController extends Controller
- {
- public function GetApplyList(Request $request)
- {
- $page_index=$request->input('page_index');
- $page_size=$request->input('page_size');
- $num=($page_index-1)*$page_size;
- $name=Auth::user()->name;
- $search_name=$request->input('search_name');
- $search_nickname=$request->input('search_nickname');
- $status=$request->input('status');
- $apply=BigGiftApply::query();
- if (Auth::user()->role_id!=32){
- $apply->where('kefu',$name);
- }
- if ($search_nickname){
- $where=function ($q)use ($search_nickname){
- $q->where('nickname','like',"%$search_nickname%");
- };
- $apply->where($where);
- }
- if ($search_name){
- $where=function ($q)use ($search_name){
- $q->where('c_name','like',"%$search_name%")
- ->orwhere('c_mobile','like',"%$search_name%");
- };
- $apply->where($where);
- }
- $apply->where('status',$status);
- $total=$apply->count();
- $list=$apply->skip($num)->take($page_size)->get();
- return $this->success_list($list,'',$total);
- }
- public function Shenhe(Request $request)
- {
- $id=$request->input('id');
- $apply=BigGiftApply::where('id',$id)->first();
- if ($request->input('type')==1){
- $apply->status=1;
- }else{
- $apply->status=3;
- $apply->reason=$request->input('reason');
- }
- $apply->save();
- return $this->success([]);
- }
- public function UpdateBigGift(Request $request){
- $data=$request->all();
- $apply_id=$request->input('id')??null;
- DB::beginTransaction();
- if (!$apply_id){
- return $this->error(50021,'','异常!!');
- }
- $apply=BigGiftApply::find($apply_id);
- try {
- //商品详情
- $detail=$data['detail'];
- $apply->detail=json_encode($detail,true);
- //批发商信息
- $apply->c_mobile=$data['c_mobile'];
- $apply->c_name=$data['c_name'];
- //地址信息
- $apply->province=$data['province'];
- $apply->city=$data['city'];
- $apply->area=$data['area'];
- $apply->address=$data['address'];
- $apply->name=$data['name'];
- $apply->mobile=$data['mobile'];
- $apply->save();
- DB::commit();
- return $this->success([]);
- }catch (\Exception $exception){
- DB::rollBack();
- Log::error('提交大礼包申请出错'.$exception->getMessage());
- return $this->error(50021,'',$exception->getMessage());
- }
- }
- }
|