ConditionsController.php 78 KB

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