RefundCompensate.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
  8. // +----------------------------------------------------------------------
  9. // | Author: 萤火科技 <admin@yiovo.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types = 1);
  12. namespace app\common\model;
  13. use app\common\model\store\Setting;
  14. use app\common\model\RefundCompensateHis;
  15. use app\common\enum\order\refund\RefundType as RefundTypeEnum;
  16. use app\common\enum\order\refund\AuditStatus as AuditStatusEnum;
  17. use app\common\enum\order\refund\RefundStatus as RefundStatusEnum;
  18. use app\common\enum\order\refund\FinanceRefundStatus as FinanceRefundStatusEnum;
  19. /**
  20. * 售后单补偿单模型
  21. * Class OrderRefund
  22. * @package app\common\model\wxapp
  23. */
  24. class RefundCompensate extends BaseModel
  25. {
  26. // 定义表名
  27. protected $name = 'refund_compensate';
  28. // 定义主键
  29. protected $pk = 'id';
  30. // const TYPE =[10=>'退货退款',20=>'不退货退款',30=>'未发货退款'];
  31. const FINANCE_REFUND =[0=>'待退款',10=>'已退款'];
  32. /**
  33. * 追加字段
  34. * @var array
  35. */
  36. protected $append = [
  37. // 'state_text', // 售后单状态
  38. // 'type_text',
  39. // 'finance_refund_text'
  40. ];
  41. // public function getTypeTextAttr($value,$data){
  42. // return self::TYPE[$data['type']]??'';
  43. // }
  44. public function getFinanceRefundTextAttr($value,$data){
  45. return self::FINANCE_REFUND[$data['finance_refund']]??'';
  46. }
  47. // /**
  48. // * 关联门店表
  49. // * @return \think\model\relation\BelongsTo
  50. // */
  51. // public function shops()
  52. // {
  53. // $module = self::getCalledModule();
  54. // return $this->belongsTo("app\\{$module}\\model\\shop\\Shops", 'shop_id');
  55. // }
  56. // /**
  57. // * 关联用户表
  58. // * @return \think\model\relation\BelongsTo
  59. // */
  60. // public function user()
  61. // {
  62. // return $this->belongsTo('User');
  63. // }
  64. /**
  65. * 关联记录
  66. * @return \think\model\relation\BelongsTo
  67. */
  68. public function his()
  69. {
  70. return $this->hasMany('RefundCompensateHis','refund_compensate_id','id');
  71. }
  72. /**
  73. * 关联订单主表
  74. * @return \think\model\relation\BelongsTo
  75. */
  76. public function orderData()
  77. {
  78. return $this->belongsTo('Order');
  79. }
  80. /**
  81. * 关联单个订单商品表
  82. * @return \think\model\relation\BelongsTo
  83. */
  84. public function orderGoods()
  85. {
  86. return $this->belongsTo('OrderGoods')->withoutField(['content']);
  87. }
  88. // /**
  89. // * 关联全部订单商品
  90. // */
  91. // public function orderGoodsAll()
  92. // {
  93. // return $this->hasMany('OrderGoods', 'order_id', 'order_id')->withoutField(['content']);
  94. // }
  95. // /**
  96. // * 关联核销人用户
  97. // * @return \think\model\relation\BelongsTo
  98. // */
  99. // public function hxUser()
  100. // {
  101. // $module = self::getCalledModule();
  102. // return $this->belongsTo("app\\{$module}\\model\\User", 'hx_refund_user_id')->field('user_id,mobile,nick_name');
  103. // }
  104. /**
  105. * 关联图片记录表
  106. * @return \think\model\relation\HasMany
  107. */
  108. // public function images()
  109. // {
  110. // return $this->hasMany('OrderRefundImage');
  111. // }
  112. /**
  113. * 获取凭证图片
  114. */
  115. public function getImagesAttr($value)
  116. {
  117. if($value){
  118. $arr = array_map(function($v){
  119. $setting = Setting:: getItem('storage',10001);
  120. $oss_domain = $setting['engine']['aliyun']['domain']??'';
  121. return (stripos($v,"http") === false) ? $oss_domain.'/'.$v : $v;
  122. },explode(',',$value));
  123. return $arr;
  124. }
  125. return [];
  126. }
  127. /**
  128. * 存凭证图片
  129. */
  130. public function setImagesAttr($value)
  131. {
  132. if($value&&is_array($value)){
  133. return implode(',',$value);
  134. }
  135. return $value;
  136. }
  137. // /**
  138. // * 关联物流公司表
  139. // * @return \think\model\relation\BelongsTo
  140. // */
  141. // public function express()
  142. // {
  143. // return $this->belongsTo('Express');
  144. // }
  145. // /**
  146. // * 关联用户表
  147. // * @return \think\model\relation\HasOne
  148. // */
  149. // public function address()
  150. // {
  151. // return $this->hasOne('OrderRefundAddress');
  152. // }
  153. /**
  154. * 售后单详情
  155. * @param array|int $where
  156. * @param array $with
  157. * @return null|static
  158. */
  159. public static function detail($where, array $with = [])
  160. {
  161. return static::get($where, $with);
  162. }
  163. // /**
  164. // * 退款成功时间
  165. // * @param $value
  166. // * @return false|string
  167. // */
  168. // public function getRefundSuccTimeAttr($value)
  169. // {
  170. // return format_time($value);
  171. // }
  172. // /**
  173. // * 门店操作退款时间
  174. // * @param $value
  175. // * @return false|string
  176. // */
  177. // public function getHxRefundTimeAttr($value)
  178. // {
  179. // return format_time($value);
  180. // }
  181. }