UserController.php 93 KB

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