BonusController.php 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: leo
  5. * Date: 2018/2/24
  6. * Time: 下午12:48
  7. */
  8. namespace frontendApi\modules\v1\controllers;
  9. use common\helpers\Cache;
  10. use common\helpers\Date;
  11. use common\helpers\Form;
  12. use common\helpers\LoggerTool;
  13. use common\helpers\Tool;
  14. use common\helpers\user\Balance;
  15. use common\helpers\user\Info;
  16. use common\helpers\user\Perf;
  17. use common\models\CalcBonus;
  18. use common\models\CalcBonusBSDefault;
  19. use common\models\CalcBonusBT;
  20. use common\models\CalcBonusFL;
  21. use common\models\Countries;
  22. use common\models\Currency;
  23. use common\models\DealType;
  24. use common\models\DeclarationLevel;
  25. use common\models\EliteLevel;
  26. use common\models\FlowBonus;
  27. use common\models\FlowCF;
  28. use common\models\FlowGaragePoints;
  29. use common\models\FlowLX;
  30. use common\models\FlowReconsumePoints;
  31. use common\models\FlowTourismPoints;
  32. use common\models\FlowVillaPoints;
  33. use common\models\FlowWallet;
  34. use common\models\forms\TransferForm;
  35. use common\models\forms\UploadForm;
  36. use common\models\forms\WithdrawForm;
  37. use common\models\InvoiceAudit;
  38. use common\models\PerfMonth;
  39. use common\models\PerfPeriod;
  40. use common\models\Period;
  41. use common\models\DecRole;
  42. use common\models\EmployLevel;
  43. use common\models\FlowExchangePoints;
  44. use common\models\RegType;
  45. use common\models\ScoreMonth;
  46. use common\models\Transfer;
  47. use common\models\Uploads;
  48. use common\models\UserBonus;
  49. use common\models\UserInfo;
  50. use common\models\UserPerformance;
  51. use common\models\UserWallet;
  52. use common\models\UserRelation;
  53. use common\models\Withdraw;
  54. use frontendApi\modules\v1\models\User;
  55. use Yii;
  56. use yii\web\HttpException;
  57. use yii\web\UploadedFile;
  58. class BonusController extends BaseController {
  59. public $modelClass = CalcBonus::class;
  60. /**
  61. * 我的账户
  62. * @return mixed
  63. * @throws \yii\web\HttpException
  64. */
  65. public function actionIndex() {
  66. $userId = \Yii::$app->user->id;
  67. $data = UserBonus::findUseSlaves()->select('BONUS')->where('USER_ID=:USER_ID', [':USER_ID' => $userId])->asArray()->one();
  68. if (!$data) {
  69. $data = [
  70. 'BONUS' => 0,
  71. ];
  72. }
  73. $data['CASH'] = 0;
  74. $cashWallet = UserWallet::findOneAsArray('USER_ID=:USER_ID', [':USER_ID'=>$userId], 'CASH');
  75. if($cashWallet){
  76. $data['CASH'] = $cashWallet['CASH'];
  77. }
  78. $user = User::getEnCodeInfo($userId);
  79. // 账户币种
  80. $country = Countries::getById($user['COUNTRY_ID']);
  81. $currency = Currency::getById($country['LOCAL_CURRENCY_ID']);
  82. // 绩效奖金
  83. $userPerformance = UserPerformance::getAmountByUserId($userId);
  84. $data['userPerformanceBonus'] = $userPerformance['AMOUNTS'] ?? 0;
  85. $wallet[] = ['walletType' => 'bonus', 'walletName' => Yii::t('app', 'memberBonus'), 'amount' => Tool::formatPrice($data['BONUS'])];//会员奖金
  86. $wallet[] = ['walletType' => 'cash', 'walletName' => Yii::t('app', 'memberEcoin'), 'amount' => Tool::formatPrice($data['CASH']), 'coin' => $currency['CODE']];//会员余额
  87. $wallet[] = ['walletType' => 'userPerformanceBonus', 'walletName' => Yii::t('app', 'userPerformanceBonus'), 'amount' => Tool::formatPrice($data['userPerformanceBonus']), 'coin' => $currency['CODE']];//绩效奖金
  88. $dealSwitch = isset(Cache::getSystemConfig()['dealSwitch']) ? Cache::getSystemConfig()['dealSwitch']['VALUE'] : '';
  89. return static::notice(['wallet' => $wallet,'dealSwitch'=>$dealSwitch]);
  90. }
  91. /**
  92. * 团队查询
  93. * @return mixed
  94. * @throws \yii\web\HttpException
  95. */
  96. public function actionTeams() {
  97. $userId = \Yii::$app->user->id;
  98. $period = Period::instance();
  99. // 查询最新一期未挂网期数
  100. $periodNum = $period->getTeamsPeriodNum();
  101. $month = $period->getTeamsYearMonth($periodNum);
  102. $periodData = Period::getInfoByPeriodNum($periodNum);
  103. // 判断此业绩期是否已经计算完成
  104. if ($periodData['IS_PREPARE'] != 4) {
  105. return static::notice(['user' => [],'team'=>[]]);
  106. }
  107. $userInfo = User::getEnCodeInfo($userId);
  108. $data = PerfMonth::fetchMonthPerf($month, $userId);
  109. $user[0] = [
  110. 'number' => $userInfo['USER_NAME'],
  111. 'name' => $userInfo['REAL_NAME'],
  112. 'user_perf' => 0, // 个人业绩
  113. 'team_perf' => 0, // 团队新增累计业绩
  114. 'total_perf' => 0, // 合计业绩
  115. 'perf_status' => '0', // 0 未达标 1为已达标
  116. 'perf_status_name' => 'Fail',
  117. ];
  118. if (!empty($data)) {
  119. $userCheck = PerfMonth::checkStatus($data['PV_PCS'] + $data['PV_PSS']);
  120. $user[0]['user_perf'] = $data['PV_PCS'];
  121. $user[0]['team_perf'] = $data['PV_PSS'];
  122. $user[0]['total_perf'] = $data['PV_PCS']+$data['PV_PSS'];
  123. $user[0]['perf_status'] = $userCheck ? '1' : $user[0]['perf_status'];
  124. $user[0]['perf_status_name'] = $userCheck ? 'Pass' : $user[0]['perf_status_name'];
  125. }
  126. $teamInfo = [];
  127. $calcAt = PerfMonth::find()->select(['CREATED_AT'])->where('CALC_MONTH=:CALC_MONTH', ['CALC_MONTH'=>$month])->asArray()->one();
  128. if(!$calcAt){
  129. $periodStartTime = $period->nowPeriodArr['START_TIME'];
  130. return static::notice(['user' => $user,'team'=>[],'calcAt' => $periodStartTime]);
  131. }
  132. // 查询此用户的推荐(开拓)团队一级信息
  133. $relation = UserRelation::getChildrenWithDeepAndLayer($userId, 1, 1, $periodNum);
  134. $userStatusFlag = false;
  135. if ($relation) {
  136. // 循环一级开拓用户
  137. foreach($relation as $k=>$v) {
  138. // 获取此用户预计算月业绩
  139. $relationPerf = PerfMonth::fetchMonthPerf($month, $v['USER_ID']);
  140. if (empty($relationPerf)) {
  141. $relationPerf['PV_PCS'] = 0;
  142. $relationPerf['PV_PSS'] = 0;
  143. }
  144. $relationCheck = PerfMonth::checkStatus($relationPerf['PV_PCS']+$relationPerf['PV_PSS']);
  145. $teamInfo[]['perf_status'] = $relationCheck ? '1' : '0';
  146. if ($relationCheck) {
  147. $userStatusFlag = true; // 只要有一个达标,则个人就达标
  148. $teamInfo[$k]['number'] = $v['USER_NAME'];
  149. $teamInfo[$k]['name'] = $v['REAL_NAME'];
  150. $teamInfo[$k]['user_perf'] = $relationPerf['PV_PCS'];
  151. $teamInfo[$k]['team_perf'] = $relationPerf['PV_PSS'];
  152. $teamInfo[$k]['total_perf'] = $relationPerf['PV_PCS']+$relationPerf['PV_PSS'];
  153. $teamInfo[$k]['perf_status'] = '1';
  154. $teamInfo[$k]['perf_status_name'] = 'Pass';
  155. } else {
  156. $teamInfo[$k]['number'] = $v['USER_NAME'];
  157. $teamInfo[$k]['name'] = $v['REAL_NAME'];
  158. $teamInfo[$k]['user_perf'] = $relationPerf['PV_PCS'];
  159. $teamInfo[$k]['team_perf'] = $relationPerf['PV_PSS'];
  160. $teamInfo[$k]['total_perf'] = $relationPerf['PV_PCS']+$relationPerf['PV_PSS'];
  161. $teamInfo[$k]['perf_status'] = '0';
  162. $teamInfo[$k]['perf_status_name'] = 'Fail';
  163. }
  164. }
  165. }
  166. if ($userStatusFlag === true) {
  167. $user[0]['perf_status'] = '1';
  168. $user[0]['perf_status_name'] = 'Pass';
  169. }
  170. return static::notice(['user' => $user,'team'=>$teamInfo,'calcAt' => $calcAt['CREATED_AT']]);
  171. }
  172. /**
  173. * 交易记录
  174. * @return mixed
  175. * @throws \yii\web\HttpException
  176. */
  177. public function actionWalletFlow(){
  178. $walletType = \Yii::$app->request->get('walletType');
  179. if(!in_array($walletType,['bonus', 'cash', 'userPerformanceBonus'])) {
  180. return static::notice('walletType error',400);
  181. }
  182. $dealType = \Yii::$app->request->get('dealType');
  183. $createAt = \Yii::$app->request->get('createAt');
  184. $remark = \Yii::$app->request->get('remark');
  185. // 获取可以查看几期流水
  186. $showFlowPeriodNum = Cache::getSystemConfig()['showFlowPeriodNum']['VALUE'];
  187. $periodArr = Period::getNearlyPeriodNum($showFlowPeriodNum);
  188. $condition = ' AND USER_ID=:USER_ID AND PERIOD_NUM>=:PERIOD_NUM_MIN AND PERIOD_NUM<=:PERIOD_NUM_MAX';
  189. $params = [':USER_ID' => \Yii::$app->user->id,':PERIOD_NUM_MIN' => min($periodArr), ':PERIOD_NUM_MAX'=> max($periodArr)];
  190. if($dealType){
  191. if($dealType==1){//增加
  192. $condition.=' AND IS_INCR=1 AND DEAL_TYPE_IS_PRESET=0';
  193. }elseif ($dealType==2){//扣除
  194. $condition.=' AND IS_INCR=0 AND DEAL_TYPE_IS_PRESET=0';
  195. }else if ($walletType != 'cash') {
  196. $condition.=' AND DEAL_TYPE_ID=:DEAL_TYPE';
  197. $params[':DEAL_TYPE'] = $dealType;
  198. }
  199. }
  200. if ($createAt) {
  201. $createAtStart = $createAt[0] ?? '';
  202. $createAtEnd = $createAt[1] ?? '';
  203. if ($createAtStart) {
  204. $condition .= " AND CREATED_AT>:CREATED_START";
  205. $params[':CREATED_START'] = Date::utcToTime($createAtStart);
  206. }
  207. if ($createAtEnd) {
  208. $condition .= " AND CREATED_AT<:CREATED_END";
  209. $params[':CREATED_END'] = Date::utcToTime($createAtEnd)+86399;
  210. }
  211. }
  212. if($remark){
  213. $condition .= " AND REMARK LIKE :REMARK";
  214. $params[':REMARK'] = '%'.$remark.'%';
  215. }
  216. $data = [];
  217. $dealLists=[];
  218. $dealTypes=[];
  219. if($walletType == 'bonus') {
  220. $dealLists = FlowBonus::find()->groupBy('DEAL_TYPE_ID')->select('DEAL_TYPE_ID')->where('USER_ID=:USER_ID',[':USER_ID'=>\Yii::$app->user->id])->asArray()->all();
  221. $data = FlowBonus::lists($condition, $params, [
  222. 'useSlaves' => true,
  223. 'select' => 'AMOUNT,TOTAL,IS_INCR,REMARK,REMARK_IS_SHOW,PERIOD_NUM,CALC_MONTH,CREATED_AT,DEAL_TYPE_ID,DEAL_TYPE_IS_PRESET',
  224. 'orderBy' => 'CREATED_AT DESC,SORT DESC',
  225. ]);
  226. }elseif ($walletType == 'cash'){
  227. $data = FlowWallet::lists($condition, $params, [
  228. 'select' => 'AMOUNT,TOTAL,IS_INCR,REMARK,PERIOD_NUM,CALC_MONTH,CREATED_AT',
  229. 'orderBy' => 'CREATED_AT DESC',
  230. ]);
  231. }else if ($walletType == 'userPerformanceBonus') {
  232. $condition = ' AND USER_ID=:USER_ID AND STATUS_ID<20 AND AMOUNTS>0';
  233. $params = [':USER_ID' => \Yii::$app->user->id];
  234. $data = UserPerformance::lists($condition, $params, [
  235. 'select' => 'ID,USER_ID,AMOUNTS,ORIGINAL,EXPIRED_AT',
  236. 'orderBy' => 'EXPIRED_AT ASC, CREATED_AT ASC',
  237. ]);
  238. } else {
  239. return static::notice('walletType error',400);
  240. }
  241. if($data && $walletType == 'bonus') {
  242. foreach ($data['list'] as $key => $value) {
  243. if ($value['DEAL_TYPE_IS_PRESET'] == 0) {
  244. $data['list'][$key]['DEAL_TYPE_NAME'] = $value['AMOUNT'] > 0 ? Yii::t('app', 'increase') : Yii::t('app', 'reduce');
  245. } else {
  246. $data['list'][$key]['DEAL_TYPE_NAME'] = DealType::getAllTypesForShow()[$value['DEAL_TYPE_ID']]['TYPE_NAME'] ?? '';
  247. }
  248. if ($value['REMARK_IS_SHOW'] == 0) $data['list'][$key]['REMARK'] = '';
  249. }
  250. }
  251. if ($dealLists && $walletType != 'userPerformanceBonus') {
  252. foreach ($dealLists as $key=>$value){
  253. if(!$value['DEAL_TYPE_ID']) continue;
  254. $dealType = DealType::getAllTypesForShow()[$value['DEAL_TYPE_ID']];
  255. if($dealType['IS_PRESET']==0){
  256. $dealTypes['1'] = Yii::t('app', 'increase');// 增加
  257. $dealTypes['2'] = Yii::t('app', 'reduce');// 扣除
  258. }else{
  259. $dealLists[$key]['DEAL_TYPE_NAME'] = $dealType['TYPE_NAME']??'';
  260. $dealTypes[$value['DEAL_TYPE_ID']] = $dealLists[$key]['DEAL_TYPE_NAME'];
  261. }
  262. }
  263. }
  264. $data['dealTypes'] = $dealTypes;
  265. unset($dealTypes);
  266. return static::notice($data);
  267. }
  268. /**
  269. * 最新奖金
  270. * @return mixed
  271. * @throws \yii\db\Exception
  272. * @throws \yii\web\HttpException
  273. */
  274. public function actionNew(){
  275. if(!$periodNum = \Yii::$app->request->get('periodNum')) {
  276. $periodNum = Period::sentMaxPeriodNum();
  277. }
  278. //是否近期期数
  279. $showFlowPeriodNum = Cache::getSystemConfig()['showFlowPeriodNum']['VALUE'];
  280. $periodArr = Period::getNearlySendPeriodNum($showFlowPeriodNum);
  281. if(!in_array($periodNum,$periodArr)) {
  282. return static::notice(Yii::t('app', 'cannotViewThisPeriod'), 400);
  283. }
  284. // 查询奖金
  285. $data = User::find()
  286. ->from(User::tableName().' AS U')
  287. ->join('LEFT JOIN', CalcBonus::tableName() . ' AS B','B.USER_ID = U.ID')
  288. ->select('U.ID AS USER_ID, U.USER_NAME, U.LAST_DEC_LV, B.LAST_EMP_LV, B.LAST_ELITE_LV, B.IS_ACTIVE, B.BONUS_E, B.BONUS_PE, B.BONUS_SE, B.BONUS_LB, B.BONUS_ST, B.BONUS_WB, B.BONUS_CAR, B.BONUS_TOTAL, B.BONUS_PB')
  289. ->where('USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM', [':USER_ID' => \Yii::$app->user->id,':PERIOD_NUM'=>$periodNum])
  290. ->asArray()
  291. ->one();
  292. $result = [
  293. 'userName' => $data['USER_NAME'],
  294. 'period' => $periodNum,
  295. 'decLevel' => Cache::getDecLevelConfig()[($data['LAST_DEC_LV'] ?: DeclarationLevel::getDefaultLevelId())]['LEVEL_NAME'],
  296. 'empLevel' => Cache::getEmpLevelConfig()[($data['LAST_EMP_LV'] ?: EmployLevel::getDefaultLevelId())]['LEVEL_NAME'],
  297. 'eliteLevel' => Cache::getEliteLevelConfig()[($data['LAST_ELITE_LV'] ?: EliteLevel::getDefaultLevelId())]['LEVEL_NAME'],
  298. 'isActive' => $data['IS_ACTIVE'] ?? 0,
  299. 'eliteBonus' => Tool::formatPrice($data['BONUS_E']),
  300. 'proEliteBonus' => Tool::formatPrice($data['BONUS_PE']),
  301. 'superEliteBonus' => Tool::formatPrice($data['BONUS_SE']),
  302. 'leaderShipBonus' => Tool::formatPrice($data['BONUS_LB']),
  303. 'stockistBonus' => Tool::formatPrice($data['BONUS_ST']),
  304. 'welcomeBonus' => Tool::formatPrice($data['BONUS_WB']),
  305. 'carBonus' => Tool::formatPrice($data['BONUS_CAR']),
  306. 'totalBonus' => Tool::formatPrice($data['BONUS_TOTAL']),
  307. 'userPerformanceBonus' => Tool::formatPrice($data['BONUS_PB']),
  308. ];
  309. return static::notice($result);
  310. }
  311. /**
  312. * 往期奖金
  313. * @return mixed
  314. * @throws \yii\web\HttpException
  315. */
  316. public function actionOther() {
  317. //获取可以查看几期奖金
  318. $showBonusPeriodNum = Cache::getSystemConfig()['showBonusPeriodNum']['VALUE'];
  319. $calcBonus = CalcBonus::find()->where('USER_ID=:USER_ID AND IS_SENT=1', [':USER_ID' => \Yii::$app->user->id])
  320. ->select('PERIOD_NUM,CALC_MONTH,LAST_DEC_LV,LAST_EMP_LV,LAST_ELITE_LV,BONUS_TOTAL,BONUS_E,BONUS_PE,BONUS_SE,BONUS_LB,BONUS_ST,BONUS_WB,BONUS_CAR,BONUS_PB')
  321. ->limit($showBonusPeriodNum)
  322. ->orderBy('PERIOD_NUM DESC')
  323. ->asArray()
  324. ->all();
  325. $result = [];
  326. foreach ($calcBonus as $data) {
  327. $result[] = [
  328. 'period' => $data['PERIOD_NUM'],
  329. 'eliteBonus' => Tool::formatPrice($data['BONUS_E']),
  330. 'proEliteBonus' => Tool::formatPrice($data['BONUS_PE']),
  331. 'superEliteBonus' => Tool::formatPrice($data['BONUS_SE']),
  332. 'leaderShipBonus' => Tool::formatPrice($data['BONUS_LB']),
  333. 'stockistBonus' => Tool::formatPrice($data['BONUS_ST']),
  334. 'welcomeBonus' => Tool::formatPrice($data['BONUS_WB']),
  335. 'carBonus' => Tool::formatPrice($data['BONUS_CAR']),
  336. 'totalBonus' => Tool::formatPrice($data['BONUS_TOTAL']),
  337. 'userPerformanceBonus' => Tool::formatPrice($data['BONUS_PB']),
  338. ];
  339. }
  340. // 奖金明细开关控制(0 只显示总奖金 1 全部显示)
  341. $flowBonusSwitch = Cache::getSystemConfig()['flowBonusSwitch']['VALUE'] ?? 0;
  342. return static::notice(['tableData' => $result, 'flowBonusSwitch' => $flowBonusSwitch]);
  343. }
  344. /**
  345. * 历史累积奖金
  346. * @return mixed
  347. * @throws \yii\web\HttpException
  348. */
  349. public function actionHistoricalCumulativeBonus()
  350. {
  351. $calcBonus = CalcBonus::find()->where('USER_ID=:USER_ID AND IS_SENT=1', [':USER_ID' => \Yii::$app->user->id])
  352. ->select([
  353. 'IFNULL(SUM(BONUS_E), 0.00) AS BONUS_E',
  354. 'IFNULL(SUM(BONUS_PE), 0.00) AS BONUS_PE',
  355. 'IFNULL(SUM(BONUS_SE), 0.00) AS BONUS_SE',
  356. 'IFNULL(SUM(BONUS_ST), 0.00) AS BONUS_ST',
  357. 'IFNULL(SUM(BONUS_LB), 0.00) AS BONUS_LB',
  358. 'IFNULL(SUM(BONUS_WB), 0.00) AS BONUS_WB',
  359. 'IFNULL(SUM(BONUS_CAR), 0.00) AS BONUS_CAR',
  360. 'IFNULL(SUM(BONUS_PB), 0.00) AS BONUS_PB',
  361. ])
  362. ->asArray()
  363. ->one();
  364. $data = [
  365. ['name' => 'eliteBonus', 'bonus' => $calcBonus['BONUS_E'] ?? '0'],
  366. ['name' => 'proEliteBonus', 'bonus' => $calcBonus['BONUS_PE'] ?? '0'],
  367. ['name' => 'superEliteBonus', 'bonus' => $calcBonus['BONUS_SE'] ?? '0'],
  368. ['name' => 'stockistBonus', 'bonus' => $calcBonus['BONUS_ST'] ?? '0'],
  369. ['name' => 'leaderShipBonus', 'bonus' => $calcBonus['BONUS_LB'] ?? '0'],
  370. ['name' => 'welcomeBonus', 'bonus' => $calcBonus['BONUS_WB'] ?? '0'],
  371. ['name' => 'carBonus', 'bonus' => $calcBonus['BONUS_CAR'] ?? '0'],
  372. ['name' => 'userPerformanceBonus', 'bonus' => $calcBonus['BONUS_PB'] ?? '0'],
  373. ];
  374. return static::notice(['tableData' => $data]);
  375. }
  376. /**
  377. * 实时业绩
  378. * @return mixed
  379. * @throws \yii\web\HttpException
  380. */
  381. public function actionRealTimePerf() {
  382. $userId = \Yii::$app->user->id;
  383. $period = Period::instance();
  384. $newPerf = Perf::getPeriodNewPerf($userId);
  385. $weekData = [['PV_1L' => Tool::formatFrontPerf($newPerf['PV_1L']), 'PV_2L' => Tool::formatFrontPerf($newPerf['PV_2L']), 'PV_3L' => Tool::formatFrontPerf($newPerf['PV_3L'])]];
  386. $monthPerf = Perf::getMonthPerf($userId);
  387. $monthData = [['PV_1L' => Tool::formatFrontPerf($monthPerf['PV_1L']), 'PV_2L' => Tool::formatFrontPerf($monthPerf['PV_2L']), 'PV_3L' => Tool::formatFrontPerf($monthPerf['PV_3L'])]];
  388. $lastMonth = PerfMonth::getMonthPerf($period->getLastMonth()['yearMonth'], $userId);
  389. $lastData = [['PV_1L' => Tool::formatFrontPerf($lastMonth['PV_1L_TOTAL']), 'PV_2L' => Tool::formatFrontPerf($lastMonth['PV_2L_TOTAL']), 'PV_3L' => Tool::formatFrontPerf($lastMonth['PV_3L_TOTAL'])]];
  390. //是否合格
  391. // $lastChkStatus = '';
  392. // $lastMonthPerfChk = Cache::getSystemConfig()['lastMonthPerfChk']['VALUE'];
  393. // $lastArr = [$lastMonth['PV_1L_TOTAL'], $lastMonth['PV_2L_TOTAL'], $lastMonth['PV_3L_TOTAL'], $lastMonth['PV_4L_TOTAL'], $lastMonth['PV_5L_TOTAL']];
  394. // if (array_sum($lastArr) >= $lastMonthPerfChk) {
  395. // $lastChkStatus = '已合格';
  396. // }
  397. //判断大区
  398. // $bigLocation = array_search(max($lastArr), $lastArr) + 1;
  399. return static::notice(['weekData' => $weekData, 'monthData' => $monthData, 'lastData' => $lastData]);
  400. }
  401. /**
  402. * 近十期已挂网的期数
  403. * @return mixed
  404. * @throws \yii\web\HttpException
  405. */
  406. public function actionDecPeriod() {
  407. $showDecPeriodNum = Cache::getSystemConfig()['showDecPeriodNum']['VALUE'];
  408. $calcBonus = Period::find()->where('IS_SENT=:IS_SENT',[':IS_SENT' => Period::SEND_FINISH])->select('PERIOD_NUM,END_TIME')->limit($showDecPeriodNum)->orderBy('PERIOD_NUM DESC')->asArray()->all();
  409. return static::notice($calcBonus);
  410. }
  411. /**
  412. * 报单中心补助明细
  413. * @return mixed
  414. * @throws \yii\web\HttpException
  415. */
  416. public function actionFlowBt() {
  417. $periodNum = \Yii::$app->request->get('periodNum');
  418. $condition = '';
  419. $params = [];
  420. if (!$periodNum) {
  421. return static::notice(Yii::t('app', 'pleaseSelectThePeriod'), 400);
  422. }
  423. if ($periodNum) {
  424. $showDecPeriodNum = Cache::getSystemConfig()['showDecPeriodNum']['VALUE'];
  425. $periodNums = Period::find()->where('IS_SENT=:IS_SENT',[':IS_SENT' => Period::SEND_FINISH])->select('PERIOD_NUM')->limit($showDecPeriodNum)->orderBy('PERIOD_NUM DESC')->asArray()->all();
  426. if(!in_array($periodNum,array_column($periodNums,'PERIOD_NUM'))){
  427. return static::notice(Yii::t('app', 'cannotViewThisPeriod'), 400);
  428. }
  429. $condition .= ' AND PERIOD_NUM=:PERIOD_NUM';
  430. $params[':PERIOD_NUM'] = $periodNum;
  431. }
  432. $condition .= ' AND USER_ID=:USER_ID';
  433. $params[':USER_ID'] = \Yii::$app->user->id;
  434. $data = CalcBonusBT::lists($condition, $params, [
  435. 'select' => 'BT_TYPE,FROM_ORDER_SN,ORDER_TIME,PAY_PV,DELIVERY_AT,TRANSFER_AMOUNT,TRANSFER_AT,AMOUNT',
  436. 'from' => CalcBonusBT::tableName(),
  437. 'orderBy' => 'CREATED_AT DESC',
  438. ]);
  439. if ($data['list']) {
  440. foreach ($data['list'] as $key => $value) {
  441. $data['list'][$key]['BT_TYPE_NAME'] = CalcBonusBT::TYPE_NAME[$value['BT_TYPE']];
  442. foreach ($value as $k=>$item){
  443. if($item==0) $data['list'][$key][$k] ='';
  444. }
  445. }
  446. }
  447. return static::notice($data);
  448. }
  449. /**
  450. * 报单中心货补追溯
  451. * @return mixed
  452. * @throws \yii\web\HttpException
  453. */
  454. public function actionTraceFl() {
  455. $periodNum = \Yii::$app->request->get('periodNum');
  456. $condition = '';
  457. $params = [];
  458. if (!$periodNum) {
  459. return static::notice(Yii::t('app', 'pleaseSelectThePeriod'), 400);
  460. }
  461. if ($periodNum) {
  462. $showDecPeriodNum = Cache::getSystemConfig()['showDecPeriodNum']['VALUE'];
  463. $periodNums = Period::find()->where('IS_SENT=:IS_SENT',[':IS_SENT' => Period::SEND_FINISH])->select('PERIOD_NUM')->limit($showDecPeriodNum)->orderBy('PERIOD_NUM DESC')->asArray()->all();
  464. if(!in_array($periodNum,array_column($periodNums,'PERIOD_NUM'))){
  465. return static::notice(Yii::t('app', 'cannotViewThisPeriod'), 400);
  466. }
  467. $condition .= ' AND PERIOD_NUM=:PERIOD_NUM';
  468. $params[':PERIOD_NUM'] = $periodNum;
  469. }
  470. $condition .= ' AND USER_ID=:USER_ID';
  471. $params[':USER_ID'] = \Yii::$app->user->id;
  472. $data = CalcBonusFL::lists($condition, $params, [
  473. 'select' => 'DEC_SN,DEC_AT,DEC_PV,AMOUNT',
  474. 'from' => CalcBonusFL::tableName(),
  475. 'orderBy' => 'CREATED_AT DESC',
  476. ]);
  477. return static::notice($data);
  478. }
  479. /**
  480. * 查看所传期数的各项奖金
  481. * @return mixed
  482. * @throws \yii\db\Exception
  483. * @throws \yii\web\HttpException
  484. */
  485. public function actionBonusDetail() {
  486. $periodNum = \Yii::$app->request->get('periodNum');
  487. $period = Period::instance();
  488. $periodInfo = $period->setPeriodNum($periodNum);
  489. $yearMonth = $period->getYearMonth($periodNum);
  490. if (!$period->isSent($periodNum)) {
  491. return static::notice(Yii::t('app', 'cannotViewThisPeriod'), 400);
  492. }
  493. $data = CalcBonus::findUseSlaves()->yearMonth($yearMonth)->select('BONUS_QY,BONUS_YC,BONUS_FX,BONUS_LS,BONUS_CF,BONUS_LX,BONUS_FL')->where('PERIOD_NUM=:PERIOD_NUM AND USER_ID=:USER_ID', [':PERIOD_NUM' => $periodNum, ':USER_ID' => \Yii::$app->user->id])->asArray()->one();
  494. return static::notice(['period' => $periodInfo, 'bonus' => $data]);
  495. }
  496. /**
  497. * 奖金流水
  498. * @return mixed
  499. * @throws \yii\web\HttpException
  500. */
  501. public function actionFlowBonus() {
  502. $yearMonth = \Yii::$app->request->get('yearMonth');
  503. if ($yearMonth) {
  504. if (!Date::isYearMonth($yearMonth)) {
  505. return static::notice(Yii::t('app', 'invalidParameter'), 400);
  506. }
  507. } else {
  508. $period = Period::instance();
  509. $yearMonth = $period->getNowYearMonth();
  510. }
  511. $data = FlowBonus::lists(' AND USER_ID=:USER_ID', [':USER_ID' => \Yii::$app->user->id], [
  512. 'useSlaves' => true,
  513. 'select' => 'AMOUNT,TOTAL,IS_INCR,REMARK,REMARK_IS_SHOW,PERIOD_NUM,CALC_MONTH,CREATED_AT',
  514. 'yearMonth' => $yearMonth,
  515. 'orderBy' => 'CREATED_AT DESC',
  516. ]);
  517. foreach ($data['list'] as $key => $value) {
  518. if($value['REMARK_IS_SHOW']==0) $data['list'][$key]['REMARK'] = '';
  519. }
  520. return static::notice($data);
  521. }
  522. /**
  523. * 提现列表
  524. * @return mixed
  525. * @throws \yii\base\Exception
  526. * @throws \yii\web\HttpException
  527. */
  528. public function actionWithdraw() {
  529. $yearMonth = \Yii::$app->request->get('yearMonth');
  530. if ($yearMonth) {
  531. if (!Date::isYearMonth($yearMonth)) {
  532. return static::notice(Yii::t('app', 'invalidParameter'), 400);
  533. }
  534. } else {
  535. $period = Period::instance();
  536. $yearMonth = $period->getNowYearMonth();
  537. }
  538. $data = Withdraw::lists('AND W.USER_ID=:USER_ID', [':USER_ID' => \Yii::$app->user->id], [
  539. 'useSlaves' => true,
  540. 'select' => 'W.ID,W.USER_ID,W.IS_AUTO_WITHDRAW,W.AMOUNT,W.AUDIT_STATUS,W.CREATED_AT,W.PAID_AT,W.PAY_TYPE,W.PAID_FAIL_REMARK,W.INVOICE_ID,IA.AMOUNT INVOICE_AMOUNT,IA.AUDIT_STATUS INVOICE_AUDIT_STATUS,IA.UPLOAD_ID',
  541. 'from' => Withdraw::tableName() . ' AS W',
  542. 'join' => [
  543. ['LEFT JOIN', InvoiceAudit::tableName() . ' AS IA', 'W.ID=IA.WITHDRAW_ID'],
  544. ],
  545. 'yearMonth' => $yearMonth,
  546. 'orderBy' => 'W.CREATED_AT DESC',
  547. //'with' => 'openBank',
  548. ]);
  549. $auditStatus = array_column(\Yii::$app->params['auditStatus'], null, 'value');
  550. foreach ($data['list'] as $key => $value) {
  551. $baseInfo = Info::baseInfo($value['USER_ID']);
  552. $data['list'][$key]['USER_NAME'] = $baseInfo['USER_NAME'];
  553. $data['list'][$key]['REAL_NAME'] = $baseInfo['REAL_NAME'];
  554. $data['list'][$key]['STATUS_NAME'] = Withdraw::STATUS_NAME[$value['AUDIT_STATUS']];
  555. $data['list'][$key]['INVOICE_STATUS_NAME'] = isset($value['INVOICE_AUDIT_STATUS'])?$auditStatus[$value['INVOICE_AUDIT_STATUS']]['label']:'未传发票';
  556. }
  557. return static::notice($data);
  558. }
  559. /**
  560. * 提交提现申请
  561. * @return mixed
  562. * @throws \yii\db\Exception
  563. * @throws \yii\web\HttpException
  564. */
  565. public function actionWithdrawAdd() {
  566. if (\Yii::$app->request->isPost) {
  567. $formModel = new WithdrawForm();
  568. $formModel->scenario = 'addByUser';
  569. if ($formModel->load(\Yii::$app->request->post(), '') && $formModel->add()) {
  570. return static::notice(Yii::t('app', 'withdrawalApplicationHasBeenSubmitted'), 400);
  571. } else {
  572. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  573. }
  574. } else {
  575. return static::notice(Yii::t('app', 'illegalRequest'), 400);
  576. }
  577. }
  578. /**
  579. * 提现退回
  580. * @return mixed
  581. * @throws \yii\db\Exception
  582. * @throws \yii\web\HttpException
  583. */
  584. public function actionWithdrawBack() {
  585. if (\Yii::$app->request->isPost) {
  586. $formModel = new WithdrawForm();
  587. $formModel->scenario = 'backByUser';
  588. if ($formModel->load(\Yii::$app->request->post(), '') && $formModel->backByUser()) {
  589. return static::notice(Yii::t('app', 'withdrawHasBeenBacked'));
  590. } else {
  591. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  592. }
  593. } else {
  594. return static::notice(Yii::t('app', 'illegalRequest'), 400);
  595. }
  596. }
  597. /**
  598. * 判断并获取提现的会员信息
  599. * @return mixed
  600. * @throws \yii\web\HttpException
  601. */
  602. public function actionChkWithdrawUser() {
  603. $uid = \Yii::$app->user->id;
  604. if (!Info::isVerified($uid)) {
  605. return static::notice(Yii::t('app', 'withdrawDoesNotAllowedOfAuthentication'), 400);
  606. }
  607. $userInfo = UserInfo::findOneAsArray('USER_ID=:USER_ID', [':USER_ID' => $uid], 'IS_BIND,IS_BIND_MAIN,IS_AUTO_WITHDRAW,REG_TYPE,TRANSFER_PROP');
  608. if ($userInfo['IS_BIND'] == 1 && $userInfo['IS_BIND_MAIN'] == 0) {
  609. return static::notice(Yii::t('app', 'withdrawDoesNotAllowedOfSubsidiaryMember'), 400);
  610. }
  611. if ($userInfo['IS_AUTO_WITHDRAW'] == 1) {
  612. return static::notice(Yii::t('app', 'autoWithdrawHasBeenOpened'), 400);
  613. }
  614. if (!Withdraw::allowWithdraw()) {
  615. return static::notice(Yii::t('app', 'withdrawNotAllowOfDate'), 400);
  616. }
  617. if (Withdraw::hasThisMonthWithdraw($uid)) {
  618. return static::notice(Yii::t('app', 'withdrawAllowOnceOfMonth'), 400);
  619. }
  620. if (Withdraw::existWaitAudit($uid)) {
  621. return static::notice(Yii::t('app', 'withdrawRecordHasNotVerify'), 400);
  622. }
  623. //是否显示服务协议
  624. $regType = RegType::findOneAsArray('ID=:ID', [':ID' => $userInfo['REG_TYPE']], 'IS_PACT');
  625. $path = \Yii::getAlias('@common/runtime/datas/pact.php');
  626. if (!file_exists($path)) {
  627. $oneData = '';
  628. } else {
  629. $oneData = include $path;
  630. }
  631. $isCanTransferProp = Cache::getSystemConfig()['isCanTransferProp']['VALUE'];
  632. if ($isCanTransferProp == 0) {
  633. $userInfo['WITHDRAW_PROP'] = 100;
  634. } else {
  635. $userInfo['WITHDRAW_PROP'] = 100 - $userInfo['TRANSFER_PROP'];
  636. }
  637. return static::notice(['userInfo' => $userInfo, 'isPact' => $regType['IS_PACT'], 'content' => $oneData['CONTENT']]);
  638. }
  639. /**
  640. * 归集附属会员奖金
  641. * @return mixed
  642. * @throws \yii\db\Exception
  643. * @throws \yii\web\HttpException
  644. */
  645. public function actionCollectBind() {
  646. $transferBonusForm = new TransferBonusForm();
  647. if ($totals=$transferBonusForm->collectBind(\Yii::$app->user->id)) {
  648. return static::notice(Yii::t('app', 'notionalPoolingAmountFinished') . $totals);
  649. } else {
  650. if($totals==0){
  651. return static::notice(Yii::t('app', 'notionalPoolingAmountFinished') . $totals);
  652. }else{
  653. return static::notice(Form::formatErrorsForApi($transferBonusForm->getErrors()), 400);
  654. }
  655. }
  656. }
  657. /**
  658. * 上传发票之前
  659. * @return mixed
  660. * @throws \yii\web\HttpException
  661. */
  662. public function actionInvoiceBeforeAdd() {
  663. $id = \Yii::$app->request->get('id');
  664. $withdraw = Withdraw::findOneAsArray('ID=:ID', [':ID' => $id]);
  665. if (!$withdraw) {
  666. return static::notice(Yii::t('app', 'dataDoesNotExists'), 400);
  667. }
  668. $uploadInvoiceTip = Cache::getSystemConfig()['uploadInvoiceTip']['VALUE'];
  669. if ($withdraw['AUDIT_STATUS'] == Withdraw::STATUS_APPLIED) {
  670. return static::notice(['addInvoiceTips' => $uploadInvoiceTip]);
  671. } else {
  672. return static::notice(Yii::t('app', 'withdrawDoesNotUploadInvoice'), 400);
  673. }
  674. }
  675. /**
  676. * 上传发票
  677. * @return mixed
  678. * @throws \yii\db\Exception
  679. * @throws \yii\web\HttpException
  680. */
  681. public function actionInvoiceAdd() {
  682. $id = \Yii::$app->request->get('id');
  683. $withdraw = Withdraw::findOneAsArray('ID=:ID', [':ID' => $id]);
  684. if (!$withdraw) {
  685. return static::notice(Yii::t('app', 'dataDoesNotExists'), 400);
  686. }
  687. if (\Yii::$app->request->isPost) {
  688. $formModel = new UploadForm();
  689. $formModel->scenario = 'invoiceFront';
  690. $formModel->file = UploadedFile::getInstanceByName('file');
  691. $formModel->withdrawId = $withdraw['ID'];
  692. $formModel->remark = '提现'.$withdraw['SN'].'发票';
  693. //$formModel->token = \Yii::$app->request->post('uploadToken');
  694. $formModel->token = \Yii::$app->request->request('uploadToken');
  695. if ($formModel->file && $formModel->upload()) {
  696. return static::notice(Yii::t('app', 'successfully'));
  697. } else {
  698. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  699. }
  700. }
  701. }
  702. /**
  703. * 显示上传的发票
  704. * @return mixed
  705. * @throws \yii\web\HttpException
  706. */
  707. public function actionInvoiceShow() {
  708. $id = \Yii::$app->request->get('id');
  709. $uploads = Uploads::findOneAsArray('ID=:ID', [':ID' => $id],'URL');
  710. if (!$uploads) {
  711. return static::notice(Yii::t('app', 'dataDoesNotExists'), 400);
  712. }
  713. return static::notice($uploads['URL']);
  714. }
  715. /**
  716. * 获取可用余额
  717. * @return mixed
  718. * @throws \yii\web\HttpException
  719. */
  720. public function actionAvailableBalance() {
  721. return static::notice(Balance::getAvailableBalance(\Yii::$app->user->id));
  722. }
  723. /**
  724. * 查看业绩
  725. * @return mixed
  726. * @throws \yii\web\HttpException
  727. */
  728. public function actionPerf() {
  729. $yearMonth = \Yii::$app->request->get('yearMonth');
  730. if ($yearMonth) {
  731. if (!Date::isYearMonth($yearMonth)) {
  732. return static::notice(Yii::t('app', 'invalidParameter'), 400);
  733. }
  734. } else {
  735. $period = Period::instance();
  736. $yearMonth = $period->getNowYearMonth();
  737. }
  738. $data = PerfPeriod::lists('AND P.USER_ID=:USER_ID AND PN.IS_SENT=1', [':USER_ID' => \Yii::$app->user->id], [
  739. 'select' => 'P.*',
  740. 'yearMonth' => $yearMonth,
  741. 'from' => PerfPeriod::tableName() . ' AS P',
  742. 'join' => [
  743. ['LEFT JOIN', Period::tableName() . ' AS PN', 'P.PERIOD_NUM=PN.PERIOD_NUM']
  744. ],
  745. 'orderBy' => 'P.PERIOD_NUM DESC',
  746. ]);
  747. $data['request']['yearMonth'] = $yearMonth;
  748. return static::notice($data);
  749. }
  750. /**
  751. * 转账列表
  752. * @return mixed
  753. * @throws \yii\web\HttpException
  754. */
  755. public function actionTransferList() {
  756. $type = \Yii::$app->request->get('type', 'out');
  757. if ($type == 'out') {
  758. $condition = ' AND T.FROM_UID=:USER_ID';
  759. } else {
  760. $condition = ' AND T.TO_UID=:USER_ID';
  761. }
  762. $params = [
  763. ':USER_ID' => \Yii::$app->user->id,
  764. ];
  765. $data = Transfer::lists($condition, $params, [
  766. 'select' => 'FUI.USER_NAME AS FROM_USER_NAME, TUI.USER_NAME AS TO_USER_NAME, T.AMOUNT, T.PERIOD_NUM, T.CREATED_AT',
  767. 'from' => Transfer::tableName() . ' AS T',
  768. 'join' => [
  769. ['LEFT JOIN', UserInfo::tableName() . ' AS FUI', 'FUI.USER_ID=T.FROM_UID'],
  770. ['LEFT JOIN', UserInfo::tableName() . ' AS TUI', 'TUI.USER_ID=T.TO_UID'],
  771. ],
  772. ]);
  773. return static::notice($data);
  774. }
  775. /**
  776. * 转账
  777. * @throws \yii\db\Exception
  778. * @throws \yii\web\HttpException
  779. */
  780. public function actionTransferAdd() {
  781. if (\Yii::$app->request->isPost) {
  782. $formModel = new TransferForm();
  783. if ($formModel->load(\Yii::$app->request->post(), '') && $formModel->transfer()) {
  784. return static::notice(Yii::t('app', 'successfully'));
  785. } else {
  786. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  787. }
  788. }
  789. }
  790. /**
  791. * 检查转账资格
  792. * @return mixed
  793. * @throws \yii\web\HttpException
  794. */
  795. public function actionChkTransferUser() {
  796. $uid = \Yii::$app->user->id;
  797. if (!Info::isVerified($uid)) {
  798. return static::notice(Yii::t('app', 'transferDoesNotAllowedOfAuthentication'), 400);
  799. }
  800. $userInfo = UserInfo::findOneAsArray('USER_ID=:USER_ID', [':USER_ID' => $uid], 'ALLOW_TRANSFER,TRANSFER_PROP');
  801. if($userInfo['ALLOW_TRANSFER']==0){
  802. return static::notice(Yii::t('app', 'transferDoesNotAllowed'), 400);
  803. }
  804. $isCanTransferProp = Cache::getSystemConfig()['isCanTransferProp']['VALUE'];
  805. if($isCanTransferProp==0){
  806. $userInfo['TRANSFER_PROP']=100;
  807. }
  808. return static::notice(['userInfo' => $userInfo]);
  809. }
  810. /**
  811. * 房产积分列表
  812. * @return mixed
  813. * @throws \yii\web\HttpException
  814. */
  815. public function actionFcPoint() {
  816. $condition = ' AND USER_ID=:USER_ID';
  817. $params = [':USER_ID' => \Yii::$app->user->id];
  818. $yearMonth = \Yii::$app->request->get('yearMonth');
  819. if ($yearMonth) {
  820. if (!Date::isYearMonth($yearMonth)) {
  821. return static::notice(Yii::t('app', 'invalidParameter'), 400);
  822. }
  823. $condition .= ' AND CALC_MONTH=:CALC_MONTH';
  824. $params['CALC_MONTH'] = $yearMonth;
  825. }
  826. $data = ScoreMonth::lists($condition, $params, [
  827. 'from' => ScoreMonth::tableName(),
  828. 'orderBy' => 'ID DESC',
  829. ]);
  830. return static::notice($data);
  831. }
  832. /**
  833. * 查询可用期数
  834. * @return mixed
  835. * @throws HttpException
  836. */
  837. public function actionPeriod() {
  838. $nowTs = time();
  839. // 当前期
  840. $currentPeriod = Period::find()->where('START_TIME<:NOW_TIME', ['NOW_TIME' => $nowTs])->where('END_TIME>=:NOW_TIME', ['NOW_TIME' => $nowTs - 6])->asArray()->one();
  841. $data[] = $currentPeriod['PERIOD_NUM'];
  842. // 上一期是否封期
  843. $prevPeriodNum = $currentPeriod['PERIOD_NUM'] - 1;
  844. $prevPeriod = Period::find()->where('PERIOD_NUM=:PERIOD_NUM AND IS_SENT=0', [':PERIOD_NUM' => $prevPeriodNum])->asArray()->one();
  845. if ($prevPeriod) {
  846. $data[] = $prevPeriod['PERIOD_NUM'];
  847. }
  848. return static::notice(['data' => $data]);
  849. }
  850. function actionSentUserPerformance()
  851. {
  852. if (\Yii::$app->request->isPost) {
  853. $param = \Yii::$app->request->post();
  854. foreach ($param as $value){
  855. UserPerformance::sentUserPerformanceApi($value['user_id'], $value['amount'], $value['period']);
  856. }
  857. return static::notice(Yii::t('app', 'successfully'));
  858. } else {
  859. return static::notice(Yii::t('app', 'illegalRequest'), 400);
  860. }
  861. }
  862. }