ConditionsController.php 78 KB

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