UserController.php 93 KB

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