BigGiftApplyController.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Models\BigGiftApply;
  4. use Carbon\Carbon;
  5. use Illuminate\Http\Request;
  6. use Illuminate\Support\Facades\Auth;
  7. use Illuminate\Support\Facades\DB;
  8. use Illuminate\Support\Facades\Log;
  9. class BigGiftApplyController extends Controller
  10. {
  11. public function GetApplyList(Request $request)
  12. {
  13. $page_index=$request->input('page_index');
  14. $page_size=$request->input('page_size');
  15. $num=($page_index-1)*$page_size;
  16. $name=Auth::user()->name;
  17. $search_name=$request->input('search_name');
  18. $search_nickname=$request->input('search_nickname');
  19. $status=$request->input('status');
  20. $apply=BigGiftApply::query();
  21. if (Auth::user()->role_id!=32){
  22. $apply->where('kefu',$name);
  23. }
  24. if ($search_nickname){
  25. $where=function ($q)use ($search_nickname){
  26. $q->where('nickname','like',"%$search_nickname%");
  27. };
  28. $apply->where($where);
  29. }
  30. if ($search_name){
  31. $where=function ($q)use ($search_name){
  32. $q->where('c_name','like',"%$search_name%")
  33. ->orwhere('c_mobile','like',"%$search_name%");
  34. };
  35. $apply->where($where);
  36. }
  37. $apply->where('status',$status);
  38. $total=$apply->count();
  39. $list=$apply->skip($num)->take($page_size)->get();
  40. return $this->success_list($list,'',$total);
  41. }
  42. public function Shenhe(Request $request)
  43. {
  44. $id=$request->input('id');
  45. $apply=BigGiftApply::where('id',$id)->first();
  46. if ($request->input('type')==1){
  47. $apply->status=1;
  48. }else{
  49. $apply->status=3;
  50. $apply->reason=$request->input('reason');
  51. }
  52. $apply->save();
  53. return $this->success([]);
  54. }
  55. public function UpdateBigGift(Request $request){
  56. $data=$request->all();
  57. $apply_id=$request->input('id')??null;
  58. DB::beginTransaction();
  59. if (!$apply_id){
  60. return $this->error(50021,'','异常!!');
  61. }
  62. $apply=BigGiftApply::find($apply_id);
  63. try {
  64. //商品详情
  65. $detail=$data['detail'];
  66. $apply->detail=json_encode($detail,true);
  67. //批发商信息
  68. $apply->c_mobile=$data['c_mobile'];
  69. $apply->c_name=$data['c_name'];
  70. //地址信息
  71. $apply->province=$data['province'];
  72. $apply->city=$data['city'];
  73. $apply->area=$data['area'];
  74. $apply->address=$data['address'];
  75. $apply->name=$data['name'];
  76. $apply->mobile=$data['mobile'];
  77. $apply->save();
  78. DB::commit();
  79. return $this->success([]);
  80. }catch (\Exception $exception){
  81. DB::rollBack();
  82. Log::error('提交大礼包申请出错'.$exception->getMessage());
  83. return $this->error(50021,'',$exception->getMessage());
  84. }
  85. }
  86. }