ConditionsController.php 75 KB

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