UserController.php 97 KB

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