截流自动化的商城平台
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

AccountLog.php 8.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <?php
  2. namespace app\common\model;
  3. use app\common\basics\Models;
  4. use app\common\model\user\User;
  5. class AccountLog extends Models
  6. {
  7. /*******************************
  8. ** 余额变动:100~199
  9. ** 积分变动:200~299
  10. ** 成长值变动:300~399
  11. ** 佣金变动: 400~499
  12. *******************************/
  13. const admin_add_money = 100;
  14. const admin_reduce_money = 101;
  15. const recharge_money = 102;
  16. const balance_pay_order = 103;
  17. const cancel_order_refund = 104;
  18. const after_sale_refund = 105;
  19. const withdraw_to_balance = 106;
  20. const user_transfer_inc_balance = 107;
  21. const user_transfer_dec_balance = 108;
  22. const integral_order_dec_balance = 109;
  23. const integral_order_inc_balance = 110;
  24. const admin_add_integral = 200;
  25. const admin_reduce_integral = 201;
  26. const sign_in_integral = 202;
  27. const recharge_give_integral = 203;
  28. const order_award_integral = 204;
  29. const register_add_integral = 205;
  30. const invite_add_integral = 206;
  31. const order_deduction_integral = 207;
  32. const cancel_order_refund_integral = 208;
  33. const luck_draw_integral = 209;
  34. const deduct_order_first_integral = 210;
  35. const order_goods_give_integral = 211;
  36. const consume_award_integral = 212;
  37. const pay_integral_order = 213;
  38. const cancel_integral_order = 214;
  39. const admin_add_growth = 300;
  40. const admin_reduce_growth = 301;
  41. const sign_give_growth = 302;
  42. const recharge_give_growth = 303;
  43. const order_give_growth = 304;//下单赠送成长值
  44. const register_give_growth = 305;//注册赠送成长值
  45. const withdraw_dec_earnings = 400;//提现扣减佣金
  46. const withdraw_back_earnings = 401;//提现被拒绝返回佣金
  47. const distribution_inc_earnings = 402;//分销订单结算增加佣金
  48. const admin_inc_earnings = 403; //后台增加佣金
  49. const admin_reduce_earnings = 404; //后台减少佣金
  50. const money_change = [ //余额变动类型
  51. self::admin_add_money,self::admin_reduce_money,self::recharge_money,self::balance_pay_order,self::cancel_order_refund,self::after_sale_refund
  52. , self::withdraw_to_balance,self::user_transfer_inc_balance, self::user_transfer_dec_balance, self::integral_order_dec_balance, self::integral_order_inc_balance
  53. ];
  54. const integral_change = [ //积分变动类型
  55. self::admin_add_integral,self::admin_reduce_integral,self::sign_in_integral,self::recharge_give_integral,self::order_award_integral,self::invite_add_integral
  56. , self::order_deduction_integral,self::register_add_integral,self::cancel_order_refund_integral,self::luck_draw_integral,self::deduct_order_first_integral
  57. , self::order_goods_give_integral,self::consume_award_integral, self::pay_integral_order,self::cancel_integral_order
  58. ];
  59. const growth_change = [ //成长值变动类型
  60. self::admin_add_growth,self::admin_reduce_growth,self::recharge_give_growth,self::sign_give_growth, self::order_give_growth,self::register_give_growth
  61. ];
  62. /**
  63. * 佣金变动类型
  64. */
  65. const earnings_change = [
  66. self::withdraw_dec_earnings, //提现扣减
  67. self::withdraw_back_earnings, //提现拒绝返还
  68. self::distribution_inc_earnings, //订单结算增加
  69. self::admin_inc_earnings, //后台增加佣金
  70. self::admin_reduce_earnings, //后台减少佣金
  71. ];
  72. public static function getAcccountDesc($from = true){
  73. $desc = [
  74. self::admin_add_money => '系统增加余额',
  75. self::admin_reduce_money => '系统扣减余额',
  76. self::recharge_money => '用户充值余额',
  77. self::admin_add_integral => '系统增加积分',
  78. self::admin_reduce_integral => '系统扣减积分',
  79. self::sign_in_integral => '每日签到赠送积分',
  80. self::recharge_give_integral => '充值赠送积分',
  81. self::order_award_integral => '下单赠送积分',
  82. self::order_deduction_integral => '下单积分抵扣',
  83. self::register_add_integral => '注册赠送积分',
  84. self::invite_add_integral => '邀请会员赠送积分',
  85. self::admin_add_growth => '系统增加成长值',
  86. self::admin_reduce_growth => '系统扣减成长值',
  87. self::sign_give_growth => '每日签到赠送成长值',
  88. self::recharge_give_growth => '充值赠送成长值',
  89. self::balance_pay_order => '下单扣减余额',
  90. self::cancel_order_refund => '取消订单退回余额',
  91. self::after_sale_refund => '售后退回余额',
  92. self::withdraw_to_balance => '佣金提现',
  93. self::withdraw_dec_earnings => '提现扣减佣金',
  94. self::withdraw_back_earnings => '拒绝提现返还佣金',
  95. self::distribution_inc_earnings => '订单结算获得佣金',
  96. self::cancel_order_refund_integral => '取消订单退回积分',
  97. self::deduct_order_first_integral => '扣除首单积分',
  98. self::luck_draw_integral => '积分抽奖中奖',
  99. self::order_goods_give_integral => '购买商品赠送积分',
  100. self::user_transfer_inc_balance => '会员转账(收入方)',
  101. self::user_transfer_dec_balance => '会员转账(支出方)',
  102. self::order_give_growth => '下单赠送成长值',
  103. self::register_give_growth => '注册赠送成长值',
  104. self::consume_award_integral => '消费赠送积分',
  105. self::pay_integral_order => '支付积分商城订单',
  106. self::integral_order_inc_balance => '积分商城订单',
  107. self::integral_order_dec_balance => '余额支付积分订单',
  108. self::cancel_integral_order => '取消积分订单返回积分',
  109. self::admin_inc_earnings => '后台增加佣金',
  110. self::admin_reduce_earnings => '后台减少佣金',
  111. ];
  112. if($from === true){
  113. return $desc;
  114. }
  115. return $desc[$from] ?? '';
  116. }
  117. //返回变动类型
  118. public static function getChangeType($source_type){
  119. $type = '';
  120. if(in_array($source_type,self::money_change)){
  121. $type = 'money';
  122. }
  123. if(in_array($source_type,self::integral_change)){
  124. $type = 'integral';
  125. }
  126. if(in_array($source_type,self::growth_change)){
  127. $type = 'growth';
  128. }
  129. if(in_array($source_type,self::earnings_change)){
  130. $type = 'earnings';
  131. }
  132. return $type;
  133. }
  134. public static function getRemarkDesc($from,$source_sn,$remark =''){
  135. return $remark;
  136. }
  137. public static function getChangeAmountFormatAttr($value,$data){
  138. $amount = $value;
  139. if(!in_array($data['source_type'],self::money_change) && !in_array($data['source_type'],self::earnings_change)){
  140. $amount = intval($value);
  141. }
  142. if($data['change_type'] == 1){
  143. return '+'.$amount;
  144. }
  145. return '-'.$amount;
  146. }
  147. public static function getSourceTypeAttr($value,$data){
  148. return self::getAcccountDesc($value);
  149. }
  150. public function getCreateTimeFormatAttr($value, $data)
  151. {
  152. return date('Y-m-d H:i:s', $value);
  153. }
  154. /**
  155. * @notes 佣金变动 [400 => 'xxxxx']
  156. * @return array
  157. * @author 段誉
  158. * @date 2022/3/16 10:17
  159. */
  160. public static function getEarningsChange()
  161. {
  162. $earnings = [];
  163. foreach (self::earnings_change as $item) {
  164. $earnings[$item] = self::getAcccountDesc($item);
  165. }
  166. return $earnings;
  167. }
  168. }