diff --git a/app/Admin/Controllers/AccountController.php b/app/Admin/Controllers/AccountController.php new file mode 100644 index 0000000..adcdc24 --- /dev/null +++ b/app/Admin/Controllers/AccountController.php @@ -0,0 +1,161 @@ +mobile; + $nickname = $request->nickname; + $start = $request->start; + $end = $request->end; + $orderField = $request->orderField; + $orderDirection = $request->orderDirection; + $numPerPage = $request->numPerPage ?: 30; + + $accounts = UserAccount::when($mobile, function ($query) use ($mobile) { + $query->whereHas('user', function ($query) use ($mobile) { + $query->where('mobile', 'like', "%{$mobile}%"); + }); + })->when($nickname, function ($query) use ($nickname) { + $query->whereHas('user.info', function ($query) use ($nickname) { + $query->where('nickname', 'like', "%{$nickname}%"); + }); + })->when($start && $end, function ($query) use ($start, $end) { + return $query->whereBetween('created_at', [$start, date('Y-m-d', strtotime("+1 days", strtotime($end)))]); + })->when($start && !$end, function ($query) use ($start) { + return $query->where('created_at', '>=', $start); + })->when(!$start && $end, function ($query) use ($end) { + return $query->where('created_at', '<=', date('Y-m-d', strtotime("+1 days", strtotime($end)))); + })->when($orderField, function ($query) use ($orderField, $orderDirection) { + $query->orderBy($orderField, $orderDirection); + })->with(['user'])->latest()->paginate($numPerPage); + + return view('Admin::accounts.index', compact('accounts')); + } + + public function rules(Request $request) + { + $title = $request->title; + $orderField = $request->orderField; + $orderDirection = $request->orderDirection; + $numPerPage = $request->numPerPage ?: 30; + + $rules = UserAccountRule::when($title, function ($query) use ($title) { + $query->where('title', 'like', "%{$title}%"); + })->when($orderField, function ($query) use ($orderField, $orderDirection) { + $query->orderBy($orderField, $orderDirection); + })->latest()->paginate($numPerPage); + return view('Admin::accounts.rules', compact('rules')); + } + + public function logs(Request $request) + { + $mobile = $request->mobile; + $rule_id = $request->rule_id; + $nickname = $request->nickname; + $start = $request->start; + $end = $request->end; + $orderField = $request->orderField; + $orderDirection = $request->orderDirection; + $numPerPage = $request->numPerPage ?: 30; + + $logs = UserAccountLog::when($mobile, function ($query) use ($mobile) { + $query->whereHas('user', function ($query) use ($mobile) { + $query->where('mobile', 'like', "%{$mobile}%"); + }); + })->when($nickname, function ($query) use ($nickname) { + $query->whereHas('user.info', function ($query) use ($nickname) { + $query->where('nickname', 'like', "%{$nickname}%"); + }); + })->when($rule_id, function ($query) use ($rule_id) { + return $query->where('rule_id', $rule_id); + })->when($start && $end, function ($query) use ($start, $end) { + return $query->whereBetween('created_at', [$start, date('Y-m-d', strtotime("+1 days", strtotime($end)))]); + })->when($start && !$end, function ($query) use ($start) { + return $query->where('created_at', '>=', $start); + })->when(!$start && $end, function ($query) use ($end) { + return $query->where('created_at', '<=', date('Y-m-d', strtotime("+1 days", strtotime($end)))); + })->when($orderField, function ($query) use ($orderField, $orderDirection) { + $query->orderBy($orderField, $orderDirection); + })->with(['user.info', 'rule'])->latest()->orderBy('id', 'desc')->paginate($numPerPage); + + $rules = UserAccountRule::get(); + return view('Admin::accounts.logs', compact('logs', 'rules')); + } + + /** + * 提现申请 + * @Author: + * @Date:2018-11-08T16:48:31+0800 + * @param Request $request [description] + * @return [type] [description] + */ + public function withdraws(Request $request) + { + $mobile = $request->mobile; + $nickname = $request->nickname; + $start = $request->start; + $end = $request->end; + $orderField = $request->orderField; + $orderDirection = $request->orderDirection; + $numPerPage = $request->numPerPage ?: 30; + + $withdraws = Withdraw::when($mobile, function ($query) use ($mobile) { + $query->whereHas('user', function ($query) use ($mobile) { + $query->where('mobile', 'like', "%{$mobile}%"); + }); + })->when($nickname, function ($query) use ($nickname) { + $query->whereHas('user.info', function ($query) use ($nickname) { + $query->where('nickname', 'like', "%{$nickname}%"); + }); + })->when($start && $end, function ($query) use ($start, $end) { + return $query->whereBetween('created_at', [$start, date('Y-m-d', strtotime("+1 days", strtotime($end)))]); + })->when($start && !$end, function ($query) use ($start) { + return $query->where('created_at', '>=', $start); + })->when(!$start && $end, function ($query) use ($end) { + return $query->where('created_at', '<=', date('Y-m-d', strtotime("+1 days", strtotime($end)))); + })->when($orderField, function ($query) use ($orderField, $orderDirection) { + $query->orderBy($orderField, $orderDirection); + })->with(['user.info'])->latest()->paginate($numPerPage); + return view('Admin::accounts.withdraws', compact('withdraws')); + } + + /** + * 通过提现申请 + * @Author: + * @Date:2018-11-08T16:48:10+0800 + * @param Request $request [description] + * @param Withdraw $withdraw [description] + * @return [type] [description] + */ + public function approve(Request $request, Withdraw $withdraw) + { + + } + + /** + * 驳回提现申请 + * @Author: + * @Date:2018-11-08T16:48:19+0800 + * @param Request $request [description] + * @param Withdraw $withdraw [description] + * @return [type] [description] + */ + public function reject(Request $request, Withdraw $withdraw) + { + if ($request->isMethod('POST')) { + # code... + } else { + return view('Admin::accounts.reject', compact('withdraw')); + } + } +} diff --git a/app/Admin/Controllers/ActivityController.php b/app/Admin/Controllers/ActivityController.php new file mode 100644 index 0000000..0db994d --- /dev/null +++ b/app/Admin/Controllers/ActivityController.php @@ -0,0 +1,271 @@ +seller->type != 'seller') { + return $this->error('您没有权限'); + } + + $title = $request->title; + $orderField = $request->orderField; + $orderDirection = $request->orderDirection; + $numPerPage = $request->numPerPage ?: 30; + + $activities = Activity::when($title, function ($query) use ($title) { + $query->where('title', 'like', "%{$title}%"); + }) + ->when($orderField, function ($query) use ($orderField, $orderDirection) { + $query->orderBy($orderField, $orderDirection); + })->orderBy('id', 'desc')->paginate($numPerPage); + + return view('Admin::activities.index', compact('activities')); + } + + public function create(Request $request) + { + $categoies = Category::treeSelect(2); + $sellers = Seller::where('status', 1)->where('type', 'seller')->get(); + + return view('Admin::activities.create', compact('categoies', 'sellers')); + } + + public function store(Request $request) + { + $validator = Validator::make($request->all(), [ + 'title' => 'required|max:100', + 'description' => 'required|max:200', + 'content' => 'required', + 'storage_id' => 'required', + 'start_time' => 'required', + 'end_time' => 'required', + + ], [ + 'title.required' => '名称必须填写', + 'title.max' => '名称长度应在:max以内', + 'description.required' => '简介必须填写', + 'content.required' => '内容必须填写', + 'storage_id.required' => '标题图必须上传', + 'start_time.required' => '开始时间必须填写', + 'end_time.required' => '结束时间必须填写', + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + + if ($request->end_time < $request->start_time) { + return $this->error('结束时间必须大于开始时间'); + } + + if (Activity::create($request->all())) { + return $this->success('新增活动成功', 'close'); + } else { + return $this->error(); + } + } + + public function edit(Activity $activity) + { + $categoies = Category::treeSelect(2); + $sellers = Seller::where('status', 1)->where('type', 'seller')->get(); + return view('Admin::activities.edit', compact('activity', 'categoies', 'sellers')); + } + + public function update(Request $request, Activity $activity) + { + $validator = Validator::make($request->all(), [ + 'title' => 'required|max:100', + 'description' => 'required|max:200', + 'content' => 'required', + 'storage_id' => 'required', + 'start_time' => 'required', + 'end_time' => 'required', + + ], [ + 'title.required' => '名称必须填写', + 'title.max' => '名称长度应在:max以内', + 'description.required' => '简介必须填写', + 'content.required' => '内容必须填写', + 'storage_id.required' => '标题图必须上传', + 'start_time.required' => '开始时间必须填写', + 'end_time.required' => '结束时间必须填写', + ]); + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + if ($request->end_time < $request->start_time) { + return $this->error('结束时间必须大于开始时间'); + } + $data = $request->all(); + $activity->update($data); + return $this->success('编辑完成', 'close'); + } + + public function destroy(Activity $activity) + { + if ($activity->delete()) { + return $this->success(); + } else { + return $this->error(); + } + } + + public function show(Activity $activity) + { + $gifts = $activity->gifts()->paginate(30); + return view('Admin::activities.show', compact('gifts', 'activity')); + } + + public function giftsCreate(Activity $activity) + { + $sellers = Seller::where('status', 1)->get(); + return view('Admin::activities.giftsCreate', compact('sellers', 'activity')); + } + + public function giftsStore(Request $request, Activity $activity) + { + $validator = Validator::make($request->all(), [ + 'goods_id' => 'required|numeric|min:1', + 'param_id' => 'required|numeric|min:1', + 'mode' => 'required|numeric', + 'consume_mode' => 'required|numeric', + + ], [ + 'goods_id.required' => '商品必须选择', + 'param_id.required' => '规格必须选择', + 'goods_id.min' => '商品必须选择', + 'param_id.min' => '规格必须选择', + 'mode.required' => '任务指标必须填写', + 'consume_mode.required' => '消耗业绩必须填写', + 'goods_id.numeric' => '商品必须为数字', + 'param_id.numeric' => '规格必须为数字', + 'mode.numeric' => '任务指标必须为数字', + 'consume_mode.numeric' => '消耗业绩必须为数字', + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + if ($request->consume_mode > $request->mode) { + return $this->error('消耗业绩不能大于任务指标'); + } + + if ($activity->gifts()->create($request->all())) { + return $this->success('添加奖品成功', 'close'); + } else { + return $this->error(); + } + } + + public function giftsEdit(ActivityGift $gift) + { + $sellers = Seller::where('status', 1)->get(); + $goods = Goods::where('status', 1) + ->whereHas('params', function ($query) {return $query->where('stock', '>', 0)->where('status', 1);}) + ->where('seller_id', $gift->goods->seller_id) + ->get(); + $params = GoodsParams::where('status', 1) + ->where('goods_id', $gift->goods_id) + ->get(); + + return view('Admin::activities.giftsEdit', compact('sellers', 'goods', 'params', 'gift')); + + } + + public function giftsUpdate(Request $request, ActivityGift $gift) + { + $validator = Validator::make($request->all(), [ + 'goods_id' => 'required|numeric|min:1', + 'param_id' => 'required|numeric|min:1', + 'mode' => 'required|numeric', + 'consume_mode' => 'required|numeric', + + ], [ + 'goods_id.required' => '商品必须选择', + 'param_id.required' => '规格必须选择', + 'goods_id.min' => '商品必须选择', + 'param_id.min' => '规格必须选择', + 'mode.required' => '任务指标必须填写', + 'consume_mode.required' => '消耗业绩必须填写', + 'goods_id.numeric' => '商品必须为数字', + 'param_id.numeric' => '规格必须为数字', + 'mode.numeric' => '任务指标必须为数字', + 'consume_mode.numeric' => '消耗业绩必须为数字', + ]); + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + $data = $request->all(); + $gift->update($data); + return $this->success('', 'close'); + } + + public function giftsDestroy(ActivityGift $gift) + { + if ($gift->delete()) { + return $this->success(); + } else { + return $this->error(); + } + } + + public function goods(Request $request) + { + if (empty($request->seller_id)) { + return ['msg' => '请选择商户', 'code' => 0]; + } + + $goods = Goods::where('status', 1) + ->whereHas('params', function ($query) {return $query->where('stock', '>', 0)->where('status', 1);}) + ->where('seller_id', $request->seller_id) + ->select('id', 'title')->get(); + $data = []; + foreach ($goods as $key => $good) { + $data[$key]['id'] = $good->id; + $data[$key]['title'] = $good->title; + } + + if ($data) { + return response()->json(['msg' => '', 'code' => 1, 'data' => $data]); + } else { + return ['msg' => '请选择商户', 'code' => 0]; + } + } + + public function params(Request $request) + { + if (empty($request->goods_id)) { + return ['msg' => '请选择商品', 'code' => 0]; + } + + $params = GoodsParams::where('status', 1) + ->where('goods_id', $request->goods_id) + ->select('id', 'value', 'price', 'cost')->get(); + $data = []; + foreach ($params as $key => $param) { + $data[$key]['id'] = $param->id; + $data[$key]['title'] = $param->value . ' - 售价' . $param->price . ' - 成本' . $param->cost; + } + + if ($data) { + return response()->json(['msg' => '', 'code' => 1, 'data' => $data]); + } else { + return ['msg' => '请选择商品', 'code' => 0]; + } + } + +} diff --git a/app/Admin/Controllers/AdvertController.php b/app/Admin/Controllers/AdvertController.php new file mode 100644 index 0000000..1eb5c39 --- /dev/null +++ b/app/Admin/Controllers/AdvertController.php @@ -0,0 +1,110 @@ + '资讯模型', + 'Goods' => '商品模型', + ]; + + public function index(Request $request) + { + $orderField = $request->orderField; + $orderDirection = $request->orderDirection; + $numPerPage = $request->numPerPage ?: 30; + $model = $request->model; + + $adverts = Advert::when($orderField, function ($query) use ($orderField, $orderDirection) { + $query->orderBy($orderField, $orderDirection); + }) + ->when($model, function ($query) use ($model) { + $query->where('advertable_type', 'like', "%{$model}%"); + }) + ->paginate($numPerPage); + + return view('Admin::adverts.index', compact('adverts')); + } + + public function create() + { + $models = $this->models; + return view('Admin::adverts.create', compact('models')); + } + + public function store(Request $request) + { + + $validator = Validator::make($request->all(), [ + 'sort' => 'required|numeric', + 'storage_id' => 'required', + ], [ + 'sort.required' => '排序必须填写', + 'sort.numeric' => '排序只能是数字', + 'url.required' => 'url必须填写', + 'url.url' => 'url格式不正确', + 'storage_id.required' => '图片必须上传', + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + + Advert::create([ + 'storage_id' => $request->storage_id, + 'sort' => $request->sort, + 'url' => $request->url, + ]); + + return $this->success('轮播创建成功', 'close'); + } + + public function edit(Advert $advert) + { + $models = $this->models; + return view('Admin::adverts.edit', compact('models', 'advert')); + } + + public function update(Request $request, Advert $advert) + { + $validator = Validator::make($request->all(), [ + 'sort' => 'required|numeric', + 'storage_id' => 'required', + ], [ + 'sort.required' => '排序必须填写', + 'sort.numeric' => '排序只能是数字', + 'url.required' => 'url必须填写', + 'url.url' => 'url格式不正确', + 'storage_id.required' => '图片必须上传', + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + + $advert->update([ + 'storage_id' => $request->storage_id, + 'sort' => $request->sort, + 'url' => $request->url, + ]); + + return $this->success('轮播更新成功', 'close'); + } + + public function destroy(Advert $advert) + { + if ($advert->delete()) { + return $this->success(); + } else { + return $this->error(); + } + } +} diff --git a/app/Admin/Controllers/AgencyController.php b/app/Admin/Controllers/AgencyController.php new file mode 100644 index 0000000..b8cc045 --- /dev/null +++ b/app/Admin/Controllers/AgencyController.php @@ -0,0 +1,150 @@ +orderField; + $orderDirection = $request->orderDirection; + $numPerPage = $request->numPerPage ?: 30; + + $lists = Agency::paginate($numPerPage); + + return view('Admin::agency.index', compact('lists')); + } + + public function create() + { + $salesmans = User::where('is_salesman', 1)->get(); + return view('Admin::agency.create', compact('salesmans')); + } + + public function store(Request $request) + { + $validator = Validator::make($request->all(), [ + 'name' => 'required|min:2|max:50', + 'status' => 'required', + ], [ + 'name.required' => '名称必须填写', + 'name.min' => '名称最少为:min字符', + 'name.max' => '名称最多为:max字符', + 'status.required' => '状态必须选择', + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + if (Agency::create($request->all())) { + return $this->success('', 'close'); + } else { + return $this->error(); + } + } + + public function edit(Agency $agency) + { + $salesmans = User::where('is_salesman', 1)->get(); + return view('Admin::agency.edit', compact('agency', 'salesmans')); + } + + public function update(Request $request, Agency $agency) + { + $validator = Validator::make($request->all(), [ + 'name' => 'required|min:2|max:50', + 'status' => 'required', + ], [ + 'name.required' => '名称必须填写', + 'name.min' => '名称最少为:min字符', + 'name.max' => '名称最多为:max字符', + 'status.required' => '状态必须选择', + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + + if ($agency->update($request->all())) { + return $this->success('', 'close'); + } else { + return $this->error(); + } + } + + //设置管理人 + public function user(Request $request, Agency $agency) + { + return view('Admin::agency.user', compact('agency')); + } + + public function douser(Request $request, Agency $agency) + { + $validator = Validator::make($request->all(), [ + 'mobile' => 'required|exists:users', + 'user_id' => 'required|unique:agencies,user_id', + ], [ + 'mobile.required' => '请输入手机号', + 'mobile.exists' => '手机号不存在', + 'user_id.required' => '请点击校验按钮', + 'user_id.unique' => '此人已经是代理了', + + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + + if ($agency->update(['user_id' => $request->user_id])) { + $agency->user->identityUpdate(2, 'AgencyUp'); + return $this->success('', 'close'); + } else { + return $this->error(''); + } + } + + public function show() + { + #Todo.. + } + + //删除 + public function delete(Agency $agency) + { + if ($agency->delete()) { + return $this->success('删除成功'); + } else { + return $this->error('删除成功'); + + } + } + + public function checkuser(Request $request) + { + $validator = Validator::make($request->all(), [ + 'mobile' => ['required', 'exists:users', new Checkmobile], + ], [ + 'mobile.required' => '手机号必须填写', + 'mobile.exists' => '手机号不存在', + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + + $user = User::where('mobile', $request->mobile)->first(); + $agency = Agency::where('user_id', $user->id)->first(); + if ($agency) { + return $this->error('此人已经是代理了'); + } + return $this->success(['user_id' => $user->id, 'nickname' => $user->info->nickname]); + } + +} diff --git a/app/Admin/Controllers/AreaController.php b/app/Admin/Controllers/AreaController.php new file mode 100644 index 0000000..5b0e635 --- /dev/null +++ b/app/Admin/Controllers/AreaController.php @@ -0,0 +1,182 @@ +info; + $type = $request->type; + $status = $request->status; + $psn = $request->psn; + + $numPerPage = $request->numPerPage ?: 30; + + $areas = OpenArea::when($info, function ($query) use ($info) { + $query->where('info', 'like', "%{$info}%"); + })->when($type, function ($query) use ($type) { + $query->where('type', $type); + })->when(is_numeric($status), function ($query) use ($status) { + $query->where('status', $status); + })->when($psn, function ($query) use ($psn) { + $query->where('psn', $psn); + })->orderBy('sn', 'asc')->whereNotNull('psn')->paginate($numPerPage); + + $list = OpenArea::treeShow(); + + return view('Admin::areas.index', compact('areas', 'list')); + } + + public function create(Request $request) + { + $list = OpenArea::treeShow(); + return view('Admin::areas.create', compact('list')); + } + + public function store(Request $request) + { + + $validator = Validator::make($request->all(), [ + 'name' => 'required|min:2|max:50', + 'psn' => 'required', + ], [ + 'name.required' => '名称必须填写', + 'name.min' => '名称最少为:min字符', + 'name.max' => '名称最多为:max字符', + 'psn.required' => '所属必须选择', + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + + $name = $request->name; + $psn = $request->psn; + $status = $request->status; + + $parent = OpenArea::where('sn', $request->psn)->first(); + $last = OpenArea::where('psn', $parent->sn)->orderBy('sn', 'desc')->first(); + + if ($last) { + $sn = $last->sn + 1; + } else { + $sn = $parent->sn + 1; + } + + $data = [ + 'sn' => $sn, + 'psn' => $parent->sn, + 'province' => $parent->province, + 'city' => $parent->city, + 'area' => $name, + 'name' => $name, + 'shortname' => $request->name, + 'info' => $parent->info . ',' . $name, + 'shortinfo' => $parent->shortinfo . ',' . $name, + 'type' => '县级', + 'depth' => 3, + 'zone' => '', + 'zip' => '', + 'cnname' => '', + 'enname' => '', + 'name_first_char' => '', + 'center' => '', + 'lng' => '', + 'lat' => '', + 'status' => $status, + ]; + + if (OpenArea::create($data)) { + return $this->success('', 'close'); + } else { + return $this->error(); + } + } + + public function edit(OpenArea $area) + { + $list = OpenArea::treeShow(); + return view('Admin::areas.edit', compact('area', 'list')); + } + + public function update(Request $request, OpenArea $area) + { + + $validator = Validator::make($request->all(), [ + 'name' => 'required|min:2|max:50', + 'psn' => 'required', + ], [ + 'name.required' => '名称必须填写', + 'name.min' => '名称最少为:min字符', + 'name.max' => '名称最多为:max字符', + 'psn.required' => '所属必须选择', + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + + $name = $request->name; + $psn = $request->psn; + $status = $request->status; + + $parent = OpenArea::where('sn', $request->psn)->first(); + + $data = [ + 'area' => $name, + 'name' => $name, + 'shortname' => $name, + 'info' => $parent->info . ',' . $name, + 'shortinfo' => $parent->shortinfo . ',' . $name, + 'status' => $status, + ]; + + if ($area->update($request->all())) { + return $this->success('', 'close'); + } else { + return $this->error(); + } + } + + public function open(Request $request, OpenArea $area) + { + $status = $request->status; + + $info = OpenArea::when($area, function ($query) use ($area) { + switch ($area->depth) { + case 1: + $query->where('province', $area->name); + break; + case 2: + $query->where('city', $area->name); + break; + case 3: + $query->where('area', $area->name); + break; + } + })->update(['status' => $status]); + + if ($info) { + return $this->success('设置成功'); + } else { + return $this->error('设置失败'); + } + } + + public function hot(Request $request, OpenArea $area) + { + if ($area->update($request->all())) { + return $this->success('设置成功'); + } else { + return $this->error('设置失败'); + } + } + +} diff --git a/app/Admin/Controllers/ArticleController.php b/app/Admin/Controllers/ArticleController.php new file mode 100644 index 0000000..e0ed391 --- /dev/null +++ b/app/Admin/Controllers/ArticleController.php @@ -0,0 +1,117 @@ +title; + $orderField = $request->orderField; + $orderDirection = $request->orderDirection; + $numPerPage = $request->numPerPage ?: 30; + $type = 'notices'; + + $articles = Article::where('type', $type) + ->when($title, function ($query) use ($title) { + $query->where('title', 'like', "%{$title}%"); + }) + ->when($orderField, function ($query) use ($orderField, $orderDirection) { + $query->orderBy($orderField, $orderDirection); + })->paginate($numPerPage); + + return view('Admin::articles.index', compact('articles', 'type')); + } + + public function news(Request $request) + { + $title = $request->title; + $orderField = $request->orderField; + $orderDirection = $request->orderDirection; + $numPerPage = $request->numPerPage ?: 30; + $type = 'news'; + + $articles = Article::where('type', $type) + ->when($title, function ($query) use ($title) { + $query->where('title', 'like', "%{$title}%"); + }) + ->when($orderField, function ($query) use ($orderField, $orderDirection) { + $query->orderBy($orderField, $orderDirection); + })->paginate($numPerPage); + return view('Admin::articles.index', compact('articles', 'type')); + } + + public function create(Request $request) + { + return view('Admin::articles.create'); + } + + public function store(Request $request) + { + $validator = Validator::make($request->all(), [ + 'title' => 'required|max:100', + 'description' => 'required|max:200', + 'content' => 'required', + 'storage_id' => 'required', + + ], [ + 'title.required' => '名称必须填写', + 'title.max' => '名称长度应在:max以内', + 'description.required' => '简介必须填写', + 'content.required' => '内容必须填写', + 'storage_id.required' => '标题图必须上传', + + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + + if (Article::create($request->all())) { + return $this->success('新增文章成功', 'close'); + } else { + return $this->error(); + } + } + + public function edit(Article $article) + { + return view('Admin::articles.edit', compact('article')); + + } + + public function update(Request $request, Article $article) + { + $validator = Validator::make($request->all(), [ + 'title' => 'required|max:100', + 'description' => 'required|max:200', + 'content' => 'required', + 'storage_id' => 'required', + + ], [ + 'title.required' => '名称必须填写', + 'title.max' => '名称长度应在:max以内', + 'description.required' => '简介必须填写', + 'content.required' => '内容必须填写', + 'storage_id.required' => '标题图必须上传', + + ]); + $data = $request->all(); + $article->update($data); + return $this->success('', 'close'); + } + + public function destroy(Article $article) + { + if ($article->delete()) { + return $this->success(); + } else { + return $this->error(); + } + } +} diff --git a/app/Admin/Controllers/BonusController.php b/app/Admin/Controllers/BonusController.php new file mode 100644 index 0000000..076078f --- /dev/null +++ b/app/Admin/Controllers/BonusController.php @@ -0,0 +1,11 @@ +title; + $parent_id = $request->get('parent_id', 0) ?: 0; + $orderField = $request->orderField; + $orderDirection = $request->orderDirection; + $numPerPage = $request->numPerPage ?: 30; + + $categories = Category::where('parent_id', $parent_id) + ->when($title, function ($query) use ($title) { + $query->where('title', 'like', "%{$title}%"); + }) + ->when($orderField, function ($query) use ($orderField, $orderDirection) { + $query->orderBy($orderField, $orderDirection); + })->paginate($numPerPage); + + $categoryTree = Category::with(['children'])->where('parent_id', 0)->orderBy('sort', 'asc')->get(); + + return view('Admin::categories.index', compact('categoryTree', 'categories')); + } + + public function create() + { + $topCates = Category::treeShow(); + return view('Admin::categories.create', compact('topCates')); + } + + public function store(Request $request) + { + $validator = Validator::make($request->all(), [ + 'title' => 'required|max:16', + 'sort' => 'required|integer', + ], [ + 'title.required' => '分类名称必须填写', + 'title.max' => '分类名称长度应在:max以内', + 'sort.required' => '分类排序必须填写', + 'sort.integer' => '分类排序只能是数字', + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + + if (Category::create($request->all())) { + return $this->success('新增分类成功', 'close'); + } else { + return $this->error(); + } + } + + public function edit(Category $category) + { + $topCates = Category::treeShow($category->id); + return view('Admin::categories.edit', compact('topCates', 'category')); + } + + public function update(Request $request, Category $category) + { + $validator = Validator::make($request->all(), [ + 'title' => 'required|max:16', + 'sort' => 'required|integer', + ], [ + 'title.required' => '分类名称必须填写', + 'title.max' => '分类名称长度应在:max以内', + 'sort.required' => '分类排序必须填写', + 'sort.integer' => '分类排序只能是数字', + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + + if ($category->update($request->all())) { + return $this->success('编辑分类成功', 'close'); + } else { + return $this->error(); + } + } + + public function destroy(Category $category) + { + $exclude_ids = [1, 2]; + if (in_array($category->id, $exclude_ids)) { + return $this->error('此分类不能删除'); + } + if ($category->delete()) { + return $this->success(); + } else { + return $this->error(); + } + } +} diff --git a/app/Admin/Controllers/Controller.php b/app/Admin/Controllers/Controller.php new file mode 100644 index 0000000..e09723e --- /dev/null +++ b/app/Admin/Controllers/Controller.php @@ -0,0 +1,10 @@ +title; + $orderField = $request->orderField; + $orderDirection = $request->orderDirection; + $numPerPage = $request->numPerPage ?: 30; + + $coupons = CouponInfo::where('seller_id', Admin::user()->seller_id) + ->when($title, function ($query) use ($title) { + $query->where('title', 'like', "%{$title}%"); + }) + ->when($orderField, function ($query) use ($orderField, $orderDirection) { + $query->orderBy($orderField, $orderDirection); + }) + ->orderBy('created_at', 'desc') + ->paginate($numPerPage); + return view('Admin::coupon.index', compact('coupons')); + } + + public function create() + { + $sellers = Seller::where('status', 1)->get(); + return view('Admin::coupon.create', compact('sellers')); + } + + public function store(Request $request) + { + $validator = Validator::make($request->all(), [ + 'title' => 'required|min:2|max:50', + 'remark' => 'required|min:4', + 'bouns' => 'required', + ], [ + 'title.required' => '标题必须填写', + 'title.min' => '标题最少为:min字符', + 'title.max' => '标题最多为:max字符', + 'remark.required' => '券码描述必须填写', + 'remark.min' => '券码描述最少:min个字', + 'bouns.required' => '享用额度必须填写', + 'bouns.number' => '享用额度必须是数字', + + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + + try { + DB::transaction(function () use ($request) { + $status = 0; + if (Admin::user()->seller_id == 1) { + $status = 1; + } + $info = CouponInfo::create($request->all()); + }); + return $this->success('操作成功', 'close'); + } catch (\Exception $e) { + return $this->error('操作失败' . $e->getmessage()); + } + + } + + public function edit($id) + { + $info = CouponInfo::find($id); + return view('Admin::coupon.edit', compact('info')); + } + + public function update(Request $request, $id) + { + $info = CouponInfo::find($id); + $validator = Validator::make($request->all(), [ + 'title' => 'required|min:2|max:50', + 'remark' => 'required|min:4', + 'bouns' => 'required', + ], [ + 'title.required' => '标题必须填写', + 'title.min' => '标题最少为:min字符', + 'title.max' => '标题最多为:max字符', + 'remark.required' => '券码描述必须填写', + 'remark.min' => '券码描述最少:min个字', + 'bouns.required' => '享用额度必须填写', + 'bouns.number' => '享用额度必须是数字', + + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + + try { + DB::transaction(function () use ($request, $info) { + $info = $info->update($request->all()); + }); + return $this->success('操作成功', 'close'); + } catch (\Exception $e) { + return $this->error('操作失败' . $e->getmessage()); + } + + } + + public function destroy($id) + { + $info = CouponInfo::find($id); + try { + $info->status = 0; + $info->save(); + return $this->success('操作成功'); + } catch (\Exception $e) { + return $this->error('操作失败' . $e->getmessage()); + } + } + + /** + * 彻底删除单条目 + * @Author: + * @Date:2018-11-02T13:43:36+0800 + * @param [type] $user [description] + * @return [type] [description] + */ + public function delete(CouponInfo $info) + { + try { + DB::transaction(function () use ($info) { + $info->delete(); + }); + return $this->success('操作成功'); + } catch (\Exception $e) { + return $this->error('操作失败' . $e->getmessage()); + } + + } +} diff --git a/app/Admin/Controllers/DataExportController.php b/app/Admin/Controllers/DataExportController.php new file mode 100644 index 0000000..fafb4f6 --- /dev/null +++ b/app/Admin/Controllers/DataExportController.php @@ -0,0 +1,1107 @@ + $v) { + $header[$i] = iconv('utf-8', 'GB18030', $v); + } + fputcsv($fp, $header); + + $mobile = $request->mobile; + $nickname = $request->nickname; + $identity = $request->identity; + $parent_id = $request->parent_id; + $start = $request->start; + $end = $request->end; + $is_salesman = $request->is_salesman; + + $users = User::when($mobile, function ($query) use ($mobile) { + return $query->where('mobile', 'like', "%{$mobile}%"); + })->when($nickname, function ($query) use ($nickname) { + return $query->whereHas('info', function ($query) use ($nickname) { + $query->where('nickname', 'like', "%{$nickname}%"); + }); + })->when(is_numeric($is_salesman), function ($query) use ($is_salesman) { + return $query->where('is_salesman', $is_salesman); + })->when($parent_id, function ($query) use ($parent_id) { + $query->whereHas('relation', function ($query) use ($parent_id) { + $query->where('parent_id', $parent_id); + }); + })->when(is_numeric($identity), function ($query) use ($identity) { + $query->whereHas('identity', function ($query) use ($identity) { + $query->where('identity_id', $identity); + }); + })->when($start && $end, function ($query) use ($start, $end) { + return $query->whereBetween('created_at', [$start, date('Y-m-d', strtotime("+1 days", strtotime($end)))]); + })->when($start && !$end, function ($query) use ($start) { + return $query->where('created_at', '>=', $start); + })->when(!$start && $end, function ($query) use ($end) { + return $query->where('created_at', '<=', date('Y-m-d', strtotime("+1 days", strtotime($end)))); + })->with(['info'])->orderBy('created_at', 'desc'); + + if ($users->exists()) { + $users->chunk(200, function ($list) use ($fp) { + self::user_sub($list, $fp); + }); + } else { + self::user_sub([], $fp); + + } + } + + private function user_sub($list, $fp) + { + $excel_data = []; + foreach ($list as $key => $vo) { + $excel_data[] = [ + $vo->id, + $vo->openid . "\t", + $vo->mobile . "\t", + $vo->info->nickname ?? '', + $vo->parent->info->nickname ?? '无', + $vo->identity_text, + $vo->salesman_text, + $vo->organ->name ?? '', + $vo->created_at . "\t" ?? '', + ]; + } + foreach ($excel_data as $item) { + $rows = array(); + foreach ($item as $export_obj) { + $rows[] = iconv('utf-8', 'GB18030', $export_obj); + } + fputcsv($fp, $rows); + } + + unset($excel_data); + ob_flush(); + flush(); + } + + //导出全部订单列表 + public function allOrders(Request $request) + { + $header = ['订单编号', '支付单号', '支付类型', '订单类型', '商户名称', '手机号', '用户昵称', '商品信息', '商品金额', '现金券抵值', '运费', '总计支付', '订单状态', '配送方式', '收件人', '联系电话', '收货地址', '物流公司', '物流单号', '买家留言', '订单备注', '创建时间', '支付时间', '发货时间', '签收时间']; + + $fileName = '订单列表-' . date('YmdHis', time()); + + header("Content-type:application/vnd.ms-excel"); + header("Content-Disposition:filename=" . iconv("UTF-8", "GB18030", $fileName) . ".csv"); + $fp = fopen('php://output', 'a'); + foreach ($header as $i => $v) { + $header[$i] = iconv('utf-8', 'GB18030', $v); + } + fputcsv($fp, $header); + + $orderid = $request->orderid; + $mobile = $request->mobile; + $nickname = $request->nickname; + $seller = $request->seller; + $state = $request->state; + $title = $request->title; + $start = $request->start; + $end = $request->end; + $item_type = $request->item_type; + + $orders = Order::when($seller, function ($query) use ($seller) { + $query->whereHas('seller', function ($query) use ($seller) { + $query->where('name', 'like', "%{$seller}%"); + }); + }) + ->when($orderid, function ($query) use ($orderid) { + $query->where('orderid', 'like', "%{$orderid}%"); + }) + ->when($mobile, function ($query) use ($mobile) { + $query->whereHas('user', function ($query) use ($mobile) { + $query->where('mobile', 'like', "%{$mobile}%"); + }); + }) + ->when($nickname, function ($query) use ($nickname) { + $query->whereHas('user', function ($query) use ($nickname) { + return $query->whereHas('info', function ($query) use ($nickname) { + $query->where('nickname', 'like', "%{$nickname}%"); + }); + }); + }) + ->when($title, function ($query) use ($title) { + $goods_ids = Goods::where('title', 'like', "%{$title}%")->pluck('id'); + $params_ids = GoodsParams::whereIn('goods_id', $goods_ids)->pluck('id'); + $query->whereHas('details', function ($query) use ($params_ids) { + return $query->whereIn('item_id', $params_ids); + }); + }) + ->when($item_type, function ($query) use ($item_type) { + return $query->where('item_type', $item_type); + }) + ->when($state == '', function ($query) { + return $query->where('state', '<>', Order::ORDER_CLOSED); + }) + ->when($state, function ($query) use ($state) { + switch ($state) { + case 'UNPAY': + return $query->where('state', Order::ORDER_UNPAY); + break; + case 'PAID': + return $query->whereIn('state', [Order::ORDER_PAID, Order::ORDER_DELIVER]); + break; + case 'DELIVERED': + return $query->where('state', Order::ORDER_DELIVERED); + break; + case 'SIGNED': + return $query->where('state', Order::ORDER_SIGNED); + break; + case 'CLOSED': + return $query->where('state', Order::ORDER_CLOSED); + break; + case 'CANCEL': + return $query->where('state', Order::ORDER_CANCEL); + break; + case 'COMPLETED': + return $query->where('state', Order::ORDER_COMPLETED); + break; + default: + break; + } + })->when($start && $end, function ($query) use ($start, $end) { + return $query->whereBetween('created_at', [$start, date('Y-m-d', strtotime("+1 days", strtotime($end)))]); + })->when($start && !$end, function ($query) use ($start) { + return $query->where('created_at', '>=', $start); + })->when(!$start && $end, function ($query) use ($end) { + return $query->where('created_at', '<=', date('Y-m-d', strtotime("+1 days", strtotime($end)))); + })->with(['seller', 'user.info'])->orderBy('created_at', 'desc'); + + if ($orders->exists()) { + $orders->chunk(200, function ($list) use ($fp) { + self::orders_sub($list, $fp); + }); + } else { + self::orders_sub([], $fp); + + } + } + + //导出订单列表 + public function orders(Request $request) + { + $header = ['订单编号', '支付单号', '支付类型', '订单类型', '商户名称', '手机号', '用户昵称', '商品信息', '商品金额', '现金券抵值', '运费', '总计支付', '订单状态', '配送方式', '收件人', '联系电话', '收货地址', '物流公司', '物流单号', '买家留言', '订单备注', '创建时间', '支付时间', '发货时间', '签收时间']; + + $fileName = '订单列表-' . date('YmdHis', time()); + + header("Content-type:application/vnd.ms-excel"); + header("Content-Disposition:filename=" . iconv("UTF-8", "GB18030", $fileName) . ".csv"); + $fp = fopen('php://output', 'a'); + foreach ($header as $i => $v) { + $header[$i] = iconv('utf-8', 'GB18030', $v); + } + fputcsv($fp, $header); + + $orderid = $request->orderid; + $mobile = $request->mobile; + $nickname = $request->nickname; + $state = $request->state; + $start = $request->start; + $end = $request->end; + $title = $request->title; + $item_type = $request->item_type; + + $orders = Order::where('seller_id', Admin::user()->seller_id) + ->when($orderid, function ($query) use ($orderid) { + $query->where('orderid', 'like', "%{$orderid}%"); + }) + ->when($mobile, function ($query) use ($mobile) { + $query->whereHas('user', function ($query) use ($mobile) { + $query->where('mobile', 'like', "%{$mobile}%"); + }); + }) + ->when($nickname, function ($query) use ($nickname) { + $query->whereHas('user', function ($query) use ($nickname) { + return $query->whereHas('info', function ($query) use ($nickname) { + $query->where('nickname', 'like', "%{$nickname}%"); + }); + }); + }) + ->when($title, function ($query) use ($title) { + $goods_ids = Goods::where('title', 'like', "%{$title}%")->pluck('id'); + $params_ids = GoodsParams::whereIn('goods_id', $goods_ids)->pluck('id'); + $query->whereHas('details', function ($query) use ($params_ids) { + return $query->whereIn('item_id', $params_ids); + }); + }) + ->when($item_type, function ($query) use ($item_type) { + return $query->where('item_type', $item_type); + }) + ->when($state == '', function ($query) { + return $query->where('state', '<>', Order::ORDER_CLOSED); + }) + ->when($state, function ($query) use ($state) { + switch ($state) { + case 'UNPAY': + return $query->where('state', Order::ORDER_UNPAY); + break; + case 'PAID': + return $query->whereIn('state', [Order::ORDER_PAID, Order::ORDER_DELIVER]); + break; + case 'DELIVERED': + return $query->where('state', Order::ORDER_DELIVERED); + break; + case 'SIGNED': + return $query->where('state', Order::ORDER_SIGNED); + break; + case 'CLOSED': + return $query->where('state', Order::ORDER_CLOSED); + break; + case 'CANCEL': + return $query->where('state', Order::ORDER_CANCEL); + break; + case 'COMPLETED': + return $query->where('state', Order::ORDER_COMPLETED); + break; + default: + break; + } + })->when($start && $end, function ($query) use ($start, $end) { + return $query->whereBetween('created_at', [$start, date('Y-m-d', strtotime("+1 days", strtotime($end)))]); + })->when($start && !$end, function ($query) use ($start) { + return $query->where('created_at', '>=', $start); + })->when(!$start && $end, function ($query) use ($end) { + return $query->where('created_at', '<=', date('Y-m-d', strtotime("+1 days", strtotime($end)))); + })->with(['seller', 'user.info'])->orderBy('created_at', 'desc'); + + if ($orders->exists()) { + $orders->chunk(200, function ($list) use ($fp) { + self::orders_sub($list, $fp); + }); + } else { + self::orders_sub([], $fp); + + } + } + + private function orders_sub($list, $fp) + { + $excel_data = []; + foreach ($list as $key => $vo) { + $type = '商品'; + switch ($vo->item_type) { + case 'GOODS': + $type = '商品'; + break; + case 'GIFT': + $type = '赠品'; + break; + case 'LESSON': + $type = '报课'; + break; + case 'ACTIVITY': + $type = '娱乐/生活'; + break; + } + + $vo->pro = ' '; + foreach ($vo->details as $detail) { + if ($detail->item) { + $vo->pro .= $detail->item->getTitle() . number_format($detail->price, 2) . '元/件 *' . $detail->number . "件\n"; + } + } + + $vo->pay_sn = ''; + $vo->pay_type = ''; + $vo->pay = Payment::where('state', 'SUCCESS')->where('order_id', $vo->id)->first(); + if ($vo->pay) { + $vo->pay_sn = $vo->pay->trade_no; + $vo->pay_type = $vo->pay->type; + } + + $vo->log_express = $vo->logs()->where('state', 'PAID|DELIVERED')->first(); + $vo->log_signed = $vo->logs()->where('state', 'DELIVERED|SIGNED')->first(); + + $excel_data[] = [ + $vo->orderid . "\t", + $vo->pay_sn . "\t", + $vo->pay_sn ? $vo->pay_type == 'WECHAT' ? '微信' : '余额' : ' ', + $type, + $vo->seller->name . "\t", + $vo->user->mobile . "\t" ?? '', + $vo->user->info->nickname . "\t" ?? '', + $vo->pro, + $vo->amount, + -$vo->score, + $vo->freight, + number_format($vo->total - $vo->score, 2), + $vo->state_text, + $vo->express_type == 1 ? '快递' : '自提', + $vo->express->name ?? '', + $vo->express->mobile ?? '', + $vo->express->address ?? '', + $vo->express->company ?? '', + !empty($vo->express->number) ? $vo->express->number . "\t" : '', + $vo->remark, + $vo->remark_mgr, + $vo->created_at . "\t" ?? '', + $vo->paid_at . "\t" ?? '', + $vo->log_express ? $vo->log_express->created_at . "\t" : '', + $vo->log_signed ? $vo->log_signed->created_at . "\t" : '', + + ]; + } + foreach ($excel_data as $item) { + $rows = array(); + foreach ($item as $export_obj) { + $rows[] = iconv('utf-8', 'GB18030', $export_obj); + } + fputcsv($fp, $rows); + } + + unset($excel_data); + ob_flush(); + flush(); + } + + //导出账户列表 + public function accounts(Request $request) + { + $header = ['用户ID', '手机号', '昵称', '现金账户', '注册时间']; + + $fileName = '账户列表-' . date('YmdHis', time()); + + header("Content-type:application/vnd.ms-excel"); + header("Content-Disposition:filename=" . iconv("UTF-8", "GB18030", $fileName) . ".csv"); + $fp = fopen('php://output', 'a'); + foreach ($header as $i => $v) { + $header[$i] = iconv('utf-8', 'GB18030', $v); + } + fputcsv($fp, $header); + + $mobile = $request->mobile; + $nickname = $request->nickname; + $start = $request->start; + $end = $request->end; + + $accounts = UserAccount::when($mobile, function ($query) use ($mobile) { + $query->whereHas('user', function ($query) use ($mobile) { + $query->where('mobile', 'like', "%{$mobile}%"); + }); + })->when($nickname, function ($query) use ($nickname) { + $query->whereHas('user.info', function ($query) use ($nickname) { + $query->where('nickname', 'like', "%{$nickname}%"); + }); + })->when($start && $end, function ($query) use ($start, $end) { + return $query->whereBetween('created_at', [$start, date('Y-m-d', strtotime("+1 days", strtotime($end)))]); + })->when($start && !$end, function ($query) use ($start) { + return $query->where('created_at', '>=', $start); + })->when(!$start && $end, function ($query) use ($end) { + return $query->where('created_at', '<=', date('Y-m-d', strtotime("+1 days", strtotime($end)))); + })->with(['user'])->orderBy('created_at', 'desc'); + + if ($accounts->exists()) { + $accounts->chunk(200, function ($list) use ($fp) { + self::accounts_sub($list, $fp); + }); + } else { + self::accounts_sub([], $fp); + + } + } + + private function accounts_sub($list, $fp) + { + $excel_data = []; + foreach ($list as $key => $vo) { + $excel_data[] = [ + $vo->user->id, + $vo->user->mobile . "\t" ?? '', + $vo->user->info->nickname . "\t" ?? '', + $vo->cash, + $vo->created_at . "\t", + ]; + } + foreach ($excel_data as $item) { + $rows = array(); + foreach ($item as $export_obj) { + $rows[] = iconv('utf-8', 'GB18030', $export_obj); + } + fputcsv($fp, $rows); + } + + unset($excel_data); + ob_flush(); + flush(); + } + + //导出账户明细列表 + public function logs(Request $request) + { + $header = ['记录ID', '手机号', '昵称', '规则', '账户类型', '变动数额', '当期余额', '冻结状态', '创建时间', '更新时间']; + + $fileName = '账户日志-' . date('YmdHis', time()); + + header("Content-type:application/vnd.ms-excel"); + header("Content-Disposition:filename=" . iconv("UTF-8", "GB18030", $fileName) . ".csv"); + $fp = fopen('php://output', 'a'); + foreach ($header as $i => $v) { + $header[$i] = iconv('utf-8', 'GB18030', $v); + } + fputcsv($fp, $header); + + $mobile = $request->mobile; + $rule_id = $request->rule_id; + $nickname = $request->nickname; + $start = $request->start; + $end = $request->end; + + $logs = UserAccountLog::when($mobile, function ($query) use ($mobile) { + $query->whereHas('user', function ($query) use ($mobile) { + $query->where('mobile', 'like', "%{$mobile}%"); + }); + })->when($nickname, function ($query) use ($nickname) { + $query->whereHas('user.info', function ($query) use ($nickname) { + $query->where('nickname', 'like', "%{$nickname}%"); + }); + })->when($rule_id, function ($query) use ($rule_id) { + return $query->where('rule_id', $rule_id); + })->when($start && $end, function ($query) use ($start, $end) { + return $query->whereBetween('created_at', [$start, date('Y-m-d', strtotime("+1 days", strtotime($end)))]); + })->when($start && !$end, function ($query) use ($start) { + return $query->where('created_at', '>=', $start); + })->when(!$start && $end, function ($query) use ($end) { + return $query->where('created_at', '<=', date('Y-m-d', strtotime("+1 days", strtotime($end)))); + })->with(['user.info', 'rule'])->orderBy('created_at', 'desc'); + + if ($logs->exists()) { + $logs->chunk(200, function ($list) use ($fp) { + self::logs_sub($list, $fp); + }); + } else { + self::logs_sub([], $fp); + + } + } + + private function logs_sub($list, $fp) + { + $excel_data = []; + foreach ($list as $key => $vo) { + $excel_data[] = [ + $vo->id, + $vo->user->mobile . "\t" ?? '', + $vo->user->info->nickname . "\t" ?? '', + $vo->rule->title ?? '', + $vo->type, + $vo->variable, + $vo->balance, + $vo->frozen, + $vo->created_at . "\t", + $vo->updated_at . "\t", + ]; + } + foreach ($excel_data as $item) { + $rows = array(); + foreach ($item as $export_obj) { + $rows[] = iconv('utf-8', 'GB18030', $export_obj); + } + fputcsv($fp, $rows); + } + + unset($excel_data); + ob_flush(); + flush(); + } + + //导出支付列表 + public function payments(Request $request) + { + $header = ['订单编号', '支付单号', '支付方式', '支付状态', '支付金额', '支付时间', '创建时间', '备注']; + + $fileName = '支付订单记录-' . date('YmdHis', time()); + + header("Content-type:application/vnd.ms-excel"); + header("Content-Disposition:filename=" . iconv("UTF-8", "GB18030", $fileName) . ".csv"); + $fp = fopen('php://output', 'a'); + foreach ($header as $i => $v) { + $header[$i] = iconv('utf-8', 'GB18030', $v); + } + fputcsv($fp, $header); + + $orderid = $request->orderid; + $trade_no = $request->trade_no; + $start = $request->start; + $end = $request->end; + + $payments = Payment::when($trade_no, function ($query) use ($trade_no) { + $query->where('trade_no', 'like', "%{$trade_no}%"); + })->when($orderid, function ($query) use ($orderid) { + $query->whereHas('order', function ($query) use ($orderid) { + $query->where('orderid', 'like', "%{$orderid}%"); + }); + })->when($start && $end, function ($query) use ($start, $end) { + return $query->whereBetween('created_at', [$start, date('Y-m-d', strtotime("+1 days", strtotime($end)))]); + })->when($start && !$end, function ($query) use ($start) { + return $query->where('created_at', '>=', $start); + })->when(!$start && $end, function ($query) use ($end) { + return $query->where('created_at', '<=', date('Y-m-d', strtotime("+1 days", strtotime($end)))); + })->with(['order'])->orderBy('created_at', 'desc'); + + if ($payments->exists()) { + $payments->chunk(200, function ($list) use ($fp) { + self::payments_sub($list, $fp); + }); + } else { + self::payments_sub([], $fp); + + } + } + + private function payments_sub($list, $fp) + { + $excel_data = []; + foreach ($list as $key => $vo) { + $excel_data[] = [ + $vo->order->orderid . "\t" ?? '', + $vo->trade_no . "\t", + strip_tags($vo->type_text), + strip_tags($vo->state_text), + $vo->amount, + $vo->paid_at . "\t", + $vo->created_at . "\t", + $vo->remark . "\t", + + ]; + } + foreach ($excel_data as $item) { + $rows = array(); + foreach ($item as $export_obj) { + $rows[] = iconv('utf-8', 'GB18030', $export_obj); + } + fputcsv($fp, $rows); + } + + unset($excel_data); + ob_flush(); + flush(); + } + //导出提现列表 + public function withdraws(Request $request) + { + $header = ['记录ID', '用户手机号', '用户昵称', '提现金额', '实到金额', '状态', '创建时间', '执行时间']; + + $fileName = '提现记录列表-' . date('YmdHis', time()); + + header("Content-type:application/vnd.ms-excel"); + header("Content-Disposition:filename=" . iconv("UTF-8", "GB18030", $fileName) . ".csv"); + $fp = fopen('php://output', 'a'); + foreach ($header as $i => $v) { + $header[$i] = iconv('utf-8', 'GB18030', $v); + } + fputcsv($fp, $header); + + $mobile = $request->mobile; + $nickname = $request->nickname; + $start = $request->start; + $end = $request->end; + + $withdraws = Withdraw::when($mobile, function ($query) use ($mobile) { + $query->whereHas('user', function ($query) use ($mobile) { + $query->where('mobile', 'like', "%{$mobile}%"); + }); + })->when($nickname, function ($query) use ($nickname) { + $query->whereHas('user.info', function ($query) use ($nickname) { + $query->where('nickname', 'like', "%{$nickname}%"); + }); + })->when($start && $end, function ($query) use ($start, $end) { + return $query->whereBetween('created_at', [$start, date('Y-m-d', strtotime("+1 days", strtotime($end)))]); + })->when($start && !$end, function ($query) use ($start) { + return $query->where('created_at', '>=', $start); + })->when(!$start && $end, function ($query) use ($end) { + return $query->where('created_at', '<=', date('Y-m-d', strtotime("+1 days", strtotime($end)))); + })->with(['user.info'])->orderBy('created_at', 'desc'); + + if ($withdraws->exists()) { + $withdraws->chunk(200, function ($list) use ($fp) { + self::withdraws_sub($list, $fp); + }); + } else { + self::withdraws_sub([], $fp); + } + } + + private function withdraws_sub($list, $fp) + { + $excel_data = []; + foreach ($list as $key => $vo) { + $excel_data[] = [ + $vo->id, + $vo->user->mobile . "\t" ?? '', + $vo->user->info->nickname . "\t" ?? '', + $vo->amount, + $vo->take, + $vo->state_text, + $vo->created_at . "\t", + $vo->updated_at . "\t", + + ]; + } + foreach ($excel_data as $item) { + $rows = array(); + foreach ($item as $export_obj) { + $rows[] = iconv('utf-8', 'GB18030', $export_obj); + } + fputcsv($fp, $rows); + } + + unset($excel_data); + ob_flush(); + flush(); + } + + //导出商品列表 + public function goods(Request $request) + { + $header = ['商户名称', '商品类型', '商品ID', '商品名称', '规格ID', '规格', '售价', '所需积分', '成本价', '库存', '单品重量(kg)', '是否包邮', '开通会员赠品', '满仓赠品', '创建时间', '更新时间']; + + $fileName = '商品列表-' . date('YmdHis', time()); + + header("Content-type:application/vnd.ms-excel"); + header("Content-Disposition:filename=" . iconv("UTF-8", "GB18030", $fileName) . ".csv"); + $fp = fopen('php://output', 'a'); + foreach ($header as $i => $v) { + $header[$i] = iconv('utf-8', 'GB18030', $v); + } + fputcsv($fp, $header); + + $title = $request->title; + $seller = $request->seller; + $position = $request->position; + $is_gift = $request->is_gift; + + $goods = Goods::when($title, function ($query) use ($title) { + $query->where('title', 'like', "%{$title}%"); + }) + ->when($seller, function ($query) use ($seller) { + $query->whereHas('seller', function ($query) use ($seller) { + $query->where('name', 'like', "%{$seller}%"); + }); + }) + ->when($is_gift, function ($query) use ($is_gift) { + switch ($is_gift) { + case 'is_seller_gift': + $query->where('is_seller_gift', 1); + break; + case 'is_mall_gift': + $query->where('is_mall_gift', 1); + break; + } + }) + ->when($position, function ($query) use ($position) { + switch ($position) { + case 'is_recommend': + $query->where('is_recommend', 1); + break; + case 'is_hot_sell': + $query->where('is_hot_sell', 1); + break; + case 'is_hot_changed': + $query->where('is_hot_changed', 1); + break; + case 'is_seller_package': + $query->where('is_seller_package', 1); + break; + } + }) + ->with(['category', 'seller']) + ->orderBy('seller_id', 'desc') + ->orderBy('status', 'desc')->orderBy('created_at', 'desc'); + + if ($goods->exists()) { + $goods->chunk(200, function ($list) use ($fp) { + self::goods_sub($list, $fp); + }); + } else { + self::goods_sub([], $fp); + + } + } + + private function goods_sub($list, $fp) + { + $excel_data = []; + foreach ($list as $key => $vo) { + foreach ($vo->params()->where('status', 1)->get() as $params) { + $excel_data[] = [ + $vo->seller->name . "\t", + $vo->category->title . "\t", + $vo->id . "\t", + $vo->title, + $params->id . "\t" ?? '', + $params->value . "\t" ?? '', + number_format($params->price - $params->score, 2) . "\t" ?? '', + $params->score . "\t" ?? '', + $params->cost . "\t" ?? '', + $params->stock . "\t" ?? '', + $params->heavy . "\t" ?? '', + $params->is_free_freight ? '-' : '是', + $vo->is_seller_gift ? '是' : '-', + $vo->is_mall_gift ? '是' : '-', + $vo->created_at . "\t", + $vo->updated_at . "\t", + ]; + + } + } + foreach ($excel_data as $item) { + $rows = array(); + foreach ($item as $export_obj) { + $rows[] = iconv('utf-8', 'GB18030', $export_obj); + } + fputcsv($fp, $rows); + } + + unset($excel_data); + ob_flush(); + flush(); + } + + public function report(Request $request) + { + $header = ['订单编号', '支付单号', '支付类型', '订单类型', '商户名称', '手机号', '用户昵称', '商品信息', '商品数量', '现金单价', '单件积分', '商品总额', '积分抵值', '运费', '总计支付', '成本总计', '商家结算运费', '商家结算', '订单状态', '整体状态', '配送方式', '收件人', '联系电话', '收货地址', '物流公司', '物流单号', '买家留言', '订单备注', '创建时间', '支付时间', '发货时间', '签收时间']; + + $fileName = '订单列表-' . date('YmdHis', time()); + + header("Content-type:application/vnd.ms-excel"); + header("Content-Disposition:filename=" . iconv("UTF-8", "GB18030", $fileName) . ".csv"); + $fp = fopen('php://output', 'a'); + foreach ($header as $i => $v) { + $header[$i] = iconv('utf-8', 'GB18030', $v); + } + fputcsv($fp, $header); + + $orderid = $request->orderid; + $mobile = $request->mobile; + $nickname = $request->nickname; + $start = $request->start; + $end = $request->end; + $item_type = $request->item_type; + $type = $request->type; + $seller_id = Admin::id() == 1 ? $request->seller_id : Admin::user()->seller_id; + + $orders = Order::when($seller_id, function ($q) use ($seller_id) {$q->where('seller_id', $seller_id);}) + ->when($orderid, function ($query) use ($orderid) { + $query->where('orderid', 'like', "%{$orderid}%"); + }) + ->when($mobile, function ($query) use ($mobile) { + $query->whereHas('user', function ($query) use ($mobile) { + $query->where('mobile', 'like', "%{$mobile}%"); + }); + }) + ->when($nickname, function ($query) use ($nickname) { + $query->whereHas('user', function ($query) use ($nickname) { + return $query->whereHas('info', function ($query) use ($nickname) { + $query->where('nickname', 'like', "%{$nickname}%"); + }); + }); + }) + ->when($item_type, function ($query) use ($item_type) { + return $query->where('item_type', $item_type); + })-> + whereHas('logs', function ($query) use ($start, $end, $type) { + $query->where('state', $type)->when($start && $end, function ($query) use ($start, $end) { + $query->whereBetween('created_at', [$start, date('Y-m-d', strtotime("+1 days", strtotime($end)))]); + }) + ->when($start && !$end, function ($query) use ($start) { + $query->where('created_at', '>=', $start); + }) + ->when((!$start && $end), function ($query) use ($end) { + $query->where('created_at', '<=', date('Y-m-d', strtotime("+1 days", strtotime($end)))); + }); + })->where('state', '<>', Order::ORDER_CLOSED)->with(['seller', 'user.info'])->orderBy('created_at', 'desc'); + + if ($orders->exists()) { + $orders->chunk(200, function ($list) use ($fp) { + self::orders_new_sub($list, $fp); + }); + } else { + self::orders_new_sub([], $fp); + + } + } + + private function orders_new_sub($list, $fp) + { + $excel_data = []; + foreach ($list as $key => $vo) { + $type = '商品'; + switch ($vo->item_type) { + case 'GOODS': + $type = '商品'; + break; + case 'VIP_GIFT': + $type = '赠品'; + break; + case 'FULL_GIFT': + $type = '满仓'; + break; + case 'ACTIVITY_GIFT': + $type = '活动'; + break; + } + + $vo->pay_sn = ''; + $vo->pay_type = ''; + $vo->pay = Payment::where('state', 'SUCCESS')->where('order_id', $vo->id)->first(); + if ($vo->pay) { + $vo->pay_sn = $vo->pay->trade_no; + $vo->pay_type = $vo->pay->type; + } + + $vo->log_express = $vo->logs()->where('state', 'PAID|DELIVERED')->first(); + $vo->log_signed = $vo->logs()->where('state', 'DELIVERED|SIGNED')->first(); + + foreach ($vo->details as $kk => $detail) { + if ($kk == 0) { + $excel_data[] = [ + $vo->orderid . "\t", + $vo->pay_sn . "\t", + $vo->pay_sn ? $vo->pay_type == 'WECHAT' ? '微信' : '余额' : ' ', + $type, + $vo->seller->name . "\t", + $vo->user->mobile . "\t" ?? '', + $vo->user->info->nickname . "\t" ?? '', + $detail->item->getTitle(), + $detail->number, + $detail->price - $detail->score, + $detail->score, + $vo->amount, + -$vo->score, + $vo->freight, + number_format($vo->total - $vo->score, 2), + number_format($vo->seller_amount, 2), + number_format($vo->seller_freight, 2), + number_format($vo->seller_amount + $vo->seller_freight, 2), + $vo->state_text, + $vo->status_text, + $vo->express_type == 1 ? '快递' : '自提', + $vo->express->name ?? '', + $vo->express->mobile ?? '', + $vo->express->address ?? '', + $vo->express->company ?? '', + !empty($vo->express->number) ? $vo->express->number . "\t" : '', + $vo->remark, + $vo->remark_mgr, + $vo->created_at . "\t" ?? '', + $vo->paid_at . "\t" ?? '', + $vo->log_express ? $vo->log_express->created_at . "\t" : '', + $vo->log_signed ? $vo->log_signed->created_at . "\t" : '', + ]; + } else { + $excel_data[] = [ + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + $detail->item->getTitle(), + $detail->number, + $detail->price - $detail->score, + $detail->score, + ]; + } + + } + + } + foreach ($excel_data as $item) { + $rows = array(); + foreach ($item as $export_obj) { + $rows[] = iconv('utf-8', 'GB18030', $export_obj); + } + fputcsv($fp, $rows); + } + + unset($excel_data); + ob_flush(); + flush(); + } + + public function dataReport(Request $request) + { + $header = ['商户名称', '日期', '商品总数', '订单总数', '商品现金总额', '商品积分总额', '支付现金总额', '消耗积分总额', '订单运费总额', '结算成本', '结算运费', '结算总额']; + $type_text = $request->type == 'DELIVERED' ? '发货' : '签收'; + $fileName = '每日' . $type_text . '记录-' . date('YmdHis', time()); + + header("Content-type:application/vnd.ms-excel"); + header("Content-Disposition:filename=" . iconv("UTF-8", "GB18030", $fileName) . ".csv"); + $fp = fopen('php://output', 'a'); + foreach ($header as $i => $v) { + $header[$i] = iconv('utf-8', 'GB18030', $v); + } + fputcsv($fp, $header); + + $seller_id = Admin::id() == 1 ? $request->seller_id : Admin::user()->seller_id; + $start = $request->start; + $end = $request->end; + $type = $request->type; + + $reports = SalesReport::when($seller_id, function ($q) use ($seller_id) {$q->where('seller_id', $seller_id);}) + ->where('state', $type) + ->when($start && $end, function ($query) use ($start, $end) { + $query->whereBetween('action_time', [$start, date('Y-m-d', strtotime("+1 days", strtotime($end)))]); + }) + ->when($start && !$end, function ($query) use ($start) { + $query->where('action_time', '>=', $start); + }) + ->when((!$start && $end), function ($query) use ($end) { + $query->where('action_time', '<=', date('Y-m-d', strtotime("+1 days", strtotime($end)))); + })->orderBy('seller_id', 'asc')->orderBy('action_time', 'desc'); + + if ($reports->exists()) { + $reports->chunk(200, function ($list) use ($fp) { + self::dataReport_sub($list, $fp); + }); + } else { + self::dataReport_sub([], $fp); + + } + } + + private function dataReport_sub($list, $fp) + { + $excel_data = []; + foreach ($list as $key => $vo) { + + $excel_data[] = [ + $vo->seller->name . "\t", + $vo->action_time . "\t" ?? '', + $vo->goods_total . "\t" ?? '', + $vo->orders_total . "\t" ?? '', + number_format($vo->goods_price_total - $vo->goods_score_total, 2) . "\t" ?? '', + $vo->goods_score_total . "\t" ?? '', + number_format($vo->orders_price - $vo->orders_score, 2) . "\t" ?? '', + $vo->orders_score . "\t" ?? '', + $vo->orders_freight . "\t" ?? '', + $vo->seller_total . "\t" ?? '', + $vo->seller_freight . "\t" ?? '', + number_format($vo->seller_freight + $vo->seller_total, 2) . "\t" ?? '', + ]; + + } + foreach ($excel_data as $item) { + $rows = array(); + foreach ($item as $export_obj) { + $rows[] = iconv('utf-8', 'GB18030', $export_obj); + } + fputcsv($fp, $rows); + } + + unset($excel_data); + ob_flush(); + flush(); + } + + //导出续费用户列表 + public function payCostUser(Request $request) + { + $header = ['ID', '微信OPENID', '手机号', '昵称', '等级', '当前推荐', '变更时间', '备注']; + + $fileName = '续费用户列表-' . date('YmdHis', time()); + + header("Content-type:application/vnd.ms-excel"); + header("Content-Disposition:filename=" . iconv("UTF-8", "GB18030", $fileName) . ".csv"); + $fp = fopen('php://output', 'a'); + foreach ($header as $i => $v) { + $header[$i] = iconv('utf-8', 'GB18030', $v); + } + fputcsv($fp, $header); + + $identity = $request->identity; + $start = $request->start; + $end = $request->end; + $mobile = $request->mobile; + $nickname = $request->nickname; + $users = IdentityLog::where('channel', 'AdminUp') + ->when(is_numeric($identity), function ($query) use ($identity) { + $query->where('after', $identity); + }) + ->when($mobile, function ($query) use ($mobile) { + $query->whereHas('user_obj', function ($query) use ($mobile) { + $query->where('mobile', 'like', "%{$mobile}%"); + }); + }) + ->when($nickname, function ($query) use ($nickname) { + $query->whereHas('user_obj', function ($query) use ($nickname) { + return $query->whereHas('info', function ($query) use ($nickname) { + $query->where('nickname', 'like', "%{$nickname}%"); + }); + }); + })->when($start && $end, function ($query) use ($start, $end) { + return $query->whereBetween('created_at', [$start, date('Y-m-d', strtotime("+1 days", strtotime($end)))]); + })->when($start && !$end, function ($query) use ($start) { + return $query->where('created_at', '>=', $start); + })->when(!$start && $end, function ($query) use ($end) { + return $query->where('created_at', '<=', date('Y-m-d', strtotime("+1 days", strtotime($end)))); + })->orderBy('created_at', 'desc'); + if ($users->exists()) { + $users->chunk(200, function ($list) use ($fp) { + self::payCostUser_sub($list, $fp); + }); + } else { + self::payCostUser_sub([], $fp); + + } + } + + private function payCostUser_sub($list, $fp) + { + $excel_data = []; + foreach ($list as $key => $vo) { + $excel_data[] = [ + $vo->id, + $vo->user->openid . "\t", + $vo->user->mobile . "\t", + $vo->user->info->nickname . "\t" ?? '', + $vo->identity_title . "\t" ?? '无', + $vo->user->identity->activation_childs . "\t" ?? '无', + $vo->created_at . "\t" ?? '无', + $vo->other['rebates_remark'] ?? '无', + ]; + } + foreach ($excel_data as $item) { + $rows = array(); + foreach ($item as $export_obj) { + $rows[] = iconv('utf-8', 'GB18030', $export_obj); + } + fputcsv($fp, $rows); + } + + unset($excel_data); + ob_flush(); + flush(); + } + +} diff --git a/app/Admin/Controllers/GoodsController.php b/app/Admin/Controllers/GoodsController.php new file mode 100644 index 0000000..76d6813 --- /dev/null +++ b/app/Admin/Controllers/GoodsController.php @@ -0,0 +1,589 @@ +title; + $seller = $request->seller; + $position = $request->position; + $is_gift = $request->is_gift; + $category_id = $request->category_id; + $orderField = $request->orderField; + $orderDirection = $request->orderDirection; + $numPerPage = $request->numPerPage ?: 30; + + $goods = Goods::where('status', '>=', 0) + ->when($title, function ($query) use ($title) { + $query->where('title', 'like', "%{$title}%"); + }) + ->when($seller, function ($query) use ($seller) { + $query->whereHas('seller', function ($query) use ($seller) { + $query->where('name', 'like', "%{$seller}%"); + }); + }) + ->when($category_id, function ($query) use ($category_id) { + $category_ids = Category::where('id', $category_id)->orWhere('parent_id', $category_id)->pluck('id'); + return $query->whereIn('category_id', $category_ids); + }) + ->when($orderField, function ($query) use ($orderField, $orderDirection) { + $query->orderBy($orderField, $orderDirection); + }) + ->when($is_gift, function ($query) use ($is_gift) { + switch ($is_gift) { + case 'is_seller_gift': + $query->where('is_seller_gift', 1); + break; + case 'is_mall_gift': + $query->where('is_mall_gift', 1); + break; + } + }) + ->when($position, function ($query) use ($position) { + switch ($position) { + case 'is_recommend': + $query->where('is_recommend', 1); + break; + case 'is_hot_sell': + $query->where('is_hot_sell', 1); + break; + case 'is_hot_changed': + $query->where('is_hot_changed', 1); + break; + case 'is_seller_package': + $query->where('is_seller_package', 1); + break; + } + }) + ->with(['category', 'seller']) + ->orderBy('seller_id', 'desc') + ->orderBy('status', 'desc') + ->orderBy('created_at', 'desc') + ->paginate($numPerPage); + $categoies = Category::treeSelect(); + + return view('Admin::goods.all', compact('goods', 'categoies')); + } + + public function index(Request $request) + { + $title = $request->title; + $orderField = $request->orderField; + $orderDirection = $request->orderDirection; + $numPerPage = $request->numPerPage ?: 30; + $admin = Admin::user(); + + $goods = Goods::when(Admin::user()->seller_id > 1, function ($query) use ($admin) { + $query->where('seller_id', $admin->seller_id); + }) + ->when($title, function ($query) use ($title) { + $query->where('title', 'like', "%{$title}%"); + }) + ->when($orderField, function ($query) use ($orderField, $orderDirection) { + $query->orderBy($orderField, $orderDirection); + }) + ->with(['category', 'seller']) + ->orderBy('status', 'desc') + ->orderBy('created_at', 'desc') + ->paginate($numPerPage); + + return view('Admin::goods.index', compact('goods')); + } + + public function create() + { + $sellers = Seller::where('status', 1)->get(); + $categoies = Category::treeSelect(91); + + return view('Admin::goods.create', compact('categoies', 'sellers')); + } + + public function store(Request $request) + { + $validator = Validator::make($request->all(), [ + 'title' => 'required|min:2|max:50', + 'category_id' => 'required', + 'description' => 'required|min:4', + 'content' => 'required|min:4', + 'storage_id' => 'required', + ], [ + 'title.required' => '标题必须填写', + 'title.min' => '标题最少为:min字符', + 'title.max' => '标题最多为:max字符', + 'category_id.required' => '分类必须选择', + 'description.required' => '简介必须填写', + 'description.min' => '简介最少:min个字', + 'content.required' => '内容必须填写', + 'content.min' => '内容最少:min个字', + 'storage_id.required' => '标题图必须上传', + + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + + if (!isset($request->params)) { + return $this->error('商品规格必须填写'); + } + + foreach ($request->params as $p) { + $validator = Validator::make($p, [ + 'original' => 'required|numeric|min:0.001', + 'price' => 'required|numeric|min:0.001', + 'stock' => 'required|integer|min:1', + 'heavy' => 'required|numeric|min:0.001', + ], [ + 'original.required' => '原价必须填写', + 'original.numeric' => '原价必须为数字', + 'original.min' => '原价最小值:min', + 'price.required' => '售价必须填写', + 'price.numeric' => '售价必须为数字', + 'price.min' => '售价最小值:min', + 'stock.required' => '库存必须填写', + 'stock.integer' => '库存必须为整数', + 'stock.min' => '库存最小值:min', + 'heavy.required' => '重量必须填写', + 'heavy.numeric' => '重量必须为数字', + 'heavy.min' => '重量最小值:min', + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + } + + try { + DB::transaction(function () use ($request) { + $status = 1; + if (Admin::user()->seller_id == 1) { + $status = 1; + } + + $seller_id = Admin::id() == 1 ? $request->seller_id : Admin::user()->seller_id; + $goods = Goods::create([ + 'title' => $request->title, + 'category_id' => $request->category_id, + 'description' => $request->description, + 'content' => $request->content, + 'storage_id' => $request->storage_id, + 'seller_id' => $seller_id, + 'status' => $status, + ]); + + $goods->params()->createMany($request->params); + + }); + return $this->success('操作成功', 'close'); + } catch (\Exception $e) { + return $this->error('操作失败' . $e->getmessage()); + } + + } + + public function edit(Goods $good) + { + $categoies = Category::treeSelect(91); + $sellers = Seller::where('status', 1)->get(); + return view('Admin::goods.edit', compact('categoies', 'good', 'sellers')); + } + + public function magageedit(Goods $good) + { + $categoies = Category::treeSelect(); + return view('Admin::goods.magageedit', compact('categoies', 'good')); + } + + public function update(Request $request, Goods $good) + { + + $validator = Validator::make($request->all(), [ + 'title' => 'required|min:2|max:50', + 'category_id' => 'required', + 'description' => 'required|min:4', + 'content' => 'required|min:4', + 'storage_id' => 'required', + ], [ + 'title.required' => '标题必须填写', + 'title.min' => '标题最少为:min字符', + 'title.max' => '标题最多为:max字符', + 'category_id.required' => '分类必须选择', + 'description.required' => '简介必须填写', + 'description.min' => '简介最少:min个字', + 'content.required' => '内容必须填写', + 'content.min' => '内容最少:min个字', + 'storage_id.required' => '标题图必须上传', + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + + if (!isset($request->params)) { + return $this->error('商品规格必须填写'); + } + foreach ($request->params as $p) { + $validator = Validator::make($p, [ + 'original' => 'required|numeric|min:0.001', + 'price' => 'required|numeric|min:0.001', + // 'score' => 'required|numeric|min:0', + 'stock' => 'required|integer|min:1', + 'heavy' => 'required|numeric|min:0.001', + ], [ + 'original.required' => '原价必须填写', + 'original.numeric' => '原价必须为数字', + 'original.min' => '原价最小值:min', + 'price.required' => '售价必须填写', + 'price.numeric' => '售价必须为数字', + 'price.min' => '售价最小值:min', + 'stock.required' => '库存必须填写', + 'stock.integer' => '库存必须为整数', + 'stock.min' => '库存最小值:min', + 'heavy.required' => '重量必须填写', + 'heavy.numeric' => '重量必须为数字', + 'heavy.min' => '重量最小值:min', + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + } + + try { + DB::transaction(function () use ($good, $request) { + + $seller_id = Admin::id() == 1 ? $request->seller_id : Admin::user()->seller_id; + + $good->update([ + 'title' => $request->title, + 'category_id' => $request->category_id, + 'description' => $request->description, + 'content' => $request->content, + 'seller_id' => $seller_id, + 'storage_id' => $request->storage_id, + ]); + + $ids = []; + + foreach ($request->params as $param) { + if (isset($param['id'])) { + $params = GoodsParams::find($param['id']); + $params->update($param); + array_push($ids, $param['id']); + } else { + $params = $good->params()->create($param); + array_push($ids, $params['id']); + } + } + $good->params()->where('status', 1)->whereNotIn('id', $ids)->update(['status' => 0, 'stock' => 0]); + }); + return $this->success('操作成功'); + } catch (\Exception $e) { + return $this->error('操作失败' . $e->getmessage()); + } + + } + + public function destroy(Goods $good) + { +// if ($good->seller_id != Admin::user()->seller_id) { + // return $this->error('非法操作'); + // } + try { + DB::transaction(function () use ($good) { + Cart::where('goods_id', $good->id)->delete(); + // $good->params()->update(['status' => 0, 'stock' => 0]); + $good->status = 0; + $good->save(); + }); + return $this->success('操作成功'); + } catch (\Exception $e) { + return $this->error('操作失败' . $e->getmessage()); + } + } + + public function recycle(Request $request) + { + $title = $request->title; + $orderField = $request->orderField; + $orderDirection = $request->orderDirection; + $numPerPage = $request->numPerPage ?: 30; + + $goods = Goods::where('seller_id', Admin::user()->seller_id)->onlyTrashed() + ->when($title, function ($query) use ($title) { + $query->where('title', 'like', "%{$title}%"); + }) + ->when($orderField, function ($query) use ($orderField, $orderDirection) { + $query->orderBy($orderField, $orderDirection); + }) + ->with(['category', 'seller']) + ->paginate($numPerPage); + return view('Admin::goods.recycle', compact('goods')); + } + + /** + * 清空回收站 + * 未考虑删除关联数据的问题 + * @Author: + * @Date:2018-11-02T13:41:40+0800 + * @return [type] [description] + */ + public function clean() + { + if (Goods::where('seller_id', Admin::user()->seller_id)->onlyTrashed()->forceDelete()) { + return $this->success(); + } else { + return $this->error(); + } + } + + /** + * 还原 + * @Author: + * @Date:2018-11-02T13:43:47+0800 + * @param [type] $user [description] + * @return [type] [description] + */ + public function resume($good) + { + if (Goods::where('seller_id', Admin::user()->seller_id)->withTrashed()->where('id', $good)->restore()) { + return $this->success(); + } else { + return $this->error(); + } + } + + /** + * 彻底删除单条目 + * @Author: + * @Date:2018-11-02T13:43:36+0800 + * @param [type] $user [description] + * @return [type] [description] + */ + public function delete(Goods $good) + { + try { + DB::transaction(function () use ($good) { + $good->params()->delete(); + $good->delete(); + }); + return $this->success('操作成功'); + } catch (\Exception $e) { + return $this->error('操作失败' . $e->getmessage()); + } + + } + + public function putOn(Request $request, Goods $good) + { + if ($request->isMethod('PUT')) { + $validator = Validator::make($request->all(), [ + 'title' => 'required|min:2|max:50', + 'category_id' => 'required', + 'description' => 'required|min:4', + 'content' => 'required|min:4', + 'storage_id' => 'required', + ], [ + 'title.required' => '标题必须填写', + 'title.min' => '标题最少为:min字符', + 'title.max' => '标题最多为:max字符', + 'category_id.required' => '分类必须选择', + 'description.required' => '简介必须填写', + 'description.min' => '简介最少:min个字', + 'content.required' => '内容必须填写', + 'content.min' => '内容最少:min个字', + 'storage_id.required' => '标题图必须上传', + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + + if (!isset($request->params)) { + return $this->error('商品规格必须填写'); + } + foreach ($request->params as $p) { + $validator = Validator::make($p, [ + 'original' => 'required|numeric|min:0.001', + 'price' => 'required|numeric|min:0.001', + 'stock' => 'required|integer|min:1', + 'heavy' => 'required|numeric|min:0.001', + ], [ + 'original.required' => '原价必须填写', + 'original.numeric' => '原价必须为数字', + 'original.min' => '原价最小值:min', + 'price.required' => '售价必须填写', + 'price.numeric' => '售价必须为数字', + 'price.min' => '售价最小值:min', + 'stock.required' => '库存必须填写', + 'stock.integer' => '库存必须为整数', + 'stock.min' => '库存最小值:min', + 'heavy.required' => '重量必须填写', + 'heavy.numeric' => '重量必须为数字', + 'heavy.min' => '重量最小值:min', + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + if ($p['score'] > $p['price']) { + return $this->error('可使用积分数量不能大于商品价格'); + } + } + + try { + DB::transaction(function () use ($good, $request) { + $good->update([ + 'title' => $request->title, + 'category_id' => $request->category_id, + 'description' => $request->description, + 'content' => $request->content, + 'storage_id' => $request->storage_id, + 'status' => 1, + ]); + + $ids = []; + + foreach ($request->params as $param) { + if (isset($param['id'])) { + $params = GoodsParams::find($param['id']); + $params->update($param); + array_push($ids, $param['id']); + } else { + $params = $good->params()->create($param); + array_push($ids, $params['id']); + } + } + }); + return $this->success('操作成功'); + } catch (\Exception $e) { + return $this->error('操作失败' . $e->getmessage()); + } + } else { + $categoies = Category::treeSelect(); + return view('Admin::goods.putOn', compact('categoies', 'good')); + } + } + + public function setting(Request $request, Goods $good) + { + if ($request->isMethod('PUT')) { + try { + $good->update([ + 'is_recommend' => $request->is_recommend, + 'is_hot_sell' => $request->is_hot_sell, + 'is_hot_changed' => $request->is_hot_changed, + 'is_seller_package' => $request->is_seller_package, + 'banner_id' => $request->is_seller_package == 1 && $request->banner_id ? $request->banner_id : 0, + ]); + return $this->success('设置成功', 'close'); + } catch (\Exception $e) { + return $this->error('设置失败' . $e->getmessage()); + } + } else { + return view('Admin::goods.setting', compact('good')); + } + } + + public function setgift(Goods $good) + { + try { + DB::transaction(function () use ($good) { + $good->is_seller_gift = 1; + $good->save(); + }); + return $this->success('设置成功'); + } catch (\Exception $e) { + return $this->error('设置失败' . $e->getmessage()); + } + + } + + public function cancelgift(Goods $good) + { + + try { + DB::transaction(function () use ($good) { + $good->is_seller_gift = 0; + $good->save(); + }); + return $this->success('设置成功'); + } catch (\Exception $e) { + return $this->error('设置失败' . $e->getmessage()); + } + + } + + public function setlottery(Goods $good) + { + try { + DB::transaction(function () use ($good) { + $good->is_lottery_gift = 1; + $good->save(); + }); + return $this->success('设置成功'); + } catch (\Exception $e) { + return $this->error('设置失败' . $e->getmessage()); + } + + } + + public function cancellottery(Goods $good) + { + + try { + DB::transaction(function () use ($good) { + $good->is_lottery_gift = 0; + $good->save(); + }); + return $this->success('设置成功'); + } catch (\Exception $e) { + return $this->error('设置失败' . $e->getmessage()); + } + + } + + public function setFull(Goods $good) + { + + try { + DB::transaction(function () use ($good) { + $good->is_mall_gift = 1; + $good->save(); + }); + return $this->success('设置成功'); + } catch (\Exception $e) { + return $this->error('设置失败' . $e->getmessage()); + } + + } + + public function cancelFull(Goods $good) + { + + try { + DB::transaction(function () use ($good) { + $good->is_mall_gift = 0; + $good->save(); + }); + return $this->success('设置成功'); + } catch (\Exception $e) { + return $this->error('设置失败' . $e->getmessage()); + } + + } + +} diff --git a/app/Admin/Controllers/HomeController.php b/app/Admin/Controllers/HomeController.php new file mode 100644 index 0000000..67700df --- /dev/null +++ b/app/Admin/Controllers/HomeController.php @@ -0,0 +1,11 @@ +get('d'); + dump($s); + dump(CDKEY::parse($s)); + + ($g = CDKEY::generator()); + echo $g['qrcode']; + return [123]; + } +} diff --git a/app/Admin/Controllers/LessonController.php b/app/Admin/Controllers/LessonController.php new file mode 100644 index 0000000..7d852b0 --- /dev/null +++ b/app/Admin/Controllers/LessonController.php @@ -0,0 +1,146 @@ +seller->type != 'organ') { + return $this->error('您没有权限'); + } + $title = $request->title; + $orderField = $request->orderField; + $orderDirection = $request->orderDirection; + $numPerPage = $request->numPerPage ?: 30; + + $lists = SellerLesson::with('organ') + ->withCount('logs') + ->when($title, function ($query) use ($title) { + $query->where('title', 'like', "%" . $title . "%"); + }) + ->when($orderField, function ($query) use ($orderField, $orderDirection) { + $query->orderBy($orderField, $orderDirection); + }) + ->paginate($numPerPage); + + return view('Admin::lesson.index', compact('lists')); + } + + public function create() + { + $organs = Seller::where('status', 1)->where('type', 'organ')->get(); + $categoies = Category::treeSelect(1); + + return view('Admin::lesson.create', compact('organs', 'categoies')); + } + + public function store(Request $request) + { + $validator = Validator::make($request->all(), [ + 'title' => 'required|min:2|max:50', + 'chapter' => 'required', + 'price' => 'required', + 'crowd' => 'required', + 'crowd_age' => 'required', + 'maximum' => 'required', + 'seller_id' => 'required', + 'description' => 'required', + 'storage_id' => 'required', + 'content' => 'required', + ], [ + 'name.required' => '课程名称必须填写', + 'name.min' => '课程名称最少为:min字符', + 'name.max' => '课程名称最多为:max字符', + 'chapter.required' => '章节数必须填写', + 'price.required' => '价格必须填写', + 'crowd.required' => '适合人群必须填写', + 'crowd_age.required' => '适合年龄必须填写', + 'maximum.required' => '报名人数必须填写', + 'seller_id.required' => '机构必须选择', + 'description.required' => '简介必须填写', + 'storage_id.required' => '图片必须上传', + 'content.required' => '详情必须填写', + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + if (SellerLesson::create($request->all())) { + return $this->success('', 'close'); + } else { + return $this->error(); + } + } + + public function edit(SellerLesson $lesson) + { + $organs = Seller::where('status', 1)->where('type', 'organ')->get(); + $categoies = Category::treeSelect(1); + return view('Admin::lesson.edit', compact('lesson', 'organs', 'categoies')); + } + + public function update(Request $request, SellerLesson $lesson) + { + $validator = Validator::make($request->all(), [ + 'title' => 'required|min:2|max:50', + 'chapter' => 'required', + 'price' => 'required', + 'crowd' => 'required', + 'crowd_age' => 'required', + 'maximum' => 'required', + 'seller_id' => 'required', + 'description' => 'required', + 'storage_id' => 'required', + 'content' => 'required', + ], [ + 'name.required' => '课程名称必须填写', + 'name.min' => '课程名称最少为:min字符', + 'name.max' => '课程名称最多为:max字符', + 'chapter.required' => '章节数必须填写', + 'price.required' => '价格必须填写', + 'crowd.required' => '适合人群必须填写', + 'crowd_age.required' => '适合年龄必须填写', + 'maximum.required' => '报名人数必须填写', + 'seller_id.required' => '机构必须选择', + 'description.required' => '简介必须填写', + 'storage_id.required' => '图片必须上传', + 'content.required' => '详情必须填写', + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + + if ($lesson->update($request->all())) { + return $this->success('', 'close'); + } else { + return $this->error(); + } + } + + public function delete(SellerLesson $lesson) + { + if ($lesson->delete()) { + return $this->success(); + } else { + return $this->error(); + } + + } + + public function logs($lesson) + { + $logs = SellerLessonLog::where('lesson_id', $lesson)->paginate(); + return view('Admin::lesson.logs', compact('logs')); + } + +} diff --git a/app/Admin/Controllers/LotteryController.php b/app/Admin/Controllers/LotteryController.php new file mode 100644 index 0000000..8316693 --- /dev/null +++ b/app/Admin/Controllers/LotteryController.php @@ -0,0 +1,264 @@ +orderField; + $orderDirection = $request->orderDirection; + $numPerPage = $request->numPerPage ?: 30; + + $lists = Lottery::withCount('logs') + ->withCount('gifts') + ->when($orderField, function ($query) use ($orderField, $orderDirection) { + $query->orderBy($orderField, $orderDirection); + }) + ->paginate($numPerPage); + + return view('Admin::lottery.index', compact('lists')); + } + + public function create() + { + return view('Admin::lottery.create'); + } + + public function store(Request $request) + { + $validator = Validator::make($request->all(), [ + 'title' => 'required|min:2|max:50', + 'status' => 'required', + 'start_at' => 'required', + 'end_at' => 'required', + ], [ + 'title.required' => '名称必须填写', + 'title.min' => '名称最少为:min字符', + 'title.max' => '名称最多为:max字符', + 'status.required' => '状态必须选择', + 'start_at.required' => '开始时间填写', + 'end_at.required' => '结束时间填写', + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + if (Lottery::create($request->all())) { + return $this->success('', 'close'); + } else { + return $this->error(); + } + } + + public function edit(Lottery $lottery) + { + return view('Admin::lottery.edit', compact('lottery')); + } + + public function update(Request $request, Lottery $lottery) + { + $validator = Validator::make($request->all(), [ + 'title' => 'required|min:2|max:50', + 'status' => 'required', + 'start_at' => 'required', + 'end_at' => 'required', + ], [ + 'title.required' => '名称必须填写', + 'title.min' => '名称最少为:min字符', + 'title.max' => '名称最多为:max字符', + 'status.required' => '状态必须选择', + 'start_at.required' => '开始时间填写', + 'end_at.required' => '结束时间填写', + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + if ($lottery->update($request->all())) { + return $this->success('', 'close'); + } else { + return $this->error(); + } + } + + public function logs(Lottery $lottery) + { + $logs = LotteryLog::where('lottery_id', $lottery->id)->paginate(); + return view('Admin::lottery.logs', compact('logs')); + } + + public function gifts(Request $request, Lottery $lottery) + { + $lists = LotteryGift::where('lottery_id', $lottery->id)->orderBy('level', 'asc')->paginate(); + return view('Admin::lottery.gifts', compact('lottery', 'lists')); + } + + //添加奖品 + public function addgifts(Request $request, Lottery $lottery) + { + $item_type = LotteryGift::$class[$request->type] ?? 'App\Models\GoodsParams'; + + if ($request->isMethod('POST')) { + $validator = Validator::make($request->all(), [ + 'number' => 'required', + 'level' => 'required', + 'chance' => 'required', + ], [ + 'number.required' => '请输入商品数量', + 'level.required' => '请选择奖项', + 'chance.required' => '请填写概率', + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + + if ($request->type && empty($request->item_id)) { + return $this->error('请选择商品'); + } + + if (!$request->type) { + $request->item_id = ''; + $request->item_type = ''; + } + + $data = [ + 'level' => $request->level, + 'lottery_id' => $request->lottery_id, + 'chance' => $request->chance, + 'item_id' => $request->item_id, + 'item_type' => $request->item_type, + 'type' => $request->type, + 'number' => $request->number, + 'site' => LotteryGift::$chances[$request->level], + ]; + + if (LotteryGift::create($data)) { + return $this->success('', 'close'); + } else { + return $this->error(); + } + } else { + $hasLevels = LotteryGift::where('lottery_id', $lottery->id)->pluck('level')->toArray(); + $params_id = LotteryGift::where('lottery_id', $lottery->id) + ->where('type', 1) + ->where('item_type', $item_type) + ->pluck('item_id') + ->toArray(); + + if ($request->type == 'activity') { + $params = Activity::where('status', 1) + ->whereNotIn('id', $params_id) + ->get(); + } elseif ($request->type == 'goods') { + $params = GoodsParams::with(['goods']) + ->whereHas('goods', function ($query) { + $query->where('status', 1)->where('is_lottery_gift', 1); + }) + ->whereNotIn('id', $params_id) + ->get(); + } elseif ($request->type == 'coupon') { + $params = CouponInfo::where('status', 1)->where('type', 'lottery') + ->whereNotIn('id', $params_id) + ->get(); + } + + $levels = LotteryGift::$levels; + $item_type = LotteryGift::$class[$request->type] ?? 'App\Models\GoodsParams'; + + return view('Admin::lottery.addgifts', compact('lottery', 'params', 'levels', 'hasLevels', 'item_type')); + } + } + + //编辑奖品 + public function editgifts(Request $request, LotteryGift $gift) + { + if ($request->isMethod('PUT')) { + + $validator = Validator::make($request->all(), [ + 'number' => 'required', + 'level' => 'required', + 'chance' => 'required', + 'item_id' => 'required', + ], [ + 'number.required' => '请输入商品数量', + 'level.required' => '请选择奖项', + 'chance.required' => '请填写概率', + 'item_id.required' => '请选择商品', + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + + $data = [ + 'level' => $request->level, + 'chance' => $request->chance, + 'item_id' => $request->item_id, + 'type' => $request->type, + 'number' => $request->number, + 'site' => LotteryGift::$chances[$request->level], + ]; + + if ($gift->update($data)) { + return $this->success('', 'close'); + } else { + return $this->error(); + } + } else { + $hasLevels = LotteryGift::where('lottery_id', $gift->lottery_id)->pluck('level')->toArray(); + + $params_id = LotteryGift::where('lottery_id', $gift->lottery_id) + ->where('type', 1) + ->where('item_type', $gift->item_type) + ->where('id', '<>', $gift->id) + ->pluck('item_id') + ->toArray(); + + if ($gift->item_type == 'App\Models\Activity') { + $params = Activity::where('status', 1) + ->whereNotIn('id', $params_id) + ->get(); + } elseif ($gift->item_type == 'App\Models\GoodsParams') { + $params = GoodsParams::with(['goods']) + ->whereHas('goods', function ($query) { + $query->where('status', 1)->where('is_lottery_gift', 1); + }) + ->whereNotIn('id', $params_id) + ->get(); + } elseif ($gift->item_type == 'RuLong\Coupon\Models\CouponInfo') { + $params = CouponInfo::where('status', 1)->where('type', 'lottery') + ->whereNotIn('id', $params_id) + ->get(); + } else { + $params = collect(); + } + + $levels = LotteryGift::$levels; + + return view('Admin::lottery.editgifts', compact('gift', 'params', 'levels', 'hasLevels')); + } + } + + //删除奖品 + public function delgifts(Request $request, LotteryGift $gift) + { + if ($gift->delete()) { + return $this->success(); + } else { + return $this->error(); + } + } + +} diff --git a/app/Admin/Controllers/NotificationController.php b/app/Admin/Controllers/NotificationController.php new file mode 100644 index 0000000..93e5fd5 --- /dev/null +++ b/app/Admin/Controllers/NotificationController.php @@ -0,0 +1,46 @@ +nickname; + $start = $request->start; + $end = $request->end; + $orderField = $request->orderField; + $orderDirection = $request->orderDirection; + $numPerPage = $request->numPerPage ?: 30; + + $notifications = DatabaseNotification::when($start && $end, function ($query) use ($start,$end) { + return $query->whereBetween('created_at', [$start, date('Y-m-d', strtotime("+1 days", strtotime($end)))]); + })->when($start && !$end, function ($query) use ($start) { + return $query->where('created_at', '>=', $start); + })->when(!$start && $end, function ($query) use ($end) { + return $query->where('created_at', '<=', date('Y-m-d', strtotime("+1 days", strtotime($end)))); + })->when($orderField, function ($query) use ($orderField, $orderDirection) { + $query->orderBy($orderField, $orderDirection); + })->orderBy('created_at', 'desc')->paginate($numPerPage); + return view('Admin::notifications.index', compact('notifications')); + } + + public function destroy(Request $request, $notification) + { + if ($notification == 'batch') { + $result = DatabaseNotification::whereIn('id', $request->ids)->delete(); + } else { + $result = DatabaseNotification::where('id', $notification)->delete(); + } + + if ($result) { + return $this->success(); + } else { + return $this->error(); + } + } +} diff --git a/app/Admin/Controllers/OrderAllController.php b/app/Admin/Controllers/OrderAllController.php new file mode 100644 index 0000000..bfd8d49 --- /dev/null +++ b/app/Admin/Controllers/OrderAllController.php @@ -0,0 +1,108 @@ +orderid; + $mobile = $request->mobile; + $nickname = $request->nickname; + $seller = $request->seller; + $state = $request->state; + $start = $request->start; + $end = $request->end; + $title = $request->title; + $item_type = $request->item_type; + $orderField = $request->orderField; + $orderDirection = $request->orderDirection; + $numPerPage = $request->numPerPage ?: 30; + + $orders = Order::when($seller, function ($query) use ($seller) { + $query->whereHas('seller', function ($query) use ($seller) { + $query->where('name', 'like', "%{$seller}%"); + }); + }) + ->when($orderid, function ($query) use ($orderid) { + $query->where('orderid', 'like', "%{$orderid}%"); + }) + ->when($mobile, function ($query) use ($mobile) { + $query->whereHas('user', function ($query) use ($mobile) { + $query->where('mobile', 'like', "%{$mobile}%"); + }); + }) + ->when($nickname, function ($query) use ($nickname) { + $query->whereHas('user', function ($query) use ($nickname) { + return $query->whereHas('info', function ($query) use ($nickname) { + $query->where('nickname', 'like', "%{$nickname}%"); + }); + }); + }) + ->when($title, function ($query) use ($title) { + $goods_ids = Goods::where('title', 'like',"%{$title}%")->pluck('id'); + $params_ids = GoodsParams::whereIn('goods_id',$goods_ids)->pluck('id'); + $query->whereHas('details', function ($query) use ($params_ids) { + return $query->whereIn('item_id',$params_ids); + }); + }) + ->when($item_type, function ($query) use($item_type){ + return $query->where('item_type',$item_type); + }) + ->when($state == '', function ($query){ + return $query->where('state', '<>',Order::ORDER_CLOSED); + }) + ->when($state, function ($query) use ($state) { + switch ($state) { + case 'UNPAY': + return $query->where('state', Order::ORDER_UNPAY); + break; + case 'PAID': + return $query->whereIn('state', [Order::ORDER_PAID, Order::ORDER_DELIVER]); + break; + case 'DELIVERED': + return $query->where('state', Order::ORDER_DELIVERED); + break; + case 'SIGNED': + return $query->where('state', Order::ORDER_SIGNED); + break; + case 'CLOSED': + return $query->where('state', Order::ORDER_CLOSED); + break; + case 'CANCEL': + return $query->where('state', Order::ORDER_CANCEL); + break; + case 'COMPLETED': + return $query->where('state', Order::ORDER_COMPLETED); + break; + default: + break; + } + }) + ->when($start && $end, function ($query) use ($start, $end) { + $query->whereBetween('created_at', [$start, date('Y-m-d', strtotime("+1 days", strtotime($end)))]); + }) + ->when($start && !$end, function ($query) use ($start) { + $query->where('created_at', '>=', $start); + }) + ->when((!$start && $end), function ($query) use ($end) { + $query->where('created_at', '<=', date('Y-m-d', strtotime("+1 days", strtotime($end)))); + }) + ->when($orderField, function ($query) use ($orderField, $orderDirection) { + $query->orderBy($orderField, $orderDirection); + }) + ->with(['seller', 'user.info']) + ->orderBy('created_at', 'desc') + ->paginate($numPerPage); + return view('Admin::orders.allSellerOrder', compact('orders')); + } + + +} diff --git a/app/Admin/Controllers/OrderController.php b/app/Admin/Controllers/OrderController.php new file mode 100644 index 0000000..cd2f7c4 --- /dev/null +++ b/app/Admin/Controllers/OrderController.php @@ -0,0 +1,372 @@ +orderid; + $mobile = $request->mobile; + $nickname = $request->nickname; + $state = $request->state; + $start = $request->start; + $end = $request->end; + $title = $request->title; + $item_type = $request->item_type; + $orderField = $request->orderField; + $orderDirection = $request->orderDirection; + $numPerPage = $request->numPerPage ?: 30; + $admin = Admin::user(); + + $orders = Order::when($admin->id > 1, function ($query) use ($admin) { + $query->where('seller_id', $admin->seller_id); + }) + ->when($orderid, function ($query) use ($orderid) { + $query->where('orderid', 'like', "%{$orderid}%"); + }) + ->when($mobile, function ($query) use ($mobile) { + $query->whereHas('user', function ($query) use ($mobile) { + $query->where('mobile', 'like', "%{$mobile}%"); + }); + }) + ->when($nickname, function ($query) use ($nickname) { + $query->whereHas('user', function ($query) use ($nickname) { + return $query->whereHas('info', function ($query) use ($nickname) { + $query->where('nickname', 'like', "%{$nickname}%"); + }); + }); + }) + ->when($title, function ($query) use ($title) { + $goods_ids = Goods::where('title', 'like', "%{$title}%")->pluck('id'); + $params_ids = GoodsParams::whereIn('goods_id', $goods_ids)->pluck('id'); + $query->whereHas('details', function ($query) use ($params_ids) { + return $query->whereIn('item_id', $params_ids); + }); + }) + ->when($item_type, function ($query) use ($item_type) { + return $query->where('item_type', $item_type); + }) + ->when($state == '', function ($query) { + return $query->where('state', '<>', Order::ORDER_CLOSED); + }) + ->when($state, function ($query) use ($state) { + switch ($state) { + case 'UNPAY': + return $query->where('state', Order::ORDER_UNPAY); + break; + case 'PAID': + return $query->whereIn('state', [Order::ORDER_PAID, Order::ORDER_DELIVER]); + break; + case 'DELIVERED': + return $query->where('state', Order::ORDER_DELIVERED); + break; + case 'SIGNED': + return $query->where('state', Order::ORDER_SIGNED); + break; + case 'CLOSED': + return $query->where('state', Order::ORDER_CLOSED); + break; + case 'CANCEL': + return $query->where('state', Order::ORDER_CANCEL); + break; + case 'COMPLETED': + return $query->where('state', Order::ORDER_COMPLETED); + break; + default: + break; + } + }) + ->when($start && $end, function ($query) use ($start, $end) { + $query->whereBetween('created_at', [$start, date('Y-m-d', strtotime("+1 days", strtotime($end)))]); + }) + ->when($start && !$end, function ($query) use ($start) { + $query->where('created_at', '>=', $start); + }) + ->when((!$start && $end), function ($query) use ($end) { + $query->where('created_at', '<=', date('Y-m-d', strtotime("+1 days", strtotime($end)))); + }) + ->when($orderField, function ($query) use ($orderField, $orderDirection) { + $query->orderBy($orderField, $orderDirection); + }) + ->with(['seller', 'user.info']) + ->orderBy('created_at', 'desc') + ->paginate($numPerPage); + return view('Admin::orders.index', compact('orders')); + } + + public function unpay(Request $request) + { + $orderid = $request->orderid; + $mobile = $request->mobile; + $nickname = $request->nickname; + $start = $request->start; + $end = $request->end; + $title = $request->title; + $item_type = $request->item_type; + $orderField = $request->orderField; + $orderDirection = $request->orderDirection; + $numPerPage = $request->numPerPage ?: 30; + + $orders = Order::Unpaid()->where('seller_id', Admin::user()->seller_id) + ->when($orderid, function ($query) use ($orderid) { + $query->where('orderid', 'like', "%{$orderid}%"); + }) + ->when($mobile, function ($query) use ($mobile) { + $query->whereHas('user', function ($query) use ($mobile) { + $query->where('mobile', 'like', "%{$mobile}%"); + }); + }) + ->when($nickname, function ($query) use ($nickname) { + $query->whereHas('user', function ($query) use ($nickname) { + return $query->whereHas('info', function ($query) use ($nickname) { + $query->where('nickname', 'like', "%{$nickname}%"); + }); + }); + }) + ->when($title, function ($query) use ($title) { + $goods_ids = Goods::where('title', 'like', "%{$title}%")->pluck('id'); + $params_ids = GoodsParams::whereIn('goods_id', $goods_ids)->pluck('id'); + $query->whereHas('details', function ($query) use ($params_ids) { + return $query->whereIn('item_id', $params_ids); + }); + }) + ->when($item_type, function ($query) use ($item_type) { + return $query->where('item_type', $item_type); + }) + ->when($start && $end, function ($query) use ($start, $end) { + return $query->whereBetween('created_at', [$start, date('Y-m-d', strtotime("+1 days", strtotime($end)))]); + }) + ->when($start && !$end, function ($query) use ($start) { + return $query->where('created_at', '>=', $start); + }) + ->when(!$start && $end, function ($query) use ($end) { + return $query->where('created_at', '<=', date('Y-m-d', strtotime("+1 days", strtotime($end)))); + }) + ->when($orderField, function ($query) use ($orderField, $orderDirection) { + $query->orderBy($orderField, $orderDirection); + }) + ->with(['seller', 'user.info']) + ->orderBy('created_at', 'desc') + ->paginate($numPerPage); + + return view('Admin::orders.index', compact('orders')); + } + + public function paid(Request $request) + { + $orderid = $request->orderid; + $mobile = $request->mobile; + $nickname = $request->nickname; + $start = $request->start; + $end = $request->end; + $title = $request->title; + $item_type = $request->item_type; + $orderField = $request->orderField; + $orderDirection = $request->orderDirection; + $numPerPage = $request->numPerPage ?: 30; + + $orders = Order::UnDeliver()->where('seller_id', Admin::user()->seller_id) + ->when($orderid, function ($query) use ($orderid) { + $query->where('orderid', 'like', "%{$orderid}%"); + }) + ->when($mobile, function ($query) use ($mobile) { + $query->whereHas('user', function ($query) use ($mobile) { + $query->where('mobile', 'like', "%{$mobile}%"); + }); + }) + ->when($nickname, function ($query) use ($nickname) { + $query->whereHas('user', function ($query) use ($nickname) { + return $query->whereHas('info', function ($query) use ($nickname) { + $query->where('nickname', 'like', "%{$nickname}%"); + }); + }); + }) + ->when($title, function ($query) use ($title) { + $goods_ids = Goods::where('title', 'like', "%{$title}%")->pluck('id'); + $params_ids = GoodsParams::whereIn('goods_id', $goods_ids)->pluck('id'); + $query->whereHas('details', function ($query) use ($params_ids) { + return $query->whereIn('item_id', $params_ids); + }); + }) + ->when($item_type, function ($query) use ($item_type) { + return $query->where('item_type', $item_type); + }) + ->when($start && $end, function ($query) use ($start, $end) { + return $query->whereBetween('created_at', [$start, date('Y-m-d', strtotime("+1 days", strtotime($end)))]); + }) + ->when($start && !$end, function ($query) use ($start) { + return $query->where('created_at', '>=', $start); + }) + ->when(!$start && $end, function ($query) use ($end) { + return $query->where('created_at', '<=', date('Y-m-d', strtotime("+1 days", strtotime($end)))); + }) + ->when($orderField, function ($query) use ($orderField, $orderDirection) { + $query->orderBy($orderField, $orderDirection); + }) + ->with(['seller', 'user.info']) + ->orderBy('created_at', 'desc') + ->paginate($numPerPage); + + return view('Admin::orders.index', compact('orders')); + } + + public function signed(Request $request) + { + + $orderid = $request->orderid; + $mobile = $request->mobile; + $nickname = $request->nickname; + $start = $request->start; + $end = $request->end; + $title = $request->title; + $item_type = $request->item_type; + $orderField = $request->orderField; + $orderDirection = $request->orderDirection; + $numPerPage = $request->numPerPage ?: 30; + + $orders = Order::Signed()->where('seller_id', Admin::user()->seller_id) + ->when($orderid, function ($query) use ($orderid) { + $query->where('orderid', 'like', "%{$orderid}%"); + }) + ->when($mobile, function ($query) use ($mobile) { + $query->whereHas('user', function ($query) use ($mobile) { + $query->where('mobile', 'like', "%{$mobile}%"); + }); + }) + ->when($nickname, function ($query) use ($nickname) { + $query->whereHas('user', function ($query) use ($nickname) { + return $query->whereHas('info', function ($query) use ($nickname) { + $query->where('nickname', 'like', "%{$nickname}%"); + }); + }); + }) + ->when($item_type, function ($query) use ($item_type) { + return $query->where('item_type', $item_type); + }) + ->when($title, function ($query) use ($title) { + $goods_ids = Goods::where('title', 'like', "%{$title}%")->pluck('id'); + $params_ids = GoodsParams::whereIn('goods_id', $goods_ids)->pluck('id'); + $query->whereHas('details', function ($query) use ($params_ids) { + return $query->whereIn('item_id', $params_ids); + }); + }) + ->when($start && $end, function ($query) use ($start, $end) { + return $query->whereBetween('created_at', [$start, date('Y-m-d', strtotime("+1 days", strtotime($end)))]); + }) + ->when($start && !$end, function ($query) use ($start) { + return $query->where('created_at', '>=', $start); + }) + ->when(!$start && $end, function ($query) use ($end) { + return $query->where('created_at', '<=', date('Y-m-d', strtotime("+1 days", strtotime($end)))); + }) + ->when($orderField, function ($query) use ($orderField, $orderDirection) { + $query->orderBy($orderField, $orderDirection); + }) + ->with(['seller', 'user.info']) + ->orderBy('created_at', 'desc') + ->paginate($numPerPage); + + return view('Admin::orders.index', compact('orders')); + } + + public function show(Order $order) + { + return view('Admin::orders.show', compact('order')); + } + + /** + * 订单发货 + * @Author: + * @Date:2018-11-02T14:47:34+0800 + * @return [type] [description] + */ + public function deliver(Request $request, Order $order) + { + if ($request->isMethod('PUT')) { + try { + $order->deliver($request->company, $request->number); + return $this->success('发货成功', 'close'); + } catch (\Exception $e) { + return $this->error('发货失败' . $e->getmessage()); + } + } else { + return view('Admin::orders.deliver', compact('order')); + } + } + + public function signin(Order $order) + { + try { + $order->deliver('自提', '自提'); + $order->signin(); + return $this->success('操作成功'); + } catch (\Exception $e) { + return $this->error('操作失败' . $e->getmessage()); + } + } + + /** + * 订单发货 + * @Author: + * @Date:2018-11-02T14:47:34+0800 + * @return [type] [description] + */ + public function remark(Request $request, Order $order) + { + if ($request->isMethod('PUT')) { + try { + $order->remark_mgr = $request->remark_mgr; + $order->save(); + return $this->success('备注成功', 'close'); + } catch (\Exception $e) { + return $this->error('备注失败' . $e->getmessage()); + } + } else { + return view('Admin::orders.remark', compact('order')); + } + } + /** + * 取消订单 + * @Author: + * @Date:2018-11-02T14:45:57+0800 + * @return [type] [description] + */ + public function destroy() + {} + + public function close(Order $order) + { + try { + $order->close(); + return $this->success('操作成功'); + } catch (\Exception $e) { + return $this->error('操作失败' . $e->getmessage()); + } + } + + public function complete(Order $order) + { + try { + $order->complete(); + return $this->success('操作成功'); + } catch (\Exception $e) { + return $this->error('操作失败' . $e->getmessage()); + } + } + + public function logistic(Order $order) + { + $message = Logistic::getMessage($order->express->company ?? '', $order->express->number ?? ''); //类型csn,编号 + return view('Admin::orders.logistic', compact('order', 'message')); + } + +} diff --git a/app/Admin/Controllers/OrderDataController.php b/app/Admin/Controllers/OrderDataController.php new file mode 100644 index 0000000..43e6aec --- /dev/null +++ b/app/Admin/Controllers/OrderDataController.php @@ -0,0 +1,184 @@ +seller_id : Admin::user()->seller_id; + $numPerPage = $request->numPerPage ?: 100; + $start = $request->start; + $end = $request->end; + + $reports = SalesReport::when($seller_id,function ($q) use($seller_id){$q->where('seller_id', $seller_id);}) + ->where('state','DELIVERED') + ->when($start && $end, function ($query) use ($start, $end) { + $query->whereBetween('action_time', [$start, date('Y-m-d', strtotime("+1 days", strtotime($end)))]); + }) + ->when($start && !$end, function ($query) use ($start) { + $query->where('action_time', '>=', $start); + }) + ->when((!$start && $end), function ($query) use ($end) { + $query->where('action_time', '<=', date('Y-m-d', strtotime("+1 days", strtotime($end)))); + })->orderBy('seller_id','asc')->orderBy('action_time','desc')->paginate($numPerPage); + + $sellers = Seller::where('status', 1)->get(); + + return view('Admin::orderData.report', compact('reports','sellers')); + } + public function signed(Request $request) + { + $seller_id = Admin::id() == 1 ? $request->seller_id : Admin::user()->seller_id; + $numPerPage = $request->numPerPage ?: 100; + $start = $request->start; + $end = $request->end; + + $reports = SalesReport::when($seller_id,function ($q) use($seller_id){$q->where('seller_id', $seller_id);}) + ->where('state','SIGNED') + ->when($start && $end, function ($query) use ($start, $end) { + $query->whereBetween('action_time', [$start, date('Y-m-d', strtotime("+1 days", strtotime($end)))]); + }) + ->when($start && !$end, function ($query) use ($start) { + $query->where('action_time', '>=', $start); + }) + ->when((!$start && $end), function ($query) use ($end) { + $query->where('action_time', '<=', date('Y-m-d', strtotime("+1 days", strtotime($end)))); + })->orderBy('seller_id','asc')->orderBy('action_time','desc')->paginate($numPerPage); + + $sellers = Seller::where('status', 1)->get(); + + return view('Admin::orderData.signed', compact('reports','sellers')); + } + + + public function order(Request $request) + { + $sellers = Seller::where('status', 1)->get(); + + $orderid = $request->orderid; + $mobile = $request->mobile; + $nickname = $request->nickname; + $start = $request->start; + $end = $request->end; + $item_id = $request->item_id; + $item_type = $request->item_type; + $type = $request->type; + $orderField = $request->orderField; + $orderDirection = $request->orderDirection; + $numPerPage = $request->numPerPage ?: 30; + + $seller_id = Admin::id() == 1 ? $request->seller_id : Admin::user()->seller_id; + + $orders = Order::when($seller_id,function ($q) use($seller_id){$q->where('seller_id', $seller_id);}) + ->when($orderid, function ($query) use ($orderid) { + $query->where('orderid', 'like', "%{$orderid}%"); + }) + ->when($mobile, function ($query) use ($mobile) { + $query->whereHas('user', function ($query) use ($mobile) { + $query->where('mobile', 'like', "%{$mobile}%"); + }); + }) + ->when($nickname, function ($query) use ($nickname) { + $query->whereHas('user', function ($query) use ($nickname) { + return $query->whereHas('info', function ($query) use ($nickname) { + $query->where('nickname', 'like', "%{$nickname}%"); + }); + }); + }) + ->when($item_id, function ($query) use ($item_id) { + $query->whereHas('details', function ($query) use ($item_id) { + return $query->where('item_id',$item_id); + }); + }) + ->when($item_type, function ($query) use($item_type){ + return $query->where('item_type',$item_type); + })-> + whereHas('logs', function ($query) use ($start,$end,$type) { + $query->where('state',$type)->when($start && $end, function ($query) use ($start, $end) { + $query->whereBetween('created_at', [$start, date('Y-m-d', strtotime("+1 days", strtotime($end)))]); + }) + ->when($start && !$end, function ($query) use ($start) { + $query->where('created_at', '>=', $start); + }) + ->when((!$start && $end), function ($query) use ($end) { + $query->where('created_at', '<=', date('Y-m-d', strtotime("+1 days", strtotime($end)))); + }); + })->where('state', '<>',Order::ORDER_CLOSED) + ->when($orderField, function ($query) use ($orderField, $orderDirection) { + $query->orderBy($orderField, $orderDirection); + }) + ->with(['seller', 'user.info']) + ->orderBy('created_at', 'desc') + ->paginate($numPerPage); + return view('Admin::orderData.order', compact('sellers','orders','type','item_id')); + } + + public function dashboard(Request $request) + { + + //已签收 + //已经发货 + //日期,商户,已发货订单总量,已发货订单总额,订单商品总成本,已发货商品总计,销售价格总计,抵值积分总计,商家结算总计, + + $sellerids = Seller::get(); + $start_arr = ['2019-01-22']; + foreach ($start_arr as $starta){ + foreach ($sellerids as $key => $seller){ + $seller_id = $seller->id; + $start = date($starta, strtotime('-1 day')); + $end = date($starta); + $orderids[$key] = Order::when($seller_id,function ($q) use($seller_id){$q->where('seller_id', $seller_id);}) + ->whereHas('logs', function ($query) use ($start,$end) { + $query->where('state','PAID|DELIVERED')->when($start && $end, function ($query) use ($start, $end) { + $query->whereBetween('created_at', [$start, date('Y-m-d', strtotime("+1 days", strtotime($end)))]); + }) + ->when($start && !$end, function ($query) use ($start) { + $query->where('created_at', '>=', $start); + }) + ->when((!$start && $end), function ($query) use ($end) { + $query->where('created_at', '<=', date('Y-m-d', strtotime("+1 days", strtotime($end)))); + }); + })->where('state', '<>',Order::ORDER_CLOSED)->pluck('id'); + if(!empty($orderids[$key])){ + $detail[$key] = OrderDetail::select(DB::raw('sum(number) as number_sum, sum(score * number) as score_sum, sum(price * number) as price_sum, sum(seller_price * number) as seller_price_sum')) + ->whereIn('order_id',$orderids[$key])->first(); + if(!empty($detail[$key]) && $detail[$key]->number_sum){ + $order[$key] = Order::select(DB::raw('count(*) as order_total, sum(freight) as freight_sum, sum(seller_freight) as seller_freight_sum, sum(amount) as orders_price, sum(score) as orders_score,sum(seller_amount) as seller_amount_sum')) + ->whereIn('id',$orderids[$key])->first(); + $report[$key] = SalesReport::where(['seller_id'=>$seller_id,'state'=>'DELIVERED','action_time'=>$starta])->first(); + if(empty($report[$key])){ + SalesReport::create([ + 'state'=>'DELIVERED', + 'action_time'=>$starta, + 'goods_total'=>$detail[$key]->number_sum, + 'goods_price_total'=>$detail[$key]->price_sum, + 'goods_score_total'=>$detail[$key]->score_sum, + 'orders_total'=>$order[$key]->order_total, + 'orders_price'=>$order[$key]->orders_price, + 'orders_score'=>$order[$key]->orders_score, + 'orders_freight'=>$order[$key]->freight_sum, + 'seller_id'=>$seller_id, + 'seller_total'=>$order[$key]->seller_amount_sum, + 'seller_freight'=>$order[$key]->seller_freight_sum, + ]); + } + + } + } + } + } + + } + +} diff --git a/app/Admin/Controllers/OrganController.php## b/app/Admin/Controllers/OrganController.php## new file mode 100644 index 0000000..37ea772 --- /dev/null +++ b/app/Admin/Controllers/OrganController.php## @@ -0,0 +1,189 @@ +title; + $orderField = $request->orderField; + $orderDirection = $request->orderDirection; + $numPerPage = $request->numPerPage ?: 30; + $start = $request->start; + $end = $request->end; + + $lists = Organ::when($title, function ($query) use ($title) { + $query->where('title', 'like', "%{$title}%"); + }) + ->when($orderField, function ($query) use ($orderField, $orderDirection) { + $query->orderBy($orderField, $orderDirection); + }) + ->orderBy('created_at', 'desc') + ->when($start && $end, function ($query) use ($start, $end) { + return $query->whereBetween('created_at', [$start, date('Y-m-d', strtotime("+1 days", strtotime($end)))]); + })->when($start && !$end, function ($query) use ($start) { + return $query->where('created_at', '>=', $start); + })->when(!$start && $end, function ($query) use ($end) { + return $query->where('created_at', '<=', date('Y-m-d', strtotime("+1 days", strtotime($end)))); + }) + ->paginate($numPerPage); + + return view('Admin::organ.index', compact('lists')); + } + + public function create() + { + $provinces = \Area::index(0); + $categoies = Category::treeSelect(1); + dd(1); + return view('Admin::organ.create', compact('provinces', 'categoies')); + } + + public function store(Request $request) + { + $validator = Validator::make($request->all(), [ + 'title' => 'required|min:2|max:50', + 'mobile' => 'required', + 'wechat' => 'required', + 'province_sn' => 'required', + 'city_sn' => 'required', + 'area_sn' => 'required', + 'address' => 'required', + 'description' => 'required|min:4', + 'content' => 'required|min:4', + 'storage_id' => 'required', + ], [ + 'title.required' => '机构名称必须填写', + 'title.min' => '机构名称最少为:min字符', + 'title.max' => '机构名称最多为:max字符', + 'mobile.required' => '电话必须填写', + 'wechat.required' => '微信必须填写', + 'province_sn.required' => '请选择省', + 'city_sn.required' => '请选择市', + 'area_sn.required' => '请选择区', + 'address.required' => '地址必须填写', + 'description.required' => '简介必须填写', + 'description.min' => '简介最少:min个字', + 'content.required' => '内容必须填写', + 'content.min' => '内容最少:min个字', + 'storage_id.required' => '图片必须上传', + + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + + try { + DB::transaction(function () use ($request) { + + $organ = Organ::create($request->all()); + + }); + return $this->success('操作成功', 'close'); + } catch (\Exception $e) { + return $this->error('操作失败' . $e->getmessage()); + } + + } + + public function edit(Organ $organ) + { + $provinces = \Area::index(0); + $cities = \Area::index($organ->province_sn); + $areas = \Area::index($organ->city_sn); + $categoies = Category::treeSelect(1); + return view('Admin::organ.edit', compact('organ', 'provinces', 'cities', 'areas', 'categoies')); + } + + public function update(Request $request, Organ $organ) + { + + $validator = Validator::make($request->all(), [ + 'title' => 'required|min:2|max:50', + 'mobile' => 'required', + 'wechat' => 'required', + 'province_sn' => 'required', + 'city_sn' => 'required', + 'area_sn' => 'required', + 'address' => 'required', + 'description' => 'required|min:4', + 'content' => 'required|min:4', + 'storage_id' => 'required', + ], [ + 'title.required' => '机构名称必须填写', + 'title.min' => '机构名称最少为:min字符', + 'title.max' => '机构名称最多为:max字符', + 'mobile.required' => '电话必须填写', + 'wechat.required' => '微信必须填写', + 'province_sn.required' => '请选择省', + 'city_sn.required' => '请选择市', + 'area_sn.required' => '请选择区', + 'address.required' => '地址必须填写', + 'description.required' => '简介必须填写', + 'description.min' => '简介最少:min个字', + 'content.required' => '内容必须填写', + 'content.min' => '内容最少:min个字', + 'storage_id.required' => '图片必须上传', + + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + + try { + DB::transaction(function () use ($organ, $request) { + + $organ->update($request->all()); + }); + return $this->success('操作成功', 'close'); + } catch (\Exception $e) { + return $this->error('操作失败' . $e->getmessage()); + } + + } + + public function destroy(Organ $organ) + { + try { + DB::transaction(function () use ($organ) { + $organ->status = 0; + $organ->save(); + }); + return $this->success('操作成功'); + } catch (\Exception $e) { + return $this->error('操作失败' . $e->getmessage()); + } + } + + /** + * 彻底删除单条目 + * @Author: + * @Date:2018-11-02T13:43:36+0800 + * @param [type] $user [description] + * @return [type] [description] + */ + public function delete(Organ $organ) + { + try { + DB::transaction(function () use ($organ) { + $organ->delete(); + }); + return $this->success('操作成功'); + } catch (\Exception $e) { + return $this->error('操作失败' . $e->getmessage()); + } + + } + +} diff --git a/app/Admin/Controllers/ParamController.php b/app/Admin/Controllers/ParamController.php new file mode 100644 index 0000000..9fbe06e --- /dev/null +++ b/app/Admin/Controllers/ParamController.php @@ -0,0 +1,102 @@ +title; + $name = $request->name; + $orderField = $request->orderField; + $orderDirection = $request->orderDirection; + $numPerPage = $request->numPerPage ?: 30; + + $params = Param::when($title, function ($query) use ($title) { + $query->where('title', 'like', "%{$title}%"); + })->when($name, function ($query) use ($name) { + $query->where('name', 'like', "%{$name}%"); + })->when($orderField, function ($query) use ($orderField, $orderDirection) { + $query->orderBy($orderField, $orderDirection); + })->paginate($numPerPage); + + return view('Admin::params.index', compact('params')); + } + + public function create() + { + return view('Admin::params.create'); + } + + public function store(Request $request) + { + $validator = Validator::make($request->all(), [ + 'title' => 'required|between:2,50', + 'name' => 'required|between:2,50|unique:params', + 'value' => 'required', + ], [ + 'title.required' => '参数标题必须填写', + 'title.between' => '参数标题长度:min-:max字符', + 'name.required' => '调用名称必须填写', + 'name.between' => '调用名称长度:min-:max字符', + 'name.unique' => '调用名称已经存在', + 'value.required' => '参数值必须填写', + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + + if (Param::create($request->all())) { + return $this->success('', 'close'); + } else { + return $this->error(); + } + } + + public function edit(Param $param) + { + return view('Admin::params.edit', compact('param')); + } + + public function update(Request $request, Param $param) + { + $validator = Validator::make($request->all(), [ + 'title' => 'required|between:2,50', + 'name' => 'required|between:2,50', + 'value' => 'required', + ], [ + 'title.required' => '参数标题必须填写', + 'title.between' => '参数标题长度:min-:max字符', + 'name.required' => '调用名称必须填写', + 'name.between' => '调用名称长度:min-:max字符', + 'name.unique' => '调用名称已经存在', + 'value.required' => '参数值必须填写', + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + + if ($param->update($request->all())) { + return $this->success('', 'close'); + } else { + return $this->error(); + } + + } + + public function destroy(Param $param) + { + if ($param->delete()) { + return $this->success(); + } else { + return $this->error(); + } + } +} diff --git a/app/Admin/Controllers/PaymentController.php b/app/Admin/Controllers/PaymentController.php new file mode 100644 index 0000000..4796d48 --- /dev/null +++ b/app/Admin/Controllers/PaymentController.php @@ -0,0 +1,78 @@ +orderid; + $trade_no = $request->trade_no; + $start = $request->start; + $end = $request->end; + $orderField = $request->orderField; + $orderDirection = $request->orderDirection; + $numPerPage = $request->numPerPage ?: 30; + + $payments = Payment::when($trade_no, function ($query) use ($trade_no) { + $query->where('trade_no', 'like', "%{$trade_no}%"); + })->when($orderid, function ($query) use ($orderid) { + $query->whereHas('order', function ($query) use ($orderid) { + $query->where('orderid', 'like', "%{$orderid}%"); + }); + })->when($start && $end, function ($query) use ($start, $end) { + return $query->whereBetween('created_at', [$start, date('Y-m-d', strtotime("+1 days", strtotime($end)))]); + })->when($start && !$end, function ($query) use ($start) { + return $query->where('created_at', '>=', $start); + })->when(!$start && $end, function ($query) use ($end) { + return $query->where('created_at', '<=', date('Y-m-d', strtotime("+1 days", strtotime($end)))); + })->when($orderField, function ($query) use ($orderField, $orderDirection) { + $query->orderBy($orderField, $orderDirection); + })->with(['order'])->latest()->paginate($numPerPage); + + return view('Admin::payments.index', compact('payments')); + } + public function vip(Request $request) + { + $user_id = $request->user_id; + $nickname = $request->nickname; + $trade_no = $request->trade_no; + $start = $request->start; + $end = $request->end; + $pay_type = $request->pay_type; + $orderField = $request->orderField; + $orderDirection = $request->orderDirection; + $numPerPage = $request->numPerPage ?: 30; + + $payments = VipPament::when($trade_no, function ($query) use ($trade_no) { + $query->where('trade_no', 'like', "%{$trade_no}%"); + })->when($user_id, function ($query) use($user_id){ + return $query->where('user_id',$user_id); + })->when($nickname, function ($query) use ($nickname) { + $query->whereHas('user', function ($query) use ($nickname) { + $query->whereHas('info', function ($query) use ($nickname) { + $query->where('nickname', 'like', "%{$nickname}%"); + }); + }); + })->when($pay_type, function ($query) use($pay_type){ + return $query->where('type',$pay_type); + })->when($start && $end, function ($query) use ($start, $end) { + return $query->whereBetween('paid_at', [$start, date('Y-m-d', strtotime("+1 days", strtotime($end)))]); + })->when($start && !$end, function ($query) use ($start) { + return $query->where('paid_at', '>=', $start); + })->when(!$start && $end, function ($query) use ($end) { + return $query->where('paid_at', '<=', date('Y-m-d', strtotime("+1 days", strtotime($end)))); + })->when($orderField, function ($query) use ($orderField, $orderDirection) { + $query->orderBy($orderField, $orderDirection); + })->where('state', 'SUCCESS')->latest()->paginate($numPerPage); + + return view('Admin::payments.vip', compact('payments')); + } + +} diff --git a/app/Admin/Controllers/ProfitController.php b/app/Admin/Controllers/ProfitController.php new file mode 100644 index 0000000..bae753b --- /dev/null +++ b/app/Admin/Controllers/ProfitController.php @@ -0,0 +1,46 @@ +status; + $start = $request->start; + $end = $request->end; + $numPerPage = $request->numPerPage ?: 30; + + $profits = ProfitLog::when($status, function ($query) use ($status) { + if ($status == 'one') { + $query->where('status', 1); + } elseif ($status == 'zero') { + $query->where('status', 0); + } + })->when($start && $end, function ($query) use ($start, $end) { + return $query->whereBetween('created_at', [$start, date('Y-m-d', strtotime("+1 days", strtotime($end)))]); + })->when($start && !$end, function ($query) use ($start) { + return $query->where('created_at', '>=', $start); + })->when(!$start && $end, function ($query) use ($end) { + return $query->where('created_at', '<=', date('Y-m-d', strtotime("+1 days", strtotime($end)))); + })->orderBy('created_at', 'desc')->paginate($numPerPage); + + return view('Admin::profit.index', compact('profits')); + } + + public function logs(Request $request, ProfitLog $profit) + { + $numPerPage = $request->numPerPage ?: 30; + + $logs = UserAccountLog::whereJsonContains('source->no', $profit->end_at->format('Ymd')) + ->orderBy('user_id', 'asc') + ->paginate($numPerPage); + + return view('Admin::profit.logs', compact('logs', 'profit')); + } +} diff --git a/app/Admin/Controllers/ReportController.php b/app/Admin/Controllers/ReportController.php new file mode 100644 index 0000000..343c0e4 --- /dev/null +++ b/app/Admin/Controllers/ReportController.php @@ -0,0 +1,100 @@ +orderField; + $orderDirection = $request->orderDirection; + $numPerPage = $request->numPerPage ?: 30; + + $lists = Report::paginate($numPerPage); + + return view('Admin::report.index', compact('lists')); + } + + public function create() + { + return view('Admin::report.create'); + } + + public function store(Request $request) + { + $validator = Validator::make($request->all(), [ + 'name' => 'required|min:2|max:50', + 'mobile' => ['required', new Checkmobile], + ], [ + 'name.required' => '名称必须填写', + 'name.min' => '名称最少为:min字符', + 'name.max' => '名称最多为:max字符', + 'mobile.required' => '手机号必须填写', + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + if (Report::create($request->all())) { + return $this->success('', 'close'); + } else { + return $this->error(); + } + } + + public function edit(Report $report) + { + return view('Admin::report.edit', compact('report')); + } + + public function update(Request $request, Report $report) + { + $validator = Validator::make($request->all(), [ + 'name' => 'required|min:2|max:50', + 'mobile' => ['required', new Checkmobile], + ], [ + 'name.required' => '名称必须填写', + 'name.min' => '名称最少为:min字符', + 'name.max' => '名称最多为:max字符', + 'mobile.required' => '手机号必须填写', + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + + if ($report->update($request->all())) { + return $this->success('', 'close'); + } else { + return $this->error(); + } + } + + public function show() + { + #Todo.. + } + + //删除 + public function delete(Report $report) + { + if ($report->delete()) { + return $this->success('删除成功'); + } else { + return $this->error('删除成功'); + + } + } + + public function logs() + { + #Todo.. + } + +} diff --git a/app/Admin/Controllers/SellerController.php b/app/Admin/Controllers/SellerController.php new file mode 100644 index 0000000..9534e04 --- /dev/null +++ b/app/Admin/Controllers/SellerController.php @@ -0,0 +1,563 @@ +seller->type != 'seller') { + return $this->error('您没有权限'); + } + $name = $request->name; + $orderField = $request->orderField; + $orderDirection = $request->orderDirection; + $numPerPage = $request->numPerPage ?: 30; + $type = 'seller'; + $title = '商家'; + $sellers = Seller::withCount('admins') + ->withCount('orders') + ->withCount('goods') + ->where('type', $type) + ->when(\Admin::id() > 1, function ($query) { + $query->where('id', \Admin::user()->seller_id); + }) + ->when($name, function ($query) use ($name) { + $query->where('name', 'like', "%{$name}%"); + }) + ->when($orderField, function ($query) use ($orderField, $orderDirection) { + $query->orderBy($orderField, $orderDirection); + })->paginate($numPerPage); + + return view('Admin::sellers.index', compact('sellers', 'type', 'title')); + } + + public function search(Request $request) + { + $name = $request->name; + $numPerPage = $request->numPerPage ?: 30; + $type = 'organ'; + $sellers = Seller::where('type', $type) + ->when($name, function ($query) use ($name) { + $query->where('name', 'like', "%{$name}%"); + }) + ->paginate($numPerPage); + + return view('Admin::sellers.search', compact('sellers', 'type', 'title')); + } + //机构列表 + public function organ(Request $request) + { + if (\Admin::id() != 1 && \Admin::user()->seller->type != 'organ') { + return $this->error('您没有权限'); + } + + $name = $request->name; + $orderField = $request->orderField; + $orderDirection = $request->orderDirection; + $numPerPage = $request->numPerPage ?: 30; + $type = 'organ'; + $title = '机构'; + + $sellers = Seller::withCount('admins') + ->withCount('orders') + ->withCount('goods') + ->withCount('lesson') + ->where('type', $type) + ->when(\Admin::id() > 1, function ($query) { + $query->where('id', \Admin::user()->seller_id); + }) + ->when($name, function ($query) use ($name) { + $query->where('name', 'like', "%{$name}%"); + }) + ->when($orderField, function ($query) use ($orderField, $orderDirection) { + $query->orderBy($orderField, $orderDirection); + })->paginate($numPerPage); + + return view('Admin::sellers.index', compact('sellers', 'type', 'title')); + } + + public function show(Seller $seller) + { + $freights = Freight::where('seller_id', $seller->id)->get(); + return view('Admin::sellers.show', compact('seller', 'freights')); + } + + public function create(Request $request) + { + $pid = ($request->type == 'organ') ? 1 : 2; + $provinces = \OpenArea::index(0); + $categoies = Category::treeSelect($pid); + $agencys = Agency::where('status', 1)->get(); + $salesmans = User::where('is_salesman', 1)->get(); + return view('Admin::sellers.create', compact('provinces', 'categoies', 'agencys', 'salesmans')); + } + + public function store(Request $request) + { + + $validator = Validator::make($request->all(), [ + 'name' => 'required|min:2|max:50', + 'mobile' => 'required', + 'wechat_id' => 'required', + 'province_sn' => 'required', + 'city_sn' => 'required', + 'area_sn' => 'required', + 'address' => 'required', + 'description' => 'required|min:4', + 'content' => 'required|min:4', + 'storage_id' => 'required', + ], [ + 'name.required' => '名称必须填写', + 'name.min' => '名称最少为:min字符', + 'name.max' => '名称最多为:max字符', + 'mobile.required' => '电话必须填写', + 'wechat_id.required' => '微信二维码必须上传', + 'province_sn.required' => '请选择省', + 'city_sn.required' => '请选择市', + 'area_sn.required' => '请选择区', + 'address.required' => '地址必须填写', + 'description.required' => '简介必须填写', + 'description.min' => '简介最少:min个字', + 'content.required' => '内容必须填写', + 'content.min' => '内容最少:min个字', + 'storage_id.required' => 'Logo必须上传', + + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + if (Seller::create($request->all())) { + return $this->success('', 'close'); + } else { + return $this->error(); + } + } + + public function edit(Seller $seller) + { + $banks = Bank::orderBy('sort', 'asc')->get(); + $provinces = \OpenArea::index(0); + $cities = \OpenArea::index($seller->province_sn); + $areas = \OpenArea::index($seller->city_sn); + $pid = ($seller->type == 'organ') ? 1 : 2; + + $categoies = Category::treeSelect($pid); + $agencys = Agency::where('status', 1)->get(); + $salesmans = User::where('is_salesman', 1)->get(); + + return view('Admin::sellers.edit', compact('seller', 'banks', 'categoies', 'provinces', 'cities', 'areas', 'agencys', 'salesmans')); + } + + public function update(Request $request, Seller $seller) + { + $validator = Validator::make($request->all(), [ + 'name' => 'required|min:2|max:50', + 'mobile' => 'required', + 'wechat_id' => 'required', + 'province_sn' => 'required', + 'city_sn' => 'required', + 'area_sn' => 'required', + 'address' => 'required', + 'description' => 'required|min:4', + 'content' => 'required|min:4', + 'storage_id' => 'required', + ], [ + 'name.required' => '名称必须填写', + 'name.min' => '名称最少为:min字符', + 'name.max' => '名称最多为:max字符', + 'mobile.required' => '电话必须填写', + 'wechat_id.required' => '微信二维码必须上传', + 'province_sn.required' => '请选择省', + 'city_sn.required' => '请选择市', + 'area_sn.required' => '请选择区', + 'address.required' => '地址必须填写', + 'description.required' => '简介必须填写', + 'description.min' => '简介最少:min个字', + 'content.required' => '内容必须填写', + 'content.min' => '内容最少:min个字', + 'storage_id.required' => 'Logo必须上传', + + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + if ($seller->update($request->all())) { + return $this->success('', 'close'); + } else { + return $this->error(); + } + } + + public function destroy(Seller $seller) + { + //删除 + if ($seller->canDel()) { + if ($seller->delete()) { + if ($seller->admins) { + $seller->admins()->delete(); + } + return $this->success(); + } else { + return $this->error(); + } + } else { + if ($seller->canCancel()) { + $seller->status = 0; + $seller->save(); + } else { + return $this->error('请下架所有商品,再关闭商户'); + } + } + + } + + public function setting(Request $request) + { + if ($request->isMethod('PUT')) { + $validator = Validator::make($request->all(), [ + 'name' => 'required|min:2|max:50', + 'description' => 'required|min:4', + 'storage_id' => 'required', + ], [ + 'name.required' => '商户名称必须填写', + 'name.min' => '商户名称最少为:min字符', + 'name.max' => '商户名称最多为:max字符', + 'description.required' => '简介必须填写', + 'description.min' => '简介最少:min个字', + 'storage_id.required' => 'Logo必须上传', + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + $seller = Seller::find(\Admin::user()->seller_id); + + if ($seller->update($request->all())) { + return $this->success('操作成功'); + } else { + return $this->error(); + } + } + $banks = Bank::orderBy('sort', 'asc')->get(); + $seller = Seller::find(\Admin::user()->seller_id); + return view('Admin::sellers.setting', compact('seller', 'banks')); + } + + public function freights(Request $request) + { + $freights = Freight::where('seller_id', \Admin::user()->seller_id)->get(); + return view('Admin::sellers.freights', compact('freights')); + } + + public function freightsEdit(Request $request, Freight $freight) + { + if ($request->isMethod('PUT')) { + + $validator = Validator::make($request->all(), [ + 'basic' => 'required|numeric', + 'heavy' => 'required|numeric', + 'added' => 'required|numeric', + ], [ + 'basic.required' => '基本邮费必须填写', + 'basic.numeric' => '基本邮费必须是数字', + 'heavy.required' => '起重必须填写', + 'heavy.numeric' => '起重必须是数字', + 'added.required' => '续重必须填写', + 'added.numeric' => '续重必须是数字', + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + + $freight->update([ + 'basic' => $request->basic, + 'heavy' => $request->heavy, + 'added' => $request->added, + ]); + + return $this->success('', 'close'); + } else { + return view('Admin::sellers.freightsEdit', compact('freight')); + } + } + + public function users(Request $request, Seller $seller) + { + + $username = $request->username; + $nickname = $request->nickname; + $orderField = $request->orderField; + $orderDirection = $request->orderDirection; + $numPerPage = $request->numPerPage ?: 30; + $seller_id = $request->seller_id ?? \Admin::user()->seller_id; + + $admins = Admin::where('seller_id', $seller->id) + ->where('id', '<>', 1) + ->when($username, function ($query) use ($username) { + return $query->where('username', 'like', "%{$username}%"); + }) + ->when($nickname, function ($query) use ($nickname) { + return $query->where('nickname', 'like', "%{$nickname}%"); + })->when($orderField, function ($query) use ($orderField, $orderDirection) { + $query->orderBy($orderField, $orderDirection); + })->with('lastLogin')->withCount('logins')->paginate($numPerPage); + + return view('Admin::sellers.users', compact('admins', 'seller')); + } + + public function usersCreate() + { + return view('Admin::sellers.usersCreate'); + + } + + public function usersStore(Request $request) + { + $validator = Validator::make($request->all(), [ + 'username' => ['required', 'between:4,32', 'unique:admins'], + 'password' => 'required|between:6,32', + 'nickname' => 'nullable|between:2,16', + ], [ + 'username.required' => '用户名称必须填写', + 'username.between' => '用户名称长度应在:min-:max位之间', + 'username.unique' => '用户名称已经存在', + 'password.required' => '登录密码必须填写', + 'password.between' => '登录密码长度应在:min-:max位之间', + 'nickname.between' => '用户昵称长度应在:min-:max位之间', + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + + try { + DB::transaction(function () use ($request) { + + $admin = Admin::create([ + 'username' => $request->username, + 'password' => $request->password, + 'nickname' => $request->nickname, + 'seller_id' => $request->seller_id ?? \Admin::user()->seller_id, + ]); + DB::table('admin_role_user')->insert([ + 'role_id' => $request->role_id, + 'admin_id' => $admin->id, + 'created_at' => now(), + 'updated_at' => now(), + ]); + }); + return $this->success('操作成功', 'close'); + } catch (\Exception $e) { + return $this->error('操作失败' . $e->getmessage()); + } + } + + public function usersEdit(Admin $admin) + { + return view('Admin::sellers.usersEdit', compact('admin')); + } + + public function usersUpdate(Request $request, Admin $admin) + { + $validator = Validator::make($request->all(), [ + 'password' => 'required|between:6,32', + 'nickname' => 'nullable|between:2,16', + ], [ + 'password.required' => '登录密码必须填写', + 'password.between' => '登录密码长度应在:min-:max位之间', + 'nickname.between' => '用户昵称长度应在:min-:max位之间', + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + + try { + DB::transaction(function () use ($request, $admin) { + $admin->update([ + 'password' => $request->password, + 'nickname' => $request->nickname, + ]); + //这里还需要更新管理员的操作权限 + }); + return $this->success('操作成功', 'close'); + } catch (\Exception $e) { + return $this->error('操作失败' . $e->getmessage()); + } + } + + public function usersDestroy(Admin $admin) + { + if ($admin->delete()) { + //同时删除管理员的权限 + return $this->success(); + } else { + return $this->error(); + } + } + + public function manager(Seller $seller) + { + $adminids = DB::table('admin_role_user')->where('role_id', 1)->pluck('admin_id'); + $manager = Admin::where('seller_id', $seller->id)->whereIN('id', $adminids)->first(); + return $manager ? view('Admin::sellers.manager', compact('manager', 'seller')) : view('Admin::sellers.managerCreate', compact('seller')); + } + + public function managerUpdate(Request $request, Admin $admin) + { + $validator = Validator::make($request->all(), [ + 'password' => 'required|between:6,32', + 'nickname' => 'nullable|between:2,16', + ], [ + 'password.required' => '登录密码必须填写', + 'password.between' => '登录密码长度应在:min-:max位之间', + 'nickname.between' => '用户昵称长度应在:min-:max位之间', + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + + try { + DB::transaction(function () use ($request, $admin) { + $admin->update([ + 'password' => $request->password, + 'nickname' => $request->nickname, + 'seller_id' => $request->seller_id, + ]); + //这里还需要更新管理员的操作权限 + }); + return $this->success('操作成功', 'close'); + } catch (\Exception $e) { + return $this->error('操作失败' . $e->getmessage()); + } + } + public function managerStore(Request $request, Seller $seller) + { + $validator = Validator::make($request->all(), [ + 'username' => ['required', 'between:4,32', 'unique:admins'], + 'password' => 'required|between:6,32', + 'nickname' => 'nullable|between:2,16', + ], [ + 'username.required' => '用户名称必须填写', + 'username.between' => '用户名称长度应在:min-:max位之间', + 'username.unique' => '用户名称已经存在', + 'password.required' => '登录密码必须填写', + 'password.between' => '登录密码长度应在:min-:max位之间', + 'nickname.between' => '用户昵称长度应在:min-:max位之间', + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + + try { + DB::transaction(function () use ($request, $seller) { + $admin = Admin::create([ + 'username' => $request->username, + 'password' => $request->password, + 'nickname' => $request->nickname, + 'seller_id' => $seller->id, + ]); + DB::table('admin_role_user')->insert([ + 'role_id' => $request->role_id, + 'admin_id' => $admin->id, + 'created_at' => now(), + 'updated_at' => now(), + ]); + }); + return $this->success('操作成功', 'close'); + } catch (\Exception $e) { + return $this->error('操作失败' . $e->getmessage()); + } + } + + public function bindUser(Seller $seller) + { + $users = User::whereHas('identity', function ($query) { + $query->where('identity_id', '>=', 0); + })->doesntHave('seller')->get(); + + if ($users->count() == 0) { + return $this->error('没有用户', 'close'); + } + return view('Admin::sellers.bindUser', compact('seller', 'users')); + } + + public function dobindUser(Request $request, Seller $seller) + { + if (empty($request->user_id)) { + return $this->error('用户必须选择'); + } + + $user = User::find($request->user_id); + + if (empty($user)) { + return $this->error('用户信息有误'); + } + + if ($user->seller) { + return $this->error('用户已绑定商户'); + } + + $seller->user_id = $request->user_id; + if ($seller->save()) { + // $uids = UserRelation::where('bloodline', 'like', "%," . $user->id . ",%") + // ->pluck('user_id') + // ->toArray(); + // User::whereIn('id', $uids)->update(['seller_id' => $seller->id]); + return $this->success('操作成功', 'close'); + } else { + return $this->error('操作失败'); + } + + } + + //取消绑定 + public function cancelUser(Request $request, Seller $seller) + { + + if (!$seller->user) { + return $this->error('没有绑定用户'); + } + + $seller->user_id = null; + if ($seller->save()) { + return $this->success('操作成功'); + } else { + return $this->error('操作失败'); + } + } + + public function certificate(Request $request, Seller $seller) + { + return view('Admin::sellers.certificate', compact('seller')); + } + + public function docertificate(Request $request, Seller $seller) + { + if ($seller->update($request->all())) { + return $this->success('上传成功', 'close'); + } else { + return $this->error('上传失败'); + + } + } +} diff --git a/app/Admin/Controllers/StationController.php b/app/Admin/Controllers/StationController.php new file mode 100644 index 0000000..8b4f216 --- /dev/null +++ b/app/Admin/Controllers/StationController.php @@ -0,0 +1,126 @@ +name; + $orderField = $request->orderField; + $orderDirection = $request->orderDirection; + $numPerPage = $request->numPerPage ?: 30; + + if (Admin::id() == 1) { + $stations = Station::when($name, function ($query) use ($name) { + $query->where('name', 'like', "%{$name}%"); + }) + ->when($orderField, function ($query) use ($orderField, $orderDirection) { + $query->orderBy($orderField, $orderDirection); + })->paginate($numPerPage); + } else { + $stations = Station::when($name, function ($query) use ($name) { + $query->where('name', 'like', "%{$name}%"); + })->where('seller_id', Admin::user()->seller_id) + ->when($orderField, function ($query) use ($orderField, $orderDirection) { + $query->orderBy($orderField, $orderDirection); + })->paginate($numPerPage); + } + + return view('Admin::stations.index', compact('stations')); + } + + public function create() + { + $sellers = Seller::where('status', 1)->get(); + return view('Admin::stations.create', compact('sellers')); + } + + public function store(Request $request) + { + $validator = Validator::make($request->all(), [ + 'name' => 'required|min:2|max:50', + 'address' => 'required|min:4', + 'mobile' => 'required', + ], [ + 'name.required' => '商户名称必须填写', + 'name.min' => '商户名称最少为:min字符', + 'name.max' => '商户名称最多为:max字符', + 'address.required' => '地址必须填写', + 'address.min' => '地址最少:min个字', + 'mobile.required' => '手机号必须填写', + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + if (Station::create($request->all())) { + return $this->success('', 'close'); + } else { + return $this->error(); + } + } + + public function edit(Station $station) + { + $sellers = Seller::where('status', 1)->get(); + return view('Admin::stations.edit', compact('station', 'sellers')); + } + + public function update(Request $request, Station $station) + { + $validator = Validator::make($request->all(), [ + 'name' => 'required|min:2|max:50', + 'address' => 'required|min:4', + 'mobile' => 'required', + ], [ + 'name.required' => '商户名称必须填写', + 'name.min' => '商户名称最少为:min字符', + 'name.max' => '商户名称最多为:max字符', + 'address.required' => '地址必须填写', + 'address.min' => '地址最少:min个字', + 'mobile.required' => '手机号必须填写', + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + if ($station->update($request->all())) { + return $this->success('', 'close'); + } else { + return $this->error(); + } + } + + public function destroy(station $station) + { + if ($station->delete()) { + return $this->success(); + } else { + return $this->error(); + } + + } + + public function areas(Request $request) + { + if (empty($request->psn)) { + return $this->error('请选择省份'); + } + + $areas = \OpenArea::index($request->psn); + if ($areas) { + return $this->success(['msg' => '', 'code' => 1, 'data' => $areas]); + } else { + return $this->error('请选择省份/城市'); + } + } + +} diff --git a/app/Admin/Controllers/TeacherController.php b/app/Admin/Controllers/TeacherController.php new file mode 100644 index 0000000..b1f10b7 --- /dev/null +++ b/app/Admin/Controllers/TeacherController.php @@ -0,0 +1,138 @@ +seller_id; + $title = $request->title; + $orderField = $request->orderField; + $orderDirection = $request->orderDirection; + $numPerPage = $request->numPerPage ?: 30; + $admin = Admin::user(); + + $teachers = SellerTeacher::when($seller_id, function ($query) use ($seller_id) { + $query->where('seller_id', $seller_id); + }) + ->when($title, function ($query) use ($title) { + $query->where('title', 'like', "%{$title}%"); + }) + ->when($orderField, function ($query) use ($orderField, $orderDirection) { + $query->orderBy($orderField, $orderDirection); + }) + ->orderBy('created_at', 'desc') + ->paginate($numPerPage); + + return view('Admin::teacher.index', compact('teachers')); + } + + public function create() + { + $sellers = Seller::where('type', 'organ')->get(); + return view('Admin::teacher.create', compact('sellers')); + } + + public function store(Request $request) + { + $validator = Validator::make($request->all(), [ + 'name' => 'required|min:2|max:50', + 'rank' => 'required|min:2', + 'school_age' => 'required', + 'storage_id' => 'required', + ], [ + 'name.required' => '标题必须填写', + 'name.min' => '标题最少为:min字符', + 'name.max' => '标题最多为:max字符', + 'rank.required' => '职级必须填写', + 'rank.min' => '职级最少:min个字', + 'school_age.required' => '教龄必须填写', + 'storage_id.required' => '教师头像必须上传', + + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + + try { + DB::transaction(function () use ($request) { + $info = SellerTeacher::create($request->all()); + }); + return $this->success('操作成功', 'close'); + } catch (\Exception $e) { + return $this->error('操作失败' . $e->getmessage()); + } + + } + + public function edit($id) + { + $info = SellerTeacher::find($id); + $sellers = Seller::where('type', 'organ')->get(); + return view('Admin::teacher.edit', compact('info', 'sellers')); + } + + public function update(Request $request, $id) + { + $info = SellerTeacher::find($id); + + $validator = Validator::make($request->all(), [ + 'name' => 'required|min:2|max:50', + 'rank' => 'required|min:2', + 'school_age' => 'required', + 'storage_id' => 'required', + ], [ + 'name.required' => '标题必须填写', + 'name.min' => '标题最少为:min字符', + 'name.max' => '标题最多为:max字符', + 'rank.required' => '职级必须填写', + 'rank.min' => '职级最少:min个字', + 'school_age.required' => '教龄必须填写', + 'storage_id.required' => '教师头像必须上传', + + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + + try { + DB::transaction(function () use ($request, $info) { + $info = $info->update($request->all()); + }); + return $this->success('操作成功', 'close'); + } catch (\Exception $e) { + return $this->error('操作失败' . $e->getmessage()); + } + + } + + /** + * 彻底删除单条目 + * @Author: + * @Date:2018-11-02T13:43:36+0800 + * @param [type] $user [description] + * @return [type] [description] + */ + public function delete(SellerTeacher $info) + { + try { + DB::transaction(function () use ($info) { + $info->delete(); + }); + return $this->success('操作成功'); + } catch (\Exception $e) { + return $this->error('操作失败' . $e->getmessage()); + } + + } +} diff --git a/app/Admin/Controllers/TeamController.php b/app/Admin/Controllers/TeamController.php new file mode 100644 index 0000000..5400821 --- /dev/null +++ b/app/Admin/Controllers/TeamController.php @@ -0,0 +1,32 @@ +mobile; + $wechat = $request->wechat; + $orderField = $request->orderField; + $orderDirection = $request->orderDirection; + $numPerPage = $request->numPerPage ?: 30; + + $lists = Team::when($mobile, function ($query) use ($mobile) { + $query->where('mobile', $mobile); + }) + ->when($wechat, function ($query) use ($wechat) { + $query->where('wechat', 'like', "%" . $wechat . "%"); + }) + ->when($orderField, function ($query) use ($orderField, $orderDirection) { + $query->orderBy($orderField, $orderDirection); + }) + ->paginate($numPerPage); + + return view('Admin::team.index', compact('lists')); + } +} diff --git a/app/Admin/Controllers/TestController.php b/app/Admin/Controllers/TestController.php new file mode 100644 index 0000000..3ab4972 --- /dev/null +++ b/app/Admin/Controllers/TestController.php @@ -0,0 +1,70 @@ +where('count', '>', 1000)->group('user_id')->orderBy('count desc')->limit(10)->get(); + dump($lists); + } + + /** + * 准备做调整关系流程 + * @Author: + * @Date:2018-12-20T18:54:09+0800 + * @return [type] [description] + */ + public function relation() + { + $users = [4189]; + $parent_id = 18; + $parent = UserRelation::where('user_id', $parent_id)->first(); + if ($parent) { + foreach ($users as $key => $user_id) { + $user = UserRelation::where('user_id', $user_id)->first(); + if ($user) { + $bloodline = $parent->bloodline . $parent_id . ','; //改变后血缘线 + $oldblood = $user->bloodline . $user->user_id . ','; //目标替换血缘线 + $newblood = $bloodline . $user->user_id . ','; //目标新血缘线 + $layer_cha = ($parent->layer + 1) - $user->layer; + $user->layer += $layer_cha; + $user->parent_id = $parent_id; + $user->bloodline = $bloodline; + $user->save(); + $childs = UserRelation::where('bloodline', 'like', '%,' . $user->user_id . ',%')->get(); + foreach ($childs as $key => $child) { + $child->bloodline = str_replace($oldblood, $newblood, $child->bloodline); + $child->layer += $layer_cha; + $child->save(); + } + } + } + + } + } + + /** + * 准备做没有分润的人产生分润流程 + * @Author: + * @Date:2018-12-20T18:54:21+0800 + * @param [type] $user_id [description] + * @return [type] [description] + */ + public function fenrun($user_id) + { + $user_id = 340; + $user = UserRelation::where('user_id', $user_id)->first(); + $payment_vip = \App\Models\VipPament::where('user_id', $user_id)->where('state', 'SUCCESS')->first(); + \App\Bonus\Direct::settlement($user, ['orderid' => 'vip' . $payment_vip->id]); + } +} diff --git a/app/Admin/Controllers/UserController.php b/app/Admin/Controllers/UserController.php new file mode 100644 index 0000000..b1aa12c --- /dev/null +++ b/app/Admin/Controllers/UserController.php @@ -0,0 +1,391 @@ +user_id; + $mobile = $request->mobile; + $nickname = $request->nickname; + $identity = $request->identity; + $parent_id = $request->parent_id; + $start = $request->start; + $end = $request->end; + $is_salesman = $request->is_salesman; + $orderField = $request->orderField; + $orderDirection = $request->orderDirection; + $numPerPage = $request->numPerPage ?: 30; + + $users = User::with('organ')->when($mobile, function ($query) use ($mobile) { + return $query->where('mobile', 'like', "%{$mobile}%"); + })->when($user_id, function ($query) use ($user_id) { + return $query->where('id', $user_id); + })->when(is_numeric($is_salesman), function ($query) use ($is_salesman) { + return $query->where('is_salesman', $is_salesman); + })->when($nickname, function ($query) use ($nickname) { + return $query->whereHas('info', function ($query) use ($nickname) { + $query->where('nickname', 'like', "%{$nickname}%"); + }); + })->when(is_numeric($identity), function ($query) use ($identity) { + $query->whereHas('identity', function ($query) use ($identity) { + $query->where('identity_id', $identity); + }); + })->when($parent_id, function ($query) use ($parent_id) { + $query->whereHas('relation', function ($query) use ($parent_id) { + $query->where('parent_id', $parent_id); + }); + })->when($start && $end, function ($query) use ($start, $end) { + return $query->whereBetween('created_at', [$start, date('Y-m-d', strtotime("+1 days", strtotime($end)))]); + })->when($start && !$end, function ($query) use ($start) { + return $query->where('created_at', '>=', $start); + })->when(!$start && $end, function ($query) use ($end) { + return $query->where('created_at', '<=', date('Y-m-d', strtotime("+1 days", strtotime($end)))); + })->when($orderField, function ($query) use ($orderField, $orderDirection) { + $query->orderBy($orderField, $orderDirection); + })->with(['info', 'lastLogin'])->withCount('logins')->orderBy('created_at', 'desc')->paginate($numPerPage); + + $identitys = Identity::get(); + return view('Admin::users.index', compact('users', 'identitys')); + } + + public function edit(User $user) + { + return view('Admin::users.edit', compact('user')); + } + + public function update(Request $request, User $user) + { + $validator = Validator::make($request->all(), [ + 'password' => 'nullable|between:6,32', + ], [ + 'password.between' => '登录密码长度应在:min-:max位之间', + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + + if ($user->update($request->all())) { + return $this->success('修改成功', 'close'); + } else { + return $this->error(); + } + } + + /** + * 软删除 + * @Author: + * @Date:2018-11-02T13:44:52+0800 + * @param User $user [description] + * @return [type] [description] + */ + public function destroy(User $user) + { + if ($user->delete()) { + return $this->success(); + } else { + return $this->error(); + } + } + + /** + * 回收站 + * @Author: + * @Date:2018-11-02T13:43:57+0800 + * @return [type] [description] + */ + public function recycle(Request $request) + { + $mobile = $request->mobile; + $nickname = $request->nickname; + $orderField = $request->orderField; + $orderDirection = $request->orderDirection; + $numPerPage = $request->numPerPage ?: 30; + + $users = User::onlyTrashed()->when($mobile, function ($query) use ($mobile) { + return $query->where('mobile', 'like', "%{$mobile}%"); + })->when($nickname, function ($query) use ($nickname) { + return $query->whereHas('info', function ($query) use ($nickname) { + $query->where('nickname', 'like', "%{$nickname}%"); + }); + })->when($orderField, function ($query) use ($orderField, $orderDirection) { + $query->orderBy($orderField, $orderDirection); + })->with(['info', 'lastLogin'])->withCount('logins')->paginate($numPerPage); + return view('Admin::users.recycle', compact('users')); + } + + /** + * 清空回收站 + * 未考虑删除关联数据的问题 + * @Author: + * @Date:2018-11-02T13:41:40+0800 + * @return [type] [description] + */ + public function clean() + { + if (User::onlyTrashed()->forceDelete()) { + return $this->success(); + } else { + return $this->error(); + } + } + + /** + * 还原 + * @Author: + * @Date:2018-11-02T13:43:47+0800 + * @param [type] $user [description] + * @return [type] [description] + */ + public function resume($user) + { + if (User::withTrashed()->where('id', $user)->restore()) { + return $this->success(); + } else { + return $this->error(); + } + } + + /** + * 彻底删除单条目 + * @Author: + * @Date:2018-11-02T13:43:36+0800 + * @param [type] $user [description] + * @return [type] [description] + */ + public function delete($user) + { + if (User::withTrashed()->where('id', $user)->forceDelete()) { + return $this->success(); + } else { + return $this->error(); + } + } + + /** + * 线下开通身份 + * @Author: + * @Date:2018-11-20T15:32:24+0800 + * @param Request $request [description] + * @param [type] $user [description] + * @return [type] [description] + */ + public function identity(User $user) + { + if ($user->seller_id) { + $identity = Identity::where('id', '>', $user->identity->identity_id)->get(); + } else { + $identity = Identity::where('id', '>', $user->identity->identity_id)->whereIn('id', [1, 2])->get(); + } + return view('Admin::users.identity', compact('user', 'identity')); + + } + + /** + * 开通身份执行事件 + * @Author: + * @Date:2018-11-20T15:34:36+0800 + * @param Request $request [description] + * @return [type] [description] + */ + public function identityrun(Request $request, User $user) + { + $identity_id = $request->identity_id ?? ''; + $pay = $request->pay ?? ''; + $max_key = $request->max_key ?? '0'; + if (!$identity_id) { + return $this->error('请选择要变更的身份'); + } + $user->identityUpdate($identity_id, 'AdminUp', $pay, $max_key); + return $this->success('变更成功', 'close'); + } + + /** + * 缴费用户列表 + * @Author: + * @Date:2018-11-26T12:03:39+0800 + * @param Request $request [description] + * @return [type] [description] + */ + public function paycostUser(Request $request) + { + $numPerPage = $request->numPerPage ?: 30; + $identity = $request->identity; + $mobile = $request->mobile; + $nickname = $request->nickname; + $lists = IdentityLog::where('channel', 'AdminUp') + ->when(is_numeric($identity), function ($query) use ($identity) { + $query->where('after', $identity); + }) + ->when($mobile, function ($query) use ($mobile) { + $query->whereHas('user_obj', function ($query) use ($mobile) { + $query->where('mobile', 'like', "%{$mobile}%"); + }); + }) + ->when($nickname, function ($query) use ($nickname) { + $query->whereHas('user_obj', function ($query) use ($nickname) { + return $query->whereHas('info', function ($query) use ($nickname) { + $query->where('nickname', 'like', "%{$nickname}%"); + }); + }); + })->orderBy('created_at', 'desc')->paginate($numPerPage); + + $identitys = Identity::get(); + return view('Admin::users.paycostuser', compact('lists', 'identitys')); + } + + /** + * 缴费用户确认返款 + * @Author: + * @Date:2018-11-26T12:03:30+0800 + * @param Request $request [description] + * @param IdentityLog $log [description] + * @return [type] [description] + */ + public function rebates(Request $request, IdentityLog $log) + { + return view('Admin::users.rebates', compact('log')); + } + + /** + * 缴费用户确认返款 + * @Author: + * @Date:2018-11-26T12:03:30+0800 + * @param Request $request [description] + * @param IdentityLog $log [description] + * @return [type] [description] + */ + public function rebatesdo(Request $request, IdentityLog $log) + { + + $log->other = array_merge($log->other, ['rebates' => '已返款', 'rebates_remark' => $request->rebates_remark]); + if ($log->save()) { + return $this->success('操作成功', 'close'); + } else { + return $this->error(); + } + } + + /** + * 更改上级ID + * @Author: + * @Date:2018-11-20T15:32:24+0800 + * @param Request $request [description] + * @param [type] $user [description] + * @return [type] [description] + */ + public function parent(User $user) + { + return view('Admin::users.parent', compact('user')); + } + + /** + * 更改上级ID执行事件 + * @Author: + * @Date:2018-11-20T15:34:36+0800 + * @param Request $request [description] + * @return [type] [description] + */ + public function parentrun(Request $request, User $user) + { + $parent_id = $request->parent_id ?? ''; + if (!$parent_id || !is_numeric($parent_id)) { + return $this->error('请输入正确的编号'); + } + $parent = UserRelation::where('user_id', (int) $parent_id)->first(); + if ($parent) { + $user = $user->relation; + $bloodline = $parent->bloodline . $parent_id . ','; //改变后血缘线 + $oldblood = $user->bloodline . $user->user_id . ','; //目标替换血缘线 + $newblood = $bloodline . $user->user_id . ','; //目标新血缘线 + $layer_cha = ($parent->layer + 1) - $user->layer; + $user->layer += $layer_cha; + $user->parent_id = $parent_id; + $user->bloodline = $bloodline; + $user->save(); + $user->user->update(['seller_id' => $parent->user->seller_id]); + + $childs = UserRelation::where('bloodline', 'like', '%,' . $user->user_id . ',%')->get(); + foreach ($childs as $key => $child) { + $child->bloodline = str_replace($oldblood, $newblood, $child->bloodline); + $child->layer += $layer_cha; + $child->save(); + $child->user->update(['seller_id' => $parent->user->seller_id]); + } + } else { + return $this->error('推荐人不存在'); + } + return $this->success('变更成功', 'close'); + } + + public function direct(User $user) + { + // if ($user->direct != 2) { + // return $this->error('状态不正确'); + // } + // $payment_vip = \App\Models\VipPament::where('user_id', $user->id)->where('state', 'SUCCESS')->first(); + // \App\Bonus\Direct::settlement($user, ['orderid' => 'vip' . $payment_vip->id]); + return $this->success('执行完毕'); + } + + public function bloodview(User $user) + { + $lists = $user->relation->list2tree('user_id', 'parent_id', 'children', $user->id); + $root = [ + "text" => $user->id . ' - ' . $user->info->nickname . '(' . ($user->identity->identity_id > 0 ? '已激活' : '未激活') . ')', + "children" => $lists, + ]; + return view('Admin::users.bloodview', compact('root')); + } + + //更改组织 + public function seller(Request $request, User $user) + { + $sellers = Seller::where('type', 'organ')->whereNotIn('id', [$user->seller_id])->get(); + return view('Admin::users.seller', compact('user', 'sellers')); + } + + //更改组织执行 + public function sellerdo(Request $request, User $user) + { + + $seller_id = $request->organ_id; + if (!$seller_id || !is_numeric($seller_id)) { + return $this->error('请选择组织'); + } + + $seller = Seller::find($seller_id); + if ($seller) { + $uids = UserRelation::where('bloodline', 'like', "%," . $user->id . ",%") + ->orWhere('user_id', $user->id) + ->pluck('user_id') + ->toArray(); + User::whereIn('id', $uids)->update(['seller_id' => $seller->id]); + } else { + return $this->error('组织不存在'); + } + return $this->success('变更成功', 'close'); + } + + //设置取消业务员 + public function salesman(Request $request, User $user) + { + $value = $request->value; + if ($user->update(['is_salesman' => $value])) { + return $this->success('设置成功'); + } else { + return $this->error('设置失败'); + } + } +} diff --git a/app/Admin/Controllers/WechatController.php b/app/Admin/Controllers/WechatController.php new file mode 100644 index 0000000..2557cc6 --- /dev/null +++ b/app/Admin/Controllers/WechatController.php @@ -0,0 +1,120 @@ +name; + + $menus = WechatMenu::when($name, function ($query) use ($name) { + $query->where('name', 'like', "%{$name}%"); + })->orderBy('sort', 'asc')->get(); + $genMenus = WechatMenu::where('parent_id', 0)->orderBy('sort', 'asc')->get(); + return view('Admin::wechat.menus', compact('menus', 'genMenus')); + } + + /** + * 发布菜单到微信 + * @Author: + * @Date:2018-11-15T16:05:55+0800 + * @return [type] [description] + */ + public function publish() + { + $buttons = WechatMenu::getPublishArray(); + + $app = app('wechat.official_account'); + $result = $app->menu->create($buttons); + + if ($result->errcode == 0) { + return $this->success(); + } else { + return $this->error($result->errmsg); + } + } + + public function create() + { + $topMenus = WechatMenu::where('parent_id', 0)->get(); + return view('Admin::wechat.create', compact('topMenus')); + } + + public function store(Request $request) + { + $validator = Validator::make($request->all(), [ + 'name' => 'required|min:2|max:5', + 'parent_id' => 'required', + 'type' => 'required|in:view,click,miniprogram', + 'value' => 'required', + ], [ + 'name.required' => '菜单名称必须填写', + 'name.min' => '菜单名称最小:min位', + 'name.max' => '菜单名称最大:max位', + 'parent_id.required' => '上级菜单必须选择', + 'type.required' => '菜单类型必须选择', + 'type.in' => '菜单类型选择有误', + 'value.required' => '菜单键值必须填写', + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + + if (WechatMenu::create($request->all())) { + return $this->success('', 'close'); + } else { + return $this->error(); + } + } + + public function edit(WechatMenu $menu) + { + $topMenus = WechatMenu::where('parent_id', 0)->where('id', '<>', $menu->id)->get(); + return view('Admin::wechat.edit', compact('topMenus', 'menu')); + } + + public function update(Request $request, WechatMenu $menu) + { + $validator = Validator::make($request->all(), [ + 'name' => 'required|min:2|max:5', + 'parent_id' => 'required', + 'type' => 'required|in:view,click,miniprogram', + 'value' => 'required', + ], [ + 'name.required' => '菜单名称必须填写', + 'name.min' => '菜单名称最小:min位', + 'name.max' => '菜单名称最大:max位', + 'parent_id.required' => '上级菜单必须选择', + 'type.required' => '菜单类型必须选择', + 'type.in' => '菜单类型选择有误', + 'value.required' => '菜单键值必须填写', + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + + if ($menu->update($request->all())) { + return $this->success('编辑成功', 'close'); + } else { + return $this->error(); + } + } + + public function destroy(WechatMenu $menu) + { + if ($menu->delete()) { + return $this->success(); + } else { + return $this->error(); + } + } +} diff --git a/app/Admin/Controllers/WechatRulesController.php b/app/Admin/Controllers/WechatRulesController.php new file mode 100644 index 0000000..de3c475 --- /dev/null +++ b/app/Admin/Controllers/WechatRulesController.php @@ -0,0 +1,91 @@ +orderField; + $orderDirection = $request->orderDirection; + $numPerPage = $request->numPerPage ?: 30; + + $wechatRules = WechatRule::when($orderField, function ($query) use ($orderField, $orderDirection) { + $query->orderBy($orderField, $orderDirection); + })->paginate($numPerPage); + + return view('Admin::wechatRules.index', compact('wechatRules')); + } + + + public function create(Request $request) + { + return view('Admin::wechatRules.create'); + } + + public function store(Request $request) + { + $validator = Validator::make($request->all(), [ + 'title' => 'required|max:100', + 'name' => 'required|max:100', + 'description' => 'required|max:200', + 'storage_id' => 'required', + + ], [ + 'title.required' => '名称必须填写', + 'title.max' => '名称长度应在:max以内', + 'name.required' => '规则必须填写', + 'name.max' => '规则长度应在:max以内', + 'description.required' => '简介必须填写', + 'storage_id.required' => '标题图必须上传', + + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + + if (WechatRule::create($request->all())) { + return $this->success('新增文章成功', 'close'); + } else { + return $this->error(); + } + } + + public function edit(WechatRule $wechatRule) + { + return view('Admin::wechatRules.edit', compact('wechatRule')); + + } + + public function update(Request $request, WechatRule $wechatRule) + { + $validator = Validator::make($request->all(), [ + 'title' => 'required|max:100', + 'name' => 'required|max:100', + 'description' => 'required|max:200', + 'storage_id' => 'required', + + ], [ + 'title.required' => '名称必须填写', + 'title.max' => '名称长度应在:max以内', + 'name.required' => '规则必须填写', + 'name.max' => '规则长度应在:max以内', + 'description.required' => '简介必须填写', + 'storage_id.required' => '标题图必须上传', + + ]); + $data = $request->all(); + $wechatRule->update($data); + return $this->success('', 'close'); + } + + public function destroy($id) + { + } +} diff --git a/app/Admin/Controllers/WindupsController.php b/app/Admin/Controllers/WindupsController.php new file mode 100644 index 0000000..c94cbd8 --- /dev/null +++ b/app/Admin/Controllers/WindupsController.php @@ -0,0 +1,179 @@ + + * @Date:2018-11-30 + */ + public function index(Request $request) + { + $sellers = Seller::whereHas('orders')->get(); + + $numPerPage = $request->numPerPage ?: 30; + $start = $request->start; + $end = $request->end; + $seller_id = Admin::id() == 1 ? $request->seller_id : Admin::user()->seller_id; + $seller_orders = WindupReport::when($seller_id, function ($q) use ($seller_id) {$q->where('seller_id', $seller_id);}) + ->when($start && $end, function ($query) use ($start, $end) { + $query->whereBetween('start_time', [$start, date('Y-m-d', strtotime("+1 days", strtotime($end)))]); + }) + ->when($start && !$end, function ($query) use ($start) { + $query->where('start_time', '>=', $start); + }) + ->when((!$start && $end), function ($query) use ($end) { + $query->where('start_time', '<=', date('Y-m-d', strtotime("+1 days", strtotime($end)))); + })->where('state',0)->orderBy('id','desc')->paginate($numPerPage); + + $unwinduped = WindupReport::when($seller_id, function ($q) use ($seller_id) {$q->where('seller_id', $seller_id);})->where('state',0) + ->select(DB::raw('SUM(seller_freight_sum + seller_amount_sum) AS sum_total'))->first(); + + $winduped = WindupReport::when($seller_id, function ($q) use ($seller_id) {$q->where('seller_id', $seller_id);})->where('state',1) + ->select(DB::raw('SUM(seller_freight_sum + seller_amount_sum) AS sum_total'))->first(); + + $curr_unwinduped = Order::when($seller_id, function ($q) use ($seller_id) {$q->where('seller_id', $seller_id);}) + ->whereHas('logs', function ($query) { + $query->where('state','DELIVERED|SIGNED'); + }) + ->where('state', '<>',Order::ORDER_CLOSED) + ->where('windup_report_id',0) + ->select(DB::raw('SUM(seller_freight + seller_amount) AS sum_total'))->first(); + + return view('Admin::windups.index', compact('seller_orders','sellers','unwinduped','winduped','curr_unwinduped')); + + } + + /** + * 待结算订单明细-平台管理员、商户管理员同时可查看 + * @Author: + * @Date:2018-11-30 + */ + public function orders(Request $request) + { + $orderid = $request->orderid; + $windup_report_id = $request->windup_report_id; + $numPerPage = $request->numPerPage ?: 30; + + $orders = Order::where('windup_report_id', $windup_report_id) + ->when($orderid, function ($query) use ($orderid) { + $query->where('orderid', 'like', "%{$orderid}%"); + }) + ->with(['seller', 'user.info']) + ->orderBy('created_at', 'desc') + ->paginate($numPerPage); + return view('Admin::windups.orders', compact('orders')); + + } + + /** + * 创建商户结算记录-平台管理员 + * @Author: + * @Date:2018-11-30 + */ + public function create(Request $request) + { + $windup_report_id = $request->windup_report_id; + + $windup = WindupReport::find($windup_report_id); + + return view('Admin::windups.create', compact('windup')); + + } + + /** + * 保存商户结算记录-平台管理员 + * @Author: + * @Date:2018-11-30 + */ + public function dostate(Request $request) + { + $windup_report_id = $request->windup_report_id; + $windup = WindupReport::find($windup_report_id); + if(!$windup->seller || empty($windup->seller->account_name)){ + return $this->error('商户必须设置收款账户才能结算', 'close'); + } + + $windup->remark = $request->remark; + $windup->is_provide_invoice = $request->is_provide_invoice; + $windup->state = 1; + $windup->seller_account_name = $windup->seller->account_name; + $windup->seller_account_bank = $windup->seller->bank_name; + $windup->seller_account_number = $windup->seller->account_number; + $windup->winduped_at = now(); + + $windup->save(); + return $this->success('操作成功', 'close'); + + } + + /** + * 全部已结算记录-平台管理员 + * @Author: + * @Date:2018-11-30 + */ + public function winduped(Request $request) + { + $sellers = Seller::whereHas('orders')->get(); + + $numPerPage = $request->numPerPage ?: 30; + $start = $request->start; + $end = $request->end; + $seller_id = Admin::id() == 1 ? $request->seller_id : Admin::user()->seller_id; + $seller_orders = WindupReport::when($seller_id, function ($q) use ($seller_id) {$q->where('seller_id', $seller_id);}) + ->when($start && $end, function ($query) use ($start, $end) { + $query->whereBetween('start_time', [$start, date('Y-m-d', strtotime("+1 days", strtotime($end)))]); + }) + ->when($start && !$end, function ($query) use ($start) { + $query->where('start_time', '>=', $start); + }) + ->when((!$start && $end), function ($query) use ($end) { + $query->where('start_time', '<=', date('Y-m-d', strtotime("+1 days", strtotime($end)))); + })->where('state',1)->orderBy('id','desc')->paginate($numPerPage); + + $unwinduped = WindupReport::when($seller_id, function ($q) use ($seller_id) {$q->where('seller_id', $seller_id);})->where('state',0) + ->select(DB::raw('SUM(seller_freight_sum + seller_amount_sum) AS sum_total'))->first(); + + $winduped = WindupReport::when($seller_id, function ($q) use ($seller_id) {$q->where('seller_id', $seller_id);})->where('state',1) + ->select(DB::raw('SUM(seller_freight_sum + seller_amount_sum) AS sum_total'))->first(); + + $curr_unwinduped = Order::when($seller_id, function ($q) use ($seller_id) {$q->where('seller_id', $seller_id);}) + ->whereHas('logs', function ($query) { + $query->where('state','DELIVERED|SIGNED'); + }) + ->where('state', '<>',Order::ORDER_CLOSED) + ->where('windup_report_id',0) + ->select(DB::raw('SUM(seller_freight + seller_amount) AS sum_total'))->first(); + return view('Admin::windups.winduped', compact('seller_orders','sellers','unwinduped','winduped','curr_unwinduped')); + + } + + + public function rule() + { + $info = \Params::get('windup_rule'); + $info = str_replace("\r", "
", $info); + return view('Admin::windups.rule', compact('info')); + + } + + public function invoice() + { + $info = \Params::get('invoice_info'); + $info = str_replace("\r", "
", $info); + return view('Admin::windups.invoice', compact('info')); + } + + +} diff --git a/app/Admin/Controllers/WithdrawsController.php b/app/Admin/Controllers/WithdrawsController.php new file mode 100644 index 0000000..66b29bb --- /dev/null +++ b/app/Admin/Controllers/WithdrawsController.php @@ -0,0 +1,73 @@ +state; + if(empty($state)){ + return $this->error('请选择审核结果'); + } + + if($state == 1){ + //提现处理-提现到微信零钱 + if($withdraw->way == 'Wechat'){ + if(empty($withdraw->openid)){ + return $this->error('提现失败,未找到提现用户微信'); + } + $app = app('wechat.payment'); + $result = $app->transfer->toBalance([ + 'partner_trade_no' => 'WTN' . date('ymdHis') . sprintf("%07d", mt_rand(0, pow(10, 7) - 1)), + 'openid' => $withdraw->openid, + 'check_name' => 'NO_CHECK', + 're_user_name' => '', + 'amount' => $withdraw->take * 100, + 'desc' => '余额提现到微信零钱', + ]); + if($result['result_code'] == 'SUCCESS'){ + $withdraw->update(['state' => 1]); + return $this->success('操作成功','close'); + }else{ + return $this->error($result['err_code_des']); + } + + }else{ + if($withdraw->update(['state' => 1])){ + return $this->success('操作成功','close'); + }else{ + return $this->error('操作失败'); + } + } + + } + + if($state == 2) { + //驳回处理 + $remark = $request->remark; + if (empty($remark)) { + return $this->error('请填写驳回原因'); + } + try { + DB::transaction(function () use ($remark,$withdraw){ + $withdraw->user->rule('withdraw_reject', $withdraw->amount, false, 'withdraw'.$withdraw->id); + $withdraw->update(['state' => 2, 'remark' => $remark]); + }); + return $this->success('操作成功','close'); + } catch (\Exception $e) { + return $this->error('操作失败' . $e->getmessage()); + } + } + } +} diff --git a/app/Admin/Views/accounts/index.blade.php b/app/Admin/Views/accounts/index.blade.php new file mode 100644 index 0000000..d1e3555 --- /dev/null +++ b/app/Admin/Views/accounts/index.blade.php @@ -0,0 +1,92 @@ + + +
+ + + + + + + + + + + + + + + + + + @foreach ($accounts as $account) + + + + + + + + + + + + + @endforeach + +
手机号昵称现金账户注册时间
{{ $account->user->mobile }}{{ $account->user->info->nickname }}{{ $account->cash }}{{ $account->created_at }}
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $accounts->total() }} 条 +
+ +
+
+ diff --git a/app/Admin/Views/accounts/logs.blade.php b/app/Admin/Views/accounts/logs.blade.php new file mode 100644 index 0000000..2201489 --- /dev/null +++ b/app/Admin/Views/accounts/logs.blade.php @@ -0,0 +1,102 @@ + + +
+ + + + + + + + + + + + + + + + + + @foreach ($logs as $log) + + + + + + + + + + + + + + @endforeach + +
编号用户手机号用户昵称规则名称账户类型变动数额当期余额冻结备注创建时间更新时间
{{ $log->id }}{{ $log->user->mobile }}{{ $log->user->info->nickname }}{{ $log->rule->title }}{{ $log->type }}{{ $log->variable }}{{ $log->balance }}{{ $log->frozen }}@json($log->source){{ $log->created_at }}{{ $log->updated_at }}
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $logs->total() }} 条 +
+ +
+
+ diff --git a/app/Admin/Views/accounts/rules.blade.php b/app/Admin/Views/accounts/rules.blade.php new file mode 100644 index 0000000..9a7b9a9 --- /dev/null +++ b/app/Admin/Views/accounts/rules.blade.php @@ -0,0 +1,80 @@ + + +
+
+ +
+ + + + + + + + + + + + + + + + + + + @foreach ($rules as $rule) + + + + + + + + + + + + + + @endforeach + +
编号规则名称调用标识账户类型变动数量调用次数直接到帐备注说明创建时间更新时间
{{ $rule->id }}{{ $rule->title }}{{ $rule->name }}{{ $rule->type }}{{ $rule->variable }}{{ $rule->trigger_text }}{{ $rule->deductions }}{{ $rule->remark }}{{ $rule->created_at }}{{ $rule->updated_at }} + {{-- 编辑 --}} + {{-- 删除 --}} +
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $rules->total() }} 条 +
+ +
+
diff --git a/app/Admin/Views/accounts/withdraws.blade.php b/app/Admin/Views/accounts/withdraws.blade.php new file mode 100644 index 0000000..1989aec --- /dev/null +++ b/app/Admin/Views/accounts/withdraws.blade.php @@ -0,0 +1,94 @@ + + +
+ + + + + + + + + + + + + + + + + + + @foreach ($withdraws as $withdraw) + + + + + + + + + + + + + + + @endforeach + +
编号用户手机号用户昵称提现金额手续费实到金额提现方式状态备注创建时间更新时间操作
{{ $withdraw->id }}{{ $withdraw->user->mobile }}{{ $withdraw->user->info->nickname }}{{ $withdraw->amount }}{{ $withdraw->tax }}{{ $withdraw->take }}{{ $withdraw->type_text }}{{ $withdraw->state_text }}{{ $withdraw->remark }}{{ $withdraw->created_at }}{{ $withdraw->updated_at }}@if($withdraw->state == 0)审核@endif
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $withdraws->total() }} 条 +
+ +
+
+ diff --git a/app/Admin/Views/activities/create.blade.php b/app/Admin/Views/activities/create.blade.php new file mode 100644 index 0000000..ea46a91 --- /dev/null +++ b/app/Admin/Views/activities/create.blade.php @@ -0,0 +1,94 @@ +
+
+
+
+ + +
+ +
+
+ + +
+ +
+
+ + +
+ +
+
+ + +
+ +
+
+ + +
+ +
+
+ + +
+ +
+
+ + +
+ +
+
+ + +
+
+
+
+ @ueditor('', 'content',"activity") +
+
+ +
+ +
+ +
+
+
+ @csrf +
+
    +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/activities/edit.blade.php b/app/Admin/Views/activities/edit.blade.php new file mode 100644 index 0000000..6166cf3 --- /dev/null +++ b/app/Admin/Views/activities/edit.blade.php @@ -0,0 +1,101 @@ +
+
+
+
+ + +
+ +
+
+ + +
+ +
+
+ + +
+ +
+
+ + +
+ +
+
+ + +
+ + +
+
+ + +
+ +
+
+ + +
+ +
+
+ + +
+
+
+
+ @ueditor($activity->content, 'content',"activities{{ $activity->id }}") +
+
+ +
+ @if ($activity->storage->path) + + @else + + @endif +
+ +
+
+
+ @csrf +
+
    + @csrf + @method('PUT') +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/activities/giftEdit.blade.php b/app/Admin/Views/activities/giftEdit.blade.php new file mode 100644 index 0000000..0ff7989 --- /dev/null +++ b/app/Admin/Views/activities/giftEdit.blade.php @@ -0,0 +1,32 @@ +
+
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+ @csrf +
+
    + @csrf + @method('PUT') +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/activities/giftsCreate.blade.php b/app/Admin/Views/activities/giftsCreate.blade.php new file mode 100644 index 0000000..1c9af1c --- /dev/null +++ b/app/Admin/Views/activities/giftsCreate.blade.php @@ -0,0 +1,90 @@ +
+
+
+
+ +
+ + + +
+
+ +
+ + +
+
+
+ + +
+
+
+ + +
+
+ @csrf +
+
    +
  • +
  • +
+
+
+
+ diff --git a/app/Admin/Views/activities/giftsEdit.blade.php b/app/Admin/Views/activities/giftsEdit.blade.php new file mode 100644 index 0000000..3e92f5b --- /dev/null +++ b/app/Admin/Views/activities/giftsEdit.blade.php @@ -0,0 +1,99 @@ +
+
+
+
+ +
+ + + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+ @csrf +
+
    + @csrf + @method('PUT') +
  • +
  • +
+
+
+
+ \ No newline at end of file diff --git a/app/Admin/Views/activities/index.blade.php b/app/Admin/Views/activities/index.blade.php new file mode 100644 index 0000000..01e888e --- /dev/null +++ b/app/Admin/Views/activities/index.blade.php @@ -0,0 +1,87 @@ + + +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + @foreach ($activities as $activity) + + + + + + + + + + + + + + + + @endforeach + +
编号活动标题所属商家所属地域所属分类状态原价现价开始时间结束时间创建时间
{{ $activity->id }}{{ $activity->title }}{{ $activity->seller->name }}{{ $activity->seller->Area->info??'' }}{{ $activity->category->title }}{!! $activity->status_text !!}{{ $activity->original }}{{ $activity->price }}{{ $activity->start_time }}{{ $activity->end_time }}{{ $activity->created_at }} + 编辑 + 删除 + +
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $activities->total() }} 条 +
+ +
+
diff --git a/app/Admin/Views/activities/show.blade.php b/app/Admin/Views/activities/show.blade.php new file mode 100644 index 0000000..fa9c4da --- /dev/null +++ b/app/Admin/Views/activities/show.blade.php @@ -0,0 +1,54 @@ +
+
+ +
+ + + + + + + + + + + + + + @foreach ($gifts as $gift) + + + + + + + + + @endforeach + +
编号奖品任务指标领取消耗创建时间
{{ $gift->id }}{{ $gift->goods->title ?? ''}}-{{ $gift->param->value ?? ''}}{{ $gift->mode}}{{ $gift->consume_mode}}{{ $gift->created_at }} + 编辑 + 删除 +
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $gifts->total() }} 条 +
+ +
+
diff --git a/app/Admin/Views/adverts/create.blade.php b/app/Admin/Views/adverts/create.blade.php new file mode 100644 index 0000000..32d9b29 --- /dev/null +++ b/app/Admin/Views/adverts/create.blade.php @@ -0,0 +1,45 @@ +
+
+
+
+ + +
+
+
+ + +
+
+ +
+
+ +
+ +
+ +
+
+ @csrf +
+
    +
  • +
  • +
+
+ +
diff --git a/app/Admin/Views/adverts/edit.blade.php b/app/Admin/Views/adverts/edit.blade.php new file mode 100644 index 0000000..3d125e5 --- /dev/null +++ b/app/Admin/Views/adverts/edit.blade.php @@ -0,0 +1,53 @@ +
+
+
+
+ + +
+
+ +
+ + +
+
+ + +
+ +
+ @if ($advert->storage) + + @else + + @endif +
+ +
+
+ +
+@method('PUT') +@csrf +
+
    +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/adverts/index.blade.php b/app/Admin/Views/adverts/index.blade.php new file mode 100644 index 0000000..8170f76 --- /dev/null +++ b/app/Admin/Views/adverts/index.blade.php @@ -0,0 +1,68 @@ + + +
+
+ +
+ + + + + + + + + + + + + @foreach ($adverts as $advert) + + + + + + + + @endforeach + +
链接地址排序创建时间更新时间
{{ $advert->url }}{{ $advert->sort }}{{ $advert->created_at }}{{ $advert->updated_at }} + 编辑 + 删除 +
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $adverts->total() }} 条 +
+ +
+
diff --git a/app/Admin/Views/agency/create.blade.php b/app/Admin/Views/agency/create.blade.php new file mode 100644 index 0000000..061a01b --- /dev/null +++ b/app/Admin/Views/agency/create.blade.php @@ -0,0 +1,38 @@ +
+
+
+
+ + +
+ + +
+
+ + +
+ +
+
+ + +
+
+ @csrf +
+
    +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/agency/edit.blade.php b/app/Admin/Views/agency/edit.blade.php new file mode 100644 index 0000000..a3ffc44 --- /dev/null +++ b/app/Admin/Views/agency/edit.blade.php @@ -0,0 +1,40 @@ +
+
+
+
+ + +
+ + +
+
+ + +
+ +
+
+ + +
+ +
+ @csrf + @method('PUT') +
+
    +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/agency/index.blade.php b/app/Admin/Views/agency/index.blade.php new file mode 100644 index 0000000..13e4191 --- /dev/null +++ b/app/Admin/Views/agency/index.blade.php @@ -0,0 +1,61 @@ + + +
+
+ +
+ + + + + + + + + + + + + + + @foreach ($lists as $agency) + + + + + + + + + + @endforeach + +
编号标题状态管理人业务员创建时间
{{ $agency->id }}{{ $agency->name }}{!! $agency->status_text !!}{{ $agency->user->info->nickname }}{{ $agency->salesman->info->nickname }}{{ $agency->created_at }} + 编辑 + 绑定管理 +
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $lists->total() }} 条 +
+ +
+
diff --git a/app/Admin/Views/agency/user.blade.php b/app/Admin/Views/agency/user.blade.php new file mode 100644 index 0000000..e241af1 --- /dev/null +++ b/app/Admin/Views/agency/user.blade.php @@ -0,0 +1,40 @@ +
+
+
+
+ + +
+ + +
+
+ + + + +
+
+ @csrf +
+
    +
  • +
  • +
+
+
+
+ + diff --git a/app/Admin/Views/areas/create.blade.php b/app/Admin/Views/areas/create.blade.php new file mode 100644 index 0000000..27d4568 --- /dev/null +++ b/app/Admin/Views/areas/create.blade.php @@ -0,0 +1,38 @@ +
+
+
+ +
+ + +
+ +
+
+ + +
+ +
+
+ + +
+
+
+ @csrf +
+
    +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/areas/edit.blade.php b/app/Admin/Views/areas/edit.blade.php new file mode 100644 index 0000000..edbc2ee --- /dev/null +++ b/app/Admin/Views/areas/edit.blade.php @@ -0,0 +1,38 @@ +
+
+
+
+ + +
+ +
+
+ + +
+ +
+
+ + +
+
+
+ @csrf + @method('PUT') +
+
    +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/areas/index.blade.php b/app/Admin/Views/areas/index.blade.php new file mode 100644 index 0000000..baa990b --- /dev/null +++ b/app/Admin/Views/areas/index.blade.php @@ -0,0 +1,114 @@ + + +
+
+ +
+ + + + + + + + + + + + + + + + + @foreach ($areas as $area) + + + + + + + + + + + + @endforeach + +
省份名称市名称区名称类型状态热门更新时间
{{ $area->province }} {{ $area->city }} {{ $area->area }}{{ $area->type }}{{ $area->status_text }}{!! $area->hot_text !!}{{ $area->updated_at }} + @if($area->status!=1) + 开通 + @else + 关闭区域 + @endif + + @if($area->depth==2) + @if($area->hot==1) + 取消热门 + @else + 开通热门 + @endif + @endif + + @if($area->depth>2) + 编辑 + @endif +
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $areas->total() }} 条 +
+ +
+
diff --git a/app/Admin/Views/articles/create.blade.php b/app/Admin/Views/articles/create.blade.php new file mode 100644 index 0000000..4063695 --- /dev/null +++ b/app/Admin/Views/articles/create.blade.php @@ -0,0 +1,52 @@ +
+
+
+ + + +
+ + +
+
+
+ + +
+ +
+
+
+ @ueditor('', 'content',"{{ Request::input('type') }}") +
+
+ +
+ +
+ +
+
+
+ @csrf +
+
    +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/articles/edit.blade.php b/app/Admin/Views/articles/edit.blade.php new file mode 100644 index 0000000..5e2dbf0 --- /dev/null +++ b/app/Admin/Views/articles/edit.blade.php @@ -0,0 +1,55 @@ +
+
+
+
+ + +
+
+
+ + +
+ +
+
+
+ @ueditor($article->content, 'content',"articles{{ $article->id }}") +
+
+ +
+ @if ($article->storage->path) + + @else + + @endif +
+ +
+
+
+ @csrf +
+
    + @csrf + @method('PUT') +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/articles/index.blade.php b/app/Admin/Views/articles/index.blade.php new file mode 100644 index 0000000..4cea71a --- /dev/null +++ b/app/Admin/Views/articles/index.blade.php @@ -0,0 +1,66 @@ + + +
+
+ +
+ + + + + + + + + + + + @foreach ($articles as $article) + + + + + + + @endforeach + +
编号文章标题创建时间
{{ $article->id }}{{ $article->title }}{{ $article->created_at }} + 编辑 + 删除 +
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $articles->total() }} 条 +
+ +
+
diff --git a/app/Admin/Views/categories/create.blade.php b/app/Admin/Views/categories/create.blade.php new file mode 100644 index 0000000..e339e4b --- /dev/null +++ b/app/Admin/Views/categories/create.blade.php @@ -0,0 +1,63 @@ +
+
+
+
+ + +
+
+
+ + +
+
+
+ + +
+ + +
+
+ +
+ +
+ +
+
+ @csrf +
+
    +
  • +
  • +
+
+ +
diff --git a/app/Admin/Views/categories/edit.blade.php b/app/Admin/Views/categories/edit.blade.php new file mode 100644 index 0000000..cf16bc2 --- /dev/null +++ b/app/Admin/Views/categories/edit.blade.php @@ -0,0 +1,70 @@ +
+
+
+
+ + +
+
+
+ + +
+
+
+ + +
+ + +
+
+ +
+ @if ($category->storage->path) + + @else + + @endif +
+ +
+
+ +
+ @csrf + @method('PUT') +
+
    +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/categories/index.blade.php b/app/Admin/Views/categories/index.blade.php new file mode 100644 index 0000000..8bd7872 --- /dev/null +++ b/app/Admin/Views/categories/index.blade.php @@ -0,0 +1,110 @@ +
+
+ +
    + @foreach($categoryTree as $category) +
  • {{ $category->title }} + @if ($category->children->count()) +
      + @foreach($category->children as $child) +
    • {{ $child->title }} + @if ($child->children->count()) + + @endif +
    • + @endforeach +
    + @endif +
  • + @endforeach +
+
+
+ +
+ +
+ + + + + + + + + + + + + + + + @foreach ($categories as $category) + + + + + + + + + + + + @endforeach + +
ID分类名称排序是否推荐推荐排序创建时间更新时间
{{ $category->id }}{{ $category->title }}{{ $category->sort }}{{ $category->is_recommend == 1 ? '是' : '否' }}{{ $category->recommend_sort }}{{ $category->description }}{{ $category->created_at }}{{ $category->updated_at }} + 编辑 + 删除 +
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $categories->total() }} 条 +
+ +
+ +
+
diff --git a/app/Admin/Views/common/tree.blade.php b/app/Admin/Views/common/tree.blade.php new file mode 100644 index 0000000..b55488d --- /dev/null +++ b/app/Admin/Views/common/tree.blade.php @@ -0,0 +1,11 @@ +@foreach ($children as $item) +
    +
  • + {{ $item['text'] }} + @isset($item['children']) + @component('Admin::tree', ['children' => $item['children']]) + @endcomponent + @endisset +
  • +
+@endforeach diff --git a/app/Admin/Views/coupon/all.blade.php b/app/Admin/Views/coupon/all.blade.php new file mode 100644 index 0000000..640f623 --- /dev/null +++ b/app/Admin/Views/coupon/all.blade.php @@ -0,0 +1,174 @@ + + +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + @php + $goodids = array(); + @endphp + @foreach ($goods as $good) + + @foreach($good->params()->where('status',1)->get() as $params) + + + @if(!in_array($good->id, $goodids)) + + + + + @else + + + + + + @endif + + + + @if(!in_array($good->id, $goodids)) + + + + + + + + + + @else + + + + + + + + @endif + + @php + array_push($goodids,$good->id); + @endphp + @endforeach + + @endforeach + + + +
编号商品类型商品名称商户名称规格售价成本价会员赠品满仓赠品平台推荐位排序状态创建时间
{{ $good->id }}{{ $good->category->title }}{{ $good->title }}{{ $good->seller->name }}{{ $params->value }} + + @if($params->score == 0){{ number_format($params->price,2) }}元 + @else + @if($params->price - $params->score > 0){{ number_format($params->price - $params->score,2) }}元 + @endif + {{ number_format($params->score,2) }}积分 + @endif + {{ number_format($params->cost,2) }}元 + @if($good->is_seller_gift == 0 && $good->status == 1)设为赠品@endif + @if($good->is_seller_gift == 1 && $good->status == 1)赠品   取消@endif + @if($good->is_mall_gift == 0 && $good->status == 1)设为满仓赠@endif + @if($good->is_mall_gift == 1 && $good->status == 1)满仓   取消@endif + @if($good->is_recommend == 1) 1.全积分购 @endif + @if($good->is_hot_sell == 1) 2.全现金购 @endif + @if($good->is_hot_changed == 1) 3.积分现金购 @endif + @if($good->is_seller_package == 1) 4.首页99套餐 @endif + {{ $good->sort }}{!! $good->status_text !!}{{ $good->created_at }} + @if($good->status == 1)编辑@endif + + {{--@if($good->status == 1)编辑@endif--}} + @if($good->canDel())删除@endif + @if($good->canCancel())下架@endif + 推荐到首页 + @if($good->status == 0)上架@endif + @if($good->is_seller_gift == 1 && $good->status == 1)取消赠品 @endif +
+

+ 注:1》删除商品- 未产生订单的商品可删除,删除操作不可逆。2》下架商品- 已产生订单的商品不可删除,只能下架,下架后不会再产生新订单,下架操作可通过上架操作恢复商品。 +

+
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $goods->total() }} 条 +
+ +
+
+ diff --git a/app/Admin/Views/coupon/create.blade.php b/app/Admin/Views/coupon/create.blade.php new file mode 100644 index 0000000..14a191b --- /dev/null +++ b/app/Admin/Views/coupon/create.blade.php @@ -0,0 +1,65 @@ +
+
+
+
+ + +
+ +
+
+ + +
+ +
+
+ + +
+ + +
+ + +
+
+
+ + +
+
+ + +
+
+
+ + +
+ +
+ @csrf + +
+
    +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/coupon/edit.blade.php b/app/Admin/Views/coupon/edit.blade.php new file mode 100644 index 0000000..0e4d616 --- /dev/null +++ b/app/Admin/Views/coupon/edit.blade.php @@ -0,0 +1,68 @@ +
+
+
+
+ + +
+ + + +
+
+ + +
+ +
+
+ + +
+ +
+
+ + +
+
+
+ + +
+
+
+ + +
+
+ + +
+ +
+
+ + +
+
+ @csrf + @method('PUT') +
+
    +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/coupon/index.blade.php b/app/Admin/Views/coupon/index.blade.php new file mode 100644 index 0000000..c8a4dec --- /dev/null +++ b/app/Admin/Views/coupon/index.blade.php @@ -0,0 +1,84 @@ + + +
+
+ +
+ + + + + + + + + + + + + + + + + @foreach ($coupons as $coupon) + + + + + + + + + + + + @endforeach + +
编号券码名称线上有效起始有效结束状态用途创建时间
{{ $coupon->id }}{{ $coupon->title }} + @if($coupon->online == 1) + 是 + @else + 否 + @endif + {{ $coupon->start_at }}{{ $coupon->end_at }}{!! $coupon->status_text !!}{!! $coupon->type_text !!}{{ $coupon->created_at }} + 编辑 + @if($coupon->canCancel()) + 下架 + @endif +
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $coupons->total() }} 条 +
+ +
+
diff --git a/app/Admin/Views/goods/all.blade.php b/app/Admin/Views/goods/all.blade.php new file mode 100644 index 0000000..7c52fed --- /dev/null +++ b/app/Admin/Views/goods/all.blade.php @@ -0,0 +1,182 @@ + + +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + @php + $goodids = array(); + @endphp + @foreach ($goods as $good) + + @foreach($good->params()->where('status',1)->get() as $params) + + + @if(!in_array($good->id, $goodids)) + + + + + @else + + + + + + @endif + + + + @if(!in_array($good->id, $goodids)) + + + + + + + + + + @else + + + + + + + + @endif + + @php + array_push($goodids,$good->id); + @endphp + @endforeach + + @endforeach + + + +
编号商品类型商品名称商户名称规格售价成本价会员赠品满仓赠品平台推荐位排序状态创建时间
{{ $good->id }}{{ $good->category->title }}{{ $good->title }}{{ $good->seller->name }}{{ $params->value }} + + @if($params->score == 0){{ number_format($params->price,2) }}元 + @else + @if($params->price - $params->score > 0){{ number_format($params->price - $params->score,2) }}元 + @endif + {{ number_format($params->score,2) }}积分 + @endif + {{ number_format($params->cost,2) }}元 + @if($good->is_seller_gift == 0 && $good->status == 1)设为赠品@endif + @if($good->is_seller_gift == 1 && $good->status == 1)赠品   取消@endif + @if($good->is_mall_gift == 0 && $good->status == 1)设为满仓赠@endif + @if($good->is_mall_gift == 1 && $good->status == 1)满仓   取消@endif + @if($good->is_recommend == 1) 1.全积分购 @endif + @if($good->is_hot_sell == 1) 2.全现金购 @endif + @if($good->is_hot_changed == 1) 3.积分现金购 @endif + @if($good->is_seller_package == 1) 4.首页99套餐 @endif + {{ $good->sort }}{!! $good->status_text !!}{{ $good->created_at }} + @if($good->status == 1)编辑@endif + + {{--@if($good->status == 1)编辑@endif--}} + @if($good->canDel())删除@endif + @if($good->canCancel())下架@endif + 推荐到首页 + @if($good->status == 0)上架@endif + @if($good->is_seller_gift == 1 && $good->status == 1)取消赠品 @endif +
+

+ 注:1》删除商品- 未产生订单的商品可删除,删除操作不可逆。2》下架商品- 已产生订单的商品不可删除,只能下架,下架后不会再产生新订单,下架操作可通过上架操作恢复商品。 +

+
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $goods->total() }} 条 +
+ +
+
+ diff --git a/app/Admin/Views/goods/create.blade.php b/app/Admin/Views/goods/create.blade.php new file mode 100644 index 0000000..2037777 --- /dev/null +++ b/app/Admin/Views/goods/create.blade.php @@ -0,0 +1,109 @@ +
+
+
+ + @if(Admin::id() == 1) +
+ + +
+ @endif + +
+
+ + +
+ +
+
+ + +
+ +
+
+ + +
+ + +
+
+
+ @ueditor('', 'content','goods') +
+
+ +
+ +
+ +
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
规格名称原价售价库存单品重量(kg)包邮(0:不包邮;1:包邮)操作
删除
+
+ +
+
+
+
+
+
+ @csrf +
+
    +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/goods/create.blade.php## b/app/Admin/Views/goods/create.blade.php## new file mode 100644 index 0000000..0adf80d --- /dev/null +++ b/app/Admin/Views/goods/create.blade.php## @@ -0,0 +1,64 @@ +
+
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + + + +
+
+
+
+ @ueditor('', 'content') +
+
+ +
+ +
+ +
+
+
+ @csrf +
+
    +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/goods/edit.blade.php b/app/Admin/Views/goods/edit.blade.php new file mode 100644 index 0000000..d861958 --- /dev/null +++ b/app/Admin/Views/goods/edit.blade.php @@ -0,0 +1,117 @@ +
+
+
+ @if(Admin::id() == 1) +
+ + +
+ @endif + +
+
+ + +
+ +
+
+ + +
+ +
+
+ + +
+ + +
+
+
+ @ueditor($good->content, 'content',"goods{{ $good->id }}") +
+
+ +
+ @if ($good->storage->path) + + @else + + @endif +
+ +
+
+
+ +
+
+ + + + + + + + + + + + + + @foreach($good->params()->where('status',1)->get() as $key => $params) + + + + + + + + + + + @endforeach + +
规格名称原价售价库存单品重量(kg)包邮(0:不包邮;1:包邮)操作
删除
+
+ +
+
+
+
+
+
+ @csrf +
+
    + @csrf + @method('PUT') +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/goods/giftseltting.blade.php b/app/Admin/Views/goods/giftseltting.blade.php new file mode 100644 index 0000000..1dfcd58 --- /dev/null +++ b/app/Admin/Views/goods/giftseltting.blade.php @@ -0,0 +1,33 @@ +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ @csrf +
+
    + @csrf + @method('PUT') +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/goods/index.blade.php b/app/Admin/Views/goods/index.blade.php new file mode 100644 index 0000000..74253c2 --- /dev/null +++ b/app/Admin/Views/goods/index.blade.php @@ -0,0 +1,130 @@ + + +
+
+ +
+ + + + + + + + + + + + + + + + + + + + @php + $goodids = array(); + @endphp + @foreach ($goods as $good) + + @foreach($good->params()->where('status',1)->get() as $params) + + + @if(!in_array($good->id, $goodids)) + + + + + @else + + + + + @endif + + + + @if(!in_array($good->id, $goodids)) + + + + + + + @else + + + + + @endif + + @php + array_push($goodids,$good->id); + @endphp + @endforeach + + @endforeach + + + +
编号商品类型商品名称商户名称规格售价成本价赠品设置奖品设置状态创建时间
{{ $good->id }}{{ $good->category->title }}{{ $good->title }}{{ $good->seller->name }}{{ $params->value }} + {{ number_format($params->price,2) }}元 + {{ number_format($params->cost,2) }}元 + + @if($good->is_seller_gift == 0 && $good->status == 1) + 设为赠品 + @endif + @if($good->is_seller_gift == 1 && $good->status == 1) + 赠品 +   取消 + @endif + + @if($good->is_lottery_gift == 0 && $good->status == 1)设为奖品@endif + @if($good->is_lottery_gift == 1 && $good->status == 1)奖品   取消@endif + {!! $good->status_text !!}{{ $good->created_at }} + @if($good->status == 1)编辑@endif + @if($good->canDel())删除@endif + @if($good->canCancel())下架@endif + @if($good->is_seller_gift == 1 && $good->status == 1)取消赠品 @endif +
+

+ 注:1》删除商品- 未产生订单的商品可删除,删除操作不可逆。2》下架商品- 已产生订单的商品不可删除,只能下架,下架后不会再产生新订单,下架操作可通过上架操作恢复商品。 +

+
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $goods->total() }} 条 +
+ +
+
diff --git a/app/Admin/Views/goods/magageedit.blade.php b/app/Admin/Views/goods/magageedit.blade.php new file mode 100644 index 0000000..4cfe448 --- /dev/null +++ b/app/Admin/Views/goods/magageedit.blade.php @@ -0,0 +1,115 @@ +
+
+
+
+ + +
+
+
+ + +
+
+
+ + +
+ +
+
+
+ @ueditor($good->content, 'content',"goods{{ $good->id }}") +
+
+ +
+ @if ($good->storage->path) + + @else + + @endif +
+ +
+
+

商品规格

+
+ +
+
+ + + + + + @if(Amind::user()->id==1) + + + @endif + + + + + + + + + + + @foreach($good->params()->where('status',1)->get() as $key => $params) + + + + + @if(Amind::user()->id==1) + + + @endif + + + + + + + + + @endforeach + +
规格名称成本复消分润总裁分红原价某宝售价可抵扣积分库存单品重量(kg)操作
删除
+
+ +
+
+
+
+
+
+ @csrf +
+
    + @csrf + @method('PUT') +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/goods/putOn.blade.php b/app/Admin/Views/goods/putOn.blade.php new file mode 100644 index 0000000..7e6e26c --- /dev/null +++ b/app/Admin/Views/goods/putOn.blade.php @@ -0,0 +1,106 @@ +
+
+
+
+ + +
+
+
+ + +
+
+
+ + +
+ +
+
+
+ @ueditor($good->content, 'content',"goods{{ $good->id }}") +
+
+ +
+ @if ($good->storage->path) + + @else + + @endif +
+ +
+
+

商品规格

+
+ +
+
+ + + + + + + + + + + + + + + @foreach($good->params()->get() as $key => $params) + + + + + + + + + + + + + @endforeach + +
规格名称成本原价售价可抵扣积分库存单品重量(kg)操作
删除
+
+ +
+
+
+
+
+
+ @csrf +
+
    + @csrf + @method('PUT') +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/goods/recycle.blade.php b/app/Admin/Views/goods/recycle.blade.php new file mode 100644 index 0000000..24b5ab0 --- /dev/null +++ b/app/Admin/Views/goods/recycle.blade.php @@ -0,0 +1,74 @@ + + +
+
+ +
+ + + + + + + + + + + + + + + + @foreach ($goods as $good) + + + + + + + + + + + @endforeach + +
编号商品名称商户名称单价库存销量创建时间
{{ $good->id }}{{ $good->title }}{{ $good->seller->name }}{{ $good->price }}{{ $good->stock }}{{ $good->sales }}{{ $good->created_at }} + 还原 + 彻底删除 +
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $goods->total() }} 条 +
+ +
+
diff --git a/app/Admin/Views/goods/setting.blade.php b/app/Admin/Views/goods/setting.blade.php new file mode 100644 index 0000000..fc8c295 --- /dev/null +++ b/app/Admin/Views/goods/setting.blade.php @@ -0,0 +1,90 @@ +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ + +
+ + + 数字越大,手机端越靠前显示 +
+
+ @csrf +
+
    + @csrf + @method('PUT') +
  • +
  • +
+
+
+
+ \ No newline at end of file diff --git a/app/Admin/Views/home/dashboard.blade.php b/app/Admin/Views/home/dashboard.blade.php new file mode 100644 index 0000000..a6575d9 --- /dev/null +++ b/app/Admin/Views/home/dashboard.blade.php @@ -0,0 +1,91 @@ +@extends('RuLong::layouts.app') + +@section('content') +

Dashboard

+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
参数名称参数值
PHP 版本PHP/{{ phpversion() }}
Laravel 版本{{ app()->version() }}
CGI 模式{{ php_sapi_name() }}
Web Server{{ array_get($_SERVER, 'SERVER_SOFTWARE') }}
Cache Driver{{ config('cache.default') }}
Session Driver{{ config('session.driver') }}
Queue Driver{{ config('queue.driver') }}
Timezone{{ config('app.timezone') }}
Locale{{ config('app.locale') }}
+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
参数名称参数值
Panel版本
模板库地址模板库
Laravel文档Laravel文档
PHP设计模式PHP设计模式
+
+
+
+
+@endsection diff --git a/app/Admin/Views/lesson/create.blade.php b/app/Admin/Views/lesson/create.blade.php new file mode 100644 index 0000000..4f8ee3d --- /dev/null +++ b/app/Admin/Views/lesson/create.blade.php @@ -0,0 +1,132 @@ +
+
+
+
+ + +
+ +
+
+ + +
+ +
+
+ + +
+ +
+
+ + +
+ +
+
+ + +
+ +
+
+ + +
+ +
+
+ + +
+ + +
+
+ + +
+ +
+
+ + +
+ +
+
+ + +
+ +
+
+ + + 选择 +
+ +
+
+ + + 选择 +
+ + +
+
+ + +
+ +
+
+
+ @ueditor('', 'content') +
+
+ +
+ +
+ +
+
+
+ @csrf +
+
    +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/lesson/edit.blade.php b/app/Admin/Views/lesson/edit.blade.php new file mode 100644 index 0000000..faf9853 --- /dev/null +++ b/app/Admin/Views/lesson/edit.blade.php @@ -0,0 +1,136 @@ +
+
+
+
+ + +
+ +
+
+ + +
+ +
+
+ + +
+ +
+
+ + +
+ +
+
+ + +
+ +
+
+ + +
+ +
+
+ + +
+ +
+
+ + +
+ +
+
+ + +
+ +
+
+ + +
+ +
+
+ + + 选择 +
+ +
+
+ + + 选择 +
+ + +
+
+ + +
+ +
+
+
+ @ueditor($lesson->content, 'content') +
+
+ +
+ @if ($lesson->storage->path) + + @else + + @endif +
+ +
+
+
+ @csrf + @method('PUT') +
+
    +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/lesson/index.blade.php b/app/Admin/Views/lesson/index.blade.php new file mode 100644 index 0000000..87710f0 --- /dev/null +++ b/app/Admin/Views/lesson/index.blade.php @@ -0,0 +1,99 @@ + + +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + @foreach ($lists as $lesson) + + + + + + + + + + + + + + + + + + + + @endforeach + +
课程编号课程名称所属机构所属地域分类章节数价格状态库存报名人数适合基础适合年龄上课人数开始时间结束时间创建时间
{{ $lesson->id }}{{ $lesson->title }}{{ $lesson->organ->name }}{{ $lesson->organ->Area->info??'' }}{{ $lesson->category->title }}{{ $lesson->chapter }}{{ $lesson->price }}{!! $lesson->status_text !!}{{ $lesson->stock }} {{ $lesson->logs()->where('status',1)->count() }}{{ $lesson->crowd }}{{ $lesson->crowd_age }}{{ $lesson->maximum }}{{ $lesson->start_at }}{{ $lesson->end_at }}{{ $lesson->created_at }} + 编辑 + 删除 +
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $lists->total() }} 条 +
+ +
+
diff --git a/app/Admin/Views/lesson/logs.blade.php b/app/Admin/Views/lesson/logs.blade.php new file mode 100644 index 0000000..4d20590 --- /dev/null +++ b/app/Admin/Views/lesson/logs.blade.php @@ -0,0 +1,48 @@ +
+ + + + + + + + + + + + + @foreach ($logs as $log) + + + + + + + + + @endforeach + +
用户宝宝姓名宝宝年龄手机号课程报名时间
{{ $log->user->info->nickname }}{{ $log->name }}{{ $log->age }}{{ $log->mobile }}{{ $log->lesson->title }}{{ $log->created_at }}
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $logs->total() }} 条 +
+ +
+
+ diff --git a/app/Admin/Views/lottery/addgifts.blade.php b/app/Admin/Views/lottery/addgifts.blade.php new file mode 100644 index 0000000..b2751ed --- /dev/null +++ b/app/Admin/Views/lottery/addgifts.blade.php @@ -0,0 +1,62 @@ +
+
+
+ +
+ + +
+ +
+
+ + +
+ +
+
+ + +
+ +
+
+ + + 数字如:4 +
+ +
+
+ + + 谢谢参与不减少这个数据 +
+ +
+ @csrf + + +
+
    +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/lottery/create.blade.php b/app/Admin/Views/lottery/create.blade.php new file mode 100644 index 0000000..36d9e2d --- /dev/null +++ b/app/Admin/Views/lottery/create.blade.php @@ -0,0 +1,43 @@ +
+
+
+
+ + +
+ + +
+
+ + +
+ + +
+
+ + + 选择 +
+ +
+
+ + + 选择 +
+ +
+ @csrf +
+
    +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/lottery/edit.blade.php b/app/Admin/Views/lottery/edit.blade.php new file mode 100644 index 0000000..9bbd029 --- /dev/null +++ b/app/Admin/Views/lottery/edit.blade.php @@ -0,0 +1,44 @@ +
+
+
+
+ + +
+ + +
+
+ + +
+ + +
+
+ + + 选择 +
+ +
+
+ + + 选择 +
+ +
+ @csrf + @method('PUT') +
+
    +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/lottery/editgifts.blade.php b/app/Admin/Views/lottery/editgifts.blade.php new file mode 100644 index 0000000..1f40cbe --- /dev/null +++ b/app/Admin/Views/lottery/editgifts.blade.php @@ -0,0 +1,58 @@ +
+
+
+ +
+ + +
+ +
+
+ + +
+ + + + +
+
+ + + 数字如:4 +
+ +
+
+ + + 谢谢参与不减少这个数据 +
+
+ @csrf + @method('PUT') + +
+
    +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/lottery/gifts.blade.php b/app/Admin/Views/lottery/gifts.blade.php new file mode 100644 index 0000000..3112d65 --- /dev/null +++ b/app/Admin/Views/lottery/gifts.blade.php @@ -0,0 +1,76 @@ + + +
+ + + + + + + + + + + + + + + + + + @foreach ($lists as $gift) + + + + + + + + + + + @endforeach + +
编号奖品奖项概率类型所属数量创建时间
{{ $gift->id }}{{ $gift->getTitle() }}{{ $gift->level_text }}{{ $gift->chance }}({{ $gift->chance_text }}%){{ $gift->type_text }}{{ $gift->class }}{{ $gift->number }}{{ $gift->created_at }} + 编辑 + 删除 +
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $lists->total() }} 条 +
+ +
+
diff --git a/app/Admin/Views/lottery/index.blade.php b/app/Admin/Views/lottery/index.blade.php new file mode 100644 index 0000000..d0f3d69 --- /dev/null +++ b/app/Admin/Views/lottery/index.blade.php @@ -0,0 +1,62 @@ + + +
+
+
    + +
+
+ + + + + + + + + + + + + + + @foreach ($lists as $lottery) + + + + + + + + + + @endforeach + +
编号标题状态开始时间结束时间创建时间
{{ $lottery->id }}{{ $lottery->title }}{{ $lottery->status_text }}{{ $lottery->start_at }}{{ $lottery->end_at }}{{ $lottery->created_at }} + 编辑 + 记录 + 奖品管理 +
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $lists->total() }} 条 +
+ +
+
diff --git a/app/Admin/Views/lottery/logs.blade.php b/app/Admin/Views/lottery/logs.blade.php new file mode 100644 index 0000000..3a138b5 --- /dev/null +++ b/app/Admin/Views/lottery/logs.blade.php @@ -0,0 +1,49 @@ + + +
+ + + + + + + + + + + + + @foreach ($logs as $log) + + + + + + + + @endforeach + +
编号活动名称用户奖品抽奖时间
{{ $log->id }}{{ $log->lottery->title }}{{ $log->user->info->nickname }}{{ $log->gift->item->getTitle() }}{{ $log->created_at }}
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $logs->total() }} 条 +
+ +
+
diff --git a/app/Admin/Views/notifications/index.blade.php b/app/Admin/Views/notifications/index.blade.php new file mode 100644 index 0000000..1577b2c --- /dev/null +++ b/app/Admin/Views/notifications/index.blade.php @@ -0,0 +1,76 @@ + + +
+
+ +
+ + + + + + + + + + + + + + + @foreach ($notifications as $notification) + + + + + + + + + + @endforeach + +
通知用户通知类型交付数据阅读时间发送时间
{{ $notification->notifiable->info->nickname }}{{ $notification->type::title() }}@json($notification->data){{ $notification->read_at }}{{ $notification->created_at }} + 删除 +
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $notifications->total() }} 条 +
+ +
+
diff --git a/app/Admin/Views/orderData/index.blade.php b/app/Admin/Views/orderData/index.blade.php new file mode 100644 index 0000000..48bc22a --- /dev/null +++ b/app/Admin/Views/orderData/index.blade.php @@ -0,0 +1,89 @@ + + +
+ + + + + + + + + + + + + @foreach ($details as $detail) + + + + + + + + + @endforeach + +
已发货商品信息已发货商品总数支付现金总额消耗积分总额结算成本总额操作
{{ \App\Models\GoodsParams::find($detail->item_id)->getTitle() }}{{ $detail->number_sum }}{{ $detail->price_sum }}{{ $detail->score_sum }}{{ $detail->seller_price_sum }} + + 订单明细 + +
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $details->total() }} 条 +
+ +
+
+ diff --git a/app/Admin/Views/orderData/order.blade.php b/app/Admin/Views/orderData/order.blade.php new file mode 100644 index 0000000..bb65add --- /dev/null +++ b/app/Admin/Views/orderData/order.blade.php @@ -0,0 +1,191 @@ + + +
+ + + + + + + + + + + + + + + + + + + @if($type == 'DELIVERED|SIGNED') + + + @endif + @if($type == 'PAID|DELIVERED') + + + @endif + + + + @php + $orderids = array(); + @endphp + @foreach ($orders as $order) + @foreach($order->details as $detail) + + @if(!in_array($order->id, $orderids)) + + @else + @endif + + + + + @if(!in_array($order->id, $orderids)) + + + + + + + + + + + + @if($type == 'DELIVERED|SIGNED') + + + @endif + @if($type == 'PAID|DELIVERED') + + + @endif + @else + + @endif + + + @php + array_push($orderids,$order->id); + @endphp + @endforeach + @endforeach + + + + + + + + + + +
订单编号商品信息商品数量商品总额商品积分订单金额订单运费积分抵扣总计支付总成本结算运费商家结算配送收件地址状态发货时间签收时间支付时间发货时间
@switch($order->item_type) + @case('GOODS') + 商品 + @break + @case('FULL_GIFT') + 满仓 + @break + @case('ACTIVITY_GIFT') + 活动 + @break + @case('VIP_GIFT') + 赠品 + @break + @endswitch{{ $order->orderid }} + {{$detail->item->getTitle() }} + {{$detail->number }} + {{$detail->price * $detail->number - $detail->score * $detail->number }} + {{$detail->score * $detail->number }} + {{ number_format($order->amount,2) }}{{ number_format($order->freight, 2)}}{{ number_format($order->score, 2) }}{{ number_format($order->total - $order->score, 2) }}{{ number_format($order->seller_amount, 2) }}{{ number_format($order->seller_freight, 2) }}{{ number_format($order->seller_freight + $order->seller_amount, 2) }}{!! $order->express_type == 1 ? '快递' : '自提' !!}{{ $order->express->name ?? $order->user->info->nickname }} {{ $order->express->mobile ?? $order->user->mobile }} {{ $order->express->address ?? '' }}{{ $order->state_text }}{{ $order->logs()->where('state','PAID|DELIVERED')->first()->created_at }}{{ $order->logs()->where('state','DELIVERED|SIGNED')->first()->created_at }}{{ $order->paid_at }}{{ $order->logs()->where('state','PAID|DELIVERED')->first()->created_at }}
+ {{ $orders->count() }}单 + + + + {{ number_format($orders->sum('seller_amount'),2) }}元 + + {{ number_format($orders->sum('seller_freight'),2) }}元 + + {{ number_format($orders->sum('seller_freight') + $orders->sum('seller_amount'),2) }}元 + +
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $orders->total() }} 条 +
+ +
+
+ diff --git a/app/Admin/Views/orderData/report.blade.php b/app/Admin/Views/orderData/report.blade.php new file mode 100644 index 0000000..a7146de --- /dev/null +++ b/app/Admin/Views/orderData/report.blade.php @@ -0,0 +1,127 @@ + + +
+ + + + + + + + + + + + + + + + + + + + @foreach ($reports as $report) + + + + + + + + + + + + + + + + + @endforeach + + + + + + + + + + + +
发货商户日期商品总数订单总数商品现金总额商品积分总额支付现金总额消耗积分总额订单运费总额结算成本结算运费结算总额操作
{{ $report->seller->name }}{{ $report->action_time }}{{ $report->goods_total }}{{ $report->orders_total }}{{ $report->goods_price_total - $report->goods_score_total}}{{ $report->goods_score_total }}{{ $report->orders_price - $report->orders_score }}{{ $report->orders_score }}{{ $report->orders_freight }}{{ $report->seller_total }}{{ $report->seller_freight }}{{ number_format($report->seller_total + $report->seller_freight,2) }} + + 明细 + +
+ + {{ $reports->sum('goods_total') }}件 + + {{ $reports->sum('orders_total') }}单 + + + {{ number_format($reports->sum('seller_total'),2) }}元 + + {{ number_format($reports->sum('seller_freight'),2) }}元 + + {{ number_format($reports->sum('seller_freight') + $reports->sum('seller_total'),2) }}元 + +
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $reports->total() }} 条 +
+ +
+
+ + diff --git a/app/Admin/Views/orderData/signed.blade.php b/app/Admin/Views/orderData/signed.blade.php new file mode 100644 index 0000000..cae7288 --- /dev/null +++ b/app/Admin/Views/orderData/signed.blade.php @@ -0,0 +1,128 @@ + + +
+ + + + + + + + + + + + + + + + + + + + @foreach ($reports as $report) + + + + + + + + + + + + + + + + + @endforeach + + + + + + + + + + + +
签收商户签收日期商品总数订单总数商品现金总额商品积分总额支付现金总额消耗积分总额订单运费总额结算成本结算运费结算总额操作
{{ $report->seller->name }}{{ $report->action_time }}{{ $report->goods_total }}{{ $report->orders_total }}{{ $report->goods_price_total - $report->goods_score_total}}{{ $report->goods_score_total }}{{ $report->orders_price - $report->orders_score }}{{ $report->orders_score }}{{ $report->orders_freight }}{{ $report->seller_total }}{{ $report->seller_freight }}{{ number_format($report->seller_total + $report->seller_freight,2) }} + + 明细 + +
+ + {{ $reports->sum('goods_total') }}件 + + {{ $reports->sum('orders_total') }}单 + + + {{ number_format($reports->sum('seller_total'),2) }}元 + + {{ number_format($reports->sum('seller_freight'),2) }}元 + + {{ number_format($reports->sum('seller_freight') + $reports->sum('seller_total'),2) }}元 + +
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $reports->total() }} 条 +
+ +
+
+ + diff --git a/app/Admin/Views/orders/allSellerOrder.blade.php b/app/Admin/Views/orders/allSellerOrder.blade.php new file mode 100644 index 0000000..63b1ea8 --- /dev/null +++ b/app/Admin/Views/orders/allSellerOrder.blade.php @@ -0,0 +1,181 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + @foreach ($orders as $order) + + + + + + + + + + + + + + + + + + + + + + @endforeach + +
订单编号商户名称手机号用户名商品信息商品金额运费抵值总计支付总成本配送收件地址状态创建时间支付时间
@switch($order->item_type) + @case('GOODS') + 商品 + @break + @case('ACTIVITY_GIFT') + 活动 + @break + @case('VIP_GIFT') + 赠品 + @break + @case('FULL_GIFT') + 满仓 + @break + @endswitch{{ $order->orderid }}{{ $order->seller->name }}{{ $order->user->mobile }}{{ $order->user->info->nickname }} @foreach ($order->details as $detail) + @if($detail->item){{ $detail->item->getTitle() ?? '未知'}} @endif {{ number_format($detail->price,2) }} * {{ $detail->number }} + @endforeach + {{ number_format($order->amount,2) }}{{ number_format($order->freight, 2)}}{{ number_format($order->score, 2) }}{{ number_format($order->total - $order->score, 2) }}{{ number_format($order->seller_amount, 2) }}{!! $order->express_type == 1 ? '快递' : '不需邮寄' !!}{{ $order->express->name ?? '' }} {{ $order->express->mobile ?? '' }} {{ $order->express->address ?? '' }}{{ $order->state_text }}{{ $order->remark }}{{ $order->created_at }}{{ $order->paid_at }} + @if ($order->canDeliver() && $order->express_type == 1) + 订单发货 + @endif + + @if ($order->canDeliver() && $order->express_type == 0) + 自提完成 + @endif + @if ($order->canComplete()) + 完成订单 + @endif + + @if (!empty($order->express->company) && !empty($order->express->number)) + 物流跟踪 + @endif + + @if ($order->canClose()) + 关闭订单 + @endif + + 订单详情 +
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $orders->total() }} 条 +
+ +
+
+ diff --git a/app/Admin/Views/orders/deliver.blade.php b/app/Admin/Views/orders/deliver.blade.php new file mode 100644 index 0000000..09f8a76 --- /dev/null +++ b/app/Admin/Views/orders/deliver.blade.php @@ -0,0 +1,41 @@ +
+
+
+
+ + +
+
+
+ + +
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+
    + @csrf + @method('PUT') +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/orders/index.blade.php b/app/Admin/Views/orders/index.blade.php new file mode 100644 index 0000000..708f6c4 --- /dev/null +++ b/app/Admin/Views/orders/index.blade.php @@ -0,0 +1,173 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + @foreach ($orders as $order) + + + + + + + + + + + + + + + + + + + @endforeach + +
订单编号商户名称手机号用户名商品信息商品金额运费抵值实际支付配送收件地址状态创建时间支付时间
+ {{ $order->orderid }} + {{ $order->seller->name }}{{ $order->user->mobile }}{{ $order->user->info->nickname }} @foreach ($order->details as $detail) + @if($detail->item){{ $detail->item->getTitle() ?? '未知'}} @endif {{ number_format($detail->price,2) }} * {{ $detail->number }} + @endforeach + {{ number_format($order->amount,2) }}{{ number_format($order->freight, 2)}}{{ number_format($order->score, 2) }}{{ number_format($order->total - $order->score, 2) }}{!! $order->express_type == 1 ? '快递' : '不需邮寄' !!}{{ $order->express->name ?? '' }} {{ $order->express->mobile ?? '' }} {{ $order->express->address ?? '' }}{{ $order->state_text }}{{ $order->remark }}{{ $order->created_at }}{{ $order->paid_at }} + @if ($order->canDeliver() && $order->express_type == 1) + 订单发货 + @endif + + @if ($order->canDeliver() && $order->express_type == 0) + 自提完成 + @endif + + @if ($order->canComplete()) + 完成订单 + @endif + + @if (!empty($order->express->company) && !empty($order->express->number)) + 物流跟踪 + @endif + + @if ($order->canClose()) + 关闭订单 + @endif + + 订单详情 +
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $orders->total() }} 条 +
+ +
+
+ diff --git a/app/Admin/Views/orders/logistic.blade.php b/app/Admin/Views/orders/logistic.blade.php new file mode 100644 index 0000000..9ee8a0f --- /dev/null +++ b/app/Admin/Views/orders/logistic.blade.php @@ -0,0 +1,40 @@ +
+
+
+ + +
+ @if($message['code'] == 'OK') +
+
+ + +
+
+
+ + +
+
+
+ +
+ +
+
+ @foreach($message['list'] as $logistic) +

{{ $logistic->content }}
{{ $logistic->time }}

+ @endforeach +
+ +
+ @else +
+ +

{{ $message['msg'] }}

+
+ @endif + +
+ +
diff --git a/app/Admin/Views/orders/remark.blade.php b/app/Admin/Views/orders/remark.blade.php new file mode 100644 index 0000000..2dbb01d --- /dev/null +++ b/app/Admin/Views/orders/remark.blade.php @@ -0,0 +1,24 @@ +
+
+
+
+ + +
+
+
+ + +
+ +
+
+
    + @csrf + @method('PUT') +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/orders/show.blade.php b/app/Admin/Views/orders/show.blade.php new file mode 100644 index 0000000..ee38f94 --- /dev/null +++ b/app/Admin/Views/orders/show.blade.php @@ -0,0 +1,106 @@ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @foreach ($order->details as $detail) + + + + + + + @endforeach + + + + + + + + + + @if(!empty($order->express->number)) + + + + + + + + + + @endif + + + + + + + + + + + + + +
订单信息:
@switch($order->item_type) + @case('GOODS') + 商品订单 + @break + @case('ACTIVITY') + 娱乐/生活 + @break + @case('GIFT') + 报名赠品 + @break + @case('LESSON') + 课程 + @break + @endswitch{{ $order->orderid }}下单用户:{{ $order->user->mobile }}{{ $order->user->info->nickname }}创建时间:{{ $order->created_at }}订单状态:{{ $order->status_text }}
支付时间:{{ $order->paid_at }}
商品金额:{{ number_format($order->amount,2) }}订单运费:{{ number_format($order->freight, 2)}}抵值:-{{ number_format($order->score, 2) }}总计支付:{{ number_format($order->total - $order->score, 2) }}
商户信息:
产品信息:
产品名称:单价*数量:小计:
{{ $detail->item->getTitle() }}{{ $detail->price }} * {{ $detail->number }}{{ number_format($detail->total,2) }}
收货信息:
配送方式:{!! $order->express_type == 1 ? '快递' : '自提' !!}收件人:{{ $order->express->name ?? '' }}手机号:{{ $order->express->mobile ?? '' }}地址:{{ $order->express->address ?? '' }}
发货信息:
物流公司:{{ $order->express->company ?? '' }}快递单号:{{ $order->express->number ?? '' }}
买家留言:
{{ $order->remark ?? '买家无留言' }}
管理员备注:
+ @if($order->remark_mgr) + 管理元备注内容:{{ $order->remark_mgr }} + + @else + 备注订单 + @endif +
+ +
diff --git a/app/Admin/Views/orders/unpay.blade.php b/app/Admin/Views/orders/unpay.blade.php new file mode 100644 index 0000000..d115c50 --- /dev/null +++ b/app/Admin/Views/orders/unpay.blade.php @@ -0,0 +1,116 @@ + + +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + @foreach ($orders as $order) + + + + + + + + + + + + + + + @endforeach + +
订单编号用户名金额运费总计状态状态创建时间支付时间
{{ $order->orderid }}{{ $order->user->name }}{{ $order->amount }}{{ $order->freight }}{{ $order->total }}{{ $order->state_text }}{{ $order->status_text }} || > {{$order->days}}{{ $order->remark }}{{ $order->created_at }}{{ $order->paid_at }} + @if ($order->canCancel()) + 取消订单 + @endif + + @if ($order->canDeliver()) + 订单发货 + @endif + + @if ($order->canComplete()) + 完成订单 + @endif + + @if ($order->canClose()) + 关闭订单 + @endif + + 订单详情 +
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $orders->total() }} 条 +
+ +
+ +
diff --git a/app/Admin/Views/organ/create.blade.php b/app/Admin/Views/organ/create.blade.php new file mode 100644 index 0000000..06f892c --- /dev/null +++ b/app/Admin/Views/organ/create.blade.php @@ -0,0 +1,143 @@ +
+
+
+
+ + +
+ +
+
+ + +
+ +
+
+ + +
+ +
+
+ + + +
+ +
+
+ + +
+ + +
+
+ + + + +
+ + +
+
+ + +
+ +
+
+ + +
+ +
+
+
+ @ueditor('', 'content') +
+
+ +
+ +
+ +
+
+
+ @csrf +
+
    +
  • +
  • +
+
+
+
+ + diff --git a/app/Admin/Views/organ/edit.blade.php b/app/Admin/Views/organ/edit.blade.php new file mode 100644 index 0000000..f2868f8 --- /dev/null +++ b/app/Admin/Views/organ/edit.blade.php @@ -0,0 +1,155 @@ +
+
+
+
+ + +
+ +
+
+ + +
+ +
+
+ + +
+ +
+
+ + + +
+ +
+
+ + +
+ + +
+
+ + + + +
+ + +
+
+ + +
+ +
+
+ + +
+ +
+
+
+ @ueditor($organ->content, 'content') +
+
+ +
+ @if ($organ->storage->path) + + @else + + @endif +
+ +
+
+
+ @csrf + @method('PUT') + +
+
    +
  • +
  • +
+
+
+
+ + diff --git a/app/Admin/Views/organ/index.blade.php b/app/Admin/Views/organ/index.blade.php new file mode 100644 index 0000000..3450e27 --- /dev/null +++ b/app/Admin/Views/organ/index.blade.php @@ -0,0 +1,81 @@ + + +
+
+ +
+ + + + + + + + + + + + + + + @foreach ($lists as $org) + + + + + + + + + + + @endforeach + +
机构编号机构名称分类电话微信地址创建时间
{{ $org->id }}{{ $org->title }}{{ $org->category->title }}{{ $org->mobile }}{{ $org->wechat }}{{ $org->all_address }}{{ $org->created_at }} + 编辑 + 删除 +
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $lists->total() }} 条 +
+ +
+
diff --git a/app/Admin/Views/params/create.blade.php b/app/Admin/Views/params/create.blade.php new file mode 100644 index 0000000..1a054cf --- /dev/null +++ b/app/Admin/Views/params/create.blade.php @@ -0,0 +1,28 @@ +
+
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ @csrf +
+
    +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/params/edit.blade.php b/app/Admin/Views/params/edit.blade.php new file mode 100644 index 0000000..1dafecb --- /dev/null +++ b/app/Admin/Views/params/edit.blade.php @@ -0,0 +1,63 @@ +
+
+
+
+ + +
+
+
+ + +
+ + @if(in_array($param->name,['baby_service'])) +
+
+
+ +
+ @if ($param->storage->path) + + @else + + @endif +
+ +
+
+ @else +
+
+ + +
+ @endif + + + +
+
+ @csrf + @method('PUT') +
+
    +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/params/index.blade.php b/app/Admin/Views/params/index.blade.php new file mode 100644 index 0000000..a85d2af --- /dev/null +++ b/app/Admin/Views/params/index.blade.php @@ -0,0 +1,76 @@ + + +
+
+ +
+ + + + + + + + + + + + + + + @foreach ($params as $param) + + + + + + + + + + @endforeach + +
编号参数标题调用名称参数值创建时间更新时间
{{ $param->id }}{{ $param->title }}{{ $param->name }}{{ $param->value }}{{ $param->created_at }}{{ $param->updated_at }} + 编辑 + 删除 +
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $params->total() }} 条 +
+ +
+
diff --git a/app/Admin/Views/payments/index.blade.php b/app/Admin/Views/payments/index.blade.php new file mode 100644 index 0000000..02ccf77 --- /dev/null +++ b/app/Admin/Views/payments/index.blade.php @@ -0,0 +1,86 @@ + + +
+ + + + + + + + + + + + + + + @foreach ($payments as $payment) + + + + + + + + + + + @endforeach + +
订单编号支付单号支付方式支付状态支付金额支付时间发送时间
{{ $payment->order->orderid??'' }}{{ $payment->trade_no }}{!! $payment->type_text !!}{!! $payment->state_text !!}{{ $payment->amount }}{{ $payment->remark }}{{ $payment->paid_at }}{{ $payment->created_at }}
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $payments->total() }} 条 +
+ +
+
+ diff --git a/app/Admin/Views/payments/vip.blade.php b/app/Admin/Views/payments/vip.blade.php new file mode 100644 index 0000000..b23caeb --- /dev/null +++ b/app/Admin/Views/payments/vip.blade.php @@ -0,0 +1,99 @@ + + +
+ + + + + + + + + + + + + + + + @foreach ($payments as $payment) + + + + + + + + + + + + @endforeach + +
用户id用户昵称支付单号支付方式支付状态支付金额支付时间发送时间
{{ $payment->user_id }}{{ $payment->user->info->nickname ?? '' }}{{ $payment->trade_no }}{{ $payment->pay_type }}支付成功{{ $payment->amount }}{{ $payment->paid_at }}{{ $payment->created_at }}
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $payments->total() }} 条 +
+ +
+
+ diff --git a/app/Admin/Views/profit/create.blade.php b/app/Admin/Views/profit/create.blade.php new file mode 100644 index 0000000..a782737 --- /dev/null +++ b/app/Admin/Views/profit/create.blade.php @@ -0,0 +1,27 @@ +
+
+
+
+ + +
+
+
+ + +
+
+ + + 选择 +
+
+ @csrf +
+
    +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/profit/edit.blade.php b/app/Admin/Views/profit/edit.blade.php new file mode 100644 index 0000000..57f199a --- /dev/null +++ b/app/Admin/Views/profit/edit.blade.php @@ -0,0 +1,28 @@ +
+
+
+
+ + +
+
+
+ + +
+
+ + + 选择 +
+
+ @csrf + @method('PUT') +
+
    +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/profit/index.blade.php b/app/Admin/Views/profit/index.blade.php new file mode 100644 index 0000000..7b8a77b --- /dev/null +++ b/app/Admin/Views/profit/index.blade.php @@ -0,0 +1,101 @@ + + +
+ + + + + + + + + + + + + + + + + + + @foreach ($profits as $profit) + + + + + + + + + + + + + + + @endforeach + +
ID利润金额清算日期总裁执行总裁总裁导师创始总裁备注状态创建时间执行之间查看详情
{{ $profit->id }}{{ $profit->price }}{{ $profit->end_at }}{{ $profit->portion(3) }}({{ (int)($profit->price*0.2/$profit->portion(3)) }}){{ $profit->portion(4) }}({{ (int)($profit->price*0.2/$profit->portion(4)) }}){{ $profit->portion(5) }}({{ (int)($profit->price*0.2/$profit->portion(5)) }}){{ $profit->portion(6) }}({{ (int)($profit->price*0.2/$profit->portion(6)) }}){{ $profit->remark }}{{ $profit->status_text }}{{ $profit->created_at }}{{ $profit->updated_at }} + @if($profit->id>2) + 查看详情 + @else + 记录无效 + + @endif +
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $profits->total() }} 条 +
+ +
+
+ diff --git a/app/Admin/Views/profit/logs.blade.php b/app/Admin/Views/profit/logs.blade.php new file mode 100644 index 0000000..f02358f --- /dev/null +++ b/app/Admin/Views/profit/logs.blade.php @@ -0,0 +1,46 @@ +
+ + + + + + + + + + + + @foreach ($logs as $log) + + + + + + + + @endforeach + +
分红日期分红类型分红会员分红金额积分
{{ $profit->end_at->format('Y-m-d') }}{{ $log->rule->title }}{{ $log->user->info->nickname }}({{ $log->user->id }}){{ $log->variable }}{{ $log->source['selfPoint'] }}
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $logs->total() }} 条 +
+ +
+
+ diff --git a/app/Admin/Views/report/create.blade.php b/app/Admin/Views/report/create.blade.php new file mode 100644 index 0000000..1f00dd6 --- /dev/null +++ b/app/Admin/Views/report/create.blade.php @@ -0,0 +1,26 @@ +
+
+
+
+ + +
+ +
+
+ + +
+ + + +
+ @csrf +
+
    +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/report/edit.blade.php b/app/Admin/Views/report/edit.blade.php new file mode 100644 index 0000000..1b13ef6 --- /dev/null +++ b/app/Admin/Views/report/edit.blade.php @@ -0,0 +1,24 @@ +
+
+
+
+ + +
+ +
+
+ + +
+
+ @csrf + @method('PUT') +
+
    +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/report/index.blade.php b/app/Admin/Views/report/index.blade.php new file mode 100644 index 0000000..fb5a0da --- /dev/null +++ b/app/Admin/Views/report/index.blade.php @@ -0,0 +1,56 @@ + + +
+
+ +
+ + + + + + + + + + + + + @foreach ($lists as $report) + + + + + + + + @endforeach + +
编号姓名手机号创建时间
{{ $report->id }}{{ $report->name }}{{ $report->mobile }}{{ $report->created_at }} + 编辑 +
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $lists->total() }} 条 +
+ +
+
diff --git a/app/Admin/Views/sellers/bindUser.blade.php b/app/Admin/Views/sellers/bindUser.blade.php new file mode 100644 index 0000000..2616270 --- /dev/null +++ b/app/Admin/Views/sellers/bindUser.blade.php @@ -0,0 +1,25 @@ +
+
+
+
+ + +
+
+ + +
+
+ @csrf +
+
    +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/sellers/certificate.blade.php b/app/Admin/Views/sellers/certificate.blade.php new file mode 100644 index 0000000..16bc20e --- /dev/null +++ b/app/Admin/Views/sellers/certificate.blade.php @@ -0,0 +1,58 @@ + +
+
+
+ +
+ + +
+ + +
+
+ +
+ @if(!empty($seller->cert_ids)) + @foreach($seller->certs as $cert) +
+
x
+ + +
+ @endforeach + @endif +
+
+ + + + +
+ @csrf +
+
    +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/sellers/create.blade.php b/app/Admin/Views/sellers/create.blade.php new file mode 100644 index 0000000..6a4abe9 --- /dev/null +++ b/app/Admin/Views/sellers/create.blade.php @@ -0,0 +1,252 @@ + +
+
+
+
+ + +
+ +
+
+ + +
+ + +
+
+ + + + 坐标拾取 +
+ +
+
+ + +
+ +
+
+ + +
+ + + +
+
+ + +
+ +
+
+ + +
+ + +
+
+ + + + +
+ + +
+
+ + +
+ +
+
+ + +
+ +
+
+ + +
+ +
+
+ +
+ +
+ +
+ +
+
+ +
+ +
+ +
+ + + +
+
+ +
+
+
+ +
+
+
+ @ueditor('', 'content','sellerskyxu') +
+
+ +
+@csrf +
+
    +
  • +
  • +
+
+
+
+ + diff --git a/app/Admin/Views/sellers/edit.blade.php b/app/Admin/Views/sellers/edit.blade.php new file mode 100644 index 0000000..985e78c --- /dev/null +++ b/app/Admin/Views/sellers/edit.blade.php @@ -0,0 +1,291 @@ + +
+
+
+ + +
+ + +
+ +
+
+ + +
+ +
+
+ + +
+ + +
+
+ + + + 坐标拾取 +
+ +
+
+ + +
+ +
+
+ + +
+ + + +
+
+ + +
+ + +
+
+ + +
+ + +
+
+ + + + +
+ + +
+
+ + +
+ +
+
+ + +
+ +
+
+ + +
+ +
+
+ +
+ @if ($seller->wechat) + + @else + + @endif +
+ +
+ +
+
+ +
+ @if ($seller->storage) + + @else + + @endif +
+ +
+ + + + +
+
+ +
+ @if(!empty($seller->storage_ids)) + @foreach($seller->storages as $storage) +
+
x
+ + +
+ @endforeach + @endif +
+
+ + +
+
+
+ @ueditor($seller->content, 'content') +
+
+ + +
+@csrf +@method('PUT') +
+
    +
  • +
  • +
+
+
+
+ + diff --git a/app/Admin/Views/sellers/freights.blade.php b/app/Admin/Views/sellers/freights.blade.php new file mode 100644 index 0000000..9f1d855 --- /dev/null +++ b/app/Admin/Views/sellers/freights.blade.php @@ -0,0 +1,48 @@ + + +
+ + + + + + + + + + + + + + @foreach ($freights as $freight) + + + + + + + + + + @endforeach + +
编号地区名称基本邮费(元)起重(公斤)续重(元/公斤)更新时间
{{ $freight->id }}{{ $freight->area->name }}{{ $freight->basic }}{{ $freight->heavy }}{{ $freight->added }}{{ $freight->updated_at }} + 编辑 +
+
+
+
diff --git a/app/Admin/Views/sellers/freightsEdit.blade.php b/app/Admin/Views/sellers/freightsEdit.blade.php new file mode 100644 index 0000000..e055f15 --- /dev/null +++ b/app/Admin/Views/sellers/freightsEdit.blade.php @@ -0,0 +1,33 @@ +
+
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+ @csrf + @method('PUT') +
+
    +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/sellers/index.blade.php b/app/Admin/Views/sellers/index.blade.php new file mode 100644 index 0000000..891ffe1 --- /dev/null +++ b/app/Admin/Views/sellers/index.blade.php @@ -0,0 +1,116 @@ + + +
+ + + + + + + + + + + @if(url()->current() == route('Admin.sellers.organ')) + + @endif + + + + + + + @if(url()->current() == route('Admin.sellers.index')) + + @endif + + + + + + @foreach ($sellers as $seller) + + + + + + + @if(url()->current() == route('Admin.sellers.organ')) + + @endif + + + + + + @if(url()->current() == route('Admin.sellers.index')) + + @endif + + + + + @endforeach + + + + +
编号{{ $title }}分类所属地域后台管理员课程数所属代理业务员排序状态商家负责人添加时间操作
{{ $seller->id }}{{ $seller->name }}{{ $seller->category->title }}{{ $seller->all_address }}{{ $seller->admins_count }}{{ $seller->lesson_count }}{{ $seller->agency->name }}{{ $seller->salesman->info->nickname }}{{ $seller->sort }}{!! $seller->status_text !!} + @if(!empty($seller->user)) {{ $seller->user->info->nickname }} + 取消 + @else + 绑定 + @endif + {{ $seller->created_at }} + 编辑 + @if(url()->current() == route('Admin.sellers.organ')) + 师资 + 资质 + @endif + + 管理员 + @if($seller->canDel())删除 @endif + canCancel())style="color: blue" @else style="color: grey" @endif>关闭 +
+

+ 注:1》关闭商户- 需要去手动下架待关闭商户的所有商品。2》删除商户- 商户下未上传商品的商户方可删除。 +

+
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $sellers->total() }} 条 +
+ +
+
diff --git a/app/Admin/Views/sellers/manager.blade.php b/app/Admin/Views/sellers/manager.blade.php new file mode 100644 index 0000000..5cfdffd --- /dev/null +++ b/app/Admin/Views/sellers/manager.blade.php @@ -0,0 +1,34 @@ +
+
+
+
+ + + +
+
+ + +
+
+
+ + +
+
+
+ + +
+ +
+ @csrf + @method('PUT') +
+
    +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/sellers/managerCreate.blade.php b/app/Admin/Views/sellers/managerCreate.blade.php new file mode 100644 index 0000000..dadb827 --- /dev/null +++ b/app/Admin/Views/sellers/managerCreate.blade.php @@ -0,0 +1,33 @@ +
+
+
+
+ + + +
+
+ + +
+
+
+ + +
+
+
+ + +
+ +
+ @csrf +
+
    +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/sellers/search.blade.php b/app/Admin/Views/sellers/search.blade.php new file mode 100644 index 0000000..07b6f84 --- /dev/null +++ b/app/Admin/Views/sellers/search.blade.php @@ -0,0 +1,74 @@ + + +
+ + + + + + + + + + + + + + + + + @foreach ($sellers as $seller) + + + + + + + + + + + + + @endforeach + + + +
编号机构名称分类所属地域所属代理业务员排序状态添加时间操作
{{ $seller->id }}{{ $seller->name }}{{ $seller->category->title }}{{ $seller->all_address }}{{ $seller->agency->name }}{{ $seller->salesman->info->nickname }}{{ $seller->sort }}{!! $seller->status_text !!}{{ $seller->created_at }} + 选择 + +
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $sellers->total() }} 条 +
+ +
+
diff --git a/app/Admin/Views/sellers/setting.blade.php b/app/Admin/Views/sellers/setting.blade.php new file mode 100644 index 0000000..2071819 --- /dev/null +++ b/app/Admin/Views/sellers/setting.blade.php @@ -0,0 +1,102 @@ +
+
+
+
+ + +
+
+
+ +
+ @if ($seller->storage) + + @else + + @endif +
+ +
+
+ +
+ +
+ @if ($seller->cover) + + @else + + @endif +
+ +
+
+
+ + +
+
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+
+ @csrf + @method('PUT') +
+
    +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/sellers/show.blade.php b/app/Admin/Views/sellers/show.blade.php new file mode 100644 index 0000000..b4bc024 --- /dev/null +++ b/app/Admin/Views/sellers/show.blade.php @@ -0,0 +1,30 @@ + +

《 {{ $seller->name }} 》运费明细

+
+ + + + + + + + + + + + + @foreach ($freights as $freight) + + + + + + + + + @endforeach + +
编号地区名称基本邮费(元)起重(公斤)续重(元/公斤)更新时间
{{ $freight->id }}{{ $freight->area->name }}{{ $freight->basic }}{{ $freight->heavy }}{{ $freight->added }}{{ $freight->updated_at }}
+
+
+
diff --git a/app/Admin/Views/sellers/users.blade.php b/app/Admin/Views/sellers/users.blade.php new file mode 100644 index 0000000..c043e52 --- /dev/null +++ b/app/Admin/Views/sellers/users.blade.php @@ -0,0 +1,83 @@ + + +
+
+ +
+ + + + + + + + + + + + + + + + + @foreach ($admins as $admin) + + + + + + + + + + + + @endforeach + +
编号登录账号昵称所属注册时间登录上次登录IP上次登录时间
{{ $admin->id }}{{ $admin->username }}{{ $admin->nickname }}{{ $admin->seller->name }}{{ $admin->created_at }}{{ $admin->logins_count }}{{ $admin->lastLogin->login_ip }}{{ $admin->lastLogin->created_at }} + 编辑 + {{--删除--}} +
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $admins->total() }} 条 +
+ +
+
diff --git a/app/Admin/Views/sellers/usersCreate.blade.php b/app/Admin/Views/sellers/usersCreate.blade.php new file mode 100644 index 0000000..43fd45e --- /dev/null +++ b/app/Admin/Views/sellers/usersCreate.blade.php @@ -0,0 +1,36 @@ +
+
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+ @csrf + +
+
    +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/sellers/usersEdit.blade.php b/app/Admin/Views/sellers/usersEdit.blade.php new file mode 100644 index 0000000..2278d55 --- /dev/null +++ b/app/Admin/Views/sellers/usersEdit.blade.php @@ -0,0 +1,35 @@ +
+
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+ @csrf + @method('PUT') +
+
    +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/stations/create.blade.php b/app/Admin/Views/stations/create.blade.php new file mode 100644 index 0000000..a5ae78a --- /dev/null +++ b/app/Admin/Views/stations/create.blade.php @@ -0,0 +1,92 @@ +
+
+
+ @if(Admin::id() == 1) +
+ + +
+ @else + + @endif +
+ + +
+
+ + +
+
+
+ + +
+
+ @csrf +
+
    +
  • +
    +
    + +
    +
    +
  • +
  • +
    +
    + +
    +
    +
  • +
+
+
+
+ diff --git a/app/Admin/Views/stations/edit.blade.php b/app/Admin/Views/stations/edit.blade.php new file mode 100644 index 0000000..d4048a5 --- /dev/null +++ b/app/Admin/Views/stations/edit.blade.php @@ -0,0 +1,38 @@ +
+
+
+ @if(Admin::id() == 1) +
+ + +
+ @else + + @endif +
+ + +
+
+ + +
+
+ + +
+
+ @csrf + @method('PUT') +
+
    +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/stations/index.blade.php b/app/Admin/Views/stations/index.blade.php new file mode 100644 index 0000000..0fcf2c4 --- /dev/null +++ b/app/Admin/Views/stations/index.blade.php @@ -0,0 +1,75 @@ + + +
+
+ +
+ + + + + + + + + + + + + + + + @foreach ($stations as $station) + + + + + + + + + + + @endforeach + + +
编号商户自提点名称自提点电话自提点地址注册时间更新时间操作
{{ $station->id }}{{ $station->seller->name ?? '' }}{{ $station->name }}{{ $station->mobile }}{{ $station->address }}{{ $station->created_at }}{{ $station->updated_at }} + 编辑 + 删除 +
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $stations->total() }} 条 +
+ +
+
diff --git a/app/Admin/Views/teacher/create.blade.php b/app/Admin/Views/teacher/create.blade.php new file mode 100644 index 0000000..00dce3b --- /dev/null +++ b/app/Admin/Views/teacher/create.blade.php @@ -0,0 +1,66 @@ +
+
+
+
+ + +
+ +
+
+ + +
+ +
+
+ + +
+ + @if(Admin::id() == 1) +
+ + +
+ @else + + @endif + + +
+
+ +
+ +
+ +
+ +
+ @csrf +
+
    +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/teacher/edit.blade.php b/app/Admin/Views/teacher/edit.blade.php new file mode 100644 index 0000000..073a519 --- /dev/null +++ b/app/Admin/Views/teacher/edit.blade.php @@ -0,0 +1,71 @@ +
+
+
+
+ + +
+ +
+
+ + +
+ +
+
+ + +
+ + @if(Admin::id() == 1) +
+ + +
+ @else + + @endif + + +
+
+ +
+ @if ($info->storage->path) + + @else + + @endif +
+ +
+ +
+ @csrf + @method('PUT') +
+
    +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/teacher/index.blade.php b/app/Admin/Views/teacher/index.blade.php new file mode 100644 index 0000000..953aa00 --- /dev/null +++ b/app/Admin/Views/teacher/index.blade.php @@ -0,0 +1,69 @@ + + +
+
+ +
+ + + + + + + + + + + + + + @foreach ($teachers as $teacher) + + + + + + + + + @endforeach + +
编号教师名称教龄所属机构创建时间
{{ $teacher->id }}{{ $teacher->name }}{{ $teacher->school_age }}{{ $teacher->seller->name }}{{ $teacher->created_at }} + 编辑 +
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $teachers->total() }} 条 +
+ +
+
diff --git a/app/Admin/Views/team/index.blade.php b/app/Admin/Views/team/index.blade.php new file mode 100644 index 0000000..6276053 --- /dev/null +++ b/app/Admin/Views/team/index.blade.php @@ -0,0 +1,64 @@ + + +
+ + + + + + + + + + + + + @foreach ($lists as $team) + + + + + + + + @endforeach + +
编号提交人手机号微信昵称提交时间
{{ $team->id }}{{ $team->user->info->nickname }}{{ $team->mobile }}{{ $team->wechat }}{{ $team->created_at }}
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $lists->total() }} 条 +
+ +
+
diff --git a/app/Admin/Views/tree.blade.php b/app/Admin/Views/tree.blade.php new file mode 100644 index 0000000..9fc6974 --- /dev/null +++ b/app/Admin/Views/tree.blade.php @@ -0,0 +1,11 @@ +@foreach ($children as $item) +
    +
  • + {{ $item['text'] }} + @isset($item['children']) + @component('Admin::common.tree', ['children' => $item['children']]) + @endcomponent + @endisset +
  • +
+@endforeach diff --git a/app/Admin/Views/users/bloodview.blade.php b/app/Admin/Views/users/bloodview.blade.php new file mode 100644 index 0000000..8f31f08 --- /dev/null +++ b/app/Admin/Views/users/bloodview.blade.php @@ -0,0 +1,20 @@ +
+
+
+
    +
  • + {{ $root['text'] }} + @isset($root['children']) + @component('Admin::common.tree', ['children' => $root['children']]) + @endcomponent + @endisset +
  • +
+
+
+
    +
  • +
+
+
+
diff --git a/app/Admin/Views/users/create.blade.php b/app/Admin/Views/users/create.blade.php new file mode 100644 index 0000000..23bca1a --- /dev/null +++ b/app/Admin/Views/users/create.blade.php @@ -0,0 +1,27 @@ +
+
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+ @csrf +
+
    +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/users/edit.blade.php b/app/Admin/Views/users/edit.blade.php new file mode 100644 index 0000000..30f9ccb --- /dev/null +++ b/app/Admin/Views/users/edit.blade.php @@ -0,0 +1,28 @@ +
+
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+ @csrf + @method('PUT') +
+
    +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/users/identity.blade.php b/app/Admin/Views/users/identity.blade.php new file mode 100644 index 0000000..0fdf82b --- /dev/null +++ b/app/Admin/Views/users/identity.blade.php @@ -0,0 +1,45 @@ +
+
+
+
+ + +
+
+
+ + +
+
+
+ + +
+ + +
+ @csrf +
+
    +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/users/index.blade.php b/app/Admin/Views/users/index.blade.php new file mode 100644 index 0000000..c52fecc --- /dev/null +++ b/app/Admin/Views/users/index.blade.php @@ -0,0 +1,136 @@ + + +
+ + + + + + + + + + + + + + + + + + + @foreach ($users as $user) + + + + + + + + + + + + + + + @endforeach + +
编号手机号昵称当前身份业务员机构上级直推登录次数激活时间注册时间
{{ $user->id }}{{ $user->mobile }}{{ $user->info->nickname }}{{ $user->identity_text }} + {{ $user->salesman_text }} + @if($user->is_salesman) + 取消 + @else + 设置 + @endif + + {{ $user->organ->name }}{{ $user->parent->info->nickname ?? '无' }}({{ $user->parent['id'] ?: '' }}) + {{ $user->identity->relation_count }} + [血缘视图] + {{ $user->logins_count }}{{ $user->identity->created_at??'' }}{{ $user->created_at }} + 开通身份 + 编辑 + @if($user->relation->parent_id==1 || $user->identity->identity_id==0) + 改变上级 + @endif + 改变组织 +
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $users->total() }} 条 +
+ +
+
+ + diff --git a/app/Admin/Views/users/parent.blade.php b/app/Admin/Views/users/parent.blade.php new file mode 100644 index 0000000..f79f638 --- /dev/null +++ b/app/Admin/Views/users/parent.blade.php @@ -0,0 +1,27 @@ +
+
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+ @csrf +
+
    +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/users/paycostuser.blade.php b/app/Admin/Views/users/paycostuser.blade.php new file mode 100644 index 0000000..7c14f02 --- /dev/null +++ b/app/Admin/Views/users/paycostuser.blade.php @@ -0,0 +1,118 @@ + + +
+
+
    +
+
+ + + + + + + + + + + + + + + + + + + + + + @foreach ($lists as $info) + + + + + + + + + + + + + + + + + @endforeach + +
编号OPENID手机号昵称等级当前推荐变更时间备注
{{ $info->user->id }}{{ $info->user->openid }}{{ $info->user->mobile }}{{ $info->user->info->nickname }}{{ $info->identity_title }}{{ $info->user->identity->activation_childs }} 人{{ $info->created_at }}{{ $info->other['rebates_remark']??'无' }} + @if (!isset($info->other['rebates'])) + + @endif +
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $lists->total() }} 条 +
+ +
+
+ + diff --git a/app/Admin/Views/users/rebates.blade.php b/app/Admin/Views/users/rebates.blade.php new file mode 100644 index 0000000..84312f2 --- /dev/null +++ b/app/Admin/Views/users/rebates.blade.php @@ -0,0 +1,46 @@ +
+
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+ @csrf +
+
    +
  • +
+
+
+
diff --git a/app/Admin/Views/users/recycle.blade.php b/app/Admin/Views/users/recycle.blade.php new file mode 100644 index 0000000..54dda52 --- /dev/null +++ b/app/Admin/Views/users/recycle.blade.php @@ -0,0 +1,78 @@ + + +
+
+ +
+ + + + + + + + + + + + + + + + @foreach ($users as $user) + + + + + + + + + + + @endforeach + +
编号用户名昵称登录次数上次登录时间上次登录IP注册时间
{{ $user->id }}{{ $user->username }}{{ $user->info->nickname }}{{ $user->logins_count }}{{ $user->lastLogin->login_at }}{{ $user->lastLogin->login_ip }}{{ $user->created_at }} + 还原 + 彻底删除 +
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $users->total() }} 条 +
+ +
+
diff --git a/app/Admin/Views/users/seller.blade.php b/app/Admin/Views/users/seller.blade.php new file mode 100644 index 0000000..1f68e30 --- /dev/null +++ b/app/Admin/Views/users/seller.blade.php @@ -0,0 +1,33 @@ +
+
+
+
+ + +
+
+
+ + + + 查找带回 +
+
+ {{--
+ + +
--}} +
+ @csrf +
+
    +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/users/upgrade.blade.php b/app/Admin/Views/users/upgrade.blade.php new file mode 100644 index 0000000..dcf1ee1 --- /dev/null +++ b/app/Admin/Views/users/upgrade.blade.php @@ -0,0 +1,23 @@ +
+
+
+
+ + +
+
+
+ + +
+
+ @csrf + @method('PUT') +
+
    +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/wechat/create.blade.php b/app/Admin/Views/wechat/create.blade.php new file mode 100644 index 0000000..76d7946 --- /dev/null +++ b/app/Admin/Views/wechat/create.blade.php @@ -0,0 +1,43 @@ +
+
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+ @csrf +
+
    +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/wechat/edit.blade.php b/app/Admin/Views/wechat/edit.blade.php new file mode 100644 index 0000000..325fe1c --- /dev/null +++ b/app/Admin/Views/wechat/edit.blade.php @@ -0,0 +1,44 @@ +
+
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+ @csrf + @method('PUT') +
+
    +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/wechat/menus.blade.php b/app/Admin/Views/wechat/menus.blade.php new file mode 100644 index 0000000..a1ef3fe --- /dev/null +++ b/app/Admin/Views/wechat/menus.blade.php @@ -0,0 +1,81 @@ +
+
+ +
    + @foreach ($genMenus as $menu) +
  • {{ $menu->name }} + @if ($menu->children->count()) + + @endif +
  • + @endforeach +
+
+
+ + + + + + + + + + + + + + + + + + @foreach ($menus as $menu) + + + + + + + + + + + + @endforeach + +
ID上级菜单菜单名称类型菜单键值排序创建时间更新时间
{{ $menu->id }}{{ $menu->parent->name }}{{ $menu->name }}{{ $menu->type }}{{ $menu->value }}{{ $menu->sort }}{{ $menu->created_at }}{{ $menu->updated_at }} + 编辑 + 删除 +
+ +
+
+
+
diff --git a/app/Admin/Views/wechatRules/create.blade.php b/app/Admin/Views/wechatRules/create.blade.php new file mode 100644 index 0000000..8563963 --- /dev/null +++ b/app/Admin/Views/wechatRules/create.blade.php @@ -0,0 +1,57 @@ +
+
+
+
+ + +
+
+ + +
+ {{--
--}} + {{----}} + {{----}} + {{--
--}} +
+
+ + +
+ +
+
+
+ +
+ +
+ +
+
+
+ @csrf +
+
    +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/wechatRules/edit.blade.php b/app/Admin/Views/wechatRules/edit.blade.php new file mode 100644 index 0000000..7eeed64 --- /dev/null +++ b/app/Admin/Views/wechatRules/edit.blade.php @@ -0,0 +1,66 @@ +
+
+
+
+ + +
+
+
+ + +
+ {{--
--}} + {{--
--}} + {{----}} + {{----}} + {{--
--}} +
+
+ + +
+ +
+
+ +
+ +
+ @if ($wechatRule->storage->path) + + @else + + @endif +
+ +
+
+
+ @csrf +
+
    + @csrf + @method('PUT') +
  • +
  • +
+
+
+
diff --git a/app/Admin/Views/wechatRules/index.blade.php b/app/Admin/Views/wechatRules/index.blade.php new file mode 100644 index 0000000..cfdf2c5 --- /dev/null +++ b/app/Admin/Views/wechatRules/index.blade.php @@ -0,0 +1,52 @@ + + +
+ + + + + + + + + + + + + @foreach ($wechatRules as $wechatRule) + + + + + + + @endforeach + +
编号配置标题创建时间
{{ $wechatRule->id }}{{ $wechatRule->title }}{{ $wechatRule->created_at }} + 编辑 + 删除 +
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $wechatRules->total() }} 条 +
+ +
+
diff --git a/app/Admin/Views/windups/create.blade.php b/app/Admin/Views/windups/create.blade.php new file mode 100644 index 0000000..115c25e --- /dev/null +++ b/app/Admin/Views/windups/create.blade.php @@ -0,0 +1,79 @@ +
+
+
+ +
+ + +
+
+
+ + +
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+
    + @method('PUT') + @csrf +
  • +
  • +
+
+
+
+ + + diff --git a/app/Admin/Views/windups/index.blade.php b/app/Admin/Views/windups/index.blade.php new file mode 100644 index 0000000..82f50f5 --- /dev/null +++ b/app/Admin/Views/windups/index.blade.php @@ -0,0 +1,152 @@ + + +
+ + + + + + + + + + @if(Admin::id() == 1) + + + + @endif + + + + + + + + + + @if($seller_orders->count() > 0) + @foreach ($seller_orders as $seller_order) + + + + + + + + @if(Admin::id() == 1) + + + + @endif + + + + + + + @endforeach + + + + + + @if(Admin::id() == 1) + + + @endif + + + @else + + + @endif + + + +
编号商户名称订单数量总成本总运费结算总额扣除税点实际结算开始时间结束时间打款状态打款账户
{{ $seller_order->id }}{{ $seller_order->seller->name }}{{ $seller_order->orders_count }}{{ $seller_order->seller_amount_sum }}{{ $seller_order->seller_freight_sum }}{{ number_format($seller_order->seller_freight_sum + $seller_order->seller_amount_sum,2) }}{{ number_format(($seller_order->seller_freight_sum + $seller_order->seller_amount_sum) * 0.06,2) }}{{ number_format(($seller_order->seller_freight_sum + $seller_order->seller_amount_sum) * 0.94,2) }}{{ $seller_order->start_time }}{{ $seller_order->end_time }}{{ $seller_order->state == 0 ? '未打款' : '已打款' }}{!! empty($seller_order->seller->account_name) ? '未设置' : $seller_order->seller->account_name !!} + 订单明细 + @if(Admin::id() == 1)   |  打款结算@endif +
+ + {{ $seller_orders->sum('orders_count') }}单 + + + {{ number_format($seller_orders->sum('seller_amount_sum') + $seller_orders->sum('seller_freight_sum'),2) }}元 + + {{ number_format(($seller_orders->sum('seller_amount_sum') + $seller_orders->sum('seller_freight_sum')) * 0.06,2) }}元 + + {{ number_format(($seller_orders->sum('seller_amount_sum') + $seller_orders->sum('seller_freight_sum')) * 0.94,2) }}元 + +
+ 没有找到待结算记录 +
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $seller_orders->total() }} 条 +
+ +
+
+ diff --git a/app/Admin/Views/windups/invoice.blade.php b/app/Admin/Views/windups/invoice.blade.php new file mode 100644 index 0000000..6a06461 --- /dev/null +++ b/app/Admin/Views/windups/invoice.blade.php @@ -0,0 +1,7 @@ +
+
+
+ {!! $info !!} +
+
+
diff --git a/app/Admin/Views/windups/orders.blade.php b/app/Admin/Views/windups/orders.blade.php new file mode 100644 index 0000000..02b506c --- /dev/null +++ b/app/Admin/Views/windups/orders.blade.php @@ -0,0 +1,103 @@ + + +
+ + + + + + + + + + + + + + + + + + @foreach ($orders as $order) + + + + + + + + + + + + + + @endforeach + + + + + + +
订单编号商户名称手机号用户名商品信息成本金额结算运费商家结算状态创建时间支付时间
@switch($order->item_type) + @case('GOODS') + 商品 + @break + @case('ACTIVITY_GIFT') + 活动 + @break + @case('VIP_GIFT') + 会员 + @break + @case('FULL_GIFT') + 满仓 + @break + @endswitch{{ $order->orderid }}{{ $order->seller->name }}{{ $order->user->mobile }}{{ $order->user->info->nickname }}@foreach ($order->details as $detail) + @if($detail->item){{ $detail->item->getTitle() ?? '未知'}} @endif {{ number_format($detail->seller_price,2) }} * {{ $detail->number }} + @endforeach + {{ number_format($order->seller_amount,2) }}{{ number_format($order->seller_freight, 2)}}{{ number_format($order->seller_amount + $order->seller_freight, 2) }}{{ $order->status_text }}{{ $order->created_at }}{{ $order->paid_at }}
订单数量:{{ $orders->count() }}     合计金额:{{ number_format($orders->sum('seller_freight') + $orders->sum('seller_amount'),2) }}
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $orders->total() }} 条 +
+ +
+
+ diff --git a/app/Admin/Views/windups/rule.blade.php b/app/Admin/Views/windups/rule.blade.php new file mode 100644 index 0000000..96a558a --- /dev/null +++ b/app/Admin/Views/windups/rule.blade.php @@ -0,0 +1,7 @@ +
+
+
+ {!! $info !!} +
+
+
diff --git a/app/Admin/Views/windups/winduped.blade.php b/app/Admin/Views/windups/winduped.blade.php new file mode 100644 index 0000000..7bb30be --- /dev/null +++ b/app/Admin/Views/windups/winduped.blade.php @@ -0,0 +1,145 @@ + + +
+ + + + + + + + + + @if(Admin::id() == 1) + @endif + + + + + + + + + + @if($seller_orders->count() > 0) + @foreach ($seller_orders as $seller_order) + + + + + + + + @if(Admin::id() == 1) + + + @endif + + + + + + + + @endforeach + + + + + + @if(Admin::id() == 1) + + + @endif + + + @else + + + @endif + +
编号商户名称订单数量总成本总运费结算总额扣除税点实际结算开始时间结束时间打款时间打款账户发票状态
{{ $seller_order->id }}{{ $seller_order->seller->name }}{{ $seller_order->orders_count }}{{ $seller_order->seller_amount_sum }}{{ $seller_order->seller_freight_sum }}{{ number_format($seller_order->seller_freight_sum + $seller_order->seller_amount_sum,2) }}{{ number_format(($seller_order->seller_freight_sum + $seller_order->seller_amount_sum) * 0.06,2) }}{{ number_format(($seller_order->seller_freight_sum + $seller_order->seller_amount_sum) * 0.94,2) }}{{ $seller_order->start_time }}{{ $seller_order->end_time }}{{ $seller_order->winduped_at }}{{ $seller_order->seller_account_name }} {{ $seller_order->seller_account_bank }} {{ $seller_order->seller_account_number }}{!! $seller_order->is_provide_invoice == 1 ? '已提供' : '未提供' !!} + 订单明细 +
+ + {{ $seller_orders->sum('orders_count') }}单 + + + {{ number_format($seller_orders->sum('seller_amount_sum') + $seller_orders->sum('seller_freight_sum'),2) }}元 + + {{ number_format(($seller_orders->sum('seller_amount_sum') + $seller_orders->sum('seller_freight_sum')) * 0.06,2) }}元 + + {{ number_format(($seller_orders->sum('seller_amount_sum') + $seller_orders->sum('seller_freight_sum')) * 0.94,2) }}元 + +
+ 没有找到已结算记录 +
+ +
+
+ + + + +
+
+ 显示 + + 条,共 {{ $seller_orders->total() }} 条 +
+ +
+
+ \ No newline at end of file diff --git a/app/Admin/Views/withdraws/status.blade.php b/app/Admin/Views/withdraws/status.blade.php new file mode 100644 index 0000000..54dc5a7 --- /dev/null +++ b/app/Admin/Views/withdraws/status.blade.php @@ -0,0 +1,46 @@ +
+
+
+
+ +
{{ $withdraw->way_text }}
+
+
+ +
{!! $withdraw->info_text !!}
+
+
+ + +
+
+ +
+
+
    + @csrf + @method('PUT') +
  • +
  • +
+
+
+
+ + diff --git a/app/Admin/Views/按钮类型 b/app/Admin/Views/按钮类型 new file mode 100644 index 0000000..71f3270 --- /dev/null +++ b/app/Admin/Views/按钮类型 @@ -0,0 +1,9 @@ +a.btnAdd 加号 +a.btnDel 删除 +a.btnView 小眼睛 +a.btnEdit 编辑 +a.btnSelect 对号 +a.btnInfo 文档 +a.btnAssign 小人 +a.btnLook 放大镜 +a.btnAttach 曲别针 diff --git a/app/Admin/installed.lock b/app/Admin/installed.lock new file mode 100644 index 0000000..e88f04a --- /dev/null +++ b/app/Admin/installed.lock @@ -0,0 +1 @@ +2018-11-01 08:34:48 \ No newline at end of file diff --git a/app/Admin/routes.php b/app/Admin/routes.php new file mode 100644 index 0000000..876c904 --- /dev/null +++ b/app/Admin/routes.php @@ -0,0 +1,207 @@ +name('dashboard'); + +Route::resource('bonus', 'BonusController'); + +Route::get('articles/notices', 'ArticleController@notices')->name('articles.notices'); +Route::get('articles/news', 'ArticleController@news')->name('articles.news'); +Route::resource('articles', 'ArticleController'); + +Route::get('notifications', 'NotificationController@index')->name('notifications.index'); +Route::delete('notifications/{notification}', 'NotificationController@destroy')->name('notifications.destroy'); +Route::get('test/test', 'TestController@test'); +Route::get('test/relation', 'TestController@relation'); + +// 产品管理部分 +Route::get('goods/all', 'GoodsController@all')->name('goods.all'); +Route::delete('goods/clean', 'GoodsController@clean')->name('goods.clean'); +Route::get('goods/{user}/resume', 'GoodsController@resume')->name('goods.resume'); +Route::delete('goods/{good}/delete', 'GoodsController@delete')->name('goods.delete'); +Route::get('goods/recycle', 'GoodsController@recycle')->name('goods.recycle'); +Route::any('goods/{good}/setting', 'GoodsController@setting')->name('goods.setting'); +Route::any('goods/{good}/setgift', 'GoodsController@setgift')->name('goods.setgift'); +Route::any('goods/{good}/cancelgift', 'GoodsController@cancelgift')->name('goods.cancelgift'); +Route::any('goods/{good}/setlottery', 'GoodsController@setlottery')->name('goods.setlottery'); +Route::any('goods/{good}/cancellottery', 'GoodsController@cancellottery')->name('goods.cancellottery'); +Route::any('goods/{good}/setFull', 'GoodsController@setFull')->name('goods.setFull'); +Route::any('goods/{good}/cancelFull', 'GoodsController@cancelFull')->name('goods.cancelFull'); + +Route::any('goods/{good}/putOn', 'GoodsController@putOn')->name('goods.putOn'); +Route::any('goods/{good}/magageedit', 'GoodsController@magageedit')->name('goods.magageedit'); +Route::resource('goods', 'GoodsController'); + +//区域设置 +Route::any('areas/{area}/open', 'AreaController@open')->name('areas.open'); +Route::any('areas/{area}/hot', 'AreaController@hot')->name('areas.hot'); +Route::resource('areas', 'AreaController'); + +// 分类管理 +Route::resource('categories', 'CategoryController'); +//券码管理 +Route::resource('coupon', 'CouponController'); + +// 用户管理 +Route::get('users/{user}/salesman', 'UserController@salesman')->name('users.salesman'); +Route::delete('users/clean', 'UserController@clean')->name('users.clean'); +Route::get('users/{user}/seller', 'UserController@seller')->name('users.seller'); +Route::post('users/{user}/sellerdo', 'UserController@sellerdo')->name('users.sellerdo'); +Route::get('users/{user}/resume', 'UserController@resume')->name('users.resume'); +Route::delete('users/{user}/delete', 'UserController@delete')->name('users.delete'); +Route::get('users/recycle', 'UserController@recycle')->name('users.recycle'); +Route::get('users/{user}/identity', 'UserController@identity')->name('users.identity'); +Route::post('users/{user}/identityrun', 'UserController@identityrun')->name('users.identityrun'); +Route::get('users/paycostuser', 'UserController@paycostUser')->name('users.paycostuser'); +Route::get('users/{log}/rebates', 'UserController@rebates')->name('users.rebates'); +Route::post('users/{log}/rebatesdo', 'UserController@rebatesdo')->name('users.rebatesdo'); +Route::get('users/{user}/parent', 'UserController@parent')->name('users.parent'); +Route::post('users/{user}/parentrun', 'UserController@parentrun')->name('users.parentrun'); +Route::get('users/{user}/direct', 'UserController@direct')->name('users.direct'); +Route::get('users/{user}/bloodview', 'UserController@bloodview')->name('users.bloodview'); +Route::resource('users', 'UserController'); +// 账户管理 +Route::get('accounts/withdraws', 'AccountController@withdraws')->name('accounts.withdraws'); +Route::get('accounts/rules', 'AccountController@rules')->name('accounts.rules'); +Route::get('accounts/logs', 'AccountController@logs')->name('accounts.logs'); +Route::get('accounts', 'AccountController@index')->name('accounts.index'); +Route::any('withdraws/{withdraw}/status', 'WithdrawsController@status')->name('withdraws.status'); +Route::any('withdraws/{withdraw}/doStatus', 'WithdrawsController@doStatus')->name('withdraws.doStatus'); + +// 订单管理 +Route::get('orders', 'OrderController@index')->name('orders.index'); +Route::get('orders/unpay', 'OrderController@unpay')->name('orders.unpay'); +Route::get('orders/paid', 'OrderController@paid')->name('orders.paid'); +Route::get('orders/signed', 'OrderController@signed')->name('orders.signed'); + +Route::delete('orders/{order}/cancel', 'OrderController@cancel')->name('orders.cancel'); +Route::any('orders/{order}/deliver', 'OrderController@deliver')->name('orders.deliver'); +Route::get('orders/{order}/complete', 'OrderController@complete')->name('orders.complete'); +Route::get('orders/{order}/close', 'OrderController@close')->name('orders.close'); +Route::get('orders/{order}', 'OrderController@show')->name('orders.show'); +Route::any('orders/{order}/remark', 'OrderController@remark')->name('orders.remark'); +Route::get('orders/{order}/logistic', 'OrderController@logistic')->name('orders.logistic'); +Route::any('orders/{order}/signin', 'OrderController@signin')->name('orders.signin'); + +Route::get('allOrders', 'OrderAllController@index')->name('allOrders.index'); + +// 支付订单 +Route::get('payments', 'PaymentController@index')->name('payments.index'); +Route::get('payments/vip', 'PaymentController@vip')->name('payments.vip'); + +//分红相关 +Route::get('profit/{profit}/run', 'ProfitController@run')->name('profit.run'); +Route::get('profit/{profit}/logs', 'ProfitController@logs')->name('profit.logs'); + +Route::resource('profit', 'ProfitController'); +// 轮播图管理 +Route::resource('adverts', 'AdvertController'); +// 系统参数 +Route::resource('params', 'ParamController'); +// 商户运费设置 +Route::get('sellers/{seller}/certificate', 'SellerController@certificate')->name('sellers.certificate'); // 设置资质 +Route::post('sellers/{seller}/docertificate', 'SellerController@docertificate')->name('sellers.docertificate'); // 设置资质 +Route::get('sellers/{seller}/manager', 'SellerController@manager')->name('sellers.manager'); // 设置管理员 +Route::put('sellers/manager/{admin}', 'SellerController@managerUpdate')->name('sellers.manager.update'); +Route::post('sellers/manager/{seller}/store', 'SellerController@managerStore')->name('sellers.manager.store'); +Route::any('sellers/setting', 'SellerController@setting')->name('sellers.setting'); // 商户设置,在这里设置商户 名称 LOGO 信息 +Route::get('sellers/freights', 'SellerController@freights')->name('sellers.freights'); // 商户运费 +Route::any('sellers/freights/{freight}/edit', 'SellerController@freightsEdit')->name('sellers.freights.edit'); // 编辑运费 +Route::get('sellers/{seller}/users', 'SellerController@users')->name('sellers.users'); // 商户管理员列表 +Route::get('sellers/users/create', 'SellerController@usersCreate')->name('sellers.users.create'); +Route::post('sellers/users', 'SellerController@usersStore')->name('sellers.users.store'); +Route::get('sellers/users/{admin}/edit', 'SellerController@usersEdit')->name('sellers.users.edit'); +Route::put('sellers/users/{admin}', 'SellerController@usersUpdate')->name('sellers.users.update'); +Route::delete('sellers/users/{admin}', 'SellerController@usersDestroy')->name('sellers.users.destroy'); +Route::get('sellers/{seller}/bindUser', 'SellerController@bindUser')->name('sellers.bindUser'); // 商户绑定总裁 +Route::post('sellers/{seller}/bindUser', 'SellerController@dobindUser')->name('sellers.bindUser'); // 商户绑定总裁 +Route::delete('sellers/{seller}/cancelusers', 'SellerController@cancelUser')->name('sellers.cancelusers'); + +// 商户管理 +Route::get('sellers/organ', 'SellerController@organ')->name('sellers.organ'); +Route::get('sellers/search', 'SellerController@search')->name('sellers.search'); +Route::resource('sellers', 'SellerController'); + +Route::any('stations/areas', 'StationController@areas')->name('stations.areas'); // 获取区域 +Route::resource('stations', 'StationController'); + +Route::get('windups/orders', 'WindupsController@orders')->name('windups.orders'); +Route::get('windups/winduped', 'WindupsController@winduped')->name('windups.winduped'); +Route::get('windups/rule', 'WindupsController@rule')->name('windups.rule'); +Route::get('windups/invoice', 'WindupsController@invoice')->name('windups.invoice'); +Route::any('windups/dostate', 'WindupsController@dostate')->name('windups.dostate'); +Route::resource('windups', 'WindupsController'); + +// 微信管理 +Route::get('wechat/menus', 'WechatController@menus')->name('wechat.menus'); +Route::get('wechat/publish', 'WechatController@publish')->name('wechat.publish'); +Route::get('wechat/create', 'WechatController@create')->name('wechat.create'); +Route::post('wechat/store', 'WechatController@store')->name('wechat.store'); +Route::get('wechat/{menu}/edit', 'WechatController@edit')->name('wechat.edit'); +Route::put('wechat/{menu}', 'WechatController@update')->name('wechat.update'); +Route::delete('wechat/{menu}', 'WechatController@destroy')->name('wechat.destroy'); +Route::resource('wechatRules', 'WechatRulesController'); + +//csv数据导出 +Route::get('export/user', 'DataExportController@user')->name('export.user'); +Route::get('export/orders', 'DataExportController@orders')->name('export.orders'); +Route::get('export/allOrders', 'DataExportController@allOrders')->name('export.allOrders'); +Route::get('export/accounts', 'DataExportController@accounts')->name('export.accounts'); +Route::get('export/logs', 'DataExportController@logs')->name('export.logs'); +Route::get('export/payments', 'DataExportController@payments')->name('export.payments'); +Route::get('export/withdraws', 'DataExportController@withdraws')->name('export.withdraws'); +Route::get('export/profits', 'DataExportController@profits')->name('export.profits'); +Route::get('export/windup_lists', 'DataExportController@windup_lists')->name('export.windup_lists'); +Route::get('export/winduped_lists', 'DataExportController@winduped_lists')->name('export.winduped_lists'); +Route::get('export/windup_orders', 'DataExportController@windup_orders')->name('export.windup_orders'); +Route::get('export/payCostUser', 'DataExportController@payCostUser')->name('export.payCostUser'); +Route::get('export/vipPay', 'DataExportController@vipPay')->name('export.vipPay'); +Route::get('export/goods', 'DataExportController@goods')->name('export.goods'); +Route::get('export/report', 'DataExportController@report')->name('export.report'); +Route::get('export/dataReport', 'DataExportController@dataReport')->name('export.dataReport'); + +Route::get('jason', 'JasonController@index')->name('jason'); + +Route::get('activityGifts/{activity}/create', 'ActivityController@giftsCreate')->name('activityGifts.create'); +Route::post('activityGifts/{activity}/store', 'ActivityController@giftsStore')->name('activityGifts.store'); +Route::get('activityGifts/{gift}/edit', 'ActivityController@giftsEdit')->name('activityGifts.edit'); +Route::put('activityGifts/{gift}', 'ActivityController@giftsUpdate')->name('activityGifts.update'); +Route::delete('activityGifts/{gift}', 'ActivityController@giftsDestroy')->name('activityGifts.destroy'); +Route::post('activities/params', 'ActivityController@params')->name('activities.params'); +Route::post('activities/goods', 'ActivityController@goods')->name('activities.goods'); +Route::resource('activities', 'ActivityController'); + +Route::get('orderData/index', 'OrderDataController@index')->name('orderData.index'); +Route::get('orderData/signed', 'OrderDataController@signed')->name('orderData.signed'); +Route::get('orderData/dashboard', 'OrderDataController@dashboard')->name('orderData.dashboard'); +Route::get('orderData/order', 'OrderDataController@order')->name('orderData.order'); + +Route::get('orderData/report', 'OrderDataController@report')->name('orderData.report'); + +//课程 +Route::delete('lessons/{lesson}/delete', 'LessonController@delete')->name('lessons.delete'); +Route::get('lessons/{lesson}/logs', 'LessonController@logs')->name('lessons.logs'); +Route::resource('lessons', 'LessonController'); + +//师资力量 +Route::resource('teachers', 'TeacherController'); + +//加盟 代理 +Route::get('teams/index', 'TeamController@index')->name('teams.index'); + +//抽奖管理 +Route::any('lottery/{lottery}/addgifts', 'LotteryController@addgifts')->name('lottery.addgifts'); +Route::any('lottery/{gift}/editgifts', 'LotteryController@editgifts')->name('lottery.editgifts'); +Route::delete('lottery/{gift}/delgifts', 'LotteryController@delgifts')->name('lottery.delgifts'); +Route::get('lottery/{lottery}/gifts', 'LotteryController@gifts')->name('lottery.gifts'); +Route::get('lottery/{lottery}/logs', 'LotteryController@logs')->name('lottery.logs'); +Route::resource('lottery', 'LotteryController'); + +//代理管理 +Route::get('agencies/checkuser', 'AgencyController@checkuser')->name('agencies.checkuser'); +Route::get('agencies/{agency}/user', 'AgencyController@user')->name('agencies.user'); +Route::any('agencies/{agency}/douser', 'AgencyController@douser')->name('agencies.douser'); +Route::resource('agencies', 'AgencyController'); + +//线下报课管理 +Route::get('reports/logs', 'ReportController@logs')->name('reports.logs'); +Route::resource('reports', 'ReportController'); diff --git a/app/Api/ApiServiceProvider.php b/app/Api/ApiServiceProvider.php new file mode 100644 index 0000000..094fee0 --- /dev/null +++ b/app/Api/ApiServiceProvider.php @@ -0,0 +1,45 @@ + Middleware\Authenticate::class, + 'checkapi' => Middleware\CheckApi::class, + ]; + + public function boot() + { + } + + public function register() + { + $this->registerRouteMiddleware(); + $this->loadAdminRoutes(); + } + + protected function registerRouteMiddleware() + { + foreach ($this->routeMiddleware as $key => $middleware) { + Route::aliasMiddleware($key, $middleware); + } + } + + protected function loadAdminRoutes() + { + Route::middleware('api') + ->domain('mapi.bohaimingpin.com') + ->namespace('App\Api\Controllers') + ->group(__DIR__ . '/routes.php'); + } + + + + + + +} diff --git a/app/Api/Controllers/AccountController.php b/app/Api/Controllers/AccountController.php new file mode 100644 index 0000000..4ff4d5f --- /dev/null +++ b/app/Api/Controllers/AccountController.php @@ -0,0 +1,85 @@ +middleware('auth.api'); + $this->user = \Auth::guard('api')->user(); + $this->uid = \Auth::guard('api')->id(); +// $this->user = User::find(824); +// $this->uid = 824; + } + + public function index() + { + $rewardtotal = $this->user->account->logs()->where('type', 'cash')->where('rule_id', 2)->sum('variable'); + $freezingTotal = $this->user->account->logs()->where('type', 'cash')->where('frozen', 1)->sum('variable'); + $logs = $this->user->account->logs()->where('type', 'cash')->orderBy('created_at', 'desc')->get(); + + return [ + 'data' => [ + 'cash'=>$this->user->account->cash, + 'rewardTotal' => $rewardtotal, + 'freezingTotal' => $freezingTotal, + 'logLists' => AccountLogsResource::collection($logs), + ], + 'status' => 'SUCCESS', + 'status_code' => 200, + ]; + + } + + public function score(Request $request) + { + $type = $request->logType; + $logs = $this->user->account->logs() + ->when($type, function ($query) use ($type) { + switch ($type) { + case 'ALL': + break; + case 'PLUS': + $query->where('variable', '>', 0); + break; + case 'MINUS': + $query->where('variable', '<', 0); + break; + case 'EXPIRE': + $query->where('variable', '>', 0); + break; + default: + break; + } + }) + ->where('type', 'score') + ->orderBy('created_at', 'desc')->get(); + $scoreExplain = \Params::get('score_explain'); + + $scoreExplain = str_replace("\n", "
", $scoreExplain); + $scoreExplain = str_replace("\r", "
", $scoreExplain); + + return [ + 'data' => [ + 'score'=>$this->user->account->score, + 'scoreExplain' => $scoreExplain, + 'logLists' => AccountLogsResource::collection($logs), + ], + 'status' => 'SUCCESS', + 'status_code' => 200, + ]; + } + +} \ No newline at end of file diff --git a/app/Api/Controllers/AddressController.php b/app/Api/Controllers/AddressController.php new file mode 100644 index 0000000..7cef6a3 --- /dev/null +++ b/app/Api/Controllers/AddressController.php @@ -0,0 +1,124 @@ +middleware('auth.api'); + $this->user = \Auth::guard('api')->user(); + $this->uid = \Auth::guard('api')->id(); + + } + + /** + * 小程序收货地址列表页数据,页面初始化时请求该接口 + */ + public function index() + { + $addresses = $this->user->addresses()->orderBy('is_default', 'desc')->orderBy('id', 'desc')->get(); + return AddressResource::collection($addresses)->additional([ + 'status' => 'SUCCESS', + 'status_code' => 200, + ]); + } + + /** + * 小程序编辑收货地址,页面初始化时请求该接口 + */ + public function detail(UserAddress $address) + { + return $this->success(new AddressResource($address)); + } + + /** + * 新建保存/编辑更新操作 小程序新建、编辑页面点击保存时请求该接口。 + * @param \Illuminate\Http\Request $request + * @return array + */ + public function update(Request $request) + { + $address = []; + if ($request->id) { + $address = UserAddress::find($request->id); + } + $data = [ + 'name' => $request->name, + 'mobile' => $request->mobile, + 'province_sn' => $request->province_sn, + 'city_sn' => $request->city_sn, + 'area_sn' => $request->area_sn, + 'address' => $request->address, + ]; + if (!empty($address)) { + $res = \Address::update($address, $data); + } else { + $res = \Address::store( + [ + 'user_id' => $this->uid, + 'name' => $request->name, + 'mobile' => $request->mobile, + 'province_sn' => $request->province_sn, + 'city_sn' => $request->city_sn, + 'area_sn' => $request->area_sn, + 'address' => $request->address, + ] + ); + } + + if ($res) { + return $this->success(['msg' => '修改成功']); + } else { + return $this->failed('修改失败'); + } + + } + + + /** + * 小程序删除收货地址,地址管理页请求该接口 + */ + public function delete($id) + { + if (\Address::destroy($id)) { + return $this->success(['msg' => '操作成功']); + } else { + return $this->failed('操作失败'); + } + } + + /** + * 省市区三级联动返回数据,小程序新建/编辑收货地址中切换省市区时出现。 + * @param \Illuminate\Http\Request $request + * @return array + */ + public function areas(Request $request) + { + $psn = $request->psn; + if ($psn == 0) { + $areas = Area::where('psn', $psn)->where('depth', 1)->select(DB::raw('sn as id'), 'sn', 'psn', 'name', DB::raw('depth as type'))->get() ?? []; + } else { + $areas = Area::where(['psn' => $psn])->select(DB::raw('sn as id'), 'sn', 'psn', 'name', DB::raw('depth as type'))->get() ?? []; + } + if ($areas) { + return $this->success($areas); + } else { + return $this->failed('请选择省份/城市'); + } + } + + +} diff --git a/app/Api/Controllers/AuthController.php b/app/Api/Controllers/AuthController.php new file mode 100644 index 0000000..33fc76b --- /dev/null +++ b/app/Api/Controllers/AuthController.php @@ -0,0 +1,131 @@ +middleware('auth.api', ['except' => ['login','smsCode']]); + } + + /** + * 用户登录 + * @param Request $request [description] + * @return [type] [description] + */ + public function login(Request $request) + { + +// $info = $request->userInfo; + $code = $request->code; + + $app = app('wechat.mini_program'); + + $jscode = $app->auth->session($code); + $user = User::where('unionid', $jscode->unionid)->first(); + $token = Auth::guard('api')->login($user); + return $this->success([ + 'access_token' => $token, + 'access_type' => 'Bearer', + 'expires_in' => Auth::guard('api')->factory()->getTTL() * 60, + 'userInfo' => [ + 'uid' => $user->id ?? '', + 'avatar' => $user->info->headimgurl ?? '', + 'nickname' => $user->info->nickname ?? '', + 'openid' => $jscode->openid ?? '' + + ] + ]); + + + + } + + /** + * 刷新TOKEN + * @return [type] [description] + */ + public function refresh() + { + return $this->success([ + 'access_token' => Auth::guard('api')->refresh(true), + 'access_type' => 'Bearer', + 'expires_in' => Auth::guard('api')->factory()->getTTL() * 60, + ]); + } + + /** + * 退出登录 + * @return [type] [description] + */ + public function logout() + { + Auth::guard('api')->logout(true); + return $this->message('退出登录成功'); + } + + + /** + * 发送验证码 + * @return + */ + public function smsCode(Request $request) + { + $channel = $request->channel; + $mobile = $request->mobile; + switch ($channel) { + case 'BYCODE': + case 'FORGOT': + // 验证码登录,必须要手机号存在才行 + $validator = Validator::make($request->all(), [ + 'mobile' => 'required|mobile|exists:users', + ], [ + 'mobile.required' => '手机号码必须填写', + 'mobile.mobile' => '手机号码格式不正确', + 'mobile.exists' => '手机号码不存在', + ]); + break; + case 'BIND': + // 绑定手机号,要不存在才可以 + $validator = Validator::make($request->all(), [ + 'mobile' => 'required|mobile|unique:users', + ], [ + 'mobile.required' => '手机号码必须填写', + 'mobile.mobile' => '手机号码格式不正确', + 'mobile.unique' => '手机号码已经绑定', + ]); + break; + default: + $validator = Validator::make($request->all(), [ + 'mobile' => 'required|mobile', + ], [ + 'mobile.required' => '手机号码必须填写', + 'mobile.mobile' => '手机号码格式不正确', + ]); + break; + } + + if ($validator->fails()) { + return $this->failed($validator->errors()->first()); + } + + $res = SmsModel::verify_code($request->mobile); + if ($res !== true) { + return $this->failed($res); + } + + try { + \Sms::send($mobile, $channel); + return $this->success('验证码发送成功'); + } catch (\Exception $e) { + return $this->failed($e->getMessage()); + } + } +} diff --git a/app/Api/Controllers/CallbackController.php b/app/Api/Controllers/CallbackController.php new file mode 100644 index 0000000..1c8de7f --- /dev/null +++ b/app/Api/Controllers/CallbackController.php @@ -0,0 +1,84 @@ +handlePaidNotify(function ($message, $fail) { + $payment = Payment::where('trade_no', $message['out_trade_no'])->first(); + if (!$payment || $payment->paid_at) { + return true; + } + if ($message['return_code'] === 'SUCCESS') { + // return_code 表示通信状态,不代表支付状态 + // 用户是否支付成功 + if (array_get($message, 'result_code') === 'SUCCESS') { + $payment->state = 'SUCCESS'; + $payment->paid_at = $message['time_end']; + } elseif (array_get($message, 'result_code') === 'FAIL') { + $payment->state = 'INIT'; + } + } else { + return $fail('通信失败,请稍后再通知我'); + } + $payment->save(); // 保存订单 + $payment->order->paid(); + return true; // 返回处理完成 + }); + + return $response; + } + + /** + * 开通vip,付款回掉地址。 + * @param + * @return array + */ + public function vip() + { + $payment = app('wechat.payment.mini'); + $response = $payment->handlePaidNotify(function ($message, $fail) { + $vip_payment = VipPament::where('trade_no', $message['out_trade_no'])->first(); + if (!$vip_payment || $vip_payment->paid_at) { + return true; + } + if ($message['return_code'] === 'SUCCESS') { + // return_code 表示通信状态,不代表支付状态 + // 用户是否支付成功 + if (array_get($message, 'result_code') === 'SUCCESS') { + $vip_payment->state = 'SUCCESS'; + $vip_payment->paid_at = $message['time_end']; + } elseif (array_get($message, 'result_code') === 'FAIL') { + $vip_payment->state = 'INIT'; + } + } else { + return $fail('通信失败,请稍后再通知我'); + } + $vip_payment->save(); // 保存订单 + event(new VipPaid($vip_payment)); + return true; // 返回处理完成 + }); + + return $response; + } + +} \ No newline at end of file diff --git a/app/Api/Controllers/CartController.php b/app/Api/Controllers/CartController.php new file mode 100644 index 0000000..61f3459 --- /dev/null +++ b/app/Api/Controllers/CartController.php @@ -0,0 +1,252 @@ +middleware('auth.api'); +// $this->user = \Auth::guard('api')->user(); +// $this->uid = \Auth::guard('api')->id(); + $this->user = User::find(824); + $this->uid = 824; + } + + /** + * 小程序,购物车页面数据接口 + * + * @param + * @return array + */ + public function index() + { + $lists = Cart::where('user_id', $this->uid)->orderBy('id', 'desc')->get(); + $data = []; + foreach ($lists as $cart) { + if (!isset($carts[$cart->params->goods->seller_id])) { + $carts[$cart->params->goods->seller_id] = []; + } + if ($cart->params->stock < 1) { + $cart->delete(); + } else { + if ($cart->number > $cart->params->stock) { + $cart->number = $cart->params->stock; + $cart->save(); + } + array_push($carts[$cart->params->goods->seller_id], $cart); + } + } + + + foreach ($carts as $key => $seller_item) { + $seller_cart = []; + $seller_cart['seller'] = new CartSellerResource(Seller::find($key)); + foreach ($seller_item as $cart_item) { + $seller_cart['goods_list'][] = new CartResource($cart_item); + } + array_push($data, $seller_cart); + } + + return [ + 'data' => $data, + 'status' => 'SUCCESS', + 'status_code' => 200, + ]; + } + + /** + * 小程序,商品详情页,点击加入购物车请求接口 + * + * @param \Illuminate\Http\Request $request + * @return array + */ + public function save(Request $request) + { + $user_id = $this->uid; + $result = Cart::where(['user_id' => $user_id, 'params_id' => $request->params_id])->first(); + $params = GoodsParams::find($request->params_id); + if ($result) { + $result->number += $request->number; + $result->save(); + } else { + $result = Cart::create([ + 'user_id' => $this->uid, + 'params_id' => $request->params_id, + 'goods_id' => $params->goods_id, //保存goods_id是为了下架商品时,删除购物车 + 'number' => $request->number, + ]); + } + + if ($result) { + return $this->success(['msg' => '成功加入购物车', 'cartGoodsCount' => Cart::where('user_id', $this->uid)->count()]); + } else { + return $this->failed('加入失败'); + } + + } + + /** + * 小程序,购物车页,点击增减商品数量请求接口 + * + * @param \Illuminate\Http\Request $request + * @return array + */ + public function setnum(Request $request) + { + $cart = Cart::find($request->id); + $cart->number = $request->number; + if ($cart->save()) { + return $this->success(['msg' => '操作成功', 'number' => $cart->number]); + } else { + return $this->failed('加入失败'); + } + } + + /** + * 小程序,确认订单页请求的接口 + * + * @param \Illuminate\Http\Request $request + * @return array + */ + public function sure(Request $request) + { + $data = array(); + $carts = array(); + $cart_amount = 0; + $cart_score = 0; + $cart_freight = 0; + $address = $request->addressId ? UserAddress::find($request->addressId) : null; + foreach (explode(',', $request->cart_ids) as $key => $value) { + $cart = Cart::find($value); + if ($cart) { + if ($cart->params->stock < 1) { + $cart->delete(); + } else { + if ($cart->number < $cart->params->stock) { + if (!isset($carts[$cart->params->goods->seller_id])) { + $carts[$cart->params->goods->seller_id] = []; + } + array_push($carts[$cart->params->goods->seller_id], $cart); + } + } + } + } + foreach ($carts as $key => $seller_item) { + $seller_cart = []; + $seller_cart['seller'] = new CartSellerResource(Seller::find($key)); + $seller_cart['express'] = ['type1' => 1, 'type2' => 0]; //配送方式,type1-快递,type2-自取 + $seller_cart['remark'] = '';//买家留言 + //获取店铺运费、金额、积分小计 + $seller_total = self::sellerTotal($key, $seller_item, $address); + + //格式化单店铺小计 + foreach ($seller_total as $k => $v) { + $seller_cart['total'][$k] = number_format($v, 2); + $seller_cart['totalOriginal'][$k] = $v; + + } + + //计算全部店铺总和 + $cart_amount += $seller_total['amount']; + $cart_score += $seller_total['score']; + $cart_freight += $seller_total['freightPrice']; + + foreach ($seller_item as $cart_item) { + $seller_cart['goods_list'][] = new CartResource($cart_item); + } + array_push($data, $seller_cart); + } + + return [ + 'data' => [ + 'cartData' => $data, + 'cartTotal' => [ + 'amount' => number_format($cart_amount, 2), + 'score' => number_format($cart_score, 2), + 'freight' => number_format($cart_freight, 2), + 'freightOriginal' => $cart_freight, + 'orderPrice' => number_format($cart_amount + $cart_freight, 2), + 'orderPriceOriginal' => $cart_amount + $cart_freight + + ], + 'address' => $address ? new AddressResource($address) : [] + ], + + 'status' => 'SUCCESS', + 'status_code' => 200, + ]; + + } + + /** + * 计算店铺商品金额、运费金额、积分金额总和 + * + * @param + * @return array + */ + private function sellerTotal($seller_id, $seller_item, $address = null) + { + $amount = 0; + $freightPrice = \Params::get('default_freight'); + $heavy = 0; + $score = 0; + foreach ($seller_item as $cart_item) { + $params = GoodsParams::find($cart_item->params_id); + $amount += $cart_item->number * $params->price; + if ($params->is_free_freight == 0) { + $heavy += $cart_item->number * $params->heavy; + } + $score += $cart_item->number * $params->score; + } + + if ($heavy === 0) { + $freightPrice = 0; //包邮 + } else { + //计算每个商户订单的运费 + if (!empty($address)) { + $freight = Freight::where(['seller_id' => $seller_id, 'area_id' => $address->province->id])->first(); + if ($freight) { + $freightPrice = $freight->basic; + if ($freight->heavy < $heavy) { + $freightPrice += ceil($heavy - $freight->heavy) * $freight->added; + } + } + } + } + + return [ + 'freightPrice' => $freightPrice, + 'score' => $score, + 'amount' => $amount - $score, + ]; + } + + /** + * 小程序,购物车页面,点击删除商品请求的接口 + * + * @param \Illuminate\Http\Request $request + * @return array + */ + public function delete(Cart $cart) + { + + if ($cart->delete()) { + return $this->success(['msg' => '操作成功']); + } else { + return $this->failed('加入失败'); + } + } + +} diff --git a/app/Api/Controllers/Controller.php b/app/Api/Controllers/Controller.php new file mode 100644 index 0000000..92cedfe --- /dev/null +++ b/app/Api/Controllers/Controller.php @@ -0,0 +1,12 @@ +middleware('auth.api'); +// $this->user = \Auth::guard('api')->user(); +// $this->uid = \Auth::guard('api')->id(); + $this->user = User::find(824); + $this->uid = 824; + } + + /** + * 用户满仓任务完成信息接口,小程序访问满仓页面时请求该接口。 + * @param + * @return array + */ + public function index() + { + $isfull = $this->user->account->act_a > 0 ? true : false;//是否满仓 + $fullOrder = Order::where(['user_id' => $this->uid, 'item_type' => 'FULL_GIFT'])->whereRaw('substring(cast(status as char),1,1) = 1')->first();//满仓订单 + $canCreateOrder = !$fullOrder && $isfull ? true : false;//是否可以创建满仓订单 + $log = UserAccountLog::where('user_id', $this->uid)->where('rule_id', 4)->orderBy('id', 'asc')->first();//完成时间 + $finished_share_num = $this->user->identity->childrentime([Carbon::today()->toDateTimeString(), Carbon::tomorrow()->toDateTimeString()]);//完成数量 + return [ + 'data' => [ + 'isfull' => $isfull, + 'finished_share_num' => $finished_share_num, + 'unfinished_share_num' => $finished_share_num >= 10 ? 0 : 10 - $finished_share_num, + 'finished_at' => $log->created_at ?? '', + 'fullOrder' => [ + 'canCreateOrder' => $canCreateOrder, + 'order_id' => $fullOrder->id ?? '', + ], + ], + 'status' => 'SUCCESS', + 'status_code' => 200, + ]; + + } +} \ No newline at end of file diff --git a/app/Api/Controllers/GoodsController.php b/app/Api/Controllers/GoodsController.php new file mode 100644 index 0000000..00cbb65 --- /dev/null +++ b/app/Api/Controllers/GoodsController.php @@ -0,0 +1,300 @@ +middleware('auth.api'); +// $this->user = \Auth::guard('api')->user(); +// $this->uid = \Auth::guard('api')->id(); + $this->user = User::find(824); + $this->uid = 824; + } + + public function index() + { + $addresses = User::find(824)->addresses()->orderBy('is_default', 'desc')->orderBy('id', 'desc')->get(); + return $this->success($addresses); + } + + /** + * 商品详情 小程序商品详情页请求该接口。 + * @param \App\Models\Goods $good + * @return array + */ + public function show(Goods $good,Request $request) + { + $type = $request->get('type', 'cashScore'); + if($type == 'score'){ + $params_count = $good->params()->where('status', 1)->where('stock', '>', 0)->where('score', '>', 0)->whereRaw('price = score')->count(); + if($params_count == 0){ + return $this->failed('商品已下架'); + }else{ + return $this->success(new GoodsParamsScoreDetailResource($good)); + } + }elseif($type == 'cashScore'){ + $params_count = $good->params()->where('status', 1)->where('stock', '>', 0)->where('score', '>', 0)->whereRaw('price > score')->count(); + if($params_count == 0){ + return $this->failed('商品已下架'); + }else{ + return $this->success(new GoodsParamsDetailResource($good)); + } + + } + } + + /** + * 相关商品 小程序商品详情页请求该接口。 + * @param \App\Models\Goods $good + * @return array + */ + public function related(Goods $good) + { + $data = $good->seller->goods()->where('status', 1)->limit(6)->get(); + return GoodsListResource::collection($data)->additional([ + 'status' => 'SUCCESS', + 'status_code' => 200, + ]); + } + + /** + * 商品列表 小程序点击某一分类页面请求该接口。 + * @param \Illuminate\Http\Request $request + * @return array + */ + public function lists(Request $request) + { + $category = $request->get('categoryId', ''); + $title = $request->get('title', ''); + $type = $request->get('type', 'cashScore'); + $data = []; + switch ($type){ + case 'cash': + $data = GoodsParams::whereHas('goods', function ($query) use($title,$category) + { + return $query->when($category, function ($query) use ($category) { + $category_ids = Category::where('id',$category)->orWhere('parent_id', $category)->pluck('id'); + return $query->whereIn('goods.category_id', $category_ids); + })->when($title, function ($query) use ($title) { + return $query->where('goods.title', 'like', "%$title%"); + })->where('status',1); + })->where('status', 1)->where('stock', '>', 0)->where('score', '=', 0)->where('price', '>', 0)->select('goods_id', DB::raw('any_value(stock) as stock'), DB::raw('any_value(original) as original'),DB::raw('any_value(status) as status'), DB::raw('any_value(price) as price'), DB::raw('any_value(score) as score'), DB::raw('any_value(id) as id')) + ->groupBy('goods_id') + ->orderBy('price','asc') + ->with('goods') + ->paginate(20); + break; + case 'score': + $data = GoodsParams::whereHas('goods', function ($query) use($title,$category) + { + return $query->when($category, function ($query) use ($category) { + $category_ids = Category::where('id',$category)->orWhere('parent_id', $category)->pluck('id'); + return $query->whereIn('goods.category_id', $category_ids); + })->when($title, function ($query) use ($title) { + return $query->where('goods.title', 'like', "%$title%"); + })->where('status',1); + })->where('status', 1)->where('stock', '>', 0)->where('score', '>', 0)->whereRaw('price = score')->select('goods_id', DB::raw('any_value(stock) as stock'), DB::raw('any_value(original) as original'),DB::raw('any_value(status) as status'), DB::raw('any_value(price) as price'), DB::raw('any_value(score) as score'), DB::raw('any_value(id) as id')) + ->groupBy('goods_id') + ->orderBy('price','asc') + ->with('goods') + ->paginate(20); + break; + case 'cashScore': + $data = GoodsParams::whereHas('goods', function ($query) use($title,$category) + { + return $query->when($category, function ($query) use ($category) { + $category_ids = Category::where('id',$category)->orWhere('parent_id', $category)->pluck('id'); + return $query->whereIn('goods.category_id', $category_ids); + })->when($title, function ($query) use ($title) { + return $query->where('goods.title', 'like', "%$title%"); + })->where('status',1); + })->where('status', 1)->where('stock', '>', 0)->where('score', '>', 0)->whereRaw('price > score')->select('goods_id', DB::raw('any_value(stock) as stock'), DB::raw('any_value(original) as original'),DB::raw('any_value(status) as status'), DB::raw('any_value(price) as price'), DB::raw('any_value(score) as score'), DB::raw('any_value(id) as id')) + ->groupBy('goods_id') + ->with('goods') + ->orderBy('price','asc') + ->paginate(20); + break; + } + return GoodsParamsListResource::collection($data)->additional([ + 'status' => 'SUCCESS', + 'status_code' => 200, + ]); + } + + + /** + * 商品分类 小程序点击某一分类页面请求该接口。 + * @param \Illuminate\Http\Request $request + * @return array + */ + public function category(Request $request) + { + $categoryId = $request->get('id', ''); + $categoryLists = Category::where('parent_id', 1)->orderBy('sort', 'desc')->orderBy('created_at', 'desc')->get(); + $currentCategory = Category::find($categoryId); + return [ + 'data' => [ + 'currentCategory' => new ChannelIndexResource($currentCategory), + 'categoryLists' => ChannelIndexResource::collection($categoryLists), + ], + 'status' => 'SUCCESS', + 'status_code' => 200, + ]; + } + + + /** + * 商品满仓列表 小程序点击满仓赠品请求该接口。 + * @param \Illuminate\Http\Request $request + * @return array + */ + public function fullLists(Request $request) + { + $title = $request->get('title', ''); + $fullGoodsLists = Goods::where('status', 1) + ->when($title, function ($query) use ($title) { + return $query->where('title', 'like', "%$title%"); + }) + ->whereHas('params', function ($query) { + return $query->where('stock', '>', 0)->where('status', 1); + }) + ->where('is_mall_gift', 1)->get(); + + $isfull = $this->user->account->act_a > 0 ? true : false; + $fullOrder = Order::where(['user_id' => $this->uid, 'item_type' => 'FULL_GIFT'])->whereRaw('substring(cast(status as char),1,1) = 1')->first(); + $canCreateOrder = !$fullOrder && $isfull ? true : false; + return [ + 'data' => [ + 'isfull' => $isfull, + 'fullGoodsLists' => GoodsGiftListResource::collection($fullGoodsLists), + 'canCreateOrder' => $canCreateOrder, + ], + 'status' => 'SUCCESS', + 'status_code' => 200, + ]; + } + + /** + * vip赠品列表 小程序点击vip赠品请求该接口。 + * @param \Illuminate\Http\Request $request + * @return array + */ + public function vipLists(Request $request) + { + $title = $request->get('title', ''); + $vipGoodsLists = Goods::where('status', 1) + ->when($title, function ($query) use ($title) { + return $query->where('title', 'like', "%$title%"); + }) + ->whereHas('params', function ($query) { + return $query->where('stock', '>', 0)->where('status', 1); + }) + ->where('is_seller_gift', 1)->get(); + + //最近的上级总裁的商品。 + $parentMallLists = []; + $parent_ids = array_reverse(array_filter(explode(',', $this->user->relation->bloodline))); + foreach ($parent_ids as $key => $parent_id) { + $parent_seller[$key] = Seller::where(['status' => 1, 'user_id' => $parent_id])->first(); + if ($parent_seller[$key]) { + $parentMallLists = $parent_seller[$key]->goods()->where('is_seller_gift', 1)->get(); + if ($parentMallLists && $parentMallLists->count() > 0) { + break; + } + } + } + + + $defaultMallLists = Goods::where('status', 1)->whereHas('params', function ($query) { + return $query->where('stock', '>', 0)->where('status', 1); + }) + ->where('is_seller_gift', 1)->where('seller_id', 1)->get(); + + $vipPay = VipPament::where(['user_id' => $this->uid, 'state' => 'SUCCESS'])->first(); + + if ($vipPay && $vipPay->type == 'CDKEY') { + $vipGoodsLists = !empty($parentMallLists) && $parentMallLists->count() > 0 ? [] : $defaultMallLists; + } + + $isVipUser = $vipPay ? true : false; + $vipOrder = Order::where(['user_id' => $this->uid, 'item_type' => 'VIP_GIFT'])->whereRaw('substring(cast(status as char),1,1) = 1')->first(); + $canCreateOrder = !$vipOrder && $isVipUser ? true : false; + + return [ + 'data' => [ + 'parentMallLists' => !empty($parentMallLists) && $parentMallLists->count() > 0 ? GoodsGiftListResource::collection($parentMallLists) : [],//最近上级的店铺赠品 + 'vipGoodsLists' => !empty($vipGoodsLists) && $vipGoodsLists->count() > 0 ? GoodsGiftListResource::collection($vipGoodsLists) : [],//可选的全部赠品 + 'isVipUser' => $isVipUser,//是否是vip + 'canCreateOrder' => $canCreateOrder//是否可以创建订单 + ], + 'status' => 'SUCCESS', + 'status_code' => 200, + ]; + } + + /** + * 满仓赠品详情 小程序点击满仓赠品查看赠品详情请求该接口。 + * @param \Illuminate\Http\Request $request + * @return array + */ + public function fullGift(Goods $good) + { + $isfull = $this->user->account->act_a > 0 ? true : false; + $fullOrder = Order::where(['user_id' => $this->uid, 'item_type' => 'FULL_GIFT'])->whereRaw('substring(cast(status as char),1,1) = 1')->first(); + $canCreateOrder = !$fullOrder && $isfull ? true : false; + return [ + 'data' => [ + 'isfull' => $isfull, + 'canCreateOrder' => $canCreateOrder, + 'goods' => new GoodsGiftDetailResource($good), + ], + 'status' => 'SUCCESS', + 'status_code' => 200, + ]; + } + + /** + * vip赠品详情 小程序点击vip赠品查看赠品详情请求该接口。 + * @param \Illuminate\Http\Request $request + * @return array + */ + public function vipGift(Goods $good) + { + $vipPay = VipPament::where(['user_id' => $this->uid, 'state' => 'SUCCESS'])->first(); + $isVipUser = $vipPay ? true : false; + + $vipOrder = Order::where(['user_id' => $this->uid, 'item_type' => 'VIP_GIFT'])->whereRaw('substring(cast(status as char),1,1) = 1')->first(); + $canCreateOrder = !$vipOrder && $isVipUser ? true : false; + + return [ + 'data' => [ + 'goods' => new GoodsGiftDetailResource($good), + 'isVipUser' => $isVipUser,//是否是vip + 'canCreateOrder' => $canCreateOrder//是否可以创建订单 + ], + 'status' => 'SUCCESS', + 'status_code' => 200, + ]; + } + +} diff --git a/app/Api/Controllers/IndexController.php b/app/Api/Controllers/IndexController.php new file mode 100644 index 0000000..1e75861 --- /dev/null +++ b/app/Api/Controllers/IndexController.php @@ -0,0 +1,65 @@ +where('status', 1); + })->where('status', 1)->where('stock', '>', 0)->where('score', '>', 0)->whereRaw('price > score')->select('goods_id', DB::raw('any_value(stock) as stock'), DB::raw('any_value(status) as status'), DB::raw('any_value(price) as price'), DB::raw('any_value(score) as score'), DB::raw('any_value(id) as id')) + ->groupBy('goods_id') + ->orderBy('price', 'asc') + ->paginate(10); + + + + $page = $request->page ?? 1; //获取当前页码 + + if ($page > 1) { + //页码大于1,AJAX调用分页 + if ($goodsLists->count() > 0) { + return [ + 'data' => [ + 'goodsLists' => GoodsParamsListResource::collection($goodsLists), + ], + 'status' => 'SUCCESS', + 'status_code' => 200, + ]; + } else { + //无内容提示到最后一页 + return $this->failed('已经到最后一页'); + } + }else{ + $sellers = Seller::with(['storage'])->orderBy('sort', 'desc')->limit(12)->get(); + $recommendSellerGoods = GoodsParams::whereHas('goods', function ($query) { + return $query->where('status', 1)->where('seller_id', 1); + })->where('status', 1)->where('stock', '>', 0)->where('score', '>', 0)->whereRaw('price > score')->select('goods_id', DB::raw('any_value(stock) as stock'), DB::raw('any_value(status) as status'), DB::raw('any_value(price) as price'), DB::raw('any_value(score) as score'), DB::raw('any_value(id) as id')) + ->groupBy('goods_id') + ->orderBy('price', 'asc') + ->limit(8)->get(); + + return [ + 'data' => [ + 'goodsLists' => GoodsParamsListResource::collection($goodsLists), + 'sellers' => SellerListResource::collection($sellers), + 'recommendSellerGoods' => GoodsParamsListResource::collection($recommendSellerGoods) + ], + 'status' => 'SUCCESS', + 'status_code' => 200, + ]; + } + + + } +} diff --git a/app/Api/Controllers/KeysController.php b/app/Api/Controllers/KeysController.php new file mode 100644 index 0000000..60007b2 --- /dev/null +++ b/app/Api/Controllers/KeysController.php @@ -0,0 +1,275 @@ +middleware('auth.api'); +// $this->user = \Auth::guard('api')->user(); +// $this->uid = \Auth::guard('api')->id(); + $this->user = User::find(824); + $this->uid = 824; + } + public function index(Request $request) + { + $user = $this->user; + + if ($user->identity->identity_id == 0) { + return $this->failed('请开通VIP后继续操作'); + } + // 已使用 USED 未使用 EMPTY + $status = $request->status ?? 'EMPTY'; + + $keys = Cdkey::where('belong_uid', $user->id) + ->when($status, function ($query) use ($status) { + if ($status == 'USED') { + $query->whereNotNull('used_at'); + } elseif ($status == 'EMPTY') { + $query->whereNull('used_at'); + } + }) + ->get(); + + $useNum = Cdkey::where('belong_uid', $user->id) + ->whereNotNull('used_at') + ->count(); + $notUseNum = Cdkey::where('belong_uid', $user->id) + ->whereNull('used_at') + ->count(); + return view('keys.index', compact('keys', 'status', 'useNum', 'notUseNum')); + } + + public function show(Cdkey $cdkey) + { + if ($cdkey->belong_uid != $this->uid) { + return $this->failed('没有权限查看激活码'); + } + $code = \App\Helpers\CDKEY::generator($cdkey->code, 'svg', 129); + return view('keys.show', compact('code', 'cdkey')); + } + + public function manage(Request $request) + { + $user = $this->user; + if ($user->id == 1757) { + $user = User::find(62); + } + if ($user->identity->identity_id < 2) { + return $this->failed('没有激活码管理权限'); + } + $count = KeysApply::where('user_id', $user->id)->whereIn('status', [0, 1])->sum('num'); + return view('keys.manage', compact('count')); + } + + + public function doManage(Request $request) + { + $user = $this->user; + if ($user->id == 1757) { + $user = User::find(62); + } + if ($user->identity->identity_id < 2) { + return $this->failed('没有激活码管理权限'); + } + + $data = $request->all(); + $data['user_id'] = $user->id; + $apply = KeysApply::create($data); + if ($apply) { + if ($apply->is_print == 0) { + if (self::callback($apply->user_id)) { + $apply->status = 1; + $apply->save(); + return $this->success('申请成功'); + } + } + return $this->success('申请成功'); + } else { + return $this->failed('申请失败'); + } + } + + + /** + * 支付完成之后,直接生产虚拟卡 + * @Author: + * @Date:2018-12-23T17:47:51+0800 + * @return function [description] + */ + public function callback($user_id) + { + $codes = []; + for ($i = 0; $i < 100; $i++) { + $codes[$i]['belong_uid'] = $user_id; + $codes[$i]['code'] = $this->random(); + $codes[$i]['is_print'] = 0; + $codes[$i]['effective_at'] = now(); + $codes[$i]['created_at'] = now(); + $codes[$i]['updated_at'] = now(); + } + return Cdkey::insert($codes); + } + + /** + * 产生随机字串,可用来自动生成密码 17010 + * @Author: + * @Date:2018-09-14T17:00:34+0800 + * @param integer $len [description] + * @return [type] [description] + */ + private function random($len = 10): string + { + $chars = 'ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz23456789'; + $chars = str_repeat($chars, 4); + $chars = str_shuffle($chars); + $str = substr($chars, 0, $len); + return $str; + } + + public function getCode(Cdkey $cdkey) + { + $user = $this->user; + $URL = \App\Helpers\CDKEY::encode($cdkey->code); + + $qrCode = QrCode::format('png')->size(235)->margin(0)->generate($URL); + $fileUrl = '/home/wwwroot/Wow/storage/app/public/headimgurl/' . $user->id . '.jpg'; + if (!file_exists($fileUrl)) { + $headimgurl = file_get_contents($user->info->headimgurl); + file_put_contents($fileUrl, $headimgurl); + } + + $headimg = self::getCircle(Image::make('storage/headimgurl/' . $user->id . '.jpg')); + $image = Image::make('img/share_bg2018.jpg'); //获取背景图片 + // ->insert(sprintf('%010d', $cdkey->id), 'bottom-left', 314, 200) + $image->text('VIP' . sprintf('%09d', $cdkey->id), 270, 880, function ($font) { + $font->file('fonts/yahei.ttf')->color('#333')->size(30); + }); + return $image + ->insert($qrCode, 'top-left', 257, 610) + ->insert($headimg, 'bottom-left', 314, 200) + ->response('jpg'); + } + + public function getCircle($img) + { + $r = $img->width() / 2; + $new = Image::canvas(164, 164); + for ($x = 0; $x < $img->width(); $x++) { + for ($y = 0; $y < $img->height(); $y++) { + $c = $img->pickColor($x, $y, 'array'); + if (((($x - $r) * ($x - $r) + ($y - $r) * ($y - $r)) < ($r * $r))) { + $new->pixel($c, $x, $y); + } + } + } + return $new; + } + + public function order() + { + $user = $this->user; + + if ($user->identity->identity_id == 0) { + return $this->failed('请开通VIP后继续操作'); + } + + $order = KeysOrder::create([ + 'user_id' => $user->id, + 'type' => '', + 'amount' => 990, + ]); + + return $this->success(['orderid' => $order->id]); + + } + + public function giving(Request $request) + { + $user_id = $request->user_id ?? ''; + if (!$user_id || !is_numeric($user_id)) { + return $this->failed('请输入正确的编号'); + } + $user = User::find($user_id); + if (!$user || $user->identity->identity_id == 0) { + return $this->failed('用户不存在或不是会员'); + } + $order = KeysOrder::create([ + 'user_id' => $user->id, + 'type' => '', + 'amount' => 990, + ]); + return $this->success(['orderid' => $order->id, 'nickname' => $user->info->nickname, 'user_id' => $user->id]); + } + + public function balance(Request $request, KeysOrder $order) + { + if ($this->user->paypass) { + if ($this->user->paypass !== md5($request->paypass)) { + return $this->failed('支付密码验证失败'); + } + } else { + return $this->failed('请您先设置支付密码', route('settings.pwd')); + } + + $order = KeysOrder::where('trade_no', $request->trade_no)->first(); + if ($this->user->account->cash < $order->amount) { + return $this->failed('账户余额不足'); + } + + try { + DB::transaction(function () use ($order) { + $this->user->rule('balance_pay', -$order->amount, false, $order->trade_no); + $order->state = 'SUCCESS'; + $order->paid_at = Carbon::now(); + $order->save(); + event(new \App\Events\KeysPaid($order)); + }); + } catch (\Exception $e) { + return $this->failed($e->getmessage()); + } + return $this->success('支付成功'); + } + + public function wechat(Request $request, KeysOrder $order) + { + $user = $this->user; + $openid = $user->openid; + if ($user->main_id > 0) { + $openid = $user->mainuser->openid; + } + + $app = app('wechat.payment'); + $result = $app->order->unify([ + 'body' => '申请激活码', + 'out_trade_no' => $order->trade_no, + 'total_fee' => $order->amount * 100, + 'notify_url' => route('notify.keys'), + 'trade_type' => 'JSAPI', + 'openid' => $openid, + ]); + + $json = $app->jssdk->bridgeConfig($result['prepay_id']); + + return view('keys.pay', compact('order', 'json')); + } + +} \ No newline at end of file diff --git a/app/Api/Controllers/MessageController.php b/app/Api/Controllers/MessageController.php new file mode 100644 index 0000000..92c679e --- /dev/null +++ b/app/Api/Controllers/MessageController.php @@ -0,0 +1,36 @@ +middleware('auth.api'); + $this->user = \Auth::guard('api')->user(); + $this->uid = \Auth::guard('api')->id(); + } + + /** + * 小程序我的订单列表请求该接口。 + * @param + * @return array + */ + public function index() + { + $orders = Order::where('user_id', $this->uid) + ->where('state', '<>', Order::ORDER_CLOSED) + ->orderBy('id', 'desc') + ->get(); + return OrdersListResource::collection($orders)->additional([ + 'status' => 'SUCCESS', + 'status_code' => 200, + ]); + } + + /** + * 小程序查看订单详情请求该接口。 + * @param $orderid + * @return array + */ + public function show($id) + { + $order = Order::find($id); + return [ + 'data' => new OrdersListResource($order), + 'status' => 'SUCCESS', + 'status_code' => 200, + ]; + } + + /** + * 小程序取消订单该接口。 + * @param $orderid + * @return array + */ + public function delete($id) + { + $order = Order::find($id); + try { + $order->close(); + return $this->success(['msg' => '签收成功']); + } catch (\Exception $e) { + return $this->failed('签收失败' . $e->getmessage()); + } + } + + /** + * 小程序签收订单请求该接口。 + * @param $orderid + * @return array + */ + public function sign($id) + { + $order = Order::find($id); + try { + $order->signin(); + return $this->success(['msg' => '签收成功']); + } catch (\Exception $e) { + return $this->failed('签收失败' . $e->getmessage()); + } + } + + /** + * 小程序物流跟踪请求该接口。 + * @param $orderid + * @return array + */ + public function logistic($id) + { + $order = Order::find($id); + $message = Logistic::getMessage($order->express->company ?? '', $order->express->number ?? ''); //类型csn,编号 + + return [ + 'data' => [ + 'order_info' => new OrdersListResource($order), + 'logistic_info' => [ + 'code' => $message['code'], + 'name' => $message['code'] == 'OK' ? $message['name'] : '', + 'no' => $message['code'] == 'OK' ? $message['no'] : '', + 'logisticLists' => $message['code'] == 'OK' ? $message['list'] : [], + ], + ], + 'status' => 'SUCCESS', + 'status_code' => 200, + ]; + } + + /** + * 小程序购物车下单确认订单数据接口 + * 购物车下单,每个店铺产生一个订单,order表中的订单类型为商品订单GOODS,order表中的订单商品id为0; + * 商品订单GOODS,商家结算运费=用户支付运费。 + * @param \Illuminate\Http\Request $request + * @return array + */ + public function cartSure(Request $request) + { + try { + DB::transaction(function () use ($request) { + + $otherParams = $request->otherParams; + $carts = array(); + $address = UserAddress::find($request->addressId); + foreach (explode(',', $request->cart_ids) as $key => $value) { + $cart = Cart::find($value); + if ($cart) { + if ($cart->params->stock < 1) { + $cart->delete(); + } else { + if ($cart->number < $cart->params->stock) { + if (!isset($carts[$cart->params->goods->seller_id])) { + $carts[$cart->params->goods->seller_id] = []; + } + array_push($carts[$cart->params->goods->seller_id], $cart); + } + } + } + } + + $items = array(); + + foreach ($carts as $key => $seller_item) { + //获取店铺运费、金额、积分小计 + $seller_total[$key] = self::sellerTotal($key, $seller_item, $address); + + $score_order[$key] = $seller_total[$key]['score']; + //账户积分 + if ($this->user->account->score < $seller_total[$key]['score']) { + throw new OrderException('积分不足'); + } + + $express_type[$key] = 1; + $remark[$key] = ''; + $items[$key] = array(); + //店铺配送方式及店铺留言 + foreach ($otherParams as $other) { + if ($other['seller_id'] === $key) { + $express_type[$key] = $other['express']; + $remark[$key] = $other['remark']; + break; + } + } + + foreach ($seller_item as $cart_item) { + $params = GoodsParams::find($cart_item->params_id); + array_push($items[$key], new OrderDetail(['goods' => $params, 'number' => $cart_item->number])); + $cart_item->delete(); + } + + //Orders::create(用户id,店铺id,订单类型及赠品id,订单商品,收货地址,买家留言,商品总价,可兑换积分,店铺总运费,配送方式,结算总运费) + \Orders::create($this->uid, $key, ['type' => 'GOODS', 'id' => 0], $items[$key], $address, $remark[$key], null, $score_order[$key], $seller_total[$key]['freightPrice'], $express_type[$key], $seller_total[$key]['freightPrice']); + } + }); + $order = Order::where('user_id', $this->uid)->where('state', 'UNPAY')->orderBy('created_at', 'desc')->first(); + return [ + 'data' => ['orderid' => $order->id, 'actualPrice' => $order->total - $order->score], + 'status' => 'SUCCESS', + 'status_code' => 200, + ]; + } catch (\Exception $e) { + return [ + 'msg' => $e->getmessage(), + 'status' => 'ERROR', + 'status_code' => 400, + ]; + + } + } + + /** + * 购物车多店铺生成多订单,计算店铺商品金额、运费金额、积分金额总和 + * @param + * @return array + */ + private function sellerTotal($seller_id, $seller_item, $address = null) + { + $amount = 0; + $freightPrice = \Params::get('default_freight'); + $heavy = 0; + $score = 0; + foreach ($seller_item as $cart_item) { + $params = GoodsParams::find($cart_item->params_id); + $amount += $cart_item->number * $params->price; + if ($params->is_free_freight == 0) { + $heavy += $cart_item->number * $params->heavy; + } + $score += $cart_item->number * $params->score; + } + + if ($heavy === 0) { + $freightPrice = 0; //包邮 + } else { + //计算每个商户订单的运费 + if (!empty($address)) { + $freight = Freight::where(['seller_id' => $seller_id, 'area_id' => $address->province->id])->first(); + if ($freight) { + $freightPrice = $freight->basic; + if ($freight->heavy < $heavy) { + $freightPrice += ceil($heavy - $freight->heavy) * $freight->added; + } + } + } + } + + return [ + 'freightPrice' => $freightPrice, + 'score' => $score, + 'amount' => $amount - $score, + ]; + } + + /** + * 单品立即购买,包括普通商品,vip赠品,满仓赠品 + * @param + * @return array + */ + public function buyNow(Request $request) + { + $address = $request->addressId ? UserAddress::find($request->addressId) : null; + $params_id = $request->params_id; + $number = $request->number; + $item_type = $request->item_type; + $params = GoodsParams::find($params_id); + + $seller = Seller::find($params->goods->seller_id); + + $amount = $params->price * $number; + $score = 0; + + $freightPrice = \Params::get('default_freight'); + + if ($item_type == 'VIP_GIFT') { + //确认是否有领取权限 + if (self::canTakeVipGift() !== true) { + return $this->failed('没有权限领取'); + } + $amount = 0; + $freightPrice = 9; //赠品固定运费9元 + + } elseif ($item_type == 'FULL_GIFT') { + //确认是否有领取权限 + if (self::canTakeFullGift() !== true) { + return $this->failed('没有权限领取'); + } + $amount = 0; + //计算运费 + $heavy = $number * $params->heavy; + $freightPrice = self::freightPrice($seller->id, $heavy, $address); + + } elseif ($item_type == 'GOODS') { + $score = $params->score * $number; + $amount -= $score; + //计算运费 + $heavy = $number * $params->heavy; + $freightPrice = self::freightPrice($seller->id, $heavy, $address); + } + return [ + 'data' => [ + 'seller' => new CartSellerResource($seller), + 'goods' => new BuyNowGoodsResource($params), + 'number' => $number, + 'item_type' => $item_type, + 'total' => [ + 'amount' => number_format($amount, 2), + 'score' => number_format($score, 2), + 'freight' => $freightPrice, + 'freightOriginal' => $freightPrice, + 'orderPrice' => $amount + $freightPrice, + + ], + 'express' => [ + 'type1' => 1, + 'type2' => 0, + ], + 'address' => $address ? new AddressResource($address) : [], + ], + + 'status' => 'SUCCESS', + 'status_code' => 200, + ]; + + } + + /** + * 单品生成订单,,包括商品订单、vip赠品订单、满仓赠品订单 + * @param + * @return array + */ + public function save(Request $request) + { + try { + DB::transaction(function () use ($request) { + //收货地址 + $address = UserAddress::find($request->addressId); + + //请求参数 + $params_id = $request->params_id; + $number = $request->number; + $express_type = $request->express_type; + $remark = $request->remark; + $item_type = $request->item_type; + + //立即购买的商品规格 + $params = GoodsParams::find($params_id); + + //商户id + $seller_id = $params->goods->seller_id; + + //积分计算 + $score = $params->score * $number; + + $score_order = 0; + + if ($item_type == 'GOODS') { + $score_order = $score; + } + + if ($this->user->account->score < $score_order) { + throw new OrderException('积分不足'); + } + + //运费计算 + $heavy = $number * $params->heavy; + $freightPrice = self::freightPrice($seller_id, $heavy, $address); + + //商品详情 + $items = array(); + array_push($items, new OrderDetail(['goods' => $params, 'number' => $number])); + + //订单类型 GOODS:商品订单 VIP_GIFT:赠品订单 FULL_GIFT:满仓订单 + $order_item = [ + 'type' => $item_type, + 'id' => $item_type == 'GOODS' ? 0 : $params->id, + ]; + + //生成订单 + \Orders::create($this->uid, $seller_id, $order_item, $items, $address, $remark, null, $score_order, $freightPrice, $express_type, $freightPrice); + + }); + $order = Order::where('user_id', $this->uid)->where('state', 'UNPAY')->orderBy('created_at', 'desc')->first(); + return [ + 'data' => ['orderid' => $order->id, 'actualPrice' => $order->total - $order->score], + 'status' => 'SUCCESS', + 'status_code' => 200, + ]; + } catch (\Exception $e) { + return [ + 'msg' => $e->getmessage(), + 'status' => 'ERROR', + 'status_code' => 400, + ]; + + } + } + + /** + * 单品订单运费计算 + * @param + * @return array + */ + private function freightPrice($seller_id, $heavy, $address = null) + { + //运费计算 + $freightPrice = \Params::get('default_freight'); + + if ($heavy === 0) { + $freightPrice = 0; //包邮 + } else { + //计算每个商户订单的运费 + if (!empty($address)) { + $freight = Freight::where(['seller_id' => $seller_id, 'area_id' => $address->province->id])->first(); + if ($freight) { + $freightPrice = $freight->basic; + if ($freight->heavy < $heavy) { + $freightPrice = ceil($heavy - $freight->heavy) * $freight->added; + } + } + } + } + + return $freightPrice; + } + + /** + * 验证是否可以领取vip赠品 + * @param + * @return boolean + */ + private function canTakeVipGift() + { + $vipPay = VipPament::where(['user_id' => $this->uid, 'state' => 'SUCCESS'])->first(); + $isVipUser = $vipPay ? true : false; + $vipOrders = Order::where(['user_id' => $this->uid, 'item_type' => 'VIP_GIFT'])->whereRaw('substring(cast(status as char),1,1) = 1')->first(); + $canTakeVipGift = !$vipOrders && $isVipUser ? true : false; + return $canTakeVipGift; + } + + /** + * 验证是否可以领取满仓赠品 + * @param + * @return boolean + */ + private function canTakeFullGift() + { + $isfull = $this->user->account->act_a > 0 ? true : false; + $fullOrder = Order::where(['user_id' => $this->uid, 'item_type' => 'FULL_GIFT'])->whereRaw('substring(cast(status as char),1,1) = 1')->first(); + $canTakeFullGift = !$fullOrder && $isfull ? true : false; + return $canTakeFullGift; + } +} diff --git a/app/Api/Controllers/PayController.php b/app/Api/Controllers/PayController.php new file mode 100644 index 0000000..9dfde81 --- /dev/null +++ b/app/Api/Controllers/PayController.php @@ -0,0 +1,64 @@ +middleware('auth.api'); + $this->user = \Auth::guard('api')->user(); + $this->uid = \Auth::guard('api')->id(); + } + + private function getpayOrder(Order $order, $type) + { + $payOrder = Payment::create([ + 'order_id' => $order->id, + 'type' => $type, + 'amount' => $order->total - $order->score, + ]); + return $payOrder; + } + + public function index(Request $request) + { + + $orderid = $request->orderId; + $order = Order::find($orderid); + +// $app = app('wechat.mini_program'); +// $wechatMessage = $app->auth->session($request->code); +// $openid = $wechatMessage->openid; + + $openid = $request->openid; + $payOrder = $this->getpayOrder($order, 'WECHAT'); + $payment = app('wechat.payment.mini'); + $result = $payment->order->unify([ + 'body' => '商城订单', + 'out_trade_no' => $payOrder->trade_no, + 'total_fee' => 0.01 * 100, + 'notify_url' => 'http://mapi.bohaimingpin.com/callback/index', + 'trade_type' => 'JSAPI', + 'openid' => $openid, + ]); + + if ($result['return_code'] == 'SUCCESS' && isset($result['prepay_id'])) { + $json = $payment->jssdk->bridgeConfig($result['prepay_id']); + return $this->success($json); + } else { + return $this->failed($result['return_msg']); + } + } +} \ No newline at end of file diff --git a/app/Api/Controllers/SellersController.php b/app/Api/Controllers/SellersController.php new file mode 100644 index 0000000..d9301d6 --- /dev/null +++ b/app/Api/Controllers/SellersController.php @@ -0,0 +1,97 @@ +middleware('auth.api'); +// $this->user = \Auth::guard('api')->user(); +// $this->uid = \Auth::guard('api')->id(); + $this->user = User::find(824); + $this->uid = 824; + } + + public function index() + { +// if ($this->user->identity->identity_id == 0) { +// return $this->failed('请开通VIP后继续操作'); +// } + + $sellers = Seller::with(['storage'])->get(); + + return SellerListResource::collection($sellers)->additional([ + 'status' => 'SUCCESS', + 'status_code' => 200, + ]); + } + + public function show(Seller $seller) + { +// if ($this->user->identity->identity_id == 0) { +// return $this->failed('请开通VIP后继续操作'); +// } + + $hotGoods = Goods::with(['storage']) + ->where('status', 1) + ->where('seller_id', $seller->id) + ->where('status', 1) + ->whereHas('params', function ($query) { + return $query->where('stock', '>', 0)->where('status', 1)->where('score', '>', 0)->whereRaw('price > score'); + }) + ->select('id', 'title', 'description', 'storage_id', 'score') + ->orderBy('created_at', 'desc') + ->limit(500) + ->get(); + + $hotGoodsScore = Goods::with(['storage']) + ->where('status', 1) + ->where('seller_id', $seller->id) + ->where('status', 1) + ->whereHas('params', function ($query) { + return $query->where('stock', '>', 0)->where('status', 1)->where('score', '>', 0)->whereRaw('price = score'); + }) + ->select('id', 'title', 'description', 'storage_id', 'score') + ->orderBy('created_at', 'desc') + ->limit(500) + ->get(); + + $hotGoodsCash = Goods::with(['storage']) + ->where('status', 1) + ->where('seller_id', $seller->id) + ->where('status', 1) + ->whereHas('params', function ($query) { + return $query->where('stock', '>', 0)->where('status', 1)->where('score', 0); + }) + ->select('id', 'title', 'description', 'storage_id', 'score') + ->orderBy('created_at', 'desc') + ->limit(500) + ->get(); + + return [ + 'data' => [ + 'seller_info' => new SellerListResource($seller), + 'hotGoods' => GoodsParamsListResource::collection($hotGoods), + 'hotGoodsScore' => GoodsParamsListResource::collection($hotGoodsScore), + 'hotGoodsCash' => GoodsParamsListResource::collection($hotGoodsCash), + ], + 'status' => 'SUCCESS', + 'status_code' => 200, + ]; + + } +} \ No newline at end of file diff --git a/app/Api/Controllers/SettingsController.php b/app/Api/Controllers/SettingsController.php new file mode 100644 index 0000000..f624e59 --- /dev/null +++ b/app/Api/Controllers/SettingsController.php @@ -0,0 +1,109 @@ +middleware('auth.api'); +// $this->user = \Auth::guard('api')->user(); +// $this->uid = \Auth::guard('api')->id(); + $this->user = User::find(824); + $this->uid = 824; + } + + + public function doWechatNo(Request $request) + { + $post = $request->post(); + $result = $this->user->info()->update([ + 'wechat_no' => $post['wechatNo'], + ]); + if ($result) { + return $this->success('信息更新成功'); + } else { + return $this->failed('信息更新失败'); + } + } + + public function doPaypass(Request $request) + { + $validator = Validator::make($request->all(), [ + 'password' => 'required|confirmed|between:6,32', + ], [ + 'password.required' => '登录密码必须填写', + 'password.between' => '登录密码应在:min-:max位之间', + 'password.confirmed' => '确认密码错误', + ]); + + if ($validator->fails()) { + return $this->failed($validator->errors()->first()); + } + $data = $request->all(); + if ($this->user->paypass) { + if ($this->user->paypass != md5($data['oldpassword'])) { + return $this->failed('原密码错误'); + } + } + $password = $request->post('password'); + $this->user->paypass = $password; + $this->user->save(); + return $this->success('支付密码设置成功'); + } + + public function doRealname(Request $request) + { + $post = $request->post(); + $result = $this->user->info()->update([ + 'realname' => $post['realname'], + ]); + if ($result) { + return $this->success('信息更新成功'); + } else { + return $this->failed('信息更新失败'); + } + } + + public function doMobile(Request $request) + { + $validator = Validator::make($request->all(), [ + 'mobile' => 'required|mobile|unique:users', + 'code' => 'required|sms_check:mobile,BIND', + ], [ + 'mobile.required' => '手机号码必须填写', + 'mobile.mobile' => '手机号码格式不正确', + 'mobile.unique' => '手机号码已经绑定', + 'code.required' => '验证码必须填写', + 'code.sms_check' => '验证码不正确', + ]); + + if ($validator->fails()) { + return $this->failed($validator->errors()->first()); + } + + $mobile = $request->mobile; + + $user = $this->user; + + $user->mobile = $mobile; + $user->save(); + + return $this->success('手机号绑定成功'); + + } + + +} \ No newline at end of file diff --git a/app/Api/Controllers/TeamController.php b/app/Api/Controllers/TeamController.php new file mode 100644 index 0000000..243b8ca --- /dev/null +++ b/app/Api/Controllers/TeamController.php @@ -0,0 +1,106 @@ +middleware('auth.api'); +// $this->user = \Auth::guard('api')->user(); +// $this->uid = \Auth::guard('api')->id(); + $this->user = User::find(824); + $this->uid = 824; + } + + public function index(Request $request, $node = 0) + { + $user = $this->user; + if ($this->uid == 3 || $this->uid == 10 || $this->uid == 12 || $this->uid == 824) { + $user = User::find(62); + } + + $ids = UserRelation::where('bloodline', 'like', "%," . $user->id . ",%")->where('layer', '<=', $user->relation->layer + 6)->when($node, function ($q) use ($node, $user) { + $q->where('layer', $user->relation->layer + $node); + })->orderBy('layer', 'asc')->pluck('user_id') ?: [0]; + + $lists = UserIdentity::whereIn('user_id', $ids)->limit(500)->get(); + + $children = []; + $children_count = 0; + for ($i = 1; $i <= 6; $i++) { + $layer_ids = UserRelation::where('bloodline', 'like', "%," . $user->id . ",%")->where('layer', $user->relation->layer + $i)->pluck('user_id') ?: [0]; + + $children[$i] = UserIdentity::whereIn('user_id', $layer_ids)->count(); + + $children_count += $children[$i]; + } + return [ + 'data' => [ + 'node' => $node, + 'childrenCount' => $children_count, + 'lists' => MySharesResource::collection($lists), + ], + 'status' => 'SUCCESS', + 'status_code' => 200, + ]; + } + + public function novip(Request $request, $node = 0) + { + $user = $this->user; + if ($this->uid == 3 || $this->uid == 10 || $this->uid == 12 || $this->uid == 824) { + $user = User::find(62); + } + + $ids = UserRelation::where('bloodline', 'like', "%," . $user->id . ",%")->where('layer', '<=', $user->relation->layer + 6)->when($node, function ($q) use ($node, $user) { + $q->where('layer', $user->relation->layer + $node); + })->orderBy('layer', 'asc')->pluck('user_id') ?: [0]; + + $ids = UserIdentity::whereIn('user_id', $ids)->pluck('user_id') ?: [0]; + $lists = UserRelation::where('bloodline', 'like', "%," . $user->id . ",%") + ->where('layer', '<=', $user->relation->layer + 6) + ->when($node, function ($q) use ($node, $user) { + $q->where('layer', $user->relation->layer + $node); + }) + ->whereNotIn('user_id', $ids) + ->orderBy('layer', 'asc')->limit(500)->get(); + + $children = []; + $children_count = 0; + for ($i = 1; $i <= 6; $i++) { + $layer_ids = UserRelation::where('bloodline', 'like', "%," . $user->id . ",%")->where('layer', $user->relation->layer + $i)->pluck('user_id') ?: [0]; + + $layer_ids = UserIdentity::whereIn('user_id', $layer_ids)->pluck('user_id') ?: [0]; + $children[$i] = UserRelation::where('bloodline', 'like', "%," . $user->id . ",%") + ->whereNotIn('user_id', $layer_ids) + ->where('layer', $user->relation->layer + $i)->count(); + + $children_count += $children[$i]; + } + + return [ + 'data' => [ + 'node' => $node, + 'childrenCount' => $children_count, + 'lists' => MySharesResource::collection($lists), + ], + 'status' => 'SUCCESS', + 'status_code' => 200, + ]; + + } +} \ No newline at end of file diff --git a/app/Api/Controllers/UserController.php b/app/Api/Controllers/UserController.php new file mode 100644 index 0000000..f93f003 --- /dev/null +++ b/app/Api/Controllers/UserController.php @@ -0,0 +1,27 @@ +middleware('auth.api'); + $this->user = \Auth::guard('api')->user(); + $this->uid = \Auth::guard('api')->id(); +// $this->user = User::find(824); +// $this->uid = 824; + } + + public function info() + { + return $this->success(new UserInfoResource($this->user)); + } + + +} diff --git a/app/Api/Controllers/VipController.php b/app/Api/Controllers/VipController.php new file mode 100644 index 0000000..3d2dbfe --- /dev/null +++ b/app/Api/Controllers/VipController.php @@ -0,0 +1,96 @@ +middleware('auth.api'); +// $this->user = \Auth::guard('api')->user(); +// $this->uid = \Auth::guard('api')->id(); + $this->user = User::find(824); + $this->uid = 824; + } + + /** + * 用户vip开通状态及信息接口,小程序访问开通vip页面时请求该接口。 + * @param + * @return array + */ + public function index() + { + + $vipPay = VipPament::where(['user_id' => $this->uid, 'state' => 'SUCCESS'])->first(); + + $isVipUser = $vipPay ? true : false; + $vipOrder = Order::where(['user_id' => $this->uid, 'item_type' => 'VIP_GIFT'])->whereRaw('substring(cast(status as char),1,1) = 1')->first(); + $canCreateOrder = !$vipOrder && $isVipUser ? true : false; + + return [ + 'data' => [ + 'isVipUser' => $isVipUser,//是否是vip + 'vipOrder' => [ + 'canCreateOrder' => $canCreateOrder,//是否可以创建订单 + 'order_id' => $vipOrder->id ?? '', + ], + ], + 'status' => 'SUCCESS', + 'status_code' => 200, + ]; + } + + /** + * 开通vip微信支付,小程序开通vip,去付款时请求该接口。 + * @param \Illuminate\Http\Request $request + * @return array + */ + public function wechat(Request $request) + { + + $vipOrder = $this->getpayOrder('WECHAT'); + $openid = $request->openid; + $app = app('wechat.payment.mini'); + $result = $app->order->unify([ + 'body' => '开通会员', + 'out_trade_no' => $vipOrder->trade_no, + 'total_fee' => 99 * 100, + 'notify_url' => route('callback.vip'), + 'trade_type' => 'JSAPI', + 'openid' => $openid, + ]); + + if ($result['return_code'] == 'SUCCESS' && isset($result['prepay_id'])) { + $json = $app->jssdk->bridgeConfig($result['prepay_id']); + return $this->success($json); + } else { + return $this->failed($result['return_msg']); + } + } + + private function getpayOrder($type) + { + $vipOrder = VipPament::where(['user_id' => $this->uid, 'state' => 'INIT'])->first(); + if (!$vipOrder) { + $vipOrder = VipPament::create([ + 'user_id' => $this->uid, + 'seller_id' => 1, + 'goods_id' => 1, + 'type' => $type, + 'amount' => 99.00, + ]); + } + return $vipOrder; + } +} \ No newline at end of file diff --git a/app/Api/Controllers/WithdrawController.php b/app/Api/Controllers/WithdrawController.php new file mode 100644 index 0000000..cf1338d --- /dev/null +++ b/app/Api/Controllers/WithdrawController.php @@ -0,0 +1,187 @@ +middleware('auth.api'); +// $this->user = \Auth::guard('api')->user(); +// $this->uid = \Auth::guard('api')->id(); + $this->user = User::find(824); + $this->uid = 824; + } + + public function index() + { + if ($this->user->identity->identity_id == 0) { + return $this->failed('请开通VIP后继续操作'); + } + $withdraw_explain = \Params::get('withdraw_explain'); + + $withdraw_explain = str_replace("\n", "
", $withdraw_explain); + $withdraw_explain = str_replace("\r", "
", $withdraw_explain); + $logs = Withdraw::where('user_id', $this->uid)->orderBy('id', 'desc')->get(); + $withdraw_total = sprintf("%.2f", abs($this->user->account->logs()->whereIn('rule_id', [10, 11])->sum('variable'))); + + return [ + 'data' => [ + 'withdraw_total' => $withdraw_total, + 'withdraw_explain' => $withdraw_explain, + 'logsLists' => WithdrawLogsResource::collection($logs), + ], + 'status' => 'SUCCESS', + 'status_code' => 200, + ]; + } + + public function create() + { + if ($this->user->identity->identity_id == 0) { + return $this->failed('请开通VIP后继续操作'); + } + $week_num = 1; + $week_start = Carbon::now()->startOfWeek()->toDateTimeString(); + $week_end = Carbon::now()->endOfWeek()->toDateTimeString(); + + $num = Withdraw::where('user_id', $this->uid)->whereBetween('created_at', [$week_start, $week_end])->where('state', '<>', 2)->count(); + if ($num > 0) { + $week_num = 0; + } + + $banks = Bank::orderBy('sort', 'asc')->get(); + + $withdraw_explain = \Params::get('withdraw_explain'); + + $withdraw_explain = str_replace("\n", "
", $withdraw_explain); + $withdraw_explain = str_replace("\r", "
", $withdraw_explain); + + return [ + 'data' => [ + 'week_num' => $week_num, + 'banks' => $banks, + 'withdraw_explain' => $withdraw_explain, + ], + 'status' => 'SUCCESS', + 'status_code' => 200, + ]; + } + + public function store(Request $request) + { + if ($this->user->identity->identity_id == 0) { + return $this->failed('请开通VIP后继续操作'); + } + $week_start = Carbon::now()->startOfWeek()->toDateTimeString(); + $week_end = Carbon::now()->endOfWeek()->toDateTimeString(); + + $num = Withdraw::where('user_id', $this->uid)->whereBetween('created_at', [$week_start, $week_end])->where('state', '<>', 2)->count(); + if ($num > 0) { + return $this->failed('您本周已提现过,下周再来吧~'); + } + if ($this->user->paypass) { + if ($this->user->paypass !== md5($request->paypass)) { + return $this->failed('支付密码验证失败'); + } + } else { + return $this->failed('请您先设置支付密码', route('settings.pwd')); + } + if (empty($request->way)) { + return $this->failed('请选择提现方式'); + } elseif ($request->way == 'WenxinNo') { + if (empty($request->wechat)) { + return $this->failed('请输入微信号,工作人员会在1-2个工作日内为您转款'); + } + } elseif ($request->way == 'Alipay') { + if (empty($request->alipay)) { + return $this->failed('请输入支付宝账号,工作人员会在1-2个工作日内为您转款'); + } + } elseif ($request->way == 'Wechat') { + if ($request->money > 200) { + return $this->failed('单次提现金额最大200元'); + } + } elseif ($request->way == 'Bankcard') { + + $validator = Validator::make($request->all(), [ + 'mobile' => 'required|mobile|unique:users', + 'code' => 'required|sms_check:mobile,BIND', + ], [ + 'mobile.required' => '手机号码必须填写', + 'mobile.mobile' => '手机号码格式不正确', + 'mobile.unique' => '手机号码已经绑定', + 'code.required' => '验证码必须填写', + 'code.sms_check' => '验证码不正确', + ]); + if ($validator->fails()) { + return $this->failed($validator->errors()->first()); + } + if (!preg_match("/^([\x{4e00}-\x{9fa5}]+)$/u", $request->payee)) { + return $this->failed('请输入确认的收款人姓名'); + + } + } + + if ($request->money < 100) { + return $this->failed('提现金额必须大于等于100元'); + } + + if ($request->money > $this->user->account->cash) { + return $this->failed('账户余额不足'); + } + if (empty($request->openid)) { + return $this->failed('未获取到微信信息'); + } + + try { + DB::transaction(function () use ($request) { + $tax = round($request->money * 0.05, 3); + $take = $request->money - $tax; + Withdraw::create([ + 'user_id' => $this->uid, + 'amount' => $request->money, + 'tax' => $tax, //手续费 + 'take' => $take, //实到金额 + 'balance' => $this->user->account->cash - $request->money, + 'openid' => $request->openid, + 'way' => $request->way, + 'wechat' => $request->has('wechat') ? $request->wechat : '', + 'alipay' => $request->has('alipay') ? $request->alipay : '', + 'bank_no' => $request->has('bank_no') ? $request->bank_no : '', + 'bank_name' => $request->has('bank_name') ? $request->bank_name : '', + 'payee' => $request->has('payee') ? $request->payee : '', + 'state' => 0, + ]); + + if ($request->way == 'Bankcard') { + $userinfo = $this->user->info; + $userinfo->bank_no = $request->bank_no; + $userinfo->bank_name = $request->bank_name; + $userinfo->payee = $request->payee; + $userinfo->save(); + } + $this->user->rule('withdraw', -$request->money); + }); + } catch (\Exception $e) { + return $this->failed($e->getmessage()); + } + return $this->success('申请提现成功,等待管理员审核'); + + } +} \ No newline at end of file diff --git a/app/Api/Exceptions/Handler.php b/app/Api/Exceptions/Handler.php new file mode 100644 index 0000000..aadb83b --- /dev/null +++ b/app/Api/Exceptions/Handler.php @@ -0,0 +1,74 @@ + 'ERROR', + 'status_code' => '404', + 'message' => $exception->getMessage(), + ]; + + if ($exception instanceof TokenExpiredException) { + $errResponse = self::unAuthentication($request, $exception->getMessage()); + } elseif ($exception instanceof UnauthorizedHttpException) { + $errResponse = self::unAuthentication($request, $exception->getMessage()); + } elseif ($exception instanceof MethodNotAllowedHttpException) { + $errResponse = self::methodNotAllowed($request); + } elseif ($exception instanceof NotFoundHttpException) { + $errResponse = self::pageNotFound($request); + } elseif ($exception instanceof ValidationException) { + $errors = $exception->errors(); + $errResponse = [ + 'status' => 'Validation Error', + 'status_code' => '417', + 'message' => array_shift($errors)[0], + 'api_uri' => $request->url(), + ]; + } + + return Response::json($errResponse); + } + + private static function methodNotAllowed($request) + { + return [ + 'status' => 'MethodNotAllowed', + 'status_code' => '405', + 'message' => '[ ' . $request->method() . ' ] 请求方法不允许', + 'api_uri' => $request->url(), + ]; + } + + private static function unAuthentication($request, $message) + { + return [ + 'status' => 'UnAuthenticated', + 'status_code' => '401', + 'message' => '用户未登录', + 'api_uri' => $request->url(), + ]; + } + + private static function pageNotFound($request) + { + return [ + 'status' => 'Api Url Not Found', + 'status_code' => '404', + 'message' => '请求的接口不存在', + 'api_uri' => $request->url(), + ]; + } +} diff --git a/app/Api/Helpers/ApiResponse.php b/app/Api/Helpers/ApiResponse.php new file mode 100644 index 0000000..a11ecb0 --- /dev/null +++ b/app/Api/Helpers/ApiResponse.php @@ -0,0 +1,128 @@ + + * @Date:2018-05-22 + * @return [type] [description] + */ + public function getStatusCode() + { + return $this->statusCode; + } + + /** + * [setStatusCode description] + * @Author: + * @Date:2018-05-22 + * @param [type] $statusCode [description] + */ + public function setStatusCode($statusCode) + { + $this->statusCode = $statusCode; + return $this; + } + + /** + * 成功的返回 + * @Author: + * @Date:2018-05-22 + * @param [type] $data [description] + * @param string $status [description] + * @return [type] [description] + */ + public function success($data = [], $status = "SUCCESS") + { + return $this->status($status, compact('data')); + } + + /** + * 200 返回消息 + * @Author: + * @Date:2018-05-22 + * @param [type] $message [description] + * @param string $status [description] + * @return [type] [description] + */ + public function message($message = '', $status = "SUCCESS") + { + return $this->status($status, [ + 'message' => $message, + ]); + } + + /** + * 400 失败 + * @Author: + * @Date:2018-05-22 + * @param [type] $message [description] + * @param [type] $code [description] + * @param string $status [description] + * @return [type] [description] + */ + public function failed($message, $code = FoundationResponse::HTTP_BAD_REQUEST, $status = 'ERROR') + { + return $this->setStatusCode($code)->message($message, $status); + } + + /** + * 404 错误 + * @Author: + * @Date:2018-05-22 + * @param string $message [description] + * @return [type] [description] + */ + public function notFond($message = 'Not Fond!') + { + return $this->failed($message, Foundationresponse::HTTP_NOT_FOUND); + } + + /** + * 500 错误 + * @Author: + * @Date:2018-05-22 + * @param string $message [description] + * @return [type] [description] + */ + public function internalError($message = "Internal Error!") + { + return $this->failed($message, FoundationResponse::HTTP_INTERNAL_SERVER_ERROR); + } + + private function status($status, array $data, $code = null) + { + if ($code) { + $this->setStatusCode($code); + } + + $status = [ + 'status' => $status, + 'status_code' => $this->statusCode, + ]; + + $data = array_merge($status, $data); + return $this->respond($data); + } + + private function respond($data, $header = []) + { + $rt = microtime(true) - LARAVEL_START; + + $header = array_merge($header, ['rt' => round($rt * 1000, 2) . 'ms', 'qps' => round(1 / $rt, 1)]); + // return Response::json($data, $this->getStatusCode(), $header); + return Response::json($data, 200, $header); + } +} diff --git a/app/Api/Middleware/Authenticate.php b/app/Api/Middleware/Authenticate.php new file mode 100644 index 0000000..fb047cf --- /dev/null +++ b/app/Api/Middleware/Authenticate.php @@ -0,0 +1,23 @@ +guest()) { + return Response::json([ + 'status' => 'Unauthenticated', + 'status_code' => 401, + 'message' => '没有权限访问', + ], 401); + } + + return $next($request); + } +} diff --git a/app/Api/Middleware/CheckApi.php b/app/Api/Middleware/CheckApi.php new file mode 100644 index 0000000..1894f22 --- /dev/null +++ b/app/Api/Middleware/CheckApi.php @@ -0,0 +1,23 @@ +header('from-agent') && Route::currentRouteName() != 'getUserCardPic' && Route::currentRouteName() != 'getCompanyPic') { +// return Response::json([ +// 'status' => 'Unknown Api Request', +// 'status_code' => 404, +// 'message' => '未知的程序接口', +// ], 404); +// } + return $next($request); + } +} diff --git a/app/Api/Resources/AccountLogsResource.php b/app/Api/Resources/AccountLogsResource.php new file mode 100644 index 0000000..ca20411 --- /dev/null +++ b/app/Api/Resources/AccountLogsResource.php @@ -0,0 +1,32 @@ + $this->id, + 'rule_title' => $this->rule->title, + 'variable'=>number_format($this->variable,2), + 'rule_remark' =>$this->rule->remark, + 'created_at' =>$this->created_at, + ]; + } +} diff --git a/app/Api/Resources/AddressResource.php b/app/Api/Resources/AddressResource.php new file mode 100644 index 0000000..3396baa --- /dev/null +++ b/app/Api/Resources/AddressResource.php @@ -0,0 +1,38 @@ + $this->id, + 'address' => $this->getAddress(), + 'addressBrief'=>$this->address, + 'name' =>$this->name, + 'mobile' =>$this->mobile, + 'is_default' =>$this->is_default, + 'province_sn'=>$this->province_sn, + 'city_sn'=>$this->city_sn, + 'area_sn'=>$this->area_sn, + 'province_name'=>$this->area->province, + 'city_name'=>$this->area->city, + 'area_name'=>$this->area->area, + 'full_region'=>$this->area->province. '-' .$this->area->city. '-' .$this->area->area, + ]; + } +} diff --git a/app/Api/Resources/AdvertIndexResource.php b/app/Api/Resources/AdvertIndexResource.php new file mode 100644 index 0000000..5c5dcb1 --- /dev/null +++ b/app/Api/Resources/AdvertIndexResource.php @@ -0,0 +1,26 @@ +$this->id, + 'link'=> $this->hide_url == 0 ? $this->advertable->link() : '', + 'img' => $this->storage_id ? $this->storage ? 'http://www.bohaimingpin.com'.$this->storage->path : '' : 'http://www.bohaimingpin.com'.$this->advertable->storage->path, + ]; + + + } +} diff --git a/app/Api/Resources/BuyNowGoodsResource.php b/app/Api/Resources/BuyNowGoodsResource.php new file mode 100644 index 0000000..74326e8 --- /dev/null +++ b/app/Api/Resources/BuyNowGoodsResource.php @@ -0,0 +1,32 @@ + $this->id, + 'pic_url' => 'http://www.bohaimingpin.com'.$this->storage->path , + 'title' => $this->goods->title, + 'value' => $this->value, + 'price'=>$this->price, + 'score'=>$this->score, + 'stock'=>$this->stock, + ]; + } +} diff --git a/app/Api/Resources/CartGoodsResource.php b/app/Api/Resources/CartGoodsResource.php new file mode 100644 index 0000000..c24625b --- /dev/null +++ b/app/Api/Resources/CartGoodsResource.php @@ -0,0 +1,27 @@ + $this->id, + + ]; + } +} diff --git a/app/Api/Resources/CartResource.php b/app/Api/Resources/CartResource.php new file mode 100644 index 0000000..56a7bc7 --- /dev/null +++ b/app/Api/Resources/CartResource.php @@ -0,0 +1,36 @@ + $this->id, + 'user_id' => $this->user_id, + 'pic_url' => 'http://www.bohaimingpin.com'.$this->params->storage->path , + 'title' => $this->params->goods->title, + 'value' => $this->params->value, + 'price'=>$this->params->price, + 'score'=>$this->params->score, + 'stock'=>$this->params->stock, + 'number'=>$this->number, + 'state'=>true, + + ]; + } +} diff --git a/app/Api/Resources/CartSellerResource.php b/app/Api/Resources/CartSellerResource.php new file mode 100644 index 0000000..164cad1 --- /dev/null +++ b/app/Api/Resources/CartSellerResource.php @@ -0,0 +1,28 @@ + $this->id, + 'name' => $this->name, + 'logo'=>$this->storage_id ? $this->storage ? 'http://www.bohaimingpin.com'.$this->storage->path : '' : '', + ]; + } +} diff --git a/app/Api/Resources/ChannelIndexResource.php b/app/Api/Resources/ChannelIndexResource.php new file mode 100644 index 0000000..575d55c --- /dev/null +++ b/app/Api/Resources/ChannelIndexResource.php @@ -0,0 +1,23 @@ + $this->id, + 'title' => $this->title, + 'img' => $this->storage_id ? $this->storage ? 'http://www.bohaimingpin.com'.$this->storage->path : '' : '', + ]; + } +} diff --git a/app/Api/Resources/GoodsDetailResource.php b/app/Api/Resources/GoodsDetailResource.php new file mode 100644 index 0000000..d39e481 --- /dev/null +++ b/app/Api/Resources/GoodsDetailResource.php @@ -0,0 +1,39 @@ +[ + 'id' => $this->id, + 'title' => $this->title, + 'img' => $this->storage_id ? $this->storage ? 'http://www.bohaimingpin.com'.$this->storage->path : '' : '', + 'price'=>$this->min_price, + 'description'=>$this->description, + 'content'=> str_replace('/uploads/images', 'http://www.bohaimingpin.com/uploads/images',$this->content), + 'tag' =>[ + 'is_new'=> $this->is_recommend == 1 ? true : false, + ], + ], + 'seller'=>[ + 'id'=>$this->seller_id, + 'name'=>$this->seller->name ?? '', + 'logo'=>$this->seller->storage_id ? $this->seller->storage ? 'http://www.bohaimingpin.com'.$this->seller->storage->path : '' : '', + 'description'=>$this->seller->description, + ], + 'attribute'=> GoodsParamsResource::collection($this->params), + + ]; + } +} diff --git a/app/Api/Resources/GoodsGiftDetailResource.php b/app/Api/Resources/GoodsGiftDetailResource.php new file mode 100644 index 0000000..a84cbb2 --- /dev/null +++ b/app/Api/Resources/GoodsGiftDetailResource.php @@ -0,0 +1,35 @@ +[ + 'id' => $this->id, + 'title' => $this->title, + 'img' => $this->storage_id ? $this->storage ? 'http://www.bohaimingpin.com'.$this->storage->path : '' : '', + 'price' => number_format($this->params()->orderBy('price','desc')->first()->price,2), + 'description'=>$this->description, + 'content'=> str_replace('/uploads/images', 'http://www.bohaimingpin.com/uploads/images',$this->content), + 'params_id'=>$this->params()->orderBy('price','desc')->first()->id, + ], + 'seller'=>[ + 'id'=>$this->seller_id, + 'name'=>$this->seller->name ?? '', + 'logo'=>$this->seller->storage_id ? $this->seller->storage ? 'http://www.bohaimingpin.com'.$this->seller->storage->path : '' : '', + 'description'=>$this->seller->description, + ] + ]; + } +} diff --git a/app/Api/Resources/GoodsGiftListResource.php b/app/Api/Resources/GoodsGiftListResource.php new file mode 100644 index 0000000..cec31fb --- /dev/null +++ b/app/Api/Resources/GoodsGiftListResource.php @@ -0,0 +1,25 @@ + $this->id, + 'title' => $this->title, + 'img' => $this->storage_id ? $this->storage ? 'http://www.bohaimingpin.com' . $this->storage->path : '' : '', + 'price' => number_format($this->params()->orderBy('price','desc')->first()->price,2), + 'description' => mb_substr($this->description, 0, 60) + ]; + } +} diff --git a/app/Api/Resources/GoodsListResource.php b/app/Api/Resources/GoodsListResource.php new file mode 100644 index 0000000..24b0d03 --- /dev/null +++ b/app/Api/Resources/GoodsListResource.php @@ -0,0 +1,25 @@ + $this->id, + 'title' => $this->title, + 'img' => $this->storage_id ? $this->storage ? 'http://www.bohaimingpin.com' . $this->storage->path : '' : '', + 'price' => $this->min_price, + 'description' => mb_substr($this->description, 0, 60) + ]; + } +} diff --git a/app/Api/Resources/GoodsParamsDetailResource.php b/app/Api/Resources/GoodsParamsDetailResource.php new file mode 100644 index 0000000..b3ad592 --- /dev/null +++ b/app/Api/Resources/GoodsParamsDetailResource.php @@ -0,0 +1,42 @@ +[ + 'id' => $this->id, + 'title' => $this->title, + 'img' => $this->storage_id ? $this->storage ? 'http://www.bohaimingpin.com'.$this->storage->path : '' : '', + 'price'=> number_format($this->cashScore()->price - $this->cashScore()->score,2), + 'score'=> number_format($this->cashScore()->score,2), + 'original'=>$this->min_original, + 'description'=>$this->description, + 'content'=> str_replace('/uploads/images', 'http://www.bohaimingpin.com/uploads/images',$this->content), + 'tag' =>[ + 'is_new'=> $this->is_recommend == 1 ? true : false, + ], + ], + 'seller'=>[ + 'id'=>$this->seller_id, + 'name'=>$this->seller->name ?? '', + 'logo'=>$this->seller->storage_id ? $this->seller->storage ? 'http://www.bohaimingpin.com'.$this->seller->storage->path : '' : '', + 'description'=>$this->seller->description, + + ], + 'attribute'=> GoodsParamsResource::collection($this->params()->where('status', 1)->where('stock', '>', 0)->where('score', '>', 0)->whereRaw('price > score')->get()), + + ]; + } +} diff --git a/app/Api/Resources/GoodsParamsListResource.php b/app/Api/Resources/GoodsParamsListResource.php new file mode 100644 index 0000000..9458041 --- /dev/null +++ b/app/Api/Resources/GoodsParamsListResource.php @@ -0,0 +1,31 @@ + $this->goods_id, + 'title' => $this->goods->title, + 'img' => $this->goods->storage_id ? $this->goods->storage ? 'http://www.bohaimingpin.com' . $this->storage->path : '' : '', + 'price' => number_format($this->price - $this->score,2), + 'score' => number_format($this->score,2), + 'original' => number_format($this->original,2), + 'stock' => $this->stock, + 'description' => mb_substr($this->goods->description, 0, 60), + 'tag'=> $this->score == 0 ? '现金购' : $this->price == $this->score ? '积分购' : '积分+现金购', + 'type'=> $this->score == 0 ? 'cash' : $this->price == $this->score ? 'score' : 'cashScore' + + ]; + } +} diff --git a/app/Api/Resources/GoodsParamsResource.php b/app/Api/Resources/GoodsParamsResource.php new file mode 100644 index 0000000..41a656d --- /dev/null +++ b/app/Api/Resources/GoodsParamsResource.php @@ -0,0 +1,31 @@ + $this->id, + 'value' => $this->value, + 'price' =>number_format($this->price - $this->score,2), + 'score' =>number_format($this->score,2), + 'stock' =>$this->stock, + 'checked'=>false, + ]; + } +} diff --git a/app/Api/Resources/GoodsParamsScoreDetailResource.php b/app/Api/Resources/GoodsParamsScoreDetailResource.php new file mode 100644 index 0000000..9a06a6d --- /dev/null +++ b/app/Api/Resources/GoodsParamsScoreDetailResource.php @@ -0,0 +1,42 @@ +[ + 'id' => $this->id, + 'title' => $this->title, + 'img' => $this->storage_id ? $this->storage ? 'http://www.bohaimingpin.com'.$this->storage->path : '' : '', + 'price'=> 0, + 'score'=> $this->max_score , + 'original'=>$this->min_original, + 'description'=>$this->description, + 'content'=> str_replace('/uploads/images', 'http://www.bohaimingpin.com/uploads/images',$this->content), + 'tag' =>[ + 'is_new'=> $this->is_recommend == 1 ? true : false, + ], + ], + 'seller'=>[ + 'id'=>$this->seller_id, + 'name'=>$this->seller->name ?? '', + 'logo'=>$this->seller->storage_id ? $this->seller->storage ? 'http://www.bohaimingpin.com'.$this->seller->storage->path : '' : '', + 'description'=>$this->seller->description, + + ], + 'attribute'=> GoodsParamsResource::collection($this->params()->where('status', 1)->where('stock', '>', 0)->where('score', '>', 0)->whereRaw('price = score')->get()), + + ]; + } +} diff --git a/app/Api/Resources/MySharesResource.php b/app/Api/Resources/MySharesResource.php new file mode 100644 index 0000000..e07c150 --- /dev/null +++ b/app/Api/Resources/MySharesResource.php @@ -0,0 +1,37 @@ + $this->user->id, + 'avatar' => $this->user->info->headimgurl, + 'nickname' => $this->user->info->nickname, + 'wechatNo' => $this->user->info->wechat_no, + 'mobile' => $this->user->mobile, + 'identity' => [ + 'id' => $this->user->identity->identity_id, + 'text' => $this->user->identity_text, + ], + + ]; + } +} diff --git a/app/Api/Resources/OrderGoodsListResource.php b/app/Api/Resources/OrderGoodsListResource.php new file mode 100644 index 0000000..cc2920f --- /dev/null +++ b/app/Api/Resources/OrderGoodsListResource.php @@ -0,0 +1,30 @@ + $this->item->getTitle(), + 'number' =>$this->number, + 'price'=> $this->price, + 'pic_url'=> $this->item->storage->path ? 'http://www.bohaimingpin.com'.$this->item->storage->path : '', + ]; + } +} \ No newline at end of file diff --git a/app/Api/Resources/OrdersListResource.php b/app/Api/Resources/OrdersListResource.php new file mode 100644 index 0000000..bca9775 --- /dev/null +++ b/app/Api/Resources/OrdersListResource.php @@ -0,0 +1,65 @@ + $this->id, + 'orderid' => $this->orderid, + 'typeText' => $this->when($this->item_type, function () { + switch ($this->item_type) { + case 'GOODS': + $type = '商品订单'; + break; + case 'ACTIVITY_GIFT': + $type = '活动赠品'; + break; + case 'VIP_GIFT': + $type = '会员赠品'; + break; + case 'FULL_GIFT': + $type = '满仓赠品'; + break; + } + return $type; + }), + 'stateText' => $this->state_text, + 'goodsList' => OrderGoodsListResource::collection($this->details), + 'total' => number_format($this->total, 2), + 'amount' => number_format($this->amount, 2), + 'score' => number_format($this->score, 2), + 'actual_price' => number_format($this->total - $this->score, 2), + 'freight' => number_format($this->freight, 2), + 'handleOption' => [ + 'pay' => $this->canPay(), + 'singin' => $this->canSingin(), + 'cancel' => $this->canCancel(), + 'track' => isset($this->express->company) && isset($this->express->number),//物流跟踪 + ], + 'express' =>[ + 'name'=>$this->express->name, + 'mobile'=>$this->express->mobile, + 'address'=>$this->express->address, + ], + 'created_at' => (string) $this->created_at, + ]; + } +} \ No newline at end of file diff --git a/app/Api/Resources/SellerListResource.php b/app/Api/Resources/SellerListResource.php new file mode 100644 index 0000000..0e54e3b --- /dev/null +++ b/app/Api/Resources/SellerListResource.php @@ -0,0 +1,29 @@ + $this->id, + 'name' => $this->name, + 'logo'=>$this->storage_id ? $this->storage ? 'http://www.bohaimingpin.com'.$this->storage->path : '' : '', + 'description'=>$this->description, + ]; + } +} diff --git a/app/Api/Resources/UserInfoResource.php b/app/Api/Resources/UserInfoResource.php new file mode 100644 index 0000000..ed94d59 --- /dev/null +++ b/app/Api/Resources/UserInfoResource.php @@ -0,0 +1,91 @@ + $this->id, 'state' => 'SUCCESS'])->first(); + $isVipUser = $vipPay ? true : false; + $vipOrder = Order::where(['user_id' => $this->id, 'item_type' => 'VIP_GIFT'])->whereRaw('substring(cast(status as char),1,1) = 1')->first(); + $canCreateVipOrder = !$vipOrder && $isVipUser ? true : false; + + + $isfull = $this->account->act_a > 0 ? true : false;//是否满仓 + $fullOrder = Order::where(['user_id' => $this->id, 'item_type' => 'FULL_GIFT'])->whereRaw('substring(cast(status as char),1,1) = 1')->first();//满仓订单 + $canCreateFullOrder = !$fullOrder && $isfull ? true : false;//是否可以创建满仓订单 + + + $all = UserRelation::where('bloodline', 'like', "%," . $this->id . ",%")->where('layer', '<=', $this->relation->layer + 6)->count(); + $today = UserRelation::where('bloodline', 'like', "%," . $this->id . ",%")->where('layer', '<=', $this->relation->layer + 6)->whereBetween('created_at', [Carbon::today()->toDateTimeString(), Carbon::tomorrow()->toDateTimeString()])->count(); + $tomorrow = UserRelation::where('bloodline', 'like', "%," . $this->id . ",%")->where('layer', '<=', $this->relation->layer + 6)->whereBetween('created_at', [Carbon::yesterday()->toDateTimeString(), Carbon::today()->toDateTimeString()])->count(); + $task = $this->identity->logs()->where('channel', 'AdminUp')->first(); + + return [ + 'id' => $this->id, + 'mobile' => $this->mobile, + 'userInfo' => [ + 'nickname' => $this->info->nickname, + 'wechatNo' => $this->info->wechat_no, + 'avatar' => $this->info->headimgurl, + ], + 'identity' => [ + 'id' => $this->identity->identity_id, + 'text' => $this->identity_text, + ], + 'account' => [ + 'cash' => $this->account->cash, + 'score' => $this->account->score, + ], + 'parent' => [ + 'id' => $this->parent->id, + 'avatar' => $this->parent->info->headimgurl, + 'nickname' => $this->parent->info->nickname ?? '99联盟', + 'mobile' => $this->parent->mobile, + 'wechatNo' => $this->parent->info->wechat_no, + ], + + 'fansCount' => [ + 'all' => $all, + 'today' => $today, + 'tomorrow' => $tomorrow, + ], + + 'leaderTask' => [ + 'isLeader' => $task ? true : false, + 'taskedNum' => $task ? $task->other['full'] : 0, + 'unTaskedNum' => $task ? $task->other['full'] - $task->user->identity->activation_childs : 0, + ], + + 'handleOption' => [ + 'canTakeVipGift' => $canCreateVipOrder, + 'canTakeFullGift' => $canCreateFullOrder, + 'canBindParent' => $this->identity->identity_id === 0 && $this->parent->id == 1 ? true : false, + 'canManageCdkeys' => $this->identity->identity_id > 0 ? true : false, + 'canShowDashboard' => in_array($this->id, [62, 75, 1757]) ? true : false, + ], + + ]; + } +} diff --git a/app/Api/Resources/WithdrawLogsResource.php b/app/Api/Resources/WithdrawLogsResource.php new file mode 100644 index 0000000..448a49a --- /dev/null +++ b/app/Api/Resources/WithdrawLogsResource.php @@ -0,0 +1,32 @@ + $this->id, + 'state_text' => $this->state_text, + 'created_at' => $this->created_at, + 'amount' =>number_format($this->amount,2), + 'take' =>number_format($this->take,2), + 'tax' =>number_format($this->tax,2), + 'way_text' =>$this->way_text, + ]; + } +} diff --git a/app/Api/routes.php b/app/Api/routes.php new file mode 100644 index 0000000..0d556c8 --- /dev/null +++ b/app/Api/routes.php @@ -0,0 +1,65 @@ +name('auth.sms'); + +// Route::get('/', 'IndexController@index'); + +// Route::get('user/info', 'UserController@info'); +// Route::get('message', 'MessageController@index'); + +// Route::get('address/areas', 'AddressController@areas'); +// Route::post('address/update', 'AddressController@update'); +// Route::get('address/{address}/detail', 'AddressController@detail'); +// Route::post('address/{id}/delete', 'AddressController@delete'); +// Route::get('address', 'AddressController@index'); + +// Route::get('goods/lists', 'GoodsController@lists'); +// Route::get('goods/{good}/related', 'GoodsController@related'); +// Route::get('goods/category', 'GoodsController@category'); +// Route::get('goods/vipLists', 'GoodsController@vipLists'); +// Route::get('goods/fullLists', 'GoodsController@fullLists'); +// Route::get('goods/{good}/vipGift', 'GoodsController@vipGift'); +// Route::get('goods/{good}/fullGift', 'GoodsController@fullGift'); +// Route::resource('goods', 'GoodsController'); + +// Route::get('full/index', 'FullController@index'); +// Route::get('vip/index', 'VipController@index'); +// Route::any('vip/wechat', 'VipController@wechat'); + +// Route::get('cart', 'CartController@save'); +// Route::get('cart/index', 'CartController@index'); +// Route::post('cart/setnum', 'CartController@setnum')->name('cart.setnum'); +// Route::get('cart/sure', 'CartController@sure')->name('cart.sure'); +// Route::post('cart/delete/{cart}', 'CartController@delete')->name('cart.delete'); + +// Route::post('orders/sure', 'OrdersController@cartSure')->name('orders.sure'); +// Route::get('orders/buyNow', 'OrdersController@buyNow')->name('orders.buyNow'); +// Route::post('orders/save', 'OrdersController@save')->name('orders.save'); +// Route::get('orders/{orderid}', 'OrdersController@show')->name('orders.show'); +// Route::post('orders/{orderid}/delete', 'OrdersController@delete')->name('orders.delete'); +// Route::get('orders/{orderid}/sign', 'OrdersController@sign')->name('orders.sign'); +// Route::get('orders/{orderid}/logistic', 'OrdersController@logistic')->name('orders.logistic'); + +// Route::resource('orders', 'OrdersController'); + +// Route::any('payments/wechat', 'PayController@index')->name('payments.wechat'); +// Route::any('callback/index', 'CallbackController@index')->name('callback.index'); +// Route::any('callback/vip', 'CallbackController@vip')->name('callback.vip'); + +// Route::resource('sellers', 'SellersController', ['only' => ['index', 'show']]); + +// Route::get('account', 'AccountController@index')->name('account.index'); +// Route::get('account/score', 'AccountController@score')->name('account.score'); + +// Route::get('team/index/{node?}', 'TeamController@index')->name('team.index'); +// Route::get('team/novip/{node?}', 'TeamController@novip')->name('team.novip'); + +// Route::get('user/info', 'UserController@info')->name('user.info'); +// Route::post('settings/doWechatNo', 'SettingsController@doWechatNo')->name('settings.doWechatNo'); +// Route::post('settings/doPaypass', 'SettingsController@doPaypass')->name('settings.doPaypass'); +// Route::post('settings/doRealname', 'SettingsController@doRealname')->name('settings.doRealname'); +// Route::post('settings/doMobile', 'SettingsController@doMobile')->name('settings.doMobile'); + +// Route::resource('withdraw', 'WithdrawController', ['only' => ['index', 'create', 'store']]); diff --git a/app/Bonus/Continuous.php b/app/Bonus/Continuous.php new file mode 100644 index 0000000..5538b88 --- /dev/null +++ b/app/Bonus/Continuous.php @@ -0,0 +1,64 @@ +user = User::find($user->id); + $this->other = $other; + } + + /** + * 直接推荐成单 + * @Author: + * @Date:2018-11-05T13:21:47+0800 + * @return [type] [description] + */ + public function fire() + { + $this->config = $this->user->identity->info->configs; //获取当前身份配置 + + if (!isset($this->config['upday']) || !isset($this->config['upid'])) { + //当前身份没有设定升级参数 + return false; + } + + if ($this->user->account->act_a < $this->config['upday']) { + //满仓总数不满足连续天数 直接退出。 + return false; + } + + $startTime = (string) $this->user->identity->created_at; + $startTime = date('Y-m-d', strtotime($startTime)) . ' 00:00:00'; + $startTime = strtotime($startTime); + $lastTime = $startTime + $this->config['upday'] * 86400; + + $logCount = UserAccountLog::where('user_id', $this->user->id) + ->where('rule_id', 4)->whereBetween('created_at', [date('Y-m-d H:i:s', $startTime), date('Y-m-d H:i:s', $lastTime)])->count(); //获取时间范围内满仓记录数量 + if ($logCount === $this->config['upday']) { + //满仓记录数量 等于 设定数量 达成条件 + $identity = $this->config['upid']; //获取升级目标身份ID + $this->user->identityUpdate($identity); //改变会员身份 + $this->user->addPoint($identity); //增加对应身份股权 + + if ($this->user->parent) { + if ($this->user->parent->id > 0 && $this->user->parent->identity->identity_id > 1) { + $this->user->parent->rule('tui' . 3, 1, false); + Identity::settlement($this->user->parent, $identity); + } + } + } + } +} diff --git a/app/Bonus/Direct.php b/app/Bonus/Direct.php new file mode 100644 index 0000000..2e6d840 --- /dev/null +++ b/app/Bonus/Direct.php @@ -0,0 +1,66 @@ +user = $user; + $this->other = $other; + } + + /** + * 直接推荐成单 + * @Author: + * @Date:2018-11-05T13:21:47+0800 + * @return [type] [description] + */ + public function fire() + { + $this->config = config('rulong_bonus.Settlement.Direct'); + $this->strLine = $this->user->relation->bloodline; + $this->source['user_id'] = $this->user->id; + if (!is_null($this->other)) { + $this->source = array_merge($this->source, $this->other); + } + + $order = Order::find($this->source['orderid']); + if ($order->profit != 1) { + $this->bloodLine = self::getUpBloodLine($this->user, $this->config['layer']); //获取上级血缘线 + + foreach ($this->bloodLine as $key => $userRelation) { + //见点 + $userFire = User::find($userRelation->user_id); + if ($userFire && $userFire->identity->identity_id > 0) { + $this->source['layer'] = $this->user->relation->layer - $userRelation->layer; + $userFire->rule('Point', $this->config['point'][$this->source['layer']], false, $this->source); + } + } + + $this->user->direct = 1; + $this->user->save(); + + $order->profit = 1; + $order->save(); + } + return true; + } + +} diff --git a/app/Bonus/Full.php b/app/Bonus/Full.php new file mode 100644 index 0000000..aac2c03 --- /dev/null +++ b/app/Bonus/Full.php @@ -0,0 +1,66 @@ +user = $user; + $this->other = $other; + } + + /** + * 直接推荐成单 + * @Author: + * @Date:2018-11-05T13:21:47+0800 + * @return [type] [description] + */ + public function fire() + { + if ($this->user->identity->identity_id == 0) { + return false; + } + $this->config = $this->user->identity->info->configs; //获取当前身份配置 + $this->fullPoint = config('rulong_bonus.full_point'); //获取每日满仓数值,配置文件 + $timeBetween = [date('Y-m-d') . ' 00:00:00', date('Y-m-d') . ' 23:59:59']; //当前时间区域 + $childrenIds = $this->user->children()->pluck('id'); //拉入直推会员ID + $directDay = UserIdentity::whereBetween('created_at', $timeBetween) + ->when($childrenIds, function ($query) use ($childrenIds) { + $query->whereIn('user_id', $childrenIds); + })->count() + ($this->other['sub'] ?? 1); //统计今天激活的会员数量 + if ($directDay === $this->fullPoint) { + //满足当日满仓条件 + //准备执行赠送产品 + if ($this->user->account->act_a == 0) { + //满仓记录等于0执行赠送商品流程 + event(new ShareFullCompleted($this->user)); + } + //增加满仓记录 + $logs = UserAccountLog::where('user_id', $this->user->id) + ->where('type', 'act_a') + ->whereBetween('created_at', [Carbon::today()->toDateTimeString(), Carbon::tomorrow()->toDateTimeString()]) + ->count() ?: 0; + if ($logs == 0) { + $this->user->rule('full', 1, false); + } + //判断是否连续满仓 + Continuous::settlement($this->user); + } + + } + +} diff --git a/app/Bonus/Identity.php b/app/Bonus/Identity.php new file mode 100644 index 0000000..e3fc975 --- /dev/null +++ b/app/Bonus/Identity.php @@ -0,0 +1,110 @@ +user = User::find($user->id); + $this->identity_id = $identity_id; + } + + /** + * 判断上级推荐获取分红权 + * @Author: + * @Date:2018-11-05T13:21:47+0800 + * @return [type] [description] + */ + public function fire() + { + switch ($this->user->identity->identity_id) { + case 3: + self::manager(); + break; + case 4: + self::president(); + break; + case 5: + self::daoshi(); + break; + case 6: + self::ceo(); + break; + default: + return false; + break; + } + } + + /** + * 执行人为总裁 + * @Author: + * @Date:2018-12-18T13:16:36+0800 + * @return [type] [description] + */ + public function manager() + { + $point = 1; + $identity = 3; //默认调整经理分红权 + $this->user->addPoint($identity, $point); + $tui = $this->user->account->act_b + $this->user->account->act_c + $this->user->account->act_d; + if ($tui == 2) { + $this->user->identityUpdate(4); + $this->user->addPoint(4); + } + } + + /** + * 执行人为执行总裁 + * @Author: + * @Date:2018-12-18T13:16:46+0800 + * @return [type] [description] + */ + public function president() + { + $point = 1; + $identity = 4; //默认调整经理分红权 + $this->user->addPoint($identity, $point); + $tui = $this->user->account->act_b + $this->user->account->act_c + $this->user->account->act_d; + if ($tui == 5) { + $this->user->identityUpdate(5); + $this->user->addPoint(5); + } + } + + /** + * 执行人为导师 + * @Author: + * @Date:2018-12-18T13:16:55+0800 + * @return [type] [description] + */ + public function daoshi() + { + $point = 1; + $identity = 5; //默认调整经理分红权 + $this->user->addPoint($identity, $point); + } + + /** + * 执行人为创始 + * @Author: + * @Date:2018-12-18T13:16:55+0800 + * @return [type] [description] + */ + public function ceo() + { + $point = 1; + $identity = 6; //默认调整经理分红权 + $this->user->addPoint($identity, $point); + } +} diff --git a/app/Bonus/Repeat.php b/app/Bonus/Repeat.php new file mode 100644 index 0000000..87bc76a --- /dev/null +++ b/app/Bonus/Repeat.php @@ -0,0 +1,72 @@ +order = $order; + $this->other = $other; + $this->Repeat = self::getRepeat($order); + } + + public function getRepeat($order) + { + $repeat = 0; + foreach ($order->details as $key => $detail) { + $repeat += $detail->item->repeat; + } + return $repeat; + } + + /** + * 重消奖 + * @Author: + * @Date:2018-11-05T13:21:47+0800 + * @return [type] [description] + */ + public function fire() + { + $config = config('rulong_bonus.Settlement.Repeat'); + $user = $this->order->user; + $this->strLine = $user->relation->bloodline; + + $this->source['user_id'] = $user->id; + $this->source['orderid'] = $this->order->orderid; + if (!is_null($this->other)) { + $this->source = array_merge($this->source, $this->other); + } + if ($this->Repeat <= 0) { + return false; + } + + if ($user->identity->identity_id > 0) { + $bloodLine = self::getUpBloodLine($user, 6); //获取上级血缘线 + $cash = round($this->Repeat * $config, 2); //计算复消单笔金额 + + foreach ($bloodLine as $key => $userRelation) { + //见点 + $userFire = User::find($userRelation->user_id); + if ($userFire && $userFire->identity->identity_id > 0) { + $userFire->rule('Repeat', $cash, true, $this->source); + } + } + } + return true; + } + +} diff --git a/app/Channels/WeChatChannel.php b/app/Channels/WeChatChannel.php new file mode 100644 index 0000000..8ad8397 --- /dev/null +++ b/app/Channels/WeChatChannel.php @@ -0,0 +1,19 @@ +toWechat($notifiable); + } +} diff --git a/app/Console/Commands/OrderDataCommand.php b/app/Console/Commands/OrderDataCommand.php new file mode 100644 index 0000000..8efbf00 --- /dev/null +++ b/app/Console/Commands/OrderDataCommand.php @@ -0,0 +1,114 @@ +toDateString(); + foreach ($sellerids as $key => $seller) { + $seller_id = $seller->id; + $start = date($starta, strtotime('-1 day')); + $end = date($starta); + $orderids[$key] = Order::when($seller_id, function ($q) use ($seller_id) {$q->where('seller_id', $seller_id);}) + ->whereHas('logs', function ($query) use ($start, $end) { + $query->where('state', 'DELIVERED|SIGNED')->when($start && $end, function ($query) use ($start, $end) { + $query->whereBetween('created_at', [$start, date('Y-m-d', strtotime("+1 days", strtotime($end)))]); + }) + ->when($start && !$end, function ($query) use ($start) { + $query->where('created_at', '>=', $start); + }) + ->when((!$start && $end), function ($query) use ($end) { + $query->where('created_at', '<=', date('Y-m-d', strtotime("+1 days", strtotime($end)))); + }); + })->where('state', '<>',Order::ORDER_CLOSED)->pluck('id'); + if (!empty($orderids[$key])) { + self::insertReport($orderids[$key], 'SIGNED', $starta, $seller_id); + } + + $orderDeliveredids[$key] = Order::when($seller_id, function ($q) use ($seller_id) {$q->where('seller_id', $seller_id);}) + ->whereHas('logs', function ($query) use ($start, $end) { + $query->where('state', 'PAID|DELIVERED')->when($start && $end, function ($query) use ($start, $end) { + $query->whereBetween('created_at', [$start, date('Y-m-d', strtotime("+1 days", strtotime($end)))]); + }) + ->when($start && !$end, function ($query) use ($start) { + $query->where('created_at', '>=', $start); + }) + ->when((!$start && $end), function ($query) use ($end) { + $query->where('created_at', '<=', date('Y-m-d', strtotime("+1 days", strtotime($end)))); + }); + })->where('state', '<>',Order::ORDER_CLOSED)->pluck('id'); + if (!empty($orderids[$key])) { + self::insertReport($orderDeliveredids[$key], 'DELIVERED', $starta, $seller_id); + } + } + + } + + private static function insertReport($orderids, $type, $starta, $seller_id) + { + $detail = OrderDetail::select(DB::raw('sum(number) as number_sum, sum(score * number) as score_sum, sum(price * number) as price_sum, sum(seller_price * number) as seller_price_sum')) + ->whereIn('order_id', $orderids)->first(); + if (!empty($detail) && $detail->number_sum) { + $order = Order::select(DB::raw('count(*) as order_total, sum(freight) as freight_sum, sum(seller_freight) as seller_freight_sum, sum(amount) as orders_price, sum(score) as orders_score,sum(seller_amount) as seller_amount_sum')) + ->whereIn('id', $orderids)->first(); + $report = SalesReport::where(['seller_id' => $seller_id, 'state' => $type, 'action_time' => $starta])->first(); + if (empty($report)) { + SalesReport::create([ + 'state' => $type, + 'action_time' => $starta, + 'goods_total' => $detail->number_sum, + 'goods_price_total' => $detail->price_sum, + 'goods_score_total' => $detail->score_sum, + 'orders_total' => $order->order_total, + 'orders_price' => $order->orders_price, + 'orders_score' => $order->orders_score, + 'orders_freight' => $order->freight_sum, + 'seller_id' => $seller_id, + 'seller_total' => $order->seller_amount_sum, + 'seller_freight' => $order->seller_freight_sum, + ]); + } + } + + } +} diff --git a/app/Console/Commands/ProfitCommand.php b/app/Console/Commands/ProfitCommand.php new file mode 100644 index 0000000..57f522b --- /dev/null +++ b/app/Console/Commands/ProfitCommand.php @@ -0,0 +1,59 @@ +toDateTimeString())->where('status', 0)->first(); + + if ($info) { + if ($info->price > 0) { + $users = IdentityPoint::where('created_at', '<', $info->end_at)->distinct()->pluck('user_id'); + foreach ($users as $key => $user_id) { + ProfitJob::dispatch($user_id, $info); + } + } + $info->status = 1; + $info->save(); + } + } +} diff --git a/app/Console/Commands/WindupReportCommand.php b/app/Console/Commands/WindupReportCommand.php new file mode 100644 index 0000000..cc9a728 --- /dev/null +++ b/app/Console/Commands/WindupReportCommand.php @@ -0,0 +1,52 @@ +autoReport(); + + } + +} diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php new file mode 100644 index 0000000..dfedbea --- /dev/null +++ b/app/Console/Kernel.php @@ -0,0 +1,47 @@ +command('inspire') + // ->hourly(); + $schedule->command('rulong:ProfitCommand')->dailyAt('22:00'); //总裁,总裁导师,创始总裁分红定时任务 + $schedule->command('rulong:OrderDataCommand')->dailyAt('1:00');//每日签收汇总、发货汇总记录生成 + $schedule->command('rulong:WindupReportCommand')->monthlyOn(1, '2:00');;//每个月1日生成上个月16日-月末的结算记录。 + $schedule->command('rulong:WindupReportCommand')->monthlyOn(16, '2:00');;//每个月16日生成1-15日结算记录。 + + } + + /** + * Register the commands for the application. + * + * @return void + */ + protected function commands() + { + $this->load(__DIR__ . '/Commands'); + + require base_path('routes/console.php'); + } +} diff --git a/app/Contracts/Advertable.php b/app/Contracts/Advertable.php new file mode 100644 index 0000000..c481990 --- /dev/null +++ b/app/Contracts/Advertable.php @@ -0,0 +1,13 @@ +order = $order; + } +} diff --git a/app/Events/Lottery.php b/app/Events/Lottery.php new file mode 100644 index 0000000..21fd41c --- /dev/null +++ b/app/Events/Lottery.php @@ -0,0 +1,22 @@ +log = $log; + } +} diff --git a/app/Events/OrderCompleted.php b/app/Events/OrderCompleted.php new file mode 100644 index 0000000..6097a4d --- /dev/null +++ b/app/Events/OrderCompleted.php @@ -0,0 +1,23 @@ +order = $order; + } +} diff --git a/app/Events/ShareFullCompleted.php b/app/Events/ShareFullCompleted.php new file mode 100644 index 0000000..6b0ae26 --- /dev/null +++ b/app/Events/ShareFullCompleted.php @@ -0,0 +1,23 @@ +user = $user; + } +} diff --git a/app/Events/VipPaid.php b/app/Events/VipPaid.php new file mode 100644 index 0000000..400efb5 --- /dev/null +++ b/app/Events/VipPaid.php @@ -0,0 +1,23 @@ +vip_pament = $vip_pament; + } +} diff --git a/app/Events/WithdrawCompleted.php b/app/Events/WithdrawCompleted.php new file mode 100644 index 0000000..5e1a1aa --- /dev/null +++ b/app/Events/WithdrawCompleted.php @@ -0,0 +1,21 @@ +withdraw = $withdraw; + } +} diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php new file mode 100644 index 0000000..290c19d --- /dev/null +++ b/app/Exceptions/Handler.php @@ -0,0 +1,57 @@ +url())) { + return ApiExceptionHandler::render($request, $exception); + } else { + return parent::render($request, $exception); + } + } +} diff --git a/app/Helpers/CDKEY.php b/app/Helpers/CDKEY.php new file mode 100644 index 0000000..32a1a05 --- /dev/null +++ b/app/Helpers/CDKEY.php @@ -0,0 +1,110 @@ + + * @Date:2018-12-23T12:13:15+0800 + * @return [type] [description] + */ + public static function generator($code, $format = 'svg', $size = 300) + { + $URL = self::encode($code); + switch ($format) { + case 'svg': + $qrcode = QrCode::format('svg')->errorCorrection("L")->size($size)->margin(0)->generate($URL); + break; + case 'png': + $qrcode = 'data:image/png;base64,' . base64_encode(QrCode::format('svg')->errorCorrection("L")->size($size)->margin(0)->generate($URL)); + break; + default: + throw new \Exception('非法图片格式'); + break; + } + return [ + 'url' => $URL, + 'qrcode' => $qrcode, + ]; + } + + public static function parse($string): string + { + $string = str_replace(' ', '+', $string); + $string = str_replace('-', '/', $string); + + return self::authCode($string); + } + + /** + * 加密方法 + * @Author: + * @Date:2018-12-23T12:18:07+0800 + * @param [type] $string 要加密的 + * @param string $operation 操作 + * @param string $key 密钥 + * @param integer $expiry 过期时间 + * @return [type] [description] + */ + public static function authCode($string, $operation = 'DECODE', $key = '', $expiry = 0): string + { + $ckey_length = 4; + + $key = md5($key ? $key : self::$key); + $keya = md5(substr($key, 0, 16)); + $keyb = md5(substr($key, 16, 16)); + $keyc = $ckey_length ? ($operation == 'DECODE' ? substr($string, 0, $ckey_length) : substr(md5(microtime()), -$ckey_length)) : ''; + + $cryptkey = $keya . md5($keya . $keyc); + $key_length = strlen($cryptkey); + + $string = $operation == 'DECODE' ? base64_decode(substr($string, $ckey_length)) : sprintf('%010d', $expiry ? $expiry + time() : 0) . substr(md5($string . $keyb), 0, 16) . $string; + $string_length = strlen($string); + $result = ''; + $box = range(0, 255); + $rndkey = array(); + + for ($i = 0; $i <= 255; $i++) { + $rndkey[$i] = ord($cryptkey[$i % $key_length]); + } + + for ($j = $i = 0; $i < 256; $i++) { + $j = ($j + $box[$i] + $rndkey[$i]) % 256; + $tmp = $box[$i]; + $box[$i] = $box[$j]; + $box[$j] = $tmp; + } + + for ($a = $j = $i = 0; $i < $string_length; $i++) { + $a = ($a + 1) % 256; + $j = ($j + $box[$a]) % 256; + $tmp = $box[$a]; + $box[$a] = $box[$j]; + $box[$j] = $tmp; + $result .= chr(ord($string[$i]) ^ ($box[($box[$a] + $box[$j]) % 256])); + } + if ($operation == 'DECODE') { + if ((substr($result, 0, 10) == 0 || substr($result, 0, 10) - time() > 0) && substr($result, 10, 16) == substr(md5(substr($result, 26) . $keyb), 0, 16)) { + return substr($result, 26); + } else { + return ''; + } + } else { + return $keyc . str_replace('=', '', base64_encode($result)); + } + } +} diff --git a/app/Helpers/Location.php b/app/Helpers/Location.php new file mode 100644 index 0000000..c02d591 --- /dev/null +++ b/app/Helpers/Location.php @@ -0,0 +1,21 @@ + 1000) { + return round($juli / 1000, 1) . 'Km'; + } else { + return $juli . 'M'; + } + } +} diff --git a/app/Helpers/Params.php b/app/Helpers/Params.php new file mode 100644 index 0000000..a6ca9d0 --- /dev/null +++ b/app/Helpers/Params.php @@ -0,0 +1,36 @@ +value('value'); + + switch ($type) { + case 'string': + return $value; + break; + case 'array': + $array = preg_split('/[\r\n]+/', trim($value, "\r\n")); + if (strpos($value, ':')) { + $value = []; + foreach ($array as $val) { + [$k, $v] = explode(':', $val, 2); + $value[$k] = $v; + } + } else { + $value = $array; + } + return $value; + break; + default: + return $value; + break; + } + } +} diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php new file mode 100644 index 0000000..f09a2bf --- /dev/null +++ b/app/Http/Controllers/AccountController.php @@ -0,0 +1,70 @@ +middleware('auth'); + view()->share('nav', 2); + } + + public function index(Request $request) + { + $reward_total = Auth::user()->account->logs()->where('type', 'cash')->where('rule_id', 2)->sum('variable'); + $freezing_total = Auth::user()->account->logs()->where('type', 'cash')->where('frozen', 1)->sum('variable'); + $logs = Auth::user()->account->logs()->where('type', 'cash')->orderBy('created_at', 'desc')->get(); + return view('account.index', compact('reward_total', 'freezing_total', 'logs')); + } + + public function coupon(Request $request, $type = 'unuse') + { + if ($type == 'unuse') { + $status = 0; + } else { + $status = 1; + } + $list = CouponUserLog::with('info')->where('user_id', Auth::id())->where('status', $status)->get(); + return view('account.coupon', compact('type', 'list')); + } + + // public function score(Request $request) + // { + // $type = $request->logType; + // $logs = Auth::user()->account->logs() + // ->when($type, function ($query) use ($type) { + // switch ($type) { + // case 'ALL': + // break; + // case 'PLUS': + // $query->where('variable', '>', 0); + // break; + // case 'MINUS': + // $query->where('variable', '<', 0); + // break; + // case 'EXPIRE': + // $query->where('variable', '>', 0); + // break; + // default: + // break; + // } + // }) + // ->where('type', 'score') + // ->orderBy('created_at', 'desc')->get(); + // $score_explain = \Params::get('score_explain'); + + // $score_explain = str_replace("\n", "
", $score_explain); + // $score_explain = str_replace("\r", "
", $score_explain); + + // return view('account.score', compact('logs', 'score_explain')); + // } + +} diff --git a/app/Http/Controllers/ActivityController.php b/app/Http/Controllers/ActivityController.php new file mode 100644 index 0000000..810e32c --- /dev/null +++ b/app/Http/Controllers/ActivityController.php @@ -0,0 +1,71 @@ +middleware('auth'); + View::share('nav', 1); + } + + public function index(Category $category) + { + if (in_array($category->id, [13, 14])) { + $categorys = Category::with('storage')->where('parent_id', $category->id)->orderby('sort', 'asc')->get(); + $category_ids = Category::where('parent_id', $category->id)->pluck('id'); + } else { + $categorys = Category::with('storage')->where('parent_id', $category->parent_id)->orderby('sort', 'asc')->get(); + $category_ids = Category::where('id', $category->id)->pluck('id'); + } + $activitys = Activity::inRandomOrder()->whereIn('category_id', $category_ids)->get(); + + return view('activity.index', compact('activitys', 'categorys', 'category')); + } + + public function show(Activity $activity) + { + return view('activity.show', compact('activity')); + } + + public function create(Request $request, Activity $activity) + { + return view('activity.create', compact('activity')); + } + + //生成核销二维码 + public function qrcode(Request $request) + { + $orderid = $request->orderid; + $order = Order::find($orderid); + + if (!$order) { + return Image::canvas(200, 200)->text('没有这个订单', 50, 100, function ($font) { + $font->file('fonts/yahei.ttf')->color('#1f1f1f')->size(21); + })->response('jpg'); + } elseif ($order->item_type != 'ACTIVITY') { + return Image::canvas(200, 200)->text('订单类型不对', 50, 100, function ($font) { + $font->file('fonts/yahei.ttf')->color('#1f1f1f')->size(21); + })->response('jpg'); + } + + if (!$order->canActivityAudit()) { + return $this->error('订单状态不对'); + } + + $activity = $order->detail->item_id; + $qrCode = Image::make(QrCode::size(3000)->format('png')->margin(1)->generate(route('sellers.verification', ['orderid' => $orderid])))->resize(230, 230); + return $qrCode->response('jpg'); + } + +} diff --git a/app/Http/Controllers/AddressController.php b/app/Http/Controllers/AddressController.php new file mode 100644 index 0000000..33c9ff4 --- /dev/null +++ b/app/Http/Controllers/AddressController.php @@ -0,0 +1,121 @@ +middleware('auth'); + view()->share('nav', 4); + } + + public function index() + { + $addresses = Auth::user()->addresses()->orderBy('is_default', 'desc')->orderBy('id', 'desc')->get(); + + if ($addresses->isEmpty()) { + return redirect()->route('addresses.create'); + } + return view('address.index', compact('addresses')); + } + + public function show() + { + # code... + } + public function create(Request $request) + { + $provinces = \Area::index(0); + return view('address.create', compact('provinces')); + } + + public function store(Request $request) + { + + \Address::store( + [ + 'user_id' => Auth::id(), + 'name' => $request->name, + 'mobile' => $request->mobile, + 'province_sn' => $request->province_sn, + 'city_sn' => $request->city_sn, + 'area_sn' => $request->area_sn, + 'address' => $request->address, + ] + ); + $address = UserAddress::where('user_id', Auth::id())->orderBy('id', 'desc')->first(); + if ($request->def) { + \Address::setDefault($address); + } + if ($request->callback) { + $callback = $request->callback . '?address=' . $address->id; + } else { + $callback = route('addresses.index'); + } + return $this->success('地址创建成功', $callback); + } + + public function edit(UserAddress $address) + { + $provinces = \Area::index(0); + $cities = \Area::index($address->province_sn); + $areas = \Area::index($address->city_sn); + return view('address.edit', compact('address', 'provinces', 'cities', 'areas')); + } + + public function update(Request $request, UserAddress $address) + { + if (\Address::update($address, $request->all())) { + return $this->success('修改成功', route('addresses.index')); + } else { + return $this->error('修改失败'); + } + } + + public function destroy($id) + { + if (\Address::destroy($id)) { + return $this->success('删除成功', route('addresses.index')); + } else { + return $this->error(); + } + } + + public function select(Request $request) + { + $callback = $request->has('callback') ? $request->callback : route('orders.create'); + $addresses = Auth::user()->addresses()->orderBy('is_default', 'desc')->orderBy('id', 'desc')->get(); + return view('address.change', compact('addresses', 'callback')); + } + + public function areas(Request $request) + { + if (empty($request->psn)) { + return ['msg' => '请选择省份', 'code' => 0]; + } + + $areas = \Area::sub($request->psn); + + if ($areas) { + return response()->json(['msg' => '', 'code' => 1, 'data' => $areas]); + } else { + return ['msg' => '请选择省份/城市', 'code' => 0]; + } + } + + public function setdef($id) + { + if (\Address::setDefault(UserAddress::find($id))) { + return $this->success('设置成功', route('addresses.index')); + } else { + return $this->error(); + } + } +} diff --git a/app/Http/Controllers/AgencyController.php b/app/Http/Controllers/AgencyController.php new file mode 100644 index 0000000..e73456c --- /dev/null +++ b/app/Http/Controllers/AgencyController.php @@ -0,0 +1,72 @@ +middleware('auth'); + View::share('nav', 2); + } + + public function index(Request $request) + { + $user = Auth::user(); + $user = User::find(1); + if (!$user->agency || $user->agency->status != 1) { + return redirect()->route('user.index'); + } + $category = $request->category; + + $sellers = Seller::with(['category']) + ->withCount('lesson') + ->where('agency_id', $user->agency->id) + ->when(is_numeric($category), function ($q) use ($category) { + $q->where('category_id', $category); + }) + ->get(); + $categoryids = Seller::where('agency_id', $user->agency->id)->groupBy('category_id')->pluck('category_id')->toArray(); + $categorys = Category::whereIn('id', $categoryids)->get(); + return view('agency.index', compact('sellers', 'categorys')); + } + + public function lesson(Request $request, Seller $seller) + { + $lessons = SellerLesson::withCount('logs')->where('seller_id', $seller->id)->get(); + return view('agency.lesson', compact('lessons', 'seller')); + } + + public function data() + { + $user = Auth::user(); + $user = User::find(1); + if (!$user->agency || $user->agency->status != 1) { + return redirect()->route('user.index'); + } + $dayBetween = [Carbon::today()->toDateTimeString(), Carbon::today()->addSecond(86399)->toDateTimeString()]; + + $sellerids = Seller::where('agency_id', $user->agency->id)->pluck('id')->toArray(); + $lessonids = SellerLesson::whereIn('seller_id', $sellerids)->pluck('id')->toArray(); + + $data = [ + 'seller_count' => count($sellerids), //机构总数 + 'lessons_count' => count($lessonids), //课程总数 + 'apply_lesson_all' => SellerLessonLog::whereIn('lesson_id', $lessonids)->count(), //报名总数 + 'apply_lesson_day' => SellerLessonLog::whereIn('lesson_id', $lessonids)->whereBetween('created_at', $dayBetween)->count(), //今日报名数 + ]; + return view('agency.data', compact('data')); + } + +} diff --git a/app/Http/Controllers/AjaxResponse.php b/app/Http/Controllers/AjaxResponse.php new file mode 100644 index 0000000..d374c19 --- /dev/null +++ b/app/Http/Controllers/AjaxResponse.php @@ -0,0 +1,28 @@ + 'SUCCESS', + 'statusCode' => 200, + 'message' => $message, + 'redirect' => $redirect, + ]; + } + + public function error($message = '', $redirect = null) + { + return [ + 'status' => 'ERROR', + 'statusCode' => 400, + 'message' => $message, + 'redirect' => $redirect, + ]; + } + +} diff --git a/app/Http/Controllers/AuthController.php b/app/Http/Controllers/AuthController.php new file mode 100644 index 0000000..a197e26 --- /dev/null +++ b/app/Http/Controllers/AuthController.php @@ -0,0 +1,431 @@ +middleware('guest')->except(['logout', 'smsCode']); + } + + public function register(Request $request) + { + if ($request->isMethod('post')) { + $request->validate([ + 'mobile' => ['required', 'unique:users', new Checkmobile], + 'verify' => ['required', 'size:4', function ($attribute, $value, $fail) use ($request) { + if ($value != SmsModel::where('mobile', $request->mobile)->where('used', 0)->latest()->value('code')) { + return $fail('验证码不正确'); + } + }], + 'password' => 'required|between:6,32|confirmed', + 'password_confirmation' => 'required|between:6,32', + ], [ + 'mobile.required' => '手机号码必须填写', + 'mobile.unique' => '手机号已经注册', + 'verify.required' => '验证码必须填写', + 'verify.size' => '验证码长度为:size位', + 'password.required' => '登录密码必须填写', + 'password.between' => '登录密码有误', + 'password.confirmed' => '确认密码与登录密码不一致', + 'password_confirmation.required' => '确认密码必须填写', + 'password_confirmation.between' => '确认密码有误', + ]); + + $Original = session('Original'); + if ($Original) { + $app = app('wechat.official_account'); + + $openUser = $app->user->get($Original['openid']); + $Original['subscribe_at'] = $openUser->subscribe_time; + $Original['subscribe_scene'] = $openUser->subscribe_scene; + $Original['qr_scene'] = $openUser->qr_scene; + $Original['qr_scene_str'] = $openUser->qr_scene_str; + } + + $parent_id = session('parent_id', 0); + $seller_id = 0; + if ($parent_id) { + $parent = User::find($parent_id); + $seller_id = $parent->seller_id ?? '0'; + } + + $findUser = User::where('openid', $Original['openid'])->first(); + if ($findUser) { + return $this->success('注册失败:此微信已被使用'); + } + $user = User::updateOrCreate( + [ + 'openid' => $Original['openid'], + 'mobile' => $request->mobile, + 'seller_id' => $seller_id, + 'password' => $request->password, + ], + [ + 'parent_id' => session('parent_id', 0), + 'info' => [ + 'nickname' => $Original['nickname'], + 'headimgurl' => $Original['headimgurl'], + 'sex' => $Original['sex'], + 'country' => $Original['country'], + 'province' => $Original['province'], + 'city' => $Original['city'], + 'subscribe_at' => $Original['subscribe_at'] ?? null, + 'subscribe_scene' => $Original['subscribe_scene'] ?? null, + 'qr_scene' => $Original['qr_scene'] ?? null, + 'qr_scene_str' => $Original['qr_scene_str'] ?? null, + ], + ] + ); + + Session::forget('parent_id'); + + // 实现注册完自动登录 + Auth::login($user); + event(new Registered($user)); + + return $this->success('注册成功', route('baby')); + } else { + if (Session::has('Original') === false) { + $app = app('wechat.official_account'); + $app['config']->set('oauth.callback', 'register/auth/wechat'); + return $app->oauth->redirect(); + } + return view('auth.register'); + } + } + + /** + * 用户登录 * + * @Author: + * @Date:2018-11-07T13:47:02+0800 + * @param Request $request + */ + public function login(Request $request) + { + if ($request->isMethod('POST')) { + $Original = session('Original'); + + $validator = Validator::make($request->all(), [ + 'mobile' => 'required|mobile|exists:users', + 'password' => 'required|between:6,32', + ], [ + 'mobile.required' => '手机号码必须填写', + 'mobile.mobile' => '手机号码格式不正确', + 'mobile.exists' => '手机号码不存在', + 'password.required' => '登录密码必须填写', + 'password.between' => '登录密码应在:min-:max位之间', + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + + $cert = [ + 'mobile' => $request->mobile, + 'password' => $request->password, + ]; + + if (Auth::attempt($cert, true)) { + $reback = $request->r ?: route('index.index'); + return $this->success('登录成功', $reback); + } else { + return $this->error('用户名或密码不存在'); + } + } else { + return view('auth.login'); + } + } + + public function regwechat() + { + $app = app('wechat.official_account'); + $weUser = $app->oauth->user(); + $Original = $weUser->getOriginal(); + Session::put('Original', $Original); + return redirect()->route('register'); + } + + /** + * 微信登录 、微信快速注册 * + * 注册完之后,在这里没有办法判断推荐关系 + * + * @Author: + * @Date:2018-11-07T13:44:34+0800 + * @param Request $request + */ + public function wechat(Request $request) + { + + if (strpos($request->server('HTTP_USER_AGENT'), 'MicroMessenger') !== false) { + $app = app('wechat.official_account'); + $app['config']->set('oauth.callback', 'login/wechatCallback'); + return $app->oauth->redirect(); + } else { + return redirect()->route('login'); + } + } + + public function wechatCallback(Request $request) + { + try { + $app = app('wechat.official_account'); + $weUser = $app->oauth->user(); + $callback = $request['callback'] ?? ''; + $openUser = $app->user->get($weUser->id); + $oldUser = User::where('openid', $weUser->id)->first(); + if ($oldUser) { + $oldUser->info->update([ + 'headimgurl' => $weUser->getOriginal()['headimgurl'], + 'sex' => $weUser->getOriginal()['sex'], + 'country' => $weUser->getOriginal()['country'], + 'province' => $weUser->getOriginal()['province'], + 'city' => $weUser->getOriginal()['city'], + 'subscribe_at' => $openUser->subscribe_time ?? null, + 'subscribe_scene' => $openUser->subscribe_scene ?? '', + 'qr_scene' => $openUser->qr_scene ?? '', + 'qr_scene_str' => $openUser->qr_scene_str ?? '', + ]); + Auth::login($oldUser, true); + if ($callback) { + $callback = base64_decode($callback); + return redirect($callback); + } else { + return redirect()->route('user.index'); + } + } else { + // $user = User::updateOrCreate( + // [ + // 'openid' => $weUser->id, + // ], + // [ + // 'parent_id' => session('parent_id', 1), + // 'info' => [ + // 'nickname' => $weUser->getOriginal()['nickname'], + // 'headimgurl' => $weUser->getOriginal()['headimgurl'], + // 'sex' => $weUser->getOriginal()['sex'], + // 'country' => $weUser->getOriginal()['country'], + // 'province' => $weUser->getOriginal()['province'], + // 'city' => $weUser->getOriginal()['city'], + // 'source' => 'Web', + // 'subscribe_at' => $openUser->subscribe_time ?? null, + // 'subscribe_scene' => $openUser->subscribe_scene ?? '', + // 'qr_scene' => $openUser->qr_scene ?? '', + // 'qr_scene_str' => $openUser->qr_scene_str ?? '', + // ], + // ] + // ); + // event(new Registered($user)); + // Auth::login($user, true); + // if ($callback) { + // $callback = base64_decode($callback); + // return redirect($callback); + // } else { + // return redirect()->route('vip.create'); + // } + return redirect()->route('register'); + } + /** + * 这个注册完成事件,只能把 updateOrCreate 这个方法拆分开来使用了 + */ + } catch (\Exception $e) { + return redirect()->route('login'); + } + } + + /** + * 验证码登录 * + * @Author: + * @Date:2018-11-07T13:46:10+0800 + * @param Request $request + */ + public function bycode(Request $request) + { + if ($request->isMethod('POST')) { + + $validator = Validator::make($request->all(), [ + 'mobile' => 'required|mobile|exists:users', + 'code' => 'required|sms_check:mobile,BYCODE', + ], [ + 'mobile.required' => '手机号码必须填写', + 'mobile.mobile' => '手机号码格式不正确', + 'mobile.exists' => '手机号码不存在', + 'code.required' => '验证码必须填写', + 'code.sms_check' => '验证码不正确', + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + + $user = User::where('mobile', $request->mobile)->first(); + try { + Auth::login($user, true); + return $this->success('登录成功', route('user.index')); + } catch (\Exception $e) { + return $this->error($e->getMessage()); + } + } else { + return view('auth.bycode'); + } + } + + /** + * 找回密码 + * @Author: + * @Date:2018-11-07T13:46:34+0800 + * @param Request $request + */ + public function forgot(Request $request) + { + if ($request->isMethod('POST')) { + $validator = Validator::make($request->all(), [ + 'mobile' => 'required|mobile|exists:users', + 'code' => 'required|sms_check:mobile,FORGOT', + ], [ + 'mobile.required' => '手机号码必须填写', + 'mobile.mobile' => '手机号码格式不正确', + 'mobile.exists' => '手机号码不存在', + 'code.required' => '验证码必须填写', + 'code.sms_check' => '验证码不正确', + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + + $request->session()->put('reset_mobile', $request->mobile); + + return $this->success('身份验证成功', Url::temporarySignedRoute('forgot.reset', now()->addHour())); + } else { + return view('auth.forgot'); + } + } + + public function reset(Request $request) + { + if ($request->isMethod('POST')) { + $validator = Validator::make($request->all(), [ + 'password' => 'required|between:6,32', + ], [ + 'password.required' => '登录密码必须填写', + 'password.mobile' => '登录密码应在:min-:max位之间', + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + + $reset_mobile = $request->session()->pull('reset_mobile'); + $password = $request->password; + + try { + $user = User::where('mobile', $reset_mobile)->first(); + $user->password = $password; + $user->save(); + return $this->success('密码重置成功', route('login')); + } catch (\Exception $e) { + return $this->success('密码重置失败', route('forgot')); + } + } else { + return view('auth.reset'); + } + } + + /** + * 退出登录 + * @Author: + * @Date:2018-11-07T13:46:45+0800 + */ + public function logout() + { + Auth::logout(); + session()->flush(); + return redirect()->route('login'); + } + + /** + * 发送验证码 + * @Author: + * @Date:2018-11-07T13:49:55+0800 + * @return + */ + public function smsCode(Request $request) + { + $channel = $request->channel; + $mobile = $request->mobile; + switch ($channel) { + case 'BYCODE': + case 'FORGOT': + // 验证码登录,必须要手机号存在才行 + $validator = Validator::make($request->all(), [ + 'mobile' => ['required', 'exists:users', new Checkmobile], + ], [ + 'mobile.required' => '手机号码必须填写', + 'mobile.mobile' => '手机号码格式不正确', + 'mobile.exists' => '手机号码不存在', + ]); + break; + case 'BIND': + // 绑定手机号,要不存在才可以 + $validator = Validator::make($request->all(), [ + 'mobile' => ['required', 'unique:users', new Checkmobile], + ], [ + 'mobile.required' => '手机号码必须填写', + 'mobile.mobile' => '手机号码格式不正确', + 'mobile.unique' => '手机号码已经绑定', + ]); + break; + case 'BINDLast': + $channel = 'DEFAULT'; + $validator = Validator::make($request->all(), [ + 'mobile' => 'required|mobile', + ], [ + 'mobile.required' => '手机号码必须填写', + 'mobile.mobile' => '手机号码格式不正确', + ]); + break; + default: + $validator = Validator::make($request->all(), [ + 'mobile' => ['required', new Checkmobile], + ], [ + 'mobile.required' => '手机号码必须填写', + ]); + break; + } + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + + $res = SmsModel::verify_code($request->mobile); + if ($res !== true) { + return $this->error($res); + } + + try { + $code = \Sms::send($mobile, $channel); + $config = config('rulong_sms'); + if ($config['debug'] != true) { + return $this->success('验证码发送成功'); + } else { + return $this->success('验证码发送成功' . $code); + } + } catch (\Exception $e) { + return $this->error($e->getMessage()); + } + } +} diff --git a/app/Http/Controllers/CartController.php b/app/Http/Controllers/CartController.php new file mode 100644 index 0000000..91feb75 --- /dev/null +++ b/app/Http/Controllers/CartController.php @@ -0,0 +1,93 @@ +middleware('auth')->except(['store']); + View::share('nav', 3); + } + + public function index(Request $request) + { + $lists = Cart::mine()->with('lesson')->orderBy('id', 'desc')->get(); + + $gifts = GoodsParams::whereHas('goods', function ($query) { + $query->where('status', 1)->where('is_seller_gift', 1); + })->where('stock', '>', 0)->get(); + + $coupon_list = CouponUserLog::with('info')->whereHas('info', function ($query) { + $query->where('type', 'lesson') + ->where('start_at', '<=', date('Y-m-d H:i:s', time())) + ->where('end_at', '>=', date('Y-m-d H:i:s', time())); + })->where('user_id', Auth::id())->where('status', 0)->get(); + + $coupon = $coupon_list->sortByDesc(function ($coupon, $key) { + return $coupon->info->bouns; + })->first(); + + $apply_lesson_price = \Params::get('apply_lesson_price'); + return view('cart.index', compact('lists', 'gifts', 'coupon', 'apply_lesson_price')); + } + + public function show(Request $request, $params_id) + { + $info = GoodsParams::with('goods.storage')->find($params_id); + return view('cart.show', compact('info')); + } + + public function delete(Cart $cart) + { + if ($cart->delete()) { + return $this->success('取消成功'); + } else { + return $this->error('取消失败'); + } + } + + public function store(SellerLesson $lesson) + { + if (Auth::guest()) { + return $this->error('请登录后在进行此操作', route('login')); + } + + $user_id = Auth::id(); + $max_num = \Params::get('lesson_num'); + $count = Cart::where('user_id', $user_id)->count(); + + if ($count >= $max_num) { + return $this->error('您已经报满' . $max_num . '个机构课程请前去支付', route('cart.index')); + } + + $info = Cart::where('lesson_id', $lesson->id)->where('user_id', $user_id)->first(); + if ($info) { + return $this->error('您已经报名此课程'); + } + + $seller = Cart::where('seller_id', $lesson->organ->id)->where('user_id', $user_id)->first(); + if ($seller) { + return $this->error('一个机构只能报名一门课程'); + } + + $result = Cart::create([ + 'user_id' => Auth::id(), + 'lesson_id' => $lesson->id, + 'seller_id' => $lesson->organ->id, + 'number' => 1, + ]); + return $this->success('报名成功', route('cart.index')); + + } +} diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php new file mode 100644 index 0000000..d935586 --- /dev/null +++ b/app/Http/Controllers/Controller.php @@ -0,0 +1,70 @@ + $request['share_uid']]); + } + + // $this->middleware('auth'); + + //检查是否有礼品 + self::checkGift(); + } + + //获取当前定位数组 + public function getDefaultLocation() + { + $lat = session('lat', '45.76021'); + $lng = session('lng', '126.66835'); + $city = session('city', ''); + $area = session('area', ''); + $real_area = session('real_area', ''); + $history_area = session('history_area', ''); + if (!$area) { + $area = Area::where('sn', '230100')->first(); + } + + if (!$real_area) { + session::put('real_area', $area); + $real_area = session('real_area', ''); + } + $location = [ + 'lat' => $lat, + 'lng' => $lng, + 'city' => $city, + 'area' => $area, + 'real_area' => $real_area, + 'history_area' => $history_area, + ]; + return $location; + } + + public function checkGift() + { + if (Auth::user()) { + $gift = Order::where('user_id', Auth::id())->where('item_type', 'GIFT')->where('state', 'UNADDRESS')->first(); + if ($gift) { + $url = ($gift->type == 'lesson') ? route('gifts.unpay') : route('lottery.logs', ['type' => 'goods']); + View::share('show_gift_url', $url); + } + } + } +} diff --git a/app/Http/Controllers/CouponController.php b/app/Http/Controllers/CouponController.php new file mode 100644 index 0000000..bcef482 --- /dev/null +++ b/app/Http/Controllers/CouponController.php @@ -0,0 +1,29 @@ +middleware('auth'); + view()->share('nav', 2); + } + + public function select(Request $request) + { + $coupon_list = CouponUserLog::with('info')->whereHas('info', function ($query) { + $query->where('type', 'lesson') + ->where('start_at', '<=', date('Y-m-d H:i:s', time())) + ->where('end_at', '>=', date('Y-m-d H:i:s', time())); + })->where('user_id', Auth::id())->where('status', 0)->get(); + + return view('coupon.select', compact('coupon_list')); + } + +} diff --git a/app/Http/Controllers/DataController.php b/app/Http/Controllers/DataController.php new file mode 100644 index 0000000..a9f0e17 --- /dev/null +++ b/app/Http/Controllers/DataController.php @@ -0,0 +1,266 @@ +middleware('auth'); + view()->share('nav', 2); + $this->todayTime = [Carbon::today()->toDateTimeString(), Carbon::today()->addSecond(86399)->toDateTimeString()]; + } + + public function users() + { + $today = [ + 'reg' => User::whereBetween('created_at', $this->todayTime)->count(), + 'counselor' => UserIdentity::whereHas('user')->where('identity_id', 1)->whereBetween('created_at', $this->todayTime)->count(), + 'agency' => UserIdentity::whereHas('user')->where('identity_id', 2)->whereBetween('created_at', $this->todayTime)->count(), + 'manage' => UserIdentity::whereHas('user')->where('identity_id', 3)->whereBetween('created_at', $this->todayTime)->count(), + 'teacher' => UserIdentity::whereHas('user')->where('identity_id', 4)->whereBetween('created_at', $this->todayTime)->count(), + 'salesman' => User::whereBetween('created_at', $this->todayTime)->where('is_salesman', 1)->count(), + ]; + + $all = [ + 'reg' => User::count(), + 'counselor' => UserIdentity::whereHas('user')->where('identity_id', 1)->count(), + 'agency' => UserIdentity::whereHas('user')->where('identity_id', 2)->count(), + 'manage' => UserIdentity::whereHas('user')->where('identity_id', 3)->count(), + 'teacher' => UserIdentity::whereHas('user')->where('identity_id', 4)->count(), + 'salesman' => User::where('is_salesman', 1)->count(), + ]; + return view('data.users', compact('today', 'all')); + } + + public function orders() + { + $state = [ + 'PAID', 'DELIVER', 'DELIVERED', 'SIGNED', 'COMPLETED', 'UNUSE', 'USED', 'UNADDRESS', + ]; + $today = [ + 'all' => Order::whereIn('state', $state)->whereBetween('created_at', $this->todayTime)->count(), + 'lesson' => Order::whereIn('state', $state)->where('type', 'order')->where('item_type', 'LESSON')->whereBetween('created_at', $this->todayTime)->count(), + 'activity_all' => Order::whereIn('state', $state)->where('item_type', 'ACTIVITY')->whereBetween('created_at', $this->todayTime)->count(), + 'activity' => [ + 'buy' => Order::whereIn('state', $state)->where('type', 'order')->where('item_type', 'ACTIVITY')->whereBetween('created_at', $this->todayTime)->count(), + 'give' => Order::whereIn('state', $state)->where('type', 'lottery')->where('item_type', 'ACTIVITY')->whereBetween('created_at', $this->todayTime)->count(), + ], + 'gift_all' => Order::whereIn('state', $state)->where('item_type', 'GIFT')->whereBetween('created_at', $this->todayTime)->count(), + 'gift' => [ + 'lesson' => Order::whereIn('state', $state)->where('item_type', 'GIFT')->where('type', 'lesson')->whereBetween('created_at', $this->todayTime)->count(), + 'lottery' => Order::whereIn('state', $state)->where('item_type', 'GIFT')->where('type', 'lottery')->whereBetween('created_at', $this->todayTime)->count(), + ], + ]; + + $all = [ + 'all' => Order::whereIn('state', $state)->count(), + 'lesson' => Order::whereIn('state', $state)->where('type', 'order')->where('item_type', 'LESSON')->count(), + 'activity_all' => Order::whereIn('state', $state)->where('item_type', 'ACTIVITY')->count(), + 'activity' => [ + 'buy' => Order::whereIn('state', $state)->where('type', 'order')->where('item_type', 'ACTIVITY')->count(), + 'give' => Order::whereIn('state', $state)->where('type', 'lottery')->where('item_type', 'ACTIVITY')->count(), + ], + 'gift_all' => Order::whereIn('state', $state)->where('item_type', 'GIFT')->count(), + 'gift' => [ + 'lesson' => Order::whereIn('state', $state)->where('item_type', 'GIFT')->where('type', 'lesson')->count(), + 'lottery' => Order::whereIn('state', $state)->where('item_type', 'GIFT')->where('type', 'lottery')->count(), + ], + ]; + return view('data.orders', compact('today', 'all')); + } + + public function withdraw() + { + + $all = [ + //申请提现额 + 'withdraw' => [ + 'all' => Withdraw::sum('amount'), + ], + + //实际转账额 + 'cash' => [ + 'all' => Withdraw::whereIn('state', [0, 1])->sum('take'), + 'pass' => Withdraw::where('state', 1)->sum('take'), + 'no' => Withdraw::where('state', -1)->sum('take'), + ], + 'user' => [ + 'all' => Withdraw::where('state', '>=', 0)->count('user_id'), + 'pass' => Withdraw::where('state', 1)->groupBy('user_id')->count('user_id'), + 'no' => Withdraw::where('state', -1)->groupBy('user_id')->count('user_id'), + ], + 'account' => [ + 'all_account' => UserAccount::sum('cash'), + 'user_count' => UserAccount::count(), + ], + ]; + + $today = [ + //申请提现额 + 'withdraw' => [ + 'all' => Withdraw::whereBetween('created_at', $this->todayTime)->whereIn('state', [0, 1])->sum('amount'), + 'pass' => Withdraw::where('state', 1)->whereBetween('created_at', $this->todayTime)->sum('amount'), + 'no' => Withdraw::where('state', -1)->whereBetween('created_at', $this->todayTime)->sum('amount'), + ], + + //实际转账额 + 'cash' => [ + 'all' => Withdraw::whereBetween('created_at', $this->todayTime)->whereIn('state', [0, 1])->sum('take'), + 'pass' => Withdraw::where('state', 1)->whereBetween('created_at', $this->todayTime)->sum('take'), + 'no' => Withdraw::where('state', -1)->whereBetween('created_at', $this->todayTime)->sum('take'), + ], + 'user' => [ + 'all' => Withdraw::whereBetween('created_at', $this->todayTime)->where('state', '>=', 0)->count('user_id'), + 'pass' => Withdraw::where('state', 1)->groupBy('user_id')->whereBetween('created_at', $this->todayTime)->count('user_id'), + 'no' => Withdraw::where('state', -1)->groupBy('user_id')->whereBetween('created_at', $this->todayTime)->count('user_id'), + ], + 'account' => [ + 'all_account' => UserAccount::whereBetween('created_at', $this->todayTime)->sum('cash'), + 'user_count' => UserAccount::whereBetween('created_at', $this->todayTime)->count(), + ], + ]; + + return view('data.withdraw', compact('today', 'all', 'nav')); + } + + public function upgrade() + { + $today = [ + 'counselor_all' => IdentityLog::where('after', 1)->whereBetween('created_at', $this->todayTime)->count(), + 'agency' => IdentityLog::where('after', 2)->whereBetween('created_at', $this->todayTime)->count(), + 'manage' => IdentityLog::where('after', 3)->whereBetween('created_at', $this->todayTime)->count(), + 'teacher' => IdentityLog::where('after', 4)->whereBetween('created_at', $this->todayTime)->count(), + 'counselor' => [ + 'auto' => IdentityLog::where('after', 1)->where('channel', 'AutoUp')->whereBetween('created_at', $this->todayTime)->count(), + 'empty' => IdentityLog::where('after', 1)->where('channel', 'AdminUp')->whereBetween('created_at', $this->todayTime)->count(), + ], + ]; + + $all = [ + 'all' => IdentityLog::whereIn('after', [1, 2, 3, 4])->count(), + 'counselor_all' => IdentityLog::where('after', 1)->count(), + 'agency' => IdentityLog::where('after', 2)->count(), + 'manage' => IdentityLog::where('after', 3)->count(), + 'teacher' => IdentityLog::where('after', 4)->count(), + 'counselor' => [ + 'auto' => IdentityLog::where('after', 1)->where('channel', 'AutoUp')->count(), + 'empty' => IdentityLog::where('after', 1)->where('channel', 'AdminUp')->count(), + ], + ]; + return view('data.upgrade', compact('today', 'all')); + } + + public function account() + { + $all = [ + 'all' => Payment::where('state', 'SUCCESS')->sum('amount'), + 'lesson' => Payment::whereHas('order', function ($query) {$query->where('item_type', 'LESSON')->where('type', 'order');})->where('state', 'SUCCESS')->sum('amount'), + 'activity' => Payment::whereHas('order', function ($query) {$query->where('item_type', 'ACTIVITY')->where('type', 'order');})->where('state', 'SUCCESS')->sum('amount'), + ]; + + $today = [ + 'all' => Payment::where('state', 'SUCCESS')->whereBetween('created_at', $this->todayTime)->sum('amount'), + 'lesson' => Payment::whereHas('order', function ($query) {$query->where('item_type', 'LESSON')->where('type', 'order');})->where('state', 'SUCCESS')->whereBetween('created_at', $this->todayTime)->sum('amount'), + 'activity' => Payment::whereHas('order', function ($query) {$query->where('item_type', 'ACTIVITY')->where('type', 'order');})->where('state', 'SUCCESS')->whereBetween('created_at', $this->todayTime)->sum('amount'), + ]; + return view('data.account', compact('all', 'today')); + } + + public function index(Request $request) + { + $state = [ + 'PAID', 'DELIVER', 'DELIVERED', 'SIGNED', 'COMPLETED', 'UNUSE', 'USED', 'UNADDRESS', + ]; + + $today = [ + 'user' => [ + 'reg' => User::whereBetween('created_at', $this->todayTime)->count(), + 'counselor' => UserIdentity::where('identity_id', 1)->whereBetween('created_at', $this->todayTime)->count(), + 'agency' => UserIdentity::where('identity_id', 2)->whereBetween('created_at', $this->todayTime)->count(), + 'manage' => UserIdentity::where('identity_id', 3)->whereBetween('created_at', $this->todayTime)->count(), + 'teacher' => UserIdentity::where('identity_id', 4)->whereBetween('created_at', $this->todayTime)->count(), + 'salesman' => User::whereBetween('created_at', $this->todayTime)->where('is_salesman', 1)->count(), + ], + 'order' => [ + 'all' => Order::whereIn('state', $state)->whereBetween('created_at', $this->todayTime)->count(), + 'lesson' => Order::whereIn('state', $state)->where('type', 'order')->where('item_type', 'LESSON')->whereBetween('created_at', $this->todayTime)->count(), + 'activity' => Order::whereIn('state', $state)->where('type', 'order')->where('item_type', 'ACTIVITY')->whereBetween('created_at', $this->todayTime)->count(), + 'lesson_gift' => Order::whereIn('state', $state)->where('type', 'lesson')->where('item_type', 'GIFT')->whereBetween('created_at', $this->todayTime)->count(), + 'lottery_gift' => Order::whereIn('state', $state)->where('type', 'lottery')->where('item_type', 'GIFT')->whereBetween('created_at', $this->todayTime)->count(), + ], + ]; + + $all = [ + 'user' => [ + 'reg' => User::count(), + 'counselor' => UserIdentity::where('identity_id', 1)->count(), + 'agency' => UserIdentity::where('identity_id', 2)->count(), + 'manage' => UserIdentity::where('identity_id', 3)->count(), + 'teacher' => UserIdentity::where('identity_id', 4)->count(), + 'salesman' => User::where('is_salesman', 1)->count(), + ], + 'order' => [ + 'all' => Order::whereIn('state', $state)->count(), + 'lesson' => Order::whereIn('state', $state)->where('type', 'order')->where('item_type', 'LESSON')->count(), + 'activity' => Order::whereIn('state', $state)->where('type', 'order')->where('item_type', 'ACTIVITY')->count(), + 'lesson_gift' => Order::whereIn('state', $state)->where('type', 'lesson')->where('item_type', 'GIFT')->count(), + 'lottery_gift' => Order::whereIn('state', $state)->where('type', 'lottery')->where('item_type', 'GIFT')->count(), + ], + ]; + return view('data.index', compact('today', 'all')); + } + + public function salesman(Request $request) + { + $user = Auth::user(); + + if (!$user->is_salesman) { + return redirect()->route('user.index'); + } + + $today = [ + 'agency' => Agency::where('salesman_id', $user->id)->whereBetween('created_at', $this->todayTime)->count(), + 'organ' => Seller::where('type', 'organ')->where('salesman_id', $user->id)->whereBetween('created_at', $this->todayTime)->count(), + 'seller' => Seller::where('type', 'seller')->where('salesman_id', $user->id)->whereBetween('created_at', $this->todayTime)->count(), + 'agency_organ' => Seller::whereHas('agency', function ($query) use ($user) { + $query->where('salesman_id', $user->id); + })->whereBetween('created_at', $this->todayTime)->count(), + ]; + + $all = [ + 'agency' => Agency::where('salesman_id', $user->id)->count(), + 'organ' => Seller::where('type', 'organ')->where('salesman_id', $user->id)->count(), + 'seller' => Seller::where('type', 'seller')->where('salesman_id', $user->id)->count(), + 'agency_organ' => Seller::whereHas('agency', function ($query) use ($user) { + $query->where('salesman_id', $user->id); + })->count(), + ]; + + $organs = Seller::whereHas('agency', function ($query) use ($user) { + $query->where('salesman_id', $user->id); + }) + ->distinct('id') + ->orWhere('salesman_id', $user->id) + ->get(); + + return view('data.salesman', compact('today', 'all', 'organs')); + } + +} diff --git a/app/Http/Controllers/FavoriteController.php b/app/Http/Controllers/FavoriteController.php new file mode 100644 index 0000000..c653466 --- /dev/null +++ b/app/Http/Controllers/FavoriteController.php @@ -0,0 +1,89 @@ +middleware('auth'); + View::share('nav', 2); + } + + public function index(Request $request) + { + $type = $request->type ?? 'SellerLesson'; + $item_type = "App\Models\\" . $type; + $lists = Favorite::mine()->where('item_type', $item_type)->get(); + return view('favorite.index', compact('lists', 'type')); + } + + public function lesson(Request $request, SellerLesson $lesson) + { + $favorite = Favorite::where('item_type', 'App\Models\SellerLesson')->where('item_id', $lesson->id)->where('user_id', Auth::id())->first(); + + if (!$lesson) { + return $this->error('没有这个课程'); + } + + if ($favorite) { + $favorite->delete(); + return $this->success('课程取消收藏成功'); + } else { + Auth::user()->lessonFavorite()->create([ + 'item_id' => $lesson->id, + 'item_type' => get_class($lesson), + ]); + return $this->success('课程收藏成功'); + } + } + + public function seller(Request $request, Seller $seller) + { + $favorite = Favorite::where('item_type', 'App\Models\Seller')->where('item_id', $seller->id)->where('user_id', Auth::id())->first(); + + if (!$seller) { + return $this->error('没有这个机构'); + } + + if ($favorite) { + $favorite->delete(); + return $this->success('机构取消收藏成功'); + } else { + Auth::user()->sellerFavorite()->create([ + 'item_id' => $seller->id, + 'item_type' => get_class($seller), + ]); + return $this->success('机构收藏成功'); + } + } + + public function activity(Request $request, Activity $activity) + { + $favorite = Favorite::where('item_type', 'App\Models\Activity')->where('item_id', $activity->id)->where('user_id', Auth::id())->first(); + + if (!$activity) { + return $this->error('没有这个生活/服务'); + } + + if ($favorite) { + $favorite->delete(); + return $this->success('生活/服务取消收藏成功'); + } else { + Auth::user()->sellerFavorite()->create([ + 'item_id' => $activity->id, + 'item_type' => get_class($activity), + ]); + return $this->success('生活/服务收藏成功'); + } + } +} diff --git a/app/Http/Controllers/GiftController.php b/app/Http/Controllers/GiftController.php new file mode 100644 index 0000000..bc10839 --- /dev/null +++ b/app/Http/Controllers/GiftController.php @@ -0,0 +1,122 @@ +middleware('auth'); + View::share('nav', 2); + } + + public function index() + { + $orders = Order::where('user_id', Auth::id()) + ->Gift() + ->where('state', '<>', Order::ORDER_CLOSED) + ->orderBy('id', 'desc') + ->get(); + + return view('gifts.index', compact('orders')); + } + + //活动和优惠券 未支付 + public function unpay() + { + $orders = Order::UnAddress() + ->Gift() + ->where('user_id', Auth::id()) + ->orderBy('id', 'desc') + ->get(); + return view('gifts.index', compact('orders')); + } + + //已支付报名课程和活动 + public function paid() + { + $orders = Order::UnDeliver() + ->Gift() + ->where('user_id', Auth::id()) + ->orderBy('id', 'desc') + ->get(); + return view('gifts.index', compact('orders')); + } + + public function delivered() + { + $orders = Order::Delivered() + ->Gift() + ->where('user_id', Auth::id()) + ->orderBy('id', 'desc') + ->get(); + return view('gifts.index', compact('orders')); + } + + public function signed() + { + $orders = Order::Delivered() + ->Gift() + ->where('user_id', Auth::id()) + ->orderBy('id', 'desc') + ->get(); + return view('gifts.index', compact('orders')); + } + + public function show($orderid) + { + $order = Order::where('orderid', $orderid)->firstOrFail(); + return view('orders.show', compact('order')); + } + + public function sign($orderid) + { + $order = Order::where('orderid', $orderid)->firstOrFail(); + try { + $order->signin(); + return $this->success('签收成功', route('gifts.signed')); + } catch (\Exception $e) { + return $this->error('签收失败' . $e->getmessage()); + } + } + + //设置收货地址 + public function address(Request $request, Order $order) + { + $callback = $request->callback; + if ($request->isMethod('post')) { + if ($request->address_id) { + $address = \Address::get($request->address_id); + } else { + $address = \Address::store( + [ + 'user_id' => Auth::id(), + 'name' => $request->name, + 'mobile' => $request->mobile, + 'province_sn' => $request->province_sn, + 'city_sn' => $request->city_sn, + 'area_sn' => $request->area_sn, + 'address' => $request->address, + ] + ); + } + + $express = new OrderExpress(['instance' => $address]); + $order->express()->save($express); + $order->state = Order::ORDER_PAID; + $order->save(); + return $this->success('设置地址成功', $callback); + } else { + $provinces = \Area::index(0); + $address_list = \Address::lists(Auth::id()); + return view('gifts.address', compact('provinces', 'order', 'address_list', 'callback')); + } + } +} diff --git a/app/Http/Controllers/IndexController.php b/app/Http/Controllers/IndexController.php new file mode 100644 index 0000000..d2615da --- /dev/null +++ b/app/Http/Controllers/IndexController.php @@ -0,0 +1,315 @@ +middleware('auth')->except(['location', 'getlocation', 'getOrgans']); + View::share('nav', 1); + } + + public function index(Request $request) + { + $user = Auth::user(); + $location = Parent::getDefaultLocation(); + $lat = $location['lat']; + $lng = $location['lng']; + $area = $location['area']; + + $adverts = Advert::limit(\Params::get('advert_limit'))->orderBy('sort', 'asc')->get(); //banner + $c_lists = Category::with('storage')->where('parent_id', 1) + // ->orderBy('sort', 'asc') + // ->orderBy('created_at', 'desc') + ->inRandomOrder() + ->limit(10)->get(); //分类 + + $organs = $this->getDefaultOrgans($request); //机构列表 + $organ = $user->organ; + //推荐课程 + $recommend = $this->getRecommend(); + + //都在看 + $watching_ids = SellerLessonLog::where('status', 1)->groupBy('lesson_id')->inRandomOrder()->take(3)->pluck('lesson_id'); + $watchings = SellerLesson::with(['organ' => function ($query) use ($lat, $lng) { + $query->select('id', 'name', 'storage_id', 'user_id', 'category_id', DB::raw('round(ACOS(SIN((' . $lat . ' * 3.1415) / 180 ) *SIN((lat * 3.1415) / 180 ) +COS((' . $lat . ' * 3.1415) / 180 ) * COS((lat * 3.1415) / 180 ) *COS((' . $lng . ' * 3.1415) / 180 - (lng * 3.1415) / 180 ) ) * 6380,2) as distance')); + }])->whereIn('seller_id', $watching_ids)->get(); + + $data = [ + 'couponlogs' => $user->couponlog()->where('status', 0)->count(), + 'lessonlogs' => SellerLessonLog::where('user_id', $user->id)->where('status', 1)->count(), + ]; + return view('index.index', compact('adverts', 'organs', 'c_lists', 'user', 'data', 'recommend', 'watchings')); + } + + //获取推荐课程 + public function getRecommend() + { + $user = Auth::user(); + $location = Parent::getDefaultLocation(); + $lat = $location['lat']; + $lng = $location['lng']; + $area = $location['area']; + + $organ = $user->organ; + $find = SellerLesson::when($area, function ($query) use ($area) { + $query->whereHas('organ', function ($query) use ($area) { + if ($area->depth == 2) { + $query->where('city_sn', $area->sn); + } elseif ($area->depth == 3) { + $query->where('area_sn', $area->sn); + } else { + $query->where('province_sn', $area->sn); + } + }); + })->count(); + + if ($find) { + $area = Area::where('sn', '230100')->first(); + } + + //推荐课程 + $recommend = SellerLesson::with(['organ' => function ($query) use ($lat, $lng) { + $query->select('id', 'name', 'storage_id', 'user_id', 'category_id', DB::raw('round(ACOS(SIN((' . $lat . ' * 3.1415) / 180 ) *SIN((lat * 3.1415) / 180 ) +COS((' . $lat . ' * 3.1415) / 180 ) * COS((lat * 3.1415) / 180 ) *COS((' . $lng . ' * 3.1415) / 180 - (lng * 3.1415) / 180 ) ) * 6380,2) as distance')); + }])->when(!empty($organ->toArray()), function ($q) use ($organ) { + $q->where('seller_id', $organ->id); + })->when(empty($organ->toArray()) && $area, function ($query) use ($area) { + $query->whereHas('organ', function ($query) use ($area) { + if ($area->depth == 2) { + $query->where('city_sn', $area->sn); + } elseif ($area->depth == 3) { + $query->where('area_sn', $area->sn); + } else { + $query->where('province_sn', $area->sn); + } + }); + })->inRandomOrder()->first(); + return $recommend; + } + + //通用获取组织 + public function getDefaultOrgans($request) + { + $page = $request->page ?? 0; //获取当前页码 + $location = Parent::getDefaultLocation(); + $lat = $location['lat']; + $lng = $location['lng']; + $area = $location['area']; + + $user = Auth::user(); + if (!$area) { + return collect([]); + } + + $organCateIds = []; + if ($user && $user->organ) { + $organCateIds = $user->organ->top_cate_id; + } + + $pageNum = 5; + + if ($user && $user->organ && $user->organ->id > 0 && !$page) { + $myorgan = Seller::with(['storage'])->where('id', Auth::user()->seller_id)->select('id', 'name', 'storage_id', 'user_id', 'category_id', DB::raw('round(ACOS(SIN((' . $lat . ' * 3.1415) / 180 ) *SIN((lat * 3.1415) / 180 ) +COS((' . $lat . ' * 3.1415) / 180 ) * COS((lat * 3.1415) / 180 ) *COS((' . $lng . ' * 3.1415) / 180 - (lng * 3.1415) / 180 ) ) * 6380,2) as distance'))->first(); + } + + $organs = Seller::with('storage') + ->where('type', 'organ') + ->when($area, function ($query) use ($area) { + if ($area->depth == 2) { + $query->where('city_sn', $area->sn); + } elseif ($area->depth == 3) { + $query->where('area_sn', $area->sn); + } else { + $query->where('province_sn', $area->sn); + } + }) + ->when($organCateIds, function ($query) use ($organCateIds) { + $query->whereNotIn('category_id', $organCateIds); + }) + ->select('id', 'name', 'storage_id', 'user_id', 'category_id', DB::raw('round(ACOS(SIN((' . $lat . ' * 3.1415) / 180 ) *SIN((lat * 3.1415) / 180 ) +COS((' . $lat . ' * 3.1415) / 180 ) * COS((lat * 3.1415) / 180 ) *COS((' . $lng . ' * 3.1415) / 180 - (lng * 3.1415) / 180 ) ) * 6380,2) as distance')) + ->orderBy('distance', 'asc') + ->orderBy('id', 'asc') + ->get(); + // ->paginate($pageNum); + + if ($user && $user->organ && $user->organ->id > 0 && !$page) { + $organs->prepend($myorgan); + } + + return $organs; + } + + //分页加载更多组织 + public function getOrgans(Request $request) + { + $organs = $this->getDefaultOrgans($request); + if ($organs->count() > 0) { + $html = response(view('index.organs', compact('organs')))->getContent(); + return $this->success($html); + } else { + return $this->error('已经到最后一页'); + } + } + + //搜索课程 + public function search(Request $request) + { + $title = $request->title; + $location = Parent::getDefaultLocation(); + $lat = $location['lat']; + $lng = $location['lng']; + $area = $location['area']; + + // $lists = SellerLesson::where('status', 1)->where('title', 'like', "%" . $request->title . "%")->get(); + + $user = Auth::user(); + + $organCateIds = $lessonids = []; + if ($user->organ) { + $organCateIds = $user->organ->top_cate_id; + $lessonids = SellerLesson::whereIn('category_id', $organCateIds)->where('seller_id', '<>', $user->organ->id)->pluck('id')->toArray(); + } + + $lists = SellerLesson::with(['organ.storage', 'organ' => function ($query) use ($lat, $lng) { + $query->select('id', 'name', 'storage_id', 'user_id', 'category_id', DB::raw('round(ACOS(SIN((' . $lat . ' * 3.1415) / 180 ) *SIN((lat * 3.1415) / 180 ) +COS((' . $lat . ' * 3.1415) / 180 ) * COS((lat * 3.1415) / 180 ) *COS((' . $lng . ' * 3.1415) / 180 - (lng * 3.1415) / 180 ) ) * 6380,2) as distance')); + }])->when($area, function ($query) use ($area) { + $query->whereHas('organ', function ($query) use ($area) { + if ($area->depth == 2) { + $query->where('city_sn', $area->sn); + } elseif ($area->depth == 3) { + $query->where('area_sn', $area->sn); + } else { + $query->where('province_sn', $area->sn); + } + }); + })->when(!empty($lessonids), function ($q) use ($lessonids) { + $q->whereNotIn('id', $lessonids); + })->where('status', 1)->where('title', 'like', "%" . $request->title . "%")->get(); + + return view('index.search', compact('lists')); + } + + public function pass() + { + $user = Auth::user(); + if ($user->info->update(['pass_at' => date('Y-m-d 23:59:59')])) { + return $this->success('今日不再提示'); + } else { + return $this->error('设置失败'); + } + } + + public function subscribe() + { + return view('index.subscribe'); + } + + public function location(Request $request) + { + $lat = $request->lat; + $lng = $request->lng; + + if (!$lat || !$lng) { + return $this->error('设置失败'); + } + + $location = Parent::getDefaultLocation(); + + if (!$location['real_area']) { + $url = "http://api.map.baidu.com/geocoder"; + $client = new Client(); + $response = $client->request('GET', $url, [ + 'timeout' => 30, + 'query' => [ + 'location' => $lat . "," . $lng, + 'output' => 'json', + ], + ]); + + if ($response->getStatusCode() == 200) { + $data = json_decode($response->getBody()->getContents(), true); + $city = $data['result']['addressComponent']['city']; + } else { + return $this->location($url); + } + $area = Area::where('name', $city)->first(); + + //如果地址没有开通,默认哈尔滨 + if ($area->status != 1) { + $area = Area::where('sn', '230100')->first(); + $lat = $area->lat; + $lng = $area->lng; + } + + Session::put('lat', $lat); + Session::put('lng', $lng); + Session::put('area', $area); + Session::put('real_area', $area); + return $this->success($city); + } else { + Session::put('lat', $lat); + Session::put('lng', $lng); + return $this->error(json_encode($location)); + } + + } + + //设置地区 + public function getLocation(Request $request) + { + + $area = $request->area; + $title = $request->title; + + if ($area) { + $area = Area::find($area); + Session::put('area', $area); + Session::push('history_area', $area); + $url = route('index.index'); + if ($request->callback) { + $url = $request->callback; + } + return $this->success('设置成功', $url); + } else { + $location = Parent::getDefaultLocation(); + $lat = $location['lat']; + $lng = $location['lng']; + $area = $location['area']; + $real_area = $location['real_area']; + $historys = $location['history_area']; + + if (empty($lat) || empty($lng) || empty($area)) { + return redirect()->route('index.index'); + } + + $lists = Area::where('city', $area->city)->where('depth', 3)->where('status', 1)->get(); + if ($title) { + $all_list = Area::where('status', 1)->where('name', 'like', "%" . $title . "%")->where('depth', 2)->orderBy('name_first_char', 'asc')->get(); + } else { + $all_list = Area::where('status', 1)->where('depth', 2)->orderBy('name_first_char', 'asc')->get(); + } + + $hots = Area::where('status', 1)->where('hot', 1)->get(); + return view('index.location', compact('area', 'lists', 'all_list', 'real_area', 'hots', 'historys')); + } + + } + +} diff --git a/app/Http/Controllers/LessonsController.php b/app/Http/Controllers/LessonsController.php new file mode 100644 index 0000000..2b7a777 --- /dev/null +++ b/app/Http/Controllers/LessonsController.php @@ -0,0 +1,148 @@ +middleware('auth')->except(['show', 'category']); + View::share('nav', 3); + } + + public function index(Request $request) + { + $type = $request->type ?? 'unoverdue'; + + $lists = SellerLessonLog::with('lesson')->whereHas('lesson', function ($query) use ($type) { + if ($type == 'unoverdue') { + $query->where('end_at', '>=', date('Y-m-d H:i:s', strtotime("+1 days", time()))); + } else { + $query->where('end_at', '<=', date('Y-m-d H:i:s', strtotime("+1 days", time()))); + } + })->where('user_id', Auth::id())->where('status', 1)->get(); + + view()->share('nav', 3); + + return view('lesson.index', compact('lists', 'type')); + } + + public function show(SellerLesson $lesson) + { + if (Auth::guest()) { + $favorite = collect(); + } else { + $favorite = Auth::user()->lessonFavorite()->where('item_id', $lesson->id)->first(); + } + + $cart = Cart::where('user_id', Auth::id())->where('lesson_id', $lesson->id)->first(); + return view('lesson.show', compact('lesson', 'favorite', 'cart')); + } + + //分类 + public function category(Request $request) + { + $category_id = $request->category_id; + + $location = Parent::getDefaultLocation(); + $lat = $location['lat']; + $lng = $location['lng']; + $area = $location['area']; + $category = Category::find($category_id); + + $user = Auth::user(); + + $organCateIds = []; + if ($user && $user->organ) { + $organCateIds = $user->organ->top_cate_id; + } + + $lists = SellerLesson::with(['organ' => function ($query) use ($lat, $lng) { + $query->select('id', 'name', 'storage_id', 'user_id', 'category_id', DB::raw('round(ACOS(SIN((' . $lat . ' * 3.1415) / 180 ) *SIN((lat * 3.1415) / 180 ) +COS((' . $lat . ' * 3.1415) / 180 ) * COS((lat * 3.1415) / 180 ) *COS((' . $lng . ' * 3.1415) / 180 - (lng * 3.1415) / 180 ) ) * 6380,2) as distance')); + }])->when(is_numeric($category_id), function ($query) use ($category_id) { + $query->whereHas('category', function ($q) use ($category_id) { + $q->where('id', $category_id)->Orwhere('parent_id', $category_id); + }); + })->when($area, function ($query) use ($area) { + $query->whereHas('organ', function ($query) use ($area) { + if ($area->depth == 2) { + $query->where('city_sn', $area->sn); + } elseif ($area->depth == 3) { + $query->where('area_sn', $area->sn); + } else { + $query->where('province_sn', $area->sn); + } + }); + })->when(in_array($category_id, $organCateIds), function ($q) use ($user) { + $q->where('seller_id', $user->organ->id); + })->where('status', 1)->get(); + + $search_id = ($category->parent_id == 1) ? $category->id : $category->parent_id; + $categorys = Category::with('storage')->where('parent_id', $search_id) + ->orderBy('sort', 'asc') + ->orderBy('created_at', 'desc')->get(); + + return view('lesson.category', compact('lists', 'categorys', 'search_id')); + } + + public function report(Request $request) + { + return view('lesson.report'); + } + + //所有课程 + public function all(Request $request) + { + + $user = Auth::user(); + $category_id = $request->category_id ?? ''; + + $location = Parent::getDefaultLocation(); + $lat = $location['lat']; + $lng = $location['lng']; + $area = $location['area']; + + $organCateIds = []; + if ($user && $user->organ) { + $organCateIds = $user->organ->top_cate_id; + } + + $lists = SellerLesson::with(['organ' => function ($query) use ($lat, $lng) { + $query->select('id', 'name', 'storage_id', 'user_id', 'category_id', DB::raw('round(ACOS(SIN((' . $lat . ' * 3.1415) / 180 ) *SIN((lat * 3.1415) / 180 ) +COS((' . $lat . ' * 3.1415) / 180 ) * COS((lat * 3.1415) / 180 ) *COS((' . $lng . ' * 3.1415) / 180 - (lng * 3.1415) / 180 ) ) * 6380,2) as distance')); + }])->when(is_numeric($category_id), function ($query) use ($category_id) { + $query->whereHas('category', function ($q) use ($category_id) { + $q->where('id', $category_id)->Orwhere('parent_id', $category_id); + }); + })->when($area, function ($query) use ($area) { + $query->whereHas('organ', function ($query) use ($area) { + if ($area->depth == 2) { + $query->where('city_sn', $area->sn); + } elseif ($area->depth == 3) { + $query->where('area_sn', $area->sn); + } else { + $query->where('province_sn', $area->sn); + } + }); + })->when(in_array($category_id, $organCateIds), function ($q) use ($user) { + $q->where('seller_id', $user->organ->id); + })->where('status', 1)->get(); + + $lists = $lists->sortBy('button_value'); + + $categorys = Category::with('storage')->where('parent_id', 1) + ->orderBy('sort', 'asc') + ->get(); + + return view('lesson.all', compact('lists', 'categorys')); + } +} diff --git a/app/Http/Controllers/LotteryController.php b/app/Http/Controllers/LotteryController.php new file mode 100644 index 0000000..4c64f4c --- /dev/null +++ b/app/Http/Controllers/LotteryController.php @@ -0,0 +1,125 @@ + | +// +------------------------------------------------+ + +namespace App\Http\Controllers; + +use App\Events\Lottery as LotteryEvent; +use App\Models\Lottery; +use App\Models\LotteryGift; +use App\Models\LotteryLog; +use Auth; +use Illuminate\Http\Request; +use Illuminate\Support\Facades\View; + +/** + * 抽奖 + */ +class LotteryController extends Controller +{ + public function __construct(Request $request) + { + parent::__construct($request); + View::share('nav', 2); + } + + public function index() + { + $lottery = Lottery::find(1); + return view('lottery.index', compact('lottery')); + } + + //抽奖 + public function draw() + { + $lottery = Lottery::find(1); + + if (!$lottery) { + return $this->error('没有这个活动'); + } elseif ($lottery->status != 1 || $lottery->start_at->timestamp > time()) { + return $this->error('活动没有开启'); + } elseif ($lottery->end_at->timestamp <= time()) { + return $this->error('活动已经结束'); + } + + $list = LotteryGift::with(['item']) + ->where('lottery_id', 1) + ->orderBy('chance', 'asc') + ->get(); + // $newlist = collect([]); + // foreach ($list as $key => $gift) { + // $newlist->put($gift->site, $gift); + // } + + $user = Auth::user(); + + if ($user->lottery_num == 0) { + return $this->error('您没有抽奖机会'); + } + + $gift = self::get_rand($list); + $user->decrement('lottery_num'); + if ($user->id == 1) { + $gift = LotteryGift::find(15); + } + if (empty($gift) || $gift->number == 0 || $gift->type == 0) { + return $this->error(['site' => 6, 'win' => '很遗憾', 'title' => '您没有中奖!', 'lottery_num' => $user->lottery_num]); + } else { + $gift->decrement('number'); + + $log = $lottery->logs()->create([ + 'user_id' => $user->id, + 'gift_id' => $gift->id, + ]); + + event(new LotteryEvent($log)); + return $this->success(['site' => $gift->site, 'win' => '恭喜您', 'title' => '抽中了 ' . $gift->item->getTitle(), 'lottery_num' => $user->lottery_num, 'allnum' => $gift->allnum, 'randNum' => $gift->randNum]); + } + } + + public function get_rand($gifts) + { + $result = ''; + + $allnum = $gifts->sum('chance'); + //概率数组循环 + foreach ($gifts as $gift) { + $randNum = mt_rand(1, $allnum); + if ($randNum <= $gift->chance) { + $gift->randNum = $randNum; + $gift->allnum = $allnum; + $result = $gift; + break; + } else { + $allnum -= $gift->chance; + } + } + unset($gifts); + return $result; + } + + public function logs(Request $request) + { + $type = $request->type ?? 'goods'; + $class = LotteryGift::$class; + $item_type = $class[$type]; + + $lists = LotteryLog::with(['gift.item'])->whereHas('gift', function ($query) use ($item_type) { + $query->where('type', 1)->where('item_type', $item_type); + })->where('user_id', Auth::id())->get(); + + view()->share('title', '抽奖礼品'); + + return view('lottery.logs', compact('lists', 'type')); + } + + public function message() + { + return view('lottery.message'); + } +} diff --git a/app/Http/Controllers/NotifyController.php b/app/Http/Controllers/NotifyController.php new file mode 100644 index 0000000..f307083 --- /dev/null +++ b/app/Http/Controllers/NotifyController.php @@ -0,0 +1,43 @@ +handlePaidNotify(function ($message, $fail) { + $payment = Payment::where('trade_no', $message['out_trade_no'])->first(); + $payment->state = 'SUCCESS'; + $payment->paid_at = $message['time_end']; + $payment->save(); + $payment->order->paid(); + return true; + }); + } + + public function vip(Request $request) + { + $app = app('wechat.payment'); + return $app->handlePaidNotify(function ($message, $fail) { + $vip_payment = VipPament::where('trade_no', $message['out_trade_no'])->first(); + $vip_payment->state = 'SUCCESS'; + $vip_payment->paid_at = $message['time_end']; + $vip_payment->save(); + event(new VipPaid($vip_payment)); + return true; + }); + } +} diff --git a/app/Http/Controllers/OrderController.php b/app/Http/Controllers/OrderController.php new file mode 100644 index 0000000..8e553b0 --- /dev/null +++ b/app/Http/Controllers/OrderController.php @@ -0,0 +1,243 @@ +middleware('auth'); + View::share('nav', 2); + } + + public function index() + { + $orders = Order::where('user_id', Auth::id()) + ->CouponAndActivity() + ->where('state', '<>', Order::ORDER_CLOSED) + ->orderBy('id', 'desc') + ->get(); + + return view('orders.index', compact('orders')); + } + + //活动和优惠券 未支付 + public function unpay() + { + $orders = Order::Unpaid() + ->CouponAndActivity() + ->where('user_id', Auth::id()) + ->orderBy('id', 'desc') + ->get(); + return view('orders.index', compact('orders')); + } + + //已支付报名课程和活动 + public function paid() + { + $orders = Order::UnUse() + ->CouponAndActivity() + ->where('user_id', Auth::id()) + ->orderBy('id', 'desc') + ->get(); + + return view('orders.index', compact('orders')); + } + + //已使用的报名课程和活动 + public function used() + { + $orders = Order::StateUsed() + ->CouponAndActivity() + ->where('user_id', Auth::id()) + ->orderBy('id', 'desc') + ->get(); + return view('orders.index', compact('orders')); + } + + public function delivered() + { + $orders = Order::Delivered() + ->where('user_id', Auth::id()) + ->orderBy('id', 'desc') + ->get(); + return view('orders.index', compact('orders')); + } + + public function signed() + { + $orders = Order::Signed() + ->where('user_id', Auth::id()) + ->orderBy('id', 'desc') + ->get(); + return view('orders.index', compact('orders')); + } + + public function show($orderid) + { + $order = Order::where('orderid', $orderid)->firstOrFail(); + return view('orders.show', compact('order')); + } + + public function pay($orderid) + { + $order = Order::where('orderid', $orderid)->firstOrFail(); + return view('orders.pay', compact('order')); + } + + public function sign($orderid) + { + $order = Order::where('orderid', $orderid)->firstOrFail(); + try { + $order->signin(); + return $this->success('签收成功', route('orders.signed')); + } catch (\Exception $e) { + return $this->error('签收失败' . $e->getmessage()); + } + } + + public function delete($orderid) + { + $order = Order::where('orderid', $orderid)->firstOrFail(); + try { + $order->close(); + return $this->success('取消订单成功'); + } catch (\Exception $e) { + return $this->error('取消订单失败' . $e->getmessage()); + } + } + + //创建课程订单 + public function LessonStore(Request $request) + { + $request->validate([ + 'cart_ids.*' => 'required', + ], [ + 'cart_ids.*.required' => '没有课程', + ]); + + if (!isset($request->cart_ids)) { + return $this->error('请选择课程后进行支付'); + } + + if (!$request->has('baby_id')) { + return $this->error('没有检测到宝宝信息,请先去录入宝宝信息。', route('baby', ['callback' => route('cart.index')])); + } + + // $lesson_num = \Params::get('lesson_num'); + // if ($lesson_num > count($request->cart_ids)) { + // return $this->error('请选够' . $lesson_num . '门课程后进行支付'); + // } + + $gift_nums = GoodsParams::where('stock', '>', 0) + ->whereHas('goods', function ($q) { + $q->where('status', 1)->where('is_seller_gift', 1); + }) + ->count(); + + if ($gift_nums > 0 && !isset($request->gifts_id)) { + return $this->error('请选择赠品'); + } + + try { + DB::transaction(function () use ($request) { + $baby = UserBaby::find($request->baby_id); + + $item = [ + 'id' => $request->gifts_id ?? 0, + 'item_type' => 'LESSON', + 'name' => $baby->name, + 'age' => $baby->age, + 'mobile' => $baby->mobile, + ]; + + $amount = \Params::get('apply_lesson_price'); + + $score_order = 0; + $score = 0; + $heavy = 0; + $windup_freight = 0; + $express_type = isset($request['express_type']) ? $request['express_type'] : 0; + $address = null; + $windup_freight = 0; + $items = []; + + if ($request->coupon_id) { + $coupon = CouponUserLog::find($request->coupon_id); + if ($coupon) { + $score_order = $coupon->info->bouns; + } + } elseif (Auth::user()->identity->identity_id > 0) { + $amount -= 100; + } + + foreach ($request->cart_ids as $key => $cart_id) { + $cart = Cart::find($cart_id); + if ($cart) { + array_push($items, new OrderDetail(['goods' => $cart->lesson, 'number' => 1])); + } + } + + \Orders::create(Auth::id(), 1, $item, $items, $address, $request->remark, $amount, $score_order, 0, $express_type, $windup_freight, $coupon ?? []); + + }); + + $order = Order::where('user_id', Auth::id())->where('state', 'UNPAY')->orderBy('created_at', 'desc')->first(); + Auth::user()->info->update([ + 'baby_age' => $request->age, + 'baby_name' => $request->name, + 'baby_mobile' => $request->mobile, + ]); + return $this->success('订单创建成功', route('pay.lesson', $order)); + + } catch (\Exception $e) { + return $this->error('订单创建失败' . $e->getmessage()); + } + } + + public function activityStore(Request $request) + { + try { + DB::transaction(function () use ($request) { + $item = [ + 'id' => 0, + 'item_type' => 'ACTIVITY', + ]; + + $score = 0; + $score_order = 0; + $heavy = 0; + $windup_freight = 0; + $express_type = isset($request['express_type']) ? $request['express_type'] : 0; + $address = null; + $windup_freight = 0; + $items = []; + $activity = Activity::find($request->activity_id); + array_push($items, new OrderDetail(['goods' => $activity, 'number' => $request->number])); + $amount = $activity->price * $request->number; + \Orders::create(Auth::id(), 1, $item, $items, $address, $request->remark, $amount, $score_order, 0, $express_type, $windup_freight); + + }); + + $order = Order::where('user_id', Auth::id())->where('state', 'UNPAY')->orderBy('created_at', 'desc')->first(); + return $this->success('订单创建成功', route('pay.order', $order)); + + } catch (\Exception $e) { + return $this->error('订单创建失败' . $e->getmessage()); + } + } + +} diff --git a/app/Http/Controllers/PayController.php b/app/Http/Controllers/PayController.php new file mode 100644 index 0000000..c0a52ea --- /dev/null +++ b/app/Http/Controllers/PayController.php @@ -0,0 +1,131 @@ +middleware('auth'); + } + + private function getpayOrder(Order $order, $type) + { + $payOrder = Payment::create([ + 'order_id' => $order->id, + 'type' => $type, + 'amount' => $order->total - $order->score, + ]); + return $payOrder; + } + + public function lesson(Request $request, $orderid) + { + $order = Order::where('orderid', $orderid)->firstOrFail(); + $coupon = ''; + if ($request->has('coupon_id')) { + $coupon = CouponUserLog::find($request->coupon_id); + } + + // $coupon_list = CouponUserLog::with('info')->whereHas('info', function ($query) { + // $query->where('type', 'lesson') + // ->where('start_at', '<=', date('Y-m-d H:i:s', time())) + // ->where('end_at', '>=', date('Y-m-d H:i:s', time())); + // })->where('user_id', Auth::id())->where('status', 0)->get(); + + // $coupon = $coupon_list->sortByDesc(function ($coupon, $key) { + // return $coupon->info->bouns; + // })->first(); + + $apply_lesson_price = \Params::get('apply_lesson_price'); + + return view('pay.lesson', compact('order', 'coupon', 'apply_lesson_price')); + } + + public function order(Request $request, $orderid) + { + $order = Order::where('orderid', $orderid)->firstOrFail(); + return view('pay.order', compact('order')); + } + + public function wechatnew(Request $request, $orderid) + { + $order = Order::where('orderid', $orderid)->firstOrFail(); + $openid = $order->user->openid; + if ($request->has('coupon') && $request->coupon) { + $coupon = CouponUserLog::find($request->coupon); + $order->score = $coupon->info->bouns; + $order->save(); + if ($order->couponuse && $order->couponuse->coupon_id != $coupon->id) { + $order->couponuse()->delete(); + } + if ($order->couponuse) { + if ($order->couponuse->coupon_id != $coupon->id) { + $order->couponuse()->delete(); + $order->couponuse()->save(new CouponUse(['order_id' => $order->id, 'coupon_id' => $coupon->id])); + } else { + $order->couponuse()->update(['updated_at' => time()]); + + } + } else { + $order->couponuse()->save(new CouponUse(['order_id' => $order->id, 'coupon_id' => $coupon->id])); + } + } else { + $order->score = 0; + $order->save(); + $order->couponuse()->delete(); + } + + $amount = $order->amount - $order->score; + + $payOrder = $this->getpayOrder($order, 'WECHAT'); + if ($amount != $payOrder->amount) { + $payOrder->amount = $amount; + $payOrder->save(); + } + $app = app('wechat.payment'); + + $amount = $payOrder->amount; + $result = $app->order->unify([ + 'body' => '商城订单', + 'out_trade_no' => $payOrder->trade_no, + 'total_fee' => $amount * 100, + 'notify_url' => route('notify.payment'), + 'trade_type' => 'JSAPI', + 'openid' => $openid, + ]); + + if ($result['return_code'] == 'SUCCESS' && isset($result['prepay_id'])) { + $json = $app->jssdk->bridgeConfig($result['prepay_id']); + return $this->success($json); + } else { + return $this->error($result['return_msg']); + } + } + + public function ok(Request $request) + { + return view('pay.ok'); + + // $user = Auth::user(); + // $openid = $user->openid; + // if (empty($openid) && $user->main_id > 0) { + // $openid = $user->mainuser->openid; + // } + // $app = app('wechat.official_account'); + // $wxuser = $app->user->get($openid); + // if ($wxuser->subscribe == 0) { + // return view('pay.subscribe'); //强制关注公众号 + // } else { + // return view('pay.ok'); + // } + } + +} diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php new file mode 100644 index 0000000..6538c2f --- /dev/null +++ b/app/Http/Controllers/ReportController.php @@ -0,0 +1,10 @@ +middleware('auth')->except(['verification']); + view()->share('nav', 1); + } + + public function index(Request $request) + { + $sellers = Seller::with(['storage'])->orderBy('sort', 'desc')->get(); + + return view('sellers.index', compact('sellers')); + } + + public function show(Seller $seller) + { + $favorite = \Auth::user()->sellerFavorite()->where('item_id', $seller->id)->first(); + $lists = SellerTeacher::where('seller_id', $seller->id)->get(); + $user = Auth::user(); + return view('sellers.show', compact('seller', 'favorite', 'lists', 'user')); + } + + //商户管理 + public function seller(Request $request) + { + + $type = $request->type ?? 'activity'; + $status = $request->status ?? ''; + $seller = Auth::user()->seller; + if (!$seller || $seller->type != 'seller') { + return redirect()->route('user.index'); + } + + if ($type == 'activity') { + $lists = Activity::with('seller')->where('seller_id', $seller->id)->get(); + } else { + $lists = ActivityLog::with(['activity.seller'])->whereHas('activity', function ($query) use ($seller) { + $query->where('seller_id', $seller->id); + })->whereHas('order', function ($query) { + $query->whereNotNull('paid_at'); + })->when($status, function ($query) use ($status) { + switch ($status) { + case 1: + $query->whereNotNull('used_at'); + break; + case 2: + $query->whereNull('used_at'); + break; + } + })->orderBy('created_at', 'desc')->get(); + } + + return view('sellers.seller', compact('type', 'lists', 'status')); + } + + //机构管理 + public function organ(Request $request) + { + $type = $request->type ?? 'lesson'; + $user = Auth::user(); + $organ = $user->organ; + //有机构 并且身份是机构负责人 + if (!$organ || $user->identity->identity_id !== 3) { + return redirect()->route('user.index'); + } + + if ($type == 'lesson') { + $lists = SellerLesson::where('seller_id', $organ->id)->get(); + } else { + $lists = SellerLessonLog::whereHas('lesson', function ($query) use ($organ) { + $query->where('seller_id', $organ->id); + })->whereHas('order', function ($query) { + $query->whereNotNull('paid_at'); + })->orderBy('created_at', 'desc')->get(); + } + return view('sellers.organ', compact('type', 'lists')); + } + + //机构内课程 + public function lessons(Request $request, Seller $seller) + { + $lists = $seller->lesson; + return view('sellers.lessons', compact('seller', 'lists')); + } + + //核销 + public function verification(Request $request) + { + $orderid = $request->orderid; + $order = Order::with(['details', 'user.info'])->where('id', $orderid)->first(); + + if ($request->isMethod('POST')) { + if (Auth::guest()) { + return $this->error('您没有登录', route('login')); + } + + $user = Auth::user(); + if (!$user->seller) { + return $this->error('您没有审核权限'); + } + + if (!$order->canActivityAudit()) { + return $this->error('订单状态不对'); + } + + if ($order->item_type != 'ACTIVITY') { + return $this->error('订单类型不对'); + } + + if (!$order->activitylog) { + return $this->error('没有查到这个服务的购买记录'); + } + + if (!$order->activitylog->activity) { + return $this->error('没有这个服务'); + } elseif ($order->activitylog->activity->status === 0) { + return $this->error('服务还未开始'); + } elseif ($order->activitylog->activity->status == '-1') { + return $this->error('服务已经结束'); + } + + if ($order->activitylog->activity->seller->id != $user->seller->id) { + return $this->error('您没有这个服务的审核权限'); + } + + if ($order->activitylog()->update(['scan_people_id' => $user->id, 'used_at' => Carbon::today()->toDateTimeString()])) { + $order->used(); + return $this->success('审核成功', url()->full()); + } else { + return $this->error('审核失败'); + } + } else { + return view('sellers.verification', compact('order')); + } + + } +} diff --git a/app/Http/Controllers/ShareController.php b/app/Http/Controllers/ShareController.php new file mode 100644 index 0000000..3358537 --- /dev/null +++ b/app/Http/Controllers/ShareController.php @@ -0,0 +1,83 @@ +middleware('auth'); + view()->share('nav', 2); + } + + public function user(User $user) + { + session(['parent_id' => $user->id]); + // return redirect()->route('vip.create'); + } + + public function index(User $user) + { + $user = Auth::user(); + return view('share.index', compact('user')); + } + + public function mine(Request $request) + { + $user = Auth::user(); + $qrCode = Image::make(QrCode::size(3000)->format('png')->margin(0)->generate(route('index.index') . '?share_uid=' . $user->id))->resize(230, 230); + return $qrCode->response('jpg'); + } + + public function getnewCode() + { + $user = Auth::user(); + $qrCode = QrCode::format('png')->size(126)->margin(0)->generate(route('index.index') . '?share_uid=' . $user->id); + // $headimg = Image::make($user->info->headimgurl); + $fileUrl = '/home/wwwroot/BabyClass/storage/app/public/headimgurl/' . $user->id . '.jpg'; + if (!file_exists($fileUrl)) { + $headimgurl = file_get_contents($user->info->headimgurl); + file_put_contents($fileUrl, $headimgurl); + } + + $headimg = self::getCircle(Image::make($fileUrl)->resize(65, 65)); + + $image = Image::make('img/new_code2.png'); //获取背景图片 + + return $image->insert($headimg, 'top-left', 205, 730) + ->insert($qrCode, 'top-left', 51, 853) + ->text('我是' . $user->info->nickname ?: '宝宝课', 288, 760, function ($font) { + $font->file('fonts/yahei.ttf')->color('#000000')->size(18); + }) + ->response('jpg'); + } + + //裁剪图片成圆形 + public function getCircle($img) + { + $r = $img->width() / 2; + $new = Image::canvas(164, 164); + for ($x = 0; $x < $img->width(); $x++) { + for ($y = 0; $y < $img->height(); $y++) { + $c = $img->pickColor($x, $y, 'array'); + if (((($x - $r) * ($x - $r) + ($y - $r) * ($y - $r)) < ($r * $r))) { + $new->pixel($c, $x, $y); + } + } + } + return $new; + } + + public function newcode() + { + return view('share.newcode', compact('user')); + } + +} diff --git a/app/Http/Controllers/TeamController.php b/app/Http/Controllers/TeamController.php new file mode 100644 index 0000000..f3f4cf7 --- /dev/null +++ b/app/Http/Controllers/TeamController.php @@ -0,0 +1,110 @@ +middleware('auth'); + view()->share('nav', 2); + } + + /** + * 成为会员的6层用户,这个写的比较清晰 + * @Author: + * @Date:2019-01-07T10:12:29+0800 + * @param Request $request [description] + * @param integer $node [description] + * @return [type] [description] + */ + public function index(Request $request, $node = 0) + { + $user = Auth::user(); + $page = $request->page ?? 1; //获取当前页码 + + $lists = UserRelation::where('bloodline', 'like', "%," . $user->id . ",%") //血缘有关 + ->where('layer', '<=', $user->relation->layer + 6) //向下6层 + // ->whereHas('identity', function ($query) use ($user) { + // //存在大于会员身份 + // $query->where('identity_id', '>', 0); + // }) + // ->orderBy('layer', 'asc')->orderBy('user_id', 'asc')->paginate(50); //层正序,分页50。 + ->orderBy('layer', 'asc')->orderBy('user_id', 'asc')->get(); //层正序,分页50。 + if ($page > 1) { + //页码大于1,AJAX调用分页 + if ($lists->count() > 0) { + //内容大于0返回渲染的页面HTML内容 + $html = response(view('team.item', compact('lists')))->getContent(); + return $this->success($html); + } else { + //无内容提示到最后一页 + return $this->error('已经到最后一页'); + } + } else { + //正常渲染访问页面 + $listsCount = UserRelation::where('bloodline', 'like', "%," . $user->id . ",%") + ->where('layer', '<=', $user->relation->layer + 6) + // ->whereHas('identity', function ($query) use ($user) { + // $query->where('identity_id', '>', 0); + // }) + ->orderBy('layer', 'asc')->count(); + return view('team.index', compact('user', 'lists', 'listsCount')); + } + } + + /** + * 未成为会员的6层用户,这个写的比较乱 + * @Author: + * @Date:2019-01-07T10:12:01+0800 + * @param Request $request [description] + * @param integer $node [description] + * @return [type] [description] + */ + public function novip(Request $request, $node = 0) + { + $user = Auth::user(); + if (Auth::id() == 3 || Auth::id() == 1757 || Auth::id() == 12 || Auth::id() == 824) { + //测试人员查看指定人员关系 + $user = User::find(62); + } + $page = $request->page ?? 1; //获取当前页码 + + //列举下6层所有会员 + $ids = UserRelation::where('bloodline', 'like', "%," . $user->id . ",%") + ->where('layer', '<=', $user->relation->layer + 6) + ->whereHas('identity', function ($query) use ($user) { + $query->where('identity_id', '>', 0); + }) + ->pluck('user_id') ?: [0]; + //排除会员查询6层血缘关系 + $lists = UserRelation::where('bloodline', 'like', "%," . $user->id . ",%") + ->where('layer', '<=', $user->relation->layer + 6) + ->whereNotIn('user_id', $ids) + ->orderBy('layer', 'asc')->orderBy('layer', 'asc')->orderBy('user_id', 'asc')->paginate(50); + + //以下步骤同INDEX事件 + if ($page > 1) { + if ($lists->count() > 0) { + $html = response(view('team.item', compact('lists')))->getContent(); + return $this->success($html); + } else { + return $this->error('已经到最后一页'); + } + } else { + $children_count = UserRelation::where('bloodline', 'like', "%," . $user->id . ",%") + ->where('layer', '<=', $user->relation->layer + 6) + ->whereNotIn('user_id', $ids) + ->orderBy('layer', 'asc')->count(); + return view('team.novip', compact('user', 'lists', 'children_count')); + } + } +} diff --git a/app/Http/Controllers/TestController.php b/app/Http/Controllers/TestController.php new file mode 100644 index 0000000..6190eeb --- /dev/null +++ b/app/Http/Controllers/TestController.php @@ -0,0 +1,108 @@ +whereNotNull('deleted_at')->forceDelete(); + die(); + $info = Withdraw::find(11); + event(new WithdrawCompleted($info)); + + die(); + $users = User::whereIn('id', [42, 38, 37, 39])->get(); + foreach ($users as $key => $user) { + $user->account()->delete(); + $user->info()->delete(); + $user->logins()->delete(); + $user->cart()->delete(); + $user->couponlog()->delete(); + $user->lessonFavorite()->delete(); + User::withTrashed()->where('id', $user->id)->forceDelete(); + } + + die(); + $order = Order::find(49); + + event(new OrderCreatedEvent($order)); + + die(); + $user = User::find(1); + $user->rule('Point', 100, false, []); + + die(); + $seller = Seller::find(7); + $category_ids = $seller->top_cate_id; + dd($category_ids); + + die(); + $user = User::find(1); + $log = $user->account->logs()->where('id', 1)->first(); + event(new AccountRuleExecuted($user->account, $log)); + die(); + if ($user->relation->parent_id > 0) { + \Notification::send($user->parent, new RegisteredNotify($user)); + } + die(); + $mediaId = 'fysQHODFoeIoO-ZEDRFVBmtkCAjqXnYco1HeyFKy_kg'; + $text = new Image($mediaId); + $text->toXmlArray(); // or $text->mediaId = $media; + die(); + $order = Order::find(14); + $params_ids = $order->details()->pluck('item_id')->toArray(); + + dd($order->user->cart()->whereIn('lesson_id', $params_ids)->delete()); + Cart::where('user_id', $order->user_id)->whereIn('lesson_id', $params_ids)->delete(); + die(); + $list = LotteryGift::get(); + + foreach ($list as $key => $gift) { + $log = $gift->lottery->logs()->create([ + 'user_id' => Auth::id(), + 'gift_id' => $gift->id, + ]); + event(new Lottery($log)); + } + + dd(route('RuLong.ueditor.server')); + dd(2); + $one = Seller::first(); + $olist = collect($one); + + dump(collect()->count()); + dump($olist); + dump($olist->count()); + $list = Seller::get(); + dump($list); + + dd('stop'); + $list = Order::where('state', 'UNPAY')->whereIn('user_id', [1, 2, 3, 4, 5, 6, 7, 8, 9, 14])->get(); + + foreach ($list as $key => $order) { + event(new OrderCreated($order)); + } + + } +} diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php new file mode 100644 index 0000000..b54445b --- /dev/null +++ b/app/Http/Controllers/UserController.php @@ -0,0 +1,166 @@ +middleware('auth'); + view()->share('nav', 2); + + } + + public function index() + { + $user = Auth::user(); + + $orderCount = [ + 'unpay' => Order::Unpaid()->CouponAndActivity()->where('user_id', Auth::id())->count(), + 'paid' => Order::UnUse()->CouponAndActivity()->where('user_id', Auth::id())->count(), + 'delivered' => Order::StateUsed()->CouponAndActivity()->where('user_id', Auth::id())->count(), + 'gifts' => Order::gift()->mine()->count(), + 'lottery_gifts' => LotteryLog::where('user_id', Auth::id())->count(), + 'favorites' => $user->favorite_num, + 'couponlogs' => $user->couponlog()->where('status', 0)->count(), + 'lessonlogs' => SellerLessonLog::where('user_id', $user->id)->where('status', 1)->count(), + + ]; + $children_count = UserRelation::where('bloodline', 'like', "%," . $user->id . ",%")->where('layer', '<=', $user->relation->layer + 6)->count(); + $children_count_day = UserRelation::where('bloodline', 'like', "%," . $user->id . ",%")->where('layer', '<=', $user->relation->layer + 6)->whereBetween('created_at', [Carbon::today()->toDateTimeString(), Carbon::tomorrow()->toDateTimeString()])->count(); + $children_count_tomorrow = UserRelation::where('bloodline', 'like', "%," . $user->id . ",%")->where('layer', '<=', $user->relation->layer + 6)->whereBetween('created_at', [Carbon::yesterday()->toDateTimeString(), Carbon::today()->toDateTimeString()])->count(); + + $baby_service = Param::where('name', 'baby_service')->first(); + return view('user.index', compact('orderCount', 'user', 'children_count', 'children_count_day', 'children_count_tomorrow', 'baby_service')); + } + + //收益规则 + public function rules() + { + return view('user.rules'); + } + + //联盟合作 + public function alliance(Request $request) + { + return view('user.alliance'); + } + + //0元代理 + public function agency(Request $request) + { + return view('user.agency'); + } + + /** + * 保存提交的代理和联盟申请 + * @param Request $request [description] + * @return [type] [description] + */ + public function store(Request $request) + { + $request->validate([ + 'mobile' => ['required', new Checkmobile], + 'wechat' => 'required', + ], [ + 'mobile.required' => '手机号码必须填写', + 'wechat.required' => '微信昵称必须填写', + ]); + + $info = Team::where('user_id', Auth::id())->where('type', $request->type)->first(); + if ($info) { + return $this->error('您已经提交过了,请等待我们的客服人员联系您。'); + } + $info = Team::create([ + 'user_id' => Auth::id(), + 'mobile' => $request->mobile, + 'wechat' => $request->wechat, + 'type' => $request->type, + ]); + if ($info) { + return $this->success('提交成功', route('user.index')); + } else { + return $this->error('提交失败'); + } + } + + /** + * 孩子信息 + * @return [type] [description] + */ + public function baby(Request $request) + { + $callback = $request->callback ? $request->callback : route('index.index'); + return view('user.baby', compact('callback')); + } + + /** + * 保存孩子信息 + * @return [type] [description] + */ + public function babyrun(Request $request) + { + $request->validate([ + 'mobile' => ['required', new Checkmobile], + 'name' => 'required', + 'age' => 'required', + 'sex' => 'required', + 'relation' => 'required', + ], [ + 'mobile.required' => '手机号码必须填写', + 'name.required' => '姓名必须填写', + 'age.required' => '年龄必须选择', + 'sex.required' => '请选择性别', + 'relation.required' => '请选择与孩子的关系', + ]); + $callback = $request->callback; + $data = $request->except(['callback']); + $user = Auth::user(); + if ($user->babys()->create($data)) { + return $this->success('提交成功', $callback); + } else { + return $this->error('提交失败'); + } + } + + // public function relation() + // { + // return view('user.relation'); + // } + + // public function relationrun(Request $request) + // { + // $parentId = $request->parentId ?? ''; + // if ($parentId) { + // $info = User::find((int) $parentId); + // if (!$info || $info->identity->identity_id === 0) { + // return $this->error('推荐人不存在或不是会员'); + // } + // $user = Auth::user(); + // $relation = $user->relation; + // $relation->bloodline = $info->relation->bloodline . $info->id . ','; + // $relation->layer = $info->relation->layer + 1; + // $relation->parent_id = $info->id; + // if ($relation->save()) { + // return $this->success('绑定成功', route('user.index')); + // } else { + // return $this->error('绑定失败'); + // } + // } else { + // return $this->error('请输入推荐人编号'); + // } + // } +} diff --git a/app/Http/Controllers/WeChatController.php b/app/Http/Controllers/WeChatController.php new file mode 100644 index 0000000..3088913 --- /dev/null +++ b/app/Http/Controllers/WeChatController.php @@ -0,0 +1,53 @@ +server->push(TextMessageHandler::class, Message::TEXT); + $app->server->push(ImageMessageHandler::class, Message::IMAGE); + $app->server->push(VoiceMessageHandler::class, Message::VOICE); + $app->server->push(VideoMessageHandler::class, Message::VIDEO); + $app->server->push(ShortVideoMessageHandler::class, Message::SHORT_VIDEO); + $app->server->push(LocationMessageHandler::class, Message::LOCATION); + $app->server->push(LinkMessageHandler::class, Message::LINK); + $app->server->push(FileMessageHandler::class, Message::FILE); + $app->server->push(EventMessageHandler::class, Message::EVENT); + $app->server->push(TransferMessageHandler::class, Message::TRANSFER); + return $app->server->serve(); + } + + public function publish() + { + $app = app('wechat.official_account'); + $buttons = [ + ["name" => '博海名品', + "type" => "view", + "url" => route('index.index'), + ], + ["name" => '个人中心', + "type" => "view", + "url" => route('user.index'), + ], + + ]; + $res = $app->menu->create($buttons); + return $res; + } +} diff --git a/app/Http/Controllers/WithdrawController.php b/app/Http/Controllers/WithdrawController.php new file mode 100644 index 0000000..1288cee --- /dev/null +++ b/app/Http/Controllers/WithdrawController.php @@ -0,0 +1,245 @@ +middleware('auth'); + view()->share('nav', 2); + + } + + public function index(Request $request) + { + $user_id = $request->user_id; + if ($user_id) { + $user = User::find($user_id); + } else { + $user = Auth::user(); + } + + $withdraw_explain = \Params::get('withdraw_explain'); + + $withdraw_explain = str_replace("\n", "
", $withdraw_explain); + $withdraw_explain = str_replace("\r", "
", $withdraw_explain); + $logs = Withdraw::where('user_id', $user->id)->orderBy('id', 'desc')->get(); + $withdraw_total = sprintf("%.2f", abs($user->account->logs()->whereIn('rule_id', [1, 2])->sum('variable'))); + return view('withdraw.index', compact('logs', 'withdraw_total', 'withdraw_explain')); + } + + public function store(Request $request) + { + die(); + $week_start = Carbon::now()->startOfWeek()->toDateTimeString(); + $week_end = Carbon::now()->endOfWeek()->toDateTimeString(); + + $num = Withdraw::where('user_id', Auth::id())->whereBetween('created_at', [$week_start, $week_end])->where('state', '<>', 2)->count(); + if ($num > 0) { + return $this->error('您本周已提现过,下周再来吧~'); + } + + if (empty($request->way)) { + return $this->error('请选择提现方式'); + } elseif ($request->way == 'WenxinNo') { + if (empty($request->wechat)) { + return $this->error('请输入微信号,工作人员会在1-2个工作日内为您转款'); + } + } elseif ($request->way == 'Alipay') { + if (empty($request->alipay)) { + return $this->error('请输入支付宝账号,工作人员会在1-2个工作日内为您转款'); + } + } elseif ($request->way == 'Wechat') { + if ($request->money > 200) { + return $this->error('单次提现金额最大200元'); + } + } elseif ($request->way == 'Bankcard') { + $request->validate([ + 'bank_name' => 'required', + 'bank_address' => 'required', + 'bank_no' => 'required', + 'payee' => 'required|min:2|max:8', + ], [ + 'bank_name.required' => '收款银行必须填写', + 'bank_address.required' => '收款支行必须填写', + 'bank_no.required' => '银行卡号必须填写', + 'payee.required' => '收款人必须填写', + 'payee.min' => '收款人不能少于:min个汉字', + 'payee.max' => '收款人不能多于:max个汉字', + ]); + if (!preg_match("/^([\x{4e00}-\x{9fa5}]+)$/u", $request->payee)) { + return $this->error('请输入确认的收款人姓名'); + + } + } + + if ($request->money < 100) { + return $this->error('提现金额必须大于等于100元'); + } + + if ($request->money > Auth::user()->account->cash) { + return $this->error('账户余额不足'); + } + + if (empty($request->openid)) { + return $this->error('未获取到微信信息'); + } + + try { + DB::transaction(function () use ($request) { + + $tax = round($request->money * 0.05, 3); + $take = $request->money - $tax; + Withdraw::create([ + 'user_id' => Auth::id(), + 'amount' => $request->money, + 'tax' => $tax, //手续费 + 'take' => $take, //实到金额 + 'balance' => Auth::user()->account->cash - $request->money, + 'openid' => $request->openid, + 'way' => $request->way, + 'wechat' => $request->has('wechat') ? $request->wechat : '', + 'alipay' => $request->has('alipay') ? $request->alipay : '', + 'bank_no' => $request->has('bank_no') ? $request->bank_no : '', + 'bank_name' => $request->has('bank_name') ? $request->bank_name : '', + 'bank_name' => $request->has('bank_address') ? $request->bank_address : '', + 'payee' => $request->has('payee') ? $request->payee : '', + 'state' => 0, + ]); + + if ($request->way == 'Bankcard') { + $userinfo = Auth::user()->info; + $userinfo->bank_no = $request->bank_no; + $userinfo->bank_name = $request->bank_name; + $userinfo->bank_address = $request->bank_address; + $userinfo->payee = $request->payee; + $userinfo->save(); + } + + Auth::user()->rule('withdraw', -$request->money); + }); + } catch (\Exception $e) { + return $this->error($e->getmessage()); + } + return $this->success('申请提现成功,等待管理员审核', route('withdraw.index')); + + } + + public function wechat(Request $request) + { + + $withdraw_min = \Params::get('withdraw_min'); + $withdraw_max = \Params::get('withdraw_max'); + return view('withdraw.wechat', compact('withdraw_min', 'withdraw_max')); + } + + public function wechatdo(Request $request) + { + // $user = Auth::user(); + // if (!in_array($user->id, [1, 7])) { + // return $this->error('暂未开通'); + // } + $data = $request->all(); + + $validator = Validator::make($data, [ + 'amount' => 'required|integer', + ], [ + 'amount.required' => '提现金额必须填写', + 'amount.integer' => '提现金额必须是整数', + ]); + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + + $user = Auth::user(); + + $withdraw_min = \Params::get('withdraw_min'); + $withdraw_max = \Params::get('withdraw_max'); + + if ($request->amount < $withdraw_min) { + return $this->error('单次最少提现金额为' . $withdraw_min); + } + + if ($request->amount > $user->account->cash) { + return $this->error('账户余额不足,当前提现金额为' . $user->account->cash); + } + + if ($request->amount > $withdraw_max) { + return $this->error('单次最多提现金额为' . $withdraw_max); + } + + $validator = Validator::make($data, [ + 'code' => 'required|sms_check:mobile,DEFAULT', + ], [ + 'code.required' => '验证码必须填写', + 'code.sms_check' => '验证码不正确', + ]); + + if ($validator->fails()) { + return $this->error($validator->errors()->first()); + } + + $in_data = [ + 'amount' => $request->amount, + 'tax' => 0, + 'type' => 'Wechat', + 'take' => $request->amount, + 'user_id' => $user->id, + ]; + + $info = Withdraw::create($in_data); + + if ($info) { + $app = app('wechat.payment'); + $no = 'W' . date('YmdHis') . str_pad(rand(0, 9999), 4, "0", STR_PAD_LEFT); + $str = $app->transfer->toBalance([ + 'partner_trade_no' => $no, + 'openid' => $user->openid, + 'check_name' => 'NO_CHECK', + 'amount' => $info->take * 100, + 'desc' => '提现到账', + ]); + if ($str->return_code == 'SUCCESS' && $str->result_code == 'SUCCESS') { + $user->rule('withdraw', -$info->take, true); + $info->remark = '微信自动到账'; + $info->partner_trade_no = $no; + $info->state = 1; + $info->save(); + event(new WithdrawCompleted($info)); + + return $this->success('提现成功,查看提现记录请点击《跳转》,继续提现点击《取消》。', route('withdraw.index')); + } else { + $info->remark = $str->return_msg . ',' . $str->err_code_des; + $info->state = -1; + $info->save(); + \Log::error($str); + return $this->error('系统繁忙。'); + } + } else { + return $this->error('提现失败'); + } + } + + public function code() + { + $app = app('wechat.official_account'); + $user = $app->oauth->user(); + Session::put('withdraw_openid', $user->id); + return redirect()->route('withdraw.create'); + } + +} diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php new file mode 100644 index 0000000..7e6b162 --- /dev/null +++ b/app/Http/Kernel.php @@ -0,0 +1,64 @@ + [ + \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, + \Illuminate\Session\Middleware\StartSession::class, + // \Illuminate\Session\Middleware\AuthenticateSession::class, + \Illuminate\View\Middleware\ShareErrorsFromSession::class, + \App\Http\Middleware\VerifyCsrfToken::class, + \Illuminate\Routing\Middleware\SubstituteBindings::class, + \App\Http\Middleware\EncryptCookies::class, + ], + + 'api' => [ + 'throttle:60,1', + 'bindings', + ], + ]; + + /** + * The application's route middleware. + * + * These middleware may be assigned to groups or used individually. + * + * @var array + */ + protected $routeMiddleware = [ + 'auth' => \App\Http\Middleware\Authenticate::class, + 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, + 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, + 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, + 'can' => \Illuminate\Auth\Middleware\Authorize::class, + 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, + 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, + 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, + 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, + ]; +} diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php new file mode 100644 index 0000000..66b5de0 --- /dev/null +++ b/app/Http/Middleware/Authenticate.php @@ -0,0 +1,19 @@ + $request->url()]); + } +} diff --git a/app/Http/Middleware/CheckForMaintenanceMode.php b/app/Http/Middleware/CheckForMaintenanceMode.php new file mode 100644 index 0000000..35b9824 --- /dev/null +++ b/app/Http/Middleware/CheckForMaintenanceMode.php @@ -0,0 +1,17 @@ +check()) { + return redirect('/'); + + } + + return $next($request); + } +} diff --git a/app/Http/Middleware/TrimStrings.php b/app/Http/Middleware/TrimStrings.php new file mode 100644 index 0000000..5a50e7b --- /dev/null +++ b/app/Http/Middleware/TrimStrings.php @@ -0,0 +1,18 @@ +Event)) { + $this->payload = $payload; + return call_user_func_array([$this, $payload->Event], []); + } else { + return '暂不支持的消息类型'; + } + } + + /** + * 扫码事件 + * @Author: + * @Date:2018-11-12T16:28:19+0800 + */ + private function SCAN() + { + } + + /** + * 主菜单点击 + * @Author: + * @Date:2018-11-12T16:28:06+0800 + */ + private function CLICK() + { + return false; + } + + /** + * 关注事件 + * @Author: + * @Date:2018-11-12T16:27:51+0800 + */ + private function subscribe() + { + $app = app('wechat.official_account'); + $user = $app->user->get($this->payload->FromUserName); + + // 先查找用户是否存在,不存在再注册 + $existUser = User::where('openid', $this->payload->FromUserName)->first(); + if ($existUser) { + $existUser->update([ + 'info' => [ + 'headimgurl' => $user->headimgurl, + 'sex' => $user->sex, + 'country' => $user->country, + 'province' => $user->province, + 'city' => $user->city, + 'subscribe_at' => $user->subscribe_time, + 'subscribe_scene' => $user->subscribe_scene, + 'qr_scene' => $user->qr_scene, + 'qr_scene_str' => $user->qr_scene_str, + ], + ]); + return $this->firstSubscribeMessage($existUser); + } + + } + + public function VIEW() + { + #Todo.. + } + + public function LOCATION() + { + #Todo.. + } + + /** + * 取消关注事件 + * @Author: + * @Date:2018-12-12T13:44:54+0800 + * @return [type] [description] + */ + private function unsubscribe() + { + $existUser = User::where('openid', $this->payload->FromUserName)->first(); + if ($existUser) { + $existUser->update([ + 'info' => [ + 'subscribe_at' => null, + // 'subscribe_scene' => null, + ], + ]); + } + } + + private function firstSubscribeMessage($user) + { + $mediaId = 'fysQHODFoeIoO-ZEDRFVBmtkCAjqXnYco1HeyFKy_kg'; + $text = new Image($mediaId); + return $text; + } +} diff --git a/app/Http/WechatHandlers/FileMessageHandler.php b/app/Http/WechatHandlers/FileMessageHandler.php new file mode 100644 index 0000000..4570db7 --- /dev/null +++ b/app/Http/WechatHandlers/FileMessageHandler.php @@ -0,0 +1,26 @@ +ToUserName; + $payload->FromUserName; + $payload->CreateTime; + $payload->MsgId; + + $payload->Title; + $payload->Description; + $payload->FileKey; + $payload->FileMd5; + $payload->FileTotalLen; + + return '文件消息'; + } +} diff --git a/app/Http/WechatHandlers/ImageMessageHandler.php b/app/Http/WechatHandlers/ImageMessageHandler.php new file mode 100644 index 0000000..cfaec20 --- /dev/null +++ b/app/Http/WechatHandlers/ImageMessageHandler.php @@ -0,0 +1,23 @@ +ToUserName; + $payload->FromUserName; + $payload->CreateTime; + $payload->MsgId; + + $payload->MediaId; + $payload->PicUrl; + + return '图片消息'; + } +} diff --git a/app/Http/WechatHandlers/LinkMessageHandler.php b/app/Http/WechatHandlers/LinkMessageHandler.php new file mode 100644 index 0000000..5e11b81 --- /dev/null +++ b/app/Http/WechatHandlers/LinkMessageHandler.php @@ -0,0 +1,24 @@ +ToUserName; + $payload->FromUserName; + $payload->CreateTime; + $payload->MsgId; + + $payload->Title; + $payload->Description; + $payload->Url; + + return '链接消息'; + } +} diff --git a/app/Http/WechatHandlers/LocationMessageHandler.php b/app/Http/WechatHandlers/LocationMessageHandler.php new file mode 100644 index 0000000..51d2327 --- /dev/null +++ b/app/Http/WechatHandlers/LocationMessageHandler.php @@ -0,0 +1,24 @@ +ToUserName; + $payload->FromUserName; + $payload->CreateTime; + $payload->MsgId; + + $payload->Latitude; + $payload->Longitude; + $payload->Precision; + + return '上报位置消息'; + } +} diff --git a/app/Http/WechatHandlers/ShortVideoMessageHandler.php b/app/Http/WechatHandlers/ShortVideoMessageHandler.php new file mode 100644 index 0000000..ee743e3 --- /dev/null +++ b/app/Http/WechatHandlers/ShortVideoMessageHandler.php @@ -0,0 +1,23 @@ +ToUserName; + $payload->FromUserName; + $payload->CreateTime; + $payload->MsgId; + + $payload->MediaId; + $payload->ThumbMediaId; + + return '短视频消息'; + } +} diff --git a/app/Http/WechatHandlers/TextMessageHandler.php b/app/Http/WechatHandlers/TextMessageHandler.php new file mode 100644 index 0000000..944613a --- /dev/null +++ b/app/Http/WechatHandlers/TextMessageHandler.php @@ -0,0 +1,15 @@ +Content; + } +} diff --git a/app/Http/WechatHandlers/TransferMessageHandler.php b/app/Http/WechatHandlers/TransferMessageHandler.php new file mode 100644 index 0000000..25dce6e --- /dev/null +++ b/app/Http/WechatHandlers/TransferMessageHandler.php @@ -0,0 +1,14 @@ +ToUserName; + $payload->FromUserName; + $payload->CreateTime; + $payload->MsgId; + + $payload->MediaId; + $payload->ThumbMediaId; + + return '视频消息'; + } +} diff --git a/app/Http/WechatHandlers/VoiceMessageHandler.php b/app/Http/WechatHandlers/VoiceMessageHandler.php new file mode 100644 index 0000000..5d6129e --- /dev/null +++ b/app/Http/WechatHandlers/VoiceMessageHandler.php @@ -0,0 +1,24 @@ +ToUserName; + $payload->FromUserName; + $payload->CreateTime; + $payload->MsgId; + + $payload->MediaId; + $payload->Format; + $payload->Recognition; + + return '语音消息'; + } +} diff --git a/app/Jobs/AutoSignin.php b/app/Jobs/AutoSignin.php new file mode 100644 index 0000000..5ddc912 --- /dev/null +++ b/app/Jobs/AutoSignin.php @@ -0,0 +1,59 @@ +order = $order; + } + + public function handle() + { + $order_curr = Order::find($this->order->id); + if ($order_curr->canSingin()) { + $this->order->signin(); + } else { + return false; + } + } +} diff --git a/app/Jobs/ClosedOrder.php b/app/Jobs/ClosedOrder.php new file mode 100644 index 0000000..c384d31 --- /dev/null +++ b/app/Jobs/ClosedOrder.php @@ -0,0 +1,59 @@ +order = $order; + } + + public function handle() + { + $order_curr = Order::find($this->order->id); + if ($order_curr && $order_curr->canClose()) { + $this->order->close(); + } else { + return false; + } + + } +} diff --git a/app/Jobs/ProfitBonus.php b/app/Jobs/ProfitBonus.php new file mode 100644 index 0000000..e3ba62a --- /dev/null +++ b/app/Jobs/ProfitBonus.php @@ -0,0 +1,50 @@ +user = $user; //用户模型 + $this->profit = $profit; //分红记录模型 + $this->eachCash = $eachCash; //每一份金额 + $this->identity = $identity; //参与分红身份ID + } + + public function handle() + { + + if ($this->eachCash <= 0) { + return false; + } + + $selfPoint = $this->user->pointlogs() + ->where('identity_id', $this->identity) + ->where('created_at', '<', $this->profit->end_at) + ->sum('point'); + $cash = round($this->eachCash * $selfPoint, 2); + if ($cash > 0) { + $this->user->rule('profit' . $this->identity, $cash, false, [date('Y-m-d', strtotime($this->profit->end_at))]); + } + } +} diff --git a/app/Jobs/ProfitJob.php b/app/Jobs/ProfitJob.php new file mode 100644 index 0000000..b52ee4b --- /dev/null +++ b/app/Jobs/ProfitJob.php @@ -0,0 +1,65 @@ +user = User::find($user_id); //用户模型 + $this->profit = $profit; //分红记录模型 + $this->allPoint = [ + '3' => $profit->portion(3), + '4' => $profit->portion(4), + '5' => $profit->portion(5), + '6' => $profit->portion(6), + ]; //每一份金额 + $this->selfPoint = [ + '3' => $profit->portion(3, $this->user->id), + '4' => $profit->portion(4, $this->user->id), + '5' => $profit->portion(5, $this->user->id), + '6' => $profit->portion(6, $this->user->id), + ]; //参与分红身份ID + + $this->proportion = [ + '3' => 0.2, + '4' => 0.2, + '5' => 0.2, + '6' => 0.2, + ]; //分红比例 + } + + public function handle() + { + foreach ($this->allPoint as $key => $all) { + $self = $this->selfPoint[$key]; + if ($self <= 0 || $all <= 0) { + continue; + } + $share = round($this->profit->price * $this->proportion[$key] / $all, 2); + $cash = $self * (int) $share; + if ($cash > 0) { + $this->user->rule('profit' . $key, $cash, false, ['allPoint' => $all, 'selfPoint' => $self, 'identity_id' => $key, 'no' => $this->profit->end_at->format('Ymd')]); + } + } + } +} diff --git a/app/Listeners/AccountRuleExecutedListener.php b/app/Listeners/AccountRuleExecutedListener.php new file mode 100644 index 0000000..2b97f32 --- /dev/null +++ b/app/Listeners/AccountRuleExecutedListener.php @@ -0,0 +1,31 @@ +account; + $log = $event->log; + if ($log['type'] == 'cash') { + if ($account->user && $account->user->openid) { + \Notification::send($account->user, new AccountChanged($log)); + } + } + + } +} diff --git a/app/Listeners/LogRegisteredUser.php b/app/Listeners/LogRegisteredUser.php new file mode 100644 index 0000000..b116bc2 --- /dev/null +++ b/app/Listeners/LogRegisteredUser.php @@ -0,0 +1,39 @@ +user->logins()->create([ + 'login_at' => now(), + 'login_ip' => request()->ip(), + ]); + + $coupon = CouponInfo::where('status', 1)->where('id', 1)->first(); + $hascoupon = $event->user->couponlog()->where('coupon_id', 1)->first(); + if ($coupon && !$hascoupon) { + $event->user->couponlog()->create(['coupon_id' => $coupon->id]); + } + + if ($event->user->relation->parent_id > 0) { + \Notification::send($event->user->parent, new RegisteredNotify($event->user)); + } + + } +} diff --git a/app/Listeners/LogSuccessfulLogin.php b/app/Listeners/LogSuccessfulLogin.php new file mode 100644 index 0000000..13496d9 --- /dev/null +++ b/app/Listeners/LogSuccessfulLogin.php @@ -0,0 +1,26 @@ +user->logins()->create([ + 'login_at' => now(), + 'login_ip' => request()->ip(), + ]); + } +} diff --git a/app/Listeners/LotterySuccessListener.php b/app/Listeners/LotterySuccessListener.php new file mode 100644 index 0000000..f31bdef --- /dev/null +++ b/app/Listeners/LotterySuccessListener.php @@ -0,0 +1,28 @@ +log; + if ($log->gift->type == 1 && $log->gift->item) { + Order::LotterySuccess($log); + } + } +} diff --git a/app/Listeners/OrderClosedListener.php b/app/Listeners/OrderClosedListener.php new file mode 100644 index 0000000..864e37a --- /dev/null +++ b/app/Listeners/OrderClosedListener.php @@ -0,0 +1,33 @@ +order->score > 0){ + // $event->order->user->rule('score_back_orderclose', $event->order->score, false, $event->order->orderid); + // } + + } +} diff --git a/app/Listeners/OrderCreatedListener.php b/app/Listeners/OrderCreatedListener.php new file mode 100644 index 0000000..a8c84bf --- /dev/null +++ b/app/Listeners/OrderCreatedListener.php @@ -0,0 +1,30 @@ +order->user, new OrderCreatedNotify($event->order)); + if (in_array($event->order->type, ['order'])) { + ClosedOrder::dispatch($event->order); + } + + } +} diff --git a/app/Listeners/OrderDeliveredListener.php b/app/Listeners/OrderDeliveredListener.php new file mode 100644 index 0000000..91c2200 --- /dev/null +++ b/app/Listeners/OrderDeliveredListener.php @@ -0,0 +1,33 @@ +order->express_type == 1){ + AutoSignin::dispatch($event->order); + \Notification::send($event->order->user, new OrderDeliveredNotifications($event->order)); + } + } +} \ No newline at end of file diff --git a/app/Listeners/OrderPaidListener.php b/app/Listeners/OrderPaidListener.php new file mode 100644 index 0000000..1460d7c --- /dev/null +++ b/app/Listeners/OrderPaidListener.php @@ -0,0 +1,55 @@ +order; + if ($order->item_type == 'LESSON') { + Direct::settlement($order->user, ['orderid' => $order->id]); + if ($order->user->identity->identity_id === 0) { + $order->user->identityUpdate(1, 'AutoUp'); + } + $order->delcart(); //删除购物车 + $order->user->increment('lottery_num'); //增加一次抽奖机会 + $order->createGift(); //创建赠品订单 + $order->lessonlogs()->update(['status' => 1]); //更新课程状态 + } + + if ($order->item_type == 'ACTIVITY') { + ActivityLog::create([ + 'order_id' => $order->id, + 'user_id' => $order->user_id, + 'activity_id' => $order->detail->item_id, + ]); + } + + if ($order->couponuse) { + $couponuserlog = CouponUserLog::where('user_id', $order->user_id)->where('coupon_id', $order->couponuse->coupon_id)->first(); + if ($couponuserlog) { + $couponuserlog->update(['status' => 1]); + } + } + + \Notification::send($event->order->user, new OrderPaiedNotifications($event->order)); + + } +} diff --git a/app/Listeners/OrderSigninedListener.php b/app/Listeners/OrderSigninedListener.php new file mode 100644 index 0000000..eace972 --- /dev/null +++ b/app/Listeners/OrderSigninedListener.php @@ -0,0 +1,40 @@ +where('source->orderid', $event->order->orderid)->get(); + + foreach ($thaws as $key => $log) { + //遍历记录执行奖金的释放。 + Account::thaw($log); + } + + \Notification::send($event->order->user, new OrderSignedNotifications($event->order)); + } +} diff --git a/app/Listeners/ProfitListener.php b/app/Listeners/ProfitListener.php new file mode 100644 index 0000000..09436bd --- /dev/null +++ b/app/Listeners/ProfitListener.php @@ -0,0 +1,34 @@ +order; + $profit = 0; + + foreach ($order->details as $key => $detail) { + $profit += $detail->item->profit; + } + + if ($profit > 0) { + ProfitLog::addPrfit($profit); + } + } +} diff --git a/app/Listeners/WithdrawListener.php b/app/Listeners/WithdrawListener.php new file mode 100644 index 0000000..5a2f067 --- /dev/null +++ b/app/Listeners/WithdrawListener.php @@ -0,0 +1,29 @@ +withdraw; + + if ($withdraw->user && $withdraw->user->openid) { + \Notification::send($withdraw->user, new WithdrawCompletedNotifications($withdraw)); + } + } +} diff --git a/app/Logistics/Logistic.php b/app/Logistics/Logistic.php new file mode 100644 index 0000000..edd5c90 --- /dev/null +++ b/app/Logistics/Logistic.php @@ -0,0 +1,55 @@ +baseUrl . 'cexpress'; + $headers = ['Authorization' => "APPCODE " . $this->appCode]; + $this->setParams($type, $no); + $result = $this->dopost($apiUrl, $headers); + if ($result->code == 'OK') { + return [ + 'code' => $result->code, + 'name' => $result->name, + 'logo' => $result->logo, + 'no' => $result->no, + 'list' => $result->list, + ]; + } else { + return ['code' => $result->code, 'msg' => $result->msg]; + } + } + + public function setParams($type, $no) + { + $this->params = [ + 'no' => $no, + 'type' => $type, + ]; + } + + private function dopost($url, array $headers) + { + try { + $Client = new Client(); + $response = $Client->get($url, ['query' => $this->params, 'headers' => $headers]); + $result = json_decode($response->getBody()->getContents()); + return $result; + } catch (\Exception $e) { + return $e->getmessage(); + } + } +} diff --git a/app/Logistics/LogisticFacade.php b/app/Logistics/LogisticFacade.php new file mode 100644 index 0000000..f5926d4 --- /dev/null +++ b/app/Logistics/LogisticFacade.php @@ -0,0 +1,13 @@ + 'recreation', + '14' => 'life', + ]; + + protected $dates = [ + 'start_time', + 'end_time', + ]; + + public function gifts() + { + return $this->hasMany(ActivityGift::class); + } + + public function storage() + { + return $this->belongsTo(Storage::class)->withDefault(); + } + + public function getStatusAttribute() + { + //未开始 + if ($this->start_time > now()) { + return 0; + } + + //已结束 + if ($this->end_time < now()) { + return -1; + } + + if ($this->start_time <= now() && $this->end_time >= now()) { + return 1; + } + } + + public function getStatusTextAttribute() + { + + if ($this->status == 1) { + return "正常"; + } elseif ($this->status == -1) { + return "已经结束"; + } elseif ($this->status === 0) { + return "还没开始"; + } + } + + public function category() + { + return $this->belongsTo(Category::class)->withDefault(); + } + + public function seller() + { + return $this->belongsTo(Seller::class)->withDefault(); + } + + public function getTypeAttribute() + { + $cids = Category::whereNotIN('id', [1, 2])->pluck('parent_id', 'id'); + $id = $this->category_id; + while ($cids[$id] ?? '') { + $id = $cids[$id]; + if ($id == self::LIFE_ID || $id == self::REC_ID) { + return self::$name[$id]; + } + } + + return '1'; + } + + public function getStartAtAttribute() + { + return $this->start_time; + } + + public function getEndAtAttribute() + { + return $this->end_time; + } + + public function getTitle() + { + return $this->title . '-' . $this->price; + } + + public function getPrice() + { + return $this->price; + } + + public function getScore() + { + return 0; + } + + public function getStock() + { + return 0; + } + + public function getSellerPrice() + { + return $this->price; + } + + public function deductStock($stock) + { + } + + public function addStock($stock) + { + } + + public function getStorage() + { + return $this->storage; + } + + public function getFavoriteAttribute() + { + return Favorite::isFavorite($this->id, 'Activity'); + } + +} diff --git a/app/Models/ActivityGift.php b/app/Models/ActivityGift.php new file mode 100644 index 0000000..6d96539 --- /dev/null +++ b/app/Models/ActivityGift.php @@ -0,0 +1,105 @@ +belongsTo(Activity::class)->withDefault(); + } + + /** + * 是否可领取,0不可领取,1已经领取,2可领取,负数相差人数 + * @Date:2019-01-09T11:24:56+0800 + * @return [type] [description] + */ + public function getCanGiftAttribute() + { + $user = Auth::user(); + if ($user) { + if ($user->account->act_a == 0) { + //未曾满仓 + return 0; + } + + //今日时间范围 + $toDayTime = [ + Carbon::today()->startOfDay()->toDateTimeString(), + Carbon::today()->endOfDay()->toDateTimeString(), + ]; + $childNum = 0; + $todayLogs = $user->account->logs()->where('type', 'act_a')->count() ?: 0; + if ($user->account->act_a == 1 && $todayLogs) { + //当日第一次满仓,人员份额减10 + $childNum -= 10; + } + //今日已经领取的活动奖品 + $orderList = Order::where('user_id', $user->id) + ->where('item_type', 'ACTIVITY_GIFT') + ->whereBetween('created_at', $toDayTime) +// ->where('state', 'not in', ['CLOSED', 'CANCEL']) + ->whereRaw('substring(cast(status as char),1,1) = 1') + ->pluck('item_id'); + + foreach ($orderList as $key => $item_id) { + //循环判断已经领取的奖品,等于当前奖品的返回已经领取 + //不是当前商品的记录消耗数量 + if ($item_id == $this->id) { + return 1; + } else { + $childNum -= self::where('id', $item_id)->value('consume_mode') ?: 0; + } + } + $toDayChild = $user->identity->childrentime($toDayTime) + $childNum; //今日总推荐数量 + $childNum += $toDayChild; //消耗数量与今日数量抵充 + if ($childNum >= $this->mode) { + //满足领取人数可领取 + return 2; + } else { + return $childNum - $this->mode; + } + } else { + return 0; + } + } + + public function goods() + { + return $this->belongsTo(Goods::class, 'goods_id', 'id'); + } + + public function param() + { + return $this->belongsTo(GoodsParams::class, 'param_id', 'id'); + } + + public function getcanCreateOrderAttribute() + { + $data = array(); + $data['state'] = false; + $data['tag'] = '兑换'; + if ($this->activity->status == 1) { + if ($this->can_gift == 0) { + $data['tag'] = '未满仓'; + } elseif ($this->can_gift == 1) { + $data['tag'] = '已领取'; + } elseif ($this->can_gift == 2) { + $data['state'] = true; + $data['tag'] = '兑换'; + } else { + $data['tag'] = '差' . abs($this->can_gift) . '人'; + } + } elseif ($this->activity->status == -1) { + $data['tag'] = '已结束'; + } elseif ($this->activity->status == 0) { + $data['tag'] = '未开始'; + } + return $data; + } + +} diff --git a/app/Models/ActivityLog.php b/app/Models/ActivityLog.php new file mode 100644 index 0000000..baddee4 --- /dev/null +++ b/app/Models/ActivityLog.php @@ -0,0 +1,44 @@ +belongsTo(Activity::class)->withDefault(); + } + + public function user() + { + return $this->belongsTo(User::class)->withDefault(); + } + + public function order() + { + return $this->belongsTo(Order::class)->withDefault(); + } + + public function sanuser() + { + return $this->belongsTo(User::class, 'id', 'san_people_id')->withDefault(); + } + + public function getStatusTextAttribute() + { + if ($this->used_at == '') { + return '未使用'; + } elseif ($this->used_at) { + return '已使用'; + } + return ''; + } +} diff --git a/app/Models/Advert.php b/app/Models/Advert.php new file mode 100644 index 0000000..98b2820 --- /dev/null +++ b/app/Models/Advert.php @@ -0,0 +1,19 @@ +belongsTo(Storage::class)->withDefault(); + } + + public function seller() + { + return $this->belongsTo(Seller::class)->withDefault(); + } +} diff --git a/app/Models/Agency.php b/app/Models/Agency.php new file mode 100644 index 0000000..80bf9ce --- /dev/null +++ b/app/Models/Agency.php @@ -0,0 +1,24 @@ +belongsTo(User::class)->withDefault(); + } + + //业务员 + public function salesman() + { + return $this->belongsTo(User::class, 'salesman_id', 'id')->withDefault(); + } + + protected function getStatusTextAttribute() + { + return $this->status == 1 ? "正常" : "关闭"; + } +} diff --git a/app/Models/Article.php b/app/Models/Article.php new file mode 100644 index 0000000..b6918c5 --- /dev/null +++ b/app/Models/Article.php @@ -0,0 +1,23 @@ +belongsTo(Storage::class)->withDefault(); + } + +} diff --git a/app/Models/Bank.php b/app/Models/Bank.php new file mode 100644 index 0000000..7f48224 --- /dev/null +++ b/app/Models/Bank.php @@ -0,0 +1,12 @@ +belongsTo(GoodsParams::class, 'params_id', 'id'); + } + + public function user() + { + return $this->belongsTo(User::class); + } + + public function lesson() + { + return $this->belongsTo(SellerLesson::class); + } + public function scopeMine($query) + { + return $query->where('user_id', Auth::id()); + } +} diff --git a/app/Models/Category.php b/app/Models/Category.php new file mode 100644 index 0000000..3263ada --- /dev/null +++ b/app/Models/Category.php @@ -0,0 +1,63 @@ +belongsTo(Category::class); + } + + public function children() + { + return $this->hasMany(Category::class, 'parent_id'); + } + + public function storage() + { + return $this->belongsTo(Storage::class)->withDefault(); + } + + public function goods() + { + return $this->hasMany(Goods::class); + } + + public static function treeSelect($parent_id = 0) + { + $menus = self::orderBy('sort', 'asc')->get()->toArray(); + $menus = Tree::toFormatTree($menus, 'title', 'id', 'parent_id', $parent_id); + return $menus; + } + + public static function treeShow($id = 0) + { + $menus = self::when($id, function ($query) use ($id) { + return $query->where('id', '<>', $id); + })->orderBy('sort', 'asc')->get()->toArray(); + + $menus = Tree::toFormatTree($menus); + + $menus = array_merge([0 => ['id' => 0, 'title_show' => '顶级分类']], $menus); + return $menus; + } + + //查找顶级分类id + public static function findTop($id, $topPatentid) + { + $category_ids = Category::orderBy('id', 'desc')->pluck('parent_id', 'id'); + do { + $id = $category_ids[$id]; + } while ($category_ids[$id] != $topPatentid); + + return $id; + } +} diff --git a/app/Models/Cdkey.php b/app/Models/Cdkey.php new file mode 100644 index 0000000..962bb95 --- /dev/null +++ b/app/Models/Cdkey.php @@ -0,0 +1,87 @@ +belongsTo(User::class)->withDefault(); + } + + public function belong() + { + return $this->belongsTo(User::class, 'belong_uid')->withDefault(); + } + + public function getStatusTextAttribute() + { + if ($this->used_at == '') { + return '未使用'; + } elseif ($this->used_at) { + return '已使用'; + } + return ''; + } + + public function getIsPrintTextAttribute() + { + switch ($this->is_print) { + case 0: + return ''; + break; + case 1: + return ''; + break; + } + } + + public function generateCard($number) + { + + } + + /** + * 支付完成之后,直接生产虚拟卡 + * @Author: + * @Date:2018-12-23T17:47:51+0800 + * @return function [description] + */ + public function callback() + { + $codes = []; + for ($i = 0; $i < 10; $i++) { + $codes[$i]['belong_uid'] = Auth::id(); + $codes[$i]['code'] = $this->random(); + $codes[$i]['is_print'] = 0; + $codes[$i]['effective_at'] = now(); + $codes[$i]['created_at'] = now(); + $codes[$i]['updated_at'] = now(); + } + Cdkey::insert($codes); + } + + /** + * 产生随机字串,可用来自动生成密码 17010 + * @Author: + * @Date:2018-09-14T17:00:34+0800 + * @param integer $len [description] + * @return [type] [description] + */ + private function random($len = 10): string + { + $chars = 'ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz23456789'; + $chars = str_repeat($chars, 4); + $chars = str_shuffle($chars); + $str = substr($chars, 0, $len); + return $str; + } +} diff --git a/app/Models/Favorite.php b/app/Models/Favorite.php new file mode 100644 index 0000000..59be280 --- /dev/null +++ b/app/Models/Favorite.php @@ -0,0 +1,32 @@ +belongsTo(user::class)->withDefault(); + } + + public function item() + { + return $this->morphTo(); + } + + public function scopeMine($query) + { + return $query->where('user_id', Auth::id()); + } + + public static function isFavorite($item_id, $type) + { + $user_id = Auth::id(); + $item_type = "App\Models\\" . $type; + $num = Self::where('user_id', $user_id)->where('item_id', $item_id)->where('item_type', $item_type)->count() ?? 0; + return $num; + } +} diff --git a/app/Models/Freight.php b/app/Models/Freight.php new file mode 100644 index 0000000..a426f8f --- /dev/null +++ b/app/Models/Freight.php @@ -0,0 +1,23 @@ +belongsTo(Seller::class); + } + + public function area() + { + return $this->belongsTo(Area::class); + } +} diff --git a/app/Models/Goods.php b/app/Models/Goods.php new file mode 100644 index 0000000..89fcae6 --- /dev/null +++ b/app/Models/Goods.php @@ -0,0 +1,164 @@ +where('seller_id', Admin::user()->seller_id); + } + + public function seller() + { + return $this->belongsTo(Seller::class)->withDefault(); + } + + public function storage() + { + return $this->belongsTo(Storage::class)->withDefault(); + } + + public function banner() + { + return $this->belongsTo(Storage::class, 'banner_id', 'id')->withDefault(); + } + + public function category() + { + return $this->belongsTo(Category::class)->withDefault(); + } + + public function params() + { + return $this->hasMany(GoodsParams::class, 'goods_id', 'id'); + } + + public function getTitle() + { + return $this->title; + } + + public function getPrice() + { + return $this->price; + } + + public function getScore() + { + return $this->score; + } + + public function getStock() + { + return $this->stock; + } + + public function getSellerPrice() + { + return $this->cost; + } + + public function deductStock($stock) + { + $this->decrement('stock', $stock); + } + + public function addStock($stock) + { + $this->increment('stock', $stock); + } + + protected function getMinPriceAttribute() + { + return number_format($this->params()->where('status', 1)->min('price'), 2); + } + + protected function getMinOriginalAttribute() + { + return number_format($this->params()->where('status', 1)->min('original'), 2); + } + + protected function getMinBaoAttribute() + { + return number_format($this->params()->where('status', 1)->min('taobao'), 2); + } + + protected function getMaxScoreAttribute() + { + return number_format($this->params()->where('status', 1)->max('score'), 2); + } + + public function cashScore() + { + return $this->params()->where('status', 1)->where('stock', '>', 0)->where('status', 1)->where('score', '>', 0)->whereRaw('price > score')->orderBy('score', 'desc')->first(); + } + + protected function getScoreRangeAttribute() + { + $params = $this->params()->where('status', 1)->orderBy('score', 'desc')->distinct()->pluck('score'); + $params_size = count($params); + if ($params_size == 1) { + return number_format($params[0], 2); + } elseif ($params_size > 1) { + if ($params[$params_size - 1] > 0) { + return number_format($params[0], 2) . '~' . number_format($params[$params_size - 1], 2); + } else { + return number_format($params[0], 2); + } + } else { + return 0.00; + } + } + + protected function getStatusTextAttribute() + { + return $this->status == 1 ? "正常" : "已下架"; + } + + /** + * 是否可删除 + * @Author: + * @Date:2018-12-10 + * @return boolean + */ + + public function canDel(): bool + { + $orderDetails = OrderDetail::whereIn('item_id', $this->params()->pluck('id'))->where('item_type', 'App\Models\GoodsParams')->first(); + return $this->status == 1 && empty($orderDetails); + } + + /** + * 是否可下架 + * @Author: + * @Date:2018-12-10 + * @return boolean + */ + + public function canCancel(): bool + { + return $this->status == 1 ? true : false; + } + + public function isScore(): bool + { + $params = $this->params()->where('status', 1)->where('score', '>', '0')->get(); + return $params->count() > 0 ? true : false; + } +} diff --git a/app/Models/GoodsParamStock.php b/app/Models/GoodsParamStock.php new file mode 100644 index 0000000..daad5a6 --- /dev/null +++ b/app/Models/GoodsParamStock.php @@ -0,0 +1,35 @@ +belongsTo(Goods::class,'goods_id','id'); + } + + public function param() + { + return $this->belongsTo(GoodsParams::class,'goods_param_id','id'); + } + + protected function getRuleTextAttribute() + { + switch ($this->rule_sign) { + case 'SHELVE_MANAGER': + return '入库:初始化库存'; + case 'UNSHELVE_MANAGER': + return '出库:管理员删除商品'; + case 'MALL_GOODS': + return '出库:用户购买商品'; + case 'PLUS_MANAGER': + return '入库:管理员商品补仓'; + case 'MINUS_MANAGER': + return '出库:管理员出库商品'; + default: + return '未知情况'; + } + } + +} diff --git a/app/Models/GoodsParams.php b/app/Models/GoodsParams.php new file mode 100644 index 0000000..c7e3a1b --- /dev/null +++ b/app/Models/GoodsParams.php @@ -0,0 +1,96 @@ +paramStocks()->create( + [ + 'amount' => $model->stock, + 'goods_id' => $model->goods_id ?? 0, + 'rule_sign' => 'SHELVE_MANAGER', + ] + ); + }); + + self::updated(function ($model) { + $before_stock = $model->getOriginal('stock'); + $after_stock = $model->stock; + $change_stock = $after_stock - $before_stock; + if ($change_stock != 0) { + $rule = $change_stock > 0 ? 'PLUS_MANAGER' : 'MINUS_MANAGER'; + $model->paramStocks()->create( + [ + 'amount' => $change_stock, + 'goods_id' => $model->goods_id ?? 0, + 'rule_sign' => $rule, + ] + ); + } + }); + } + + public function goods() + { + return $this->belongsTo(Goods::class, 'goods_id', 'id'); + } + + public function getTitle() + { + return $this->goods->title . '-' . $this->value; + } + + public function getPrice() + { + return $this->price; + } + + public function getScore() + { + return $this->score; + } + + public function getStock() + { + return $this->stock; + } + + public function getSellerPrice() + { + return $this->cost; + } + + public function deductStock($stock) + { + $this->decrement('stock', $stock); + } + + public function addStock($stock) + { + $this->increment('stock', $stock); + } + + protected function getStorageAttribute() + { + return $this->goods->storage; + } + + public function paramStocks() + { + return $this->hasMany(GoodsParamStock::class, 'goods_param_id', 'id'); + } + + public function getStorage() + { + return $this->goods->storage; + } + +} diff --git a/app/Models/KeysApply.php b/app/Models/KeysApply.php new file mode 100644 index 0000000..ace674e --- /dev/null +++ b/app/Models/KeysApply.php @@ -0,0 +1,37 @@ +is_print) { + case 0: + return ''; + break; + case 1: + return ''; + break; + } + } + + protected function getStatusTextAttribute() + { + if ($this->status == 0) { + return '申请中'; + } elseif ($this->status == 1) { + return '已生成'; + } elseif ($this->status == 2) { + return '已驳回'; + } else { + return $this->status; + } + } + + public function user() + { + return $this->belongsTo(\App\User::class); + } +} diff --git a/app/Models/KeysOrder.php b/app/Models/KeysOrder.php new file mode 100644 index 0000000..fd186a5 --- /dev/null +++ b/app/Models/KeysOrder.php @@ -0,0 +1,39 @@ +state = 'INIT'; + $model->trade_no = 'K' . date('ymdHis') . sprintf("%07d", mt_rand(0, pow(10, 7) - 1)); + }); + } + + protected function getTypeTextAttribute() + { + if ($this->type == 'BALANCE') { + return '余额支付'; + } elseif ($this->type == 'WECHAT') { + return '微信支付'; + } else { + return $this->type; + } + } + + protected function getStateTextAttribute() + { + if ($this->state == 'SUCCESS') { + return '支付完成'; + } elseif ($this->state == 'INIT') { + return '待支付'; + } else { + return $this->state; + } + } +} diff --git a/app/Models/Lottery.php b/app/Models/Lottery.php new file mode 100644 index 0000000..8acae01 --- /dev/null +++ b/app/Models/Lottery.php @@ -0,0 +1,27 @@ +status == 1 ? "开启" : "关闭"; + } + + public function logs() + { + return $this->hasMany(LotteryLog::class); + } + + public function gifts() + { + return $this->hasMany(LotteryGift::class)->orderBy('level', 'asc'); + } + +} diff --git a/app/Models/LotteryGift.php b/app/Models/LotteryGift.php new file mode 100644 index 0000000..114b841 --- /dev/null +++ b/app/Models/LotteryGift.php @@ -0,0 +1,86 @@ + '一等奖', + '2' => '二等奖', + '3' => '三等奖', + '4' => '四等奖', + '5' => '五等奖', + '6' => '六等奖', + '7' => '七等奖', + '8' => '谢谢参与', + ]; + + static $chances = [ + '1' => 0, + '2' => 1, + '3' => 2, + '4' => 7, + '5' => 3, + '6' => 5, + '7' => 4, + '8' => 6, + ]; + + static $types = [ + '0' => '谢谢参与', + '1' => '正常奖品', + ]; + + static $class = [ + 'activity' => 'App\Models\Activity', + 'coupon' => 'RuLong\Coupon\Models\CouponInfo', + 'goods' => 'App\Models\GoodsParams', + ]; + + public function lottery() + { + return $this->belongsTo(Lottery::class)->withDefault(); + } + + public function item() + { + return $this->morphTo(); + } + + public function getLevelTextAttribute() + { + return self::$levels[$this->level] ?? '未知'; + } + + public function getTypeTextAttribute() + { + return self::$types[$this->type] ?? '未知'; + } + + public function getClassAttribute() + { + foreach (self::$class as $key => $class) { + if ($this->item_type == $class) { + return $key; + } + } + + return 'Null'; + } + + public function getChanceTextAttribute() + { + $all = $this->lottery->gifts()->sum('chance'); + return round($this->chance / $all * 100, 2); + } + + public function getTitle() + { + if ($this->item) { + return $this->item->getTitle(); + } else { + return '谢谢参与'; + } + } + +} diff --git a/app/Models/LotteryLog.php b/app/Models/LotteryLog.php new file mode 100644 index 0000000..2b83631 --- /dev/null +++ b/app/Models/LotteryLog.php @@ -0,0 +1,33 @@ +belongsTo(User::class)->withDefault(); + } + + public function lottery() + { + return $this->belongsTo(Lottery::class)->withDefault(); + } + + public function gift() + { + return $this->belongsTo(LotteryGift::class)->withDefault(); + } + + public function getOrderAttribute() + { + return Order::where('item_id', $this->id)->where('type', 'lottery')->first(); + } +} diff --git a/app/Models/Model.php b/app/Models/Model.php new file mode 100644 index 0000000..dc24989 --- /dev/null +++ b/app/Models/Model.php @@ -0,0 +1,12 @@ +hasOne(Storage::class, 'id', 'value')->withDefault(); + } +} diff --git a/app/Models/Payment.php b/app/Models/Payment.php new file mode 100644 index 0000000..20cca9a --- /dev/null +++ b/app/Models/Payment.php @@ -0,0 +1,46 @@ +state = 'INIT'; + $model->trade_no = 'T' . date('ymdHis') . sprintf("%07d", mt_rand(0, pow(10, 7) - 1)); + }); + } + + public function order() + { + return $this->belongsTo(Order::class); + } + + protected function getTypeTextAttribute() + { + if($this->type == 'BALANCE'){ + return '余额支付'; + }elseif($this->type == 'WECHAT'){ + return '微信支付'; + }else{ + return $this->type; + } + } + + protected function getStateTextAttribute() + { + if($this->state == 'SUCCESS'){ + return '支付完成'; + }elseif($this->state == 'INIT'){ + return '待支付'; + }else{ + return $this->state; + } + } +} diff --git a/app/Models/ProfitLog.php b/app/Models/ProfitLog.php new file mode 100644 index 0000000..65ba1f5 --- /dev/null +++ b/app/Models/ProfitLog.php @@ -0,0 +1,66 @@ +status) { + case 0: + return '尚未执行'; + break; + case 1: + return '已经执行'; + break; + } + } + + public function portion($id, $user_id = 0) + { + return IdentityPoint::where('identity_id', $id) + ->when($user_id, function ($q) use ($user_id) { + $q->where('user_id', $user_id); + }) + ->where('created_at', '<', $this->end_at)->sum('point'); + } + + public static function getnow() + { + $time = Carbon::today()->toDateTimeString(); + $info = self::where('created_at', $time)->first(); + if (!$info) { + $info = self::create([ + 'price' => 0, + 'created_at' => $time, + 'end_at' => Carbon::today()->addSecond(86399)->toDateTimeString(), + 'status' => 0, + ]); + } + return $info; + } + + public static function addPrfit($price = 0) + { + $time = Carbon::today()->toDateTimeString(); + $info = self::where('created_at', $time)->first(); + if ($info) { + $info->price += $price; + $info->save(); + } else { + self::create([ + 'price' => $price, + 'created_at' => $time, + 'end_at' => Carbon::today()->addSecond(86399)->toDateTimeString(), + 'status' => 0, + ]); + } + } +} diff --git a/app/Models/Report.php b/app/Models/Report.php new file mode 100644 index 0000000..1d46cf0 --- /dev/null +++ b/app/Models/Report.php @@ -0,0 +1,8 @@ +belongsTo(Seller::class)->withDefault(); + } +} diff --git a/app/Models/Seller.php b/app/Models/Seller.php new file mode 100644 index 0000000..6f57adb --- /dev/null +++ b/app/Models/Seller.php @@ -0,0 +1,224 @@ + 'array', + 'cert_ids' => 'array', + ]; + public static function boot() + { + parent::boot(); + + // self::created(function ($model) { + // $area_ids = Area::where('type', '省级')->pluck('id'); + // foreach ($area_ids as $area_id) { + // $model->freights()->create([ + // 'area_id' => $area_id, + // ]); + // } + // }); + + } + + public function admins() + { + return $this->hasMany(Admin::class); + } + + public function storage() + { + return $this->belongsTo(Storage::class)->withDefault(); + } + + public function agency() + { + return $this->belongsTo(Agency::class)->withDefault(['name' => '未设置']); + } + + //返回多图 + public function getStoragesAttribute() + { + $list = Storage::whereIn('id', $this->storage_ids)->get(); + return $list; + } + + //返回多图 资质 + public function getCertsAttribute() + { + $list = Storage::whereIn('id', $this->cert_ids)->get(); + return $list; + } + + //封面 + public function cover() + { + return $this->belongsTo(Storage::class, 'cover_id', 'id')->withDefault(); + } + + //微信二维码 + public function wechat() + { + return $this->belongsTo(Storage::class, 'wechat_id', 'id')->withDefault(); + } + + public function freights() + { + return $this->hasMany(Freight::class); + } + + public function getGoodsFirst() + { + $goods = Goods::where('seller_id', $this->id) + ->whereHas('params', function ($query) {return $query->where('stock', '>', 0)->where('status', 1);}) + ->where('status', 1) + ->orderBy('created_at', 'desc') + ->first(); + if ($goods) { + return $goods->storage->path ?? ''; + } else { + return ''; + } + + } + + public function goods() + { + return $this->hasMany(Goods::class); + } + + public function orders() + { + return $this->hasMany(Order::class); + } + + /** + * 是否可删除 + * @Author: + * @Date:2018-11-30 + * @return boolean + */ + + public function canDel(): bool + { + return $this->status == 1 && count($this->orders) == 0 && count($this->goods) == 0 ? true : false; + } + + /** + * 是否可关闭 + * @Author: + * @Date:2018-11-30 + * @return boolean + */ + + public function canCancel(): bool + { + return $this->status == 1 && $this->goods()->where('status', 1)->count() == 0 ? true : false; + } + + protected function getStatusTextAttribute() + { + return $this->status == 1 ? "正常" : "锁定"; + } + + protected function getTypeTextAttribute() + { + switch ($this->type) { + case 'organ': + return '机构'; + break; + case 'seller': + return '商家'; + break; + + default: + return '未知'; + break; + } + } + + public function user() + { + return $this->belongsTo(User::class); + } + + public function reports() + { + return $this->hasMany(WindupReport::class); + } + + protected function getAllAddressAttribute() + { + return str_replace(",", "-", $this->Area->info) . '-' . $this->address; + } + + public function Area() + { + return $this->belongsTo(OpenArea::class, 'area_sn', 'sn'); + } + + public function Province() + { + return $this->belongsTo(OpenArea::class, 'province_sn', 'sn'); + } + + public function category() + { + return $this->belongsTo(Category::class)->withDefault(); + } + + public function lesson() + { + return $this->hasMany(SellerLesson::class); + } + + public function getTitle() + { + return $this->name; + } + + public function salesman() + { + return $this->belongsTo(User::class, 'salesman_id', 'id')->withDefault(); + } + + //获取屏蔽分类id + public function getTopCateIdAttribute() + { + $cateids = $this->lesson()->pluck('category_id')->toArray(); + $parenids = []; + if ($cateids) { + foreach ($cateids as $key => $id) { + $parenids[] = Category::findTop($id, 1); + } + } else { + return []; + } + $findcateids = Category::whereIn('parent_id', $parenids)->OrwhereIn('id', $parenids)->pluck('id')->toArray(); + return $findcateids; + } + + //机构报课数 + public function getLessonLogsCountAttribute() + { + $lessons = $this->lesson()->with(['logs'])->get(); + return $lessons->sum('logs_count'); + } + +} diff --git a/app/Models/SellerLesson.php b/app/Models/SellerLesson.php new file mode 100644 index 0000000..9fcf256 --- /dev/null +++ b/app/Models/SellerLesson.php @@ -0,0 +1,136 @@ +belongsTo(Seller::class, 'seller_id', 'id')->withDefault(); + } + + public function storage() + { + return $this->belongsTo(Storage::class)->withDefault(); + } + + public function category() + { + return $this->belongsTo(Category::class)->withDefault(); + } + + protected function getStatusTextAttribute() + { + if ($this->status == 1) { + if ($this->start_at->timestamp > time()) { + return "还没开始"; + } elseif ($this->end_at->timestamp < time()) { + return "已经结束"; + } + return "正常"; + + } else { + return "关闭"; + } + } + + public function logs() + { + return $this->HasMany(SellerLessonLog::class, 'lesson_id', 'id'); + } + + public function getTitle() + { + return $this->title; + } + + public function getPrice() + { + return $this->price; + } + + public function getScore() + { + return 0; + } + + public function getStock() + { + return $this->stock; + } + + public function getSellerPrice() + { + return $this->price; + } + + public function deductStock($stock) + { + $this->decrement('stock', $stock); + } + + public function addStock($stock) + { + $this->increment('stock', $stock); + } + + public function getStorage() + { + return $this->storage; + } + + /** + * 可报名 + * @return boolean + */ + public function canCart(): bool + { + return Cart::where('user_id', Auth::id())->where('lesson_id', $this->id)->count(); + } + + protected function getCanCartTextAttribute() + { + return $this->canCart(); + } + + //是否已购买 + public function getBuyTextAttribute() + { + return $this->logs()->where('lesson_id', $this->id)->where('status', 1)->where('user_id', Auth::id())->count() ?? 0; + } + + //是否已购买 + public function getButtonTextAttribute() + { + if ($this->buy_text) { + return "学习中"; + } elseif ($this->canCart()) { + return "已报名"; + } else { + return "立即报名"; + } + } + + //是否已购买 + public function getButtonValueAttribute() + { + if ($this->buy_text) { + return 1; + } elseif ($this->canCart()) { + return 2; + } else { + return 0; + } + } + +} diff --git a/app/Models/SellerLessonLog.php b/app/Models/SellerLessonLog.php new file mode 100644 index 0000000..81d22d3 --- /dev/null +++ b/app/Models/SellerLessonLog.php @@ -0,0 +1,25 @@ +belongsTo(SellerLesson::class)->withDefault(); + } + + public function user() + { + return $this->belongsTo(User::class)->withDefault(); + } + + public function order() + { + return $this->belongsTo(Order::class)->withDefault(); + } +} diff --git a/app/Models/SellerTeacher.php b/app/Models/SellerTeacher.php new file mode 100644 index 0000000..f880340 --- /dev/null +++ b/app/Models/SellerTeacher.php @@ -0,0 +1,20 @@ +belongsto(Seller::class); + } + + public function storage() + { + return $this->belongsTo(Storage::class)->withDefault(); + + } +} diff --git a/app/Models/Station.php b/app/Models/Station.php new file mode 100644 index 0000000..8286878 --- /dev/null +++ b/app/Models/Station.php @@ -0,0 +1,50 @@ +name; + + } + + /** + * 配送网点电话 + * @return string + */ + public function getMobile(){ + return $this->mobile; + + } + + /** + * 配送网点地址 + * @return string + */ + public function getAddress(){ + return $this->address; + + } + + + public function seller() + { + return $this->belongsTo(Seller::class); + } + +} + diff --git a/app/Models/Team.php b/app/Models/Team.php new file mode 100644 index 0000000..4a99c1f --- /dev/null +++ b/app/Models/Team.php @@ -0,0 +1,20 @@ +belongsTo(User::class)->withDefault(); + } + + protected function getTypeTextAttribute() + { + return $this->status == 'alliance' ? "联盟" : "代理"; + } + +} diff --git a/app/Models/Test.php b/app/Models/Test.php new file mode 100644 index 0000000..4375a5b --- /dev/null +++ b/app/Models/Test.php @@ -0,0 +1,8 @@ +belongsTo(User::class); + } +} diff --git a/app/Models/UserLogin.php b/app/Models/UserLogin.php new file mode 100644 index 0000000..6034d91 --- /dev/null +++ b/app/Models/UserLogin.php @@ -0,0 +1,19 @@ +belongsTo(User::class); + } +} diff --git a/app/Models/VipPament.php b/app/Models/VipPament.php new file mode 100644 index 0000000..8640bdf --- /dev/null +++ b/app/Models/VipPament.php @@ -0,0 +1,40 @@ +state) { + $model->state = 'INIT'; + } + $model->trade_no = 'T' . date('ymdHis') . sprintf("%07d", mt_rand(0, pow(10, 7) - 1)); + }); + } + + public function getPayTypeAttribute() + { + switch ($this->type) { + case 'WECHAT': + return '微信支付'; + break; + case 'CDKEY': + return '激活码'; + break; + default: + return '无'; + break; + } + } + + public function user() + { + return $this->belongsTo(User::class); + } +} diff --git a/app/Models/WechatMenu.php b/app/Models/WechatMenu.php new file mode 100644 index 0000000..38251f3 --- /dev/null +++ b/app/Models/WechatMenu.php @@ -0,0 +1,75 @@ +hasMany(WechatMenu::class, 'parent_id')->orderBy('sort', 'asc'); + } + + public function parent() + { + return $this->belongsTo(WechatMenu::class)->withDefault(); + } + + public static function getPublishArray() + { + $buttons = []; + + $menus = self::where('parent_id', 0)->orderBy('sort', 'asc')->get(); + + foreach ($menus as $key => $menu) { + $button['name'] = $menu->name; + if ($menu->children->isEmpty()) { + $button = array_merge($button, $menu->type_value); + } else { + foreach ($menu->children as $k => $child) { + $subButton['name'] = $child->name; + $subButton = array_merge($subButton, $child->type_value); + $button['sub_button'][$k] = $subButton; + $subButton = []; + } + } + $buttons[] = $button; + $button = []; + } + + return $buttons; + } + + public function getTypeValueAttribute() + { + switch ($this->type) { + case 'click': + return [ + 'type' => $this->type, + 'key' => $this->value, + ]; + break; + case 'view': + return [ + 'type' => $this->type, + 'url' => $this->value, + ]; + break; + case 'miniprogram': + return [ + 'type' => $this->type, + 'url' => explode($this->value)[0], + 'appid' => explode($this->value)[1], + 'pagepath' => explode($this->value)[2], + ]; + break; + default: + return [ + 'type' => 'view', + 'url' => $this->value, + ]; + break; + } + + } +} diff --git a/app/Models/WechatRule.php b/app/Models/WechatRule.php new file mode 100644 index 0000000..8bea466 --- /dev/null +++ b/app/Models/WechatRule.php @@ -0,0 +1,18 @@ +belongsTo(Storage::class)->withDefault(); + } + +} diff --git a/app/Models/Windup.php b/app/Models/Windup.php new file mode 100644 index 0000000..c1356c3 --- /dev/null +++ b/app/Models/Windup.php @@ -0,0 +1,18 @@ +hasMany(Order::class); + } + + public function seller() + { + return $this->belongsTo(Seller::class); + } +} diff --git a/app/Models/WindupReport.php b/app/Models/WindupReport.php new file mode 100644 index 0000000..c2b2ba1 --- /dev/null +++ b/app/Models/WindupReport.php @@ -0,0 +1,68 @@ +hasMany(Order::class); + } + + public function seller() + { + return $this->belongsTo(Seller::class); + } + + public function autoReport() + { + + $today_arr = explode('-', Carbon::today()->toDateString()); + if ($today_arr[2] > 15) { + //本月1=15 + $start = date("Y-m-d H:i:s", mktime(0, 0, 0, date("m"), 1, date("Y"))); + $end = date("Y-m-d H:i:s", mktime(23, 59, 59, date("m"), 15, date("Y"))); + } else { + $start = date('Y-m-16 00:00:00', strtotime('-1 month')); + $end = date("Y-m-d 23:59:59", strtotime(-date('d') . 'day')); + } + $sellerids = Seller::get(); + foreach ($sellerids as $key => $seller) { + $seller_id = $seller->id; + $orderids = Order::where('seller_id', $seller_id) + ->whereHas('logs', function ($query) use ($start, $end) { + $query->where('state', 'DELIVERED|SIGNED')->when($start && $end, function ($query) use ($start, $end) { + $query->whereBetween('created_at', [$start, $end]); + }); + }) + ->where('state', '<>',Order::ORDER_CLOSED) + ->pluck('id'); + $windup = Order::select(DB::raw('count(*) as orders_count, sum(freight) as freight_sum, sum(seller_freight) as seller_freight_sum, sum(amount) as amount_sum, sum(score) as score_sum,sum(seller_amount) as seller_amount_sum')) + ->whereIn('id', $orderids)->first(); + + $report = WindupReport::where(['seller_id' => $seller_id, 'start_time' => $start, 'end_time' => $end])->first(); + if ($orderids->count()>0 && empty($report)) { + DB::transaction(function () use ($seller_id, $start, $end, $windup, $orderids) { + $windup_report = WindupReport::create([ + 'seller_id' => $seller_id, + 'start_time' => $start, + 'end_time' => $end, + 'orders_count' => $windup->orders_count ?? 0, + 'freight_sum' => $windup->freight_sum ?? 0, + 'amount_sum' => $windup->amount_sum ?? 0, + 'score_sum' => $windup->score_sum ?? 0, + 'seller_freight_sum' => $windup->seller_freight_sum ?? 0, + 'seller_amount_sum' => $windup->seller_amount_sum ?? 0, + 'orderids' => $orderids + ]); + + Order::whereIn('id', $orderids)->update(['windup_report_id' => $windup_report->id]); + }); + } + } + } +} diff --git a/app/Models/Withdraw.php b/app/Models/Withdraw.php new file mode 100644 index 0000000..7d3d241 --- /dev/null +++ b/app/Models/Withdraw.php @@ -0,0 +1,42 @@ +belongsTo(User::class); + } + + protected function getStateTextAttribute() + { + if ($this->state == 0) { + return '待审核'; + } else if ($this->state == -1) { + return '提现失败'; + } elseif ($this->state == 1) { + return '成功'; + } elseif ($this->state == 2) { + return '驳回'; + } + } + + protected function getTypeTextAttribute() + { + switch ($this->type) { + case 'Alipay': + return '支付宝'; + break; + case 'Wechat': + return '微信零钱'; + break; + + default: + return '未知'; + break; + } + } +} diff --git a/app/Notifications/AccountChanged.php b/app/Notifications/AccountChanged.php new file mode 100644 index 0000000..1be13d2 --- /dev/null +++ b/app/Notifications/AccountChanged.php @@ -0,0 +1,48 @@ +log = $log; + } + + public function toWechat($notifiable) + { + $app = app('wechat.official_account'); + $variable = number_format($this->log->variable ?? '', 2); + if ($variable > 0) { + $variable = '+' . $variable; + } + if ($notifiable->openid) { + $data = ['cash' => '现金账户', 'score' => '可提现账户']; + $str = '亲爱的' . $notifiable->info->nickname . ',您的余额发生变动,内容如下:' . "\r\n\r\n"; + $str .= '变动账户:' . $data[$this->log->type] . "\r\n"; + $str .= '变动金额:' . $variable . "\r\n"; + $str .= '变动内容:' . $this->log->rule->title . "\r\n"; + $str .= '变动时间:' . $this->log->created_at->format('Y-m-d H:i:s') . "\r\n\r\n"; + + $app->customer_service->message($str)->to($notifiable->openid)->send(); + } + + } + + public function toArray($notifiable) + { + return [ + + ]; + } +} diff --git a/app/Notifications/BaseNotification.php b/app/Notifications/BaseNotification.php new file mode 100644 index 0000000..7b26660 --- /dev/null +++ b/app/Notifications/BaseNotification.php @@ -0,0 +1,65 @@ + + * @Date:2018-11-05T11:43:53+0800 + * @return [type] [description] + */ + abstract public static function title(); + + /** + * 通知默认发送通道 + * @Author: + * @Date:2018-11-05T11:44:03+0800 + * @param App\User $notifiable 通知对象 + * @return array + */ + public function via($notifiable) + { + return ['database', WeChatChannel::class]; + } + + /** + * 格式化至数据库 + * @Author: + * @Date:2018-11-05T11:44:51+0800 + * @param App\User $notifiable 通知对象 + */ + abstract public function toArray($notifiable); + + /** + * 通知到微信的实际方法 + * @Author: + * @Date:2018-11-12T16:35:44+0800 + * @param App\User $notifiable 通知对象 + */ + abstract public function toWechat($notifiable); +} diff --git a/app/Notifications/OrderCreatedNotify.php b/app/Notifications/OrderCreatedNotify.php new file mode 100644 index 0000000..b9ded1c --- /dev/null +++ b/app/Notifications/OrderCreatedNotify.php @@ -0,0 +1,63 @@ +order = $order; + } + + public function toWechat($notifiable) + { + // $det = ''; + // foreach ($this->order->details as $detail) { + // $det .= $detail->item->getTitle() . '*' . $detail->number . '/'; + // } + // $det = rtrim($det, '/'); + + // $app = app('wechat.official_account'); + // if($notifiable->openid){ + // $app->template_message->send([ + // 'touser' => $notifiable->openid, + // 'template_id' => $this->TPL, + // 'url' => route('orders.show',$this->order->orderid), + // 'data' => [ + // 'first' => [ + // 'value' => '恭喜您达到满仓资格,获得满仓奖励一份,您在“待付款”订单中支付满仓赠品的运费后,即可成功领取满仓奖励', + // 'color' => '#FF0000', + // ], + // 'keyword1' =>$this->order->created_at, + // 'keyword2' => $this->order->orderid,//订单编号 + // 'keyword3' => $det,//商品名称 + // 'keyword4' => number_format($this->order->total - $this->order->score,2), + // ], + + // ]); + + // } + } + + public function toArray($notifiable) + { + return [ + // + ]; + } +} diff --git a/app/Notifications/OrderDelivered.php b/app/Notifications/OrderDelivered.php new file mode 100644 index 0000000..f492858 --- /dev/null +++ b/app/Notifications/OrderDelivered.php @@ -0,0 +1,49 @@ +order = $order; + } + + public function toWechat($notifiable) + { + + $app = app('wechat.official_account'); + if ($notifiable->openid) { + $str = '您的订单已经成功发货!!' . "\r\n\r\n"; + $str .= '订单号:' . $this->order->orderid . "\r\n"; + $str .= '商品名称:' . $this->order->detail->item->goods->title . "\r\n"; + $str .= '商品数量:' . $this->order->details()->sum('number') . "\r\n"; + $str .= '快递公司:' . $this->order->express->company ?? '' . "\r\n"; + $str .= '快递单号:' . $this->order->express->number ?? '' . "\r\n"; + $str .= "order->orderid) . "'>点击查看详情"; + + $app->customer_service->message($str)->to($notifiable->openid)->send(); + } + } + + public function toArray($notifiable) + { + return [ + // + ]; + } +} diff --git a/app/Notifications/OrderPaied.php b/app/Notifications/OrderPaied.php new file mode 100644 index 0000000..64d0768 --- /dev/null +++ b/app/Notifications/OrderPaied.php @@ -0,0 +1,68 @@ +order = $order; + } + + public function toWechat($notifiable) + { + $app = app('wechat.official_account'); + if ($notifiable->openid && $this->order->item_type == 'GIFT') { + $type_text = ''; + $url = route('orders.show', $this->order->orderid); + switch ($this->order->type) { + case 'lottery': + $type_text = '奖品'; + $url = route('lottery.logs'); + break; + case 'lesson': + $type_text = '赠品'; + $url = route('gifts.index'); + + break; + default: + $type_text = ($this->order->payment) ? $this->order->payment->type_text : ''; + break; + } + + if (in_array($this->order->type, ['lottery', 'lesson'])) { + $str = '您获得一份礼品,请设置收货地址,我们将尽快为您安排发货' . "\r\n\r\n"; + } else { + $str = '您的订单已经支付成功,我们将尽快为您安排发货!!' . "\r\n\r\n"; + } + + $str .= '订单号:' . $this->order->orderid . "\r\n"; + $str .= '下单时间:' . $this->order->created_at->format('Y-m-d H:i:s') . "\r\n"; + $str .= '订单金额:' . number_format($this->order->amount, 2) . "\r\n"; + $str .= '支付途径:' . $type_text . "\r\n\r\n"; + $str .= "点击查看详情"; + + $app->customer_service->message($str)->to($notifiable->openid)->send(); + } + } + + public function toArray($notifiable) + { + return [ + // + ]; + } +} diff --git a/app/Notifications/OrderSigned.php b/app/Notifications/OrderSigned.php new file mode 100644 index 0000000..25e4ee0 --- /dev/null +++ b/app/Notifications/OrderSigned.php @@ -0,0 +1,47 @@ +order = $order; + } + + public function toWechat($notifiable) + { + $app = app('wechat.official_account'); + if ($notifiable->openid) { + $str = '您好,您的订单由于主动签收或超过15天系统自动签收!!' . "\r\n\r\n"; + $str .= '订单号:' . $this->order->orderid . "\r\n"; + $str .= '下单时间:' . $this->order->created_at->format('Y-m-d H:i:s') . "\r\n"; + $str .= '订单金额:' . number_format($this->order->amount, 2) . "\r\n"; + $str .= '签收时间:' . date('Y-m-d H:i:s', time()) . "\r\n"; + $str .= "order->orderid) . "'>点击查看详情"; + + $app->customer_service->message($str)->to($notifiable->openid)->send(); + } + } + + public function toArray($notifiable) + { + return [ + // + ]; + } +} diff --git a/app/Notifications/Registered.php b/app/Notifications/Registered.php new file mode 100644 index 0000000..f823b9c --- /dev/null +++ b/app/Notifications/Registered.php @@ -0,0 +1,44 @@ +user = $user; + } + + public function toWechat($notifiable) + { + $app = app('wechat.official_account'); + if ($notifiable->openid) { + $str = '恭喜您新增一位课粉' . "\r\n\r\n"; + $str .= '昵称:' . $this->user->info->nickname . "\r\n"; + $str .= '新增时间:' . $this->user->created_at->format('Y-m-d H:i:s') . "\r\n"; + + $app->customer_service->message($str)->to($notifiable->openid)->send(); + } + + } + + public function toArray($notifiable) + { + return [ + // 'user_id' => $this->user->id, + // 'nickname' => $this->user->info->nickname, + ]; + } +} diff --git a/app/Notifications/WithdrawCompleted.php b/app/Notifications/WithdrawCompleted.php new file mode 100644 index 0000000..16fdde6 --- /dev/null +++ b/app/Notifications/WithdrawCompleted.php @@ -0,0 +1,44 @@ +withdraw = $withdraw; + } + + public function toWechat($notifiable) + { + $app = app('wechat.official_account'); + if ($notifiable->openid) { + $str = '恭喜您已经成功提现,请检查您的账户余额!!' . "\r\n\r\n"; + $str .= '提现金额:' . number_format($this->withdraw->amount, 2) . "\r\n"; + $str .= '实际到账金额:' . number_format($this->withdraw->take, 2) . "\r\n\r\n"; + $str .= "点击查看详情"; + $app->customer_service->message($str)->to($notifiable->openid)->send(); + } + } + + public function toArray($notifiable) + { + return [ + // + ]; + } +} diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php new file mode 100644 index 0000000..c83be4a --- /dev/null +++ b/app/Providers/AppServiceProvider.php @@ -0,0 +1,53 @@ +bindings as $i => $binding) { + // if ($binding instanceof \DateTime) { + // $sql->bindings[$i] = $binding->format('\'Y-m-d H:i:s\''); + // } else { + // if (is_string($binding)) { + // $sql->bindings[$i] = "'$binding'"; + // } + // } + // } + + // // Insert bindings into query + // $query = str_replace(array('%', '?'), array('%%', '%s'), $sql->sql); + + // $query = vsprintf($query, $sql->bindings); + + // // Save the query to file + // $logFile = fopen( + // storage_path('logs' . DIRECTORY_SEPARATOR . date('Y-m-d') . '_query.log'), + // 'a+' + // ); + // fwrite($logFile, date('Y-m-d H:i:s') . ': ' . $query . PHP_EOL); + // fclose($logFile); + // } + // ); + } + + /** + * Register any application services. + * + * @return void + */ + public function register() + { + // + } +} diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php new file mode 100644 index 0000000..9784b1a --- /dev/null +++ b/app/Providers/AuthServiceProvider.php @@ -0,0 +1,30 @@ + 'App\Policies\ModelPolicy', + ]; + + /** + * Register any authentication / authorization services. + * + * @return void + */ + public function boot() + { + $this->registerPolicies(); + + // + } +} diff --git a/app/Providers/BroadcastServiceProvider.php b/app/Providers/BroadcastServiceProvider.php new file mode 100644 index 0000000..352cce4 --- /dev/null +++ b/app/Providers/BroadcastServiceProvider.php @@ -0,0 +1,21 @@ + [ + 'App\Listeners\LogRegisteredUser', + ], + // 用户登录成功,事件处理 + 'Illuminate\Auth\Events\Login' => [ + 'App\Listeners\LogSuccessfulLogin', + ], + + //订单创建完成,事件处理 + 'RuLong\Order\Events\OrderCreated' => [ + 'App\Listeners\OrderCreatedListener', + ], + + //订单关闭完成,事件处理 + 'RuLong\Order\Events\OrderClosed' => [ + 'App\Listeners\OrderClosedListener', + ], + + //订单支付完成,事件处理 + 'RuLong\Order\Events\OrderPaid' => [ + 'App\Listeners\OrderPaidListener', + ], + + //订单发货完成,事件处理 + 'RuLong\Order\Events\OrderDelivered' => [ + 'App\Listeners\OrderDeliveredListener', + ], + + //订单签收完成,事件处理 + 'RuLong\Order\Events\OrderSignined' => [ + 'App\Listeners\OrderSigninedListener', + ], + + //账户变动,事件处理 + 'RuLong\UserAccount\Events\AccountRuleExecuted' => [ + 'App\Listeners\AccountRuleExecutedListener', + ], + + //抽奖成功事件 + 'App\Events\Lottery' => [ + 'App\Listeners\LotterySuccessListener', + ], + + //提现审核完成事件 + 'App\Events\WithdrawCompleted' => [ + 'App\Listeners\WithdrawListener', + ], + + ]; + + /** + * Register any events for your application. + * @return void + */ + public function boot() + { + parent::boot(); + } +} diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php new file mode 100644 index 0000000..5ea48d3 --- /dev/null +++ b/app/Providers/RouteServiceProvider.php @@ -0,0 +1,73 @@ +mapApiRoutes(); + + $this->mapWebRoutes(); + + // + } + + /** + * Define the "web" routes for the application. + * + * These routes all receive session state, CSRF protection, etc. + * + * @return void + */ + protected function mapWebRoutes() + { + Route::middleware('web') + ->namespace($this->namespace) + ->group(base_path('routes/web.php')); + } + + /** + * Define the "api" routes for the application. + * + * These routes are typically stateless. + * + * @return void + */ + protected function mapApiRoutes() + { + Route::prefix('api') + ->middleware('api') + ->namespace($this->namespace) + ->group(base_path('routes/api.php')); + } +} diff --git a/app/Rules/Checkmobile.php b/app/Rules/Checkmobile.php new file mode 100644 index 0000000..c51f90c --- /dev/null +++ b/app/Rules/Checkmobile.php @@ -0,0 +1,44 @@ +info) && !empty($model->info)) { + $model->info()->updateOrCreate(['user_id' => $model->id], $model->info); + } + }); + } + + /** + * Get the identifier that will be stored in the subject claim of the JWT. + * @return mixed + */ + public function getJWTIdentifier() + { + return $this->getKey(); + } + + /** + * Return a key value array, containing any custom claims to be added to the JWT. + * @return array + */ + public function getJWTCustomClaims() + { + return []; + } + + /** + * 管理的商户/或者组织 + * @Author: + * @Date:2018-12-10T15:30:46+0800 + * @return [type] [description] + */ + public function seller() + { + return $this->hasOne(Seller::class); + } + + /** + * 是否是代理 + * @Author: + * @Date:2018-12-10T15:30:46+0800 + * @return [type] [description] + */ + public function agency() + { + return $this->hasOne(Agency::class); + } + + /** + *所属组织 + * @Author: + * @Date:2018-12-10T15:30:46+0800 + * @return [type] [description] + */ + public function organ() + { + return $this->belongsTo(Seller::class, 'seller_id', 'id')->where('type', 'organ')->withDefault(); + } + + /** + * 修改用户资料 + * @Author: + * @Date:2018-11-07T13:30:14+0800 + * @param array $info UserInfo fields + */ + protected function setInfoAttribute($info) + { + $this->info = $info; + } + + /** + * 修改密码,留空则不修改 + * @Author: + * @Date:2018-10-31T15:04:59+0800 + * @param void + */ + protected function setPasswordAttribute($password) + { + if ($password) { + $this->attributes['password'] = bcrypt($password); + } + } + + /** + * 修改支付密码,留空则不修改 + * @Author: + * @Date:2018-10-31T15:04:59+0800 + * @param void + */ + protected function setPayPassAttribute($password) + { + if ($password) { + $this->attributes['paypass'] = md5($password); + } + } + + public function info() + { + return $this->hasOne(UserInfo::class)->withDefault(); + } + + public function logins() + { + return $this->hasMany(UserLogin::class); + } + + public function lastLogin() + { + return $this->hasOne(UserLogin::class)->orderBy('id', 'desc')->withDefault(); + } + + /** + * 是否已经领取了会员赠品 + * @Author: + * @Date:2018-12-26T13:17:44+0800 + * @return [type] [description] + */ + public function getGiftOrderAttribute() + { + $vipOrder = Order::where('user_id', $this->id)->where('item_type', 'VIP_GIFT')->whereIn('state', ['PAID', 'DELIVER', 'DELIVERED', 'SIGNED', 'COMPLETED'])->count(); + return $vipOrder; + } + + /** + * 以生成的激活码数量 + * @Author: + * @Date:2018-12-27T12:06:25+0800 + * @return [type] [description] + */ + public function keys() + { + return $this->hasMany(Cdkey::class, 'belong_uid', 'id'); + } + + /** + * 总裁申请的数量 + * @Author: + * @Date:2018-12-27T12:06:25+0800 + * @return [type] [description] + */ + public function keyapplies() + { + return $this->hasMany(KeysApply::class); + } + + //报名数量 + public function getCartNumAttribute() + { + return Cart::where('user_id', $this->id)->count() ?? 0; + } + + //是否是业务员 + public function getSalesmanTextAttribute() + { + return $this->is_salesman == 1 ? '是' : '否'; + } + + public function cart() + { + return $this->hasMany(Cart::class); + } + + public function couponlog() + { + return $this->hasMany(CouponUserLog::class); + } + + //关联课程收藏 + public function lessonFavorite() + { + return $this->hasMany(Favorite::class)->where('item_type', 'App\Models\SellerLesson'); + } + + //关联机构收藏 + public function sellerFavorite() + { + return $this->hasMany(Favorite::class)->where('item_type', 'App\Models\Seller'); + } + + //关联机构收藏 + public function activityFavorite() + { + return $this->hasMany(Favorite::class)->where('item_type', 'App\Models\Activity'); + } + + //报名数量 + public function getFavoriteNumAttribute() + { + return ($this->lessonFavorite()->count() + $this->sellerFavorite()->count() + $this->activityFavorite()->count()) ?? 0; + } + + public function babys() + { + return $this->hasOne(UserBaby::class, 'user_id'); + } + +} diff --git a/app/清理历史数据脚本.sql b/app/清理历史数据脚本.sql new file mode 100644 index 0000000..b360a8f --- /dev/null +++ b/app/清理历史数据脚本.sql @@ -0,0 +1,43 @@ +TRUNCATE table `admin_logins`; +TRUNCATE table `admin_operation_logs`; + +TRUNCATE table `jobs`; +TRUNCATE table `sms`; +TRUNCATE table `notifications`; +TRUNCATE table `followables`; + +TRUNCATE table `carts`; +TRUNCATE table `payments`; +TRUNCATE table `orders`; +TRUNCATE table `order_details`; +TRUNCATE table `order_expresses`; +TRUNCATE table `order_logs`; +TRUNCATE table `order_expresses`; +TRUNCATE table `windups`; + +TRUNCATE table `users`; +TRUNCATE table `user_accounts`; +TRUNCATE table `user_account_logs`; +TRUNCATE table `user_addresses`; +TRUNCATE table `user_identities`; +TRUNCATE table `user_infos`; +TRUNCATE table `user_logins`; +TRUNCATE table `user_relations`; +TRUNCATE table `vip_paments`; +TRUNCATE table `withdraws`; +TRUNCATE table `identity_logs`; +TRUNCATE table `profit_logs`; +TRUNCATE table `bonus_logs`; + +TRUNCATE `activity_logs`; +TRUNCATE `coupon_logs`; +TRUNCATE `coupon_user_logs`; +TRUNCATE `coupon_uses`; +TRUNCATE `failed_jobs`; +TRUNCATE `lottery_logs`; +TRUNCATE `order_refunds`; +TRUNCATE `order_refund_expresses`; +TRUNCATE `order_refund_items`; +TRUNCATE `seller_lesson_logs`; + + diff --git a/bootstrap/app.php b/bootstrap/app.php new file mode 100644 index 0000000..f2801ad --- /dev/null +++ b/bootstrap/app.php @@ -0,0 +1,55 @@ +singleton( + Illuminate\Contracts\Http\Kernel::class, + App\Http\Kernel::class +); + +$app->singleton( + Illuminate\Contracts\Console\Kernel::class, + App\Console\Kernel::class +); + +$app->singleton( + Illuminate\Contracts\Debug\ExceptionHandler::class, + App\Exceptions\Handler::class +); + +/* +|-------------------------------------------------------------------------- +| Return The Application +|-------------------------------------------------------------------------- +| +| This script returns the application instance. The instance is given to +| the calling script so we can separate the building of the instances +| from the actual running of the application and sending responses. +| +*/ + +return $app; diff --git a/bootstrap/cache/packages.php b/bootstrap/cache/packages.php new file mode 100644 index 0000000..2e28e0b --- /dev/null +++ b/bootstrap/cache/packages.php @@ -0,0 +1,191 @@ + + array ( + 'providers' => + array ( + 0 => 'Barryvdh\\Debugbar\\ServiceProvider', + ), + 'aliases' => + array ( + 'Debugbar' => 'Barryvdh\\Debugbar\\Facade', + ), + ), + 'beyondcode/laravel-dump-server' => + array ( + 'providers' => + array ( + 0 => 'BeyondCode\\DumpServer\\DumpServerServiceProvider', + ), + ), + 'fideloper/proxy' => + array ( + 'providers' => + array ( + 0 => 'Fideloper\\Proxy\\TrustedProxyServiceProvider', + ), + ), + 'intervention/image' => + array ( + 'providers' => + array ( + 0 => 'Intervention\\Image\\ImageServiceProvider', + ), + 'aliases' => + array ( + 'Image' => 'Intervention\\Image\\Facades\\Image', + ), + ), + 'jacobcyl/ali-oss-storage' => + array ( + 'providers' => + array ( + 0 => 'Jacobcyl\\AliOSS\\AliOssServiceProvider', + ), + ), + 'laravel/tinker' => + array ( + 'providers' => + array ( + 0 => 'Laravel\\Tinker\\TinkerServiceProvider', + ), + ), + 'mews/captcha' => + array ( + 'providers' => + array ( + 0 => 'Mews\\Captcha\\CaptchaServiceProvider', + ), + 'aliases' => + array ( + 'Captcha' => 'Mews\\Captcha\\Facades\\Captcha', + ), + ), + 'nesbot/carbon' => + array ( + 'providers' => + array ( + 0 => 'Carbon\\Laravel\\ServiceProvider', + ), + ), + 'nunomaduro/collision' => + array ( + 'providers' => + array ( + 0 => 'NunoMaduro\\Collision\\Adapters\\Laravel\\CollisionServiceProvider', + ), + ), + 'overtrue/laravel-follow' => + array ( + 'providers' => + array ( + 0 => 'Overtrue\\LaravelFollow\\FollowServiceProvider', + ), + ), + 'overtrue/laravel-wechat' => + array ( + 'providers' => + array ( + 0 => 'Overtrue\\LaravelWeChat\\ServiceProvider', + ), + 'aliases' => + array ( + 'EasyWeChat' => 'Overtrue\\LaravelWeChat\\Facade', + ), + ), + 'rulong/areas' => + array ( + 'providers' => + array ( + 0 => 'RuLong\\Area\\ServiceProvider', + ), + 'aliases' => + array ( + 'Address' => 'RuLong\\Area\\Facades\\Address', + 'Area' => 'RuLong\\Area\\Facades\\Area', + ), + ), + 'rulong/dwz-panel' => + array ( + 'providers' => + array ( + 0 => 'RuLong\\Panel\\ServiceProvider', + ), + 'aliases' => + array ( + 'Admin' => 'RuLong\\Panel\\Facades\\Admin', + ), + ), + 'rulong/order' => + array ( + 'providers' => + array ( + 0 => 'RuLong\\Order\\ServiceProvider', + ), + 'aliases' => + array ( + 'Orders' => 'RuLong\\Order\\Facades\\Orders', + 'Refunds' => 'RuLong\\Order\\Facades\\Refunds', + ), + ), + 'rulong/sms' => + array ( + 'providers' => + array ( + 0 => 'RuLong\\Sms\\ServiceProvider', + ), + 'aliases' => + array ( + 'Sms' => 'RuLong\\Sms\\Facades\\Sms', + ), + ), + 'rulong/user-account' => + array ( + 'providers' => + array ( + 0 => 'RuLong\\UserAccount\\ServiceProvider', + ), + 'aliases' => + array ( + 'Account' => 'RuLong\\UserAccount\\Facades\\Account', + 'AccountRule' => 'RuLong\\UserAccount\\Facades\\AccountRule', + ), + ), + 'rulong/user-relation' => + array ( + 'providers' => + array ( + 0 => 'RuLong\\UserRelation\\ServiceProvider', + ), + ), + 'simplesoftwareio/simple-qrcode' => + array ( + 'providers' => + array ( + 0 => 'SimpleSoftwareIO\\QrCode\\QrCodeServiceProvider', + ), + 'aliases' => + array ( + 'QrCode' => 'SimpleSoftwareIO\\QrCode\\Facades\\QrCode', + ), + ), + 'tymon/jwt-auth' => + array ( + 'aliases' => + array ( + 'JWTAuth' => 'Tymon\\JWTAuth\\Facades\\JWTAuth', + 'JWTFactory' => 'Tymon\\JWTAuth\\Facades\\JWTFactory', + ), + 'providers' => + array ( + 0 => 'Tymon\\JWTAuth\\Providers\\LaravelServiceProvider', + ), + ), + 'xethron/migrations-generator' => + array ( + 'providers' => + array ( + 0 => 'Way\\Generators\\GeneratorsServiceProvider', + 1 => 'Xethron\\MigrationsGenerator\\MigrationsGeneratorServiceProvider', + ), + ), +); \ No newline at end of file diff --git a/bootstrap/cache/services.php b/bootstrap/cache/services.php new file mode 100644 index 0000000..abd43d3 --- /dev/null +++ b/bootstrap/cache/services.php @@ -0,0 +1,251 @@ + + array ( + 0 => 'Illuminate\\Auth\\AuthServiceProvider', + 1 => 'Illuminate\\Broadcasting\\BroadcastServiceProvider', + 2 => 'Illuminate\\Bus\\BusServiceProvider', + 3 => 'Illuminate\\Cache\\CacheServiceProvider', + 4 => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 5 => 'Illuminate\\Cookie\\CookieServiceProvider', + 6 => 'Illuminate\\Database\\DatabaseServiceProvider', + 7 => 'Illuminate\\Encryption\\EncryptionServiceProvider', + 8 => 'Illuminate\\Filesystem\\FilesystemServiceProvider', + 9 => 'Illuminate\\Foundation\\Providers\\FoundationServiceProvider', + 10 => 'Illuminate\\Hashing\\HashServiceProvider', + 11 => 'Illuminate\\Mail\\MailServiceProvider', + 12 => 'Illuminate\\Notifications\\NotificationServiceProvider', + 13 => 'Illuminate\\Pagination\\PaginationServiceProvider', + 14 => 'Illuminate\\Pipeline\\PipelineServiceProvider', + 15 => 'Illuminate\\Queue\\QueueServiceProvider', + 16 => 'Illuminate\\Redis\\RedisServiceProvider', + 17 => 'Illuminate\\Auth\\Passwords\\PasswordResetServiceProvider', + 18 => 'Illuminate\\Session\\SessionServiceProvider', + 19 => 'Illuminate\\Translation\\TranslationServiceProvider', + 20 => 'Illuminate\\Validation\\ValidationServiceProvider', + 21 => 'Illuminate\\View\\ViewServiceProvider', + 22 => 'Barryvdh\\Debugbar\\ServiceProvider', + 23 => 'BeyondCode\\DumpServer\\DumpServerServiceProvider', + 24 => 'Fideloper\\Proxy\\TrustedProxyServiceProvider', + 25 => 'Intervention\\Image\\ImageServiceProvider', + 26 => 'Jacobcyl\\AliOSS\\AliOssServiceProvider', + 27 => 'Laravel\\Tinker\\TinkerServiceProvider', + 28 => 'Mews\\Captcha\\CaptchaServiceProvider', + 29 => 'Carbon\\Laravel\\ServiceProvider', + 30 => 'NunoMaduro\\Collision\\Adapters\\Laravel\\CollisionServiceProvider', + 31 => 'Overtrue\\LaravelFollow\\FollowServiceProvider', + 32 => 'Overtrue\\LaravelWeChat\\ServiceProvider', + 33 => 'RuLong\\Area\\ServiceProvider', + 34 => 'RuLong\\Panel\\ServiceProvider', + 35 => 'RuLong\\Order\\ServiceProvider', + 36 => 'RuLong\\Sms\\ServiceProvider', + 37 => 'RuLong\\UserAccount\\ServiceProvider', + 38 => 'RuLong\\UserRelation\\ServiceProvider', + 39 => 'SimpleSoftwareIO\\QrCode\\QrCodeServiceProvider', + 40 => 'Tymon\\JWTAuth\\Providers\\LaravelServiceProvider', + 41 => 'Way\\Generators\\GeneratorsServiceProvider', + 42 => 'Xethron\\MigrationsGenerator\\MigrationsGeneratorServiceProvider', + 43 => 'App\\Providers\\AppServiceProvider', + 44 => 'App\\Providers\\AuthServiceProvider', + 45 => 'App\\Providers\\EventServiceProvider', + 46 => 'App\\Providers\\RouteServiceProvider', + 47 => 'RuLong\\Bonus\\ServiceProvider', + 48 => 'RuLong\\Coupon\\ServiceProvider', + 49 => 'SimpleSoftwareIO\\QrCode\\QrCodeServiceProvider', + 50 => 'Intervention\\Image\\ImageServiceProviderLaravel5', + 51 => 'App\\Api\\ApiServiceProvider', + ), + 'eager' => + array ( + 0 => 'Illuminate\\Auth\\AuthServiceProvider', + 1 => 'Illuminate\\Cookie\\CookieServiceProvider', + 2 => 'Illuminate\\Database\\DatabaseServiceProvider', + 3 => 'Illuminate\\Encryption\\EncryptionServiceProvider', + 4 => 'Illuminate\\Filesystem\\FilesystemServiceProvider', + 5 => 'Illuminate\\Foundation\\Providers\\FoundationServiceProvider', + 6 => 'Illuminate\\Notifications\\NotificationServiceProvider', + 7 => 'Illuminate\\Pagination\\PaginationServiceProvider', + 8 => 'Illuminate\\Session\\SessionServiceProvider', + 9 => 'Illuminate\\View\\ViewServiceProvider', + 10 => 'Barryvdh\\Debugbar\\ServiceProvider', + 11 => 'BeyondCode\\DumpServer\\DumpServerServiceProvider', + 12 => 'Fideloper\\Proxy\\TrustedProxyServiceProvider', + 13 => 'Intervention\\Image\\ImageServiceProvider', + 14 => 'Jacobcyl\\AliOSS\\AliOssServiceProvider', + 15 => 'Mews\\Captcha\\CaptchaServiceProvider', + 16 => 'Carbon\\Laravel\\ServiceProvider', + 17 => 'Overtrue\\LaravelFollow\\FollowServiceProvider', + 18 => 'Overtrue\\LaravelWeChat\\ServiceProvider', + 19 => 'RuLong\\Area\\ServiceProvider', + 20 => 'RuLong\\Panel\\ServiceProvider', + 21 => 'RuLong\\Order\\ServiceProvider', + 22 => 'RuLong\\Sms\\ServiceProvider', + 23 => 'RuLong\\UserAccount\\ServiceProvider', + 24 => 'RuLong\\UserRelation\\ServiceProvider', + 25 => 'Tymon\\JWTAuth\\Providers\\LaravelServiceProvider', + 26 => 'Way\\Generators\\GeneratorsServiceProvider', + 27 => 'Xethron\\MigrationsGenerator\\MigrationsGeneratorServiceProvider', + 28 => 'App\\Providers\\AppServiceProvider', + 29 => 'App\\Providers\\AuthServiceProvider', + 30 => 'App\\Providers\\EventServiceProvider', + 31 => 'App\\Providers\\RouteServiceProvider', + 32 => 'RuLong\\Bonus\\ServiceProvider', + 33 => 'RuLong\\Coupon\\ServiceProvider', + 34 => 'Intervention\\Image\\ImageServiceProviderLaravel5', + 35 => 'App\\Api\\ApiServiceProvider', + ), + 'deferred' => + array ( + 'Illuminate\\Broadcasting\\BroadcastManager' => 'Illuminate\\Broadcasting\\BroadcastServiceProvider', + 'Illuminate\\Contracts\\Broadcasting\\Factory' => 'Illuminate\\Broadcasting\\BroadcastServiceProvider', + 'Illuminate\\Contracts\\Broadcasting\\Broadcaster' => 'Illuminate\\Broadcasting\\BroadcastServiceProvider', + 'Illuminate\\Bus\\Dispatcher' => 'Illuminate\\Bus\\BusServiceProvider', + 'Illuminate\\Contracts\\Bus\\Dispatcher' => 'Illuminate\\Bus\\BusServiceProvider', + 'Illuminate\\Contracts\\Bus\\QueueingDispatcher' => 'Illuminate\\Bus\\BusServiceProvider', + 'cache' => 'Illuminate\\Cache\\CacheServiceProvider', + 'cache.store' => 'Illuminate\\Cache\\CacheServiceProvider', + 'memcached.connector' => 'Illuminate\\Cache\\CacheServiceProvider', + 'command.cache.clear' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.cache.forget' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.clear-compiled' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.auth.resets.clear' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.config.cache' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.config.clear' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.down' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.environment' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.key.generate' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.migrate' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.migrate.fresh' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.migrate.install' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.migrate.refresh' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.migrate.reset' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.migrate.rollback' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.migrate.status' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.optimize' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.optimize.clear' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.package.discover' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.preset' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.queue.failed' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.queue.flush' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.queue.forget' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.queue.listen' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.queue.restart' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.queue.retry' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.queue.work' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.route.cache' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.route.clear' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.route.list' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.seed' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'Illuminate\\Console\\Scheduling\\ScheduleFinishCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'Illuminate\\Console\\Scheduling\\ScheduleRunCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.storage.link' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.up' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.view.cache' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.view.clear' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.app.name' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.auth.make' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.cache.table' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.channel.make' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.console.make' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.controller.make' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.event.generate' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.event.make' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.exception.make' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.factory.make' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.job.make' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.listener.make' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.mail.make' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.middleware.make' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.migrate.make' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.model.make' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.notification.make' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.notification.table' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.observer.make' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.policy.make' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.provider.make' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.queue.failed-table' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.queue.table' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.request.make' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.resource.make' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.rule.make' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.seeder.make' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.session.table' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.serve' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.test.make' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'command.vendor.publish' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'migrator' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'migration.repository' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'migration.creator' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'composer' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', + 'hash' => 'Illuminate\\Hashing\\HashServiceProvider', + 'hash.driver' => 'Illuminate\\Hashing\\HashServiceProvider', + 'mailer' => 'Illuminate\\Mail\\MailServiceProvider', + 'swift.mailer' => 'Illuminate\\Mail\\MailServiceProvider', + 'swift.transport' => 'Illuminate\\Mail\\MailServiceProvider', + 'Illuminate\\Mail\\Markdown' => 'Illuminate\\Mail\\MailServiceProvider', + 'Illuminate\\Contracts\\Pipeline\\Hub' => 'Illuminate\\Pipeline\\PipelineServiceProvider', + 'queue' => 'Illuminate\\Queue\\QueueServiceProvider', + 'queue.worker' => 'Illuminate\\Queue\\QueueServiceProvider', + 'queue.listener' => 'Illuminate\\Queue\\QueueServiceProvider', + 'queue.failer' => 'Illuminate\\Queue\\QueueServiceProvider', + 'queue.connection' => 'Illuminate\\Queue\\QueueServiceProvider', + 'redis' => 'Illuminate\\Redis\\RedisServiceProvider', + 'redis.connection' => 'Illuminate\\Redis\\RedisServiceProvider', + 'auth.password' => 'Illuminate\\Auth\\Passwords\\PasswordResetServiceProvider', + 'auth.password.broker' => 'Illuminate\\Auth\\Passwords\\PasswordResetServiceProvider', + 'translator' => 'Illuminate\\Translation\\TranslationServiceProvider', + 'translation.loader' => 'Illuminate\\Translation\\TranslationServiceProvider', + 'validator' => 'Illuminate\\Validation\\ValidationServiceProvider', + 'validation.presence' => 'Illuminate\\Validation\\ValidationServiceProvider', + 'command.tinker' => 'Laravel\\Tinker\\TinkerServiceProvider', + 'NunoMaduro\\Collision\\Contracts\\Provider' => 'NunoMaduro\\Collision\\Adapters\\Laravel\\CollisionServiceProvider', + 'qrcode' => 'SimpleSoftwareIO\\QrCode\\QrCodeServiceProvider', + ), + 'when' => + array ( + 'Illuminate\\Broadcasting\\BroadcastServiceProvider' => + array ( + ), + 'Illuminate\\Bus\\BusServiceProvider' => + array ( + ), + 'Illuminate\\Cache\\CacheServiceProvider' => + array ( + ), + 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider' => + array ( + ), + 'Illuminate\\Hashing\\HashServiceProvider' => + array ( + ), + 'Illuminate\\Mail\\MailServiceProvider' => + array ( + ), + 'Illuminate\\Pipeline\\PipelineServiceProvider' => + array ( + ), + 'Illuminate\\Queue\\QueueServiceProvider' => + array ( + ), + 'Illuminate\\Redis\\RedisServiceProvider' => + array ( + ), + 'Illuminate\\Auth\\Passwords\\PasswordResetServiceProvider' => + array ( + ), + 'Illuminate\\Translation\\TranslationServiceProvider' => + array ( + ), + 'Illuminate\\Validation\\ValidationServiceProvider' => + array ( + ), + 'Laravel\\Tinker\\TinkerServiceProvider' => + array ( + ), + 'NunoMaduro\\Collision\\Adapters\\Laravel\\CollisionServiceProvider' => + array ( + ), + 'SimpleSoftwareIO\\QrCode\\QrCodeServiceProvider' => + array ( + ), + ), +); \ No newline at end of file diff --git a/config/app.php b/config/app.php new file mode 100644 index 0000000..7387c0e --- /dev/null +++ b/config/app.php @@ -0,0 +1,226 @@ + env('APP_NAME', 'Laravel'), + + /* + |-------------------------------------------------------------------------- + | Application Environment + |-------------------------------------------------------------------------- + | + | This value determines the "environment" your application is currently + | running in. This may determine how you prefer to configure various + | services the application utilizes. Set this in your ".env" file. + | + */ + + 'env' => env('APP_ENV', 'production'), + + /* + |-------------------------------------------------------------------------- + | Application Debug Mode + |-------------------------------------------------------------------------- + | + | When your application is in debug mode, detailed error messages with + | stack traces will be shown on every error that occurs within your + | application. If disabled, a simple generic error page is shown. + | + */ + + 'debug' => env('APP_DEBUG', false), + + /* + |-------------------------------------------------------------------------- + | Application URL + |-------------------------------------------------------------------------- + | + | This URL is used by the console to properly generate URLs when using + | the Artisan command line tool. You should set this to the root of + | your application so that it is used when running Artisan tasks. + | + */ + + 'url' => env('APP_URL', 'http://localhost'), + + /* + |-------------------------------------------------------------------------- + | Application Timezone + |-------------------------------------------------------------------------- + | + | Here you may specify the default timezone for your application, which + | will be used by the PHP date and date-time functions. We have gone + | ahead and set this to a sensible default for you out of the box. + | + */ + + 'timezone' => 'PRC', + + /* + |-------------------------------------------------------------------------- + | Application Locale Configuration + |-------------------------------------------------------------------------- + | + | The application locale determines the default locale that will be used + | by the translation service provider. You are free to set this value + | to any of the locales which will be supported by the application. + | + */ + + 'locale' => 'en', + + /* + |-------------------------------------------------------------------------- + | Application Fallback Locale + |-------------------------------------------------------------------------- + | + | The fallback locale determines the locale to use when the current one + | is not available. You may change the value to correspond to any of + | the language folders that are provided through your application. + | + */ + + 'fallback_locale' => 'en', + + /* + |-------------------------------------------------------------------------- + | Encryption Key + |-------------------------------------------------------------------------- + | + | This key is used by the Illuminate encrypter service and should be set + | to a random, 32 character string, otherwise these encrypted strings + | will not be safe. Please do this before deploying an application! + | + */ + + 'key' => env('APP_KEY'), + + 'cipher' => 'AES-256-CBC', + + /* + |-------------------------------------------------------------------------- + | Autoloaded Service Providers + |-------------------------------------------------------------------------- + | + | The service providers listed here will be automatically loaded on the + | request to your application. Feel free to add your own services to + | this array to grant expanded functionality to your applications. + | + */ + + 'providers' => [ + + /* + * Laravel Framework Service Providers... + */ + Illuminate\Auth\AuthServiceProvider::class, + Illuminate\Broadcasting\BroadcastServiceProvider::class, + Illuminate\Bus\BusServiceProvider::class, + Illuminate\Cache\CacheServiceProvider::class, + Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class, + Illuminate\Cookie\CookieServiceProvider::class, + Illuminate\Database\DatabaseServiceProvider::class, + Illuminate\Encryption\EncryptionServiceProvider::class, + Illuminate\Filesystem\FilesystemServiceProvider::class, + Illuminate\Foundation\Providers\FoundationServiceProvider::class, + Illuminate\Hashing\HashServiceProvider::class, + Illuminate\Mail\MailServiceProvider::class, + Illuminate\Notifications\NotificationServiceProvider::class, + Illuminate\Pagination\PaginationServiceProvider::class, + Illuminate\Pipeline\PipelineServiceProvider::class, + Illuminate\Queue\QueueServiceProvider::class, + Illuminate\Redis\RedisServiceProvider::class, + Illuminate\Auth\Passwords\PasswordResetServiceProvider::class, + Illuminate\Session\SessionServiceProvider::class, + Illuminate\Translation\TranslationServiceProvider::class, + Illuminate\Validation\ValidationServiceProvider::class, + Illuminate\View\ViewServiceProvider::class, + + /* + * Package Service Providers... + */ + + /* + * Application Service Providers... + */ + App\Providers\AppServiceProvider::class, + App\Providers\AuthServiceProvider::class, + // App\Providers\BroadcastServiceProvider::class, + App\Providers\EventServiceProvider::class, + App\Providers\RouteServiceProvider::class, + + RuLong\Bonus\ServiceProvider::class, + RuLong\Coupon\ServiceProvider::class, + SimpleSoftwareIO\QrCode\QrCodeServiceProvider::class, + Intervention\Image\ImageServiceProviderLaravel5::class, + + App\Api\ApiServiceProvider::class, + + ], + + /* + |-------------------------------------------------------------------------- + | Class Aliases + |-------------------------------------------------------------------------- + | + | This array of class aliases will be registered when this application + | is started. However, feel free to register as many as you wish as + | the aliases are "lazy" loaded so they don't hinder performance. + | + */ + + 'aliases' => [ + + 'App' => Illuminate\Support\Facades\App::class, + 'Artisan' => Illuminate\Support\Facades\Artisan::class, + 'Auth' => Illuminate\Support\Facades\Auth::class, + 'Blade' => Illuminate\Support\Facades\Blade::class, + 'Broadcast' => Illuminate\Support\Facades\Broadcast::class, + 'Bus' => Illuminate\Support\Facades\Bus::class, + 'Cache' => Illuminate\Support\Facades\Cache::class, + 'Config' => Illuminate\Support\Facades\Config::class, + 'Cookie' => Illuminate\Support\Facades\Cookie::class, + 'Crypt' => Illuminate\Support\Facades\Crypt::class, + 'DB' => Illuminate\Support\Facades\DB::class, + 'Eloquent' => Illuminate\Database\Eloquent\Model::class, + 'Event' => Illuminate\Support\Facades\Event::class, + 'File' => Illuminate\Support\Facades\File::class, + 'Gate' => Illuminate\Support\Facades\Gate::class, + 'Hash' => Illuminate\Support\Facades\Hash::class, + 'Lang' => Illuminate\Support\Facades\Lang::class, + 'Log' => Illuminate\Support\Facades\Log::class, + 'Mail' => Illuminate\Support\Facades\Mail::class, + 'Notification' => Illuminate\Support\Facades\Notification::class, + 'Password' => Illuminate\Support\Facades\Password::class, + 'Queue' => Illuminate\Support\Facades\Queue::class, + 'Redirect' => Illuminate\Support\Facades\Redirect::class, + 'Redis' => Illuminate\Support\Facades\Redis::class, + 'Request' => Illuminate\Support\Facades\Request::class, + 'Response' => Illuminate\Support\Facades\Response::class, + 'Route' => Illuminate\Support\Facades\Route::class, + 'Schema' => Illuminate\Support\Facades\Schema::class, + 'Session' => Illuminate\Support\Facades\Session::class, + 'Storage' => Illuminate\Support\Facades\Storage::class, + 'URL' => Illuminate\Support\Facades\URL::class, + 'Validator' => Illuminate\Support\Facades\Validator::class, + 'View' => Illuminate\Support\Facades\View::class, + + 'Params' => App\Helpers\Params::class, + 'QrCode' => SimpleSoftwareIO\QrCode\Facades\QrCode::class, + 'Image' => Intervention\Image\Facades\Image::class, + 'Logistic' => App\Logistics\LogisticFacade::class, + 'OpenArea' => RuLong\Area\Facades\OpenArea::class, + ], + +]; diff --git a/config/auth.php b/config/auth.php new file mode 100644 index 0000000..c0e91c7 --- /dev/null +++ b/config/auth.php @@ -0,0 +1,102 @@ + [ + 'guard' => 'web', + 'passwords' => 'users', + ], + + /* + |-------------------------------------------------------------------------- + | Authentication Guards + |-------------------------------------------------------------------------- + | + | Next, you may define every authentication guard for your application. + | Of course, a great default configuration has been defined for you + | here which uses session storage and the Eloquent user provider. + | + | All authentication drivers have a user provider. This defines how the + | users are actually retrieved out of your database or other storage + | mechanisms used by this application to persist your user's data. + | + | Supported: "session", "token" + | + */ + + 'guards' => [ + 'web' => [ + 'driver' => 'session', + 'provider' => 'users', + ], + + 'api' => [ + 'driver' => 'jwt', + 'provider' => 'users', + ], + ], + + /* + |-------------------------------------------------------------------------- + | User Providers + |-------------------------------------------------------------------------- + | + | All authentication drivers have a user provider. This defines how the + | users are actually retrieved out of your database or other storage + | mechanisms used by this application to persist your user's data. + | + | If you have multiple user tables or models you may configure multiple + | sources which represent each model / table. These sources may then + | be assigned to any extra authentication guards you have defined. + | + | Supported: "database", "eloquent" + | + */ + + 'providers' => [ + 'users' => [ + 'driver' => 'eloquent', + 'model' => App\User::class, + ], + + // 'users' => [ + // 'driver' => 'database', + // 'table' => 'users', + // ], + ], + + /* + |-------------------------------------------------------------------------- + | Resetting Passwords + |-------------------------------------------------------------------------- + | + | You may specify multiple password reset configurations if you have more + | than one user table or model in the application and you want to have + | separate password reset settings based on the specific user types. + | + | The expire time is the number of minutes that the reset token should be + | considered valid. This security feature keeps tokens short-lived so + | they have less time to be guessed. You may change this as needed. + | + */ + + 'passwords' => [ + 'users' => [ + 'provider' => 'users', + 'table' => 'password_resets', + 'expire' => 60, + ], + ], + +]; diff --git a/config/broadcasting.php b/config/broadcasting.php new file mode 100644 index 0000000..3ca45ea --- /dev/null +++ b/config/broadcasting.php @@ -0,0 +1,59 @@ + env('BROADCAST_DRIVER', 'null'), + + /* + |-------------------------------------------------------------------------- + | Broadcast Connections + |-------------------------------------------------------------------------- + | + | Here you may define all of the broadcast connections that will be used + | to broadcast events to other systems or over websockets. Samples of + | each available type of connection are provided inside this array. + | + */ + + 'connections' => [ + + 'pusher' => [ + 'driver' => 'pusher', + 'key' => env('PUSHER_APP_KEY'), + 'secret' => env('PUSHER_APP_SECRET'), + 'app_id' => env('PUSHER_APP_ID'), + 'options' => [ + 'cluster' => env('PUSHER_APP_CLUSTER'), + 'encrypted' => true, + ], + ], + + 'redis' => [ + 'driver' => 'redis', + 'connection' => 'default', + ], + + 'log' => [ + 'driver' => 'log', + ], + + 'null' => [ + 'driver' => 'null', + ], + + ], + +]; diff --git a/config/cache.php b/config/cache.php new file mode 100644 index 0000000..6c4629d --- /dev/null +++ b/config/cache.php @@ -0,0 +1,94 @@ + env('CACHE_DRIVER', 'file'), + + /* + |-------------------------------------------------------------------------- + | Cache Stores + |-------------------------------------------------------------------------- + | + | Here you may define all of the cache "stores" for your application as + | well as their drivers. You may even define multiple stores for the + | same cache driver to group types of items stored in your caches. + | + */ + + 'stores' => [ + + 'apc' => [ + 'driver' => 'apc', + ], + + 'array' => [ + 'driver' => 'array', + ], + + 'database' => [ + 'driver' => 'database', + 'table' => 'cache', + 'connection' => null, + ], + + 'file' => [ + 'driver' => 'file', + 'path' => storage_path('framework/cache/data'), + ], + + 'memcached' => [ + 'driver' => 'memcached', + 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), + 'sasl' => [ + env('MEMCACHED_USERNAME'), + env('MEMCACHED_PASSWORD'), + ], + 'options' => [ + // Memcached::OPT_CONNECT_TIMEOUT => 2000, + ], + 'servers' => [ + [ + 'host' => env('MEMCACHED_HOST', '127.0.0.1'), + 'port' => env('MEMCACHED_PORT', 11211), + 'weight' => 100, + ], + ], + ], + + 'redis' => [ + 'driver' => 'redis', + 'connection' => 'cache', + ], + + ], + + /* + |-------------------------------------------------------------------------- + | Cache Key Prefix + |-------------------------------------------------------------------------- + | + | When utilizing a RAM based store such as APC or Memcached, there might + | be other applications utilizing the same cache. So, we'll specify a + | value to get prefixed to all our keys so we can avoid collisions. + | + */ + + 'prefix' => env( + 'CACHE_PREFIX', + str_slug(env('APP_NAME', 'laravel'), '_').'_cache' + ), + +]; diff --git a/config/captcha.php b/config/captcha.php new file mode 100644 index 0000000..b5fa647 --- /dev/null +++ b/config/captcha.php @@ -0,0 +1,48 @@ + '2346789abcdefghjmnpqrtuxyzABCDEFGHJMNPQRTUXYZ', + + 'default' => [ + 'length' => 4, + 'width' => 115, + 'height' => 34, + 'quality' => 90, + 'fontColors' => ['#2c3e50', '#c0392b', '#16a085', '#c0392b', '#8e44ad', '#303f9f', '#f57c00', '#795548'], + ], + + 'flat' => [ + 'length' => 6, + 'width' => 160, + 'height' => 46, + 'quality' => 90, + 'lines' => 6, + 'bgImage' => false, + 'bgColor' => '#ecf2f4', + 'fontColors' => ['#2c3e50', '#c0392b', '#16a085', '#c0392b', '#8e44ad', '#303f9f', '#f57c00', '#795548'], + 'contrast' => -5, + ], + + 'mini' => [ + 'length' => 3, + 'width' => 60, + 'height' => 32, + ], + + 'inverse' => [ + 'length' => 5, + 'width' => 120, + 'height' => 36, + 'quality' => 90, + 'sensitive' => true, + 'angle' => 12, + 'sharpen' => 10, + 'blur' => 2, + 'invert' => true, + 'contrast' => -5, + ], +]; diff --git a/config/database.php b/config/database.php new file mode 100644 index 0000000..db0e0c6 --- /dev/null +++ b/config/database.php @@ -0,0 +1,127 @@ + env('DB_CONNECTION', 'mysql'), + + /* + |-------------------------------------------------------------------------- + | Database Connections + |-------------------------------------------------------------------------- + | + | Here are each of the database connections setup for your application. + | Of course, examples of configuring each database platform that is + | supported by Laravel is shown below to make development simple. + | + | + | All database work in Laravel is done through the PHP PDO facilities + | so make sure you have the driver for your particular database of + | choice installed on your machine before you begin development. + | + */ + + 'connections' => [ + + 'sqlite' => [ + 'driver' => 'sqlite', + 'database' => env('DB_DATABASE', database_path('database.sqlite')), + 'prefix' => '', + ], + + 'mysql' => [ + 'driver' => 'mysql', + 'host' => env('DB_HOST', '127.0.0.1'), + 'port' => env('DB_PORT', '3306'), + 'database' => env('DB_DATABASE', 'forge'), + 'username' => env('DB_USERNAME', 'forge'), + 'password' => env('DB_PASSWORD', ''), + 'unix_socket' => env('DB_SOCKET', ''), + 'charset' => 'utf8mb4', + 'collation' => 'utf8mb4_unicode_ci', + 'prefix' => '', + 'strict' => false, + 'engine' => null, + ], + + 'pgsql' => [ + 'driver' => 'pgsql', + 'host' => env('DB_HOST', '127.0.0.1'), + 'port' => env('DB_PORT', '5432'), + 'database' => env('DB_DATABASE', 'forge'), + 'username' => env('DB_USERNAME', 'forge'), + 'password' => env('DB_PASSWORD', ''), + 'charset' => 'utf8', + 'prefix' => '', + 'schema' => 'public', + 'sslmode' => 'prefer', + ], + + 'sqlsrv' => [ + 'driver' => 'sqlsrv', + 'host' => env('DB_HOST', 'localhost'), + 'port' => env('DB_PORT', '1433'), + 'database' => env('DB_DATABASE', 'forge'), + 'username' => env('DB_USERNAME', 'forge'), + 'password' => env('DB_PASSWORD', ''), + 'charset' => 'utf8', + 'prefix' => '', + ], + + ], + + /* + |-------------------------------------------------------------------------- + | Migration Repository Table + |-------------------------------------------------------------------------- + | + | This table keeps track of all the migrations that have already run for + | your application. Using this information, we can determine which of + | the migrations on disk haven't actually been run in the database. + | + */ + + 'migrations' => 'migrations', + + /* + |-------------------------------------------------------------------------- + | Redis Databases + |-------------------------------------------------------------------------- + | + | Redis is an open source, fast, and advanced key-value store that also + | provides a richer set of commands than a typical key-value systems + | such as APC or Memcached. Laravel makes it easy to dig right in. + | + */ + + 'redis' => [ + + 'client' => 'predis', + + 'default' => [ + 'host' => env('REDIS_HOST', '127.0.0.1'), + 'password' => env('REDIS_PASSWORD', null), + 'port' => env('REDIS_PORT', 6379), + 'database' => env('REDIS_DB', 0), + ], + + 'cache' => [ + 'host' => env('REDIS_HOST', '127.0.0.1'), + 'password' => env('REDIS_PASSWORD', null), + 'port' => env('REDIS_PORT', 6379), + 'database' => env('REDIS_CACHE_DB', 1), + ], + + ], + +]; diff --git a/config/debugbar.php b/config/debugbar.php new file mode 100644 index 0000000..a966091 --- /dev/null +++ b/config/debugbar.php @@ -0,0 +1,201 @@ + env('DEBUGBAR_ENABLED', null), + 'except' => [ + // + ], + + /* + |-------------------------------------------------------------------------- + | Storage settings + |-------------------------------------------------------------------------- + | + | DebugBar stores data for session/ajax requests. + | You can disable this, so the debugbar stores data in headers/session, + | but this can cause problems with large data collectors. + | By default, file storage (in the storage folder) is used. Redis and PDO + | can also be used. For PDO, run the package migrations first. + | + */ + 'storage' => [ + 'enabled' => true, + 'driver' => 'file', // redis, file, pdo, custom + 'path' => storage_path('debugbar'), // For file driver + 'connection' => null, // Leave null for default connection (Redis/PDO) + 'provider' => '', // Instance of StorageInterface for custom driver + ], + + /* + |-------------------------------------------------------------------------- + | Vendors + |-------------------------------------------------------------------------- + | + | Vendor files are included by default, but can be set to false. + | This can also be set to 'js' or 'css', to only include javascript or css vendor files. + | Vendor files are for css: font-awesome (including fonts) and highlight.js (css files) + | and for js: jquery and and highlight.js + | So if you want syntax highlighting, set it to true. + | jQuery is set to not conflict with existing jQuery scripts. + | + */ + + 'include_vendors' => true, + + /* + |-------------------------------------------------------------------------- + | Capture Ajax Requests + |-------------------------------------------------------------------------- + | + | The Debugbar can capture Ajax requests and display them. If you don't want this (ie. because of errors), + | you can use this option to disable sending the data through the headers. + | + | Optionally, you can also send ServerTiming headers on ajax requests for the Chrome DevTools. + */ + + 'capture_ajax' => true, + 'add_ajax_timing' => false, + + /* + |-------------------------------------------------------------------------- + | Custom Error Handler for Deprecated warnings + |-------------------------------------------------------------------------- + | + | When enabled, the Debugbar shows deprecated warnings for Symfony components + | in the Messages tab. + | + */ + 'error_handler' => false, + + /* + |-------------------------------------------------------------------------- + | Clockwork integration + |-------------------------------------------------------------------------- + | + | The Debugbar can emulate the Clockwork headers, so you can use the Chrome + | Extension, without the server-side code. It uses Debugbar collectors instead. + | + */ + 'clockwork' => false, + + /* + |-------------------------------------------------------------------------- + | DataCollectors + |-------------------------------------------------------------------------- + | + | Enable/disable DataCollectors + | + */ + + 'collectors' => [ + 'phpinfo' => true, // Php version + 'messages' => true, // Messages + 'time' => true, // Time Datalogger + 'memory' => true, // Memory usage + 'exceptions' => true, // Exception displayer + 'log' => true, // Logs from Monolog (merged in messages if enabled) + 'db' => true, // Show database (PDO) queries and bindings + 'views' => true, // Views with their data + 'route' => true, // Current route information + 'auth' => true, // Display Laravel authentication status + 'gate' => true, // Display Laravel Gate checks + 'session' => true, // Display session data + 'symfony_request' => true, // Only one can be enabled.. + 'mail' => true, // Catch mail messages + 'laravel' => false, // Laravel version and environment + 'events' => false, // All events fired + 'default_request' => false, // Regular or special Symfony request logger + 'logs' => false, // Add the latest log messages + 'files' => false, // Show the included files + 'config' => false, // Display config settings + 'cache' => false, // Display cache events + ], + + /* + |-------------------------------------------------------------------------- + | Extra options + |-------------------------------------------------------------------------- + | + | Configure some DataCollectors + | + */ + + 'options' => [ + 'auth' => [ + 'show_name' => true, // Also show the users name/email in the debugbar + ], + 'db' => [ + 'with_params' => true, // Render SQL with the parameters substituted + 'backtrace' => true, // Use a backtrace to find the origin of the query in your files. + 'timeline' => false, // Add the queries to the timeline + 'explain' => [ // Show EXPLAIN output on queries + 'enabled' => false, + 'types' => ['SELECT'], // ['SELECT', 'INSERT', 'UPDATE', 'DELETE']; for MySQL 5.6.3+ + ], + 'hints' => true, // Show hints for common mistakes + ], + 'mail' => [ + 'full_log' => false, + ], + 'views' => [ + 'data' => false, //Note: Can slow down the application, because the data can be quite large.. + ], + 'route' => [ + 'label' => true, // show complete route on bar + ], + 'logs' => [ + 'file' => null, + ], + 'cache' => [ + 'values' => true, // collect cache values + ], + ], + + /* + |-------------------------------------------------------------------------- + | Inject Debugbar in Response + |-------------------------------------------------------------------------- + | + | Usually, the debugbar is added just before , by listening to the + | Response after the App is done. If you disable this, you have to add them + | in your template yourself. See http://phpdebugbar.com/docs/rendering.html + | + */ + + 'inject' => true, + + /* + |-------------------------------------------------------------------------- + | DebugBar route prefix + |-------------------------------------------------------------------------- + | + | Sometimes you want to set route prefix to be used by DebugBar to load + | its resources from. Usually the need comes from misconfigured web server or + | from trying to overcome bugs like this: http://trac.nginx.org/nginx/ticket/97 + | + */ + 'route_prefix' => '_debugbar', + + /* + |-------------------------------------------------------------------------- + | DebugBar route domain + |-------------------------------------------------------------------------- + | + | By default DebugBar route served from the same domain that request served. + | To override default domain, specify it as a non-empty value. + */ + 'route_domain' => null, +]; diff --git a/config/filesystems.php b/config/filesystems.php new file mode 100644 index 0000000..9d9b66c --- /dev/null +++ b/config/filesystems.php @@ -0,0 +1,82 @@ + env('FILESYSTEM_DRIVER', 'local'), + + /* + |-------------------------------------------------------------------------- + | Default Cloud Filesystem Disk + |-------------------------------------------------------------------------- + | + | Many applications store files both locally and in the cloud. For this + | reason, you may specify a default "cloud" driver here. This driver + | will be bound as the Cloud disk implementation in the container. + | + */ + + 'cloud' => env('FILESYSTEM_CLOUD', 's3'), + + /* + |-------------------------------------------------------------------------- + | Filesystem Disks + |-------------------------------------------------------------------------- + | + | Here you may configure as many filesystem "disks" as you wish, and you + | may even configure multiple disks of the same driver. Defaults have + | been setup for each driver as an example of the required options. + | + | Supported Drivers: "local", "ftp", "sftp", "s3", "rackspace" + | + */ + + 'disks' => [ + + 'local' => [ + 'driver' => 'local', + 'root' => storage_path('app'), + ], + + 'public' => [ + 'driver' => 'local', + 'root' => storage_path('app/public'), + 'url' => '/storage', + 'visibility' => 'public', + ], + + 's3' => [ + 'driver' => 's3', + 'key' => env('AWS_ACCESS_KEY_ID'), + 'secret' => env('AWS_SECRET_ACCESS_KEY'), + 'region' => env('AWS_DEFAULT_REGION'), + 'bucket' => env('AWS_BUCKET'), + 'url' => env('AWS_URL'), + ], + + 'oss' => [ + 'driver' => 'oss', + 'access_id' => 'LTAIQdaKM7cPEUg6', + 'access_key' => 'DjEtf7D06eAn18EsQnbstL6FwfAOYw', + 'bucket' => 'bhmp', + 'endpoint' => 'oss-cn-beijing.aliyuncs.com', // OSS 外网节点或自定义外部域名 + //'endpoint_internal' => 'oss-cn-beijing-internal.aliyuncs.com', // v2.0.4 新增配置属性,如果为空,则默认使用 endpoint 配置(由于内网上传有点小问题未解决,请大家暂时不要使用内网节点上传,正在与阿里技术沟通中) + 'cdnDomain' => '', // 如果isCName为true, getUrl会判断cdnDomain是否设定来决定返回的url,如果cdnDomain未设置,则使用endpoint来生成url,否则使用cdn + 'ssl' => true, // true to use 'https://' and false to use 'http://'. default is false, + 'isCName' => false, // 是否使用自定义域名,true: 则Storage.url()会使用自定义的cdn或域名生成文件url, false: 则使用外部节点生成url + 'debug' => false, + ], + + ], + +]; diff --git a/config/follow.php b/config/follow.php new file mode 100644 index 0000000..010364e --- /dev/null +++ b/config/follow.php @@ -0,0 +1,52 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +return [ + /* + * Model class name of users. + */ + 'user_model' => 'App\User', + + /* + * Table name of users table. + */ + 'users_table_name' => 'users', + + /* + * Primary key of users table. + */ + 'users_table_primary_key' => 'id', + + /* + * Foreign key of users table. + */ + 'users_table_foreign_key' => 'user_id', + + /* + * Table name of followable relations. + */ + 'followable_table' => 'followables', + + /* + * Prefix of many-to-many relation fields. + */ + 'morph_prefix' => 'followable', + + /* + * Date format for created_at. + */ + 'date_format' => 'Y-m-d H:i:s', + + /* + * Namespace of models. + */ + 'model_namespace' => 'App', +]; diff --git a/config/hashing.php b/config/hashing.php new file mode 100644 index 0000000..8425770 --- /dev/null +++ b/config/hashing.php @@ -0,0 +1,52 @@ + 'bcrypt', + + /* + |-------------------------------------------------------------------------- + | Bcrypt Options + |-------------------------------------------------------------------------- + | + | Here you may specify the configuration options that should be used when + | passwords are hashed using the Bcrypt algorithm. This will allow you + | to control the amount of time it takes to hash the given password. + | + */ + + 'bcrypt' => [ + 'rounds' => env('BCRYPT_ROUNDS', 10), + ], + + /* + |-------------------------------------------------------------------------- + | Argon Options + |-------------------------------------------------------------------------- + | + | Here you may specify the configuration options that should be used when + | passwords are hashed using the Argon algorithm. These will allow you + | to control the amount of time it takes to hash the given password. + | + */ + + 'argon' => [ + 'memory' => 1024, + 'threads' => 2, + 'time' => 2, + ], + +]; diff --git a/config/jwt.php b/config/jwt.php new file mode 100644 index 0000000..8b7843b --- /dev/null +++ b/config/jwt.php @@ -0,0 +1,304 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +return [ + + /* + |-------------------------------------------------------------------------- + | JWT Authentication Secret + |-------------------------------------------------------------------------- + | + | Don't forget to set this in your .env file, as it will be used to sign + | your tokens. A helper command is provided for this: + | `php artisan jwt:secret` + | + | Note: This will be used for Symmetric algorithms only (HMAC), + | since RSA and ECDSA use a private/public key combo (See below). + | + */ + + 'secret' => env('JWT_SECRET'), + + /* + |-------------------------------------------------------------------------- + | JWT Authentication Keys + |-------------------------------------------------------------------------- + | + | The algorithm you are using, will determine whether your tokens are + | signed with a random string (defined in `JWT_SECRET`) or using the + | following public & private keys. + | + | Symmetric Algorithms: + | HS256, HS384 & HS512 will use `JWT_SECRET`. + | + | Asymmetric Algorithms: + | RS256, RS384 & RS512 / ES256, ES384 & ES512 will use the keys below. + | + */ + + 'keys' => [ + + /* + |-------------------------------------------------------------------------- + | Public Key + |-------------------------------------------------------------------------- + | + | A path or resource to your public key. + | + | E.g. 'file://path/to/public/key' + | + */ + + 'public' => env('JWT_PUBLIC_KEY'), + + /* + |-------------------------------------------------------------------------- + | Private Key + |-------------------------------------------------------------------------- + | + | A path or resource to your private key. + | + | E.g. 'file://path/to/private/key' + | + */ + + 'private' => env('JWT_PRIVATE_KEY'), + + /* + |-------------------------------------------------------------------------- + | Passphrase + |-------------------------------------------------------------------------- + | + | The passphrase for your private key. Can be null if none set. + | + */ + + 'passphrase' => env('JWT_PASSPHRASE'), + + ], + + /* + |-------------------------------------------------------------------------- + | JWT time to live + |-------------------------------------------------------------------------- + | + | Specify the length of time (in minutes) that the token will be valid for. + | Defaults to 1 hour. + | + | You can also set this to null, to yield a never expiring token. + | Some people may want this behaviour for e.g. a mobile app. + | This is not particularly recommended, so make sure you have appropriate + | systems in place to revoke the token if necessary. + | Notice: If you set this to null you should remove 'exp' element from 'required_claims' list. + | + */ + + 'ttl' => env('JWT_TTL', 60), + + /* + |-------------------------------------------------------------------------- + | Refresh time to live + |-------------------------------------------------------------------------- + | + | Specify the length of time (in minutes) that the token can be refreshed + | within. I.E. The user can refresh their token within a 2 week window of + | the original token being created until they must re-authenticate. + | Defaults to 2 weeks. + | + | You can also set this to null, to yield an infinite refresh time. + | Some may want this instead of never expiring tokens for e.g. a mobile app. + | This is not particularly recommended, so make sure you have appropriate + | systems in place to revoke the token if necessary. + | + */ + + 'refresh_ttl' => env('JWT_REFRESH_TTL', 20160), + + /* + |-------------------------------------------------------------------------- + | JWT hashing algorithm + |-------------------------------------------------------------------------- + | + | Specify the hashing algorithm that will be used to sign the token. + | + | See here: https://github.com/namshi/jose/tree/master/src/Namshi/JOSE/Signer/OpenSSL + | for possible values. + | + */ + + 'algo' => env('JWT_ALGO', 'HS256'), + + /* + |-------------------------------------------------------------------------- + | Required Claims + |-------------------------------------------------------------------------- + | + | Specify the required claims that must exist in any token. + | A TokenInvalidException will be thrown if any of these claims are not + | present in the payload. + | + */ + + 'required_claims' => [ + 'iss', + 'iat', + 'exp', + 'nbf', + 'sub', + 'jti', + ], + + /* + |-------------------------------------------------------------------------- + | Persistent Claims + |-------------------------------------------------------------------------- + | + | Specify the claim keys to be persisted when refreshing a token. + | `sub` and `iat` will automatically be persisted, in + | addition to the these claims. + | + | Note: If a claim does not exist then it will be ignored. + | + */ + + 'persistent_claims' => [ + // 'foo', + // 'bar', + ], + + /* + |-------------------------------------------------------------------------- + | Lock Subject + |-------------------------------------------------------------------------- + | + | This will determine whether a `prv` claim is automatically added to + | the token. The purpose of this is to ensure that if you have multiple + | authentication models e.g. `App\User` & `App\OtherPerson`, then we + | should prevent one authentication request from impersonating another, + | if 2 tokens happen to have the same id across the 2 different models. + | + | Under specific circumstances, you may want to disable this behaviour + | e.g. if you only have one authentication model, then you would save + | a little on token size. + | + */ + + 'lock_subject' => true, + + /* + |-------------------------------------------------------------------------- + | Leeway + |-------------------------------------------------------------------------- + | + | This property gives the jwt timestamp claims some "leeway". + | Meaning that if you have any unavoidable slight clock skew on + | any of your servers then this will afford you some level of cushioning. + | + | This applies to the claims `iat`, `nbf` and `exp`. + | + | Specify in seconds - only if you know you need it. + | + */ + + 'leeway' => env('JWT_LEEWAY', 0), + + /* + |-------------------------------------------------------------------------- + | Blacklist Enabled + |-------------------------------------------------------------------------- + | + | In order to invalidate tokens, you must have the blacklist enabled. + | If you do not want or need this functionality, then set this to false. + | + */ + + 'blacklist_enabled' => env('JWT_BLACKLIST_ENABLED', true), + + /* + | ------------------------------------------------------------------------- + | Blacklist Grace Period + | ------------------------------------------------------------------------- + | + | When multiple concurrent requests are made with the same JWT, + | it is possible that some of them fail, due to token regeneration + | on every request. + | + | Set grace period in seconds to prevent parallel request failure. + | + */ + + 'blacklist_grace_period' => env('JWT_BLACKLIST_GRACE_PERIOD', 0), + + /* + |-------------------------------------------------------------------------- + | Cookies encryption + |-------------------------------------------------------------------------- + | + | By default Laravel encrypt cookies for security reason. + | If you decide to not decrypt cookies, you will have to configure Laravel + | to not encrypt your cookie token by adding its name into the $except + | array available in the middleware "EncryptCookies" provided by Laravel. + | see https://laravel.com/docs/master/responses#cookies-and-encryption + | for details. + | + | Set it to true if you want to decrypt cookies. + | + */ + + 'decrypt_cookies' => false, + + /* + |-------------------------------------------------------------------------- + | Providers + |-------------------------------------------------------------------------- + | + | Specify the various providers used throughout the package. + | + */ + + 'providers' => [ + + /* + |-------------------------------------------------------------------------- + | JWT Provider + |-------------------------------------------------------------------------- + | + | Specify the provider that is used to create and decode the tokens. + | + */ + + 'jwt' => Tymon\JWTAuth\Providers\JWT\Lcobucci::class, + + /* + |-------------------------------------------------------------------------- + | Authentication Provider + |-------------------------------------------------------------------------- + | + | Specify the provider that is used to authenticate users. + | + */ + + 'auth' => Tymon\JWTAuth\Providers\Auth\Illuminate::class, + + /* + |-------------------------------------------------------------------------- + | Storage Provider + |-------------------------------------------------------------------------- + | + | Specify the provider that is used to store tokens in the blacklist. + | + */ + + 'storage' => Tymon\JWTAuth\Providers\Storage\Illuminate::class, + + ], + +]; diff --git a/config/logging.php b/config/logging.php new file mode 100644 index 0000000..9c6a0cc --- /dev/null +++ b/config/logging.php @@ -0,0 +1,81 @@ + env('LOG_CHANNEL', 'stack'), + + /* + |-------------------------------------------------------------------------- + | Log Channels + |-------------------------------------------------------------------------- + | + | Here you may configure the log channels for your application. Out of + | the box, Laravel uses the Monolog PHP logging library. This gives + | you a variety of powerful log handlers / formatters to utilize. + | + | Available Drivers: "single", "daily", "slack", "syslog", + | "errorlog", "monolog", + | "custom", "stack" + | + */ + + 'channels' => [ + 'stack' => [ + 'driver' => 'stack', + 'channels' => ['single'], + ], + + 'single' => [ + 'driver' => 'single', + 'path' => storage_path('logs/laravel.log'), + 'level' => 'debug', + ], + + 'daily' => [ + 'driver' => 'daily', + 'path' => storage_path('logs/laravel.log'), + 'level' => 'debug', + 'days' => 30, + ], + + 'slack' => [ + 'driver' => 'slack', + 'url' => env('LOG_SLACK_WEBHOOK_URL'), + 'username' => 'Laravel Log', + 'emoji' => ':boom:', + 'level' => 'critical', + ], + + 'stderr' => [ + 'driver' => 'monolog', + 'handler' => StreamHandler::class, + 'with' => [ + 'stream' => 'php://stderr', + ], + ], + + 'syslog' => [ + 'driver' => 'syslog', + 'level' => 'debug', + ], + + 'errorlog' => [ + 'driver' => 'errorlog', + 'level' => 'debug', + ], + ], + +]; diff --git a/config/mail.php b/config/mail.php new file mode 100644 index 0000000..bb92224 --- /dev/null +++ b/config/mail.php @@ -0,0 +1,123 @@ + env('MAIL_DRIVER', 'smtp'), + + /* + |-------------------------------------------------------------------------- + | SMTP Host Address + |-------------------------------------------------------------------------- + | + | Here you may provide the host address of the SMTP server used by your + | applications. A default option is provided that is compatible with + | the Mailgun mail service which will provide reliable deliveries. + | + */ + + 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), + + /* + |-------------------------------------------------------------------------- + | SMTP Host Port + |-------------------------------------------------------------------------- + | + | This is the SMTP port used by your application to deliver e-mails to + | users of the application. Like the host we have set this value to + | stay compatible with the Mailgun e-mail application by default. + | + */ + + 'port' => env('MAIL_PORT', 587), + + /* + |-------------------------------------------------------------------------- + | Global "From" Address + |-------------------------------------------------------------------------- + | + | You may wish for all e-mails sent by your application to be sent from + | the same address. Here, you may specify a name and address that is + | used globally for all e-mails that are sent by your application. + | + */ + + 'from' => [ + 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'), + 'name' => env('MAIL_FROM_NAME', 'Example'), + ], + + /* + |-------------------------------------------------------------------------- + | E-Mail Encryption Protocol + |-------------------------------------------------------------------------- + | + | Here you may specify the encryption protocol that should be used when + | the application send e-mail messages. A sensible default using the + | transport layer security protocol should provide great security. + | + */ + + 'encryption' => env('MAIL_ENCRYPTION', 'tls'), + + /* + |-------------------------------------------------------------------------- + | SMTP Server Username + |-------------------------------------------------------------------------- + | + | If your SMTP server requires a username for authentication, you should + | set it here. This will get used to authenticate with your server on + | connection. You may also set the "password" value below this one. + | + */ + + 'username' => env('MAIL_USERNAME'), + + 'password' => env('MAIL_PASSWORD'), + + /* + |-------------------------------------------------------------------------- + | Sendmail System Path + |-------------------------------------------------------------------------- + | + | When using the "sendmail" driver to send e-mails, we will need to know + | the path to where Sendmail lives on this server. A default path has + | been provided here, which will work well on most of your systems. + | + */ + + 'sendmail' => '/usr/sbin/sendmail -bs', + + /* + |-------------------------------------------------------------------------- + | Markdown Mail Settings + |-------------------------------------------------------------------------- + | + | If you are using Markdown based email rendering, you may configure your + | theme and component paths here, allowing you to customize the design + | of the emails. Or, you may simply stick with the Laravel defaults! + | + */ + + 'markdown' => [ + 'theme' => 'default', + + 'paths' => [ + resource_path('views/vendor/mail'), + ], + ], + +]; diff --git a/config/queue.php b/config/queue.php new file mode 100644 index 0000000..38326ef --- /dev/null +++ b/config/queue.php @@ -0,0 +1,86 @@ + env('QUEUE_CONNECTION', 'sync'), + + /* + |-------------------------------------------------------------------------- + | Queue Connections + |-------------------------------------------------------------------------- + | + | Here you may configure the connection information for each server that + | is used by your application. A default configuration has been added + | for each back-end shipped with Laravel. You are free to add more. + | + | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null" + | + */ + + 'connections' => [ + + 'sync' => [ + 'driver' => 'sync', + ], + + 'database' => [ + 'driver' => 'database', + 'table' => 'jobs', + 'queue' => 'default', + 'retry_after' => 90, + ], + + 'beanstalkd' => [ + 'driver' => 'beanstalkd', + 'host' => 'localhost', + 'queue' => 'default', + 'retry_after' => 90, + ], + + 'sqs' => [ + 'driver' => 'sqs', + 'key' => env('SQS_KEY', 'your-public-key'), + 'secret' => env('SQS_SECRET', 'your-secret-key'), + 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), + 'queue' => env('SQS_QUEUE', 'your-queue-name'), + 'region' => env('SQS_REGION', 'us-east-1'), + ], + + 'redis' => [ + 'driver' => 'redis', + 'connection' => 'default', + 'queue' => 'default', + 'retry_after' => 90, + 'block_for' => null, + ], + + ], + + /* + |-------------------------------------------------------------------------- + | Failed Queue Jobs + |-------------------------------------------------------------------------- + | + | These options configure the behavior of failed queue job logging so you + | can control which database and table are used to store the jobs that + | have failed. You may change them to any database / table you wish. + | + */ + + 'failed' => [ + 'database' => env('DB_CONNECTION', 'mysql'), + 'table' => 'failed_jobs', + ], + +]; diff --git a/config/rulong.php b/config/rulong.php new file mode 100644 index 0000000..de4cfc3 --- /dev/null +++ b/config/rulong.php @@ -0,0 +1,132 @@ + '宝宝课', + + 'directory' => app_path('Admin'), + + 'route' => [ + 'prefix' => 'admin', + 'middleware' => ['web', 'rulong'], + 'namespace' => 'App\\Admin\\Controllers', + ], + + 'auth' => [ + 'guards' => [ + 'rulong' => [ + 'driver' => 'session', + 'provider' => 'rulong', + ], + ], + + 'providers' => [ + 'rulong' => [ + 'driver' => 'eloquent', + 'model' => RuLong\Panel\Models\Admin::class, + ], + ], + ], + + 'logs' => [ + 'enable' => true, + 'except' => [ + '/', + 'dashboard', + 'password', + 'logs*', + ], + ], + 'permission' => [ + 'except' => [ + '/', + 'auth*', + 'dashboard', + 'password', + ], + ], + + 'ueditor' => [ + 'imageActionName' => 'uploadImage', + 'imageFieldName' => 'upfile', + 'imageMaxSize' => 2048000, + 'imageAllowFiles' => ['.png', '.jpg', '.jpeg', '.gif', '.bmp'], + 'imageCompressEnable' => true, + 'imageCompressBorder' => 1600, + 'imageInsertAlign' => 'none', + 'imageUrlPrefix' => '', + 'imagePathFormat' => '/uploads/images/{yyyy}/{mm}/{dd}/{hash}', + + /* 涂鸦图片上传配置项 */ + 'scrawlActionName' => 'uploadScrawl', + 'scrawlFieldName' => 'upfile', + 'scrawlPathFormat' => '/uploads/images/{yyyy}/{mm}/{dd}/{hash}', + 'scrawlMaxSize' => 2048000, + 'scrawlUrlPrefix' => '', + 'scrawlInsertAlign' => 'none', + + /* 截图工具上传 */ + 'snapscreenActionName' => 'uploadImage', + 'snapscreenPathFormat' => '/uploads/images/{yyyy}/{mm}/{dd}/{hash}', + 'snapscreenUrlPrefix' => '', + 'snapscreenInsertAlign' => 'none', + + /* 抓取远程图片配置 */ + 'catcherActionName' => 'catchImage', + 'catcherLocalDomain' => [], + 'catcherFieldName' => 'source', + 'catcherPathFormat' => '/uploads/images/{yyyy}/{mm}/{dd}/{hash}', + 'catcherUrlPrefix' => '', + 'catcherMaxSize' => 2048000, + 'catcherAllowFiles' => ['.png', '.jpg', '.jpeg', '.gif', '.bmp'], + + /* 上传视频配置 */ + 'videoActionName' => 'uploadVideo', + 'videoFieldName' => 'upfile', + 'videoPathFormat' => '/uploads/videos/{yyyy}/{mm}/{dd}/{hash}', + 'videoUrlPrefix' => '', + 'videoMaxSize' => 102400000, + 'videoAllowFiles' => [ + '.flv', '.swf', '.mkv', '.avi', '.rm', '.rmvb', '.mpeg', '.mpg', + '.ogg', '.ogv', '.mov', '.wmv', '.mp4', '.webm', '.mp3', '.wav', '.mid', + ], + + /* 上传文件配置 */ + 'fileActionName' => 'uploadFile', + 'fileFieldName' => 'upfile', + 'filePathFormat' => '/uploads/files/{yyyy}/{mm}/{dd}/{hash}', + 'fileUrlPrefix' => '', + 'fileMaxSize' => 51200000, + 'fileAllowFiles' => [ + '.png', '.jpg', '.jpeg', '.gif', '.bmp', + '.flv', '.swf', '.mkv', '.avi', '.rm', '.rmvb', '.mpeg', '.mpg', + '.ogg', '.ogv', '.mov', '.wmv', '.mp4', '.webm', '.mp3', '.wav', '.mid', + '.rar', '.zip', '.tar', '.gz', '.7z', '.bz2', '.cab', '.iso', + '.doc', '.docx', '.xls', '.xlsx', '.ppt', '.pptx', '.pdf', '.txt', '.md', '.xml', + ], + + /* 列出指定目录下的图片 */ + 'imageManagerActionName' => 'listImage', + 'imageManagerListPath' => '/uploads/images/', + 'imageManagerListSize' => 20, + 'imageManagerUrlPrefix' => '', + 'imageManagerInsertAlign' => 'none', + 'imageManagerAllowFiles' => ['.png', '.jpg', '.jpeg', '.gif', '.bmp'], + + /* 列出指定目录下的文件 */ + 'fileManagerActionName' => 'listFile', + 'fileManagerListPath' => '/uploads/files/', + 'fileManagerUrlPrefix' => '', + 'fileManagerListSize' => 20, + 'fileManagerAllowFiles' => [ + '.png', '.jpg', '.jpeg', '.gif', '.bmp', + '.flv', '.swf', '.mkv', '.avi', '.rm', '.rmvb', '.mpeg', '.mpg', + '.ogg', '.ogv', '.mov', '.wmv', '.mp4', '.webm', '.mp3', '.wav', '.mid', + '.rar', '.zip', '.tar', '.gz', '.7z', '.bz2', '.cab', '.iso', + '.doc', '.docx', '.xls', '.xlsx', '.ppt', '.pptx', '.pdf', '.txt', '.md', '.xml', + ], + ], +]; diff --git a/config/rulong_order.php b/config/rulong_order.php new file mode 100644 index 0000000..719346b --- /dev/null +++ b/config/rulong_order.php @@ -0,0 +1,36 @@ + \App\User::class, + + /** + * 订单编号规则 + */ + 'order_orderid' => [ + 'length' => 20, + 'prefix' => '', + ], + + /** + * 退款单号规则 + */ + 'refund_orderid' => [ + 'length' => 20, + 'prefix' => 'R', + ], + + /** + * 订单自动审核 + */ + 'auto_audit' => true, + + /** + * N天后无事件的订单 可完成 + */ + 'completed_days' => 7, + + 'admin_guard' => 'rulong', +]; diff --git a/config/rulong_sms.php b/config/rulong_sms.php new file mode 100644 index 0000000..d365599 --- /dev/null +++ b/config/rulong_sms.php @@ -0,0 +1,60 @@ + false, + + // HTTP 请求的超时时间(秒) + 'timeout' => 5.0, + + // 默认发送配置 + 'default' => [ + // 网关调用策略,默认:顺序调用 + 'strategy' => \Overtrue\EasySms\Strategies\OrderStrategy::class, + // 默认可用的发送网关 + 'gateways' => [ + 'aliyun', + ], + ], + + // 验证码长度 + 'length' => 4, + + // 验证后立即失效 + 'once_used' => true, + + // 模板与通道映射 + 'template' => [ + 'DEFAULT' => 'SMS_163439005', + 'LOGIN' => '', + 'BYCODE' => 'SMS_163439024', + 'FORGOT' => 'SMS_163433753', + 'BIND' => '', + ], + + // 可用的网关配置 + 'gateways' => [ + 'errorlog' => [ + 'file' => storage_path('logs/easy-sms.log'), + ], + // 阿里云 AccessKeyID: + 'aliyun' => [ + 'access_key_id' => 'LTAIvmJMmaE7AEbD', + 'access_key_secret' => 'LCNtWTfJC2wjRQlSWrOxVku9hQmIA0', + 'sign_name' => '宝宝课', + ], + // 阿里云Rest + 'aliyunrest' => [ + 'app_key' => '', + 'app_secret_key' => '', + 'sign_name' => '', + ], + // 云片 + 'yunpian' => [ + 'api_key' => '', + 'signature' => '', + ], + // ... 具体参数请参考 https://github.com/overtrue/easy-sms/blob/master/README.md + ], +]; diff --git a/config/services.php b/config/services.php new file mode 100644 index 0000000..aa1f7f8 --- /dev/null +++ b/config/services.php @@ -0,0 +1,38 @@ + [ + 'domain' => env('MAILGUN_DOMAIN'), + 'secret' => env('MAILGUN_SECRET'), + ], + + 'ses' => [ + 'key' => env('SES_KEY'), + 'secret' => env('SES_SECRET'), + 'region' => env('SES_REGION', 'us-east-1'), + ], + + 'sparkpost' => [ + 'secret' => env('SPARKPOST_SECRET'), + ], + + 'stripe' => [ + 'model' => App\User::class, + 'key' => env('STRIPE_KEY'), + 'secret' => env('STRIPE_SECRET'), + ], + +]; diff --git a/config/session.php b/config/session.php new file mode 100644 index 0000000..48419c4 --- /dev/null +++ b/config/session.php @@ -0,0 +1,197 @@ + env('SESSION_DRIVER', 'file'), + + /* + |-------------------------------------------------------------------------- + | Session Lifetime + |-------------------------------------------------------------------------- + | + | Here you may specify the number of minutes that you wish the session + | to be allowed to remain idle before it expires. If you want them + | to immediately expire on the browser closing, set that option. + | + */ + + 'lifetime' => env('SESSION_LIFETIME', 120), + + 'expire_on_close' => false, + + /* + |-------------------------------------------------------------------------- + | Session Encryption + |-------------------------------------------------------------------------- + | + | This option allows you to easily specify that all of your session data + | should be encrypted before it is stored. All encryption will be run + | automatically by Laravel and you can use the Session like normal. + | + */ + + 'encrypt' => false, + + /* + |-------------------------------------------------------------------------- + | Session File Location + |-------------------------------------------------------------------------- + | + | When using the native session driver, we need a location where session + | files may be stored. A default has been set for you but a different + | location may be specified. This is only needed for file sessions. + | + */ + + 'files' => storage_path('framework/sessions'), + + /* + |-------------------------------------------------------------------------- + | Session Database Connection + |-------------------------------------------------------------------------- + | + | When using the "database" or "redis" session drivers, you may specify a + | connection that should be used to manage these sessions. This should + | correspond to a connection in your database configuration options. + | + */ + + 'connection' => env('SESSION_CONNECTION', null), + + /* + |-------------------------------------------------------------------------- + | Session Database Table + |-------------------------------------------------------------------------- + | + | When using the "database" session driver, you may specify the table we + | should use to manage the sessions. Of course, a sensible default is + | provided for you; however, you are free to change this as needed. + | + */ + + 'table' => 'sessions', + + /* + |-------------------------------------------------------------------------- + | Session Cache Store + |-------------------------------------------------------------------------- + | + | When using the "apc" or "memcached" session drivers, you may specify a + | cache store that should be used for these sessions. This value must + | correspond with one of the application's configured cache stores. + | + */ + + 'store' => env('SESSION_STORE', null), + + /* + |-------------------------------------------------------------------------- + | Session Sweeping Lottery + |-------------------------------------------------------------------------- + | + | Some session drivers must manually sweep their storage location to get + | rid of old sessions from storage. Here are the chances that it will + | happen on a given request. By default, the odds are 2 out of 100. + | + */ + + 'lottery' => [2, 100], + + /* + |-------------------------------------------------------------------------- + | Session Cookie Name + |-------------------------------------------------------------------------- + | + | Here you may change the name of the cookie used to identify a session + | instance by ID. The name specified here will get used every time a + | new session cookie is created by the framework for every driver. + | + */ + + 'cookie' => env( + 'SESSION_COOKIE', + str_slug(env('APP_NAME', 'laravel'), '_') . '_session' + ), + + /* + |-------------------------------------------------------------------------- + | Session Cookie Path + |-------------------------------------------------------------------------- + | + | The session cookie path determines the path for which the cookie will + | be regarded as available. Typically, this will be the root path of + | your application but you are free to change this when necessary. + | + */ + + 'path' => '/', + + /* + |-------------------------------------------------------------------------- + | Session Cookie Domain + |-------------------------------------------------------------------------- + | + | Here you may change the domain of the cookie used to identify a session + | in your application. This will determine which domains the cookie is + | available to in your application. A sensible default has been set. + | + */ + + 'domain' => env('SESSION_DOMAIN', null), + + /* + |-------------------------------------------------------------------------- + | HTTPS Only Cookies + |-------------------------------------------------------------------------- + | + | By setting this option to true, session cookies will only be sent back + | to the server if the browser has a HTTPS connection. This will keep + | the cookie from being sent to you if it can not be done securely. + | + */ + + 'secure' => env('SESSION_SECURE_COOKIE', false), + + /* + |-------------------------------------------------------------------------- + | HTTP Access Only + |-------------------------------------------------------------------------- + | + | Setting this value to true will prevent JavaScript from accessing the + | value of the cookie and the cookie will only be accessible through + | the HTTP protocol. You are free to modify this option if needed. + | + */ + + 'http_only' => true, + + /* + |-------------------------------------------------------------------------- + | Same-Site Cookies + |-------------------------------------------------------------------------- + | + | This option determines how your cookies behave when cross-site requests + | take place, and can be used to mitigate CSRF attacks. By default, we + | do not enable this as other CSRF protection services are in place. + | + | Supported: "lax", "strict" + | + */ + + 'same_site' => null, + +]; diff --git a/config/user_account.php b/config/user_account.php new file mode 100644 index 0000000..749d8cf --- /dev/null +++ b/config/user_account.php @@ -0,0 +1,42 @@ + \App\User::class, + + /** + * 账户是否可以为负数 + */ + 'can_minus' => [ + 'cash' => false, + 'score' => true, + 'act_a' => false, + 'act_b' => true, + 'act_c' => true, + 'act_d' => true, + ], + + /** + * 是否立即扣款 + */ + 'deductions' => false, + + /** + * 账户类型 + */ + 'account_type' => [ + 'cash' => '现金账户', + 'score' => '积分账户', + 'act_a' => '满仓次数', + 'act_b' => '预留账户', + 'act_c' => '预留账户', + 'act_d' => '预留账户', + ], +]; diff --git a/config/user_relation.php b/config/user_relation.php new file mode 100644 index 0000000..a4cfdf0 --- /dev/null +++ b/config/user_relation.php @@ -0,0 +1,18 @@ + \App\User::class, + + /** + * 默认推荐人 + */ + 'default_parent_id' => 0, +]; diff --git a/config/view.php b/config/view.php new file mode 100644 index 0000000..2acfd9c --- /dev/null +++ b/config/view.php @@ -0,0 +1,33 @@ + [ + resource_path('views'), + ], + + /* + |-------------------------------------------------------------------------- + | Compiled View Path + |-------------------------------------------------------------------------- + | + | This option determines where all the compiled Blade templates will be + | stored for your application. Typically, this is within the storage + | directory. However, as usual, you are free to change this value. + | + */ + + 'compiled' => realpath(storage_path('framework/views')), + +]; diff --git a/config/wechat.php b/config/wechat.php new file mode 100644 index 0000000..331544d --- /dev/null +++ b/config/wechat.php @@ -0,0 +1,139 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +return [ + /* + * 默认配置,将会合并到各模块中 + */ + 'defaults' => [ + /* + * 指定 API 调用返回结果的类型:array(default)/collection/object/raw/自定义类名 + */ + 'response_type' => 'collection', + + /* + * 使用 Laravel 的缓存系统 + */ + 'use_laravel_cache' => true, + + /* + * 日志配置 + * + * level: 日志级别,可选为: + * debug/info/notice/warning/error/critical/alert/emergency + * file:日志文件位置(绝对路径!!!),要求可写权限 + */ + 'log' => [ + 'level' => env('WECHAT_LOG_LEVEL', 'error'), + 'file' => env('WECHAT_LOG_FILE', storage_path('logs/wechat.log')), + ], + ], + + /* + * 路由配置 + */ + 'route' => [ + /* + * 开放平台第三方平台路由配置 + */ + // 'open_platform' => [ + // 'uri' => 'serve', + // 'action' => Overtrue\LaravelWeChat\Controllers\OpenPlatformController::class, + // 'attributes' => [ + // 'prefix' => 'open-platform', + // 'middleware' => null, + // ], + // ], + ], + + /* + * 公众号 + */ + 'official_account' => [ + 'default' => [ + 'app_id' => env('WECHAT_OFFICIAL_ACCOUNT_APPID', 'your-app-id'), // AppID + 'secret' => env('WECHAT_OFFICIAL_ACCOUNT_SECRET', 'your-app-secret'), // AppSecret + 'token' => env('WECHAT_OFFICIAL_ACCOUNT_TOKEN', 'your-token'), // Token + 'aes_key' => env('WECHAT_OFFICIAL_ACCOUNT_AES_KEY', ''), // EncodingAESKey + + /* + * OAuth 配置 + * + * scopes:公众平台(snsapi_userinfo / snsapi_base),开放平台:snsapi_login + * callback:OAuth授权完成后的回调页地址(如果使用中间件,则随便填写。。。) + */ + // 'oauth' => [ + // 'scopes' => array_map('trim', explode(',', env('WECHAT_OFFICIAL_ACCOUNT_OAUTH_SCOPES', 'snsapi_userinfo'))), + // 'callback' => env('WECHAT_OFFICIAL_ACCOUNT_OAUTH_CALLBACK', '/examples/oauth_callback.php'), + // ], + ], + ], + + /* + * 开放平台第三方平台 + */ + // 'open_platform' => [ + // 'default' => [ + // 'app_id' => env('WECHAT_OPEN_PLATFORM_APPID', ''), + // 'secret' => env('WECHAT_OPEN_PLATFORM_SECRET', ''), + // 'token' => env('WECHAT_OPEN_PLATFORM_TOKEN', ''), + // 'aes_key' => env('WECHAT_OPEN_PLATFORM_AES_KEY', ''), + // ], + // ], + /* + * 小程序 + */ + 'mini_program' => [ + 'default' => [ + 'app_id' => env('WECHAT_MINI_PROGRAM_APPID', 'wx254bc1018ea4412a'), + 'secret' => env('WECHAT_MINI_PROGRAM_SECRET', '191dcb8bdd6fab07d989f4a78a3d8a61'), + 'token' => env('WECHAT_MINI_PROGRAM_TOKEN', 'BiX5ygs8lIOP6EtrKF6kCktebp7rWgzy'), + 'aes_key' => env('WECHAT_MINI_PROGRAM_AES_KEY', 'pEiJGppqDo2G9svNUWB2cLpxwKewoCjXPSsS9Y7mbCQ'), + ], + ], + + /* + * 微信支付 + */ + 'payment' => [ + 'default' => [ + 'sandbox' => env('WECHAT_PAYMENT_SANDBOX', false), + 'app_id' => env('WECHAT_PAYMENT_APPID', ''), + 'mch_id' => env('WECHAT_PAYMENT_MCH_ID', 'your-mch-id'), + 'key' => env('WECHAT_PAYMENT_KEY', 'key-for-signature'), + 'cert_path' => env('WECHAT_PAYMENT_CERT_PATH', 'path/to/cert/apiclient_cert.pem'), // XXX: 绝对路径!!!! + 'key_path' => env('WECHAT_PAYMENT_KEY_PATH', 'path/to/cert/apiclient_key.pem'), // XXX: 绝对路径!!!! + 'notify_url' => 'http://example.com/payments/wechat-notify', // 默认支付结果通知地址 + ], + 'mini' => [ + 'sandbox' => env('WECHAT_PAYMENT_MINI_SANDBOX', false), + 'app_id' => env('WECHAT_PAYMENT_MINI_APPID', ''), + 'mch_id' => env('WECHAT_PAYMENT_MINI_MCH_ID', 'your-mch-id'), + 'key' => env('WECHAT_PAYMENT_MINI_KEY', 'key-for-signature'), + 'cert_path' => env('WECHAT_PAYMENT_MINI_CERT_PATH', 'path/to/cert/apiclient_cert.pem'), // XXX: 绝对路径!!!! + 'key_path' => env('WECHAT_PAYMENT_MINI_KEY_PATH', 'path/to/cert/apiclient_key.pem'), // XXX: 绝对路径!!!! + 'notify_url' => 'http://example.com/payments/wechat-notify', // 默认支付结果通知地址 + ], + // ... + ], + + /* + * 企业微信 + */ + // 'work' => [ + // 'default' => [ + // 'corp_id' => 'xxxxxxxxxxxxxxxxx', + /// 'agent_id' => 100020, + // 'secret' => env('WECHAT_WORK_AGENT_CONTACTS_SECRET', ''), + // //... + // ], + // ], +]; diff --git a/database/.gitignore b/database/.gitignore new file mode 100644 index 0000000..9b1dffd --- /dev/null +++ b/database/.gitignore @@ -0,0 +1 @@ +*.sqlite diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php new file mode 100644 index 0000000..facf233 --- /dev/null +++ b/database/factories/UserFactory.php @@ -0,0 +1,23 @@ +define(App\User::class, function (Faker $faker) { + return [ + 'name' => $faker->name, + 'email' => $faker->unique()->safeEmail, + 'password' => '$2y$10$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm', // secret + 'remember_token' => str_random(10), + ]; +}); diff --git a/database/migrations/0000_00_00_000000_create_admin_tables.php b/database/migrations/0000_00_00_000000_create_admin_tables.php new file mode 100644 index 0000000..81ba935 --- /dev/null +++ b/database/migrations/0000_00_00_000000_create_admin_tables.php @@ -0,0 +1,94 @@ +increments('id'); + $table->string('username', 32); + $table->string('password'); + $table->string('nickname', 32)->nullable(); + $table->string('remember_token')->nullable(); + $table->timestamps(); + $table->softDeletes(); + }); + + Schema::create('admin_logins', function (Blueprint $table) { + $table->increments('id'); + $table->integer('admin_id')->unsigned(); + $table->string('login_ip', 15)->nullable(); + $table->timestamp('created_at')->nullable(); + }); + + Schema::create('admin_menus', function (Blueprint $table) { + $table->increments('id'); + $table->integer('parent_id')->unsigned(); + $table->string('title', 64); + $table->integer('sort')->unsigned(); + $table->string('uri')->nullable(); + $table->timestamps(); + }); + + Schema::create('admin_operation_logs', function (Blueprint $table) { + $table->bigInteger('id', true)->unsigned(); + $table->integer('admin_id')->unsigned()->index(); + $table->string('path'); + $table->string('method', 10); + $table->string('ip', 15); + $table->text('input')->nullable(); + $table->timestamp('created_at')->nullable(); + }); + + Schema::create('admin_roles', function (Blueprint $table) { + $table->increments('id'); + $table->string('name', 64); + $table->string('description')->nullable(); + $table->text('rules')->nullable(); + $table->timestamps(); + $table->softDeletes(); + }); + + Schema::create('admin_role_user', function (Blueprint $table) { + $table->integer('role_id')->unsigned(); + $table->integer('admin_id')->unsigned(); + $table->timestamps(); + $table->primary(['role_id', 'admin_id']); + }); + + Schema::create('storages', function (Blueprint $table) { + $table->increments('id'); + $table->string('name', 255); + $table->string('hash', 32)->index(); + $table->string('type', 32); + $table->integer('size')->unsigned(); + $table->string('path', 255); + $table->timestamp('created_at')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::disableForeignKeyConstraints(); + Schema::drop('admins'); + Schema::drop('admin_logins'); + Schema::drop('admin_menus'); + Schema::drop('admin_operation_logs'); + Schema::drop('admin_roles'); + Schema::drop('admin_role_user'); + } +} diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php new file mode 100644 index 0000000..16a6108 --- /dev/null +++ b/database/migrations/2014_10_12_000000_create_users_table.php @@ -0,0 +1,36 @@ +increments('id'); + $table->string('name'); + $table->string('email')->unique(); + $table->timestamp('email_verified_at')->nullable(); + $table->string('password'); + $table->rememberToken(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('users'); + } +} diff --git a/database/migrations/2014_10_12_100000_create_password_resets_table.php b/database/migrations/2014_10_12_100000_create_password_resets_table.php new file mode 100644 index 0000000..0d5cb84 --- /dev/null +++ b/database/migrations/2014_10_12_100000_create_password_resets_table.php @@ -0,0 +1,32 @@ +string('email')->index(); + $table->string('token'); + $table->timestamp('created_at')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('password_resets'); + } +} diff --git a/database/migrations/2018_06_29_032244_create_laravel_follow_tables.php b/database/migrations/2018_06_29_032244_create_laravel_follow_tables.php new file mode 100644 index 0000000..9264f69 --- /dev/null +++ b/database/migrations/2018_06_29_032244_create_laravel_follow_tables.php @@ -0,0 +1,50 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +use Illuminate\Database\Schema\Blueprint; +use Illuminate\Database\Migrations\Migration; + +class CreateLaravelFollowTables extends Migration +{ + /** + * Run the migrations. + */ + public function up() + { + Schema::create(config('follow.followable_table', 'followables'), function (Blueprint $table) { + $userForeignKey = config('follow.users_table_foreign_key', 'user_id'); + $table->unsignedInteger($userForeignKey); + $table->unsignedInteger('followable_id'); + $table->string('followable_type')->index(); + $table->string('relation')->default('follow')->comment('follow/like/subscribe/favorite/upvote/downvote'); + $table->softDeletes(); + $table->timestamps(); + + $table->foreign($userForeignKey) + ->references(config('follow.users_table_primary_key', 'id')) + ->on(config('follow.users_table_name', 'users')) + ->onUpdate('cascade') + ->onDelete('cascade'); + }); + } + + /** + * Reverse the migrations. + */ + public function down() + { + Schema::table(config('follow.followable_table', 'followables'), function ($table) { + $table->dropForeign(config('follow.followable_table', 'followables').'_user_id_foreign'); + }); + + Schema::drop(config('follow.followable_table', 'followables')); + } +} diff --git a/database/migrations/2018_10_31_071131_create_bonuses_table.php b/database/migrations/2018_10_31_071131_create_bonuses_table.php new file mode 100644 index 0000000..ae647c7 --- /dev/null +++ b/database/migrations/2018_10_31_071131_create_bonuses_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('bonuses'); + } +} diff --git a/database/migrations/2018_10_31_071802_create_bonus_logs_table.php b/database/migrations/2018_10_31_071802_create_bonus_logs_table.php new file mode 100644 index 0000000..1ead485 --- /dev/null +++ b/database/migrations/2018_10_31_071802_create_bonus_logs_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('bonus_logs'); + } +} diff --git a/database/migrations/2018_11_01_075350_create_goods_table.php b/database/migrations/2018_11_01_075350_create_goods_table.php new file mode 100644 index 0000000..d853b0e --- /dev/null +++ b/database/migrations/2018_11_01_075350_create_goods_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('goods'); + } +} diff --git a/database/migrations/2018_11_02_040159_create_user_infos_table.php b/database/migrations/2018_11_02_040159_create_user_infos_table.php new file mode 100644 index 0000000..b400808 --- /dev/null +++ b/database/migrations/2018_11_02_040159_create_user_infos_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('user_infos'); + } +} diff --git a/database/migrations/2018_11_02_040559_create_user_logins_table.php b/database/migrations/2018_11_02_040559_create_user_logins_table.php new file mode 100644 index 0000000..85cbb8e --- /dev/null +++ b/database/migrations/2018_11_02_040559_create_user_logins_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('user_logins'); + } +} diff --git a/database/migrations/2018_11_05_094221_create_notifications_table.php b/database/migrations/2018_11_05_094221_create_notifications_table.php new file mode 100644 index 0000000..fb16d5b --- /dev/null +++ b/database/migrations/2018_11_05_094221_create_notifications_table.php @@ -0,0 +1,35 @@ +uuid('id')->primary(); + $table->string('type'); + $table->morphs('notifiable'); + $table->text('data'); + $table->timestamp('read_at')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('notifications'); + } +} diff --git a/database/migrations/2018_11_05_094255_create_jobs_table.php b/database/migrations/2018_11_05_094255_create_jobs_table.php new file mode 100644 index 0000000..58d7715 --- /dev/null +++ b/database/migrations/2018_11_05_094255_create_jobs_table.php @@ -0,0 +1,36 @@ +bigIncrements('id'); + $table->string('queue')->index(); + $table->longText('payload'); + $table->unsignedTinyInteger('attempts'); + $table->unsignedInteger('reserved_at')->nullable(); + $table->unsignedInteger('available_at'); + $table->unsignedInteger('created_at'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('jobs'); + } +} diff --git a/database/migrations/2018_11_05_095605_create_categories_table.php b/database/migrations/2018_11_05_095605_create_categories_table.php new file mode 100644 index 0000000..47fea4d --- /dev/null +++ b/database/migrations/2018_11_05_095605_create_categories_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('categories'); + } +} diff --git a/database/migrations/2018_11_05_134432_create_payments_table.php b/database/migrations/2018_11_05_134432_create_payments_table.php new file mode 100644 index 0000000..089e7d3 --- /dev/null +++ b/database/migrations/2018_11_05_134432_create_payments_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('payments'); + } +} diff --git a/database/migrations/2018_11_06_102939_create_articles_table.php b/database/migrations/2018_11_06_102939_create_articles_table.php new file mode 100644 index 0000000..e9bc644 --- /dev/null +++ b/database/migrations/2018_11_06_102939_create_articles_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('articles'); + } +} diff --git a/database/migrations/2018_11_08_094531_create_adverts_table.php b/database/migrations/2018_11_08_094531_create_adverts_table.php new file mode 100644 index 0000000..04046ea --- /dev/null +++ b/database/migrations/2018_11_08_094531_create_adverts_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('adverts'); + } +} diff --git a/database/migrations/2018_11_08_163936_create_withdraws_table.php b/database/migrations/2018_11_08_163936_create_withdraws_table.php new file mode 100644 index 0000000..9bf3980 --- /dev/null +++ b/database/migrations/2018_11_08_163936_create_withdraws_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('withdraws'); + } +} diff --git a/database/migrations/2018_11_12_103310_create_profit_logs_table.php b/database/migrations/2018_11_12_103310_create_profit_logs_table.php new file mode 100644 index 0000000..ae20843 --- /dev/null +++ b/database/migrations/2018_11_12_103310_create_profit_logs_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('profit_logs'); + } +} diff --git a/database/migrations/2018_11_13_162409_create_params_table.php b/database/migrations/2018_11_13_162409_create_params_table.php new file mode 100644 index 0000000..117dac4 --- /dev/null +++ b/database/migrations/2018_11_13_162409_create_params_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('params'); + } +} diff --git a/database/migrations/2018_11_14_140722_create_failed_jobs_table.php b/database/migrations/2018_11_14_140722_create_failed_jobs_table.php new file mode 100644 index 0000000..d432dff --- /dev/null +++ b/database/migrations/2018_11_14_140722_create_failed_jobs_table.php @@ -0,0 +1,35 @@ +bigIncrements('id'); + $table->text('connection'); + $table->text('queue'); + $table->longText('payload'); + $table->longText('exception'); + $table->timestamp('failed_at')->useCurrent(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('failed_jobs'); + } +} diff --git a/database/migrations/2018_11_15_114829_create_wechat_menus_table.php b/database/migrations/2018_11_15_114829_create_wechat_menus_table.php new file mode 100644 index 0000000..63b798e --- /dev/null +++ b/database/migrations/2018_11_15_114829_create_wechat_menus_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('wechat_menus'); + } +} diff --git a/database/migrations/2018_11_16_144356_create_freights_table.php b/database/migrations/2018_11_16_144356_create_freights_table.php new file mode 100644 index 0000000..aa1697b --- /dev/null +++ b/database/migrations/2018_11_16_144356_create_freights_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('freights'); + } +} diff --git a/database/migrations/2018_11_16_144715_create_shops_table.php b/database/migrations/2018_11_16_144715_create_shops_table.php new file mode 100644 index 0000000..9872367 --- /dev/null +++ b/database/migrations/2018_11_16_144715_create_shops_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('shops'); + } +} diff --git a/database/migrations/2018_11_19_164350_create_goods_params_table.php b/database/migrations/2018_11_19_164350_create_goods_params_table.php new file mode 100644 index 0000000..834d0d0 --- /dev/null +++ b/database/migrations/2018_11_19_164350_create_goods_params_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('goods_params'); + } +} diff --git a/database/migrations/2018_11_30_101708_create_windups_table.php b/database/migrations/2018_11_30_101708_create_windups_table.php new file mode 100644 index 0000000..62e661c --- /dev/null +++ b/database/migrations/2018_11_30_101708_create_windups_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('windups'); + } +} diff --git a/database/migrations/2018_12_04_134435_create_vip_paments_table.php b/database/migrations/2018_12_04_134435_create_vip_paments_table.php new file mode 100644 index 0000000..a9f0e13 --- /dev/null +++ b/database/migrations/2018_12_04_134435_create_vip_paments_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('vip_paments'); + } +} diff --git a/database/migrations/2018_12_23_141904_create_cdkeys_table.php b/database/migrations/2018_12_23_141904_create_cdkeys_table.php new file mode 100644 index 0000000..eb1183e --- /dev/null +++ b/database/migrations/2018_12_23_141904_create_cdkeys_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('cdkeys'); + } +} diff --git a/database/migrations/2018_12_24_142116_create_keys_orders_table.php b/database/migrations/2018_12_24_142116_create_keys_orders_table.php new file mode 100644 index 0000000..912f637 --- /dev/null +++ b/database/migrations/2018_12_24_142116_create_keys_orders_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('keys_orders'); + } +} diff --git a/database/migrations/2018_12_24_184126_create_keys_applies_table.php b/database/migrations/2018_12_24_184126_create_keys_applies_table.php new file mode 100644 index 0000000..ecc1685 --- /dev/null +++ b/database/migrations/2018_12_24_184126_create_keys_applies_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('keys_applies'); + } +} diff --git a/database/migrations/2019_01_08_113013_create_activities_table.php b/database/migrations/2019_01_08_113013_create_activities_table.php new file mode 100644 index 0000000..e70491a --- /dev/null +++ b/database/migrations/2019_01_08_113013_create_activities_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('activities'); + } +} diff --git a/database/migrations/2019_01_08_113723_create_activity_gifts_table.php b/database/migrations/2019_01_08_113723_create_activity_gifts_table.php new file mode 100644 index 0000000..f9ae655 --- /dev/null +++ b/database/migrations/2019_01_08_113723_create_activity_gifts_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('activity_gifts'); + } +} diff --git a/database/migrations/2019_01_11_141709_create_tests_table.php b/database/migrations/2019_01_11_141709_create_tests_table.php new file mode 100644 index 0000000..09153a8 --- /dev/null +++ b/database/migrations/2019_01_11_141709_create_tests_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('tests'); + } +} diff --git a/database/migrations/2019_01_14_170609_create_sales_reports_table.php b/database/migrations/2019_01_14_170609_create_sales_reports_table.php new file mode 100644 index 0000000..036cc8f --- /dev/null +++ b/database/migrations/2019_01_14_170609_create_sales_reports_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('sales_reports'); + } +} diff --git a/database/migrations/2019_01_24_105629_create_windup_reports_table.php b/database/migrations/2019_01_24_105629_create_windup_reports_table.php new file mode 100644 index 0000000..66d7770 --- /dev/null +++ b/database/migrations/2019_01_24_105629_create_windup_reports_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('windup_reports'); + } +} diff --git a/database/migrations/2019_02_12_094626_create_coupon_infos_table.php b/database/migrations/2019_02_12_094626_create_coupon_infos_table.php new file mode 100644 index 0000000..3770a3d --- /dev/null +++ b/database/migrations/2019_02_12_094626_create_coupon_infos_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('coupon_infos'); + } +} diff --git a/database/migrations/2019_02_12_094635_create_coupon_logs_table.php b/database/migrations/2019_02_12_094635_create_coupon_logs_table.php new file mode 100644 index 0000000..0ba7492 --- /dev/null +++ b/database/migrations/2019_02_12_094635_create_coupon_logs_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('coupon_logs'); + } +} diff --git a/database/migrations/2019_02_12_094713_create_coupon_uses_table.php b/database/migrations/2019_02_12_094713_create_coupon_uses_table.php new file mode 100644 index 0000000..062d320 --- /dev/null +++ b/database/migrations/2019_02_12_094713_create_coupon_uses_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('coupon_uses'); + } +} diff --git a/database/migrations/2019_02_12_094728_create_coupon_user_logs_table.php b/database/migrations/2019_02_12_094728_create_coupon_user_logs_table.php new file mode 100644 index 0000000..514b111 --- /dev/null +++ b/database/migrations/2019_02_12_094728_create_coupon_user_logs_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('coupon_user_logs'); + } +} diff --git a/database/migrations/2019_02_12_101447_create_coupon_rules_table.php b/database/migrations/2019_02_12_101447_create_coupon_rules_table.php new file mode 100644 index 0000000..ab8efbb --- /dev/null +++ b/database/migrations/2019_02_12_101447_create_coupon_rules_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('coupon_rules'); + } +} diff --git a/database/migrations/2019_03_07_133921_create_seller_lessons_table.php b/database/migrations/2019_03_07_133921_create_seller_lessons_table.php new file mode 100644 index 0000000..fdd57dd --- /dev/null +++ b/database/migrations/2019_03_07_133921_create_seller_lessons_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('seller_lessons'); + } +} diff --git a/database/migrations/2019_03_08_094116_create_seller_lesson_logs_table.php b/database/migrations/2019_03_08_094116_create_seller_lesson_logs_table.php new file mode 100644 index 0000000..7a0ee1a --- /dev/null +++ b/database/migrations/2019_03_08_094116_create_seller_lesson_logs_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('seller_lesson_logs'); + } +} diff --git a/database/migrations/2019_03_11_092933_create_activity_logs_table.php b/database/migrations/2019_03_11_092933_create_activity_logs_table.php new file mode 100644 index 0000000..6716ef2 --- /dev/null +++ b/database/migrations/2019_03_11_092933_create_activity_logs_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('activity_logs'); + } +} diff --git a/database/migrations/2019_03_13_140653_create_favorites_table.php b/database/migrations/2019_03_13_140653_create_favorites_table.php new file mode 100644 index 0000000..91e325f --- /dev/null +++ b/database/migrations/2019_03_13_140653_create_favorites_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('favorites'); + } +} diff --git a/database/migrations/2019_03_19_133501_create_seller_teachers_table.php b/database/migrations/2019_03_19_133501_create_seller_teachers_table.php new file mode 100644 index 0000000..037e03a --- /dev/null +++ b/database/migrations/2019_03_19_133501_create_seller_teachers_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('seller_teachers'); + } +} diff --git a/database/migrations/2019_03_25_150603_create_teams_table.php b/database/migrations/2019_03_25_150603_create_teams_table.php new file mode 100644 index 0000000..ee7127f --- /dev/null +++ b/database/migrations/2019_03_25_150603_create_teams_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('teams'); + } +} diff --git a/database/migrations/2019_03_27_105309_create_lotteries_table.php b/database/migrations/2019_03_27_105309_create_lotteries_table.php new file mode 100644 index 0000000..7a7089d --- /dev/null +++ b/database/migrations/2019_03_27_105309_create_lotteries_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('lotteries'); + } +} diff --git a/database/migrations/2019_03_27_105326_create_lottery_logs_table.php b/database/migrations/2019_03_27_105326_create_lottery_logs_table.php new file mode 100644 index 0000000..c3042ea --- /dev/null +++ b/database/migrations/2019_03_27_105326_create_lottery_logs_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('lottery_logs'); + } +} diff --git a/database/migrations/2019_03_27_105338_create_lottery_gifts_table.php b/database/migrations/2019_03_27_105338_create_lottery_gifts_table.php new file mode 100644 index 0000000..abb67ae --- /dev/null +++ b/database/migrations/2019_03_27_105338_create_lottery_gifts_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('lottery_gifts'); + } +} diff --git a/database/migrations/2019_04_03_144642_create_models_agencies_table.php b/database/migrations/2019_04_03_144642_create_models_agencies_table.php new file mode 100644 index 0000000..19b6f5a --- /dev/null +++ b/database/migrations/2019_04_03_144642_create_models_agencies_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('models_agencies'); + } +} diff --git a/database/migrations/2019_04_03_145024_create_agencies_table.php b/database/migrations/2019_04_03_145024_create_agencies_table.php new file mode 100644 index 0000000..4920b8c --- /dev/null +++ b/database/migrations/2019_04_03_145024_create_agencies_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('agencies'); + } +} diff --git a/database/migrations/2019_04_09_131834_create_reports_table.php b/database/migrations/2019_04_09_131834_create_reports_table.php new file mode 100644 index 0000000..d3cae48 --- /dev/null +++ b/database/migrations/2019_04_09_131834_create_reports_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('reports'); + } +} diff --git a/database/migrations/2019_04_09_131905_create_report_logs_table.php b/database/migrations/2019_04_09_131905_create_report_logs_table.php new file mode 100644 index 0000000..1ea6d57 --- /dev/null +++ b/database/migrations/2019_04_09_131905_create_report_logs_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('report_logs'); + } +} diff --git a/database/migrations/2019_05_05_115944_create_user_babies_table.php b/database/migrations/2019_05_05_115944_create_user_babies_table.php new file mode 100644 index 0000000..9c1dadd --- /dev/null +++ b/database/migrations/2019_05_05_115944_create_user_babies_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('user_babies'); + } +} diff --git a/database/seeds/DatabaseSeeder.php b/database/seeds/DatabaseSeeder.php new file mode 100644 index 0000000..91cb6d1 --- /dev/null +++ b/database/seeds/DatabaseSeeder.php @@ -0,0 +1,16 @@ +call(UsersTableSeeder::class); + } +} diff --git a/packages/bonus/README.md b/packages/bonus/README.md new file mode 100644 index 0000000..6cc270d --- /dev/null +++ b/packages/bonus/README.md @@ -0,0 +1,2 @@ +# Bonus 奖金结算系统 + diff --git a/packages/bonus/composer.json b/packages/bonus/composer.json new file mode 100644 index 0000000..ff05785 --- /dev/null +++ b/packages/bonus/composer.json @@ -0,0 +1,28 @@ +{ + "name": "rulong/bonus", + "description": "", + "license": "MIT", + "authors": [ + { + "name": "C.Jason", + "email": "chenjxlg@163.com" + } + ], + "require": { + "php": ">=7.1.3", + "rulong/user-account": "^1.0", + "laravel/framework": "*" + }, + "autoload": { + "psr-0": { + "RuLong\\Bonus": "src/" + } + }, + "extra": { + "laravel": { + "providers": [ + "RuLong\\Bonus\\ServiceProvider" + ] + } + } +} diff --git a/packages/bonus/config/rulong_bonus.php b/packages/bonus/config/rulong_bonus.php new file mode 100644 index 0000000..df6f2bf --- /dev/null +++ b/packages/bonus/config/rulong_bonus.php @@ -0,0 +1,18 @@ + \App\User::class, + 'Settlement' => [ + 'Direct' => [ + 'integral' => 200, + 'layer' => 2, //两级分润 + 'point' => [ + '1' => 100, + '2' => 15, + ], + ], + 'Repeat' => 0.1, + ], + 'full_point' => 10, + +]; diff --git a/packages/bonus/src/Bonus.php b/packages/bonus/src/Bonus.php new file mode 100644 index 0000000..ceb67d9 --- /dev/null +++ b/packages/bonus/src/Bonus.php @@ -0,0 +1,20 @@ +settlement = $settlement; + } + + public function __destruct() + { + $this->settlement->fire(); + } +} diff --git a/packages/bonus/src/Contracts/Settlement.php b/packages/bonus/src/Contracts/Settlement.php new file mode 100644 index 0000000..e4ec366 --- /dev/null +++ b/packages/bonus/src/Contracts/Settlement.php @@ -0,0 +1,15 @@ + + * @Date:2018-10-31T14:22:48+0800 + */ + function fire(); + +} diff --git a/packages/bonus/src/Demo/这里放结算示例 b/packages/bonus/src/Demo/这里放结算示例 new file mode 100644 index 0000000..e69de29 diff --git a/packages/bonus/src/Models/Bonus.php b/packages/bonus/src/Models/Bonus.php new file mode 100644 index 0000000..56b67b8 --- /dev/null +++ b/packages/bonus/src/Models/Bonus.php @@ -0,0 +1,29 @@ + 'array', + 'configs' => 'array', + ]; + + public function logs() + { + return $this->hasMany(BonusLog::class); + } + +} diff --git a/packages/bonus/src/Models/BonusLog.php b/packages/bonus/src/Models/BonusLog.php new file mode 100644 index 0000000..a12f9dc --- /dev/null +++ b/packages/bonus/src/Models/BonusLog.php @@ -0,0 +1,21 @@ +belongsTo(Bonus::class); + } + + public function user() + { + return $this->belongsTo(config('rulong_bonus.user_model')); + } +} diff --git a/packages/bonus/src/ServiceProvider.php b/packages/bonus/src/ServiceProvider.php new file mode 100644 index 0000000..af28602 --- /dev/null +++ b/packages/bonus/src/ServiceProvider.php @@ -0,0 +1,34 @@ + + * @Date:2018-06-22T16:01:20+0800 + * @return [type] [description] + */ + public function boot() + { + if ($this->app->runningInConsole()) { + $this->publishes([__DIR__ . '/../config/rulong_bonus.php' => config_path('rulong_bonus.php')]); + $this->loadMigrationsFrom(__DIR__ . '/../database/migrations/'); + } + } + + /** + * 注册服务提供者 + * @Author: + * @Date:2018-06-22T16:01:12+0800 + * @return [type] [description] + */ + public function register() + { + $this->mergeConfigFrom(__DIR__ . '/../config/rulong_bonus.php', 'rulong_bonus'); + } +} diff --git a/packages/bonus/src/Traits/BloodLine.php b/packages/bonus/src/Traits/BloodLine.php new file mode 100644 index 0000000..4c0781d --- /dev/null +++ b/packages/bonus/src/Traits/BloodLine.php @@ -0,0 +1,20 @@ +strLine); + return UserRelation::whereIn('user_id', $lineArray)->orderBy('layer', 'desc')->limit($layer)->get(); + } + + public function getDownBloodLine($user, $layer) + { + #Todo... + return UserRelation::where('bloodline', 'like', "%," . $user->id . ",%")->whereBetween('layer', [$user->relation->layer, $user->relation->layer + $layer])->orderBy('layer', 'asc')->get(); + } +} diff --git a/packages/bonus/src/Traits/Settlementable.php b/packages/bonus/src/Traits/Settlementable.php new file mode 100644 index 0000000..39fbe03 --- /dev/null +++ b/packages/bonus/src/Traits/Settlementable.php @@ -0,0 +1,14 @@ +identityUpdate(Identity_id,Channel) // (身份ID,变更渠道) +# 身份加权点数 $User->addPoint(Identity_id,Point) // (身份ID,加权数额:默认1) diff --git a/packages/coupon/composer.json b/packages/coupon/composer.json new file mode 100644 index 0000000..38e4a36 --- /dev/null +++ b/packages/coupon/composer.json @@ -0,0 +1,27 @@ +{ + "name": "rulong/coupon", + "description": "", + "license": "MIT", + "authors": [ + { + "name": "C.Jason", + "email": "chenjxlg@163.com" + } + ], + "require": { + "php": ">=7.1.3", + "laravel/framework": "*" + }, + "autoload": { + "psr-0": { + "RuLong\\Coupon": "src/" + } + }, + "extra": { + "laravel": { + "providers": [ + "RuLong\\Coupon\\ServiceProvider" + ] + } + } +} diff --git a/packages/coupon/config/rulong_coupon.php b/packages/coupon/config/rulong_coupon.php new file mode 100644 index 0000000..956b6b4 --- /dev/null +++ b/packages/coupon/config/rulong_coupon.php @@ -0,0 +1,19 @@ + \App\User::class, + 'type' => [ + 'direct' => '直购', + 'discount' => '折扣', + 'reduction' => '满减', + 'lesson' => '报名课程', + 'lottery' => '抽奖', + ], + 'time_type' => [ + 'specified' => '指定时间', + 'obtain' => '获取后', + ], + 'channel' => [ + 'Buy' => '购买', + 'Gift' => '赠与', + ], +]; diff --git a/packages/coupon/src/Coupon.php b/packages/coupon/src/Coupon.php new file mode 100644 index 0000000..a9c1e9f --- /dev/null +++ b/packages/coupon/src/Coupon.php @@ -0,0 +1,17 @@ +type] ?? '无'; + } + + public function seller() + { + return $this->belongsTo(Seller::class)->withDefault(); + } + + public function getStateAttribute() + { + + //下架 + if ($this->status != 1) { + return 2; + } + + //未开始 + if ($this->start_at > now()) { + return 0; + } + + //已结束 + if ($this->end_at < now()) { + return -1; + } + + //正常 + if ($this->start_at <= now() && $this->end_at >= now()) { + return 1; + } + } + + protected function getStatusTextAttribute() + { + + if ($this->state === 0) { + return "未开始"; + } elseif ($this->state == 1) { + return "正常"; + } elseif ($this->state == -1) { + return "已过期"; + } elseif ($this->state == 2) { + return "已下架"; + } + + } + + public function logs() + { + return $this->hasMany(CouponUserLog::class, 'coupon_id', 'id'); + } + + /** + * 是否可下架 + * @Author: + * @Date:2018-12-10 + * @return boolean + */ + + public function canCancel(): bool + { + return $this->status == 1 ? true : false; + } + + public function getTitle() + { + return $this->title . '-' . $this->bouns; + } + + public function getPrice() + { + return $this->bouns; + } + + public function getScore() + { + return 0; + } + + public function getStock() + { + return 0; + } + + public function getSellerPrice() + { + return $this->bouns; + } + + public function deductStock($stock) + { + } + + public function addStock($stock) + { + } + + public function getStorage() + { + } +} diff --git a/packages/coupon/src/Models/CouponLog.php b/packages/coupon/src/Models/CouponLog.php new file mode 100644 index 0000000..033f14c --- /dev/null +++ b/packages/coupon/src/Models/CouponLog.php @@ -0,0 +1,8 @@ +belongsTo(CouponInfo::class, 'coupon_id', 'id'); + } + + public function user() + { + return $this->belongsTo(User::class); + } +} diff --git a/packages/coupon/src/Models/Model.php b/packages/coupon/src/Models/Model.php new file mode 100644 index 0000000..c0ef285 --- /dev/null +++ b/packages/coupon/src/Models/Model.php @@ -0,0 +1,10 @@ + + * @Date:2018-06-22T16:01:20+0800 + * @return [type] [description] + */ + public function boot() + { + if ($this->app->runningInConsole()) { + $this->publishes([__DIR__ . '/../config/rulong_coupon.php' => config_path('rulong_coupon.php')]); + $this->loadMigrationsFrom(__DIR__ . '/../database/migrations/'); + } + } + + /** + * 注册服务提供者 + * @Author: + * @Date:2018-06-22T16:01:12+0800 + * @return [type] [description] + */ + public function register() + { + $this->mergeConfigFrom(__DIR__ . '/../config/rulong_coupon.php', 'rulong_coupon'); + } +} diff --git a/packages/identity/README.md b/packages/identity/README.md new file mode 100644 index 0000000..c226328 --- /dev/null +++ b/packages/identity/README.md @@ -0,0 +1,4 @@ +# Identity 身份系统 +# trait User 模型 涉及函数 RuLong\Identity\Traits\UserHasIdentity +# 身份变更 $User->identityUpdate(Identity_id,Channel) // (身份ID,变更渠道) +# 身份加权点数 $User->addPoint(Identity_id,Point) // (身份ID,加权数额:默认1) diff --git a/packages/identity/composer.json b/packages/identity/composer.json new file mode 100644 index 0000000..50c1000 --- /dev/null +++ b/packages/identity/composer.json @@ -0,0 +1,27 @@ +{ + "name": "rulong/identity", + "description": "", + "license": "MIT", + "authors": [ + { + "name": "C.Jason", + "email": "chenjxlg@163.com" + } + ], + "require": { + "php": ">=7.1.3", + "laravel/framework": "*" + }, + "autoload": { + "psr-0": { + "RuLong\\Identity": "src/" + } + }, + "extra": { + "laravel": { + "providers": [ + "RuLong\\Identity\\ServiceProvider" + ] + } + } +} diff --git a/packages/identity/config/rulong_identity.php b/packages/identity/config/rulong_identity.php new file mode 100644 index 0000000..17afb94 --- /dev/null +++ b/packages/identity/config/rulong_identity.php @@ -0,0 +1,8 @@ + \App\User::class, + 'channel' => [ + 'AutoUp' => '自动升级', + 'AdminUp' => '后台升级', + ], +]; diff --git a/packages/identity/database/migrations/2018_11_05_145209_create_identities_table.php b/packages/identity/database/migrations/2018_11_05_145209_create_identities_table.php new file mode 100644 index 0000000..d109909 --- /dev/null +++ b/packages/identity/database/migrations/2018_11_05_145209_create_identities_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('identities'); + } +} diff --git a/packages/identity/database/migrations/2018_11_05_145219_create_identity_logs_table.php b/packages/identity/database/migrations/2018_11_05_145219_create_identity_logs_table.php new file mode 100644 index 0000000..d6ea64a --- /dev/null +++ b/packages/identity/database/migrations/2018_11_05_145219_create_identity_logs_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('identity_logs'); + } +} diff --git a/packages/identity/database/migrations/2018_11_05_150346_create_user_identities_table.php b/packages/identity/database/migrations/2018_11_05_150346_create_user_identities_table.php new file mode 100644 index 0000000..921f9ed --- /dev/null +++ b/packages/identity/database/migrations/2018_11_05_150346_create_user_identities_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('user_identities'); + } +} diff --git a/packages/identity/database/migrations/2018_11_07_161147_create_identity_points_table.php b/packages/identity/database/migrations/2018_11_07_161147_create_identity_points_table.php new file mode 100644 index 0000000..6da05a4 --- /dev/null +++ b/packages/identity/database/migrations/2018_11_07_161147_create_identity_points_table.php @@ -0,0 +1,31 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('identity_points'); + } +} diff --git a/packages/identity/src/Contracts/IdentityContracts.php b/packages/identity/src/Contracts/IdentityContracts.php new file mode 100644 index 0000000..3024404 --- /dev/null +++ b/packages/identity/src/Contracts/IdentityContracts.php @@ -0,0 +1,15 @@ + + * @Date:2018-10-31T14:22:48+0800 + */ + function fire(); + +} diff --git a/packages/identity/src/Events/IdentityPoint.php b/packages/identity/src/Events/IdentityPoint.php new file mode 100644 index 0000000..4ac6cc5 --- /dev/null +++ b/packages/identity/src/Events/IdentityPoint.php @@ -0,0 +1,39 @@ +user = $user; + $this->identity_id = $other['identity_id']; + if (isset($other['point']) && is_numeric($other['point'])) { + $this->point = $other['point']; + } else { + $this->point = 1; + } + } + + /** + * 创建及修改身份 + * @Author: + * @Date:2018-11-05T13:21:47+0800 + * @return [type] [description] + */ + public function fire() + { + IdentityPointModel::create(['user_id' => $this->user->id, 'identity_id' => $this->identity_id, 'point' => $this->point]); + } + +} diff --git a/packages/identity/src/Events/IdentityUpdate.php b/packages/identity/src/Events/IdentityUpdate.php new file mode 100644 index 0000000..73f2fb6 --- /dev/null +++ b/packages/identity/src/Events/IdentityUpdate.php @@ -0,0 +1,61 @@ +user = $user; + $this->identity_id = $other['identity_id']; + $this->channel = $other['channel'] ?? ''; + $this->maxKey = $other['max_key'] ?? 0; + if ($this->channel == 'AdminUp') { + $info = IdentityModel::find($this->identity_id); + if ($other['pay'] == 1) { + $this->other = [ + 'full' => $info->configs['full'] ?? '', + 'cost' => $info->configs['cost'] ?? '', + ]; + } + } + + } + + /** + * 创建及修改身份 + * @Author: + * @Date:2018-11-05T13:21:47+0800 + * @return [type] [description] + */ + public function fire() + { + $before = 0; + if ($this->user->identity->identity_id === 0) { + $data = [ + 'user_id' => $this->user->id, + 'identity_id' => $this->identity_id, + 'max_key' => $this->maxKey, + ]; + UserIdentityModel::create($data); + } else { + $before = $this->user->identity->identity_id; + UserIdentityModel::where('user_id', $this->user->id)->update(['identity_id' => $this->identity_id, 'max_key' => $this->maxKey]); + } + IdentityLogModel::create(['user_id' => $this->user->id, 'before' => $before, 'after' => $this->identity_id, 'channel' => $this->channel, 'other' => $this->other]); + } + +} diff --git a/packages/identity/src/Identity.php b/packages/identity/src/Identity.php new file mode 100644 index 0000000..56c9f7b --- /dev/null +++ b/packages/identity/src/Identity.php @@ -0,0 +1,20 @@ +contracts = $contracts; + } + + public function __destruct() + { + $this->contracts->fire(); + } +} diff --git a/packages/identity/src/Models/Identity.php b/packages/identity/src/Models/Identity.php new file mode 100644 index 0000000..9fc86d5 --- /dev/null +++ b/packages/identity/src/Models/Identity.php @@ -0,0 +1,13 @@ + 'array', + ]; +} diff --git a/packages/identity/src/Models/IdentityLog.php b/packages/identity/src/Models/IdentityLog.php new file mode 100644 index 0000000..dcfe543 --- /dev/null +++ b/packages/identity/src/Models/IdentityLog.php @@ -0,0 +1,35 @@ + 'array', + ]; + + // + protected function user() + { + return $this->belongsTo(config('user_account.user_model'))->withDefault(); + } + + protected function getIdentityTitleAttribute() + { + return Identity::where('id', $this->after)->value('title') ?: ''; + } + + public function getChannelTextAttribute() + { + return config('rulong_identity.channel.' . $this->channel) ?? '无'; + } + + public function user_obj() + { + return $this->belongsTo(config('rulong_bonus.user_model'),'user_id','id'); + } +} diff --git a/packages/identity/src/Models/IdentityPoint.php b/packages/identity/src/Models/IdentityPoint.php new file mode 100644 index 0000000..93992f3 --- /dev/null +++ b/packages/identity/src/Models/IdentityPoint.php @@ -0,0 +1,15 @@ +belongsTo(config('user_account.user_model'), 'user_id', 'id'); + } +} diff --git a/packages/identity/src/Models/UserIdentity.php b/packages/identity/src/Models/UserIdentity.php new file mode 100644 index 0000000..0691002 --- /dev/null +++ b/packages/identity/src/Models/UserIdentity.php @@ -0,0 +1,81 @@ +belongsTo(Identity::class, 'identity_id'); + } + + public function logs() + { + return $this->hasMany(IdentityLog::class, 'user_id', 'user_id'); + } + + public function getActivationChildsAttribute() + { + $childrenIds = $this->user->children()->pluck('id'); //拉入直推会员ID + $direct = self::when($childrenIds, function ($query) use ($childrenIds) { + $query->whereIn('user_id', $childrenIds); + })->count() ?: 0; + return $direct; + } + + public function childrentime($timeBetween = '') + { + $childrenIds = $this->user->children()->pluck('id'); //拉入直推会员ID + return self::when($childrenIds, function ($query) use ($childrenIds) { + $query->whereIn('user_id', $childrenIds); + })->when($timeBetween, function ($query) use ($timeBetween) { + $query->whereBetween('created_at', $timeBetween); + })->count() ?: 0; + } + + public function user() + { + return $this->belongsTo(config('user_account.user_model'))->withDefault(); + } + + /** + * 按指定层数内获取推荐人ID + * @Author: + * @Date:2018-12-06T11:45:44+0800 + * @return [type] [description] + */ + public function relationid($layer = 6) + { + $users = UserRelation::where('bloodline', 'like', "%," . $this->user_id . ",%")->where('layer', '<=', $this->user->relation->layer + $layer)->pluck('user_id'); + return $users; //拉入9层 + } + + /** + * 按指定层数获取推荐人ID + * @Author: + * @Date:2018-12-06T11:45:44+0800 + * @return [type] [description] + */ + public function realrelationid($layer = 6) + { + $users = UserRelation::where('bloodline', 'like', "%," . $this->user_id . ",%")->where('layer', $this->user->relation->layer + $layer)->pluck('user_id'); + return $users; //拉入9层 + } + + public function getRelationCountAttribute() + { + $childrenIds = self::relationid(1); //拉入直推会员ID + $direct = self::when($childrenIds, function ($query) use ($childrenIds) { + $query->whereIn('user_id', $childrenIds); + })->count() ?: 0; + return $direct; + } + +} diff --git a/packages/identity/src/ServiceProvider.php b/packages/identity/src/ServiceProvider.php new file mode 100644 index 0000000..3f38a18 --- /dev/null +++ b/packages/identity/src/ServiceProvider.php @@ -0,0 +1,34 @@ + + * @Date:2018-06-22T16:01:20+0800 + * @return [type] [description] + */ + public function boot() + { + if ($this->app->runningInConsole()) { + $this->publishes([__DIR__ . '/../config/rulong_identity.php' => config_path('rulong_identity.php')]); + $this->loadMigrationsFrom(__DIR__ . '/../database/migrations/'); + } + } + + /** + * 注册服务提供者 + * @Author: + * @Date:2018-06-22T16:01:12+0800 + * @return [type] [description] + */ + public function register() + { + $this->mergeConfigFrom(__DIR__ . '/../config/rulong_identity.php', 'rulong_identity'); + } +} diff --git a/packages/identity/src/Traits/Identityable.php b/packages/identity/src/Traits/Identityable.php new file mode 100644 index 0000000..54561aa --- /dev/null +++ b/packages/identity/src/Traits/Identityable.php @@ -0,0 +1,13 @@ + + * @Date:2018-11-09T17:00:39+0800 + * @return [type] [description] + */ + public function getIdentityTextAttribute() + { + return Identity::where('id', $this->identity->identity_id)->value('title') ?: '注册用户'; + } + + public function pointlogs() + { + return $this->hasMany(IdentityPointModel::class); + } + + public function identity() + { + return $this->hasOne(UserIdentity::class)->withDefault(['identity_id' => 0]); + } + + /** + * User模型涉及函数,辅助快速执行修改身份, + * [identityUpdate description] + * @Author: + * @Date:2018-11-07T16:24:44+0800 + * @param [type] $id [身份ID] + * @return [type] [description] + */ + public function identityUpdate($id, $channel = 'AutoUp', $pay = 0, $max_key = 0) + { + return IdentityUpdate::start($this, ['identity_id' => $id, 'channel' => $channel, 'pay' => $pay, 'max_key' => $max_key]); + } + + /** + * User模型设计函数,辅助快速增加身份积分。 + * @Author: + * @Date:2018-11-07T16:25:45+0800 + * @param [type] $id [description] + * @param integer $point [description] + */ + public function addPoint($id, $point = 1) + { + return IdentityPoint::start($this, ['identity_id' => $id, 'point' => $point]); + } +}