PeriodBonusList.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. <?php
  2. namespace backendApi\modules\v1\models\lists\bonus;
  3. use backendApi\modules\v1\models\Admin;
  4. use common\helpers\Cache;
  5. use common\helpers\Tool;
  6. use common\helpers\user\Info;
  7. use common\libs\dataList\column\Price;
  8. use common\libs\dataList\column\YesNo;
  9. use common\libs\dataList\DataListInterface;
  10. use common\models\CalcBonus;
  11. use common\models\PerfOrder;
  12. use common\models\Period;
  13. use common\models\Region;
  14. use common\models\User as modelUser;
  15. use common\models\UserBind;
  16. use common\models\UserBonus;
  17. use common\models\UserInfo;
  18. use common\libs\dataList\column\DateTime;
  19. use common\models\UserPerf;
  20. use common\models\UserSystem;
  21. use common\models\Withdraw;
  22. use Yii;
  23. class PeriodBonusList extends \common\libs\dataList\DataList implements DataListInterface
  24. {
  25. /**
  26. * 列表名称
  27. * @return string
  28. */
  29. public function getListName(){
  30. return '奖金列表';
  31. }
  32. /**
  33. * 列表筛选到的数据
  34. * @throws \yii\base\Exception
  35. */
  36. public function dataHandle()
  37. {
  38. $yearMonth = $this->others['yearMonth'];
  39. $this->listData = CalcBonus::lists($this->condition, $this->params, [
  40. // 'select'=>'CB.*, UP.SURPLUS_1L AS UP_SURPLUS_1L, UP.SURPLUS_2L AS UP_SURPLUS_2L, UP.SURPLUS_3L AS UP_SURPLUS_3L,UI.CON_UID,UI.REC_UID',
  41. 'select'=>'CB.*,UI.CON_UID,UI.REC_UID',
  42. 'from' => CalcBonus::tableName().' AS CB',
  43. 'join' => [
  44. // ['LEFT JOIN', UserPerf::tableName() . ' AS UP', 'CB.USER_ID=UP.USER_ID'],
  45. ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'CB.USER_ID=UI.USER_ID'],
  46. ],
  47. 'yearMonth' => $yearMonth,
  48. 'orderBy' => 'CB.CREATED_AT DESC, CB.ID DESC',
  49. 'page' => $this->page,
  50. 'pageSize' => $this->pageSize,
  51. ]);
  52. unset($yearMonth);
  53. if ($this->listData['list']) {
  54. foreach ($this->listData['list'] as $key => $value) {
  55. $this->listData['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_DEC_LV']]['LEVEL_NAME'];
  56. $this->listData['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_EMP_LV']]['LEVEL_NAME'];
  57. $this->listData['list'][$key]['LAST_CROWN_LV_NAME'] = Cache::getStarCrownLevelConfig()[$value['LAST_CROWN_LV']]['LEVEL_NAME'] ?? $value['LAST_CROWN_LV'];
  58. $this->listData['list'][$key]['LAST_STATUS_NAME'] = Tool::paramConvert(Yii::$app->params['userStatus'])[$value['LAST_STATUS']]['label'];
  59. $this->listData['list'][$key]['LAST_REC_USER_NAME'] = Info::getUserNameByUserId($value['REC_UID']);
  60. $this->listData['list'][$key]['LAST_REC_REAL_NAME'] = Info::getUserRealNameByUserId($value['REC_UID']);
  61. $this->listData['list'][$key]['LAST_CON_USER_NAME'] = Info::getUserNameByUserId($value['CON_UID']);
  62. $this->listData['list'][$key]['LAST_CON_REAL_NAME'] = Info::getUserRealNameByUserId($value['CON_UID']);
  63. }
  64. }
  65. }
  66. /**
  67. * 要展示和导出的所有字段
  68. * @return array
  69. */
  70. public function getColumn(){
  71. if(!$this->columns){
  72. $this->columns = [
  73. 'ID' => null,
  74. 'PERIOD_NUM' => [
  75. 'header' => \Yii::t('ctx', 'payCycle'), // 结算期数
  76. 'headerOther' => [
  77. 'width' => '150',
  78. ],
  79. 'valueOther' => [
  80. 'tag'=>['type'=>'', 'size' => 'small', 'class'=>'no-border'],
  81. ],
  82. ],
  83. 'CALCULATED_AT' => [
  84. 'header' => \Yii::t('ctx', 'bonusDate'), // 结算时间
  85. 'value' => function($row) {
  86. return (new DateTime([
  87. 'value' => $row['CALCULATED_AT'],
  88. ]))->result();
  89. },
  90. 'headerOther' => ['width' => '170'],
  91. ],
  92. 'LAST_USER_NAME' => [
  93. 'header' => \Yii::t('ctx', 'memberCode'), // 会员编号
  94. 'headerOther' => [
  95. 'width' => '150',
  96. ],
  97. 'valueOther' => [
  98. 'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border']
  99. ],
  100. ],
  101. 'LAST_REAL_NAME' => [
  102. 'header' => \Yii::t('ctx', 'memberName'), // 会员姓名
  103. 'headerOther' => [
  104. 'width' => '120',
  105. ],
  106. 'valueOther' => [
  107. 'tag'=>['type'=>'success', 'size' => 'small', 'class'=>'no-border']
  108. ],
  109. ],
  110. 'LAST_DEC_LV_NAME' => [
  111. 'header' => \Yii::t('ctx', 'PCMemberLevel'), // 结算时会员级别
  112. 'headerOther' => [
  113. 'width' => '140',
  114. ],
  115. ],
  116. 'LAST_EMP_LV_NAME' => [
  117. 'header' => \Yii::t('ctx', 'latestDirector'), // 结算时会员最新管理星级
  118. 'headerOther' => [
  119. 'width' => '140',
  120. ],
  121. ],
  122. 'LAST_CROWN_LV_NAME' => [
  123. 'header' => \Yii::t('ctx', 'latestCrown'),//结算时会员最新皇冠星级
  124. 'headerOther' => [
  125. 'width' => '140',
  126. ],
  127. ],
  128. 'LAST_MOBILE' => [
  129. 'header' => \Yii::t('ctx', 'phoneNumber'),//手机号码
  130. 'headerOther' => [
  131. 'width' => '120',
  132. ],
  133. ],
  134. 'LAST_PERIOD_AT' => [
  135. 'header' => Yii::t('ctx', 'joiningPeriod'), // 加入期数
  136. 'headerOther' => [
  137. 'width' => '110',
  138. ],
  139. ],
  140. 'LAST_CREATED_AT' => [
  141. 'header' => Yii::t('ctx', 'joiningDate'), // 加入时间
  142. 'value' => function($row) {
  143. return (new DateTime([
  144. 'value' => $row['LAST_CREATED_AT'],
  145. ]))->result();
  146. },
  147. 'headerOther' => ['width' => '170'],
  148. ],
  149. 'LAST_REC_USER_NAME' => [
  150. 'header' => Yii::t('ctx', 'sponsorNo'), // 开拓者编号
  151. 'headerOther' => [
  152. 'width' => '150',
  153. ],
  154. ],
  155. 'LAST_REC_REAL_NAME' => [
  156. 'header' => Yii::t('ctx', 'sponsorName'), // 开拓者姓名
  157. 'headerOther' => [
  158. 'width' => '120',
  159. ],
  160. ],
  161. 'LAST_CON_USER_NAME' => [
  162. 'header' => Yii::t('ctx', 'superiorCode'), // 上级编号
  163. 'headerOther' => [
  164. 'width' => '150',
  165. ],
  166. ],
  167. 'LAST_CON_REAL_NAME' => [
  168. 'header' => Yii::t('ctx', 'superiorName'), // 上级姓名
  169. 'headerOther' => [
  170. 'width' => '120',
  171. ],
  172. ],
  173. 'BONUS_TG' => [
  174. 'header' => Yii::t('ctx', 'welcomeBonus'), // 销售奖金
  175. 'value' => function($row) {
  176. return (new Price([
  177. 'value' => $row['BONUS_TG'],
  178. ]))->result();
  179. },
  180. 'headerOther' => [
  181. 'width' => '130',
  182. 'prop'=>'BONUS_TG',
  183. ],
  184. ],
  185. 'BONUS_QY' => [
  186. 'header' => Yii::t('ctx', 'teamBonus'), // 绩效奖金
  187. 'value' => function($row) {
  188. return (new Price([
  189. 'value' => $row['BONUS_QY'],
  190. ]))->result();
  191. },
  192. 'headerOther' => [
  193. 'width' => '120',
  194. 'prop'=>'BONUS_QY',
  195. ],
  196. ],
  197. 'ORI_CAPPED_BONUS_QY' => [
  198. 'header' => Yii::t('ctx', 'uncappedTeamBonus'), // 绩效奖未封顶金额
  199. 'value' => function($row) {
  200. return (new Price([
  201. 'value' => $row['ORI_CAPPED_BONUS_QY'],
  202. ]))->result();
  203. },
  204. 'headerOther' => [
  205. 'width' => '170',
  206. 'prop'=>'ORI_CAPPED_BONUS_QY',
  207. ],
  208. ],
  209. 'BONUS_BS' => [
  210. 'header' => Yii::t('ctx', 'directorBonus'),// 管理奖/蓝星奖
  211. 'value' => function($row) {
  212. return (new Price([
  213. 'value' => $row['BONUS_BS'],
  214. ]))->result();
  215. },
  216. 'headerOther' => [
  217. 'width' => '120',
  218. 'prop'=>'BONUS_BS',
  219. ],
  220. ],
  221. 'BONUS_BD' => [
  222. 'header' => Yii::t('ctx', 'stockistCommission'), // 服务奖
  223. 'value' => function($row) {
  224. return (new Price([
  225. 'value' => $row['BONUS_BD'],
  226. ]))->result();
  227. },
  228. 'headerOther' => [
  229. 'width' => '150',
  230. 'prop'=>'BONUS_BD',
  231. ],
  232. ],
  233. 'BONUS_QUARTER' => [
  234. 'header' => Yii::t('ctx', 'quarterlyBonus'), // 季度分红
  235. 'value' => function($row) {
  236. return (new Price([
  237. 'value' => $row['BONUS_QUARTER'],
  238. ]))->result();
  239. },
  240. 'headerOther' => [
  241. 'width' => '130',
  242. 'prop'=>'BONUS_QUARTER',
  243. ],
  244. ],
  245. 'BONUS_REAL' => [
  246. 'header' => Yii::t('ctx', 'actualBonus'), // 实发奖金
  247. 'value' => function($row) {
  248. return (new Price([
  249. 'value' => $row['BONUS_REAL'],
  250. ]))->result();
  251. },
  252. 'headerOther' => [
  253. 'width' => '120',
  254. 'prop'=>'BONUS_REAL',
  255. ],
  256. ],
  257. 'BONUS_TOTAL' => [
  258. 'header' => Yii::t('ctx', 'totalBonus'), // 总奖金
  259. 'value' => function($row) {
  260. return (new Price([
  261. 'value' => $row['BONUS_TOTAL'],
  262. ]))->result();
  263. },
  264. 'headerOther' => [
  265. 'width' => '120',
  266. 'prop'=>'BONUS_TOTAL',
  267. ],
  268. ],
  269. 'BONUS_INCOME' => [
  270. 'header' => Yii::t('ctx', 'totalRevenue'), // 总收入
  271. 'value' => function($row) {
  272. return (new Price([
  273. 'value' => $row['BONUS_INCOME'],
  274. ]))->result();
  275. },
  276. 'headerOther' => [
  277. 'width' => '120',
  278. 'prop'=>'BONUS_INCOME',
  279. ],
  280. ],
  281. 'CALC_MONTH' => [
  282. 'header' => Yii::t('ctx', 'bonusMonth'), // 结算月
  283. 'headerOther' => [
  284. 'width' => '110',
  285. ],
  286. ],
  287. ];
  288. }
  289. return $this->columns;
  290. }
  291. /**
  292. * 前台用于筛选的类型集合
  293. * @return mixed
  294. */
  295. public function getFilterTypes()
  296. {
  297. if(!$this->filterTypes){
  298. $this->filterTypes = [
  299. 'LAST_USER_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'memberCode')], // 会员编号
  300. 'LAST_REAL_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'memberName')], // 会员姓名
  301. 'LAST_DEC_LV_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'PCMemberLevel'), 'other'=> 'decLevel'], // 结算时会员级别
  302. 'LAST_EMP_LV_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'latestDirector'), 'other'=> 'empLevel'], // 结算时会员管理星级
  303. 'LAST_CROWN_LV_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'latestCrown'), 'other'=> 'crownLevel'], // 结算时会员皇冠星级
  304. 'LAST_MOBILE'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'phoneNumber')], // 手机号
  305. 'LAST_PERIOD_AT'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'joiningPeriod')], // 加入期数
  306. 'LAST_CREATED_AT'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'joiningDate'), 'other'=> 'date'], // 加入时间
  307. 'CALCULATED_AT'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'date'), 'other'=> 'date'], // 备份时间
  308. 'LAST_REC_USER_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'sponsorNo')], // 开拓者编号
  309. 'LAST_REC_REAL_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'sponsorName')], // 开拓者姓名
  310. 'LAST_CON_USER_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'superiorNumber')], // 上级编号
  311. 'LAST_CON_REAL_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'superiorName')], // 上级姓名
  312. 'PV_1L'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'oneNewMarketPerformance')], // 一市场新增业绩
  313. 'SURPLUS_1L'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'oneMarketBalancePerformance')], // 一市场结余业绩
  314. 'PV_2L'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'twoNewMarketPerformance')], // 二市场新增业绩
  315. 'SURPLUS_2L'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'twoMarketBalancePerformance')], // 二市场结余业绩
  316. 'BONUS_BD'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'stockistCommission')], // 服务奖
  317. 'BONUS_GL'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'managementAward')], // 管理奖
  318. 'BONUS_QY'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'teamBonus')], // 团队奖
  319. 'CALC_MONTH'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'bonusMonth')], // 结算月
  320. ];
  321. }
  322. return $this->filterTypes;
  323. }
  324. }