1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318 |
- <?php
- namespace App\Http\Controllers\Channel\OfficialAccount;
- use App\Http\Controllers\Channel\BaseController as ChannelBaseController;
- use App\Http\Controllers\Channel\OfficialAccount\Transformers\CustomMsgControllerTransformer;
- use App\Http\Controllers\Channel\OfficialAccount\Transformers\CustomMsgSwitchMultyTransformer;
- use App\Http\Controllers\Channel\OfficialAccount\Transformers\CustomMsgSwitchTransformer;
- use App\Http\Controllers\Channel\OfficialAccount\Transformers\CustomSendMsgsTransformers;
- use App\Http\Controllers\Channel\OfficialAccount\Transformers\OfficialImgtextUrlsTransformer;
- use App\Http\Controllers\Channel\Promotion\Transformers\DocumentCoversTransformer;
- use App\Http\Controllers\Channel\Promotion\Transformers\HeadlinelTransformer;
- use App\Modules\Statistic\Services\WapVisitStatService;
- use App\Modules\OfficialAccount\Services\CustomMsgService;
- use App\Modules\OfficialAccount\Services\ForceSubscribeService;
- use App\Modules\Promotion\Services\PromotionService;
- use GuzzleHttp\Client;
- use Illuminate\Http\Request;
- use OSS\Core\OssException;
- use OSS\OssClient;
- class CustomMsgController extends ChannelBaseController
- {
-
-
- function customerImgUrlByChannelId(Request $request)
- {
- $distribution_channel_id = $this->getChannelId();
- $distributionChannelSetting = CustomMsgService::customerImgUrlByChannelId($distribution_channel_id);
- if (!empty($distributionChannelSetting)) {
-
- return response()->item(new CustomMsgControllerTransformer(), $distributionChannelSetting);
- } else {
- return response()->success(['data' => 0]);
- }
- }
-
- function uploadCustomerImgUrl(Request $request)
- {
- $distribution_channel_id = $this->getChannelId();
- if ($request->hasFile('photo')) {
- $file = $request->file('photo');
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $ossImgBackData = $this->ossObject()->uploadFile(env('OSS_BUCKET', 'zhuishuyun'), 'service/customimage_' . $distribution_channel_id . '_' . time() . '.' . $file->getClientOriginalName(), $file->path());
- $ossImg = $ossImgBackData['oss-request-url'];
- $customerImgPram['distribution_channel_id'] = $distribution_channel_id;
- $customerImgPram['customer_img_url'] = $ossImg;
- $sustomMsgService = CustomMsgService::updateCustomerImgUrl($customerImgPram);
- return response()->item(new CustomMsgControllerTransformer(), $sustomMsgService);
- }
- }
-
- function ossObject()
- {
- $accessKeyId = env('OSS_ACCESS_ID');
- $accessKeySecret = env('OSS_ACCESS_KEY');
- $endpoint = env('OSS_END_POINT');
- $ossClient = null;
- try {
- $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint);
- } catch (OssException $e) {
- return null;
- }
- return $ossClient;
- }
-
- function customMsgSwitchSetting(Request $request)
- {
- $distribution_channel_id = $this->getChannelId();
- $custom_category = $request->has('custom_category') ? $request->input('custom_category') : '';
- if (empty($custom_category)) {
- return response()->error("PARAM_EMPTY");
- }
- $status = $request->has('status') ? $request->input('status') : '';
- if (empty($status)) {
- return response()->error("PARAM_EMPTY");
- }
- $is_self_content = $request->has('is_self_content') ? $request->input('is_self_content') : '0';
- $customMsgService = CustomMsgService::customMsgSwitchSetting($distribution_channel_id, $custom_category, $status, $is_self_content);
- if ($customMsgService == 1) {
- return response()->success();
- } elseif ($customMsgService == 2) {
- return response()->error('CUSTOMS_SETTING_FAILED');
- } elseif ($customMsgService == 0) {
- return response()->error('HAS_NO_CUSTOMS');
- } else {
- return response()->error('CUSTOMS_SETTING_FAILED');
- }
- }
-
- function customMsgSwitchsByChannelId(Request $request)
- {
- $distribution_channel_id = $this->getChannelId();
- $customMsgService = CustomMsgService::customMsgSwitchsByChannelId($distribution_channel_id);
- if (!empty($customMsgService)) {
- return response()->collection(new CustomMsgSwitchMultyTransformer(), $customMsgService);
- } else {
- return response()->success(['data' => 0]);
- }
- }
-
- function customMsgSwitchsByChannelCate(Request $request)
- {
- $distribution_channel_id = $this->getChannelId();
- $custom_category = $request->has('custom_category') ? $request->input('custom_category') : '';
- if (empty($custom_category)) {
- return response()->error("PARAM_EMPTY");
- }
- $customMsgService = CustomMsgService::customMsgSwitchsByChannelCate($distribution_channel_id, $custom_category);
- if (!empty($customMsgService)) {
- return response()->item(new CustomMsgSwitchTransformer(), $customMsgService);
- } else {
- return response()->success(['data' => 0]);
- }
- }
-
- function customSendMsgsByChannelId(Request $request)
- {
- $distribution_channel_id = $this->getChannelId();
- $customMsgServices = CustomMsgService::customSendMsgsByChannelId($distribution_channel_id);
- if (!empty($customMsgServices)) {
- foreach($customMsgServices as $key=>$customMsgService){
- if($customMsgService->is_full_send){
- $customMsgServices[$key]->user_category = '服务号全量用户';
- }elseif($customMsgService->subscribe_time == 'z' &&
- $customMsgService->sex == 'z' &&
- $customMsgService->balance == 'z' &&
- $customMsgService->order_type == 'z' &&
- $customMsgService->category_id == 'z' ){
- $customMsgServices[$key]->user_category = '追书云全部用户';
- }else{
- $customMsgServices[$key]->user_category = '追书云标签用户';
- }
- }
- return response()->pagination(new CustomSendMsgsTransformers(), $customMsgServices);
- } else {
- return response()->success(['data' => 0]);
- }
- }
- function searchCustomSendMsgs(Request $request)
- {
- \Log::info('searchCustomSendMsgs_start');
- $start_time = $request->has('start_time') ? $request->input('start_time') : '';
- $end_time = $request->has('end_time') ? $request->input('end_time') : '';
- $book_name = $request->has('book_name') ? $request->input('book_name') : '';
- $task_name = $request->has('task_name') ? $request->input('task_name') : '';
- if ($start_time < '2018-11-02') {
- \Log::info('searchCustomSendMsgs,update_start_time:' . $start_time);
- $start_time = '2018-11-02';
- }
- $distribution_channel_id = $this->getChannelId();
- $param = [
- 'distribution_channel_id' => $distribution_channel_id,
- 'start_time' => $start_time,
- 'end_time' => $end_time,
- 'book_name' => $book_name,
- 'task_name' => $task_name
- ];
- $customMsgServices = CustomMsgService::searchCustomSendMsgs($param, false);
- if (!empty($customMsgServices)) {
- foreach ($customMsgServices as $key => $customMsgService) {
- $fromtype = 'custom_' . $customMsgService->id;
- $statistics = WapVisitStatService::innerCustomerAllStats($fromtype);
- $customMsgServices[$key]->uv = isset($statistics['uv']) ? $statistics['uv'] : '';
- $customMsgServices[$key]->pv = isset($statistics['pv']) ? $statistics['pv'] : '';
- $customMsgServices[$key]->register_user_num = isset($statistics['register_user_num']) ? $statistics['register_user_num'] : '';
- $customMsgServices[$key]->pay_user_num = isset($statistics['pay_user_num']) ? $statistics['pay_user_num'] : '';
- $customMsgServices[$key]->charge_amount = isset($statistics['charge_amount']) ? $statistics['charge_amount'] : '';
- }
- return response()->pagination(new CustomSendMsgsTransformers(), $customMsgServices);
- } else {
- return response()->success(['data' => 0]);
- }
- }
- function exportCustomSendMsgs(Request $request)
- {
- \Log::info('exportCustomSendMsgs_start');
- $start_time = $request->has('start_time') ? $request->input('start_time') : '';
- $end_time = $request->has('end_time') ? $request->input('end_time') : '';
- $book_name = $request->has('book_name') ? $request->input('book_name') : '';
- $task_name = $request->has('task_name') ? $request->input('task_name') : '';
- if ($start_time < '2018-11-02') {
- \Log::info('searchCustomSendMsgs,update_start_time:' . $start_time);
- $start_time = '2018-11-02';
- }
- $distribution_channel_id = $this->getChannelId();
- $param = [
- 'distribution_channel_id' => $distribution_channel_id,
- 'start_time' => $start_time,
- 'end_time' => $end_time,
- 'book_name' => $book_name,
- 'task_name' => $task_name
- ];
- $customMsgServices = CustomMsgService::searchCustomSendMsgs($param, true);
- header("Content-type:application/vnd.ms-excel");
- header("Content-Disposition:attachment;filename=" . "客服消息" . date("YmdHis") . ".csv");
- echo iconv("UTF-8", "GBK", "\"类型\",\"id\",\"任务名称\",\"小说\",\"章节\",\"pv\",\"uv\",\"充值用户\",\"充值总额\"\r\n");
- if (!empty($customMsgServices)) {
- foreach ($customMsgServices as $key => $customMsgService) {
- $fromtype = 'custom_' . $customMsgService->id;
- $statistics = WapVisitStatService::innerCustomerAllStats($fromtype);
- $uv = empty($statistics['uv']) ? 0 : $statistics['uv'];
- $pv = empty($statistics['pv']) ? 0 : $statistics['pv'];
- $pay_user_num = empty($statistics['pay_user_num']) ? 0 : $statistics['pay_user_num'];
- $charge_amount = empty($statistics['charge_amount']) ? 0 : $statistics['charge_amount'];
- echo("\"" . iconv("UTF-8", "GBK", '客服消息') . "\",");
- echo("\"" . iconv("UTF-8", "GBK", $customMsgService->id) . "\",");
- echo("\"" . iconv("UTF-8", "GBK//IGNORE", $customMsgService->name ? $customMsgService->name : '未填') . "\",");
- echo("\"" . iconv("UTF-8", "GBK//IGNORE", $customMsgService->book_name ? $customMsgService->book_name : '未填') . "\",");
- echo("\"" . iconv("UTF-8", "GBK//IGNORE", $customMsgService->chapter_name ? $customMsgService->chapter_name : '未填') . "\",");
- echo("\"" . iconv("UTF-8", "GBK", $pv) . "\",");
- echo("\"" . iconv("UTF-8", "GBK", $uv) . "\",");
- echo("\"" . iconv("UTF-8", "GBK", $pay_user_num) . "\",");
- echo("\"" . iconv("UTF-8", "GBK", $charge_amount) . "\"\r\n");
- }
- }
- exit();
- }
-
- function customSendMsgsById(Request $request)
- {
- $id = $request->has('id') ? $request->input('id') : '';
- if (empty($id)) {
- return response()->error("PARAM_EMPTY");
- }
- $customMsgService = CustomMsgService::customSendMsgsById($id);
- if (!empty($customMsgService)) {
- if ($customMsgService->description) {
- $customMsgService->description = json_decode($customMsgService->description);
- }
- return response()->item(new CustomSendMsgsTransformers(), $customMsgService);
- } else {
- return response()->success(['data' => 0]);
- }
- }
-
- function stopCustomSendMsgsById(Request $request)
- {
- $id = $request->has('id') ? $request->input('id') : '';
- if (empty($id)) {
- return response()->error("PARAM_EMPTY");
- }
- $customMsgService = CustomMsgService::updateCustomSendMsgsStatus($id);
- if ($customMsgService == 1) {
- return response()->success();
- } elseif ($customMsgService == 2) {
- return response()->error('CUSTOMS_SEND_FAILED');
- } elseif ($customMsgService == 4) {
- return response()->error('CUSTOMMSG_IS_SEDDING');
- } elseif ($customMsgService == 0) {
- return response()->error('CUSTOMS_SEND_FAILED');
- } else {
- return response()->error('CUSTOMS_SEND_FAILED');
- }
- }
-
- function forceUserCountByCustomPrams(Request $request)
- {
-
- $distribution_channel_id = $this->getChannelId();
- $subscribe_time = $request->has('subscribe_time') ? $request->input('subscribe_time') : '';
- if (empty($subscribe_time)) {
- return response()->error("PARAM_EMPTY");
- }
- $appids = $request->has('appids') ? $request->input('appids') : '';
- if (empty($appids)) {
- return response()->error("PARAM_EMPTY");
- }
- $sex = $request->has('sex') ? $request->input('sex') : '';
- if (empty($sex)) {
- return response()->error("PARAM_EMPTY");
- }
- $balance = $request->has('balance') ? $request->input('balance') : '';
- if (empty($balance)) {
- return response()->error("PARAM_EMPTY");
- }
- $order_type = $request->has('order_type') ? $request->input('order_type') : '';
- if (empty($order_type)) {
- return response()->error("PARAM_EMPTY");
- }
- $category_id = $request->has('category_id') ? $request->input('category_id') : '';
- if (empty($category_id)) {
- return response()->error("PARAM_EMPTY");
- }
- $appidArray = explode(',', $appids);
- $usernum = 0;
- for ($j = 0; $j < count($appidArray); $j++) {
- $skip = 0;
- while ($skip <= 2500000) {
- \Log::info('-----------客服消息-------分页取强关用户,目前页数----------' . $skip);
-
- $sign_time = 'z';
- $force_user = ForceSubscribeService::forceUserCountByCustomPrams($appidArray[$j], $distribution_channel_id, $subscribe_time, $sex, $balance, $category_id, $order_type, $sign_time, $skip);
- if (count($force_user) > 0) {
- $usernum += count($force_user);
- } else {
- break;
- }
- $skip += count($force_user);
- }
- }
- return response()->success(['num' => $usernum]);
- }
-
- function addCustomSendMsgs(Request $request)
- {
- $distribution_channel_id = $this->getChannelId();
- \Log::info('addCustomSendMsgs_start:'.$distribution_channel_id);
- \Log::info($request->all());
- $name = $request->has('name') ? $request->input('name') : '';
- if (empty($name)) {
- return response()->error("PARAM_EMPTY");
- }
- $appid = $request->has('appid') ? $request->input('appid') : '';
- if (empty($appid)) {
- return response()->error("PARAM_EMPTY");
- }
- $send_time = $request->has('send_time') ? $request->input('send_time') : '';
- if (empty($send_time)) {
- return response()->error("PARAM_EMPTY");
- }
- $content = $request->has('content') ? $request->input('content') : '';
- if (empty($content)) {
- return response()->error("PARAM_EMPTY");
- }
- $redirect_url = $request->has('redirect_url') ? $request->input('redirect_url') : '';
- if (empty($redirect_url)) {
- return response()->error("PARAM_EMPTY");
- }
- $subscribe_time = $request->has('subscribe_time') ? $request->input('subscribe_time') : '';
- if (empty($subscribe_time)) {
- return response()->error("PARAM_EMPTY");
- }
- $sex = $request->has('sex') ? $request->input('sex') : '';
- if (empty($sex)) {
- return response()->error("PARAM_EMPTY");
- }
- $balance = $request->has('balance') ? $request->input('balance') : '';
- if (empty($balance)) {
- return response()->error("PARAM_EMPTY");
- }
- $order_type = $request->has('order_type') ? $request->input('order_type') : '';
- if (empty($order_type)) {
- return response()->error("PARAM_EMPTY");
- }
- $category_id = $request->has('category_id') ? $request->input('category_id') : '';
- if (empty($category_id)) {
- return response()->error("PARAM_EMPTY");
- }
- $is_activity = $request->has('is_activity') ? $request->input('is_activity') : '0';
- $description = $request->has('description') ? $request->input('description') : '';
- $book_name = $request->has('book_name') ? $request->input('book_name') : '';
- $chapter_name = $request->has('chapter_name') ? $request->input('chapter_name') : '';
- if ($is_activity == '0') {
- if (empty($book_name)) {
- return response()->error("PARAM_EMPTY");
- }
- if (empty($chapter_name)) {
- return response()->error("PARAM_EMPTY");
- }
- }
- $user_condition = $request->has('user_condition') ? $request->input('user_condition') : '';
- $is_full_send = $request->has('is_full_send') ? $request->input('is_full_send') : '0';
- \Log::info('addCustomSendMsgs_after_check:'.$distribution_channel_id);
-
- $customMsgPrams['appid'] = $appid;
- $customMsgPrams['name'] = $name;
- $customMsgPrams['send_time'] = $send_time;
- $customMsgPrams['is_activity'] = $is_activity;
- $customMsgPrams['content'] = json_encode($content);
- $customMsgPrams['description'] = json_encode($description);
- $customMsgPrams['book_name'] = $book_name;
- $customMsgPrams['chapter_name'] = $chapter_name;
- $customMsgPrams['redirect_url'] = $redirect_url;
- $customMsgPrams['subscribe_time'] = $subscribe_time;
- $customMsgPrams['sex'] = $sex;
- $customMsgPrams['balance'] = $balance;
- $customMsgPrams['order_type'] = $order_type;
- $customMsgPrams['category_id'] = $category_id;
- $customMsgPrams['is_full_send'] = $is_full_send;
- $customMsgPrams['distribution_channel_id'] = $distribution_channel_id;
- $customMsgPrams['status'] = '1';
- $customMsgPrams['user_condition'] = $user_condition;
-
- $isSendCustomer = CustomMsgService::isSendCustomerAtSameTime($customMsgPrams);
- if (!empty($isSendCustomer)) {
- \Log::info('已经发送过该客服消息');
- \Log::info($isSendCustomer['id']);
- \Log::info($isSendCustomer['status']);
- \Log::info($isSendCustomer['del_flag']);
- return response()->error('CUSTOMS_DOUBLE_FAILED');
- }
- $customMsgService = CustomMsgService::addCustomSendMsgs($customMsgPrams);
- if ($customMsgService == 1) {
- return response()->success();
- } elseif ($customMsgService == 2) {
- return response()->error('CUSTOMS_SEND_FAILED');
- } elseif ($customMsgService == 3) {
- return response()->error('CUSTOMS_DOUBLE_FAILED');
- } elseif ($customMsgService == 0) {
- return response()->error('CUSTOMS_SEND_FAILED');
- } else {
- return response()->error('CUSTOMS_SEND_FAILED');
- }
- }
-
- function editCustomSendMsgs(Request $request)
- {
- $distribution_channel_id = $this->getChannelId();
- $name = $request->has('name') ? $request->input('name') : '';
- if (empty($name)) {
- return response()->error("PARAM_EMPTY");
- }
- $appid = $request->has('appid') ? $request->input('appid') : '';
- if (empty($appid)) {
- return response()->error("PARAM_EMPTY");
- }
- $send_time = $request->has('send_time') ? $request->input('send_time') : '';
- if (empty($send_time)) {
- return response()->error("PARAM_EMPTY");
- }
- $content = $request->has('content') ? $request->input('content') : '';
- if (empty($content)) {
- return response()->error("PARAM_EMPTY");
- }
- $redirect_url = $request->has('redirect_url') ? $request->input('redirect_url') : '';
- if (empty($redirect_url)) {
- return response()->error("PARAM_EMPTY");
- }
- $subscribe_time = $request->has('subscribe_time') ? $request->input('subscribe_time') : '';
- if (empty($subscribe_time)) {
- return response()->error("PARAM_EMPTY");
- }
- $sex = $request->has('sex') ? $request->input('sex') : '';
- if (empty($sex)) {
- return response()->error("PARAM_EMPTY");
- }
- $balance = $request->has('balance') ? $request->input('balance') : '';
- if (empty($balance)) {
- return response()->error("PARAM_EMPTY");
- }
- $order_type = $request->has('order_type') ? $request->input('order_type') : '';
- if (empty($order_type)) {
- return response()->error("PARAM_EMPTY");
- }
- $category_id = $request->has('category_id') ? $request->input('category_id') : '';
- if (empty($category_id)) {
- return response()->error("PARAM_EMPTY");
- }
- $is_activity = $request->has('is_activity') ? $request->input('is_activity') : '0';
- $description = $request->has('description') ? $request->input('description') : '';
- $book_name = $request->has('book_name') ? $request->input('book_name') : '';
- $chapter_name = $request->has('chapter_name') ? $request->input('chapter_name') : '';
- if ($is_activity == '0') {
- if (empty($book_name)) {
- return response()->error("PARAM_EMPTY");
- }
- if (empty($chapter_name)) {
- return response()->error("PARAM_EMPTY");
- }
- }
- $is_full_send = $request->has('is_full_send') ? $request->input('is_full_send') : '0';
- $user_condition = $request->has('user_condition') ? $request->input('user_condition') : '';
- $id = $request->has('id') ? $request->input('id') : '';
- if (empty($id)) {
- return response()->error("PARAM_EMPTY");
- }
- $customMsgPrams['appid'] = $appid;
- $customMsgPrams['name'] = $name;
- $customMsgPrams['send_time'] = $send_time;
- $customMsgPrams['is_activity'] = $is_activity;
- $customMsgPrams['content'] = json_encode($content);
- $customMsgPrams['description'] = json_encode($description);
- $customMsgPrams['book_name'] = $book_name;
- $customMsgPrams['chapter_name'] = $chapter_name;
- $customMsgPrams['redirect_url'] = $redirect_url;
- $customMsgPrams['subscribe_time'] = $subscribe_time;
- $customMsgPrams['sex'] = $sex;
- $customMsgPrams['balance'] = $balance;
- $customMsgPrams['order_type'] = $order_type;
- $customMsgPrams['category_id'] = $category_id;
- $customMsgPrams['is_full_send'] = $is_full_send;
- $customMsgPrams['distribution_channel_id'] = $distribution_channel_id;
- $customMsgPrams['status'] = '1';
- $customMsgPrams['user_condition'] = $user_condition;
- $customMsgPrams['id'] = $id;
- $customMsgService = CustomMsgService::editCustomSendMsgs($customMsgPrams);
- if ($customMsgService == 1) {
- return response()->success();
- } elseif ($customMsgService == 2) {
- return response()->error('CUSTOMS_SEND_FAILED');
- } elseif ($customMsgService == 4) {
- return response()->error('CUSTOMMSG_IS_SEDDING');
- } elseif ($customMsgService == 0) {
- return response()->error('CUSTOMS_SEND_FAILED');
- } else {
- return response()->error('CUSTOMS_SEND_FAILED');
- }
- }
-
- function delCustomSendMsgs(Request $request)
- {
- $id = $request->has('id') ? $request->input('id') : '';
- if (empty($id)) {
- return response()->error("PARAM_EMPTY");
- }
- \Log::info('》》》》》》》》》》》》》》获取删除客服消息时所传的ID');
- \Log::info($id);
- $customSendMsgsPrams['id'] = $id;
- $customMsgService = CustomMsgService::delCustomSendMsgs($customSendMsgsPrams);
- \Log::info('》》》》》》》》》》》》》》获取删除客服消息 返回结果');
- \Log::info($customMsgService);
- if ($customMsgService == 1) {
- return response()->success();
- } elseif ($customMsgService == 2) {
- return response()->error('CUSTOMS_SEND_FAILED');
- } elseif ($customMsgService == 4) {
- return response()->error('CUSTOMMSG_IS_SEDDING');
- } elseif ($customMsgService == 0) {
- return response()->error('CUSTOMS_SEND_FAILED');
- } else {
- return response()->error('CUSTOMS_SEND_FAILED');
- }
- }
-
- function getAllDocumentCovers(Request $request)
- {
- $distribution_channel_id = $this->getChannelId();
- $promotionService = PromotionService::getAllMessageDocumentCovers($distribution_channel_id);
- if (!empty($promotionService)) {
- return response()->collection(new DocumentCoversTransformer(), $promotionService);
- } else {
- return response()->success(['data' => 0]);
- }
- }
-
- function getAllHeadlinesNoType(Request $request)
- {
- $promotionService = PromotionService::getHeadlines();
- if (!empty($promotionService)) {
- return response()->collection(new HeadlinelTransformer(), $promotionService);
- } else {
- return response()->success(['data' => 0]);
- }
- }
-
- function testAddCustomSendMsgs(Request $request)
- {
- $distribution_channel_id = $this->getChannelId();
- $appid = $request->has('appid') ? $request->input('appid') : '';
- if (empty($appid)) {
- return response()->error("PARAM_EMPTY");
- }
- $name = $request->has('name') ? $request->input('name') : '';
- if (empty($name)) {
- return response()->error("PARAM_EMPTY");
- }
- $content = $request->has('content') ? $request->input('content') : '';
- if (empty($content)) {
- return response()->error("PARAM_EMPTY");
- }
- $redirect_url = $request->has('redirect_url') ? $request->input('redirect_url') : '';
- if (empty($redirect_url)) {
- return response()->error("PARAM_EMPTY");
- }
- $uid = $request->has('uid') ? $request->input('uid') : '';
- if (empty($uid)) {
- return response()->error("PARAM_EMPTY");
- }
- $customMsgPrams['appid'] = $appid;
- $customMsgPrams['name'] = $name;
- $customMsgPrams['content'] = json_encode($content);
- $customMsgPrams['redirect_url'] = $redirect_url;
- $customMsgPrams['distribution_channel_id'] = $distribution_channel_id;
- $customMsgPrams['uid'] = $uid;
- $customMsgService = CustomMsgService::testAddCustomSendMsgs($customMsgPrams);
- if ($customMsgService == 1) {
- return response()->success();
- } elseif ($customMsgService == 2) {
- return response()->error('CUSTOMS_SEND_FAILED');
- } elseif ($customMsgService == 0) {
- return response()->error('CUSTOMS_SEND_FAILED');
- } else {
- return response()->error('CUSTOMS_SEND_FAILED');
- }
- }
-
- function createOfficialImgTxtUrl(Request $request)
- {
- \Log::info('createOfficialImgTxtUrl_start');
-
-
- $img_url = $request->has('img_url') ? $request->input('img_url') : '';
- if (empty($img_url)) {
- return response()->error("PARAM_EMPTY");
- }
-
-
- $content = $request->has('content') ? $request->input('content') : '';
- if (empty($content)) {
- return response()->error("PARAM_EMPTY");
- }
-
- $title = $request->has('title') ? $request->input('title') : '';
- if (empty($title)) {
- return response()->error("PARAM_EMPTY");
- }
- $book_name = $request->has('book_name') ? $request->input('book_name') : '';
- if (empty($book_name)) {
- return response()->error("PARAM_EMPTY");
- }
- $chapter_sequence = $request->has('chapter_sequence') ? $request->input('chapter_sequence') : '';
- if (empty($chapter_sequence)) {
- return response()->error("PARAM_EMPTY");
- }
- $qrcode_Img = $request->has('qrcode_Img') ? $request->input('qrcode_Img') : '';
- $send_orders_id = $request->has('send_orders_id') ? $request->input('send_orders_id') : '';
- $send_orders_name = $request->has('send_orders_name') ? $request->input('send_orders_name') : '';
- $send_orders_url = $request->has('send_orders_url') ? $request->input('send_orders_url') : '';
- $distribution_channel_id = $this->getChannelId();
-
- \Log::info('createOfficialImgTxtUrl_start2:'.$distribution_channel_id.' book_name:'.$book_name.' chapter_sequence:'.$chapter_sequence);
-
- $officialImgTxtUrlPrams['distribution_channel_id'] = $distribution_channel_id;
- $officialImgTxtUrlPrams['img_url'] = $img_url;
- $officialImgTxtUrlPrams['content'] = $content;
- $officialImgTxtUrlPrams['title'] = $title;
- $officialImgTxtUrlPrams['book_name'] = $book_name;
- $officialImgTxtUrlPrams['chapter_sequence'] = $chapter_sequence;
- $officialImgTxtUrlPrams['send_orders_id'] = $send_orders_id;
- $officialImgTxtUrlPrams['send_orders_name'] = $send_orders_name;
- $officialImgTxtUrlPrams['send_orders_url'] = $send_orders_url;
- $customMsgService = CustomMsgService::createOfficialImgTxtUrl($officialImgTxtUrlPrams);
- if (!empty($customMsgService)) {
-
- return response()->success(['img_url' => $customMsgService]);
- } else {
- return response()->error('OFFICIAL_IMGTXT_FAILED');
- }
- }
-
- function getOfficialImgTxtUrl(Request $request)
- {
- $distribution_channel_id = $this->getChannelId();
- $customMsgService = CustomMsgService::getOfficialImgTxtUrl($distribution_channel_id);
- if (!empty($customMsgService)) {
-
- return response()->pagination(new OfficialImgtextUrlsTransformer(), $customMsgService);
- } else {
- return response()->success(['data' => 0]);
- }
- }
-
- function getOfficialImgTxtUrlByBookName(Request $request)
- {
- $distribution_channel_id = $this->getChannelId();
- $book_name = $request->has('book_name') ? $request->input('book_name') : '';
- if (empty($book_name)) {
- return response()->error("PARAM_EMPTY");
- }
- $customMsgService = CustomMsgService::getOfficialImgTxtUrlByBookName($distribution_channel_id, $book_name);
- if (!empty($customMsgService)) {
-
- return response()->pagination(new OfficialImgtextUrlsTransformer(), $customMsgService);
- } else {
- return response()->success(['data' => 0]);
- }
- }
-
- function uploadQrcodeImgToWechat(Request $request)
- {
- $distribution_channel_id = $this->getChannelId();
- $qrcode_Img = $request->has('qrcode_Img') ? $request->input('qrcode_Img') : '';
- if (empty($qrcode_Img)) {
- return response()->error("PARAM_EMPTY");
- }
- $officialImgTxtUrlPrams['distribution_channel_id'] = $distribution_channel_id;
- $officialImgTxtUrlPrams['qrcode_Img'] = $qrcode_Img;
- $result = CustomMsgService::uploadQrcodeImgToWechat($officialImgTxtUrlPrams);
- if ($result) {
-
- return response()->success(['media_id' => $result['media_id'], 'url' => $result['url']]);
- } else {
- return response()->success();
- }
- }
- function uploadQrcodeImgToOss(Request $request)
- {
- \Log::info('-----------------OSS上传二维码图片');
- $distribution_channel_id = $this->getChannelId();
- if ($request->hasFile('photo')) {
- $file = $request->file('photo');
- $ossImgBackData = $this->ossObject()->uploadFile(env('OSS_BUCKET', 'zhuishuyun'), 'service/qrcodeimg_' . $distribution_channel_id . '_' . time() . '.' . $file->getClientOriginalName(), $file->path());
- $ossImg = $ossImgBackData['oss-request-url'];
- \Log::info('-----------------OSS上传二维码图片成功');
- \Log::info($ossImg);
- return response()->success(['qrcode_img' => $ossImg]);
- } else {
- \Log::info('-----------------没获取到传过来的图片');
- }
- }
-
- function delOfficialImgTxtUrl(Request $request)
- {
- $id = $request->has('id') ? $request->input('id') : '';
- if (empty($id)) {
- return response()->error("PARAM_EMPTY");
- }
- $customMsgServiceStatus = CustomMsgService::delOfficialImgTxtUrl($id);
- if ($customMsgServiceStatus == 1) {
- return response()->success();
- } elseif ($customMsgServiceStatus == 2) {
- return response()->error('OFFICIAL_IMGTXT_FOUNDFAILED');
- } elseif ($customMsgServiceStatus == 0) {
- return response()->error('OFFICIAL_IMGTXT_DELFAILED');
- } else {
- return response()->error('OFFICIAL_IMGTXT_DELFAILED');
- }
- }
- }
|