123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322 |
- <?php
- namespace App\Http\Controllers\Api;
- use App\Service\SourceQrcodeService;
- use Illuminate\Http\Request;
- use App\Http\Controllers\Controller;
-
- class SourceQrcodeController extends Controller
- {
- public function addSqgroup(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required',
- 'name' => 'required'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $name = $request->input('name');
- $type = $request->input('type', 1); // 类型 1:渠道活码 2:群活码
- $errCode = SourceQrcodeService::addSqgroup($corpid, $name, $type);
- return self::returnValue([], $errCode);
- }
- public function editSqgroup(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'id' => 'required|int',
- 'name' => 'required'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $id = $request->input('id');
- $name = $request->input('name');
- $errCode = SourceQrcodeService::editSqgroup($id, $name);
- return self::returnValue([], $errCode);
- }
- public function editGroupSort(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'ids' => 'required|array',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $ids = $request->input('ids');
- $errCode = SourceQrcodeService::editGroupSort($ids);
- return self::returnValue([], $errCode);
- }
- public function delSqGroup(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'id' => 'required|int',
- 'del_sqs' => 'nullable|int'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $id = $request->input('id');
- $del_sqs = $request->input('del_sqs');
- $errCode = SourceQrcodeService::delSqGroup($id, $del_sqs);
- return self::returnValue([], $errCode);
- }
- public function sqGroupList(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required',
- 'page' => 'required|int',
- 'page_size' => 'int',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $page = $request->input('page', 1);
- $pagesize = $request->input('page_size', 20);
- $type = $request->input('type', 1);
- list($data, $total) = SourceQrcodeService::sqGroupList($corpid, $type, $page, $pagesize);
- return self::returnPageValue($data, $total, $pagesize, $page);
- }
- public function addSourceQrcode(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required',
- 'name' => 'required',
- 'group_id' => 'nullable',
- 'user_json' => 'required',
- 'tag_list' => 'nullable',
- 'customer_prefix' => 'required',
- 'customer_prefix_type' => 'required',
- 'up_toplimit' => 'nullable|int',
- 'warn_user' => 'nullable',
- 'msg_data' => 'required'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $name = $request->input('name');
- $group_id = $request->input('group_id');
- $user_json = $request->input('user_json');
- $tag_list = $request->input('tag_list');
- $customer_prefix = $request->input('customer_prefix');
- $customer_prefix_type = $request->input('customer_prefix_type');
- $up_toplimit = $request->input('up_toplimit');
- $warn_user = $request->input('warn_user');
- $msg_data = $request->input('msg_data');
- list($code, $msg) = SourceQrcodeService::addSourceQrcode($corpid, $name, $group_id, $user_json, $tag_list, $customer_prefix, $customer_prefix_type, $up_toplimit, $warn_user, $msg_data);
- return self::returnValue(['msg' => $msg], $code);
- }
- public function editSourceQrcode(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'id' => 'required|int',
- 'name' => 'required',
- 'group_id' => 'nullable',
- 'user_json' => 'required',
- 'tag_list' => 'required',
- 'customer_prefix' => 'required',
- 'customer_prefix_type' => 'required',
- 'up_toplimit' => 'nullable|int',
- 'warn_user' => 'nullable',
- 'msg_data' => 'required'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $id = $request->input('id');
- $name = $request->input('name');
- $group_id = $request->input('group_id');
- $user_json = $request->input('user_json');
- $tag_list = $request->input('tag_list');
- $customer_prefix = $request->input('customer_prefix');
- $customer_prefix_type = $request->input('customer_prefix_type');
- $up_toplimit = $request->input('up_toplimit');
- $warn_user = $request->input('warn_user');
- $msg_data = $request->input('msg_data');
- list($code, $msg) = SourceQrcodeService::editSourceQrcode($id, $name, $group_id, $user_json, $tag_list, $customer_prefix, $customer_prefix_type, $up_toplimit, $warn_user, $msg_data);
- return self::returnValue(['msg' => $msg], $code);
- }
- public function sourceQrcodeList(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required',
- 'group_id' => 'nullable|int',
- 'name' => 'nullable',
- 'user_id' => 'nullable',
- 'page' => 'required|int',
- 'page_size' => 'int',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $group_id = $request->input('group_id');
- $name = $request->input('name');
- $user_ids = $request->input('user_ids');
- $page = $request->input('page', 1);
- $pagesize = $request->input('page_size', 20);
- list($data, $total) = SourceQrcodeService::sourceQrcodeList($corpid, $group_id, $name, $user_ids, $page, $pagesize);
- return self::returnPageValue($data, $total, $pagesize, $page);
- }
- public function delSourceQrcode(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'id' => 'required|int'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $id = $request->input('id');
- list($code, $msg) = SourceQrcodeService::delSourceQrcode($id);
- return self::returnValue(['msg' => $msg], $code);
- }
- public function sourceQrcodeDetail(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'id' => 'required|int'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $id = $request->input('id');
- $res = SourceQrcodeService::sourceQrcodeDetail($id);
- return self::returnValue($res);
- }
- public function customerList(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'sq_id' => 'required|int',
- 'name' => 'nullable',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $sq_id = $request->input('sq_id');
- $name = $request->input('name');
- $page = $request->input('page', 1);
- $pagesize = $request->input('page_size', 20);
- list($data, $total) = SourceQrcodeService::customerList($sq_id, $name, $page, $pagesize);
- return self::returnPageValue($data, $total, $pagesize, $page);
- }
- public function staffList(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'sq_id' => 'required|int'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $sq_id = $request->input('sq_id');
- $data = SourceQrcodeService::staffList($sq_id);
- return self::returnValue($data);
- }
-
- /**
- * 数据分析概览
- * @param Request $request
- * @return array
- */
- public function dataView(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'id' => 'required|int'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $id = $request->input('id');
- $res = SourceQrcodeService::dataView($id);
- return self::returnValue($res);
- }
- /**
- * 数据分析趋势
- * @param Request $request
- * @return array
- */
- public function dataTrend(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'id' => 'required|int',
- 'st_date' => 'required|date',
- 'en_date' => 'required|date',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $id = $request->input('id');
- $stDate = $request->input('st_date');
- $enDate = $request->input('en_date');
- $res = SourceQrcodeService::dataTrend($id, $stDate, $enDate);
- return self::returnValue($res);
- }
- }
|