UserController.php 97 KB

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