ConditionsController.php 75 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859
  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use App\Models\WxTenant;
  4. use App\Wen\Utils\Settings;
  5. use App\Wen\Utils\UserUtils;
  6. use App\Models\User\WxUser;
  7. use App\Models\Conditions;
  8. use App\Models\UserStanding;
  9. use App\Models\WxGift;
  10. use App\Models\WxUserGift;
  11. use App\Models\User\WxUserFinancial;
  12. use App\Models\User\WxUserFinancialRecord;
  13. use App\Models\UserRecommended;
  14. use App\Wen\Utils\Utils;
  15. use App\Models\WxXiangqin;
  16. use App\Models\WxSlideshow;
  17. use App\Models\WxUserNotice;
  18. use App\Models\System\ChinaArea;
  19. use App\Models\WxSetting;
  20. use App\Models\User\WxUserFollow;
  21. use App\Wen\Utils\SafeUtils;
  22. use App\Http\Controllers\Api\OrderController;
  23. use Illuminate\Support\Facades\Http;
  24. use App\Http\Controllers\Api\UserController;
  25. use Illuminate\Support\Facades\Log;
  26. use Illuminate\Http\Request;
  27. use Illuminate\Support\Facades\Cache;
  28. use Illuminate\Support\Facades\DB;
  29. use Illuminate\Support\Str;
  30. use Illuminate\Contracts\Validation\Validator;
  31. use Laravel\Socialite\Facades\Socialite;
  32. use App\Wen\Utils\BaiduUtils;
  33. class ConditionsController extends BaseController
  34. {
  35. /** 把日志写到公共日志
  36. * @param Request $request
  37. * @return \Illuminate\Http\JsonResponse
  38. */
  39. public function putLog(Request $request){
  40. $log = $request->log;
  41. _logger_(__file__, __line__, $log);
  42. return $this->success();
  43. }
  44. /**
  45. * 获取用户信息接口
  46. */
  47. public function getUserWhiteList(Request $request)
  48. {
  49. $id = $request->user_id;
  50. $uid = $request->uid;
  51. // print_r($uid);exit;
  52. $info = WxUser::where('id', $id)->first(['id','is_official']);
  53. // print_r($info->is_member);exit;
  54. if (empty($info)) {
  55. return $this->fail(200000, [], '用户不存在');
  56. }
  57. if ($info->is_official == 0) {
  58. $user_info = WxUser::where('id',$uid)->first(['id','is_official']);
  59. // print_r($user_info);exit;
  60. if ($user_info->is_official == 1) {
  61. $info->is_official = 1;
  62. }
  63. }
  64. return $this->success($info);
  65. }
  66. /**
  67. * 获取首页列表
  68. */
  69. public function getIndexList(Request $request)
  70. {
  71. $list[0]['id'] = 1;
  72. $list[0]['name'] = '全部';
  73. $list[0]['is_vip'] = 0;
  74. $list[1]['id'] = 2;
  75. $list[1]['name'] = '推荐';
  76. $list[1]['is_vip'] = 0;
  77. $wheresa = ['is_city_wide','is_new_list'];
  78. $info = WxSetting::whereIn('key',$wheresa)->get();
  79. // print_r($info[0]);exit;
  80. if ($info[0]['value'] == 1) {
  81. $list[2]['id'] = 3;
  82. $list[2]['name'] = '同城';
  83. $list[2]['is_vip'] = 1;
  84. }
  85. if ($info[1]['value'] == 1) {
  86. $list[3]['id'] = 4;
  87. $list[3]['name'] = '最新';
  88. $list[3]['is_vip'] = 1;
  89. }
  90. // 重新排序
  91. $list = array_values($list);
  92. return $this->success($list);
  93. }
  94. /**
  95. * 推荐自己回调
  96. */
  97. public function recommendSelfCallback($data)
  98. {
  99. $order_sn = $data['order_sn'];
  100. $order = UserRecommended::where('order_sn', $order_sn)->first();
  101. if (empty($order)) {
  102. return $this->fail(200000, [], '订单不存在');
  103. }
  104. // 获取是否是续费订单
  105. $pid = $order->pid;
  106. $time = time();
  107. if ($pid > 0) {
  108. // 如果是续费订单
  109. $pid_order = UserRecommended::where('id', $pid)->first();
  110. if (empty($pid_order)) {
  111. // return $this->fail(200000, [], '续费订单不存在');
  112. // 续费订单不存在,直接更新当前订单
  113. $order->start_time = $time;
  114. $order->end_time = $time + ($order->day_num * 86400);
  115. $order->status = 2;
  116. $order->pid = 0;
  117. $order->pay_time = $time;
  118. $order->save();
  119. } else {
  120. $order->start_time = $time;
  121. $order->end_time = $time + ($order->day_num * 86400);
  122. $order->status = 4;
  123. $order->pay_time = $time;
  124. $order->save();
  125. // 更新续费订单
  126. $pid_order->end_time = $pid_order->end_time + ($order->day_num * 86400);
  127. $pid_order->save();
  128. }
  129. } else {
  130. $order->start_time = $time;
  131. $order->end_time = $time + ($order->day_num * 86400);
  132. $order->status = 2;
  133. $order->pay_time = $time;
  134. $order->save();
  135. }
  136. // 更新推荐状态 和推荐结束时间(结束时间+推荐天数*86400) 如果推荐结束时间为空或者小于当前时间 则更新为当前时间
  137. $conditions = Conditions::where('user_id', $order->user_id)->first();
  138. if (empty($conditions->recommend_end_time) || $conditions->recommend_end_time < time()) {
  139. $conditions->recommend_end_time = $time + ($order->day_num * 86400);
  140. $conditions->save();
  141. } else {
  142. $conditions->recommend_end_time = $conditions->recommend_end_time + ($order->day_num * 86400);
  143. $conditions->save();
  144. }
  145. }
  146. /**
  147. * 详情
  148. */
  149. public function getConditionsDetailAdmin($id)
  150. {
  151. // $id = $request->uid;
  152. $id = $id;
  153. $info = Conditions::where('user_id', $id)->first();
  154. if (empty($info)) {
  155. return [];
  156. }
  157. $info['video_url'] = $info['video_url'] ?? '';
  158. $info['addresss'] = $info['addresss'] ?? '';
  159. $info['registration'] = $info['registration'] ?? '';
  160. $info['content'] = $info['content'] ?? '';
  161. if (!empty($info['addresss'])) {
  162. $address_name = explode(',',$info['addresss']);
  163. $info['addresss'] = $address_name[0].$address_name[1];
  164. }
  165. if (!empty($info['registration'])) {
  166. $registration_name = explode(',',$info['registration']);
  167. $info['registration'] = $registration_name[0].$registration_name[1];
  168. }
  169. $settings = $this->getSettings(2);
  170. // 获取用户的名称
  171. $user = WxUser::where('id', $info['user_id'])->first(['user_name','is_yy','is_real']);
  172. $info['user_name'] = $user->user_name ?? '';
  173. $info['is_yy'] = $user->is_yy ?? 0;
  174. $info['is_real'] = $user->is_real ?? 0;
  175. $info['house_name'] = $this->getNameInfo($settings['house'], $info['house']); // 买房情况
  176. $info['occupation_name'] = $this->getNameInfo($settings['occupation'], $info['occupation']); // 职业
  177. $info['income_name'] = $this->getNameInfo($settings['income'], $info['income']); // 收入
  178. $info['age'] = $info['age'] . '岁'; // 年龄
  179. $info['height'] = $info['height'] . 'cm'; // 身高
  180. $info['educational_name'] = $this->getNameInfo($settings['educational'], $info['educational']);// 学历
  181. $info['img_urls'] = explode(',', $info['img_urls']);
  182. $info['sex_name'] = $info['sex'] == 1 ? '男' : '女';
  183. $info['matrimony_name'] = $this->getNameInfo($settings['matrimony'], $info['matrimony']); // 婚姻状况
  184. $info['only_name'] = $info['is_only'] == 1 ? '是' : '否'; // 独生子女
  185. $info['married_name'] = $this->getNameInfo($settings['married'], $info['married']); // 何时结婚
  186. $info['car_name'] = $this->getNameInfo($settings['car'], $info['car']);// 买车情况
  187. $info['choose_small_educational_name'] = $this->getNameInfo($settings['educational'], $info['choose_small_educational']); // 择偶-最低学历
  188. $info['choose_matrimony_name'] = $this->getNameInfo($settings['matrimony'], $info['choose_matrimony']); // 择偶-婚姻状况要求
  189. $info['choose_house_name'] = $this->getNameInfo($settings['house'], $info['choose_house']); // 择偶-住房要求
  190. $info['choose_age'] = $this->getNameInfo($settings['choose_age'], $info['choose_age']); // 择偶-住房要求
  191. $info['choose_child_name'] = $info['choose_child'] == 1 ? '接受' : '不接受'; // 择偶-接受对方小孩
  192. $info['choose_income_name'] = $this->getNameInfo($settings['choose_income'], $info['choose_income']); // 择偶-最低月薪
  193. $info['choose_content'] = explode(',', $info['choose_content']);
  194. unset($info['choose_child_name']);
  195. if (!empty($info['choose_matrimony_name'])) {
  196. $info['choose_matrimony_name'] = '婚姻状况:'.$info['choose_matrimony_name'];
  197. }
  198. if (!empty($info['choose_income_name'])) {
  199. if ($info['choose_income_name'] == '不限') {
  200. $info['choose_income_name'] = '不限';
  201. } else {
  202. $info['choose_income_name'] = '月收入'.$info['choose_income_name'] . '以上'; // 择偶-最低身高
  203. }
  204. }
  205. if ($info['choose_small_educational_name'] == '初中以下') {
  206. $info['choose_small_educational_name'] = '初中以上';
  207. } else if ($info['choose_small_educational_name'] == '') {
  208. $info['choose_small_educational_name'] = '不限';
  209. } else {
  210. $info['choose_small_educational_name'] = $info['choose_small_educational_name'].'及以上';
  211. }
  212. if (!empty($info['choose_small_height'])) {
  213. if ($info['choose_small_height'] == '不限') {
  214. $info['choose_small_height'] = '不限';
  215. } else {
  216. $info['choose_small_height'] = $info['choose_small_height'] . '以上'; // 择偶-最低身高
  217. }
  218. }
  219. // if ($info['choose_small_height'] == '不限') {
  220. // $info['choose_small_height'] = '不限';
  221. // } else {
  222. // $info['choose_small_height'] = $info['choose_small_height'] . 'cm以上'; // 择偶-最低身高
  223. // }
  224. // print_r('<pre>');
  225. // print_r($info);
  226. // exit;
  227. // 获取礼物列表
  228. $gifts = WxGift::get(['id','name','photo_url'])->toArray();
  229. $gift_num = 0;
  230. // 获取礼物数量
  231. foreach ($gifts as $key => $val) {
  232. $num = WxUserGift::where('accept_user_id', $info['user_id'])->where('gift_id', $val['id'])->count();
  233. if ($num == 0) {
  234. unset($gifts[$key]);
  235. } else {
  236. $gifts[$key]['num'] = $num;
  237. $gift_num += $num;
  238. }
  239. }
  240. if (empty($gifts)) {
  241. $gifts = [];
  242. } else {
  243. // 重新排序
  244. $gifts = array_values($gifts);
  245. }
  246. $is_follow = (new WxUserFollow())->isFollowUser($info['id'], $info['user_id']);
  247. $info['is_follow'] = $is_follow ? 1 : 0;
  248. $info['gift_num'] = $gift_num;
  249. $info['gifts'] = $gifts;
  250. // print_r($id);exit;
  251. if ($info['step']) {
  252. $info['step'] = $info['step']+1;
  253. } else {
  254. $info['step'] = 0+1;
  255. }
  256. //$info['user_choose_content'] = $this->getConditionsById($info['choose_content'],'choose_content',4);
  257. return $info;
  258. return $this->success($info);
  259. }
  260. /**
  261. * 获取标签
  262. */
  263. public function getTagList($type=1)
  264. {
  265. $educational = [
  266. ['id' => 1, 'name' => '毛遂自荐'],
  267. ['id' => 2, 'name' => '温柔善良'],
  268. ['id' => 3, 'name' => '勤俭持家'],
  269. ];
  270. if ($type == 1) {
  271. return $this->success($educational);
  272. } else {
  273. return $educational;
  274. }
  275. }
  276. /**
  277. * 获取红娘信息
  278. */
  279. public function getMatchmakerInfo(Request $request)
  280. {
  281. $type = $request->type;
  282. // print_r($type);exit;
  283. if ($type == 1) {
  284. $wheresa = ['xiangqin_name','xiangqin_wx_code','xiangqin_wx_img'];
  285. $info = WxSetting::whereIn('key',$wheresa)->get();
  286. $data = [
  287. 'id' => 1,
  288. 'name' => $info[0]['value'],
  289. 'wx_code' => $info[1]['value'],
  290. 'wx_img' => $info[2]['value'],
  291. ];
  292. } else {
  293. $wheresa = ['xiangqin_one_name','xiangqin_one_wx_code','xiangqin_one_wx_img'];
  294. $info = WxSetting::whereIn('key',$wheresa)->get();
  295. $data = [
  296. 'id' => 2,
  297. 'name' => $info[0]['value'],
  298. 'wx_code' => $info[1]['value'],
  299. 'wx_img' => $info[2]['value'],
  300. ];
  301. }
  302. return $this->success($data);
  303. }
  304. /**
  305. * 获取用户信息接口
  306. */
  307. public function getUserInfo(Request $request)
  308. {
  309. $id = $request->uid;
  310. $info = WxUser::where('id', $id)->first(['id','is_yy','is_real','is_member','gender','age','requirement','is_online_status']);
  311. // print_r($info->is_member);exit;
  312. if (empty($info)) {
  313. return $this->fail(200000, [], '用户不存在');
  314. }
  315. // if (empty($info->is_member)) {
  316. // $info->is_member = 0;
  317. // } else if ($info->is_member <= time()) {
  318. // $info->is_member = 0;
  319. // } else {
  320. // $info->is_member = 1;
  321. // }
  322. if (empty($info->gender) || empty($info->age) || empty($info->requirement)) {
  323. $info->is_user_info = 0;
  324. } else {
  325. $info->is_user_info = 1;
  326. }
  327. return $this->success($info);
  328. }
  329. /**
  330. * 获取地区
  331. */
  332. public function getAreaList(Request $request)
  333. {
  334. $pid = $request->code;
  335. // print_r($pid);exit;
  336. if (empty($pid)) {
  337. $area = ChinaArea::where('pcode', 0)->get(['code','name']);
  338. return $this->success($area);
  339. }
  340. $area = ChinaArea::where('pcode', $pid)->get(['code','name']);
  341. return $this->success($area);
  342. }
  343. /**
  344. * 获取选择内容
  345. */
  346. public function getChooseContent(Request $request)
  347. {
  348. $wheresa = ['xiangqin_question'];
  349. $info = WxSetting::whereIn('key',$wheresa)->get();
  350. $list = $info[0]['value'];
  351. $list = json_decode($list, true);
  352. foreach ($list as $key => $val) {
  353. $list[$key]['id'] = $key+1;
  354. }
  355. // print_r($list);exit;
  356. // $list[0] = [
  357. // 'id' => 1,
  358. // 'name' => 'NO.1 亿友圈内找对象',
  359. // ];
  360. // $list[1] = [
  361. // 'id' => 2,
  362. // 'name' => 'NO.2 了解乙肝治疗知识',
  363. // ];
  364. // $list[2] = [
  365. // 'id' => 3,
  366. // 'name' => 'NO.3 随便逛逛',
  367. // ];
  368. return $this->success(['list' => $list]);
  369. }
  370. /**
  371. * 个人信息
  372. */
  373. public function updateUserInfo(Request $request)
  374. {
  375. global $__MINI_GLOBAL_IP__;
  376. $uid = $request->uid;
  377. $age = $request->age;
  378. // print_r($uid);exit;
  379. // 身高范围
  380. $requirement = $request->requirement;
  381. $user_avatar = $request->user_avatar;
  382. $user_name = $request->user_name;
  383. $is_online_status = $request->is_online_status;
  384. $data = [];
  385. //print_r($requirement);exit;
  386. // 性别
  387. $sex = $request->sex;
  388. //$data['age'] = $age;
  389. //$data['requirement'] = $requirement;
  390. //$data['gender'] = $sex;
  391. //$data['user_name'] = $user_name;
  392. // 判断头像是否为空 为空不上传
  393. if (!empty($user_avatar)) {
  394. $data['user_avatar'] = $user_avatar;
  395. }
  396. if (isset($user_name)) {
  397. $data['user_name'] = $user_name;
  398. }
  399. if (isset($is_online_status)) {
  400. $data['is_online_status'] = $is_online_status;
  401. }
  402. if (isset($age)) {
  403. $data['age'] = $age;
  404. }
  405. if (isset($requirement)) {
  406. $data['requirement'] = $requirement;
  407. }
  408. if (isset($sex)) {
  409. $data['gender'] = $sex;
  410. }
  411. if ($data != []) {
  412. $info = WxUser::where('id', $uid)->update($data);
  413. }
  414. $requirement_list = explode(',', $requirement);
  415. // 检测里面是否包含 亿友圈内找对象 文字(要模糊查询 里面可能还有别的文字)
  416. $is_find = 0;
  417. foreach ($requirement_list as $key => $val) {
  418. if (strpos($val, '亿友圈内找对象') !== false) {
  419. $is_find = 1;
  420. }
  421. }
  422. // print_r($is_find);exit;
  423. if ($is_find == 1) {
  424. // 亿友圈内找对象 Conditions
  425. $info = Conditions::where('user_id', $uid)->first(['id']);
  426. //print_r($info);exit;
  427. if (!empty($info)) {
  428. $info->status = 1;
  429. $info->save();
  430. } else {
  431. $res = _ip_address($__MINI_GLOBAL_IP__);
  432. // print_r($res);exit;
  433. if(_empty_($res)){
  434. // 获取wxuser 表的地区
  435. $user_info = WxUser::where('id', $uid)->first(['province','city','district']);
  436. $ip_address = $user_info->province .','. $user_info->city .','. $user_info->district;
  437. $add_conditions['ip_address'] = $ip_address;
  438. } else {
  439. // 更新用户相亲表 ip 地址地区
  440. // 判断是否存在不存在就不更新 ,如果 ip_address 相同 也不更新
  441. $ip_address = $res['province'] .','. $res['city'] .','. $res['district'];
  442. $add_conditions['ip_address'] = $ip_address;
  443. }
  444. // 如果不存在添加 Conditions
  445. $add_conditions['img_urls'] = $request->user_avatar;
  446. $add_conditions['age'] = $request->age;
  447. $add_conditions['sex'] = $sex;
  448. $add_conditions['create_time'] = time();
  449. $add_conditions['user_id'] = $uid;
  450. $add_conditions['status'] = 1;
  451. //print_r($add_conditions);exit;
  452. Conditions::create($add_conditions);
  453. }
  454. }
  455. return $this->success();
  456. }
  457. /**
  458. * 获取轮播图
  459. */
  460. public function getSlideshow(Request $request)
  461. {
  462. $slideshow = WxSlideshow::wherein('id', explode(',', Settings::get('app_xiangqin_index_banner', '', true)))->orderBy(DB::raw('FIND_IN_SET(id, "' . Settings::get('app_xiangqin_index_banner', '', true) . '"' . ")"))->get(['id', 'poster', 'target_id', 'slideshow_type']);
  463. // sort 排序
  464. // $where[] = ['slideshow_state', 1];
  465. // $where[] = ['is_xiangqin', 1];
  466. // $slideshow = WxSlideshow::where($where)->get(['poster','target_id','slideshow_type']);
  467. foreach ($slideshow as $key => $val) {
  468. unset($slideshow[$key]['id']);
  469. }
  470. return $this->success(['data' => $slideshow]);
  471. }
  472. /**
  473. * 查看公告
  474. */
  475. public function getNoticeInfo(Request $request)
  476. {
  477. $id = $request->id;
  478. $notice = Settings::get('app_xiangqin_index_notice', [], true);
  479. $info = $notice[$id - 1] ?? [];
  480. // 查询wx_user_notice 表
  481. $wx_swhere = [];
  482. $wx_swhere[] = ['notice_info', $info['text']];
  483. $wx_swhere[] = ['user_id', $request->uid];
  484. $notice_info = WxUserNotice::where($wx_swhere)->first();
  485. if (empty($notice_info)) {
  486. $data = [
  487. 'user_id' => $request->uid,
  488. 'notice_info' => $info['text'],
  489. ];
  490. WxUserNotice::create($data);
  491. }
  492. return $this->success();
  493. }
  494. /**
  495. * 获取相亲tab
  496. *
  497. */
  498. public function getXiangQinTab()
  499. {
  500. $notice = Settings::get('app_xiangqin_index_nav', [], true);
  501. return $this->success(['data' => $notice]);
  502. }
  503. /**
  504. * 获取 会员消息提示
  505. * app_index_nav
  506. */
  507. public function getVipMessage()
  508. {
  509. $wheresa = ['message_vip_name','huji_vip_name','jvzhu_vip_name','yincang_vip_name'];
  510. $info = WxSetting::whereIn('key',$wheresa)->get();
  511. $message_vip_name = Settings::get('message_vip_name', [], true);
  512. $huji_vip_name = Settings::get('huji_vip_name', [], true);
  513. $jvzhu_vip_name = Settings::get('jvzhu_vip_name', [], true);
  514. $data['message_vip_name'] = $info[2]['value'];
  515. $data['huji_vip_name'] = $info[0]['value'];
  516. $data['jvzhu_vip_name'] = $info[1]['value'];
  517. $data['yincang_vip_name'] = $info[3]['value'];
  518. return $this->success(['data' => $data]);
  519. // return $this->success(['data' => $info]);
  520. }
  521. /**
  522. * 获取公告列表
  523. * app_index_nav
  524. */
  525. public function getNoticeList(Request $request)
  526. {
  527. $notice = Settings::get('app_xiangqin_index_notice', [], true);
  528. foreach ($notice as $key => $val) {
  529. $notice[$key]['id'] = $key+1;
  530. // 查询wx_user_notice 表
  531. $wx_swhere = [];
  532. $wx_swhere[] = ['notice_info', $val['text']];
  533. $wx_swhere[] = ['user_id', $request->uid];
  534. $info = WxUserNotice::where($wx_swhere)->count();
  535. if ($info > 0) {
  536. $notice[$key]['is_read'] = 1;
  537. } else {
  538. $notice[$key]['is_read'] = 0;
  539. }
  540. }
  541. // print_r($notice);exit;
  542. return $this->success(['data' => $notice]);
  543. }
  544. /**
  545. * 获取跳转ID
  546. */
  547. public function getTargetId(Request $request)
  548. {
  549. $where[] = ['id', '<>', 0];
  550. $info = WxXiangqin::where($where)->get(['id','type','target_id']);
  551. if (empty($info)) {
  552. return $this->fail(200000, [], '数据不存在');
  553. }
  554. return $this->success(['data' => $info]);
  555. }
  556. /**
  557. * 获取推荐自己每天的价格
  558. */
  559. public function getRecommendSelfPrice(Request $request)
  560. {
  561. $wheresa = ['tuijian_price'];
  562. $info = WxSetting::whereIn('key',$wheresa)->get();
  563. $day_price = $info[0]['value'];
  564. // 转换为数字
  565. $day_price = intval($day_price);
  566. return $this->success(['day_price' => $day_price]);
  567. }
  568. /**
  569. * 推荐自己
  570. */
  571. public function recommendSelf(Request $request)
  572. {
  573. $uid = $request->uid;
  574. $day_num = $request->day_num;// 推荐天数
  575. $tag = $request->tag;// 标签
  576. $type = $request->type;// 1:余额支付 2:微信支付
  577. $user = WxUser::where('id', $uid)->first(['is_yy','is_real']);
  578. if (empty($user)) {
  579. return $this->fail(200000, [], '用户不存在');
  580. }
  581. // if ($user->is_yy == 0 || $user->is_real == 0) {
  582. // return $this->fail(200000, [], '用户未实名认证或者未亿友认证');
  583. // }
  584. // 获取每天推荐需要多少钱
  585. $day_price = 1;
  586. $total_price = $day_num * $day_price;
  587. // 获取当前用户相亲表ID
  588. $info = Conditions::where('user_id', $uid)->first(['id']);
  589. if (empty($info)) {
  590. return $this->fail(200000, [], '请先发布相亲信息');
  591. }
  592. // 检测当前用户是否在推荐中
  593. $pid = 0;
  594. $ur_info = UserRecommended::where('user_id', $uid)->where('status', 2)->first();
  595. if (!empty($ur_info)) {
  596. // 如果已经在推荐中 续费时间
  597. $pid = $ur_info->id;
  598. }
  599. if ($pid == 0) {
  600. // 检测现在已发布的数量
  601. $count = UserRecommended::where('status', 2)->count();
  602. // 获取配置的最大推荐数量
  603. $max_num = Settings::get('app_max_recommend_num', 10);
  604. if ($count >= $max_num) {
  605. return $this->fail(200000, [], '推荐数量已经达到上限');
  606. }
  607. }
  608. $user_financial = WxUserFinancial::where('user_id', $request->uid)->first();
  609. if (empty($user_financial)) {
  610. return $this->fail(200001, [], '余额不足');
  611. }
  612. if ($user_financial->balance < $total_price) {
  613. return $this->fail(200001, [], '余额不足');
  614. }
  615. // 生成随机数字订单编号 纯数字
  616. $order_sn = Utils::getSn(1);
  617. $data = [
  618. 'user_id' => $uid,
  619. 'uc_id' => $info->id,
  620. 'order_sn' => $order_sn,
  621. 'tag' => $tag,
  622. 'day_num' => $day_num,
  623. 'start_time' => time(),
  624. 'end_time' => time() + ($day_num * 86400),
  625. 'status' => 1,
  626. 'price' => $total_price,
  627. 'pid' => $pid,
  628. 'create_time' => time(),
  629. ];
  630. UserRecommended::create($data);
  631. // 扣除用户的余额
  632. $user_financial->balance = $user_financial->balance - $total_price;
  633. $user_financial->save();
  634. if ($type == 1) {
  635. $this->recommendSelfCallback($data);
  636. return $this->success();
  637. } else {
  638. $pay_info['body'] = '推荐自己';
  639. $pay_info['price'] = $total_price;
  640. $pay_info['order_sn'] = $order_sn;
  641. return (new OrderController)->orderfun($uid,$data);
  642. }
  643. }
  644. /**
  645. * 赠送礼物
  646. */
  647. public function sendGift(Request $request)
  648. {
  649. // 获取赠送礼物的ID
  650. $gift_id = $request->gift_id;
  651. $gift_num = $request->gift_num;
  652. // 获取接收礼物的用户ID
  653. $accept_user_id = $request->accept_user_id;
  654. // 获取分成
  655. $wheresa = ['share_proportion'];
  656. $info = WxSetting::whereIn('key',$wheresa)->get();
  657. $app_reward_platform_percent = $info[0]['value'];
  658. $gift = WxGift::where('id', $gift_id)->first();
  659. if (empty($gift)) {
  660. return $this->fail(200000, [], '礼物不存在');
  661. }
  662. $price = $gift->price * $gift_num;
  663. // 获取用户的余额
  664. $user_financial = WxUserFinancial::where('user_id', $request->uid)->first();
  665. if (empty($user_financial)) {
  666. return $this->fail(200000, [], '余额不足1');
  667. }
  668. if ($user_financial->balance < $price) {
  669. return $this->fail(200001, [], '余额不足');
  670. }
  671. // 开始赠送礼物
  672. $data = [
  673. 'user_id' => $request->uid,
  674. 'accept_user_id' => $accept_user_id,
  675. 'gift_id' => $gift_id,
  676. 'num' => $gift_num,
  677. 'price' => $price,
  678. 'create_time' => time(),
  679. ];
  680. WxUserGift::create($data);
  681. // 扣除用户的余额
  682. $user_financial->balance = $user_financial->balance - $price;
  683. $user_financial->save();
  684. // 平台分成
  685. $platform_price = $price * $app_reward_platform_percent / 100;
  686. // 接受礼物的收入 = 价格 - 平台分成
  687. // 接受礼物的人收入
  688. $accept_user_financial = WxUserFinancial::where('user_id', $accept_user_id)->first();
  689. if (empty($accept_user_financial)) {
  690. // 创建
  691. // $accept_user_financial = [
  692. // 'user_id' => $accept_user_id,
  693. // 'balance' => $price - $platform_price,
  694. // ];
  695. $accept_user_financial['user_id'] = $accept_user_id;
  696. $accept_user_financial['balance'] = $price - $platform_price;
  697. $user_financial_record = $price - $platform_price;
  698. WxUserFinancial::create($accept_user_financial);
  699. } else {
  700. $user_financial_record = $accept_user_financial->balance + $price - $platform_price;
  701. $accept_user_financial->balance = $user_financial_record;
  702. $accept_user_financial->save();
  703. }
  704. // WxUserFinancialRecord 记录
  705. $record = [
  706. 'user_id' => $request->uid,
  707. 'num' => $user_financial_record,
  708. 'type' => 6,
  709. 'balance' => $user_financial->balance,
  710. 'tip'=>'礼物收益增加'.$user_financial_record.',平台收入'.$platform_price,
  711. 'created_at' => date('Y-m-d H:i:s'),
  712. ];
  713. WxUserFinancialRecord::create($record);
  714. // 赠送成功
  715. return $this->success();
  716. }
  717. /**
  718. * 获取礼物列表
  719. */
  720. public function getGiftList(Request $request)
  721. {
  722. $list = WxGift::get(['id','name','photo_url','price']);
  723. return $this->success($list);
  724. }
  725. /**
  726. * 详情
  727. */
  728. public function getConditionsDetail(Request $request)
  729. {
  730. // $id = $request->uid;
  731. $id = $request->id;
  732. $info = Conditions::where('id', $id)->first();
  733. $info['addresss'] = $info['addresss'] ?? '';
  734. $info['registration'] = $info['registration'] ?? '';
  735. // print_r($info['registration']);exit;
  736. if (!empty($info['addresss'])) {
  737. $address_name = explode(',',$info['addresss']);
  738. $info['addresss'] = $address_name[0].$address_name[1];
  739. }
  740. if (!empty($info['registration'])) {
  741. $registration_name = explode(',',$info['registration']);
  742. $info['registration'] = $registration_name[0].$registration_name[1];
  743. }
  744. $settings = $this->getSettings(2);
  745. // 获取用户的名称
  746. $user = WxUser::where('id', $info['user_id'])->first(['user_name','is_yy','is_real']);
  747. $info['user_name'] = $user->user_name ?? '';
  748. //$info['is_yy'] = $user->is_yy ?? 0;
  749. //$info['is_real'] = $user->is_real ?? 0;
  750. $info['house_name'] = $this->getNameInfo($settings['house'], $info['house']); // 买房情况
  751. $info['occupation_name'] = $this->getNameInfo($settings['occupation'], $info['occupation']); // 职业
  752. $info['income_name'] = $this->getNameInfo($settings['income'], $info['income']); // 收入
  753. if (empty($info['age'])) {
  754. $info['age'] = '暂无';
  755. } else {
  756. $info['age'] = $info['age'] . '岁'; // 年龄
  757. }
  758. if (empty($info['height'])) {
  759. $info['height'] = '暂无';
  760. } else {
  761. $info['height'] = $info['height'] . 'cm'; // 身高
  762. }
  763. $info['educational_name'] = $this->getNameInfo($settings['educational'], $info['educational']);// 学历
  764. $info['img_urls'] = explode(',', $info['img_urls']);
  765. $info['sex_name'] = $info['sex'] == 1 ? '男' : '女';
  766. $info['matrimony_name'] = $this->getNameInfo($settings['matrimony'], $info['matrimony']); // 婚姻状况
  767. $info['only_name'] = $info['is_only'] == 1 ? '是' : '否'; // 独生子女
  768. $info['married_name'] = $this->getNameInfo($settings['married'], $info['married']); // 何时结婚
  769. $info['car_name'] = $this->getNameInfo($settings['car'], $info['car']);// 买车情况
  770. $info['choose_small_educational_name'] = $this->getNameInfo($settings['educational'], $info['choose_small_educational']); // 择偶-最低学历
  771. $info['choose_matrimony_name'] = $this->getNameInfo($settings['matrimony'], $info['choose_matrimony']); // 择偶-婚姻状况要求
  772. $info['choose_house_name'] = $this->getNameInfo($settings['house'], $info['choose_house']); // 择偶-住房要求
  773. $info['choose_age'] = $this->getNameInfo($settings['choose_age'], $info['choose_age']); // 择偶-住房要求
  774. $info['choose_small_height'] = $this->getNameInfo($settings['choose_small_height'], $info['choose_small_height']); // 择偶-住房要求
  775. $info['choose_child_name'] = $info['choose_child'] == 1 ? '接受' : '不接受'; // 择偶-接受对方小孩
  776. unset($info['choose_child_name']);
  777. $info['choose_income_name'] = $this->getNameInfo($settings['choose_income'], $info['choose_income']); // 择偶-最低月薪
  778. // $info['choose_content'] = explode(',', $info['choose_content']);
  779. $info['choose_content'] = $this->getConditionsById($info['choose_content'],'choose_content',4);
  780. $info['peculiarity_names'] = $this->getConditionsById($info['peculiarity'],'peculiarity',4);
  781. $info['family_name'] = $this->getConditionsById($info['family'],'family',1);
  782. if (!empty($info['choose_matrimony_name'])) {
  783. $info['choose_matrimony_name'] = '婚姻状况:'.$info['choose_matrimony_name'];
  784. }
  785. if (!empty($info['choose_income_name'])) {
  786. if ($info['choose_income_name'] == '不限') {
  787. $info['choose_income_name'] = '不限';
  788. } else {
  789. $info['choose_income_name'] = '月收入'.$info['choose_income_name'] . '以上'; // 择偶-最低身高
  790. }
  791. }
  792. if ($info['choose_small_educational_name'] == '初中以下') {
  793. $info['choose_small_educational_name'] = '初中以上';
  794. } else if ($info['choose_small_educational_name'] == '') {
  795. $info['choose_small_educational_name'] = '不限';
  796. } else {
  797. $info['choose_small_educational_name'] = $info['choose_small_educational_name'].'及以上';
  798. }
  799. if (!empty($info['choose_small_height'])) {
  800. if ($info['choose_small_height'] == '不限') {
  801. $info['choose_small_height'] = '不限';
  802. } else {
  803. $info['choose_small_height'] = $info['choose_small_height'] . '以上'; // 择偶-最低身高
  804. }
  805. }
  806. // 获取礼物列表
  807. $gifts = WxGift::get(['id','name','photo_url'])->toArray();
  808. $gift_num = 0;
  809. // 获取礼物数量
  810. foreach ($gifts as $key => $val) {
  811. $num = WxUserGift::where('accept_user_id', $info['user_id'])->where('gift_id', $val['id'])->count();
  812. if ($num == 0) {
  813. unset($gifts[$key]);
  814. } else {
  815. $gifts[$key]['num'] = $num;
  816. $gift_num += $num;
  817. }
  818. }
  819. if (empty($gifts)) {
  820. $gifts = [];
  821. } else {
  822. // 重新排序
  823. $gifts = array_values($gifts);
  824. }
  825. $is_follow = (new WxUserFollow())->isFollowUser($request->uid, $info['user_id']);
  826. $info['is_follow'] = $is_follow ? 1 : 0;
  827. $info['gift_num'] = $gift_num;
  828. $info['gifts'] = $gifts;
  829. // print_r($id);exit;
  830. if ($info['step']) {
  831. $info['step'] = $info['step']+1;
  832. } else {
  833. $info['step'] = 0+1;
  834. }
  835. return $this->success($info);
  836. }
  837. /**
  838. * 首页列表
  839. */
  840. public function getConditionsList(Request $request)
  841. {
  842. $uid = $request->uid;
  843. $page = $request->page ?? 1;
  844. $limit = $request->limit ?? 10;
  845. $type = $request->type ?? 1;
  846. // 年龄范围
  847. $age = $request->age;
  848. // 身高范围
  849. $height = $request->height;
  850. // 性别
  851. $sex = $request->sex;
  852. // 学历
  853. $educational = $request->educational;
  854. // 职业
  855. $occupation = $request->occupation;
  856. // 收入
  857. $income = $request->income;
  858. // 婚姻状况
  859. $matrimony = $request->matrimony;
  860. // 实名认证
  861. $is_real = $request->is_real;
  862. // 现居地
  863. $addresss = $request->addresss;
  864. // 户籍地
  865. $registration = $request->registration;
  866. $offset = ($page - 1) * $limit;
  867. if ($age && $age != 0) {
  868. $age = explode('-', $age);
  869. $age = [$age[0], $age[1]];
  870. $where[] = ['age', '>=', $age[0]];
  871. $where[] = ['age', '<=', $age[1]];
  872. }
  873. if ($height && $height != 0) {
  874. $height = explode('-', $height);
  875. $height = [$height[0], $height[1]];
  876. $where[] = ['height', '>=', $height[0]];
  877. $where[] = ['height', '<=', $height[1]];
  878. }
  879. if ($sex && $sex != 0) {
  880. $where[] = ['sex', $sex];
  881. }
  882. if ($educational && $educational != 0) {
  883. $where[] = ['educational','>=', $educational];
  884. }
  885. if ($occupation && $occupation != 0) {
  886. $where[] = ['occupation', $occupation];
  887. }
  888. if ($income && $income != 0) {
  889. $where[] = ['income', $income];
  890. }
  891. if ($matrimony && $matrimony != 0) {
  892. $where[] = ['matrimony', $matrimony];
  893. }
  894. // 获取当前用户信息
  895. $user = WxUser::where('id', $uid)->first(['is_member']);
  896. $address_status = 0;
  897. // Log::info('addresss', ['addresss' => $addresss])
  898. if ($user->is_member > 0) {
  899. if ($addresss && $addresss != 0) {
  900. $where[] = ['addresss', 'like', '%' . $addresss . '%'];
  901. $address_status = 1;
  902. }
  903. if ($registration && $registration != 0) {
  904. // $where[] = ['registration', $registration];
  905. $where[] = ['registration', 'like', '%' . $registration . '%'];
  906. }
  907. }
  908. if ($is_real && $is_real != 0) {
  909. if ($is_real == 1) {
  910. $where[] = ['is_real', 1];
  911. } else {
  912. $where[] = ['is_yy', 1];
  913. }
  914. }
  915. $order_by = [
  916. ['id', 'desc'],
  917. ];
  918. if ($type == 1) {
  919. // 全部
  920. } else if ($type == 2) {
  921. // 推荐
  922. $where[] = ['recommend_end_time', '>', time()];
  923. $order_by = [
  924. ['r_time', 'asc'],
  925. ];
  926. } else if ($type == 3) {
  927. // 同城
  928. // 获取当前用户的省市区
  929. if ($address_status == 0) {
  930. $user_info = Conditions::where('user_id', $uid)->first(['ip_address']);
  931. // $where[] = ['addresss', $user_info->addresss];
  932. $where[] = ['ip_address', 'like', '%' . $user_info->ip_address . '%'];
  933. }
  934. } else {
  935. // 最新 create_time
  936. $order_by = [
  937. ['create_time', 'desc'],
  938. ];
  939. }
  940. $where[] = ['user_id', '>', 0];
  941. $where[] = ['is_xiangqin_status', '=', 1];
  942. // $where[] = ['status', '>', 0];
  943. // print_r($where);exit;
  944. $field = ['id', 'user_id', 'age', 'height', 'img_urls','house','occupation','income','educational','sex'];
  945. // $list = Conditions::where($where)->offset($offset)->limit($limit)->get($field);
  946. // $total = Conditions::where($where)->count();
  947. $query = Conditions::where($where)->offset($offset)->limit($limit);
  948. foreach ($order_by as $order) {
  949. $query->orderBy($order[0], $order[1]);
  950. }
  951. $list = $query->get($field);
  952. $total = Conditions::where($where)->count();
  953. $settings = $this->getSettings(2);
  954. $tag_list = $this->getTagList(2);
  955. // print_r($this->getNameInfo($settings['house'], 2));exit;
  956. foreach ($list as $key => $val) {
  957. if ($type == 2) {
  958. // 获取推荐标签 UserRecommended 表 user_id , 倒序排序,status = 2
  959. $recommend_tags = UserRecommended::where('user_id', $val['user_id'])->orderBy('id', 'desc')->whereIn('status', [2, 4])->first(['id','tag']);
  960. if (empty($recommend_tags)) {
  961. $list[$key]['recommend_tag_name'] = $tag_list[0]['name'] ?? '';
  962. } else {
  963. $recommend_tag_name = $tag_list[0]['name'] ?? '';
  964. foreach ($tag_list as $ks => $vs) {
  965. if ($vs['id'] == $recommend_tags->tag) {
  966. $recommend_tag_name = $vs['name'];
  967. }
  968. }
  969. $list[$key]['recommend_tag_name'] = $recommend_tag_name;
  970. }
  971. } else {
  972. $list[$key]['recommend_tag_name'] = '';
  973. }
  974. // print_r($val['house']);exit;
  975. $list[$key]['sex_name'] = $val['sex'] == 1 ? '男' : '女';
  976. $list[$key]['photo_img'] = explode(',', $val['img_urls'])[0];// 取第一张图片, 作为封面
  977. $list[$key]['img_urls'] = explode(',', $val['img_urls']);
  978. // 获取用户的名称
  979. $user = WxUser::where('id', $val['user_id'])->first(['user_name','is_yy','is_real']);
  980. $list[$key]['user_name'] = $user->user_name ?? '';
  981. $list[$key]['is_yy'] = $user->is_yy ?? 0;
  982. $list[$key]['is_real'] = $user->is_real ?? 0;
  983. // $list[$key]['house_name'] = $settings['house'][$val['house']]['name'] ?? '暂无';
  984. $list[$key]['house_name'] = $this->getNameInfo($settings['house'], $val['house']);
  985. $list[$key]['occupation_name'] = $this->getNameInfo($settings['occupation'], $val['occupation']);
  986. $list[$key]['income_name'] = $this->getNameInfo($settings['income'], $val['income']);
  987. if (empty($val['age'])) {
  988. $list[$key]['age'] = '暂无';
  989. } else {
  990. $list[$key]['age'] = $val['age'] . '岁';
  991. }
  992. if (empty($val['height'])) {
  993. $list[$key]['height'] = '暂无';
  994. } else {
  995. $list[$key]['height'] = $val['height'] . 'cm';
  996. }
  997. $list[$key]['educational_name'] = $this->getNameInfo($settings['educational'], $val['educational']);
  998. }
  999. return $this->success(['list' => $list, 'total' => $total]);
  1000. }
  1001. public function editConditions(Request $request)
  1002. {
  1003. $uid = $request->uid;
  1004. $step = 1;
  1005. if (empty($request->img_urls)) {
  1006. return $this->fail(200000, [], '图片地址不能为空');
  1007. }
  1008. if (empty($request->age)) {
  1009. return $this->fail(200000, [], '年龄不能为空');
  1010. }
  1011. if (empty($request->height)) {
  1012. return $this->fail(200000, [], '身高不能为空');
  1013. }
  1014. // if (empty($request->sex)) {
  1015. // return $this->fail(200000, [], '性别不能为空');
  1016. // }
  1017. if (empty($request->educational)) {
  1018. return $this->fail(200000, [], '学历不能为空');
  1019. }
  1020. if (empty($request->occupation)) {
  1021. return $this->fail(200000, [], '职业不能为空');
  1022. }
  1023. if (empty($request->income)) {
  1024. return $this->fail(200000, [], '收入不能为空');
  1025. }
  1026. if (empty($request->matrimony)) {
  1027. return $this->fail(200000, [], '婚姻状况不能为空');
  1028. }
  1029. if (empty($request->addresss)) {
  1030. return $this->fail(200000, [], '省市区不能为空');
  1031. }
  1032. if (empty($request->registration)) {
  1033. return $this->fail(200000, [], '户籍地不能为空');
  1034. }
  1035. if (empty($request->content)) {
  1036. return $this->fail(200000, [], '补充内容不能为空');
  1037. }
  1038. // 百度审核
  1039. $wheresa = ['is_xiangqin_audit_posts'];
  1040. $info = WxSetting::whereIn('key',$wheresa)->get();
  1041. $is_xiangqin_audit_posts = $info[0]['value'];
  1042. if(UserUtils::user_permissions_check_by_config($uid, 'xiangqin_audit_posts_white_list')){
  1043. $need_manual_review = false;
  1044. }else{
  1045. $need_manual_review = true;
  1046. }
  1047. if($is_xiangqin_audit_posts == 2 && $need_manual_review){
  1048. $filter_result = BaiduUtils::text_filter($request->content);
  1049. if($filter_result){
  1050. if($filter_result['hit_level'] == 2){
  1051. return $this->fail(200016, ['tip'=>$filter_result['tip_list'], 'hit_word'=>$filter_result['hit_word']]);
  1052. }
  1053. }
  1054. }
  1055. $data['img_urls'] = $request->img_urls ?? '';
  1056. $data['video_url'] = $request->video_url ?? '';
  1057. $data['age'] = $request->age ?? '';
  1058. $data['height'] = $request->height ?? '';
  1059. // $data['sex'] = $request->sex ?? '';
  1060. $data['educational'] = $request->educational ?? '';
  1061. $data['occupation'] = $request->occupation ?? '';
  1062. $data['income'] = $request->income ?? '';
  1063. $data['matrimony'] = $request->matrimony ?? '';
  1064. $data['addresss'] = $request->addresss ?? '';
  1065. $data['registration'] = $request->registration ?? '';
  1066. $data['content'] = $request->content ?? '';
  1067. $data['family'] = $request->family ?? '';
  1068. $data['is_only'] = $request->is_only ?? 0;
  1069. $data['married'] = $request->married ?? 0;
  1070. $data['car'] = $request->car ?? 0;
  1071. $data['house'] = $request->house ?? 0;
  1072. $data['peculiarity'] = $request->peculiarity ?? '';
  1073. // 检测 上面这个几个是否有提交的数据 family、is_only、married、car、house、peculiarity 里面其中一个不为空 修改步骤为2
  1074. if (!empty($request->family) || !empty($request->is_only) || !empty($request->married) || !empty($request->car) || !empty($request->house) || !empty($request->peculiarity)) {
  1075. $step = 2;
  1076. }
  1077. $data['choose_age'] = $request->choose_age ?? '';
  1078. $data['choose_small_height'] = $request->choose_small_height ?? '';
  1079. $data['choose_small_educational'] = $request->choose_small_educational ?? '';
  1080. $data['choose_income'] = $request->choose_income ?? '';
  1081. $data['choose_matrimony'] = $request->choose_matrimony ?? '';
  1082. $data['choose_house'] = $request->choose_house ?? '';
  1083. $data['choose_child'] = $request->choose_child ?? 0;
  1084. $data['choose_content'] = $request->choose_content ?? '';
  1085. if (!empty($request->choose_age) || !empty($request->choose_small_height) || !empty($request->choose_small_educational) || !empty($request->choose_income) || !empty($request->choose_matrimony) || !empty($request->choose_house) || !empty($request->choose_child) || !empty($request->choose_content)) {
  1086. $step = 3;
  1087. }
  1088. $user = WxUser::where('id', $uid)->first();
  1089. // 判断是否创建了数据
  1090. $info = Conditions::where('user_id', $uid)->first();
  1091. if ($info) {
  1092. // 判断步骤是否大于 当前步骤 如果大于当前步骤 则不更新步骤
  1093. if ($info->step < $step) {
  1094. $data['step'] = $step;
  1095. }
  1096. Conditions::where('user_id', $uid)->update($data);
  1097. } else {
  1098. // 获取 requirement 并逗号分隔 获取是否有 亿友圈内找对象 文字
  1099. $requirement = $user->requirement;
  1100. $requirementArray = explode(',', $requirement);
  1101. $is_find = 0;
  1102. $data['status'] = 0;
  1103. foreach ($requirementArray as $key => $val) {
  1104. if (strpos($val, '亿友圈内找对象') !== false) {
  1105. $is_find = 1;
  1106. $data['status'] = 1;
  1107. }
  1108. }
  1109. $data['create_time'] = date('Y-m-d H:i:s');
  1110. $data['step'] = $step;
  1111. Conditions::create($data);
  1112. }
  1113. //Conditions::where('user_id', $uid)->update($data);
  1114. // $user = WxUser::where('id', $uid)->first();
  1115. // address 分为province、city、area
  1116. $address = $request->addresss;
  1117. if ($address) {
  1118. $addressArray = explode(',', $address);
  1119. // $user->province = $addressArray[0];
  1120. // $user->city = $addressArray[1];
  1121. // $user->district = $addressArray[2];
  1122. // $user->country = '中国';
  1123. }
  1124. if ($request->sex) {
  1125. $user->gender = $request->sex;
  1126. }
  1127. if ($request->sex || $address) {
  1128. $user->save();
  1129. }
  1130. return $this->success();
  1131. }
  1132. /**
  1133. * 实名认证
  1134. */
  1135. public function realNameAuth(Request $request)
  1136. {
  1137. $uid = $request->uid;
  1138. $info = (new UserController())->real_name_api($uid, $request->real_name, $request->card_num);
  1139. return $info;
  1140. return $this->success();
  1141. }
  1142. /**
  1143. * 添加用户条件
  1144. * video_url 视频地址
  1145. * img_urls 图片地址 - 强制验证
  1146. * age 年龄 - 强制验证
  1147. * height 身高 - 强制验证
  1148. * sex 性别 1:男 2:女 - 强制验证
  1149. * educational 学历 - 强制验证
  1150. * occupation 职业ID - 强制验证
  1151. * income 收入ID - 强制验证
  1152. * matrimony 婚姻状况 - 强制验证
  1153. * addresss 省市区ID 用逗号分隔 - 强制验证
  1154. * registration 户籍地(省市区)用逗号分隔 - 强制验证
  1155. * content 补充内容 - 强制验证
  1156. * family 家庭背景
  1157. * is_only 独生子女1:是 2:否
  1158. * married 何时结婚ID
  1159. * car 买车情况ID
  1160. * house 买房情况
  1161. * peculiarity 特点
  1162. * choose_age 择偶-年龄范围
  1163. * choose_small_height 择偶-最低身高
  1164. * choose_small_educational 择偶-最低学历
  1165. * choose_income 择偶-最低月薪
  1166. * choose_matrimony 择偶-婚姻状况要求
  1167. * choose_house 择偶-住房要求
  1168. * choose_child 择偶-接受对方小孩 1:接受 2:不接受
  1169. * choose_content 择偶-希望ta 内容
  1170. * @param Request $request
  1171. */
  1172. public function addConditions(Request $request)
  1173. {
  1174. $uid = $request->uid;
  1175. $step = $request->step;
  1176. if (!isset($step) || empty($step)) {
  1177. return $this->fail(200000, [], '参数错误');
  1178. }
  1179. // $info = Conditions::where('user_id', $uid)->first();
  1180. // if ($info) {
  1181. // return $this->fail(200000, [], '已经存在条件');
  1182. // }
  1183. if ($step == 1) {
  1184. // 手动验证数据 - 有些数据需要强制验证
  1185. if (empty($request->img_urls)) {
  1186. return $this->fail(200000, [], '图片地址不能为空');
  1187. }
  1188. if (empty($request->age)) {
  1189. return $this->fail(200000, [], '年龄不能为空');
  1190. }
  1191. if (empty($request->height)) {
  1192. return $this->fail(200000, [], '身高不能为空');
  1193. }
  1194. // if (empty($request->sex)) {
  1195. // return $this->fail(200000, [], '性别不能为空');
  1196. // }
  1197. if (empty($request->educational)) {
  1198. return $this->fail(200000, [], '学历不能为空');
  1199. }
  1200. if (empty($request->occupation)) {
  1201. return $this->fail(200000, [], '职业不能为空');
  1202. }
  1203. if (empty($request->income)) {
  1204. return $this->fail(200000, [], '收入不能为空');
  1205. }
  1206. if (empty($request->matrimony)) {
  1207. return $this->fail(200000, [], '婚姻状况不能为空');
  1208. }
  1209. if (empty($request->addresss)) {
  1210. return $this->fail(200000, [], '省市区不能为空');
  1211. }
  1212. if (empty($request->registration)) {
  1213. return $this->fail(200000, [], '户籍地不能为空');
  1214. }
  1215. if (empty($request->content)) {
  1216. return $this->fail(200000, [], '补充内容不能为空');
  1217. }
  1218. // 百度审核
  1219. $wheresa = ['is_xiangqin_audit_posts'];
  1220. $info = WxSetting::whereIn('key',$wheresa)->get();
  1221. $is_xiangqin_audit_posts = $info[0]['value'];
  1222. if(UserUtils::user_permissions_check_by_config($uid, 'xiangqin_audit_posts_white_list')){
  1223. $need_manual_review = false;
  1224. }else{
  1225. $need_manual_review = true;
  1226. }
  1227. if($is_xiangqin_audit_posts == 2 && $need_manual_review){
  1228. $filter_result = BaiduUtils::text_filter($request->content);
  1229. if($filter_result){
  1230. if($filter_result['hit_level'] == 2){
  1231. return $this->fail(200016, ['tip'=>$filter_result['tip_list'], 'hit_word'=>$filter_result['hit_word']]);
  1232. }
  1233. }
  1234. }
  1235. }
  1236. if ($step == 2) {
  1237. // 验证 家庭背景、独生子女、何时结婚、买车情况、买房情况、我的特点
  1238. // if (empty($request->family)) {
  1239. // return $this->fail(200000, [], '家庭背景不能为空');
  1240. // }
  1241. // if (empty($request->is_only)) {
  1242. // return $this->fail(200000, [], '独生子女不能为空');
  1243. // }
  1244. // if (empty($request->married)) {
  1245. // return $this->fail(200000, [], '何时结婚不能为空');
  1246. // }
  1247. // if (empty($request->car)) {
  1248. // return $this->fail(200000, [], '买车情况不能为空');
  1249. // }
  1250. // if (empty($request->house)) {
  1251. // return $this->fail(200000, [], '买房情况不能为空');
  1252. // }
  1253. // if (empty($request->peculiarity)) {
  1254. // return $this->fail(200000, [], '我的特点不能为空');
  1255. // }
  1256. }
  1257. if ($step == 3) {
  1258. // 年龄范围、最低身高、最低学历、最低月薪、婚姻状况要求、住房要求、接受对方小孩、希望ta 内容
  1259. // if (empty($request->choose_age)) {
  1260. // return $this->fail(200000, [], '年龄范围不能为空');
  1261. // }
  1262. // if (empty($request->choose_small_height)) {
  1263. // return $this->fail(200000, [], '最低身高不能为空');
  1264. // }
  1265. // if (empty($request->choose_small_educational)) {
  1266. // return $this->fail(200000, [], '最低学历不能为空');
  1267. // }
  1268. // if (empty($request->choose_income)) {
  1269. // return $this->fail(200000, [], '最低月薪不能为空');
  1270. // }
  1271. // if (empty($request->choose_matrimony)) {
  1272. // return $this->fail(200000, [], '婚姻状况要求不能为空');
  1273. // }
  1274. // if (empty($request->choose_house)) {
  1275. // return $this->fail(200000, [], '住房要求不能为空');
  1276. // }
  1277. // if (empty($request->choose_child)) {
  1278. // return $this->fail(200000, [], '接受对方小孩不能为空');
  1279. // }
  1280. // if (empty($request->choose_content)) {
  1281. // return $this->fail(200000, [], '希望ta 内容不能为空');
  1282. // }
  1283. }
  1284. if ($step == 4) {
  1285. //
  1286. if (!empty($request->real_name) || !empty($request->card_num) || !empty($request->identity_picture) || !empty($request->identity_picture_the)) {
  1287. // if (empty($request->real_name)) {
  1288. // return $this->fail(200000, [], '真实姓名不能为空');
  1289. // }
  1290. // if (empty($request->card_num)) {
  1291. // return $this->fail(200000, [], '身份证号不能为空');
  1292. // }
  1293. // if (empty($request->identity_picture)) {
  1294. // return $this->fail(200000, [], '身份证正面不能为空');
  1295. // }
  1296. // if (empty($request->identity_picture_the)) {
  1297. // return $this->fail(200000, [], '身份证反面不能为空');
  1298. // }
  1299. // // 添加到实名认证表
  1300. // $standing = [
  1301. // 'user_id' => $uid,
  1302. // 'real_name' => $request->real_name,
  1303. // 'card_num' => $request->card_num,
  1304. // 'identity_picture' => $request->identity_picture,
  1305. // 'identity_picture_the' => $request->identity_picture_the,
  1306. // 'created_at' => date('Y-m-d H:i:s')
  1307. // ];
  1308. // UserStanding::create($standing);
  1309. $data['step'] = $step;
  1310. // return $this->success($data);
  1311. // 检测是否实名认证
  1312. $user_infos = WxUser::where('id', $uid)->first();
  1313. // 检测是否实名认证 real_name、real_id_card 不为空
  1314. if (empty($user_infos->real_name) || empty($user_infos->real_id_card)) {
  1315. // 如果存在更新里面的数据
  1316. Conditions::where('user_id', $uid)->update($data);
  1317. $info = (new UserController())->real_name_api($uid, $request->real_name, $request->card_num);
  1318. return $info;
  1319. }
  1320. } else {
  1321. $step = 4;
  1322. }
  1323. }
  1324. // 获取用户是否在否在实名认证
  1325. // 查询排序
  1326. // $user = UserStanding::where('user_id', $uid)->orderBy('id','desc')->first();
  1327. // if (empty($user) || $user->is_examine == 2) {
  1328. // // 如果没有实名认证或者实名认证失败
  1329. // // 检测是否上传了实名认证
  1330. // if (!empty($request->real_name) || !empty($request->card_num)|| !empty($request->identity_picture) || !empty($request->identity_picture_the)) {
  1331. // // 如果其中有一个上传了,那么就要验证其他的
  1332. // if (empty($request->real_name)) {
  1333. // return $this->fail(200000, [], '真实姓名不能为空');
  1334. // }
  1335. // if (empty($request->card_num)) {
  1336. // return $this->fail(200000, [], '身份证号不能为空');
  1337. // }
  1338. // if (empty($request->identity_picture)) {
  1339. // return $this->fail(200000, [], '身份证正面不能为空');
  1340. // }
  1341. // if (empty($request->identity_picture_the)) {
  1342. // return $this->fail(200000, [], '身份证反面不能为空');
  1343. // }
  1344. // // 添加到实名认证表
  1345. // $standing = [
  1346. // 'user_id' => $uid,
  1347. // 'real_name' => $request->real_name,
  1348. // 'card_num' => $request->card_num,
  1349. // 'identity_picture' => $request->identity_picture,
  1350. // 'identity_picture_the' => $request->identity_picture_the,
  1351. // 'created_at' => date('Y-m-d H:i:s')
  1352. // ];
  1353. // UserStanding::create($standing);
  1354. // }
  1355. // }
  1356. // 检测user_id是否存在
  1357. $count = Conditions::where('user_id', $uid)->count();
  1358. // $data = $request->all();
  1359. // unset($data['real_name']);
  1360. // unset($data['card_num']);
  1361. // unset($data['identity_picture']);
  1362. // unset($data['identity_picture_the']);
  1363. // unset($data['uid']);
  1364. if ($step == 1) {
  1365. $data['img_urls'] = $request->img_urls;
  1366. $data['video_url'] = $request->video_url;
  1367. $data['age'] = $request->age;
  1368. $data['height'] = $request->height;
  1369. // $data['sex'] = $request->sex;
  1370. $data['educational'] = $request->educational;
  1371. $data['occupation'] = $request->occupation;
  1372. $data['income'] = $request->income;
  1373. $data['matrimony'] = $request->matrimony;
  1374. $data['addresss'] = $request->addresss;
  1375. $data['registration'] = $request->registration;
  1376. $data['content'] = $request->content;
  1377. $data['create_time'] = time();
  1378. }
  1379. if ($step == 2) {
  1380. $data['family'] = $request->family;
  1381. $data['is_only'] = $request->is_only;
  1382. $data['married'] = $request->married;
  1383. $data['car'] = $request->car;
  1384. $data['house'] = $request->house;
  1385. $data['peculiarity'] = $request->peculiarity;
  1386. }
  1387. if ($step == 3) {
  1388. $data['choose_age'] = $request->choose_age;
  1389. $data['choose_small_height'] = $request->choose_small_height;
  1390. $data['choose_small_educational'] = $request->choose_small_educational;
  1391. $data['choose_income'] = $request->choose_income;
  1392. $data['choose_matrimony'] = $request->choose_matrimony;
  1393. $data['choose_house'] = $request->choose_house;
  1394. $data['choose_child'] = $request->choose_child;
  1395. $data['choose_content'] = $request->choose_content;
  1396. }
  1397. // 更新会员的性别
  1398. if ($step == 1) {
  1399. // 更新会员 country
  1400. $user = WxUser::where('id', $uid)->first();
  1401. //print_r($user->area);exit;
  1402. // address 分为province、city、area
  1403. $address = $request->addresss;
  1404. //print_r($address);exit;
  1405. $addressArray = explode(',', $address);
  1406. // $user->province = $addressArray[0];
  1407. // $user->city = $addressArray[1];
  1408. // $user->district = $addressArray[2];
  1409. // $user->country = '中国';
  1410. // $user->gender = $request->age;
  1411. //$user->save();
  1412. // 获取 requirement 并逗号分隔 获取是否有 亿友圈内找对象 文字
  1413. $requirement = $user->requirement;
  1414. $requirementArray = explode(',', $requirement);
  1415. $is_find = 0;
  1416. foreach ($requirementArray as $key => $val) {
  1417. if (strpos($val, '亿友圈内找对象') !== false) {
  1418. $is_find = 1;
  1419. $data['status'] = 1;
  1420. }
  1421. }
  1422. }
  1423. if ($count > 0) {
  1424. $data['step'] = $step;
  1425. // return $this->success($data);
  1426. // 如果存在更新里面的数据
  1427. Conditions::where('user_id', $uid)->update($data);
  1428. } else {
  1429. $data['step'] = 1;
  1430. $data['user_id'] = $uid;
  1431. $data['create_time'] = time();
  1432. Conditions::create($data);
  1433. }
  1434. return $this->success();
  1435. }
  1436. public function getNameInfo($data, $id)
  1437. {
  1438. $name = '';
  1439. foreach ($data as $item) {
  1440. if ($item['id'] == $id) {
  1441. $name = $item['name'];
  1442. break;
  1443. }
  1444. }
  1445. return $name;
  1446. }
  1447. /** 获取用户的条件
  1448. * @param Request $request
  1449. * @return \Illuminate\Http\JsonResponse
  1450. */
  1451. public function getConditions(Request $request)
  1452. {
  1453. // 获取当前用户表里的年龄
  1454. $user = WxUser::where('id', $request->uid)->first();
  1455. // 获取当前用户的条件 Conditions
  1456. $info = Conditions::where('user_id', $request->uid)->first();
  1457. if (empty($info)) {
  1458. // return $this->fail(200000, [], '暂无数据');
  1459. $info['step'] = 1;
  1460. // 获取用户信息
  1461. $user = WxUser::where('id', $request->uid)->first();
  1462. $info['sex'] = $user->gender;
  1463. $info['sex_name'] = $info['sex'] == 1 ? '男' : '女';
  1464. $info['age'] = $user->age;
  1465. return $this->success($info);
  1466. }
  1467. $info['sex_name'] = $info['sex'] == 1 ? '男' : '女';
  1468. $info['only_name'] = $info['is_only'] == 1 ? '是' : '否';
  1469. $info['age'] = $user->age;
  1470. $settings = $this->getSettings(2);
  1471. $info['educational_name'] = $this->getNameInfo($settings['educational'], $info['educational']);
  1472. $info['occupation_name'] = $this->getNameInfo($settings['occupation'], $info['occupation']);
  1473. $info['income_name'] = $this->getNameInfo($settings['income'], $info['income']);
  1474. $info['matrimony_name'] = $this->getNameInfo($settings['matrimony'], $info['matrimony']);
  1475. $info['married_name'] = $this->getNameInfo($settings['married'], $info['married']);
  1476. $info['car_name'] = $this->getNameInfo($settings['car'], $info['car']);
  1477. $info['house_name'] = $this->getNameInfo($settings['house'], $info['house']);
  1478. $info['choose_small_educational_name'] = $this->getNameInfo($settings['educational'], $info['choose_small_educational']);
  1479. $info['choose_matrimony_name'] = $this->getNameInfo($settings['matrimony'], $info['choose_matrimony']);
  1480. $info['choose_child_name'] = $info['choose_child'] == 1 ? '接受' : '不接受';
  1481. // 获取实名认证状态
  1482. $user = UserStanding::where('user_id', $request->uid)->orderBy('id','desc')->first();
  1483. if (empty($user)) {
  1484. $info['real_name'] = '';
  1485. $info['card_num'] = '';
  1486. $info['identity_picture'] = '';
  1487. $info['identity_picture_the'] = '';
  1488. $info['is_examine'] = 3;
  1489. } else {
  1490. $info['real_name'] = $user->real_name ?? '';
  1491. $info['card_num'] = $user->card_num ?? '';
  1492. $info['identity_picture'] = $user->identity_picture ?? '';
  1493. $info['identity_picture_the'] = $user->identity_picture_the ?? '';
  1494. $info['is_examine'] = $user->is_examine ?? 3;
  1495. }
  1496. $info['user_educational'] = $this->getConditionsById($info['educational'],'educational');
  1497. $info['user_occupation'] = $this->getConditionsById($info['occupation'],'occupation');
  1498. $info['user_income'] = $this->getConditionsById($info['income'],'income');
  1499. $info['user_matrimony'] = $this->getConditionsById($info['matrimony'],'matrimony');
  1500. $info['user_family'] = $this->getConditionsById($info['family'],'family');
  1501. $info['user_married'] = $this->getConditionsById($info['married'],'married');
  1502. $info['user_car'] = $this->getConditionsById($info['car'],'car');
  1503. $info['user_house'] = $this->getConditionsById($info['house'],'house');
  1504. $info['user_peculiarity'] = $this->getConditionsById($info['peculiarity'],'peculiarity',4);
  1505. $info['user_choose_age'] = $this->getConditionsById($info['choose_age'],'choose_age',1);
  1506. $info['user_choose_small_height'] = $this->getConditionsById($info['choose_small_height'],'choose_small_height',1);
  1507. $info['user_choose_small_educational'] = $this->getConditionsById($info['choose_small_educational'],'choose_small_educational',1);
  1508. $info['user_choose_income'] = $this->getConditionsById($info['choose_income'],'choose_income',1);
  1509. $info['user_choose_matrimony'] = $this->getConditionsById($info['choose_matrimony'],'choose_matrimony',1);
  1510. $info['user_choose_house'] = $this->getConditionsById($info['choose_house'],'choose_house',1);
  1511. $info['user_choose_child'] = $this->getConditionsById($info['choose_child'],'choose_child',1);
  1512. $info['user_choose_content'] = $this->getConditionsById($info['choose_content'],'choose_content',4);
  1513. $info['user_is_only'] = $this->getConditionsById($info['is_only'],'is_only',1);
  1514. if (empty($info)) {
  1515. $info['step'] = 1;
  1516. } else {
  1517. if ($info['step'] == 0) {
  1518. $info['step'] = 1;
  1519. } else {
  1520. $info['step'] = $info['step'] + 1;
  1521. }
  1522. }
  1523. return $this->success($info);
  1524. }
  1525. /**
  1526. * 根据id获取用户所选的条件
  1527. */
  1528. public function getConditionsById($id,$name,$type = 1)
  1529. {
  1530. $settings = $this->getSettings(2);
  1531. $list = $settings[$name];
  1532. if ($type == 1) {
  1533. foreach ($list as $key => $val) {
  1534. if ($val['id'] == $id) {
  1535. return $val;
  1536. }
  1537. }
  1538. }
  1539. if ($type == 2) {
  1540. foreach ($list as $key => $val) {
  1541. if ($val['name'] == $id) {
  1542. return $val;
  1543. }
  1544. }
  1545. }
  1546. if ($type == 3) {
  1547. $arr = [];
  1548. // $id = '品味出众,重视家庭';
  1549. $idArray = array_map('trim', explode(',', $id));
  1550. $arr = array_filter($list, function($val) use ($idArray) {
  1551. return in_array(trim($val['name']), $idArray);
  1552. });
  1553. $arr = array_values($arr);
  1554. return $arr;
  1555. }
  1556. if ($type == 4) {
  1557. $arr = [];
  1558. $idArray = array_map('trim', explode(',', $id));
  1559. $arr = array_filter($list, function($val) use ($idArray) {
  1560. return in_array(trim($val['id']), $idArray);
  1561. });
  1562. // 重拍数组
  1563. $arr = array_values($arr);
  1564. return $arr;
  1565. }
  1566. return '';
  1567. }
  1568. /**
  1569. * 获取配置信息
  1570. */
  1571. public function getSettings($type = 1)
  1572. {
  1573. // 学历配置, 初中以下,高中,大专,本科,硕士,博士
  1574. $educational = [
  1575. ['id' => 1, 'name' => '初中以下','search_name' => '初中以下'],
  1576. ['id' => 2, 'name' => '高中','search_name' =>'高中及以上'],
  1577. ['id' => 3, 'name' => '大专','search_name' => '大专及以上'],
  1578. ['id' => 4, 'name' => '本科','search_name' => '本科及以上'],
  1579. ['id' => 5, 'name' => '硕士','search_name' => '硕士及以上'],
  1580. ['id' => 6, 'name' => '博士','search_name' => '博士及以上'],
  1581. ];
  1582. // 职业配置 occupation
  1583. $occupation = [
  1584. ['id' => 1, 'name' => '学生'],
  1585. ['id' => 2, 'name' => '教师'],
  1586. ['id' => 3, 'name' => '医生'],
  1587. ['id' => 4, 'name' => '程序员'],
  1588. ['id' => 5, 'name' => '公务员'],
  1589. ['id' => 6, 'name' => '警察'],
  1590. ['id' => 7, 'name' => '军人'],
  1591. ['id' => 8, 'name' => '司机'],
  1592. ['id' => 9, 'name' => '厨师'],
  1593. ['id' => 10, 'name' => '服务员'],
  1594. ['id' => 11, 'name' => '销售'],
  1595. ['id' => 12, 'name' => '保安'],
  1596. ['id' => 13, 'name' => '保姆'],
  1597. ['id' => 14, 'name' => '其他'],
  1598. ];
  1599. // income 收入配置
  1600. $income = [
  1601. ['id' => 1, 'name' => '2000以下'],
  1602. ['id' => 2, 'name' => '2000-5000'],
  1603. ['id' => 3, 'name' => '5000-8000'],
  1604. ['id' => 4, 'name' => '8000-12000'],
  1605. ['id' => 5, 'name' => '12000-20000'],
  1606. ['id' => 6, 'name' => '20000以上'],
  1607. ];
  1608. // 婚姻状况配置 matrimony
  1609. $matrimony = [
  1610. ['id' => 1, 'name' => '未婚'],
  1611. ['id' => 2, 'name' => '离异'],
  1612. ['id' => 3, 'name' => '丧偶'],
  1613. ];
  1614. // married 何时结婚配置
  1615. $married = [
  1616. ['id' => 1, 'name' => '一年内'],
  1617. ['id' => 2, 'name' => '两年内'],
  1618. ['id' => 3, 'name' => '三年内'],
  1619. ['id' => 4, 'name' => '四年内'],
  1620. ['id' => 5, 'name' => '五年内'],
  1621. ['id' => 6, 'name' => '五年以上'],
  1622. ];
  1623. // car 买车情况配置
  1624. $car = [
  1625. ['id' => 1, 'name' => '已买车'],
  1626. ['id' => 2, 'name' => '未买车'],
  1627. ];
  1628. // house 买房情况配置
  1629. $house = [
  1630. ['id' => 1, 'name' => '已买房'],
  1631. ['id' => 2, 'name' => '未买房'],
  1632. ];
  1633. // choose_age 择偶-年龄范围
  1634. $choose_age = [
  1635. ['id' => 1, 'name' => '18-25'],
  1636. ['id' => 2, 'name' => '26-30'],
  1637. ['id' => 3, 'name' => '31-35'],
  1638. ['id' => 4, 'name' => '36-40'],
  1639. ['id' => 5, 'name' => '41-45'],
  1640. ['id' => 6, 'name' => '46-50'],
  1641. ['id' => 7, 'name' => '51-55'],
  1642. ['id' => 8, 'name' => '56-60'],
  1643. ['id' => 9, 'name' => '60以上'],
  1644. ];
  1645. // 家庭背景
  1646. $family = [
  1647. ['id' => 1, 'name' => '一般'],
  1648. ['id' => 2, 'name' => '良好'],
  1649. ['id' => 3, 'name' => '优秀'],
  1650. ];
  1651. // peculiarity 特点
  1652. $peculiarity = [
  1653. ['id' => 1, 'name' => '温柔'],
  1654. ['id' => 2, 'name' => '善良'],
  1655. ['id' => 3, 'name' => '孝顺'],
  1656. ['id' => 4, 'name' => '幽默'],
  1657. ['id' => 5, 'name' => '开朗'],
  1658. ['id' => 6, 'name' => '大方'],
  1659. ['id' => 7, 'name' => '细心'],
  1660. ['id' => 8, 'name' => '有责任心'],
  1661. ['id' => 9, 'name' => '有上进心'],
  1662. ['id' => 10, 'name' => '有爱心'],
  1663. ];
  1664. // 我的补充(补充个人信息的内容)
  1665. $user_content = [
  1666. ['id' => 1, 'name' => '我是一个有责任心的人'],
  1667. ['id' => 2, 'name' => '我是一个有爱心的人'],
  1668. ['id' => 3, 'name' => '我是一个有上进心的人'],
  1669. ];
  1670. // 独生子女
  1671. $is_only = [
  1672. ['id' => 1, 'name' => '是'],
  1673. ['id' => 2, 'name' => '否'],
  1674. ];
  1675. // 希望Ta有的特点
  1676. $choose_content = [
  1677. ['id' => 1, 'name' => '品味出众'],
  1678. ['id' => 2, 'name' => '喜欢厨艺'],
  1679. ['id' => 3, 'name' => '不冷暴力'],
  1680. ['id' => 4, 'name' => '重视家庭'],
  1681. ['id' => 5, 'name' => '整洁干净'],
  1682. ['id' => 6, 'name' => '阳光运动'],
  1683. ['id' => 7, 'name' => '文艺范'],
  1684. ['id' => 8, 'name' => '懂得尊重'],
  1685. ['id' => 9, 'name' => '低调沉稳'],
  1686. ['id' => 10, 'name' => '心地善良'],
  1687. ];
  1688. // 最低身高
  1689. $choose_small_height = [
  1690. ['id' => 1, 'name' => '150cm'],
  1691. ['id' => 2, 'name' => '155cm'],
  1692. ['id' => 3, 'name' => '160cm'],
  1693. ['id' => 4, 'name' => '165cm'],
  1694. ['id' => 5, 'name' => '170cm'],
  1695. ['id' => 6, 'name' => '175cm'],
  1696. ['id' => 7, 'name' => '180cm'],
  1697. ['id' => 8, 'name' => '185cm'],
  1698. ['id' => 9, 'name' => '不限'],
  1699. ];
  1700. // 最低月薪
  1701. $choose_income = [
  1702. ['id' => 1, 'name' => '2000'],
  1703. ['id' => 2, 'name' => '3000'],
  1704. ['id' => 3, 'name' => '4000'],
  1705. ['id' => 4, 'name' => '5000'],
  1706. ['id' => 5, 'name' => '6000'],
  1707. ['id' => 6, 'name' => '7000'],
  1708. ['id' => 7, 'name' => '8000'],
  1709. ['id' => 8, 'name' => '9000'],
  1710. ['id' => 9, 'name' => '10000'],
  1711. ['id' => 10, 'name' => '15000'],
  1712. ['id' => 11, 'name' => '20000'],
  1713. ['id' => 12, 'name' => '30000'],
  1714. ['id' => 13, 'name' => '不限'],
  1715. ];
  1716. // 择偶-最低学历
  1717. $choose_small_educational = [
  1718. ['id' => 1, 'name' => '初中'],
  1719. ['id' => 2, 'name' => '高中'],
  1720. ['id' => 3, 'name' => '大专'],
  1721. ['id' => 4, 'name' => '本科'],
  1722. ['id' => 5, 'name' => '硕士'],
  1723. ['id' => 6, 'name' => '博士'],
  1724. ['id' => 7, 'name' => '不限'],
  1725. ];
  1726. // 择偶-婚姻状况要求
  1727. $choose_matrimony = [
  1728. ['id' => 1, 'name' => '未婚'],
  1729. ['id' => 2, 'name' => '离异'],
  1730. ['id' => 3, 'name' => '丧偶'],
  1731. ['id' => 4, 'name' => '不限'],
  1732. ];
  1733. // 择偶-住房要求
  1734. $choose_house = [
  1735. ['id' => 1, 'name' => '已买房'],
  1736. ['id' => 2, 'name' => '未买房'],
  1737. ['id' => 3, 'name' => '不限'],
  1738. ];
  1739. // 择偶-接受对方小孩
  1740. $choose_child = [
  1741. ['id' => 1, 'name' => '接受'],
  1742. ['id' => 2, 'name' => '不接受'],
  1743. ];
  1744. $data['educational'] = $educational;
  1745. $data['occupation'] = $occupation;
  1746. $data['income'] = $income;
  1747. $data['matrimony'] = $matrimony;
  1748. $data['married'] = $married;
  1749. $data['car'] = $car;
  1750. $data['house'] = $house;
  1751. $data['choose_age'] = $choose_age;
  1752. $data['choose_content'] = $choose_content;
  1753. $data['is_only'] = $is_only;
  1754. $data['user_content'] = $user_content;
  1755. $data['peculiarity'] = $peculiarity;
  1756. $data['family'] = $family;
  1757. $data['choose_income'] = $choose_income;
  1758. $data['choose_small_height'] = $choose_small_height;
  1759. $data['choose_small_educational'] = $choose_small_educational;
  1760. $data['choose_house'] = $choose_house;
  1761. $data['choose_child'] = $choose_child;
  1762. $data['choose_matrimony'] = $choose_matrimony;
  1763. if ($type == 2) {
  1764. return $data;
  1765. }
  1766. return $this->success($data);
  1767. }
  1768. }