UserController.php 95 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528
  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. $adminId = Yii::$app->getUser()->getUserInfo()['id'];
  1138. $adminCountry = AdminCountry::getCountry($adminId);
  1139. $countries = Countries::getFromCache();
  1140. $countries = array_filter($countries, fn($country) => in_array($country['ID'], $adminCountry));
  1141. $data['country'] = array_values($countries);
  1142. $data['userInfo'] = [
  1143. 'userId' => $userInfo['ID'],
  1144. 'nation' => \Yii::$app->params['nation'][$userInfo['NATION']]['name']??'',
  1145. 'realName' => $userInfo['REAL_NAME'],
  1146. 'idCard' => $userInfo['ID_CARD'],
  1147. 'mobile' => $userInfo['MOBILE'],
  1148. 'openBank' => $userInfo['OPEN_BANK'],
  1149. 'bankAddress' => $userInfo['BANK_ADDRESS'],
  1150. 'bankNo' => $userInfo['BANK_NO'],
  1151. 'language' => $userInfo['LANGUAGE_ID'],
  1152. 'country' => $userInfo['COUNTRY_ID'],
  1153. ];
  1154. return static::notice($data);
  1155. }
  1156. public function actionModifyProfile() {
  1157. $form = new UserBasicForm();
  1158. $form->scenario = 'modifyProfile';
  1159. if(Yii::$app->request->isPost && $form->load(Yii::$app->request->post(), '') && $result = $form->modifyProfile()){
  1160. return static::notice(Yii::t('ctx', 'successfully'));//个人资料修改成功
  1161. } else {
  1162. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1163. }
  1164. }
  1165. public function actionModifyStatus() {
  1166. $form = new UserBasicForm();
  1167. $form->scenario = 'modifyStatus';
  1168. if(Yii::$app->request->isPost && $form->load(Yii::$app->request->post(), '') && $result = $form->modifyStatus()){
  1169. return static::notice(Yii::t('ctx', 'successfully'));//会员状态修改成功
  1170. } else {
  1171. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1172. }
  1173. }
  1174. /**
  1175. * @return mixed
  1176. * @throws \yii\db\Exception
  1177. * @throws HttpException
  1178. */
  1179. public function actionIsModifyPasswordStatus() {
  1180. $form = new UserBasicForm();
  1181. $form->scenario = 'isModifyPasswordStatus';
  1182. if(Yii::$app->request->isPost && $form->load(Yii::$app->request->post(), '') && $result = $form->isModifyPasswordStatus()){
  1183. return static::notice(Yii::t('ctx', 'successfully'));//状态修改成功
  1184. } else {
  1185. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1186. }
  1187. }
  1188. /**
  1189. * 分页把待导入表中的数据导入到真正的数据中
  1190. * @return mixed
  1191. * @throws HttpException
  1192. */
  1193. public function actionImportUsersAdd()
  1194. {
  1195. if (\Yii::$app->request->isPost) {
  1196. $excelImportId = Yii::$app->request->post('excelImportId');
  1197. $offset = Yii::$app->request->post('offset');
  1198. $limit = Yii::$app->request->post('limit', 1000);
  1199. $errorMsg = '';
  1200. try {
  1201. $excel = new \common\helpers\Excel();
  1202. $result = $excel->pageImportDataFromExcelTable('addUser', $excelImportId, $offset, $limit);
  1203. } catch (Exception $e) {
  1204. $result = false;
  1205. $errorMsg = $e->getMessage();
  1206. }
  1207. // 还有数据
  1208. if ($result === 1) {
  1209. return static::notice(['finish' => false]);
  1210. } elseif ($result === 0) {
  1211. return static::notice(['finish' => true]);
  1212. } else {
  1213. return static::notice('An error occurred:' . $errorMsg, 400);//发生错误
  1214. }
  1215. }
  1216. }
  1217. /**
  1218. * 判断是否满足删除条件
  1219. * @return mixed
  1220. * @throws HttpException
  1221. */
  1222. public function actionChkDelUser()
  1223. {
  1224. $userName = Yii::$app->request->get('userName');
  1225. if (!$uid = Info::getUserIdByUserName($userName)) {
  1226. return static::notice('user does not exist' . $userName, 400);//用户不存在
  1227. }
  1228. if (UserInfo::findOneAsArray('REC_UID=:REC_UID AND DELETED=0', [':REC_UID' => $uid], 'USER_ID')) {
  1229. return static::notice('This member has developed other members and cannot be deleted', 400);//此会员已开拓其它会员不可以删除
  1230. }
  1231. if (UserInfo::findOneAsArray('CON_UID=:CON_UID AND DELETED=0', [':CON_UID' => $uid], 'USER_ID')) {
  1232. return static::notice('This member has been placed with other members and cannot be deleted', 400);//此会员已安置其它会员不可以删除
  1233. }
  1234. if (User::findOneAsArray('DEC_ID=:DEC_ID AND DELETED=0', [':DEC_ID' => $uid], 'ID')) {
  1235. return static::notice('This member has submitted a bill and other members cannot delete it', 400);//此会员已报单其它会员不可以删除
  1236. }
  1237. if (DecOrder::findOneAsArray('USER_ID=:TO_USER_ID OR TO_USER_ID=:TO_USER_ID', [':TO_USER_ID' => $uid], 'ID')) {
  1238. return static::notice('This member has submitted a bill and cannot be deleted', 400);//此会员已报单不可以删除
  1239. }
  1240. $info = Info::baseInfoWithNet($uid);
  1241. if ($info['REG_FROM'] == 1) {
  1242. return static::notice('This member is not empty and cannot be deleted', 400);//此会员不是空单无法删除
  1243. }
  1244. $sentMaxPeriodNum = Period::sentMaxPeriodNum();
  1245. if ($info['PERIOD_AT'] <= $sentMaxPeriodNum) {
  1246. return static::notice('The number of enrollment periods of this member is less than or equal to the number of online periods', 400);//此会员加入期数小于等于已挂网期数
  1247. }
  1248. if (User::find()->where('ID=:ID AND VERIFIED=1', [':ID' => $uid])->exists()) {
  1249. return static::notice('This member has been authenticated by real name and cannot be deleted', 400);//此会员已实名认证无法删除
  1250. }
  1251. if (User::find()->where('ID=:ID AND SUB_COM_LEADER=1', [':ID' => $uid])->exists()) {
  1252. return static::notice('This member is a branch leader and cannot be deleted', 400);//此会员是分公司领导人无法删除
  1253. }
  1254. 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()) {
  1255. return static::notice('This member cannot be deleted due to the following conditions: Team Leader / system leader / point binding / point cooperation', 400);//此会员存在以下情况无法删除,团队领导人/体系领导人/点位绑定/点位合作
  1256. }
  1257. if (FlowBonus::findOneAsArray('USER_ID=:USER_ID', [':USER_ID' => $uid], 'ID')) {
  1258. return static::notice('This member has generated a balance flow, which cannot be deleted', 400);//该会员产生过余额流水无法删除
  1259. }
  1260. if (UserMove::findOneAsArray('USER_ID=:USER_ID', [':USER_ID' => $uid], 'ID')) {
  1261. return static::notice('The member cannot be deleted due to network migration', 400);//该会员发生过移网无法删除
  1262. }
  1263. return static::notice($info);
  1264. }
  1265. /**
  1266. * 删除空单会员
  1267. * @return mixed
  1268. * @throws Exception
  1269. * @throws HttpException
  1270. */
  1271. public function actionUserDel()
  1272. {
  1273. $formModel = new AdminAddUserForm();
  1274. $formModel->scenario = 'userDel';
  1275. if ($formModel->load(Yii::$app->request->post(), '') && $result = $formModel->userDel()) {
  1276. $user = User::getBaseInfoFromRedis($result);
  1277. //// Log::adminHandle('删除空单会员' . $user['USER_NAME'], 1, $result, $user['USER_NAME']);
  1278. // Log::adminHandle('删除空单会员' . $user['USER_NAME'], 1);
  1279. return static::notice(Yii::t('ctx', 'successfully'));//删除空单会员完成
  1280. }
  1281. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  1282. }
  1283. /**
  1284. * 复销列表
  1285. * @return mixed
  1286. * @throws HttpException
  1287. */
  1288. public function actionReConsumeList()
  1289. {
  1290. // $filter = $this->filterCondition(ReconsumePool::tableName(), [
  1291. // 'userName' => ['UI.USER_NAME', '='],
  1292. // ]);
  1293. $condition = '';
  1294. $params = [];
  1295. $data = ReconsumePool::lists($condition, $params, [
  1296. 'select' => 'RP.USER_ID,RP.UNUSED_PV,RP.UNUSED_MONTH',
  1297. 'from' => ReconsumePool::tableName() . ' AS RP',
  1298. 'join' => [
  1299. ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'UI.USER_ID=RP.USER_ID']
  1300. ],
  1301. 'orderBy' => 'RP.USER_ID ASC'
  1302. ]);
  1303. foreach ($data['list'] as $key => $value) {
  1304. $userBaseInfo = Cache::getUserBaseInfo($value['USER_ID']);
  1305. $data['list'][$key]['USER_NAME'] = $userBaseInfo['USER_NAME'];
  1306. $data['list'][$key]['REAL_NAME'] = $userBaseInfo['REAL_NAME'];
  1307. $data['list'][$key]['DEC_LV'] = Info::getDecLv($value['USER_ID']);
  1308. $data['list'][$key]['EMP_LV'] = Info::getEmpLv($value['USER_ID']);
  1309. }
  1310. return static::notice($data);
  1311. }
  1312. /**
  1313. * 筛选用户
  1314. * 前端传过来的get参数类似于
  1315. * [
  1316. * 'USER_NAME' => 'like,test',
  1317. * 'CREATED_AT' => '>=,2018-11-10,date'
  1318. * ]
  1319. * @return mixed
  1320. * @throws HttpException
  1321. */
  1322. public function actionFilterUser()
  1323. {
  1324. $filter = $this->filterCondition([
  1325. 'USER_NAME' => 'U.USER_NAME',
  1326. 'REAL_NAME' => 'U.REAL_NAME',
  1327. 'STATUS' => 'U.STATUS',
  1328. 'STATUS_AT' => 'U.STATUS_AT',
  1329. 'STATUS_NAME' => 'U.STATUS',
  1330. 'ALLOW_LOGIN' => 'U.ALLOW_LOGIN',
  1331. 'CREATED_AT' => 'U.CREATED_AT',
  1332. 'USER_CREATED_AT' => 'U.CREATED_AT',
  1333. 'PERIOD_AT' => 'U.PERIOD_AT',
  1334. 'DEC_LV' => 'U.DEC_LV',
  1335. 'DEC_LV_NAME' => 'U.DEC_LV',
  1336. 'DEC_LV_UPDATED_AT' => 'U.DEC_LV_UPDATED_AT',
  1337. 'LAST_DEC_LV' => 'U.LAST_DEC_LV',
  1338. 'LAST_DEC_LV_NAME' => 'U.LAST_DEC_LV',
  1339. 'EMP_LV' => 'U.EMP_LV',
  1340. 'EMP_LV_NAME' => 'U.EMP_LV',
  1341. //'ID_TYPE' => 'U.ID_TYPE',
  1342. 'ID_CARD' => 'U.ID_CARD',
  1343. 'SPOUSE_NAME' => 'U.SPOUSE_NAME',
  1344. 'SPOUSE_IDCARD' => 'U.SPOUSE_IDCARD',
  1345. 'SUB_COM_ID' => 'U.SUB_COM_ID',
  1346. 'SUB_COM_NAME' => 'U.SUB_COM_ID',
  1347. 'MOBILE' => 'U.MOBILE',
  1348. 'TEL' => 'U.TEL',
  1349. 'DEC_DEC_ROLE_ID' => 'UD.DEC_ROLE_ID',
  1350. 'DEC_DEC_ROLE_NAME' => 'UD.DEC_ROLE_ID',
  1351. 'DEC_USER_NAME' => 'UD.USER_NAME',
  1352. 'IS_DEC' => 'U.IS_DEC',
  1353. 'DEC_ROLE_ID' => 'U.DEC_ROLE_ID',
  1354. 'DEC_ROLE_NAME' => 'U.DEC_ROLE_ID',
  1355. 'OPEN_BANK' => 'U.OPEN_BANK',
  1356. 'OPEN_BANK_NAME' => 'U.OPEN_BANK',
  1357. 'BANK_AREA' => [
  1358. 'FIELD' => ['U.BANK_PROVINCE', 'U.BANK_CITY', 'U.BANK_COUNTY'],
  1359. 'BIND' => ['BANK_PROVINCE', 'BANK_CITY', 'BANK_COUNTY'],
  1360. ],
  1361. 'BANK_ADDRESS' => 'U.BANK_ADDRESS',
  1362. 'BANK_NO' => 'U.BANK_NO',
  1363. 'SEX' => 'U.SEX',
  1364. 'NATION' => 'U.NATION',
  1365. 'NATION_NAME' => 'U.NATION',
  1366. 'AREA' => [
  1367. 'FIELD' => ['U.PROVINCE', 'U.CITY', 'U.COUNTY'],
  1368. 'BIND' => ['PROVINCE', 'CITY', 'COUNTY'],
  1369. ],
  1370. 'ADDRESS' => 'U.ADDRESS',
  1371. 'VERIFIED' => 'U.VERIFIED',
  1372. 'VERIFIED_AT' => 'U.VERIFIED_AT',
  1373. 'IS_DIRECT_SELLER' => 'U.IS_DIRECT_SELLER',
  1374. 'PART_FUNC_CLOSED' => 'U.PART_FUNC_CLOSED',
  1375. //'BIRTHDAY' => 'U.BIRTHDAY',
  1376. 'DEC_CLOSED' => 'U.DEC_CLOSED',
  1377. 'NOT_OPERATING' => 'U.NOT_OPERATING',
  1378. ]);
  1379. $condition = $filter['condition'];
  1380. $params = $filter['params'];
  1381. $data = User::lists($condition, $params, [
  1382. 'select' => 'U.*, UD.USER_NAME AS UD_USER_NAME',
  1383. 'from' => User::tableName() . ' AS U',
  1384. 'join' => [
  1385. ['LEFT JOIN', User::tableName() . ' AS UD', 'U.DEC_ID=UD.ID'],
  1386. ],
  1387. 'orderBy' => 'U.CREATED_AT DESC',
  1388. ]);
  1389. return static::notice($data);
  1390. }
  1391. /**
  1392. * 会员级别变动记录
  1393. * @return mixed
  1394. * @throws \yii\base\Exception
  1395. * @throws HttpException
  1396. */
  1397. public function actionDecLevelList()
  1398. {
  1399. $filter = $this->filterCondition([
  1400. 'USER_NAME' => 'CU.USER_NAME',
  1401. 'CREATED_AT' => 'LL.CREATED_AT',
  1402. 'ADMIN_NAME' => 'ADM.ADMIN_NAME',
  1403. ]);
  1404. $condition = $filter['condition'];
  1405. $params = $filter['params'];
  1406. $isSuper = AdminRole::isSuperAdmin(\Yii::$app->getUser()->getUserInfo()['roleId']);
  1407. if (!$isSuper) {
  1408. $adminId = Yii::$app->getUser()->getUserInfo()['id'];
  1409. $adminCountry = AdminCountry::getCountry($adminId);
  1410. $quotedAdminCountry = array_map(function($item) {
  1411. return "'" . addslashes($item) . "'";
  1412. }, $adminCountry);
  1413. $condition .= " AND CU.COUNTRY_ID IN (" . implode(',', $quotedAdminCountry) . ")";
  1414. }
  1415. $listObj = new DecLevelList();
  1416. $data = $listObj->getList(['condition' => $condition, 'params' => $params]);
  1417. return static::notice($data);
  1418. }
  1419. /**
  1420. * 调整会员级别报单级别
  1421. * @return mixed
  1422. * @throws HttpException
  1423. */
  1424. public function actionChangeUserDecLevel()
  1425. {
  1426. if (Yii::$app->request->isPost) {
  1427. return parent::edit(DecLevelLogForm::class, Yii::t('ctx', 'successfully'), 'adminChange', [ // 修改会员级别成功
  1428. 'adminChange',
  1429. ], null, function ($form, $result) {
  1430. //$userName = Info::getUserNameByUserId($result['ID']);
  1431. // Log::adminHandle('后台调整会员级别级别:'.$userName, 1, $result['ID'], $userName);
  1432. });
  1433. }
  1434. }
  1435. /**
  1436. * 调整会员级别报单级别
  1437. * @return mixed
  1438. * @throws HttpException
  1439. */
  1440. public function actionChangeUserDecRole()
  1441. {
  1442. if (Yii::$app->request->isPost) {
  1443. return parent::edit(DecRoleLogForm::class, Yii::t('ctx', 'successfully'), 'adminChange', [//修改报单中心级别成功
  1444. 'adminChange',
  1445. ], null, function ($form, $result) {
  1446. //$userName = Info::getUserNameByUserId($result['ID']);
  1447. // Log::adminHandle('后台调整会员级别级别:'.$userName, 1, $result['ID'], $userName);
  1448. });
  1449. }
  1450. }
  1451. /**
  1452. * 修改会员前台显示聘级
  1453. * @return mixed
  1454. * @throws HttpException
  1455. */
  1456. public function actionChangeShowEmpLevel()
  1457. {
  1458. if (Yii::$app->request->isPost) {
  1459. return parent::edit(ChangeShowEmpLvForm::class, Yii::t('ctx', 'successfully'), 'adminChange', [//修改会员前台显示聘级成功
  1460. 'adminChange',
  1461. ], null, function ($form, $result) {
  1462. //$userName = Info::getUserNameByUserId($result['ID']);
  1463. // Log::adminHandle('后台调整会员级别级别:'.$userName, 1, $result['ID'], $userName);
  1464. });
  1465. }
  1466. }
  1467. /**
  1468. * 注册信息管理
  1469. * @return mixed
  1470. * @throws Exception
  1471. * @throws HttpException
  1472. */
  1473. public function actionRegInfo()
  1474. {
  1475. $filter = $this->filterCondition([
  1476. 'userIds' => 'UI.USER_ID',
  1477. 'regType' => 'UI.REG_TYPE',
  1478. ]);
  1479. $condition = $filter['condition'];
  1480. $params = $filter['params'];
  1481. $condition .= ' AND UI.DELETED=0';
  1482. $data = UserInfo::lists($condition, $params, [
  1483. 'orderBy' => 'UI.CREATED_AT DESC',
  1484. 'from' => UserInfo::tableName() . ' AS UI',
  1485. ]);
  1486. foreach ($data['list'] as $key => $value) {
  1487. $data['list'][$key]['BASE_INFO'] = Info::baseInfoZh($value['USER_ID']);
  1488. $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();
  1489. }
  1490. return static::notice($data);
  1491. }
  1492. /**
  1493. * 注册信息管理中提交修改注册信息
  1494. * @return mixed
  1495. * @throws HttpException
  1496. */
  1497. public function actionRegInfoEdit()
  1498. {
  1499. if (Yii::$app->request->isPost) {
  1500. 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) {//注册信息修改提交成功,审核后生效
  1501. $user = User::getBaseInfoFromRedis($result['USER_ID']);
  1502. // Log::adminHandle('申请为' . $user['USER_NAME'] . '注册信息修改', 1, $result['USER_ID'], $user['USER_NAME']);
  1503. });
  1504. }
  1505. $allOpenBank = OpenBank::findAllAsArray('STATUS=1');
  1506. return static::notice(['allOpenBank' => $allOpenBank]);
  1507. }
  1508. /**
  1509. * 会员注册信息审核
  1510. * @return mixed
  1511. * @throws Exception
  1512. * @throws HttpException
  1513. */
  1514. public function actionRegInfoAudit()
  1515. {
  1516. $filter = $this->filterCondition([
  1517. 'userIds' => 'UI.USER_ID',
  1518. 'createdAt' => 'RIA.CREATED_AT',
  1519. 'regType' => 'RIA.REG_TYPE',
  1520. 'filterStatus' => 'RIA.AUDIT_STATUS',
  1521. ]);
  1522. $condition = $filter['condition'];
  1523. $params = $filter['params'];
  1524. $data = RegInfoAudit::lists($condition, $params, [
  1525. 'orderBy' => 'RIA.CREATED_AT DESC',
  1526. 'from' => RegInfoAudit::tableName() . ' AS RIA',
  1527. 'join' => [
  1528. ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'RIA.USER_ID=UI.USER_ID'],
  1529. ],
  1530. ]);
  1531. $auditStatus = array_column(\Yii::$app->params['auditStatus'], null, 'value');
  1532. foreach ($data['list'] as $key => $value) {
  1533. $data['list'][$key]['BASE_INFO'] = Info::baseInfoZh($value['USER_ID']);
  1534. $data['list'][$key]['CREATE_ADMIN_NAME'] = Admin::getAdminNameById($value['CREATE_ADMIN']);
  1535. $data['list'][$key]['AUDIT_ADMIN_NAME'] = Admin::getAdminNameById($value['AUDIT_ADMIN']);
  1536. $data['list'][$key]['STATUS_NAME'] = $auditStatus[$value['AUDIT_STATUS']]['label'];
  1537. }
  1538. return static::notice($data);
  1539. }
  1540. /**
  1541. * 会员注册信息添加
  1542. * @return mixed
  1543. * @throws HttpException
  1544. */
  1545. public function actionRegInfoAuditAdd()
  1546. {
  1547. if (Yii::$app->request->isPost) {
  1548. return parent::edit(RegInfoAuditForm::class, Yii::t('ctx', 'successfully'), 'add', ['add'], null, function ($form, $result) {//注册信息录入成功
  1549. $user = User::getBaseInfoFromRedis($result['USER_ID']);
  1550. // Log::adminHandle('申请为' . $user['USER_NAME'] . '注册信息录入', 1, $result['USER_ID'], $user['USER_NAME']);
  1551. });
  1552. }
  1553. }
  1554. /**
  1555. * 会员注册信息添加获取
  1556. * @return mixed
  1557. * @throws HttpException
  1558. */
  1559. public function actionRegInfoAuditAddOpt()
  1560. {
  1561. $allOpenBank = OpenBank::findAllAsArray('STATUS=1');
  1562. return static::notice(['allOpenBank' => $allOpenBank]);
  1563. }
  1564. /**
  1565. * 会员注册信息获取
  1566. * @return mixed
  1567. * @throws Exception
  1568. * @throws HttpException
  1569. */
  1570. public function actionRegInfoAuditGet()
  1571. {
  1572. $id = Yii::$app->request->get('id');
  1573. $regInfo = RegInfoAudit::findOneAsArray('ID=:ID', [':ID' => $id]);
  1574. if (!$regInfo) {
  1575. return static::notice('Data does not exist', 400);//数据不存在
  1576. }
  1577. $regInfo['BASE_INFO'] = Info::baseInfoZh($regInfo['USER_ID']);
  1578. $regInfo['REG_EXPIRES'] = Date::convert($regInfo['REG_EXPIRES']);
  1579. $allOpenBank = OpenBank::findAllAsArray('STATUS=1');
  1580. $companyBank = CompanyBank::findOneAsArray('USER_ID=:USER_ID', [':USER_ID' => $regInfo['USER_ID']]);
  1581. $bank = ['openBank' => null, 'bankAreaSelected' => [], 'bankAddress' => null, 'openName' => null, 'bankNo' => null];
  1582. 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']];
  1583. 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]);
  1584. }
  1585. /**
  1586. * 会员注册信息修改
  1587. * @return mixed
  1588. * @throws \yii\db\Exception
  1589. * @throws HttpException
  1590. */
  1591. public function actionRegInfoAuditEdit()
  1592. {
  1593. $formModel = new RegInfoAuditForm();
  1594. $formModel->scenario = 'edit';
  1595. if ($formModel->load(Yii::$app->request->post(), '') && $result = $formModel->edit()) {
  1596. $user = User::getBaseInfoFromRedis($result['USER_ID']);
  1597. // Log::adminHandle('修改' . $user['USER_NAME'] . '注册信息录入数据', 1, $result['USER_ID'], $user['USER_NAME']);
  1598. return static::notice(Yii::t('ctx', 'successfully'));//修改注册信息录入数据完成
  1599. }
  1600. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  1601. }
  1602. /**
  1603. * 会员注册信息审核
  1604. * @return mixed
  1605. * @throws \yii\db\Exception
  1606. * @throws HttpException
  1607. */
  1608. public function actionRegInfoAuditAudit()
  1609. {
  1610. $formModel = new RegInfoAuditForm();
  1611. $formModel->scenario = 'audit';
  1612. if ($formModel->load(Yii::$app->request->post(), '') && $result = $formModel->audit()) {
  1613. $user = User::getBaseInfoFromRedis($result['USER_ID']);
  1614. // Log::adminHandle('审核' . $user['USER_NAME'] . '注册信息', 1, $result['USER_ID'], $user['USER_NAME']);
  1615. return static::notice(Yii::t('ctx', 'successfully'));//审核注册信息完成
  1616. }
  1617. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  1618. }
  1619. /**
  1620. * 分页导入excel文件到待导入数据的表中
  1621. * @return mixed
  1622. * @throws HttpException
  1623. */
  1624. public function actionImportRegInfoToExcelTable()
  1625. {
  1626. // 先上传到服务器文件
  1627. if (\Yii::$app->request->isPost) {
  1628. $excelImportId = Yii::$app->request->post('excelImportId');
  1629. $rowCount = Yii::$app->request->post('rowCount');
  1630. $startRow = Yii::$app->request->post('startRow');
  1631. $limit = Yii::$app->request->post('limit', 1000);
  1632. $errorMsg = '';
  1633. try {
  1634. $excel = new \common\helpers\Excel();
  1635. $result = $excel->pageImportDataFromExcel('regInfo', $excelImportId, $rowCount, $startRow, $limit);
  1636. } catch (Exception $e) {
  1637. $result = false;
  1638. $errorMsg = $e->getMessage();
  1639. }
  1640. // 还有数据
  1641. if ($result === 1) {
  1642. return static::notice(['finish' => false]);
  1643. } elseif ($result === 0) {
  1644. return static::notice(['finish' => true]);
  1645. } else {
  1646. return static::notice('发生错误:' . $errorMsg, 400);
  1647. }
  1648. }
  1649. }
  1650. /**
  1651. * 分页把待导入表中的数据导入到真正的数据中
  1652. * @return mixed
  1653. * @throws Exception
  1654. * @throws HttpException
  1655. */
  1656. public function actionImportRegInfo()
  1657. {
  1658. if (\Yii::$app->request->isPost) {
  1659. $excelImportId = Yii::$app->request->post('excelImportId');
  1660. $offset = Yii::$app->request->post('offset');
  1661. $limit = Yii::$app->request->post('limit', 1000);
  1662. $errorMsg = '';
  1663. $excel = new \common\helpers\Excel();
  1664. $result = $excel->pageImportDataFromExcelTable('regInfo', $excelImportId, $offset, $limit);
  1665. // 还有数据
  1666. if ($result === 1) {
  1667. return static::notice(['finish' => false]);
  1668. } elseif ($result === 0) {
  1669. return static::notice(['finish' => true]);
  1670. } else {
  1671. return static::notice('发生错误:' . $errorMsg, 400);
  1672. }
  1673. }
  1674. }
  1675. /**
  1676. * 会员注册信息删除
  1677. * @return mixed
  1678. * @throws \yii\db\Exception
  1679. * @throws HttpException
  1680. */
  1681. public function actionRegInfoAuditDelete()
  1682. {
  1683. $result = static::delete(RegInfoAudit::class, null, function ($selected) {
  1684. RegInfoAuditForm::delete($selected);
  1685. // Log::adminHandle('删除注册信息');
  1686. }, true);
  1687. return $result;
  1688. }
  1689. /**
  1690. * 禁止登录
  1691. * @return mixed
  1692. * @throws HttpException
  1693. */
  1694. public function actionCloseLogin()
  1695. {
  1696. if (Yii::$app->request->isPost) {
  1697. return parent::edit(CloseLoginForm::class, Yii::t('ctx', 'successfully'), 'single', ['single'], null, function ($form, $result) {
  1698. // $appStr = CloseLoginForm::$apps[$form->shopOrBonus];
  1699. // $closeStr = CloseLoginForm::$closeSwitch[$form->isClose];
  1700. // $typeStr = CloseLoginForm::$types[$form->type];
  1701. // $remark = $form->remark;
  1702. // Log::adminHandle('为会员' . $form->userName . $typeStr . $closeStr . $appStr, 1, $result, $form->userName, $remark);
  1703. });
  1704. }
  1705. }
  1706. /**
  1707. * 禁止登陆类型获取
  1708. * @return mixed
  1709. * @throws HttpException
  1710. */
  1711. public function actionCloseLoginGet()
  1712. {
  1713. return static::notice(['types' => CloseLoginForm::$types, 'closeSwitch' => CloseLoginForm::$closeSwitch]);
  1714. }
  1715. /**
  1716. * 关闭地区登录
  1717. * @return mixed
  1718. * @throws HttpException
  1719. */
  1720. public function actionCloseAreaLogin()
  1721. {
  1722. if (Yii::$app->request->isPost) {
  1723. return parent::edit(CloseLoginForm::class, Yii::t('ctx', 'successfully'), 'area', ['area'], null, function ($form, $result) {
  1724. // $appStr = CloseLoginForm::$apps[$form->shopOrBonus];
  1725. // $closeStr = CloseLoginForm::$closeSwitch[$form->isClose];
  1726. // $province = $form->areaSelected[0] ?? '';
  1727. // $city = $form->areaSelected[1] ?? '';
  1728. // $county = $form->areaSelected[2] ?? '';
  1729. // $remark = $form->remark;
  1730. // Log::adminHandle('区域'.$appStr.$closeStr.':' . $province . $city . $county, 1, null, null, $remark);
  1731. });
  1732. }
  1733. return static::notice(['types' => CloseLoginForm::$types, 'closeSwitch' => CloseLoginForm::$closeSwitch]);
  1734. }
  1735. /**
  1736. * 批量登录管理
  1737. * @return mixed
  1738. * @throws HttpException
  1739. */
  1740. public function actionBatchCloseLogin()
  1741. {
  1742. if (Yii::$app->request->isPost) {
  1743. return parent::edit(CloseLoginForm::class, Yii::t('ctx', 'successfully'), 'batch', ['batch'], null, function ($form, $result) {
  1744. /*$appStr = CloseLoginForm::$apps[$form->shopOrBonus];
  1745. $closeStr = CloseLoginForm::$closeSwitch[$form->isClose];
  1746. $remark = $form->remark;
  1747. if (is_array($result)) {
  1748. foreach ($result as $value) {
  1749. // 获取其中一个人的会员编号
  1750. $userName = Info::getUserNameByUserId($value);
  1751. // Log::adminHandle('为会员' . $userName . $closeStr . $appStr, 1, $value, $userName, $remark);
  1752. }
  1753. }*/
  1754. });
  1755. }
  1756. return static::notice(['types' => CloseLoginForm::$types, 'closeSwitch' => CloseLoginForm::$closeSwitch]);
  1757. }
  1758. /**
  1759. * 关闭报单信息获取
  1760. * @return mixed
  1761. * @throws HttpException
  1762. */
  1763. public function actionCloseDecGet()
  1764. {
  1765. return static::notice(['types' => CloseDecForm::$types, 'closeSwitch' => CloseDecForm::$closeSwitch]);
  1766. }
  1767. /**
  1768. * 关闭报单
  1769. * @return mixed
  1770. * @throws HttpException
  1771. */
  1772. public function actionCloseDec()
  1773. {
  1774. if (Yii::$app->request->isPost) {
  1775. return parent::edit(CloseDecForm::class, Yii::t('ctx', 'successfully'), 'single', ['single'], null, function ($form, $result) {
  1776. // $closeStr = CloseDecForm::$closeSwitch[$form->isClose];
  1777. // $typeStr = CloseDecForm::$types[$form->type];
  1778. // $remark = $form->remark;
  1779. // Log::adminHandle('为会员' . $form->userName . $typeStr . $closeStr, 1, $result, $form->userName, $remark);
  1780. });
  1781. }
  1782. }
  1783. /**
  1784. * 批量关闭报单
  1785. * @return mixed
  1786. * @throws HttpException
  1787. */
  1788. public function actionBatchCloseDec()
  1789. {
  1790. if (Yii::$app->request->isPost) {
  1791. return parent::edit(CloseDecForm::class, Yii::t('ctx', 'successfully'), 'batch', ['batch'], null, function ($form, $result) {
  1792. /*$closeStr = CloseDecForm::$closeSwitch[$form->isClose];
  1793. $remark = $form->remark;
  1794. if (is_array($result)) {
  1795. foreach ($result as $value) {
  1796. // 获取其中一个人的会员编号
  1797. $userName = Info::getUserNameByUserId($value);
  1798. // Log::adminHandle('为会员' . $userName . $closeStr, 1, $value, $userName, $remark);
  1799. }
  1800. }*/
  1801. });
  1802. }
  1803. return static::notice(['types' => CloseDecForm::$types, 'closeSwitch' => CloseDecForm::$closeSwitch]);
  1804. }
  1805. /**
  1806. * 按地区关闭报单
  1807. * @return mixed
  1808. * @throws HttpException
  1809. */
  1810. public function actionCloseAreaDec()
  1811. {
  1812. if (Yii::$app->request->isPost) {
  1813. return parent::edit(CloseDecForm::class, Yii::t('ctx', 'successfully'), 'area', ['area'], null, function ($form, $result) {
  1814. // $closeStr = CloseDecForm::$closeSwitch[$form->isClose];
  1815. // $province = $form->areaSelected[0] ?? '';
  1816. // $city = $form->areaSelected[1] ?? '';
  1817. // $county = $form->areaSelected[2] ?? '';
  1818. // $remark = $form->remark;
  1819. // Log::adminHandle('区域'.$closeStr.':' . $province . $city . $county, 1, null, null, $remark);
  1820. });
  1821. }
  1822. return static::notice(['types' => CloseDecForm::$types, 'closeSwitch' => CloseDecForm::$closeSwitch]);
  1823. }
  1824. /**
  1825. * 会员状态管理
  1826. * @return mixed
  1827. * @throws Exception
  1828. * @throws HttpException
  1829. */
  1830. // public function actionStatusAuditList()
  1831. // {
  1832. // $filter = $this->filterCondition([
  1833. // 'userIds' => 'UI.USER_ID',
  1834. // 'filterStatus' => 'USA.AUDIT_STATUS',
  1835. // 'SYSTEM_NAME' => 'UI.SYSTEM_ID',
  1836. // 'ORI_STATUS_NAME' => 'USA.ORI_VALUE',
  1837. // 'STATUS_NAME' => 'USA.STATUS_VALUE',
  1838. // 'PERIOD_NUM' => 'USA.PERIOD_NUM',
  1839. // 'CREATE_REMARK' => 'USA.CREATE_REMARK',
  1840. // 'IS_PERIOD_ADD_T' => 'USA.IS_PERIOD_ADD_T',
  1841. // 'ADD_T_PERIOD_NUM' => 'USA.ADD_T_PERIOD_NUM',
  1842. // 'IS_PERIOD_OPEN' => 'USA.IS_PERIOD_OPEN',
  1843. // 'OPEN_PERIOD_NUM' => 'USA.OPEN_PERIOD_NUM',
  1844. // 'CREATE_ADMIN_NAME' => 'ADM.ADMIN_NAME',
  1845. // 'CREATED_AT' => 'ADM.CREATED_AT',
  1846. // 'AUDIT_ADMIN_NAME' => 'ADMA.ADMIN_NAME',
  1847. // 'AUDITED_AT' => 'ADM.AUDITED_AT',
  1848. // ]);
  1849. // $condition = $filter['condition'];
  1850. // $params = $filter['params'];
  1851. // $listObj = new StatusAuditList();
  1852. // $data = $listObj->getList(['condition' => $condition, 'params' => $params]);
  1853. // return static::notice($data);
  1854. // }
  1855. /**
  1856. * 会员状态管理导出
  1857. * @return mixed
  1858. * @throws \yii\db\Exception
  1859. * @throws HttpException
  1860. */
  1861. public function actionStatusAuditExport()
  1862. {
  1863. $filter = $this->filterCondition([
  1864. 'userIds' => 'UI.USER_ID',
  1865. 'filterStatus' => 'USA.AUDIT_STATUS',
  1866. 'SYSTEM_NAME' => 'UI.SYSTEM_ID',
  1867. 'ORI_STATUS_NAME' => 'USA.ORI_VALUE',
  1868. 'STATUS_NAME' => 'USA.STATUS_VALUE',
  1869. 'PERIOD_NUM' => 'USA.PERIOD_NUM',
  1870. 'CREATE_REMARK' => 'USA.CREATE_REMARK',
  1871. 'IS_PERIOD_ADD_T' => 'USA.IS_PERIOD_ADD_T',
  1872. 'ADD_T_PERIOD_NUM' => 'USA.ADD_T_PERIOD_NUM',
  1873. 'IS_PERIOD_OPEN' => 'USA.IS_PERIOD_OPEN',
  1874. 'OPEN_PERIOD_NUM' => 'USA.OPEN_PERIOD_NUM',
  1875. 'CREATE_ADMIN_NAME' => 'ADM.ADMIN_NAME',
  1876. 'CREATED_AT' => 'ADM.CREATED_AT',
  1877. 'AUDIT_ADMIN_NAME' => 'ADMA.ADMIN_NAME',
  1878. 'AUDITED_AT' => 'ADM.AUDITED_AT',
  1879. ]);
  1880. $form = new UserExportForm();
  1881. $result = $form->run($filter, '会员状态管理');
  1882. if (!$result) {
  1883. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  1884. }
  1885. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  1886. }
  1887. /**
  1888. * 申请修改会员状态
  1889. * @return mixed
  1890. * @throws HttpException
  1891. */
  1892. public function actionStatusAuditAdd()
  1893. {
  1894. if (Yii::$app->request->isPost) {
  1895. return parent::edit(UserStatusForm::class, Yii::t('ctx', 'successfully'), 'add', ['add'], null, function ($form, $result) {
  1896. $userInfo = Info::baseInfo($result->USER_ID);
  1897. // Log::adminHandle('申请修改' . $userInfo['USER_NAME'] . '状态为' . Yii::$app->params['userStatus'][$result->STATUS_VALUE]['label'], 1, $result->USER_ID, $userInfo['USER_NAME']);
  1898. });
  1899. }
  1900. }
  1901. /**
  1902. * 获取全部移网类型
  1903. * @return mixed
  1904. * @throws HttpException
  1905. */
  1906. public function actionStatusAuditGetStatuses()
  1907. {
  1908. $statuses = Tool::paramConvert(Yii::$app->params['userStatus']);
  1909. return static::notice(['statuses' => $statuses]);
  1910. }
  1911. /**
  1912. * 获取会员状态数据
  1913. * @return mixed
  1914. * @throws Exception
  1915. * @throws HttpException
  1916. */
  1917. public function actionStatusAuditGet()
  1918. {
  1919. $id = Yii::$app->request->get('id');
  1920. $userStatusAudit = UserStatusAudit::findOneAsArray('ID=:ID', [':ID' => $id]);
  1921. if (!$userStatusAudit) {
  1922. return static::notice('The data does not exist', 400); // 数据不存在
  1923. }
  1924. $userStatusAudit['BASE_INFO'] = Info::baseInfoZh($userStatusAudit['USER_ID']);
  1925. $statuses = Tool::paramConvert(Yii::$app->params['userStatus']);
  1926. return static::notice([
  1927. 'id' => $userStatusAudit['ID'],
  1928. 'baseInfo' => $userStatusAudit['BASE_INFO'],
  1929. 'statusValue' => $userStatusAudit['STATUS_VALUE'],
  1930. 'isPeriodAddT' => $userStatusAudit['IS_PERIOD_ADD_T'] ? true : false,
  1931. 'addTPeriodNum' => $userStatusAudit['ADD_T_PERIOD_NUM'],
  1932. 'isPeriodOpen' => $userStatusAudit['IS_PERIOD_OPEN'] ? true : false,
  1933. 'openPeriodNum' => $userStatusAudit['OPEN_PERIOD_NUM'],
  1934. 'remark' => $userStatusAudit['CREATE_REMARK'],
  1935. ]);
  1936. }
  1937. /**
  1938. * 审核修改会员状态
  1939. * @return mixed
  1940. * @throws Exception
  1941. * @throws \yii\db\Exception
  1942. * @throws HttpException
  1943. */
  1944. public function actionStatusAudit()
  1945. {
  1946. $formModel = new UserStatusForm();
  1947. $formModel->scenario = 'audit';
  1948. if ($formModel->load(Yii::$app->request->post(), '') && $result = $formModel->audit()) {
  1949. $userInfo = Info::baseInfo($result->USER_ID);
  1950. // Log::adminHandle('审核修改' . $userInfo['USER_NAME'] . '状态为' . Yii::$app->params['userStatus'][$result->STATUS_VALUE]['label'], 1, $result->USER_ID, $userInfo['USER_NAME']);
  1951. return static::notice(Yii::t('ctx', 'successfully'));
  1952. }
  1953. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  1954. }
  1955. /**
  1956. * 删除审核修改会员状态
  1957. * @return mixed
  1958. * @throws \yii\db\Exception
  1959. * @throws HttpException
  1960. */
  1961. public function actionStatusAuditDelete()
  1962. {
  1963. $userStatusForm = new UserStatusForm();
  1964. $result = static::delete(UserStatusAudit::class, function ($selected) use ($userStatusForm) {
  1965. $userStatusForm->beforeDelete($selected);
  1966. // Log::adminHandle('删除审核修改会员状态信息');
  1967. }, function ($selected) use ($userStatusForm) {
  1968. $userStatusForm->delete($selected);
  1969. // Log::adminHandle('删除审核修改会员状态信息');
  1970. }, true);
  1971. return $result;
  1972. }
  1973. /**
  1974. * 设置是否运作
  1975. * @return mixed
  1976. * @throws HttpException
  1977. */
  1978. public function actionIsOperating()
  1979. {
  1980. if (Yii::$app->request->isPost) {
  1981. return parent::edit(UserStatusForm::class, Yii::t('ctx', 'successfully'), 'operating', ['operating'], null, function ($form, $result) {
  1982. /*$isOperating = $form->isOperating ? '运作' : '不运作';
  1983. if(is_array($result)){
  1984. foreach ($result as $value){
  1985. // 获取其中一个人的会员编号
  1986. $userName = Info::getUserNameByUserId($value);
  1987. // Log::adminHandle('为会员' . $userName . '会员设置为' . $isOperating, 1, $value, $userName);
  1988. }
  1989. }*/
  1990. });
  1991. }
  1992. }
  1993. /**
  1994. * 团队领导人
  1995. * @return mixed
  1996. * @throws HttpException
  1997. */
  1998. public function actionIsGroup()
  1999. {
  2000. if (Yii::$app->request->isPost) {
  2001. return parent::edit(UserGroupForm::class, Yii::t('ctx', 'successfully'), 'group', ['group'], null, function ($form, $result) {
  2002. $isGroup = $form->isGroup ? '设为团队领导人' : '取消团队领导人';
  2003. if (is_array($result)) {
  2004. foreach ($result as $value) {
  2005. // 获取其中一个人的会员编号
  2006. $userName = Info::getUserNameByUserId($value);
  2007. // Log::adminHandle('为会员' . $userName . $isGroup, 1, $value, $userName);
  2008. }
  2009. }
  2010. });
  2011. }
  2012. }
  2013. /**
  2014. * 报单中心
  2015. * @return mixed
  2016. * @throws HttpException
  2017. */
  2018. public function actionIsDec()
  2019. {
  2020. if (Yii::$app->request->isPost) {
  2021. return parent::edit(UserDecForm::class, Yii::t('ctx', 'successfully'), 'isDec', ['isDec'], null, null);
  2022. }
  2023. }
  2024. /**
  2025. * 工作室
  2026. * @return mixed
  2027. * @throws HttpException
  2028. */
  2029. public function actionIsStudio()
  2030. {
  2031. if (Yii::$app->request->isPost) {
  2032. return parent::edit(UserDecForm::class, Yii::t('ctx', 'successfully'), 'isStudio', ['isStudio'], null, null);
  2033. }
  2034. }
  2035. /**
  2036. * 网络图谱
  2037. * @return mixed
  2038. * @throws HttpException
  2039. */
  2040. public function actionIsAtlas()
  2041. {
  2042. if (Yii::$app->request->isPost) {
  2043. return parent::edit(UserDecForm::class, Yii::t('ctx', 'successfully'), 'isAtlas', ['isAtlas'], null, null);
  2044. }
  2045. }
  2046. /**
  2047. * 会员充值管理显隐设置
  2048. * @return mixed
  2049. * @throws HttpException
  2050. */
  2051. public function actionIsRecharge()
  2052. {
  2053. if (Yii::$app->request->isPost) {
  2054. return parent::edit(UserDecForm::class, Yii::t('ctx', 'successfully'), 'isRecharge', ['isRecharge'], null, null);
  2055. }
  2056. }
  2057. /**
  2058. * 获取企业银行信息
  2059. * @return mixed
  2060. * @throws HttpException
  2061. */
  2062. public function actionCompanyBankGet()
  2063. {
  2064. $id = Yii::$app->request->get('id');
  2065. $userName = Yii::$app->request->get('userName');
  2066. $companyBank = [];
  2067. if ($id) {
  2068. $companyBank = CompanyBank::findOneAsArray('ID=:ID', [':ID' => $id]);
  2069. }
  2070. if ($userName) {
  2071. $userId = Info::getUserIdByUserName($userName);
  2072. if ($userId) $companyBank = CompanyBank::findOneAsArray('USER_ID=:USER_ID', [':USER_ID' => $userId]);
  2073. }
  2074. 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']]);
  2075. return static::notice(['openBank' => null, 'bankAreaSelected' => [], 'bankAddress' => null, 'openName' => null, 'bankNo' => null]);
  2076. }
  2077. /**
  2078. * 调整会员转账/提现比例
  2079. * @return mixed
  2080. * @throws HttpException
  2081. */
  2082. public function actionChangeTransferProp()
  2083. {
  2084. if (Yii::$app->request->isPost) {
  2085. return parent::edit(UserTransferPropForm::class, Yii::t('ctx', 'successfully'), 'change', ['change'], null, function ($form, $result) {
  2086. /*$remark = $form->remark;
  2087. if (is_array($result)) {
  2088. foreach ($result as $value) {
  2089. // 获取其中一个人的会员编号
  2090. $userName = Info::getUserNameByUserId($value);
  2091. // Log::adminHandle('调整会员'.$userName.'转账/提现比例成功', 1, $value, $userName, $remark);
  2092. }
  2093. }*/
  2094. });
  2095. }
  2096. }
  2097. public function actionStatusCloseGet()
  2098. {
  2099. $users = Status::getCloseUser();
  2100. return $users;
  2101. }
  2102. /**
  2103. * 清空关停会员钱包
  2104. * @return mixed
  2105. * @throws Exception
  2106. * @throws \yii\db\Exception
  2107. * @throws HttpException
  2108. */
  2109. public function actionClearWallet()
  2110. {
  2111. $formModel = new UserStatusForm();
  2112. $formModel->scenario = 'clearWallet';
  2113. if ($formModel->load(Yii::$app->request->post(), '') && $result = $formModel->clearWallet()) {
  2114. /*if (is_array($result)) {
  2115. foreach ($result as $value) {
  2116. // 获取其中一个人的会员编号
  2117. $userName = Info::getUserNameByUserId($value);
  2118. Log::adminHandle('清空关停会员' . $userName . '钱包', 1, $value, $userName);
  2119. }
  2120. }*/
  2121. return static::notice('清空关停会员钱包,影响会员【' . count($result) . '】人');
  2122. }
  2123. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  2124. }
  2125. /**
  2126. * 会员历史年度最高聘级表
  2127. * @return mixed
  2128. * @throws Exception
  2129. * @throws HttpException
  2130. */
  2131. public function actionYearHighestEmpLv()
  2132. {
  2133. $filter = $this->filterCondition([
  2134. 'userIds' => 'UI.USER_ID',
  2135. 'YEAR' => 'YHEL.YEAR',
  2136. 'HIGHEST_EMP_LV_NAME' => 'YHEL.HIGHEST_EMP_LV',
  2137. 'HIGHEST_EMP_LV_PERIOD' => 'YHEL.HIGHEST_EMP_LV_PERIOD',
  2138. ]);
  2139. $condition = $filter['condition'];
  2140. $params = $filter['params'];
  2141. $listObj = new YearHighestEmpLvList();
  2142. $data = $listObj->getList(['condition' => $condition, 'params' => $params]);
  2143. return static::notice($data);
  2144. }
  2145. /**
  2146. * 会员历史年度最高聘级表导出
  2147. * @return mixed
  2148. * @throws \yii\db\Exception
  2149. * @throws HttpException
  2150. */
  2151. public function actionYearHighestEmpLvExport()
  2152. {
  2153. $filter = $this->filterCondition([
  2154. 'userIds' => 'UI.USER_ID',
  2155. 'YEAR' => 'YHEL.YEAR',
  2156. 'HIGHEST_EMP_LV_NAME' => 'YHEL.HIGHEST_EMP_LV',
  2157. 'HIGHEST_EMP_LV_PERIOD' => 'YHEL.HIGHEST_EMP_LV_PERIOD',
  2158. ]);
  2159. $form = new UserExportForm();
  2160. $result = $form->run($filter, '会员历史年度最高聘级表');
  2161. if (!$result) {
  2162. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2163. }
  2164. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  2165. }
  2166. /**
  2167. * 会员现金充值
  2168. * @return mixed
  2169. * @throws \yii\db\Exception
  2170. * @throws HttpException
  2171. */
  2172. public function actionRechargeToUser()
  2173. {
  2174. $formModel = new RechargeForm();
  2175. $formModel->scenario = 'addByAdmin';
  2176. if ($formModel->load(Yii::$app->request->post(), '') && $result = $formModel->recharge()) {
  2177. return static::notice(Yii::t('ctx', 'successfully'));
  2178. }
  2179. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  2180. }
  2181. /**
  2182. * 会员修改密码
  2183. * @return mixed
  2184. * @throws HttpException
  2185. */
  2186. public function actionBaModifyPassword()
  2187. {
  2188. $form = new BaUserBasicForm();
  2189. $form->scenario = 'modifyPassword';
  2190. if(Yii::$app->request->isPost && $form->load(Yii::$app->request->post(), '') && $result = $form->edit()){
  2191. return static::notice(Yii::t('ctx', 'successfully')); // 密码修改成功
  2192. } else {
  2193. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2194. }
  2195. }
  2196. /**
  2197. * 个人资料获取
  2198. * @return mixed
  2199. * @throws HttpException
  2200. */
  2201. public function actionBaProfileGet() {
  2202. $id = Yii::$app->request->get('id');
  2203. $userInfo = BaUser::findOneAsArray('ID=:ID', [':ID' => $id]);
  2204. if (!$userInfo) {
  2205. return static::notice('Data does not exist', 400);//数据不存在
  2206. }
  2207. $data['userInfo'] = [
  2208. 'userId' => $userInfo['ID'],
  2209. 'realName' => $userInfo['REAL_NAME'],
  2210. 'mobile' => $userInfo['MOBILE'],
  2211. ];
  2212. return static::notice($data);
  2213. }
  2214. public function actionBaModifyProfile() {
  2215. $form = new BaUserBasicForm();
  2216. $form->scenario = 'modifyProfile';
  2217. if(Yii::$app->request->isPost && $form->load(Yii::$app->request->post(), '') && $result = $form->modifyProfile()){
  2218. return static::notice(Yii::t('ctx', 'successfully'));//个人资料修改成功
  2219. } else {
  2220. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2221. }
  2222. }
  2223. public function actionBaModifyStatus() {
  2224. $form = new BaUserBasicForm();
  2225. $form->scenario = 'modifyStatus';
  2226. if(Yii::$app->request->isPost && $form->load(Yii::$app->request->post(), '') && $result = $form->modifyStatus()){
  2227. return static::notice(Yii::t('ctx', 'successfully'));//会员状态修改成功
  2228. } else {
  2229. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2230. }
  2231. }
  2232. /**
  2233. * @return mixed
  2234. * @throws \yii\db\Exception
  2235. * @throws HttpException
  2236. */
  2237. public function actionBaIsModifyPasswordStatus() {
  2238. $form = new BaUserBasicForm();
  2239. $form->scenario = 'isModifyPasswordStatus';
  2240. if(Yii::$app->request->isPost && $form->load(Yii::$app->request->post(), '') && $result = $form->isModifyPasswordStatus()){
  2241. return static::notice(Yii::t('ctx', 'successfully'));//状态修改成功
  2242. } else {
  2243. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2244. }
  2245. }
  2246. /**
  2247. * BA会员列表
  2248. * @return mixed
  2249. * @throws Exception
  2250. * @throws \yii\web\HttpException
  2251. */
  2252. public function actionBaUserList() {
  2253. $filter = $this->filterCondition([
  2254. 'USER_NAME' => 'U.USER_NAME',
  2255. 'REAL_NAME' => 'U.REAL_NAME',
  2256. 'STATUS' => 'U.STATUS',
  2257. 'ALLOW_LOGIN' => 'U.ALLOW_LOGIN',
  2258. 'CREATED_AT' => 'U.CREATED_AT',
  2259. 'PERIOD_AT' => 'U.PERIOD_AT',
  2260. 'SPOUSE_NAME' => 'U.SPOUSE_NAME',
  2261. 'MOBILE' => 'U.MOBILE',
  2262. 'TEL' => 'U.TEL',
  2263. 'SEX' => 'U.SEX',
  2264. 'AREA' => [
  2265. 'FIELD' => ['U.PROVINCE', 'U.CITY', 'U.COUNTY'],
  2266. 'BIND' => ['PROVINCE', 'CITY', 'COUNTY'],
  2267. ],
  2268. 'ADDRESS' => 'U.ADDRESS',
  2269. 'ALLOW_TRANSFER' => 'UI.ALLOW_TRANSFER',
  2270. ]);
  2271. $condition = $filter['condition'];
  2272. $params = $filter['params'];
  2273. $condition .= ' AND UI.DELETED=0 ';
  2274. $listObj = new BaUserList();
  2275. $data = $listObj->getList(['condition' => $condition, 'params' => $params]);
  2276. return static::notice($data);
  2277. }
  2278. /**
  2279. * @throws \yii\db\Exception
  2280. * @throws HttpException
  2281. */
  2282. public function actionBaUserListExport() {
  2283. $filter = $this->filterCondition([
  2284. 'USER_NAME' => 'U.USER_NAME',
  2285. 'REAL_NAME' => 'U.REAL_NAME',
  2286. 'STATUS' => 'U.STATUS',
  2287. 'ALLOW_LOGIN' => 'U.ALLOW_LOGIN',
  2288. 'CREATED_AT' => 'U.CREATED_AT',
  2289. 'PERIOD_AT' => 'U.PERIOD_AT',
  2290. 'REC_USER_NAME' => 'RU.USER_NAME',
  2291. 'CON_USER_NAME' => 'CU.USER_NAME',
  2292. 'SPOUSE_NAME' => 'U.SPOUSE_NAME',
  2293. 'SYSTEM_NAME' => 'U.SYSTEM_ID',
  2294. 'MOBILE' => 'U.MOBILE',
  2295. 'TEL' => 'U.TEL',
  2296. 'SEX' => 'U.SEX',
  2297. 'AREA' => [
  2298. 'FIELD' => ['U.PROVINCE', 'U.CITY', 'U.COUNTY'],
  2299. 'BIND' => ['PROVINCE', 'CITY', 'COUNTY'],
  2300. ],
  2301. 'ADDRESS' => 'U.ADDRESS',
  2302. 'ALLOW_TRANSFER' => 'UI.ALLOW_TRANSFER',
  2303. ]);
  2304. $form = new BaUserExportForm();
  2305. $result = $form->run($filter, 'Brand_Ambassador_List');
  2306. if (!$result) {
  2307. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  2308. }
  2309. return static::notice(Yii::t('ctx', 'startExporting')); // 导出开始,请到文件管理-导出文件查看
  2310. }
  2311. /**
  2312. * 会员最高聘级变动记录.
  2313. * @return mixed
  2314. * @throws \yii\base\Exception
  2315. * @throws \yii\web\HttpException
  2316. */
  2317. public function actionChangeHighestEmpLevelList()
  2318. {
  2319. $filter = $this->filterCondition([
  2320. 'USER_NAME' => 'CU.USER_NAME',
  2321. 'CREATED_AT' => 'LL.CREATED_AT',
  2322. 'ADMIN_NAME' => 'ADM.ADMIN_NAME',
  2323. ]);
  2324. $condition = $filter['condition'];
  2325. $params = $filter['params'];
  2326. $listObj = new ChangeHighestEmpLevelList();
  2327. $data = $listObj->getList(['condition' => $condition, 'params' => $params]);
  2328. return static::notice($data);
  2329. }
  2330. /**
  2331. * 调整会员最高聘级.
  2332. * @return mixed
  2333. * @throws \yii\web\HttpException
  2334. */
  2335. public function actionChangeHighestEmpLevel()
  2336. {
  2337. if (Yii::$app->request->isPost) {
  2338. return parent::edit(HighestEmpLevelLogForm::class, Yii::t('ctx', 'successfully'), 'adminChange', ['adminChange',], null, function ($form, $result) {
  2339. });
  2340. }
  2341. return static::notice('无效请求', 400);
  2342. }
  2343. /**
  2344. * 移民记录.
  2345. * @return mixed
  2346. * @throws \yii\base\Exception
  2347. * @throws \yii\web\HttpException
  2348. */
  2349. public function actionImmigrantList()
  2350. {
  2351. $filter = $this->filterCondition([
  2352. 'USER_NAME' => 'CU.USER_NAME',
  2353. 'CREATED_AT' => 'UU.CREATED_AT',
  2354. 'ADMIN_NAME' => 'ADM.ADMIN_NAME',
  2355. ]);
  2356. $condition = $filter['condition'];
  2357. $params = $filter['params'];
  2358. $listObj = new UserImmigrant();
  2359. $data = $listObj->getList(['condition' => $condition, 'params' => $params]);
  2360. return static::notice($data);
  2361. }
  2362. /**
  2363. * 移民.
  2364. * @return mixed
  2365. * @throws \yii\web\HttpException
  2366. */
  2367. public function actionImmigrant()
  2368. {
  2369. // 移民条件检查
  2370. if (Yii::$app->request->isGet) {
  2371. // 会员
  2372. $userId = Info::getUserIdByUserName(Yii::$app->request->get('userName'));
  2373. // 1.是否有进行中的分期订单
  2374. $instalmentOrder = Instalment::findOne(['USER_ID' => $userId]);
  2375. // 订单分期总期数配置
  2376. if ($instalmentOrder) {
  2377. // 分期的总期数
  2378. $instalment = intval(Cache::getSystemConfig()['instalment']['VALUE'] ?? 3);
  2379. // 分期商品的期数不能大于总分期数限制
  2380. if (intval($instalmentOrder['STAGE']) < $instalment) {
  2381. return static::notice(Yii::t('app', 'instalmentOrderInProcess'), 400);
  2382. }
  2383. }
  2384. }
  2385. // 移民
  2386. if (Yii::$app->request->isPost) {
  2387. return parent::edit(ImmigrantForm::class, Yii::t('ctx', 'successfully'), 'userImmigrant', ['userImmigrant'], null, function ($form, $result) {});
  2388. }
  2389. return static::notice(Yii::t('app', 'illegalRequest'), 400);
  2390. }
  2391. }