UserController.php 94 KB

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