UserController.php 94 KB

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