Withdraw.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?php
  2. namespace app\frontend\modules\finance\models;
  3. use app\common\models\Income;
  4. use Illuminate\Support\Facades\Config;
  5. class Withdraw extends \app\common\models\Withdraw
  6. {
  7. public $Incomes;
  8. protected $appends = ['incomes', 'pay_way_name'];
  9. public static function getWithdrawLog($status)
  10. {
  11. $withdrawModel = self::select('id', 'type_name', 'amounts', 'poundage', 'status', 'created_at');
  12. $withdrawModel->uniacid();
  13. $withdrawModel->where('member_id', \YunShop::app()->getMemberId());
  14. if ($status != '') {
  15. $withdrawModel->where('status', $status);
  16. }
  17. return $withdrawModel;
  18. }
  19. public static function getWithdrawInfoById($id)
  20. {
  21. $withdrawModel = self::select('id', 'withdraw_sn', 'pay_way', 'type', 'type_id', 'type_name', 'amounts', 'poundage', 'status', 'created_at', 'actual_amounts', 'actual_poundage','actual_servicetax','servicetax');
  22. $withdrawModel->uniacid();
  23. $withdrawModel->where('id', $id);
  24. return $withdrawModel;
  25. }
  26. public function getIncomesAttribute()
  27. {
  28. if (!isset($this->Incomes)) {
  29. $configs = \app\backend\modules\income\Income::current()->getItems();
  30. foreach ($configs as $key => $config) {
  31. if ($config['class'] === $this->type) {
  32. $incomes = Income::getIncomeByIds($this->type_id)
  33. ->select('id', 'incometable_type','incometable_id')
  34. ->get();
  35. foreach ($incomes as $key => $income) {
  36. $relation=$income->incometable;
  37. if($relation){
  38. $this->Incomes[$key] = $relation->toArray();
  39. }
  40. }
  41. }
  42. }
  43. }
  44. return $this->Incomes;
  45. }
  46. /**
  47. * 验证提现订单号唯一性
  48. *
  49. * @param $withdrawSN
  50. * @return mixed
  51. * @Author yitian */
  52. public static function validatorOrderSn($withdrawSN)
  53. {
  54. return self::uniacid()->where('withdraw_sn', $withdrawSN)->first();
  55. }
  56. /**
  57. * 定义字段名
  58. * @return array
  59. * @Author yitian */
  60. public function atributeNames() {
  61. return [
  62. 'withdraw_sn' => "提现订单号",
  63. 'uniacid' => "公众号ID",
  64. 'member_id' => '会员ID',
  65. 'type' => '提现类型',
  66. //'type_id' => '充值订单号不能为空',
  67. 'type_name' => '状态',
  68. 'amounts' => "提现金额",
  69. //'poundage' => "会员ID不能为空",
  70. //'poundage_rate' => "会员ID不能为空",
  71. //'pay_way' => "提现类型",
  72. //'status' => "会员ID不能为空",
  73. //'audit_at' => "会员ID不能为空",
  74. //'pay_at' => "会员ID不能为空",
  75. //'arrival_at' => "会员ID不能为空",
  76. //'actual_amounts' => "会员ID不能为空",
  77. //'actual_poundage' => "会员ID不能为空"
  78. ];
  79. }
  80. /**
  81. * 字段规则
  82. * @return array
  83. * @Author yitian */
  84. public function rules()
  85. {
  86. return [
  87. 'withdraw_sn' => "required",
  88. 'uniacid' => "required|numeric",
  89. 'member_id' => 'required|numeric',
  90. 'type' => 'required',
  91. //'type_id' => '',
  92. 'type_name' => 'required',
  93. 'amounts' => "numeric|regex:/^(?!0+(?:\.0+)?$)\d+(?:\.\d{1,2})?$/",
  94. //'poundage' => "",
  95. //'poundage_rate' => "",
  96. //'pay_way' => "",
  97. //'status' => "",
  98. //'audit_at' => "",
  99. //'pay_at' => "",
  100. //'arrival_at' => "",
  101. //'actual_amounts' => "",
  102. //'actual_poundage' => ""
  103. ];
  104. }
  105. }