UserController.php 97 KB

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