UserController.php 96 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: leo
  5. * Date: 2018/2/24
  6. * Time: 下午12:48
  7. */
  8. namespace backendApi\modules\v1\controllers;
  9. use backendApi\modules\v1\components\UserAuth;
  10. use backendApi\modules\v1\models\Admin;
  11. use backendApi\modules\v1\models\AdminCountry;
  12. use backendApi\modules\v1\models\AdminRole;
  13. use backendApi\modules\v1\models\exportForms\BaUserExportForm;
  14. use backendApi\modules\v1\models\exportForms\UserExportForm;
  15. use backendApi\modules\v1\models\lists\shop\BaUserList;
  16. use backendApi\modules\v1\models\lists\user\BindList;
  17. use backendApi\modules\v1\models\lists\user\ChangeHighestEmpLevelList;
  18. use backendApi\modules\v1\models\lists\user\DecLevelList;
  19. use backendApi\modules\v1\models\lists\user\GroupList;
  20. use backendApi\modules\v1\models\lists\user\IndexList;
  21. use backendApi\modules\v1\models\lists\user\MoveList;
  22. use backendApi\modules\v1\models\lists\user\StatusAuditList;
  23. use backendApi\modules\v1\models\lists\user\SystemList;
  24. use backendApi\modules\v1\models\lists\user\TeamworkList;
  25. use backendApi\modules\v1\models\lists\user\YearHighestEmpLvList;
  26. use common\helpers\Date;
  27. use common\helpers\Form;
  28. use common\helpers\http\BackendToFrontendApi;
  29. use common\helpers\Log;
  30. use common\helpers\LoggerTool;
  31. use common\helpers\NetPoint;
  32. use common\helpers\Tool;
  33. use common\helpers\user\Balance;
  34. use common\helpers\user\Cash;
  35. use common\helpers\user\Info;
  36. use common\helpers\user\Status;
  37. use common\models\BaUser;
  38. use common\models\CompanyBank;
  39. use common\models\Countries;
  40. use common\models\CurrencyConversions;
  41. use common\models\FlowBonus;
  42. use common\models\forms\AdminAddUserForm;
  43. use common\models\forms\BaUserBasicForm;
  44. use common\models\forms\ChangeShowEmpLvForm;
  45. use common\models\forms\CloseDecForm;
  46. use common\models\forms\CloseLoginForm;
  47. use common\models\forms\DecLevelLogForm;
  48. use common\models\forms\DecRoleLogForm;
  49. use common\models\forms\HighestEmpLevelLogForm;
  50. use common\models\forms\ImmigrantForm;
  51. use common\models\forms\NetMoveForm;
  52. use common\models\forms\RechargeForm;
  53. use common\models\forms\ReconsumeForm;
  54. use common\models\forms\RegInfoAuditForm;
  55. use common\models\forms\UploadForm;
  56. use common\models\forms\UserBasicForm;
  57. use common\models\forms\UserBindForm;
  58. use common\models\forms\UserCloseForm;
  59. use common\models\forms\UserDecForm;
  60. use common\models\forms\UserForm;
  61. use common\models\forms\UserGroupForm;
  62. use common\models\forms\UserStatusForm;
  63. use common\models\forms\UserSystemForm;
  64. use common\models\forms\UserTeamworkForm;
  65. use common\models\forms\UserTransferPropForm;
  66. use common\models\Instalment;
  67. use common\models\Language;
  68. use common\models\Period;
  69. use common\models\ReconsumeAudit;
  70. use common\models\ReconsumePool;
  71. use common\models\RegInfoAudit;
  72. use common\models\Region;
  73. use common\models\RegType;
  74. use common\models\DecOrder;
  75. use common\models\DecRole;
  76. use common\models\EmployLevel;
  77. use common\models\OpenBank;
  78. use common\models\UserBind;
  79. use common\models\UserClose;
  80. use common\models\UserImmigrant;
  81. use common\models\UserMove;
  82. use common\models\UserNetwork;
  83. use common\models\UserRelation;
  84. use common\models\UserStatusAudit;
  85. use common\models\UserSystem;
  86. use common\models\YearHighestEmpLv;
  87. use SebastianBergmann\CodeCoverage\Report\PHP;
  88. use sunmoon\phpspreadsheet\Excel;
  89. use Yii;
  90. use common\helpers\Cache;
  91. use common\models\User;
  92. use common\models\UserInfo;
  93. use common\models\UserTeamwork;
  94. use yii\base\Exception;
  95. use yii\web\HttpException;
  96. use yii\web\UploadedFile;
  97. class UserController extends BaseController
  98. {
  99. public $modelClass = User::class;
  100. public function behaviors()
  101. {
  102. $behaviors = parent::behaviors();
  103. //$behaviors['contentNegotiator']['formats']['text/html'] = Response::FORMAT_JSON;
  104. return $behaviors;
  105. }
  106. /**
  107. * 会员列表
  108. * @return mixed
  109. * @throws Exception
  110. * @throws HttpException
  111. */
  112. public function actionIndex()
  113. {
  114. $filter = $this->filterCondition([
  115. 'USER_NAME' => 'U.USER_NAME',
  116. 'REAL_NAME' => 'U.REAL_NAME',
  117. 'STATUS' => 'U.STATUS',
  118. 'ALLOW_LOGIN' => 'U.ALLOW_LOGIN',
  119. 'CREATED_AT' => 'U.CREATED_AT',
  120. 'PERIOD_AT' => 'U.PERIOD_AT',
  121. 'DEC_LV_NAME' => 'U.DEC_LV',
  122. 'COUNTRY' => 'U.COUNTRY_ID',
  123. 'DEC_LV_UPDATED_AT' => 'U.DEC_LV_UPDATED_AT',
  124. 'LAST_DEC_LV_NAME' => 'U.LAST_DEC_LV',
  125. 'EMP_LV_NAME' => 'U.EMP_LV',
  126. 'LAST_EMP_LV_NAME' => 'U.LAST_EMP_LV',
  127. 'ELITE_LV_NAME' => 'U.ELITE_LV',
  128. 'LAST_ELITE_LV_NAME' => 'U.LAST_ELITE_LV',
  129. 'REC_USER_NAME' => 'RU.USER_NAME',
  130. 'CON_USER_NAME' => 'CU.USER_NAME',
  131. 'SPOUSE_NAME' => 'U.SPOUSE_NAME',
  132. 'MOBILE' => 'U.MOBILE',
  133. 'TEL' => 'U.TEL',
  134. 'DEC_USER_NAME' => 'DU.USER_NAME',
  135. 'IS_DEC' => 'U.IS_DEC',
  136. 'IS_STUDIO' => 'U.IS_STUDIO',
  137. 'DEC_ROLE_NAME' => 'U.DEC_ROLE_ID',
  138. 'AREA' => [
  139. 'FIELD' => ['U.PROVINCE', 'U.CITY', 'U.COUNTY'],
  140. 'BIND' => ['PROVINCE', 'CITY', 'COUNTY'],
  141. ],
  142. 'ADDRESS' => 'U.ADDRESS',
  143. ]);
  144. $isSuper = AdminRole::isSuperAdmin(\Yii::$app->getUser()->getUserInfo()['roleId']);
  145. if (!$isSuper) {
  146. $adminId = Yii::$app->getUser()->getUserInfo()['id'];
  147. $adminCountry = AdminCountry::getCountry($adminId);
  148. $quotedAdminCountry = array_map(function($item) {
  149. return "'" . addslashes($item) . "'";
  150. }, $adminCountry);
  151. $condition = $filter['condition'] ?? '';
  152. $filter['condition'] = $condition . " AND U.COUNTRY_ID IN (" . implode(',', $quotedAdminCountry) . ")";
  153. $condition = $filter['condition'];
  154. $params = $filter['params'];
  155. $condition .= " AND UI.DELETED=0 AND U.COUNTRY_ID IN (" . implode(',', $quotedAdminCountry) . ")";
  156. } else {
  157. $condition = $filter['condition'] ?? '';
  158. $params = $filter['params'];
  159. }
  160. $listObj = new IndexList();
  161. $data = $listObj->getList(['condition' => $condition, 'params' => $params]);
  162. return static::notice($data);
  163. }
  164. /**
  165. * 导出会员列表
  166. * @return mixed
  167. * @throws \yii\db\Exception
  168. * @throws HttpException
  169. */
  170. public function actionIndexExport()
  171. {
  172. $filter = $this->filterCondition([
  173. 'USER_NAME' => 'U.USER_NAME',
  174. 'REAL_NAME' => 'U.REAL_NAME',
  175. 'STATUS' => 'U.STATUS',
  176. 'ALLOW_LOGIN' => 'U.ALLOW_LOGIN',
  177. 'CREATED_AT' => 'U.CREATED_AT',
  178. 'PERIOD_AT' => 'U.PERIOD_AT',
  179. 'DEC_LV_NAME' => 'U.DEC_LV',
  180. 'DEC_LV_UPDATED_AT' => 'U.DEC_LV_UPDATED_AT',
  181. 'LAST_DEC_LV_NAME' => 'U.LAST_DEC_LV',
  182. 'EMP_LV_NAME' => 'U.EMP_LV',
  183. 'REC_USER_NAME' => 'RU.USER_NAME',
  184. 'CON_USER_NAME' => 'CU.USER_NAME',
  185. 'ID_CARD' => 'U.ID_CARD',
  186. 'SPOUSE_NAME' => 'U.SPOUSE_NAME',
  187. 'SPOUSE_IDCARD' => 'U.SPOUSE_IDCARD',
  188. 'SYSTEM_NAME' => 'U.SYSTEM_ID',
  189. 'MOBILE' => 'U.MOBILE',
  190. 'TEL' => 'U.TEL',
  191. 'DEC_USER_NAME' => 'DU.USER_NAME',
  192. 'IS_DEC' => 'U.IS_DEC',
  193. 'IS_STUDIO' => 'U.IS_STUDIO',
  194. 'DEC_ROLE_NAME' => 'U.DEC_ROLE_ID',
  195. 'OPEN_BANK_NAME' => 'U.OPEN_BANK',
  196. 'BANK_AREA' => [
  197. 'FIELD' => ['U.BANK_PROVINCE', 'U.BANK_CITY', 'U.BANK_COUNTY'],
  198. 'BIND' => ['BANK_PROVINCE', 'BANK_CITY', 'BANK_COUNTY'],
  199. ],
  200. 'BANK_ADDRESS' => 'U.BANK_ADDRESS',
  201. 'BANK_NO' => 'U.BANK_NO',
  202. 'SEX' => 'U.SEX',
  203. 'NATION_NAME' => 'U.NATION',
  204. 'AREA' => [
  205. 'FIELD' => ['U.PROVINCE', 'U.CITY', 'U.COUNTY'],
  206. 'BIND' => ['PROVINCE', 'CITY', 'COUNTY'],
  207. ],
  208. 'ADDRESS' => 'U.ADDRESS',
  209. 'VERIFIED' => 'U.VERIFIED',
  210. 'VERIFIED_AT' => 'U.VERIFIED_AT',
  211. 'ALLOW_TRANSFER' => 'UI.ALLOW_TRANSFER',
  212. ]);
  213. $isSuper = AdminRole::isSuperAdmin(\Yii::$app->getUser()->getUserInfo()['roleId']);
  214. if (!$isSuper) {
  215. $adminId = Yii::$app->getUser()->getUserInfo()['id'];
  216. $adminCountry = AdminCountry::getCountry($adminId);
  217. $quotedAdminCountry = array_map(function($item) {
  218. return "'" . addslashes($item) . "'";
  219. }, $adminCountry);
  220. $condition = $filter['condition'] ?? '';
  221. $filter['condition'] = $condition . " AND U.COUNTRY_ID IN (" . implode(',', $quotedAdminCountry) . ")";
  222. } else {
  223. $condition = $filter['condition'] ?? '';
  224. $filter['condition'] = $condition;
  225. }
  226. $form = new UserExportForm();
  227. $result = $form->run($filter, 'Member_List');
  228. if (!$result) {
  229. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  230. }
  231. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  232. }
  233. /**
  234. * 空单会员列表
  235. * @return mixed
  236. * @throws Exception
  237. * @throws HttpException
  238. */
  239. public function actionEmptyList()
  240. {
  241. $filter = $this->filterCondition([
  242. 'USER_NAME' => 'U.USER_NAME',
  243. 'REAL_NAME' => 'U.REAL_NAME',
  244. 'STATUS' => 'U.STATUS',
  245. 'ALLOW_LOGIN' => 'U.ALLOW_LOGIN',
  246. 'CREATED_AT' => 'U.CREATED_AT',
  247. 'PERIOD_AT' => 'U.PERIOD_AT',
  248. 'DEC_LV_NAME' => 'U.DEC_LV',
  249. 'DEC_LV_UPDATED_AT' => 'U.DEC_LV_UPDATED_AT',
  250. 'LAST_DEC_LV_NAME' => 'U.LAST_DEC_LV',
  251. 'EMP_LV_NAME' => 'U.EMP_LV',
  252. // 'HIGHEST_EMP_LV_NAME' => 'UI.HIGHEST_EMP_LV',
  253. // 'HIGHEST_EMP_LV_PERIOD' => 'UI.HIGHEST_EMP_LV_PERIOD',
  254. 'REC_USER_NAME' => 'RU.USER_NAME',
  255. 'CON_USER_NAME' => 'CU.USER_NAME',
  256. 'ID_CARD' => 'U.ID_CARD',
  257. 'SPOUSE_NAME' => 'U.SPOUSE_NAME',
  258. 'SPOUSE_IDCARD' => 'U.SPOUSE_IDCARD',
  259. 'SYSTEM_NAME' => 'U.SYSTEM_ID',
  260. 'MOBILE' => 'U.MOBILE',
  261. 'TEL' => 'U.TEL',
  262. 'DEC_USER_NAME' => 'DU.USER_NAME',
  263. 'IS_DEC' => 'U.IS_DEC',
  264. 'DEC_ROLE_NAME' => 'U.DEC_ROLE_ID',
  265. 'OPEN_BANK_NAME' => 'U.OPEN_BANK',
  266. 'BANK_AREA' => [
  267. 'FIELD' => ['U.BANK_PROVINCE', 'U.BANK_CITY', 'U.BANK_COUNTY'],
  268. 'BIND' => ['BANK_PROVINCE', 'BANK_CITY', 'BANK_COUNTY'],
  269. ],
  270. 'BANK_ADDRESS' => 'U.BANK_ADDRESS',
  271. 'BANK_NO' => 'U.BANK_NO',
  272. 'SEX' => 'U.SEX',
  273. 'NATION_NAME' => 'U.NATION',
  274. 'AREA' => [
  275. 'FIELD' => ['U.PROVINCE', 'U.CITY', 'U.COUNTY'],
  276. 'BIND' => ['PROVINCE', 'CITY', 'COUNTY'],
  277. ],
  278. 'ADDRESS' => 'U.ADDRESS',
  279. // 'IS_AUTO_WITHDRAW' => 'UI.IS_AUTO_WITHDRAW',
  280. 'VERIFIED' => 'U.VERIFIED',
  281. 'VERIFIED_AT' => 'U.VERIFIED_AT',
  282. // 'IS_DIRECT_SELLER' => 'U.IS_DIRECT_SELLER',
  283. // 'IS_SYSTEM_LEADER' => 'UI.IS_SYSTEM_LEADER',
  284. // 'IS_GROUP_LEADER' => 'UI.IS_GROUP_LEADER',
  285. 'ALLOW_TRANSFER' => 'UI.ALLOW_TRANSFER',
  286. ]);
  287. $condition = $filter['condition'];
  288. $params = $filter['params'];
  289. $condition .= ' AND UI.DELETED=0 AND U.REG_FROM=0';
  290. $listObj = new IndexList();
  291. $data = $listObj->getList(['condition' => $condition, 'params' => $params]);
  292. return static::notice($data);
  293. }
  294. /**
  295. * 点位绑定
  296. * @return mixed
  297. * @throws Exception
  298. * @throws HttpException
  299. */
  300. public function actionBind()
  301. {
  302. $filter = $this->filterCondition([
  303. 'userIds' => 'UI.USER_ID',
  304. 'MAIN_USER_NAME' => 'MUI.USER_NAME',
  305. 'HIGHEST_EMP_LV' => 'UI.HIGHEST_EMP_LV',
  306. 'CREATED_AT' => 'UB.CREATED_AT',
  307. 'UPDATED_AT' => 'UB.UPDATED_AT',
  308. 'CREATE_ADMIN_NAME' => 'ADMC.ADMIN_NAME',
  309. 'UPDATE_ADMIN_NAME' => 'ADMU.ADMIN_NAME',
  310. ]);
  311. $condition = $filter['condition'];
  312. $params = $filter['params'];
  313. $condition .= ' AND UB.IS_DEL=0';
  314. $listObj = new BindList();
  315. $data = $listObj->getList(['condition' => $condition, 'params' => $params]);
  316. return static::notice($data);
  317. }
  318. /**
  319. * 点位绑定导出
  320. * @return mixed
  321. * @throws \yii\db\Exception
  322. * @throws HttpException
  323. */
  324. public function actionBindExport()
  325. {
  326. $filter = $this->filterCondition([
  327. 'userIds' => 'UI.USER_ID',
  328. 'MAIN_USER_NAME' => 'MUI.USER_NAME',
  329. 'HIGHEST_EMP_LV' => 'UI.HIGHEST_EMP_LV',
  330. 'CREATED_AT' => 'UB.CREATED_AT',
  331. 'UPDATED_AT' => 'UB.UPDATED_AT',
  332. 'CREATE_ADMIN_NAME' => 'ADMC.ADMIN_NAME',
  333. 'UPDATE_ADMIN_NAME' => 'ADMU.ADMIN_NAME',
  334. ]);
  335. $filter['condition'] .= ' AND UB.IS_DEL=0';
  336. $form = new UserExportForm();
  337. $result = $form->run($filter, '点位绑定');
  338. if (!$result) {
  339. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  340. }
  341. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  342. }
  343. /**
  344. * 添加点位绑定
  345. * @return mixed
  346. * @throws HttpException
  347. */
  348. public function actionBindAdd()
  349. {
  350. if (Yii::$app->request->isPost) {
  351. return parent::edit(UserBindForm::class, Yii::t('ctx', 'successfully'), 'add', ['add'], null, function ($form, $result) {
  352. // Log::adminHandle('为' . $form->userName . '添加点位绑定,主点位:' . $form->mainUserName);
  353. });
  354. }
  355. }
  356. /**
  357. * 编辑点位绑定
  358. * @return mixed
  359. * @throws Exception
  360. * @throws HttpException
  361. */
  362. public function actionBindEdit()
  363. {
  364. $id = Yii::$app->request->get('id');
  365. if (Yii::$app->request->isPost) {
  366. return parent::edit(UserBindForm::class, Yii::t('ctx', 'successfully'), 'edit', ['edit'], null, function ($form, $result) {
  367. //$userBaseInfo = Info::baseInfo($result->USER_ID);
  368. // Log::adminHandle('为' . $userBaseInfo['USER_NAME'] . '更改点位绑定关系');
  369. });
  370. }
  371. // 获得当前会员的用户名等信息
  372. $userBind = UserBind::findOneAsArray('ID=:ID AND IS_DEL=0', [':ID' => $id]);
  373. $userBinds = UserBind::findAllAsArray('MAIN_UID=:MAIN_UID AND IS_DEL=0', [':MAIN_UID' => $userBind['MAIN_UID']]);
  374. foreach ($userBinds as $key => $value) {
  375. $userBinds[$key]['BASE_INFO'] = Info::baseInfoZh($value['USER_ID']);
  376. }
  377. return static::notice(['userBinds' => $userBinds, 'mainUid' => $userBind['MAIN_UID']]);
  378. }
  379. /**
  380. * 删除点位绑定
  381. * @return mixed
  382. * @throws \yii\db\Exception
  383. * @throws HttpException
  384. */
  385. public function actionBindDelete()
  386. {
  387. $userBindForm = new UserBindForm();
  388. $result = static::delete(UserBind::class, function ($selected) use ($userBindForm) {
  389. $userBindForm->beforeDelete($selected);
  390. }, function ($selected) use ($userBindForm) {
  391. $userBindForm->delete($selected);
  392. }, false);
  393. return self::notice(Yii::t('ctx', 'successfully'));
  394. }
  395. /**
  396. * 生成点位合作的用户名
  397. * @return mixed
  398. * @throws \yii\base\InvalidConfigException
  399. * @throws HttpException
  400. */
  401. public function actionGenerateUserName()
  402. {
  403. // 获取用户名
  404. if (!$userName = Info::generateUserName('hz')) {
  405. return static::notice(Yii::t('ctx', 'failed'), 400);
  406. }
  407. return static::notice(['userName' => $userName]);
  408. }
  409. /**
  410. * 点位合作
  411. * @return mixed
  412. * @throws Exception
  413. * @throws HttpException
  414. */
  415. public function actionTeamwork()
  416. {
  417. $filter = $this->filterCondition([
  418. 'userIds' => 'UI.USER_ID',
  419. 'MAIN_USER_NAME' => 'MUI.USER_NAME',
  420. 'DIVIDE_PERCENT' => 'UT.DIVIDE_PERCENT',
  421. 'CREATE_REMARK' => 'UT.CREATE_REMARK',
  422. 'CREATE_ADMIN_NAME' => 'ADMC.ADMIN_NAME',
  423. 'CREATED_AT' => 'UT.CREATED_AT',
  424. 'PERIOD_NUM' => 'UT.PERIOD_NUM',
  425. 'UPDATE_ADMIN_NAME' => 'ADMU.ADMIN_NAME',
  426. 'UPDATED_AT' => 'UT.UPDATED_AT',
  427. 'UPDATED_PERIOD' => 'UT.PERIOD_NUM',
  428. ]);
  429. $condition = $filter['condition'];
  430. $params = $filter['params'];
  431. $condition .= ' AND UT.IS_DEL=0';
  432. $listObj = new TeamworkList();
  433. $data = $listObj->getList(['condition' => $condition, 'params' => $params]);
  434. return static::notice($data);
  435. }
  436. /**
  437. * 点位合作导出
  438. * @return mixed
  439. * @throws \yii\db\Exception
  440. * @throws HttpException
  441. */
  442. public function actionTeamworkExport()
  443. {
  444. $filter = $this->filterCondition([
  445. 'userIds' => 'UI.USER_ID',
  446. 'MAIN_USER_NAME' => 'MUI.USER_NAME',
  447. 'DIVIDE_PERCENT' => 'UT.DIVIDE_PERCENT',
  448. 'CREATE_REMARK' => 'UT.CREATE_REMARK',
  449. 'CREATE_ADMIN_NAME' => 'ADMC.ADMIN_NAME',
  450. 'CREATED_AT' => 'UT.CREATED_AT',
  451. 'PERIOD_NUM' => 'UT.PERIOD_NUM',
  452. 'UPDATE_ADMIN_NAME' => 'ADMU.ADMIN_NAME',
  453. 'UPDATED_AT' => 'UT.UPDATED_AT',
  454. 'UPDATED_PERIOD' => 'UT.PERIOD_NUM',
  455. ]);
  456. $filter['condition'] .= ' AND UT.IS_DEL=0';
  457. $form = new UserExportForm();
  458. $result = $form->run($filter, '点位合作');
  459. if (!$result) {
  460. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  461. }
  462. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  463. }
  464. /**
  465. * 添加点位合作
  466. * @return mixed
  467. * @throws HttpException
  468. */
  469. public function actionTeamworkAdd()
  470. {
  471. if (Yii::$app->request->isPost) {
  472. return parent::edit(UserTeamworkForm::class, Yii::t('ctx', 'successfully'), 'add', ['add'], null, function ($form, $result) {
  473. // Log::adminHandle('为' . $form->mainUserName . '添加合作点位,姓名:' . $form->userName, 0, $result->USER_ID, $form->userName);
  474. });
  475. }
  476. // 所有民族
  477. $allNation = Yii::$app->params['nation'];
  478. // 所有开户行
  479. $allOpenBank = OpenBank::findAllAsArray('STATUS=1');
  480. return static::notice(['allNation' => $allNation, 'allOpenBank' => $allOpenBank]);
  481. }
  482. /**
  483. * 编辑点位合作
  484. * @return mixed
  485. * @throws Exception
  486. * @throws HttpException
  487. */
  488. public function actionTeamworkEdit()
  489. {
  490. $id = Yii::$app->request->get('id');
  491. if (Yii::$app->request->isPost) {
  492. return parent::edit(UserTeamworkForm::class, Yii::t('ctx', 'successfully'), 'changeDivide', ['changeDivide'], null, function ($form, $result) {
  493. foreach ($result['logs'] as $k => $value) {
  494. $userName = Info::getUserNameByUserId($k);
  495. // Log::adminHandle('为' . $userName . '编辑合作点位分成比例为' . $value , 1, $k, $userName);
  496. }
  497. });
  498. }
  499. // 获得当前会员的用户名等信息
  500. if (!$userTeamwork = UserTeamwork::findOneAsArray('ID=:ID AND IS_DEL=0', [':ID' => $id], 'MAIN_UID')) {
  501. return static::notice('点位合作不存在', 404);
  502. }
  503. $teamwork = UserTeamwork::findAllAsArray('MAIN_UID=:MAIN_UID AND IS_DEL=0', [':MAIN_UID' => $userTeamwork['MAIN_UID']], 'ID,USER_ID,MAIN_UID,DIVIDE_PERCENT');
  504. foreach ($teamwork as $key => $value) {
  505. $userInfo = Info::baseInfo($value['USER_ID']);
  506. $teamwork[$key]['USER_NAME'] = $userInfo['USER_NAME'];
  507. $teamwork[$key]['REAL_NAME'] = $userInfo['REAL_NAME'];
  508. }
  509. unset($userInfo);
  510. return static::notice($teamwork);
  511. }
  512. /**
  513. * 删除方法
  514. * @return mixed
  515. * @throws \yii\db\Exception
  516. * @throws HttpException
  517. */
  518. public function actionTeamworkDelete()
  519. {
  520. return static::notice('无法删除', 400);
  521. $result = static::delete(UserTeamwork::class, null, function ($selected) {
  522. UserTeamworkForm::delete($selected);
  523. // Log::adminHandle('删除合作点位');
  524. }, false);
  525. return $result;
  526. }
  527. /**
  528. * 会员体系
  529. * @return mixed
  530. * @throws Exception
  531. * @throws HttpException
  532. */
  533. public function actionSystem()
  534. {
  535. $filter = $this->filterCondition([
  536. 'userIds' => 'US.LEADER_UID',
  537. 'SYSTEM_NAME' => 'US.SYSTEM_NAME',
  538. 'CREATE_ADMIN_NAME' => 'ADMC.ADMIN_NAME',
  539. 'PERIOD_NUM' => 'US.PERIOD_NUM',
  540. 'CREATED_AT' => 'US.CREATED_AT',
  541. 'UPDATE_ADMIN_NAME' => 'ADMU.ADMIN_NAME',
  542. 'UPDATE_PERIOD_NUM' => 'US.UPDATE_PERIOD_NUM',
  543. 'UPDATED_AT' => 'US.UPDATED_AT',
  544. 'IS_DEL' => 'US.IS_DEL',
  545. 'CREATE_REMARK' => 'US.CREATE_REMARK',
  546. ]);
  547. $condition = $filter['condition'];
  548. $params = $filter['params'];
  549. $listObj = new SystemList();
  550. $data = $listObj->getList(['condition' => $condition, 'params' => $params]);
  551. return static::notice($data);
  552. }
  553. /**
  554. * 体系管理导出
  555. * @return mixed
  556. * @throws \yii\db\Exception
  557. * @throws HttpException
  558. */
  559. public function actionSystemExport()
  560. {
  561. $filter = $this->filterCondition([
  562. 'userIds' => 'US.LEADER_UID',
  563. 'SYSTEM_NAME' => 'US.SYSTEM_NAME',
  564. 'CREATE_ADMIN_NAME' => 'ADMC.ADMIN_NAME',
  565. 'PERIOD_NUM' => 'US.PERIOD_NUM',
  566. 'CREATED_AT' => 'US.CREATED_AT',
  567. 'UPDATE_ADMIN_NAME' => 'ADMU.ADMIN_NAME',
  568. 'UPDATE_PERIOD_NUM' => 'US.UPDATE_PERIOD_NUM',
  569. 'UPDATED_AT' => 'US.UPDATED_AT',
  570. 'IS_DEL' => 'US.IS_DEL',
  571. 'CREATE_REMARK' => 'US.CREATE_REMARK',
  572. ]);
  573. $form = new UserExportForm();
  574. $result = $form->run($filter, '体系管理');
  575. if (!$result) {
  576. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  577. }
  578. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  579. }
  580. /**
  581. * 添加体系
  582. * @return mixed
  583. * @throws \yii\base\InvalidConfigException
  584. * @throws \yii\db\Exception
  585. * @throws \yii\httpclient\Exception
  586. * @throws HttpException
  587. */
  588. public function actionSystemAdd()
  589. {
  590. if (Yii::$app->request->post()) {
  591. $formModel = new UserSystemForm();
  592. $formModel->scenario = 'add';
  593. if ($formModel->load(Yii::$app->request->post(), '') && $formModel->edit()) {
  594. // Log::adminHandle('添加体系' . Yii::$app->request->post('systemName'));
  595. return static::notice(Yii::t('ctx', 'successfully'));
  596. } else {
  597. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  598. }
  599. }
  600. }
  601. /**
  602. * 编辑体系
  603. * @return mixed
  604. * @throws \yii\base\InvalidConfigException
  605. * @throws \yii\httpclient\Exception
  606. * @throws HttpException
  607. */
  608. public function actionSystemEdit()
  609. {
  610. $id = Yii::$app->request->get('id');
  611. if (Yii::$app->request->isPost) {
  612. return parent::edit(UserSystemForm::class, Yii::t('ctx', 'successfully'), 'edit', ['edit'], null, function ($form, $result) {
  613. // Log::adminHandle('编辑体系' . $result['SYSTEM_NAME']);
  614. });
  615. }
  616. if (!$oneData = UserSystem::find()->select('US.*, UI.USER_NAME AS LEADER_NAME')->where('US.ID=:ID AND US.IS_DEL=0', [':ID' => $id])->from(UserSystem::tableName() . ' AS US')->join('LEFT JOIN', UserInfo::tableName() . ' AS UI', 'US.LEADER_UID=UI.USER_ID')->asArray()->one()) {
  617. return static::notice('体系已撤销或不存在', 400);
  618. }
  619. return static::notice(['oneData' => $oneData]);
  620. }
  621. /**
  622. * 恢复体系
  623. * @return mixed
  624. * @throws HttpException
  625. */
  626. public function actionSystemRenew()
  627. {
  628. return parent::edit(UserSystemForm::class, Yii::t('ctx', 'successfully'), 'renewSystem', [
  629. 'renewSystem',
  630. ], null, function ($form, $result) {
  631. // Log::adminHandle('编辑体系' . $result['SYSTEM_NAME']);
  632. });
  633. }
  634. /**
  635. * 删除方法
  636. * @return mixed
  637. * @throws \yii\db\Exception
  638. * @throws HttpException
  639. */
  640. public function actionSystemDelete()
  641. {
  642. $userSystemForm = new UserSystemForm();
  643. $result = static::delete(UserSystem::class, function ($selected) use ($userSystemForm) {
  644. $userSystemForm->beforeDelete($selected);
  645. }, function ($selected) use ($userSystemForm) {
  646. $userSystemForm->delete($selected);
  647. }, false);
  648. return self::notice(Yii::t('ctx', 'successfully'));
  649. }
  650. /**
  651. * 团队领导人列表
  652. * @return mixed
  653. * @throws Exception
  654. * @throws HttpException
  655. */
  656. public function actionGroup()
  657. {
  658. $filter = $this->filterCondition([
  659. 'userName' => 'UI.USER_NAME',
  660. ]);
  661. $condition = $filter['condition'];
  662. $params = $filter['params'];
  663. $condition .= ' AND PUI.IS_GROUP_LEADER=1';
  664. $listObj = new GroupList();
  665. $data = $listObj->getList(['condition' => $condition, 'params' => $params]);
  666. return static::notice($data);
  667. }
  668. /**
  669. * 团队领导人列表导出
  670. * @return mixed
  671. * @throws \yii\db\Exception
  672. * @throws HttpException
  673. */
  674. public function actionGroupExport()
  675. {
  676. $filter = $this->filterCondition([
  677. 'userName' => 'UI.USER_NAME',
  678. ]);
  679. $filter['condition'] .= ' AND PUI.IS_GROUP_LEADER=1';
  680. $form = new UserExportForm();
  681. $result = $form->run($filter, '团队领导人列表');
  682. if (!$result) {
  683. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  684. }
  685. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  686. }
  687. /**
  688. * 会员移网记录
  689. * @return mixed
  690. * @throws Exception
  691. * @throws HttpException
  692. */
  693. public function actionMove()
  694. {
  695. $filter = $this->filterCondition([
  696. 'filterStatus' => 'UM.AUDIT_STATUS',
  697. 'MOVE_USER_NAME' => 'CU.USER_NAME',
  698. 'MOVE_REAL_NAME' => 'CU.REAL_NAME',
  699. 'MOVE_PERCENT_SHOW' => 'UM.MOVE_PERCENT',
  700. 'CREATE_ADMIN_NAME' => 'ADMC.ADMIN_NAME',
  701. 'PERIOD_NUM' => 'UM.PERIOD_NUM',
  702. 'AUDIT_ADMIN_NAME' => 'ADMU.ADMIN_NAME',
  703. 'MOVE_ADMIN_NAME' => 'ADMC.ADMIN_NAME',
  704. 'AUDITED_AT' => 'UM.AUDITED_AT',
  705. ]);
  706. $condition = $filter['condition'];
  707. $params = $filter['params'];
  708. $listObj = new MoveList();
  709. $data = $listObj->getList(['condition' => $condition, 'params' => $params]);
  710. return static::notice($data);
  711. }
  712. /**
  713. * 移网管理导出
  714. * @return mixed
  715. * @throws \yii\db\Exception
  716. * @throws HttpException
  717. */
  718. public function actionMoveExport()
  719. {
  720. $filter = $this->filterCondition([
  721. //'userIds' => 'UM.USER_ID',
  722. 'filterStatus' => 'UM.AUDIT_STATUS',
  723. 'moveType' => 'UM.TYPE',
  724. 'FROM_USER_NAME' => 'FUI.USER_NAME',
  725. 'TO_USER_NAME' => 'TUI.USER_NAME',
  726. //'MOVE_PERCENT_SHOW' => 'UM.MOVE_PERCENT',
  727. //'STARTED_AT' => 'UM.STARTED_AT',
  728. //'ENDED_AT' => 'UM.ENDED_AT',
  729. 'CREATE_ADMIN_NAME' => 'ADMC.ADMIN_NAME',
  730. 'PERIOD_NUM' => 'UM.PERIOD_NUM',
  731. 'CREATED_AT' => 'UM.CREATED_AT',
  732. 'AUDIT_ADMIN_NAME' => 'ADMU.ADMIN_NAME',
  733. //'AUDIT_PERIOD_NUM' => 'UM.AUDIT_PERIOD_NUM',
  734. 'AUDITED_AT' => 'UM.AUDITED_AT',
  735. //'CREATE_REMARK' => 'UM.CREATE_REMARK',
  736. ]);
  737. $form = new UserExportForm();
  738. $result = $form->run($filter, 'Move_Network'); // 移网管理
  739. if (!$result) {
  740. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  741. }
  742. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  743. }
  744. /**
  745. * 申请移网
  746. * @return mixed
  747. * @throws \yii\base\InvalidConfigException
  748. * @throws \yii\httpclient\Exception
  749. * @throws HttpException
  750. */
  751. public function actionMoveAdd()
  752. {
  753. if (Yii::$app->request->isPost) {
  754. return parent::edit(NetMoveForm::class, Yii::t('ctx', 'successfully'), 'add', ['add'], null, function ($form, $result) { // 移网申请成功
  755. // $user = User::getBaseInfoFromRedis($result['USER_ID']);
  756. // Log::adminHandle('申请为' . $user['USER_NAME'] . '移网', 1, $result['USER_ID'], $user['USER_NAME']);
  757. });
  758. }
  759. }
  760. /**
  761. * 获取全部移网类型
  762. * @return mixed
  763. * @throws HttpException
  764. */
  765. public function actionMoveNetType()
  766. {
  767. return static::notice(['netType' => UserMove::getNetWork()]);
  768. }
  769. /**
  770. * 获取移网数据
  771. * @return mixed
  772. * @throws Exception
  773. * @throws HttpException
  774. */
  775. public function actionMoveGet()
  776. {
  777. $id = Yii::$app->request->get('id');
  778. $userMove = UserMove::find()->where('ID=:ID', [':ID' => $id])->asArray()->one();
  779. if (!$userMove) {
  780. return static::notice('Data not exists', 400);
  781. }
  782. $userMove['BASE_INFO'] = Info::baseInfoWithNet($userMove['USER_ID']);
  783. $toUserInfo = Info::baseInfoZh($userMove['TO_UID']);
  784. return static::notice(['moveId' => $userMove['ID'], 'moveUserName' => $userMove['BASE_INFO']['USER_NAME'], 'baseInfo' => $userMove['BASE_INFO'], 'type' => $userMove['TYPE'], 'toConUserName' => $toUserInfo['USER_NAME'], 'toConRealName' => $toUserInfo['REAL_NAME'], 'location' => $userMove['LOCATION'], 'remark' => $userMove['CREATE_REMARK']]);
  785. }
  786. /**
  787. * 修改移网数据
  788. * @return mixed
  789. * @throws \yii\db\Exception
  790. * @throws HttpException
  791. */
  792. public function actionMoveEdit()
  793. {
  794. $formModel = new NetMoveForm();
  795. $formModel->scenario = 'edit';
  796. if ($formModel->load(Yii::$app->request->post(), '') && $result = $formModel->edit()) {
  797. $user = Info::baseInfoZh($result['USER_ID']);
  798. // Log::adminHandle('修改' . $user['USER_NAME'] . '移网录入数据', 1, $result['USER_ID'], $user['USER_NAME']);
  799. return static::notice(Yii::t('ctx', 'successfully')); // 修改移网录入数据完成
  800. }
  801. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  802. }
  803. /**
  804. * 审核通过移网数据(实际的移网动作在这里,异步操作)
  805. * @return mixed
  806. * @throws \yii\db\Exception
  807. * @throws HttpException
  808. */
  809. public function actionMovePass()
  810. {
  811. $formModel = new NetMoveForm();
  812. $formModel->scenario = 'pass';
  813. if ($formModel->load(Yii::$app->request->post(), '') && $result = $formModel->pass()) {
  814. $user = Info::baseInfoZh($result['USER_ID']);
  815. // Log::adminHandle('审核通过移网数据', 1, $result['USER_ID'], $user['USER_NAME']);
  816. return static::notice("It's on the move. Please wait"); // 正在移动中,请稍候
  817. }
  818. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  819. }
  820. /**
  821. * 审核移网数据
  822. * @return mixed
  823. * @throws \yii\base\InvalidConfigException
  824. * @throws \yii\db\Exception
  825. * @throws \yii\httpclient\Exception
  826. * @throws HttpException
  827. */
  828. public function actionMoveAudit()
  829. {
  830. $formModel = new NetMoveForm();
  831. $formModel->scenario = 'changeAudit';
  832. if ($formModel->load(Yii::$app->request->post(), '') && $result = $formModel->changeAudit()) {
  833. // Log::adminHandle('审核移网数据');
  834. return static::notice(Yii::t('ctx', 'successfully')); // 审核移网数据完成
  835. }
  836. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  837. }
  838. /**
  839. * 删除移网数据
  840. * @return mixed
  841. * @throws \yii\db\Exception
  842. * @throws HttpException
  843. */
  844. public function actionMoveDelete()
  845. {
  846. $netMoveForm = new NetMoveForm();
  847. $result = static::delete(UserMove::class, function ($selected) use ($netMoveForm) {
  848. $netMoveForm->beforeDelete($selected);
  849. }, function ($selected) use ($netMoveForm) {
  850. $netMoveForm->delete($selected);
  851. }, true);
  852. return $result;
  853. }
  854. /**
  855. * 会员的基础用户信息
  856. * @return mixed
  857. * @throws HttpException
  858. */
  859. public function actionFullInfo()
  860. {
  861. $userName = Yii::$app->request->get('userName');
  862. $userInfo = Info::getBaseUserByUserName($userName);
  863. $isSuper = AdminRole::isSuperAdmin(\Yii::$app->getUser()->getUserInfo()['roleId']);
  864. if (!$isSuper) {
  865. $adminId = Yii::$app->getUser()->getUserInfo()['id'];
  866. $adminCountry = AdminCountry::getCountry($adminId);
  867. if (!in_array($userInfo['COUNTRY_ID'], $adminCountry)) {
  868. return static::notice('Member number does not exist', 400);
  869. }
  870. }
  871. if($userInfo){
  872. $decLevelConfig = Cache::getDecLevelConfig();
  873. $userInfo['LEVEL_NAME'] = isset($decLevelConfig[$userInfo['DEC_LV']])?$decLevelConfig[$userInfo['DEC_LV']]['LEVEL_NAME'] : '';
  874. $userInfo['BONUS'] = Balance::getAvailableBalance($userInfo['ID']);
  875. $userInfo['CASH'] = Cash::getAvailableBalance($userInfo['ID']);
  876. $userInfo['RECONSUME_POINTS'] = Balance::getBalanceReconsumePoints($userInfo['ID']);
  877. $userInfo['EXCHANGE_POINTS'] = Balance::getBalanceExchangePoints($userInfo['ID']);
  878. return static::notice($userInfo);
  879. }else{
  880. return static::notice('Member number does not exist', 400);//会员编号不存在
  881. }
  882. }
  883. /**
  884. * 会员的基本信息编号名称
  885. * @return mixed
  886. * @throws HttpException
  887. */
  888. public function actionBaseInfo()
  889. {
  890. $userName = Yii::$app->request->get('userName');
  891. $baseUser = Info::getBaseUserByUserName($userName);
  892. return static::notice($baseUser);
  893. }
  894. /**
  895. * 点位合作主点位分成比例
  896. * @return mixed
  897. * @throws HttpException
  898. */
  899. public function actionMainDivide()
  900. {
  901. $userId = Yii::$app->request->get('userId');
  902. $divide = 100;
  903. if ($teamwork = UserTeamwork::findOneAsArray('USER_ID=:USER_ID AND MAIN_UID=:USER_ID AND IS_DEL=0', [':USER_ID' => $userId], 'DIVIDE_PERCENT')) {
  904. $divide = $teamwork['DIVIDE_PERCENT'];
  905. }
  906. return static::notice($divide);
  907. }
  908. /**
  909. * 获取子公司
  910. * @return mixed
  911. * @throws HttpException
  912. */
  913. public function actionGetSubCom()
  914. {
  915. $areaSelected = Yii::$app->request->get('areaSelected');
  916. $location = [];
  917. return static::notice($location);
  918. }
  919. /**
  920. * 判断是否在同一推荐网络
  921. * @return mixed
  922. * @throws HttpException
  923. */
  924. public function actionChkRelation()
  925. {
  926. $userName = Yii::$app->request->get('userName');
  927. $toUserName = Yii::$app->request->get('toUserName');
  928. $userId = Info::getUserIdByUserName($userName);
  929. $toUserId = Info::getUserIdByUserName($toUserName);
  930. $is = 0;
  931. if (UserRelation::isParentUser($userId, $toUserId)) {
  932. $is = 1;
  933. }
  934. $toUser = Info::baseInfoWithNetAndBalance($toUserId);
  935. $real_name = $toUser ? $toUser['REAL_NAME'] : '';
  936. return static::notice(['is' => $is, 'real_name' => $real_name]);
  937. }
  938. /**
  939. * 获取当前期数
  940. * @return mixed
  941. * @throws HttpException
  942. */
  943. public function actionGetPeriodNum()
  944. {
  945. $period = Period::instance();
  946. $periodNum = $period->getNowPeriodNum();
  947. //上期是否挂网
  948. $lastPeriodNum = $periodNum - 1;
  949. $periodArr = [$periodNum];
  950. if ($period->isSent($lastPeriodNum)) {
  951. $periodArr[] = $periodNum + 1;
  952. } else {
  953. $periodArr[] = $lastPeriodNum;
  954. }
  955. return static::notice($periodArr);
  956. }
  957. /**
  958. * 关停列表
  959. * @return mixed
  960. * @throws HttpException
  961. */
  962. // public function actionClose()
  963. // {
  964. // $filter = $this->filterCondition([
  965. // 'userIds' => 'UC.USER_ID',
  966. // 'filterStatus' => 'UC.AUDIT_STATUS',
  967. // ]);
  968. // $condition = $filter['condition'];
  969. // $params = $filter['params'];
  970. // $data = UserClose::lists($condition, $params, [
  971. // 'from' => UserClose::tableName() . ' AS UC',
  972. // 'orderBy' => 'UC.CREATED_AT DESC',
  973. // ]);
  974. // // 获取全部移网类型
  975. // $data['type'] = [
  976. // UserClose::TYPE_GT => '关停',
  977. // UserClose::TYPE_TF => '停发',
  978. // ];
  979. // $auditStatus = array_column(\Yii::$app->params['auditStatus'], null, 'value');
  980. // foreach ($data['list'] as $key => $value) {
  981. // $data['list'][$key]['BASE_INFO'] = Info::baseInfoZh($value['USER_ID']);
  982. // $data['list'][$key]['CREATE_ADMIN_NAME'] = Admin::getAdminNameById($value['ADMIN_ID']);
  983. // $data['list'][$key]['AUDIT_ADMIN_NAME'] = Admin::getAdminNameById($value['AUDIT_ADMIN_ID']);
  984. // $data['list'][$key]['STATUS_NAME'] = $auditStatus[$value['AUDIT_STATUS']]['label'];
  985. // }
  986. // return static::notice($data);
  987. //
  988. // }
  989. /**
  990. * 申请关停或停发
  991. * @return mixed
  992. * @throws HttpException
  993. */
  994. // public function actionCloseAdd()
  995. // {
  996. // if (Yii::$app->request->isPost) {
  997. // return parent::edit(UserCloseForm::class, '申请成功', null, null, null, function ($form, $result) {
  998. // $user = User::getBaseInfoFromRedis($result['USER_ID']);
  999. // $type = '';
  1000. // switch ($result['TYPE']) {
  1001. // case UserClose::TYPE_GT:
  1002. // $type = '关停';
  1003. // break;
  1004. // case UserClose::TYPE_TF:
  1005. // $type = '停发';
  1006. // break;
  1007. // }
  1008. // // Log::adminHandle('申请' . $user['USER_NAME'] . $type, 1, $result['USER_ID'], $user['USER_NAME']);
  1009. // });
  1010. // }
  1011. // // 获取全部移网类型
  1012. // $type = [
  1013. // UserClose::TYPE_GT => '关停',
  1014. // UserClose::TYPE_TF => '停发',
  1015. // ];
  1016. // return static::notice(['type' => $type]);
  1017. // }
  1018. /**
  1019. * 审核关停或停发
  1020. * @return mixed
  1021. * @throws \yii\db\Exception
  1022. * @throws HttpException
  1023. */
  1024. // public function actionCloseAudit()
  1025. // {
  1026. // $formModel = new UserCloseForm();
  1027. // $formModel->scenario = 'audit';
  1028. // if ($formModel->load(Yii::$app->request->get(), '') && $result = $formModel->audit()) {
  1029. // $user = User::getBaseInfoFromRedis($result['USER_ID']);
  1030. // $type = '';
  1031. // switch ($result['TYPE']) {
  1032. // case UserClose::TYPE_GT:
  1033. // $type = '关停';
  1034. // break;
  1035. // case UserClose::TYPE_TF:
  1036. // $type = '停发';
  1037. // break;
  1038. // }
  1039. // // Log::adminHandle('审核' . $user['USER_NAME'] . $type, 1, $result['USER_ID'], $user['USER_NAME']);
  1040. // return static::notice('操作成功');
  1041. // }
  1042. // return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  1043. // }
  1044. /**
  1045. * 添加会员
  1046. * @return mixed
  1047. * @throws HttpException
  1048. */
  1049. public function actionUserAdd()
  1050. {
  1051. if (Yii::$app->request->isPost) {
  1052. return parent::edit(AdminAddUserForm::class, Yii::t('ctx', 'successfully'), null, null, null, function ($form, $result) {//添加成功
  1053. // Log::adminHandle('后台添加会员:' . $result['USER_NAME'], 1, $result['ID'], $result['USER_NAME']);
  1054. });
  1055. }
  1056. $countryId = \Yii::$app->request->get('countryId');
  1057. // 获取所有报单中心级别
  1058. $allDecRole = DecRole::getAllData();
  1059. // 所有民族
  1060. $allNation = Yii::$app->params['nation'];
  1061. // 行政区划
  1062. $regions = Region::getByCountryId($countryId);
  1063. // 银行开户行
  1064. $allOpenBank = OpenBank::findAllAsArray('STATUS=:STATUS AND COUNTRY_ID=:COUNTRY_ID', [':STATUS' => 1, ':COUNTRY_ID' => $countryId]);
  1065. // 生成用户名
  1066. if (!$userName = Info::generateWebName($countryId)) {
  1067. return static::notice('Failed to generate member number', 400);//会员编号生成失败
  1068. }
  1069. return static::notice(
  1070. [
  1071. 'allDecRole' => $allDecRole,
  1072. 'allNation' => $allNation,
  1073. 'allOpenBank' => $allOpenBank,
  1074. 'userName' => $userName,
  1075. 'region' => $regions,
  1076. ]);
  1077. }
  1078. /**
  1079. * 分页导入excel文件到待导入数据的表中
  1080. * @return mixed
  1081. * @throws HttpException
  1082. */
  1083. public function actionImportUsersToExcelTable()
  1084. {
  1085. // 先上传到服务器文件
  1086. if (\Yii::$app->request->isPost) {
  1087. $excelImportId = Yii::$app->request->post('excelImportId');
  1088. $rowCount = Yii::$app->request->post('rowCount');
  1089. $startRow = Yii::$app->request->post('startRow');
  1090. $limit = Yii::$app->request->post('limit', 1000);
  1091. $errorMsg = '';
  1092. try {
  1093. $excel = new \common\helpers\Excel();
  1094. $result = $excel->pageImportDataFromExcel('addUser', $excelImportId, $rowCount, $startRow, $limit);
  1095. } catch (Exception $e) {
  1096. $result = false;
  1097. $errorMsg = $e->getMessage();
  1098. }
  1099. // 还有数据
  1100. if ($result === 1) {
  1101. return static::notice(['finish' => false]);
  1102. } elseif ($result === 0) {
  1103. return static::notice(['finish' => true]);
  1104. } else {
  1105. return static::notice('An error occurred:' . $errorMsg, 400);//发生错误
  1106. }
  1107. }
  1108. }
  1109. public function actionModifyPassword() {
  1110. $form = new UserBasicForm();
  1111. $form->scenario = 'modifyPassword';
  1112. if(Yii::$app->request->isPost && $form->load(Yii::$app->request->post(), '') && $result = $form->edit()){
  1113. return static::notice(Yii::t('ctx', 'successfully')); // 密码修改成功
  1114. } else {
  1115. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1116. }
  1117. }
  1118. /**
  1119. * 个人资料获取
  1120. * @return mixed
  1121. * @throws HttpException
  1122. */
  1123. public function actionProfileGet() {
  1124. $id = Yii::$app->request->get('id');
  1125. $userInfo = User::findOneAsArray('ID=:ID', [':ID' => $id]);
  1126. if (!$userInfo) {
  1127. return static::notice('Data does not exist', 400);//数据不存在
  1128. }
  1129. $data['allNation'] = \Yii::$app->params['nation'];
  1130. $data['region'] = Region::getByCountryId($userInfo['COUNTRY_ID']);
  1131. $data['language'] = Language::getFromCache();
  1132. $data['allOpenBank'] = OpenBank::find()
  1133. ->where('STATUS=:STATUS AND COUNTRY_ID=:COUNTRY_ID', [':STATUS' => 1, ':COUNTRY_ID' => $userInfo['COUNTRY_ID']])
  1134. ->orderBy('BANK_NAME ASC')
  1135. ->asArray()
  1136. ->all();
  1137. $countries = Countries::getFromCache();
  1138. $isSuper = AdminRole::isSuperAdmin(\Yii::$app->getUser()->getUserInfo()['roleId']);
  1139. if (!$isSuper) {
  1140. $adminId = Yii::$app->getUser()->getUserInfo()['id'];
  1141. $adminCountry = AdminCountry::getCountry($adminId);
  1142. $countries = array_filter($countries, fn($country) => in_array($country['ID'], $adminCountry));
  1143. $countries = array_values($countries);
  1144. }
  1145. $data['country'] = array_values($countries);
  1146. $data['userInfo'] = [
  1147. 'userId' => $userInfo['ID'],
  1148. 'nation' => \Yii::$app->params['nation'][$userInfo['NATION']]['name']??'',
  1149. 'realName' => $userInfo['REAL_NAME'],
  1150. 'idCard' => $userInfo['ID_CARD'],
  1151. 'mobile' => $userInfo['MOBILE'],
  1152. 'openBank' => $userInfo['OPEN_BANK'],
  1153. 'bankAddress' => $userInfo['BANK_ADDRESS'],
  1154. 'bankNo' => $userInfo['BANK_NO'],
  1155. 'language' => $userInfo['LANGUAGE_ID'],
  1156. 'country' => $userInfo['COUNTRY_ID'],
  1157. ];
  1158. return static::notice($data);
  1159. }
  1160. public function actionModifyProfile() {
  1161. $form = new UserBasicForm();
  1162. $form->scenario = 'modifyProfile';
  1163. if(Yii::$app->request->isPost && $form->load(Yii::$app->request->post(), '') && $result = $form->modifyProfile()){
  1164. return static::notice(Yii::t('ctx', 'successfully'));//个人资料修改成功
  1165. } else {
  1166. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1167. }
  1168. }
  1169. public function actionModifyStatus() {
  1170. $form = new UserBasicForm();
  1171. $form->scenario = 'modifyStatus';
  1172. if(Yii::$app->request->isPost && $form->load(Yii::$app->request->post(), '') && $result = $form->modifyStatus()){
  1173. return static::notice(Yii::t('ctx', 'successfully'));//会员状态修改成功
  1174. } else {
  1175. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1176. }
  1177. }
  1178. /**
  1179. * @return mixed
  1180. * @throws \yii\db\Exception
  1181. * @throws HttpException
  1182. */
  1183. public function actionIsModifyPasswordStatus() {
  1184. $form = new UserBasicForm();
  1185. $form->scenario = 'isModifyPasswordStatus';
  1186. if(Yii::$app->request->isPost && $form->load(Yii::$app->request->post(), '') && $result = $form->isModifyPasswordStatus()){
  1187. return static::notice(Yii::t('ctx', 'successfully'));//状态修改成功
  1188. } else {
  1189. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1190. }
  1191. }
  1192. /**
  1193. * 分页把待导入表中的数据导入到真正的数据中
  1194. * @return mixed
  1195. * @throws HttpException
  1196. */
  1197. public function actionImportUsersAdd()
  1198. {
  1199. if (\Yii::$app->request->isPost) {
  1200. $excelImportId = Yii::$app->request->post('excelImportId');
  1201. $offset = Yii::$app->request->post('offset');
  1202. $limit = Yii::$app->request->post('limit', 1000);
  1203. $errorMsg = '';
  1204. try {
  1205. $excel = new \common\helpers\Excel();
  1206. $result = $excel->pageImportDataFromExcelTable('addUser', $excelImportId, $offset, $limit);
  1207. } catch (Exception $e) {
  1208. $result = false;
  1209. $errorMsg = $e->getMessage();
  1210. }
  1211. // 还有数据
  1212. if ($result === 1) {
  1213. return static::notice(['finish' => false]);
  1214. } elseif ($result === 0) {
  1215. return static::notice(['finish' => true]);
  1216. } else {
  1217. return static::notice('An error occurred:' . $errorMsg, 400);//发生错误
  1218. }
  1219. }
  1220. }
  1221. /**
  1222. * 判断是否满足删除条件
  1223. * @return mixed
  1224. * @throws HttpException
  1225. */
  1226. public function actionChkDelUser()
  1227. {
  1228. $userName = Yii::$app->request->get('userName');
  1229. if (!$uid = Info::getUserIdByUserName($userName)) {
  1230. return static::notice('user does not exist' . $userName, 400);//用户不存在
  1231. }
  1232. if (UserInfo::findOneAsArray('REC_UID=:REC_UID AND DELETED=0', [':REC_UID' => $uid], 'USER_ID')) {
  1233. return static::notice('This member has developed other members and cannot be deleted', 400);//此会员已开拓其它会员不可以删除
  1234. }
  1235. if (UserInfo::findOneAsArray('CON_UID=:CON_UID AND DELETED=0', [':CON_UID' => $uid], 'USER_ID')) {
  1236. return static::notice('This member has been placed with other members and cannot be deleted', 400);//此会员已安置其它会员不可以删除
  1237. }
  1238. if (User::findOneAsArray('DEC_ID=:DEC_ID AND DELETED=0', [':DEC_ID' => $uid], 'ID')) {
  1239. return static::notice('This member has submitted a bill and other members cannot delete it', 400);//此会员已报单其它会员不可以删除
  1240. }
  1241. if (DecOrder::findOneAsArray('USER_ID=:TO_USER_ID OR TO_USER_ID=:TO_USER_ID', [':TO_USER_ID' => $uid], 'ID')) {
  1242. return static::notice('This member has submitted a bill and cannot be deleted', 400);//此会员已报单不可以删除
  1243. }
  1244. $info = Info::baseInfoWithNet($uid);
  1245. if ($info['REG_FROM'] == 1) {
  1246. return static::notice('This member is not empty and cannot be deleted', 400);//此会员不是空单无法删除
  1247. }
  1248. $sentMaxPeriodNum = Period::sentMaxPeriodNum();
  1249. if ($info['PERIOD_AT'] <= $sentMaxPeriodNum) {
  1250. return static::notice('The number of enrollment periods of this member is less than or equal to the number of online periods', 400);//此会员加入期数小于等于已挂网期数
  1251. }
  1252. if (User::find()->where('ID=:ID AND VERIFIED=1', [':ID' => $uid])->exists()) {
  1253. return static::notice('This member has been authenticated by real name and cannot be deleted', 400);//此会员已实名认证无法删除
  1254. }
  1255. if (User::find()->where('ID=:ID AND SUB_COM_LEADER=1', [':ID' => $uid])->exists()) {
  1256. return static::notice('This member is a branch leader and cannot be deleted', 400);//此会员是分公司领导人无法删除
  1257. }
  1258. if (UserInfo::find()->where('USER_ID=:USER_ID AND (IS_GROUP_LEADER=1 OR IS_SYSTEM_LEADER=1 OR IS_BIND=1 OR IS_TEAM=1)', [':USER_ID' => $uid])->exists()) {
  1259. return static::notice('This member cannot be deleted due to the following conditions: Team Leader / system leader / point binding / point cooperation', 400);//此会员存在以下情况无法删除,团队领导人/体系领导人/点位绑定/点位合作
  1260. }
  1261. if (FlowBonus::findOneAsArray('USER_ID=:USER_ID', [':USER_ID' => $uid], 'ID')) {
  1262. return static::notice('This member has generated a balance flow, which cannot be deleted', 400);//该会员产生过余额流水无法删除
  1263. }
  1264. if (UserMove::findOneAsArray('USER_ID=:USER_ID', [':USER_ID' => $uid], 'ID')) {
  1265. return static::notice('The member cannot be deleted due to network migration', 400);//该会员发生过移网无法删除
  1266. }
  1267. return static::notice($info);
  1268. }
  1269. /**
  1270. * 删除空单会员
  1271. * @return mixed
  1272. * @throws Exception
  1273. * @throws HttpException
  1274. */
  1275. public function actionUserDel()
  1276. {
  1277. $formModel = new AdminAddUserForm();
  1278. $formModel->scenario = 'userDel';
  1279. if ($formModel->load(Yii::$app->request->post(), '') && $result = $formModel->userDel()) {
  1280. $user = User::getBaseInfoFromRedis($result);
  1281. //// Log::adminHandle('删除空单会员' . $user['USER_NAME'], 1, $result, $user['USER_NAME']);
  1282. // Log::adminHandle('删除空单会员' . $user['USER_NAME'], 1);
  1283. return static::notice(Yii::t('ctx', 'successfully'));//删除空单会员完成
  1284. }
  1285. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  1286. }
  1287. /**
  1288. * 复销列表
  1289. * @return mixed
  1290. * @throws HttpException
  1291. */
  1292. public function actionReConsumeList()
  1293. {
  1294. // $filter = $this->filterCondition(ReconsumePool::tableName(), [
  1295. // 'userName' => ['UI.USER_NAME', '='],
  1296. // ]);
  1297. $condition = '';
  1298. $params = [];
  1299. $data = ReconsumePool::lists($condition, $params, [
  1300. 'select' => 'RP.USER_ID,RP.UNUSED_PV,RP.UNUSED_MONTH',
  1301. 'from' => ReconsumePool::tableName() . ' AS RP',
  1302. 'join' => [
  1303. ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'UI.USER_ID=RP.USER_ID']
  1304. ],
  1305. 'orderBy' => 'RP.USER_ID ASC'
  1306. ]);
  1307. foreach ($data['list'] as $key => $value) {
  1308. $userBaseInfo = Cache::getUserBaseInfo($value['USER_ID']);
  1309. $data['list'][$key]['USER_NAME'] = $userBaseInfo['USER_NAME'];
  1310. $data['list'][$key]['REAL_NAME'] = $userBaseInfo['REAL_NAME'];
  1311. $data['list'][$key]['DEC_LV'] = Info::getDecLv($value['USER_ID']);
  1312. $data['list'][$key]['EMP_LV'] = Info::getEmpLv($value['USER_ID']);
  1313. }
  1314. return static::notice($data);
  1315. }
  1316. /**
  1317. * 筛选用户
  1318. * 前端传过来的get参数类似于
  1319. * [
  1320. * 'USER_NAME' => 'like,test',
  1321. * 'CREATED_AT' => '>=,2018-11-10,date'
  1322. * ]
  1323. * @return mixed
  1324. * @throws HttpException
  1325. */
  1326. public function actionFilterUser()
  1327. {
  1328. $filter = $this->filterCondition([
  1329. 'USER_NAME' => 'U.USER_NAME',
  1330. 'REAL_NAME' => 'U.REAL_NAME',
  1331. 'STATUS' => 'U.STATUS',
  1332. 'STATUS_AT' => 'U.STATUS_AT',
  1333. 'STATUS_NAME' => 'U.STATUS',
  1334. 'ALLOW_LOGIN' => 'U.ALLOW_LOGIN',
  1335. 'CREATED_AT' => 'U.CREATED_AT',
  1336. 'USER_CREATED_AT' => 'U.CREATED_AT',
  1337. 'PERIOD_AT' => 'U.PERIOD_AT',
  1338. 'DEC_LV' => 'U.DEC_LV',
  1339. 'DEC_LV_NAME' => 'U.DEC_LV',
  1340. 'DEC_LV_UPDATED_AT' => 'U.DEC_LV_UPDATED_AT',
  1341. 'LAST_DEC_LV' => 'U.LAST_DEC_LV',
  1342. 'LAST_DEC_LV_NAME' => 'U.LAST_DEC_LV',
  1343. 'EMP_LV' => 'U.EMP_LV',
  1344. 'EMP_LV_NAME' => 'U.EMP_LV',
  1345. //'ID_TYPE' => 'U.ID_TYPE',
  1346. 'ID_CARD' => 'U.ID_CARD',
  1347. 'SPOUSE_NAME' => 'U.SPOUSE_NAME',
  1348. 'SPOUSE_IDCARD' => 'U.SPOUSE_IDCARD',
  1349. 'SUB_COM_ID' => 'U.SUB_COM_ID',
  1350. 'SUB_COM_NAME' => 'U.SUB_COM_ID',
  1351. 'MOBILE' => 'U.MOBILE',
  1352. 'TEL' => 'U.TEL',
  1353. 'DEC_DEC_ROLE_ID' => 'UD.DEC_ROLE_ID',
  1354. 'DEC_DEC_ROLE_NAME' => 'UD.DEC_ROLE_ID',
  1355. 'DEC_USER_NAME' => 'UD.USER_NAME',
  1356. 'IS_DEC' => 'U.IS_DEC',
  1357. 'DEC_ROLE_ID' => 'U.DEC_ROLE_ID',
  1358. 'DEC_ROLE_NAME' => 'U.DEC_ROLE_ID',
  1359. 'OPEN_BANK' => 'U.OPEN_BANK',
  1360. 'OPEN_BANK_NAME' => 'U.OPEN_BANK',
  1361. 'BANK_AREA' => [
  1362. 'FIELD' => ['U.BANK_PROVINCE', 'U.BANK_CITY', 'U.BANK_COUNTY'],
  1363. 'BIND' => ['BANK_PROVINCE', 'BANK_CITY', 'BANK_COUNTY'],
  1364. ],
  1365. 'BANK_ADDRESS' => 'U.BANK_ADDRESS',
  1366. 'BANK_NO' => 'U.BANK_NO',
  1367. 'SEX' => 'U.SEX',
  1368. 'NATION' => 'U.NATION',
  1369. 'NATION_NAME' => 'U.NATION',
  1370. 'AREA' => [
  1371. 'FIELD' => ['U.PROVINCE', 'U.CITY', 'U.COUNTY'],
  1372. 'BIND' => ['PROVINCE', 'CITY', 'COUNTY'],
  1373. ],
  1374. 'ADDRESS' => 'U.ADDRESS',
  1375. 'VERIFIED' => 'U.VERIFIED',
  1376. 'VERIFIED_AT' => 'U.VERIFIED_AT',
  1377. 'IS_DIRECT_SELLER' => 'U.IS_DIRECT_SELLER',
  1378. 'PART_FUNC_CLOSED' => 'U.PART_FUNC_CLOSED',
  1379. //'BIRTHDAY' => 'U.BIRTHDAY',
  1380. 'DEC_CLOSED' => 'U.DEC_CLOSED',
  1381. 'NOT_OPERATING' => 'U.NOT_OPERATING',
  1382. ]);
  1383. $condition = $filter['condition'];
  1384. $params = $filter['params'];
  1385. $data = User::lists($condition, $params, [
  1386. 'select' => 'U.*, UD.USER_NAME AS UD_USER_NAME',
  1387. 'from' => User::tableName() . ' AS U',
  1388. 'join' => [
  1389. ['LEFT JOIN', User::tableName() . ' AS UD', 'U.DEC_ID=UD.ID'],
  1390. ],
  1391. 'orderBy' => 'U.CREATED_AT DESC',
  1392. ]);
  1393. return static::notice($data);
  1394. }
  1395. /**
  1396. * 会员级别变动记录
  1397. * @return mixed
  1398. * @throws \yii\base\Exception
  1399. * @throws HttpException
  1400. */
  1401. public function actionDecLevelList()
  1402. {
  1403. $filter = $this->filterCondition([
  1404. 'USER_NAME' => 'CU.USER_NAME',
  1405. 'CREATED_AT' => 'LL.CREATED_AT',
  1406. 'ADMIN_NAME' => 'ADM.ADMIN_NAME',
  1407. ]);
  1408. $condition = $filter['condition'];
  1409. $params = $filter['params'];
  1410. $isSuper = AdminRole::isSuperAdmin(\Yii::$app->getUser()->getUserInfo()['roleId']);
  1411. if (!$isSuper) {
  1412. $adminId = Yii::$app->getUser()->getUserInfo()['id'];
  1413. $adminCountry = AdminCountry::getCountry($adminId);
  1414. $quotedAdminCountry = array_map(function($item) {
  1415. return "'" . addslashes($item) . "'";
  1416. }, $adminCountry);
  1417. $condition .= " AND CU.COUNTRY_ID IN (" . implode(',', $quotedAdminCountry) . ")";
  1418. }
  1419. $listObj = new DecLevelList();
  1420. $data = $listObj->getList(['condition' => $condition, 'params' => $params]);
  1421. return static::notice($data);
  1422. }
  1423. /**
  1424. * 调整会员级别报单级别
  1425. * @return mixed
  1426. * @throws HttpException
  1427. */
  1428. public function actionChangeUserDecLevel()
  1429. {
  1430. if (Yii::$app->request->isPost) {
  1431. return parent::edit(DecLevelLogForm::class, Yii::t('ctx', 'successfully'), 'adminChange', [ // 修改会员级别成功
  1432. 'adminChange',
  1433. ], null, function ($form, $result) {
  1434. //$userName = Info::getUserNameByUserId($result['ID']);
  1435. // Log::adminHandle('后台调整会员级别级别:'.$userName, 1, $result['ID'], $userName);
  1436. });
  1437. }
  1438. }
  1439. /**
  1440. * 调整会员级别报单级别
  1441. * @return mixed
  1442. * @throws HttpException
  1443. */
  1444. public function actionChangeUserDecRole()
  1445. {
  1446. if (Yii::$app->request->isPost) {
  1447. return parent::edit(DecRoleLogForm::class, Yii::t('ctx', 'successfully'), 'adminChange', [//修改报单中心级别成功
  1448. 'adminChange',
  1449. ], null, function ($form, $result) {
  1450. //$userName = Info::getUserNameByUserId($result['ID']);
  1451. // Log::adminHandle('后台调整会员级别级别:'.$userName, 1, $result['ID'], $userName);
  1452. });
  1453. }
  1454. }
  1455. /**
  1456. * 修改会员前台显示聘级
  1457. * @return mixed
  1458. * @throws HttpException
  1459. */
  1460. public function actionChangeShowEmpLevel()
  1461. {
  1462. if (Yii::$app->request->isPost) {
  1463. return parent::edit(ChangeShowEmpLvForm::class, Yii::t('ctx', 'successfully'), 'adminChange', [//修改会员前台显示聘级成功
  1464. 'adminChange',
  1465. ], null, function ($form, $result) {
  1466. //$userName = Info::getUserNameByUserId($result['ID']);
  1467. // Log::adminHandle('后台调整会员级别级别:'.$userName, 1, $result['ID'], $userName);
  1468. });
  1469. }
  1470. }
  1471. /**
  1472. * 注册信息管理
  1473. * @return mixed
  1474. * @throws Exception
  1475. * @throws HttpException
  1476. */
  1477. public function actionRegInfo()
  1478. {
  1479. $filter = $this->filterCondition([
  1480. 'userIds' => 'UI.USER_ID',
  1481. 'regType' => 'UI.REG_TYPE',
  1482. ]);
  1483. $condition = $filter['condition'];
  1484. $params = $filter['params'];
  1485. $condition .= ' AND UI.DELETED=0';
  1486. $data = UserInfo::lists($condition, $params, [
  1487. 'orderBy' => 'UI.CREATED_AT DESC',
  1488. 'from' => UserInfo::tableName() . ' AS UI',
  1489. ]);
  1490. foreach ($data['list'] as $key => $value) {
  1491. $data['list'][$key]['BASE_INFO'] = Info::baseInfoZh($value['USER_ID']);
  1492. $data['list'][$key]['AUDIT_INFO'] = RegInfoAudit::find()->from(RegInfoAudit::tableName() . ' AS RIA')->select('RIA.*,ADM.ADMIN_NAME CREATE_ADMIN_NAME,ADMA.ADMIN_NAME AUDIT_ADMIN_NAME')->where('USER_ID=:USER_ID AND AUDIT_STATUS=:AUDIT_STATUS', [':USER_ID' => $value['USER_ID'], ':AUDIT_STATUS' => \Yii::$app->params['auditStatus']['true']['value']])->join('LEFT JOIN', Admin::tableName() . ' AS ADM', 'ADM.ID=RIA.CREATE_ADMIN')->join('LEFT JOIN', Admin::tableName() . ' AS ADMA', 'ADMA.ID=RIA.AUDIT_ADMIN')->orderBy('AUDITED_AT DESC')->asArray()->one();
  1493. }
  1494. return static::notice($data);
  1495. }
  1496. /**
  1497. * 注册信息管理中提交修改注册信息
  1498. * @return mixed
  1499. * @throws HttpException
  1500. */
  1501. public function actionRegInfoEdit()
  1502. {
  1503. if (Yii::$app->request->isPost) {
  1504. return parent::edit(RegInfoAuditForm::class, 'The registration information modification has been submitted successfully and will take effect after approval', 'editRegInfo', ['editRegInfo'], null, function ($form, $result) {//注册信息修改提交成功,审核后生效
  1505. $user = User::getBaseInfoFromRedis($result['USER_ID']);
  1506. // Log::adminHandle('申请为' . $user['USER_NAME'] . '注册信息修改', 1, $result['USER_ID'], $user['USER_NAME']);
  1507. });
  1508. }
  1509. $allOpenBank = OpenBank::findAllAsArray('STATUS=1');
  1510. return static::notice(['allOpenBank' => $allOpenBank]);
  1511. }
  1512. /**
  1513. * 会员注册信息审核
  1514. * @return mixed
  1515. * @throws Exception
  1516. * @throws HttpException
  1517. */
  1518. public function actionRegInfoAudit()
  1519. {
  1520. $filter = $this->filterCondition([
  1521. 'userIds' => 'UI.USER_ID',
  1522. 'createdAt' => 'RIA.CREATED_AT',
  1523. 'regType' => 'RIA.REG_TYPE',
  1524. 'filterStatus' => 'RIA.AUDIT_STATUS',
  1525. ]);
  1526. $condition = $filter['condition'];
  1527. $params = $filter['params'];
  1528. $data = RegInfoAudit::lists($condition, $params, [
  1529. 'orderBy' => 'RIA.CREATED_AT DESC',
  1530. 'from' => RegInfoAudit::tableName() . ' AS RIA',
  1531. 'join' => [
  1532. ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'RIA.USER_ID=UI.USER_ID'],
  1533. ],
  1534. ]);
  1535. $auditStatus = array_column(\Yii::$app->params['auditStatus'], null, 'value');
  1536. foreach ($data['list'] as $key => $value) {
  1537. $data['list'][$key]['BASE_INFO'] = Info::baseInfoZh($value['USER_ID']);
  1538. $data['list'][$key]['CREATE_ADMIN_NAME'] = Admin::getAdminNameById($value['CREATE_ADMIN']);
  1539. $data['list'][$key]['AUDIT_ADMIN_NAME'] = Admin::getAdminNameById($value['AUDIT_ADMIN']);
  1540. $data['list'][$key]['STATUS_NAME'] = $auditStatus[$value['AUDIT_STATUS']]['label'];
  1541. }
  1542. return static::notice($data);
  1543. }
  1544. /**
  1545. * 会员注册信息添加
  1546. * @return mixed
  1547. * @throws HttpException
  1548. */
  1549. public function actionRegInfoAuditAdd()
  1550. {
  1551. if (Yii::$app->request->isPost) {
  1552. return parent::edit(RegInfoAuditForm::class, Yii::t('ctx', 'successfully'), 'add', ['add'], null, function ($form, $result) {//注册信息录入成功
  1553. $user = User::getBaseInfoFromRedis($result['USER_ID']);
  1554. // Log::adminHandle('申请为' . $user['USER_NAME'] . '注册信息录入', 1, $result['USER_ID'], $user['USER_NAME']);
  1555. });
  1556. }
  1557. }
  1558. /**
  1559. * 会员注册信息添加获取
  1560. * @return mixed
  1561. * @throws HttpException
  1562. */
  1563. public function actionRegInfoAuditAddOpt()
  1564. {
  1565. $allOpenBank = OpenBank::findAllAsArray('STATUS=1');
  1566. return static::notice(['allOpenBank' => $allOpenBank]);
  1567. }
  1568. /**
  1569. * 会员注册信息获取
  1570. * @return mixed
  1571. * @throws Exception
  1572. * @throws HttpException
  1573. */
  1574. public function actionRegInfoAuditGet()
  1575. {
  1576. $id = Yii::$app->request->get('id');
  1577. $regInfo = RegInfoAudit::findOneAsArray('ID=:ID', [':ID' => $id]);
  1578. if (!$regInfo) {
  1579. return static::notice('Data does not exist', 400);//数据不存在
  1580. }
  1581. $regInfo['BASE_INFO'] = Info::baseInfoZh($regInfo['USER_ID']);
  1582. $regInfo['REG_EXPIRES'] = Date::convert($regInfo['REG_EXPIRES']);
  1583. $allOpenBank = OpenBank::findAllAsArray('STATUS=1');
  1584. $companyBank = CompanyBank::findOneAsArray('USER_ID=:USER_ID', [':USER_ID' => $regInfo['USER_ID']]);
  1585. $bank = ['openBank' => null, 'bankAreaSelected' => [], 'bankAddress' => null, 'openName' => null, 'bankNo' => null];
  1586. if ($companyBank) $bank = ['openBank' => $companyBank['OPEN_BANK'], 'bankAreaSelected' => [$companyBank['BANK_PROVINCE'], $companyBank['BANK_CITY'], $companyBank['BANK_COUNTY']], 'bankAddress' => $companyBank['BANK_ADDRESS'], 'openName' => $companyBank['OPEN_NAME'], 'bankNo' => $companyBank['BANK_NO']];
  1587. return static::notice(['form' => ['id' => $regInfo['ID'], 'userId' => $regInfo['USER_ID'], 'baseInfo' => $regInfo['BASE_INFO'], 'type' => $regInfo['REG_TYPE'], 'regName' => $regInfo['REG_NAME'], 'creditCode' => $regInfo['CREDIT_CODE'], 'premises' => $regInfo['PREMISES'], 'legalPerson' => $regInfo['LEGAL_PERSON'], 'regExpires' => $regInfo['REG_EXPIRES'], 'createRemark' => $regInfo['CREATE_REMARK'], 'companyBank' => $bank], 'allOpenBank' => $allOpenBank]);
  1588. }
  1589. /**
  1590. * 会员注册信息修改
  1591. * @return mixed
  1592. * @throws \yii\db\Exception
  1593. * @throws HttpException
  1594. */
  1595. public function actionRegInfoAuditEdit()
  1596. {
  1597. $formModel = new RegInfoAuditForm();
  1598. $formModel->scenario = 'edit';
  1599. if ($formModel->load(Yii::$app->request->post(), '') && $result = $formModel->edit()) {
  1600. $user = User::getBaseInfoFromRedis($result['USER_ID']);
  1601. // Log::adminHandle('修改' . $user['USER_NAME'] . '注册信息录入数据', 1, $result['USER_ID'], $user['USER_NAME']);
  1602. return static::notice(Yii::t('ctx', 'successfully'));//修改注册信息录入数据完成
  1603. }
  1604. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  1605. }
  1606. /**
  1607. * 会员注册信息审核
  1608. * @return mixed
  1609. * @throws \yii\db\Exception
  1610. * @throws HttpException
  1611. */
  1612. public function actionRegInfoAuditAudit()
  1613. {
  1614. $formModel = new RegInfoAuditForm();
  1615. $formModel->scenario = 'audit';
  1616. if ($formModel->load(Yii::$app->request->post(), '') && $result = $formModel->audit()) {
  1617. $user = User::getBaseInfoFromRedis($result['USER_ID']);
  1618. // Log::adminHandle('审核' . $user['USER_NAME'] . '注册信息', 1, $result['USER_ID'], $user['USER_NAME']);
  1619. return static::notice(Yii::t('ctx', 'successfully'));//审核注册信息完成
  1620. }
  1621. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  1622. }
  1623. /**
  1624. * 分页导入excel文件到待导入数据的表中
  1625. * @return mixed
  1626. * @throws HttpException
  1627. */
  1628. public function actionImportRegInfoToExcelTable()
  1629. {
  1630. // 先上传到服务器文件
  1631. if (\Yii::$app->request->isPost) {
  1632. $excelImportId = Yii::$app->request->post('excelImportId');
  1633. $rowCount = Yii::$app->request->post('rowCount');
  1634. $startRow = Yii::$app->request->post('startRow');
  1635. $limit = Yii::$app->request->post('limit', 1000);
  1636. $errorMsg = '';
  1637. try {
  1638. $excel = new \common\helpers\Excel();
  1639. $result = $excel->pageImportDataFromExcel('regInfo', $excelImportId, $rowCount, $startRow, $limit);
  1640. } catch (Exception $e) {
  1641. $result = false;
  1642. $errorMsg = $e->getMessage();
  1643. }
  1644. // 还有数据
  1645. if ($result === 1) {
  1646. return static::notice(['finish' => false]);
  1647. } elseif ($result === 0) {
  1648. return static::notice(['finish' => true]);
  1649. } else {
  1650. return static::notice('发生错误:' . $errorMsg, 400);
  1651. }
  1652. }
  1653. }
  1654. /**
  1655. * 分页把待导入表中的数据导入到真正的数据中
  1656. * @return mixed
  1657. * @throws Exception
  1658. * @throws HttpException
  1659. */
  1660. public function actionImportRegInfo()
  1661. {
  1662. if (\Yii::$app->request->isPost) {
  1663. $excelImportId = Yii::$app->request->post('excelImportId');
  1664. $offset = Yii::$app->request->post('offset');
  1665. $limit = Yii::$app->request->post('limit', 1000);
  1666. $errorMsg = '';
  1667. $excel = new \common\helpers\Excel();
  1668. $result = $excel->pageImportDataFromExcelTable('regInfo', $excelImportId, $offset, $limit);
  1669. // 还有数据
  1670. if ($result === 1) {
  1671. return static::notice(['finish' => false]);
  1672. } elseif ($result === 0) {
  1673. return static::notice(['finish' => true]);
  1674. } else {
  1675. return static::notice('发生错误:' . $errorMsg, 400);
  1676. }
  1677. }
  1678. }
  1679. /**
  1680. * 会员注册信息删除
  1681. * @return mixed
  1682. * @throws \yii\db\Exception
  1683. * @throws HttpException
  1684. */
  1685. public function actionRegInfoAuditDelete()
  1686. {
  1687. $result = static::delete(RegInfoAudit::class, null, function ($selected) {
  1688. RegInfoAuditForm::delete($selected);
  1689. // Log::adminHandle('删除注册信息');
  1690. }, true);
  1691. return $result;
  1692. }
  1693. /**
  1694. * 禁止登录
  1695. * @return mixed
  1696. * @throws HttpException
  1697. */
  1698. public function actionCloseLogin()
  1699. {
  1700. if (Yii::$app->request->isPost) {
  1701. return parent::edit(CloseLoginForm::class, Yii::t('ctx', 'successfully'), 'single', ['single'], null, function ($form, $result) {
  1702. // $appStr = CloseLoginForm::$apps[$form->shopOrBonus];
  1703. // $closeStr = CloseLoginForm::$closeSwitch[$form->isClose];
  1704. // $typeStr = CloseLoginForm::$types[$form->type];
  1705. // $remark = $form->remark;
  1706. // Log::adminHandle('为会员' . $form->userName . $typeStr . $closeStr . $appStr, 1, $result, $form->userName, $remark);
  1707. });
  1708. }
  1709. }
  1710. /**
  1711. * 禁止登陆类型获取
  1712. * @return mixed
  1713. * @throws HttpException
  1714. */
  1715. public function actionCloseLoginGet()
  1716. {
  1717. return static::notice(['types' => CloseLoginForm::$types, 'closeSwitch' => CloseLoginForm::$closeSwitch]);
  1718. }
  1719. /**
  1720. * 关闭地区登录
  1721. * @return mixed
  1722. * @throws HttpException
  1723. */
  1724. public function actionCloseAreaLogin()
  1725. {
  1726. if (Yii::$app->request->isPost) {
  1727. return parent::edit(CloseLoginForm::class, Yii::t('ctx', 'successfully'), 'area', ['area'], null, function ($form, $result) {
  1728. // $appStr = CloseLoginForm::$apps[$form->shopOrBonus];
  1729. // $closeStr = CloseLoginForm::$closeSwitch[$form->isClose];
  1730. // $province = $form->areaSelected[0] ?? '';
  1731. // $city = $form->areaSelected[1] ?? '';
  1732. // $county = $form->areaSelected[2] ?? '';
  1733. // $remark = $form->remark;
  1734. // Log::adminHandle('区域'.$appStr.$closeStr.':' . $province . $city . $county, 1, null, null, $remark);
  1735. });
  1736. }
  1737. return static::notice(['types' => CloseLoginForm::$types, 'closeSwitch' => CloseLoginForm::$closeSwitch]);
  1738. }
  1739. /**
  1740. * 批量登录管理
  1741. * @return mixed
  1742. * @throws HttpException
  1743. */
  1744. public function actionBatchCloseLogin()
  1745. {
  1746. if (Yii::$app->request->isPost) {
  1747. return parent::edit(CloseLoginForm::class, Yii::t('ctx', 'successfully'), 'batch', ['batch'], null, function ($form, $result) {
  1748. /*$appStr = CloseLoginForm::$apps[$form->shopOrBonus];
  1749. $closeStr = CloseLoginForm::$closeSwitch[$form->isClose];
  1750. $remark = $form->remark;
  1751. if (is_array($result)) {
  1752. foreach ($result as $value) {
  1753. // 获取其中一个人的会员编号
  1754. $userName = Info::getUserNameByUserId($value);
  1755. // Log::adminHandle('为会员' . $userName . $closeStr . $appStr, 1, $value, $userName, $remark);
  1756. }
  1757. }*/
  1758. });
  1759. }
  1760. return static::notice(['types' => CloseLoginForm::$types, 'closeSwitch' => CloseLoginForm::$closeSwitch]);
  1761. }
  1762. /**
  1763. * 关闭报单信息获取
  1764. * @return mixed
  1765. * @throws HttpException
  1766. */
  1767. public function actionCloseDecGet()
  1768. {
  1769. return static::notice(['types' => CloseDecForm::$types, 'closeSwitch' => CloseDecForm::$closeSwitch]);
  1770. }
  1771. /**
  1772. * 关闭报单
  1773. * @return mixed
  1774. * @throws HttpException
  1775. */
  1776. public function actionCloseDec()
  1777. {
  1778. if (Yii::$app->request->isPost) {
  1779. return parent::edit(CloseDecForm::class, Yii::t('ctx', 'successfully'), 'single', ['single'], null, function ($form, $result) {
  1780. // $closeStr = CloseDecForm::$closeSwitch[$form->isClose];
  1781. // $typeStr = CloseDecForm::$types[$form->type];
  1782. // $remark = $form->remark;
  1783. // Log::adminHandle('为会员' . $form->userName . $typeStr . $closeStr, 1, $result, $form->userName, $remark);
  1784. });
  1785. }
  1786. }
  1787. /**
  1788. * 批量关闭报单
  1789. * @return mixed
  1790. * @throws HttpException
  1791. */
  1792. public function actionBatchCloseDec()
  1793. {
  1794. if (Yii::$app->request->isPost) {
  1795. return parent::edit(CloseDecForm::class, Yii::t('ctx', 'successfully'), 'batch', ['batch'], null, function ($form, $result) {
  1796. /*$closeStr = CloseDecForm::$closeSwitch[$form->isClose];
  1797. $remark = $form->remark;
  1798. if (is_array($result)) {
  1799. foreach ($result as $value) {
  1800. // 获取其中一个人的会员编号
  1801. $userName = Info::getUserNameByUserId($value);
  1802. // Log::adminHandle('为会员' . $userName . $closeStr, 1, $value, $userName, $remark);
  1803. }
  1804. }*/
  1805. });
  1806. }
  1807. return static::notice(['types' => CloseDecForm::$types, 'closeSwitch' => CloseDecForm::$closeSwitch]);
  1808. }
  1809. /**
  1810. * 按地区关闭报单
  1811. * @return mixed
  1812. * @throws HttpException
  1813. */
  1814. public function actionCloseAreaDec()
  1815. {
  1816. if (Yii::$app->request->isPost) {
  1817. return parent::edit(CloseDecForm::class, Yii::t('ctx', 'successfully'), 'area', ['area'], null, function ($form, $result) {
  1818. // $closeStr = CloseDecForm::$closeSwitch[$form->isClose];
  1819. // $province = $form->areaSelected[0] ?? '';
  1820. // $city = $form->areaSelected[1] ?? '';
  1821. // $county = $form->areaSelected[2] ?? '';
  1822. // $remark = $form->remark;
  1823. // Log::adminHandle('区域'.$closeStr.':' . $province . $city . $county, 1, null, null, $remark);
  1824. });
  1825. }
  1826. return static::notice(['types' => CloseDecForm::$types, 'closeSwitch' => CloseDecForm::$closeSwitch]);
  1827. }
  1828. /**
  1829. * 会员状态管理
  1830. * @return mixed
  1831. * @throws Exception
  1832. * @throws HttpException
  1833. */
  1834. // public function actionStatusAuditList()
  1835. // {
  1836. // $filter = $this->filterCondition([
  1837. // 'userIds' => 'UI.USER_ID',
  1838. // 'filterStatus' => 'USA.AUDIT_STATUS',
  1839. // 'SYSTEM_NAME' => 'UI.SYSTEM_ID',
  1840. // 'ORI_STATUS_NAME' => 'USA.ORI_VALUE',
  1841. // 'STATUS_NAME' => 'USA.STATUS_VALUE',
  1842. // 'PERIOD_NUM' => 'USA.PERIOD_NUM',
  1843. // 'CREATE_REMARK' => 'USA.CREATE_REMARK',
  1844. // 'IS_PERIOD_ADD_T' => 'USA.IS_PERIOD_ADD_T',
  1845. // 'ADD_T_PERIOD_NUM' => 'USA.ADD_T_PERIOD_NUM',
  1846. // 'IS_PERIOD_OPEN' => 'USA.IS_PERIOD_OPEN',
  1847. // 'OPEN_PERIOD_NUM' => 'USA.OPEN_PERIOD_NUM',
  1848. // 'CREATE_ADMIN_NAME' => 'ADM.ADMIN_NAME',
  1849. // 'CREATED_AT' => 'ADM.CREATED_AT',
  1850. // 'AUDIT_ADMIN_NAME' => 'ADMA.ADMIN_NAME',
  1851. // 'AUDITED_AT' => 'ADM.AUDITED_AT',
  1852. // ]);
  1853. // $condition = $filter['condition'];
  1854. // $params = $filter['params'];
  1855. // $listObj = new StatusAuditList();
  1856. // $data = $listObj->getList(['condition' => $condition, 'params' => $params]);
  1857. // return static::notice($data);
  1858. // }
  1859. /**
  1860. * 会员状态管理导出
  1861. * @return mixed
  1862. * @throws \yii\db\Exception
  1863. * @throws HttpException
  1864. */
  1865. public function actionStatusAuditExport()
  1866. {
  1867. $filter = $this->filterCondition([
  1868. 'userIds' => 'UI.USER_ID',
  1869. 'filterStatus' => 'USA.AUDIT_STATUS',
  1870. 'SYSTEM_NAME' => 'UI.SYSTEM_ID',
  1871. 'ORI_STATUS_NAME' => 'USA.ORI_VALUE',
  1872. 'STATUS_NAME' => 'USA.STATUS_VALUE',
  1873. 'PERIOD_NUM' => 'USA.PERIOD_NUM',
  1874. 'CREATE_REMARK' => 'USA.CREATE_REMARK',
  1875. 'IS_PERIOD_ADD_T' => 'USA.IS_PERIOD_ADD_T',
  1876. 'ADD_T_PERIOD_NUM' => 'USA.ADD_T_PERIOD_NUM',
  1877. 'IS_PERIOD_OPEN' => 'USA.IS_PERIOD_OPEN',
  1878. 'OPEN_PERIOD_NUM' => 'USA.OPEN_PERIOD_NUM',
  1879. 'CREATE_ADMIN_NAME' => 'ADM.ADMIN_NAME',
  1880. 'CREATED_AT' => 'ADM.CREATED_AT',
  1881. 'AUDIT_ADMIN_NAME' => 'ADMA.ADMIN_NAME',
  1882. 'AUDITED_AT' => 'ADM.AUDITED_AT',
  1883. ]);
  1884. $form = new UserExportForm();
  1885. $result = $form->run($filter, '会员状态管理');
  1886. if (!$result) {
  1887. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1888. }
  1889. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  1890. }
  1891. /**
  1892. * 申请修改会员状态
  1893. * @return mixed
  1894. * @throws HttpException
  1895. */
  1896. public function actionStatusAuditAdd()
  1897. {
  1898. if (Yii::$app->request->isPost) {
  1899. return parent::edit(UserStatusForm::class, Yii::t('ctx', 'successfully'), 'add', ['add'], null, function ($form, $result) {
  1900. $userInfo = Info::baseInfo($result->USER_ID);
  1901. // Log::adminHandle('申请修改' . $userInfo['USER_NAME'] . '状态为' . Yii::$app->params['userStatus'][$result->STATUS_VALUE]['label'], 1, $result->USER_ID, $userInfo['USER_NAME']);
  1902. });
  1903. }
  1904. }
  1905. /**
  1906. * 获取全部移网类型
  1907. * @return mixed
  1908. * @throws HttpException
  1909. */
  1910. public function actionStatusAuditGetStatuses()
  1911. {
  1912. $statuses = Tool::paramConvert(Yii::$app->params['userStatus']);
  1913. return static::notice(['statuses' => $statuses]);
  1914. }
  1915. /**
  1916. * 获取会员状态数据
  1917. * @return mixed
  1918. * @throws Exception
  1919. * @throws HttpException
  1920. */
  1921. public function actionStatusAuditGet()
  1922. {
  1923. $id = Yii::$app->request->get('id');
  1924. $userStatusAudit = UserStatusAudit::findOneAsArray('ID=:ID', [':ID' => $id]);
  1925. if (!$userStatusAudit) {
  1926. return static::notice('The data does not exist', 400); // 数据不存在
  1927. }
  1928. $userStatusAudit['BASE_INFO'] = Info::baseInfoZh($userStatusAudit['USER_ID']);
  1929. $statuses = Tool::paramConvert(Yii::$app->params['userStatus']);
  1930. return static::notice([
  1931. 'id' => $userStatusAudit['ID'],
  1932. 'baseInfo' => $userStatusAudit['BASE_INFO'],
  1933. 'statusValue' => $userStatusAudit['STATUS_VALUE'],
  1934. 'isPeriodAddT' => $userStatusAudit['IS_PERIOD_ADD_T'] ? true : false,
  1935. 'addTPeriodNum' => $userStatusAudit['ADD_T_PERIOD_NUM'],
  1936. 'isPeriodOpen' => $userStatusAudit['IS_PERIOD_OPEN'] ? true : false,
  1937. 'openPeriodNum' => $userStatusAudit['OPEN_PERIOD_NUM'],
  1938. 'remark' => $userStatusAudit['CREATE_REMARK'],
  1939. ]);
  1940. }
  1941. /**
  1942. * 审核修改会员状态
  1943. * @return mixed
  1944. * @throws Exception
  1945. * @throws \yii\db\Exception
  1946. * @throws HttpException
  1947. */
  1948. public function actionStatusAudit()
  1949. {
  1950. $formModel = new UserStatusForm();
  1951. $formModel->scenario = 'audit';
  1952. if ($formModel->load(Yii::$app->request->post(), '') && $result = $formModel->audit()) {
  1953. $userInfo = Info::baseInfo($result->USER_ID);
  1954. // Log::adminHandle('审核修改' . $userInfo['USER_NAME'] . '状态为' . Yii::$app->params['userStatus'][$result->STATUS_VALUE]['label'], 1, $result->USER_ID, $userInfo['USER_NAME']);
  1955. return static::notice(Yii::t('ctx', 'successfully'));
  1956. }
  1957. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  1958. }
  1959. /**
  1960. * 删除审核修改会员状态
  1961. * @return mixed
  1962. * @throws \yii\db\Exception
  1963. * @throws HttpException
  1964. */
  1965. public function actionStatusAuditDelete()
  1966. {
  1967. $userStatusForm = new UserStatusForm();
  1968. $result = static::delete(UserStatusAudit::class, function ($selected) use ($userStatusForm) {
  1969. $userStatusForm->beforeDelete($selected);
  1970. // Log::adminHandle('删除审核修改会员状态信息');
  1971. }, function ($selected) use ($userStatusForm) {
  1972. $userStatusForm->delete($selected);
  1973. // Log::adminHandle('删除审核修改会员状态信息');
  1974. }, true);
  1975. return $result;
  1976. }
  1977. /**
  1978. * 设置是否运作
  1979. * @return mixed
  1980. * @throws HttpException
  1981. */
  1982. public function actionIsOperating()
  1983. {
  1984. if (Yii::$app->request->isPost) {
  1985. return parent::edit(UserStatusForm::class, Yii::t('ctx', 'successfully'), 'operating', ['operating'], null, function ($form, $result) {
  1986. /*$isOperating = $form->isOperating ? '运作' : '不运作';
  1987. if(is_array($result)){
  1988. foreach ($result as $value){
  1989. // 获取其中一个人的会员编号
  1990. $userName = Info::getUserNameByUserId($value);
  1991. // Log::adminHandle('为会员' . $userName . '会员设置为' . $isOperating, 1, $value, $userName);
  1992. }
  1993. }*/
  1994. });
  1995. }
  1996. }
  1997. /**
  1998. * 团队领导人
  1999. * @return mixed
  2000. * @throws HttpException
  2001. */
  2002. public function actionIsGroup()
  2003. {
  2004. if (Yii::$app->request->isPost) {
  2005. return parent::edit(UserGroupForm::class, Yii::t('ctx', 'successfully'), 'group', ['group'], null, function ($form, $result) {
  2006. $isGroup = $form->isGroup ? '设为团队领导人' : '取消团队领导人';
  2007. if (is_array($result)) {
  2008. foreach ($result as $value) {
  2009. // 获取其中一个人的会员编号
  2010. $userName = Info::getUserNameByUserId($value);
  2011. // Log::adminHandle('为会员' . $userName . $isGroup, 1, $value, $userName);
  2012. }
  2013. }
  2014. });
  2015. }
  2016. }
  2017. /**
  2018. * 报单中心
  2019. * @return mixed
  2020. * @throws HttpException
  2021. */
  2022. public function actionIsDec()
  2023. {
  2024. if (Yii::$app->request->isPost) {
  2025. return parent::edit(UserDecForm::class, Yii::t('ctx', 'successfully'), 'isDec', ['isDec'], null, null);
  2026. }
  2027. }
  2028. /**
  2029. * 工作室
  2030. * @return mixed
  2031. * @throws HttpException
  2032. */
  2033. public function actionIsStudio()
  2034. {
  2035. if (Yii::$app->request->isPost) {
  2036. return parent::edit(UserDecForm::class, Yii::t('ctx', 'successfully'), 'isStudio', ['isStudio'], null, null);
  2037. }
  2038. }
  2039. /**
  2040. * 网络图谱
  2041. * @return mixed
  2042. * @throws HttpException
  2043. */
  2044. public function actionIsAtlas()
  2045. {
  2046. if (Yii::$app->request->isPost) {
  2047. return parent::edit(UserDecForm::class, Yii::t('ctx', 'successfully'), 'isAtlas', ['isAtlas'], null, null);
  2048. }
  2049. }
  2050. /**
  2051. * 会员充值管理显隐设置
  2052. * @return mixed
  2053. * @throws HttpException
  2054. */
  2055. public function actionIsRecharge()
  2056. {
  2057. if (Yii::$app->request->isPost) {
  2058. return parent::edit(UserDecForm::class, Yii::t('ctx', 'successfully'), 'isRecharge', ['isRecharge'], null, null);
  2059. }
  2060. }
  2061. /**
  2062. * 获取企业银行信息
  2063. * @return mixed
  2064. * @throws HttpException
  2065. */
  2066. public function actionCompanyBankGet()
  2067. {
  2068. $id = Yii::$app->request->get('id');
  2069. $userName = Yii::$app->request->get('userName');
  2070. $companyBank = [];
  2071. if ($id) {
  2072. $companyBank = CompanyBank::findOneAsArray('ID=:ID', [':ID' => $id]);
  2073. }
  2074. if ($userName) {
  2075. $userId = Info::getUserIdByUserName($userName);
  2076. if ($userId) $companyBank = CompanyBank::findOneAsArray('USER_ID=:USER_ID', [':USER_ID' => $userId]);
  2077. }
  2078. if ($companyBank) return static::notice(['openBank' => $companyBank['OPEN_BANK'], 'bankAreaSelected' => [$companyBank['BANK_PROVINCE'], $companyBank['BANK_CITY'], $companyBank['BANK_COUNTY']], 'bankAddress' => $companyBank['BANK_ADDRESS'], 'openName' => $companyBank['OPEN_NAME'], 'bankNo' => $companyBank['BANK_NO']]);
  2079. return static::notice(['openBank' => null, 'bankAreaSelected' => [], 'bankAddress' => null, 'openName' => null, 'bankNo' => null]);
  2080. }
  2081. /**
  2082. * 调整会员转账/提现比例
  2083. * @return mixed
  2084. * @throws HttpException
  2085. */
  2086. public function actionChangeTransferProp()
  2087. {
  2088. if (Yii::$app->request->isPost) {
  2089. return parent::edit(UserTransferPropForm::class, Yii::t('ctx', 'successfully'), 'change', ['change'], null, function ($form, $result) {
  2090. /*$remark = $form->remark;
  2091. if (is_array($result)) {
  2092. foreach ($result as $value) {
  2093. // 获取其中一个人的会员编号
  2094. $userName = Info::getUserNameByUserId($value);
  2095. // Log::adminHandle('调整会员'.$userName.'转账/提现比例成功', 1, $value, $userName, $remark);
  2096. }
  2097. }*/
  2098. });
  2099. }
  2100. }
  2101. public function actionStatusCloseGet()
  2102. {
  2103. $users = Status::getCloseUser();
  2104. return $users;
  2105. }
  2106. /**
  2107. * 清空关停会员钱包
  2108. * @return mixed
  2109. * @throws Exception
  2110. * @throws \yii\db\Exception
  2111. * @throws HttpException
  2112. */
  2113. public function actionClearWallet()
  2114. {
  2115. $formModel = new UserStatusForm();
  2116. $formModel->scenario = 'clearWallet';
  2117. if ($formModel->load(Yii::$app->request->post(), '') && $result = $formModel->clearWallet()) {
  2118. /*if (is_array($result)) {
  2119. foreach ($result as $value) {
  2120. // 获取其中一个人的会员编号
  2121. $userName = Info::getUserNameByUserId($value);
  2122. Log::adminHandle('清空关停会员' . $userName . '钱包', 1, $value, $userName);
  2123. }
  2124. }*/
  2125. return static::notice('清空关停会员钱包,影响会员【' . count($result) . '】人');
  2126. }
  2127. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  2128. }
  2129. /**
  2130. * 会员历史年度最高聘级表
  2131. * @return mixed
  2132. * @throws Exception
  2133. * @throws HttpException
  2134. */
  2135. public function actionYearHighestEmpLv()
  2136. {
  2137. $filter = $this->filterCondition([
  2138. 'userIds' => 'UI.USER_ID',
  2139. 'YEAR' => 'YHEL.YEAR',
  2140. 'HIGHEST_EMP_LV_NAME' => 'YHEL.HIGHEST_EMP_LV',
  2141. 'HIGHEST_EMP_LV_PERIOD' => 'YHEL.HIGHEST_EMP_LV_PERIOD',
  2142. ]);
  2143. $condition = $filter['condition'];
  2144. $params = $filter['params'];
  2145. $listObj = new YearHighestEmpLvList();
  2146. $data = $listObj->getList(['condition' => $condition, 'params' => $params]);
  2147. return static::notice($data);
  2148. }
  2149. /**
  2150. * 会员历史年度最高聘级表导出
  2151. * @return mixed
  2152. * @throws \yii\db\Exception
  2153. * @throws HttpException
  2154. */
  2155. public function actionYearHighestEmpLvExport()
  2156. {
  2157. $filter = $this->filterCondition([
  2158. 'userIds' => 'UI.USER_ID',
  2159. 'YEAR' => 'YHEL.YEAR',
  2160. 'HIGHEST_EMP_LV_NAME' => 'YHEL.HIGHEST_EMP_LV',
  2161. 'HIGHEST_EMP_LV_PERIOD' => 'YHEL.HIGHEST_EMP_LV_PERIOD',
  2162. ]);
  2163. $form = new UserExportForm();
  2164. $result = $form->run($filter, '会员历史年度最高聘级表');
  2165. if (!$result) {
  2166. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2167. }
  2168. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  2169. }
  2170. /**
  2171. * 会员现金充值
  2172. * @return mixed
  2173. * @throws \yii\db\Exception
  2174. * @throws HttpException
  2175. */
  2176. public function actionRechargeToUser()
  2177. {
  2178. $formModel = new RechargeForm();
  2179. $formModel->scenario = 'addByAdmin';
  2180. if ($formModel->load(Yii::$app->request->post(), '') && $result = $formModel->recharge()) {
  2181. return static::notice(Yii::t('ctx', 'successfully'));
  2182. }
  2183. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  2184. }
  2185. /**
  2186. * 会员修改密码
  2187. * @return mixed
  2188. * @throws HttpException
  2189. */
  2190. public function actionBaModifyPassword()
  2191. {
  2192. $form = new BaUserBasicForm();
  2193. $form->scenario = 'modifyPassword';
  2194. if(Yii::$app->request->isPost && $form->load(Yii::$app->request->post(), '') && $result = $form->edit()){
  2195. return static::notice(Yii::t('ctx', 'successfully')); // 密码修改成功
  2196. } else {
  2197. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2198. }
  2199. }
  2200. /**
  2201. * 个人资料获取
  2202. * @return mixed
  2203. * @throws HttpException
  2204. */
  2205. public function actionBaProfileGet() {
  2206. $id = Yii::$app->request->get('id');
  2207. $userInfo = BaUser::findOneAsArray('ID=:ID', [':ID' => $id]);
  2208. if (!$userInfo) {
  2209. return static::notice('Data does not exist', 400);//数据不存在
  2210. }
  2211. $data['userInfo'] = [
  2212. 'userId' => $userInfo['ID'],
  2213. 'realName' => $userInfo['REAL_NAME'],
  2214. 'mobile' => $userInfo['MOBILE'],
  2215. ];
  2216. return static::notice($data);
  2217. }
  2218. public function actionBaModifyProfile() {
  2219. $form = new BaUserBasicForm();
  2220. $form->scenario = 'modifyProfile';
  2221. if(Yii::$app->request->isPost && $form->load(Yii::$app->request->post(), '') && $result = $form->modifyProfile()){
  2222. return static::notice(Yii::t('ctx', 'successfully'));//个人资料修改成功
  2223. } else {
  2224. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2225. }
  2226. }
  2227. public function actionBaModifyStatus() {
  2228. $form = new BaUserBasicForm();
  2229. $form->scenario = 'modifyStatus';
  2230. if(Yii::$app->request->isPost && $form->load(Yii::$app->request->post(), '') && $result = $form->modifyStatus()){
  2231. return static::notice(Yii::t('ctx', 'successfully'));//会员状态修改成功
  2232. } else {
  2233. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2234. }
  2235. }
  2236. /**
  2237. * @return mixed
  2238. * @throws \yii\db\Exception
  2239. * @throws HttpException
  2240. */
  2241. public function actionBaIsModifyPasswordStatus() {
  2242. $form = new BaUserBasicForm();
  2243. $form->scenario = 'isModifyPasswordStatus';
  2244. if(Yii::$app->request->isPost && $form->load(Yii::$app->request->post(), '') && $result = $form->isModifyPasswordStatus()){
  2245. return static::notice(Yii::t('ctx', 'successfully'));//状态修改成功
  2246. } else {
  2247. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2248. }
  2249. }
  2250. /**
  2251. * BA会员列表
  2252. * @return mixed
  2253. * @throws Exception
  2254. * @throws \yii\web\HttpException
  2255. */
  2256. public function actionBaUserList() {
  2257. $filter = $this->filterCondition([
  2258. 'USER_NAME' => 'U.USER_NAME',
  2259. 'REAL_NAME' => 'U.REAL_NAME',
  2260. 'STATUS' => 'U.STATUS',
  2261. 'ALLOW_LOGIN' => 'U.ALLOW_LOGIN',
  2262. 'CREATED_AT' => 'U.CREATED_AT',
  2263. 'PERIOD_AT' => 'U.PERIOD_AT',
  2264. 'SPOUSE_NAME' => 'U.SPOUSE_NAME',
  2265. 'MOBILE' => 'U.MOBILE',
  2266. 'TEL' => 'U.TEL',
  2267. 'SEX' => 'U.SEX',
  2268. 'AREA' => [
  2269. 'FIELD' => ['U.PROVINCE', 'U.CITY', 'U.COUNTY'],
  2270. 'BIND' => ['PROVINCE', 'CITY', 'COUNTY'],
  2271. ],
  2272. 'ADDRESS' => 'U.ADDRESS',
  2273. 'ALLOW_TRANSFER' => 'UI.ALLOW_TRANSFER',
  2274. ]);
  2275. $condition = $filter['condition'];
  2276. $params = $filter['params'];
  2277. $condition .= ' AND UI.DELETED=0 ';
  2278. $listObj = new BaUserList();
  2279. $data = $listObj->getList(['condition' => $condition, 'params' => $params]);
  2280. return static::notice($data);
  2281. }
  2282. /**
  2283. * @throws \yii\db\Exception
  2284. * @throws HttpException
  2285. */
  2286. public function actionBaUserListExport() {
  2287. $filter = $this->filterCondition([
  2288. 'USER_NAME' => 'U.USER_NAME',
  2289. 'REAL_NAME' => 'U.REAL_NAME',
  2290. 'STATUS' => 'U.STATUS',
  2291. 'ALLOW_LOGIN' => 'U.ALLOW_LOGIN',
  2292. 'CREATED_AT' => 'U.CREATED_AT',
  2293. 'PERIOD_AT' => 'U.PERIOD_AT',
  2294. 'REC_USER_NAME' => 'RU.USER_NAME',
  2295. 'CON_USER_NAME' => 'CU.USER_NAME',
  2296. 'SPOUSE_NAME' => 'U.SPOUSE_NAME',
  2297. 'SYSTEM_NAME' => 'U.SYSTEM_ID',
  2298. 'MOBILE' => 'U.MOBILE',
  2299. 'TEL' => 'U.TEL',
  2300. 'SEX' => 'U.SEX',
  2301. 'AREA' => [
  2302. 'FIELD' => ['U.PROVINCE', 'U.CITY', 'U.COUNTY'],
  2303. 'BIND' => ['PROVINCE', 'CITY', 'COUNTY'],
  2304. ],
  2305. 'ADDRESS' => 'U.ADDRESS',
  2306. 'ALLOW_TRANSFER' => 'UI.ALLOW_TRANSFER',
  2307. ]);
  2308. $form = new BaUserExportForm();
  2309. $result = $form->run($filter, 'Brand_Ambassador_List');
  2310. if (!$result) {
  2311. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2312. }
  2313. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  2314. }
  2315. /**
  2316. * 会员最高聘级变动记录.
  2317. * @return mixed
  2318. * @throws \yii\base\Exception
  2319. * @throws \yii\web\HttpException
  2320. */
  2321. public function actionChangeHighestEmpLevelList()
  2322. {
  2323. $filter = $this->filterCondition([
  2324. 'USER_NAME' => 'CU.USER_NAME',
  2325. 'CREATED_AT' => 'LL.CREATED_AT',
  2326. 'ADMIN_NAME' => 'ADM.ADMIN_NAME',
  2327. ]);
  2328. $condition = $filter['condition'];
  2329. $params = $filter['params'];
  2330. $listObj = new ChangeHighestEmpLevelList();
  2331. $data = $listObj->getList(['condition' => $condition, 'params' => $params]);
  2332. return static::notice($data);
  2333. }
  2334. /**
  2335. * 调整会员最高聘级.
  2336. * @return mixed
  2337. * @throws \yii\web\HttpException
  2338. */
  2339. public function actionChangeHighestEmpLevel()
  2340. {
  2341. if (Yii::$app->request->isPost) {
  2342. return parent::edit(HighestEmpLevelLogForm::class, Yii::t('ctx', 'successfully'), 'adminChange', ['adminChange',], null, function ($form, $result) {
  2343. });
  2344. }
  2345. return static::notice('无效请求', 400);
  2346. }
  2347. /**
  2348. * 移民记录.
  2349. * @return mixed
  2350. * @throws \yii\base\Exception
  2351. * @throws \yii\web\HttpException
  2352. */
  2353. public function actionImmigrantList()
  2354. {
  2355. $filter = $this->filterCondition([
  2356. 'USER_NAME' => 'CU.USER_NAME',
  2357. 'CREATED_AT' => 'UU.CREATED_AT',
  2358. 'ADMIN_NAME' => 'ADM.ADMIN_NAME',
  2359. ]);
  2360. $condition = $filter['condition'];
  2361. $params = $filter['params'];
  2362. $listObj = new UserImmigrant();
  2363. $data = $listObj->getList(['condition' => $condition, 'params' => $params]);
  2364. return static::notice($data);
  2365. }
  2366. /**
  2367. * 移民.
  2368. * @return mixed
  2369. * @throws \yii\web\HttpException
  2370. */
  2371. public function actionImmigrant()
  2372. {
  2373. // 移民条件检查
  2374. if (Yii::$app->request->isGet) {
  2375. // 会员
  2376. $userId = Info::getUserIdByUserName(Yii::$app->request->get('userName'));
  2377. // 1.是否有进行中的分期订单
  2378. $instalmentOrder = Instalment::findOne(['USER_ID' => $userId]);
  2379. // 订单分期总期数配置
  2380. if ($instalmentOrder) {
  2381. // 分期的总期数
  2382. $instalment = intval(Cache::getSystemConfig()['instalment']['VALUE'] ?? 3);
  2383. // 分期商品的期数不能大于总分期数限制
  2384. if (intval($instalmentOrder['STAGE']) < $instalment) {
  2385. return static::notice(Yii::t('app', 'instalmentOrderInProcess'), 400);
  2386. }
  2387. }
  2388. }
  2389. // 移民
  2390. if (Yii::$app->request->isPost) {
  2391. return parent::edit(ImmigrantForm::class, Yii::t('ctx', 'successfully'), 'userImmigrant', ['userImmigrant'], null, function ($form, $result) {});
  2392. }
  2393. return static::notice(Yii::t('app', 'illegalRequest'), 400);
  2394. }
  2395. }