PeriodBonusList.php 14 KB

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