UserController.php 94 KB

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