PerfOrderList.php 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <?php
  2. namespace backendApi\modules\v1\models\lists\bonus;
  3. use backendApi\modules\v1\models\Admin;
  4. use backendApi\modules\v1\models\User;
  5. use common\models\User as modelUser;
  6. use common\helpers\Cache;
  7. use common\helpers\user\Info;
  8. use common\libs\dataList\column\Price;
  9. use common\libs\dataList\column\YesNo;
  10. use common\libs\dataList\DataListInterface;
  11. use common\models\PerfOrder;
  12. use common\models\Region;
  13. use common\models\UserBind;
  14. use common\models\UserBonus;
  15. use common\models\UserInfo;
  16. use common\libs\dataList\column\DateTime;
  17. use common\models\UserSystem;
  18. use common\models\Withdraw;
  19. use Yii;
  20. class PerfOrderList extends \common\libs\dataList\DataList implements DataListInterface
  21. {
  22. /**
  23. * 列表名称
  24. * @return string
  25. */
  26. public function getListName(){
  27. return '业绩单列表';
  28. }
  29. /**
  30. * 列表筛选到的数据
  31. * @throws \yii\base\Exception
  32. */
  33. public function dataHandle()
  34. {
  35. $data = PerfOrder::lists($this->condition, $this->params, [
  36. 'select'=>'PO.*, U.USER_NAME, U.REAL_NAME',
  37. 'from' => PerfOrder::tableName().' AS PO',
  38. 'join' => [
  39. ['LEFT JOIN', modelUser::tableName() . ' AS U', 'PO.USER_ID=U.ID'],
  40. ],
  41. 'orderBy' => 'PO.CREATED_AT DESC, PO.ID DESC',
  42. 'page' => $this->page,
  43. 'pageSize' => $this->pageSize,
  44. ]);
  45. if($data['list']){
  46. foreach($data['list'] as $key=>$value){
  47. $data['list'][$key]['DEC_STATUS_NAME'] = PerfOrder::STATUS_NAME[$data['list'][$key]['DEC_STATUS']];
  48. }
  49. }
  50. $this->listData = $data;
  51. }
  52. /**
  53. * 要展示和导出的所有字段
  54. * @return array
  55. */
  56. public function getColumn(){
  57. if(!$this->columns){
  58. $this->columns = [
  59. 'PERIOD_NUM' => [
  60. 'header' => 'Number of settlement periods',//结算期数
  61. 'headerOther' => [
  62. 'width' => '100',
  63. ],
  64. ],
  65. 'SN' => [
  66. 'header' => 'Performance sheet No',//业绩单编号
  67. 'value' => function($row) {
  68. return "\t".$row['SN'];
  69. },
  70. 'headerOther' => [
  71. 'width' => '250',
  72. ],
  73. ],
  74. 'DEC_TYPE' => [
  75. 'header' => 'Performance sheet type',//业绩单类型
  76. 'headerOther' => [
  77. 'width' => '130',
  78. ],
  79. 'value' => function($row){
  80. $decTypes = [
  81. 'ZC'=> 'First purchase order',//首购单
  82. 'YH'=> 'Coupon',//优惠单
  83. 'ZG'=> 'Additional purchase order',//增购单
  84. 'LS'=> 'Retail order',//零售单
  85. 'FX'=> 'Re sales order',//复销单
  86. ];
  87. return $decTypes[strtoupper($row['DEC_TYPE'])];
  88. },
  89. ],
  90. 'DEC_STATUS_NAME' => [
  91. 'header' => 'Performance sheet status',//业绩单状态
  92. 'headerOther' => [
  93. 'width' => '110',
  94. ],
  95. ],
  96. 'USER_NAME' => [
  97. 'header' => 'Member code',//会员编号
  98. 'headerOther' => [
  99. 'width' => '110',
  100. ],
  101. ],
  102. 'REAL_NAME' => [
  103. 'header' => 'Member name',//会员姓名
  104. 'headerOther' => [
  105. 'width' => '150',
  106. ],
  107. ],
  108. 'LAST_REC_USER_NAME' => [
  109. 'header' => 'Pioneer No. at settlement',//结算时开拓者编号
  110. 'headerOther' => [
  111. 'width' => '150',
  112. ],
  113. ],
  114. 'LAST_REC_REAL_NAME' => [
  115. 'header' => 'Pioneer name at settlement',//结算时开拓者姓名
  116. 'headerOther' => [
  117. 'width' => '150',
  118. ],
  119. ],
  120. 'PV' => [
  121. 'header' => 'Entry BV',//报单BV
  122. 'headerOther' => [
  123. 'width' => '150',
  124. ],
  125. 'value' => function($row) {
  126. return (new Price([
  127. 'value' => $row['PV'],
  128. ]))->result();
  129. },
  130. ],
  131. 'DEC_AMOUNT' => [
  132. 'header' => 'Entry amount',//报单金额
  133. 'headerOther' => [
  134. 'width' => '150',
  135. ],
  136. 'value' => function($row) {
  137. return (new Price([
  138. 'value' => $row['DEC_AMOUNT'],
  139. ]))->result();
  140. },
  141. ],
  142. 'DEC_SN' => [
  143. 'header' => 'Entry No',//报单编号
  144. 'headerOther' => [
  145. 'width' => '250',
  146. ],
  147. ],
  148. 'FROM_TABLES' => [
  149. 'header' => '订单来源',
  150. 'headerOther' => [
  151. 'width' => '250',
  152. ],
  153. ],
  154. 'CREATED_AT' => [
  155. 'header' => 'Creation time',//创建时间
  156. 'value' => function($row) {
  157. return (new DateTime([
  158. 'value' => $row['CREATED_AT'],
  159. ]))->result();
  160. },
  161. 'headerOther' => ['width' => '170'],
  162. ],
  163. ];
  164. }
  165. return $this->columns;
  166. }
  167. /**
  168. * 前台用于筛选的类型集合
  169. * @return mixed
  170. */
  171. public function getFilterTypes()
  172. {
  173. if(!$this->filterTypes){
  174. $this->filterTypes = [
  175. 'PERIOD_NUM'=> ['isUserTable'=> false, 'name'=> 'Number of settlement periods'],//结算期数
  176. 'SN'=> ['isUserTable'=> false, 'name'=> 'Performance sheet No'],//业绩单编号
  177. 'DEC_STATUS_NAME'=> ['isUserTable'=> false, 'name'=> 'Performance sheet status','other'=> 'select',
  178. 'selectData'=> [['id'=> 1, 'name'=> 'Reviewed'], ['id'=> 2, 'name'=> 'Waste disposal']],],//业绩单状态,已审核,置废
  179. 'USER_NAME'=> ['isUserTable'=> false, 'name'=> 'Member code'],//会员编号
  180. 'REAL_NAME'=> ['isUserTable'=> false, 'name'=> 'Member name'],//会员姓名
  181. 'LAST_REC_USER_NAME'=> ['isUserTable'=> false, 'name'=> 'Pioneer No. at settlement'],//结算时开拓者编号
  182. 'LAST_REC_REAL_NAME'=> ['isUserTable'=> false, 'name'=> 'Pioneer name at settlement'],//结算时开拓者姓名
  183. 'PV'=> ['isUserTable'=> false, 'name'=> 'Entry BV'],//报单BV
  184. 'DEC_AMOUNT'=> ['isUserTable'=> false, 'name'=> 'Entry amount'],//报单金额
  185. 'DEC_SN'=> ['isUserTable'=> false, 'name'=> 'Entry No'],//报单编号
  186. 'CREATED_AT'=> ['isUserTable'=> true, 'name'=> 'Creation time', 'other'=> 'date'],//创建时间
  187. ];
  188. }
  189. return $this->filterTypes;
  190. }
  191. }