RefundProcessLog.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * Name: 芸众商城系统
  5. * Author: 广州市芸众信息科技有限公司
  6. * Profile: 广州市芸众信息科技有限公司位于国际商贸中心的广州,专注于移动电子商务生态系统打造,拥有芸众社交电商系统、区块链数字资产管理系统、供应链管理系统、电子合同等产品/服务。官网 :www.yunzmall.com www.yunzshop.com
  7. * Date: 2021/12/23
  8. * Time: 14:14
  9. */
  10. namespace app\common\models\refund;
  11. use app\common\models\BaseModel;
  12. class RefundProcessLog extends BaseModel
  13. {
  14. protected $table = 'yz_order_refund_process_log';
  15. protected $fillable = [];
  16. protected $guarded = ['id'];
  17. protected $hidden = ['updated_at',];
  18. protected $appends = ['operate_name'];
  19. protected $casts = [
  20. 'detail' => 'json',
  21. 'remark' => 'json',
  22. ];
  23. const OPERATOR_SHOP = 0; //操作者 商城
  24. const OPERATOR_MEMBER = 1; //操作者 会员
  25. const OPERATE_CANCEL = -2;
  26. const OPERATE_REJECT = -1;
  27. const OPERATE_APPLY = 0;
  28. const OPERATE_AGREE_APPLY = 1;
  29. const OPERATE_USER_SEND_BACK = 2;
  30. const OPERATE_SHOP_BATCH_RESEND = 3;
  31. const OPERATE_SHOP_RESEND = 4;
  32. const OPERATE_REFUND_COMPLETE = 6;
  33. const OPERATE_REFUND_CONSENSUS = 7;
  34. const OPERATE_APPLY_SHOP = 8;
  35. //其他操作从10开启,10以下为退款表状态
  36. const OPERATE_CHANGE_APPLY = 10;
  37. const OPERATE_CHANGE_AMOUNT = 11;
  38. const OPERATE_EDIT = 12;
  39. /**
  40. * @param RefundApply $refund
  41. * @param int $operator
  42. * @return static
  43. */
  44. public static function logInstance(RefundApply $refund, $operator = 0)
  45. {
  46. $operator_id = $operator == static::OPERATOR_MEMBER ? $refund->order->uid : \YunShop::app()->uid;
  47. $processLog = new static([
  48. 'refund_id' => $refund->id,
  49. 'order_id' => $refund->order->id,
  50. 'operator' => $operator,
  51. 'operator_id' => $operator_id?:0,
  52. ]);
  53. return $processLog;
  54. }
  55. /**
  56. *
  57. * @param array $detail
  58. * @param array $remark
  59. */
  60. public function saveLog($detail, $remark = [])
  61. {
  62. $this->setAttribute('detail', $detail);
  63. $this->setAttribute('remark', $remark);
  64. return $this->save();
  65. }
  66. public function getOperateNameAttribute()
  67. {
  68. return $this->getOperateNameComment($this->attributes['operate_type']);
  69. }
  70. public function getOperateNameComment($attribute)
  71. {
  72. return isset($this->operateComment()[$attribute]) ? $this->operateComment()[$attribute] : "未知类型";
  73. }
  74. public function operateComment()
  75. {
  76. return [
  77. self::OPERATE_CANCEL => '用户关闭申请',
  78. self::OPERATE_REJECT => '商家驳回申请',
  79. self::OPERATE_APPLY => '用户发起申请',
  80. self::OPERATE_AGREE_APPLY => '商家同意申请',
  81. self::OPERATE_USER_SEND_BACK => '用户已退货,等待商家收货',
  82. self::OPERATE_SHOP_BATCH_RESEND => '商家分批发货,等待买家收货',
  83. self::OPERATE_SHOP_RESEND => '商家已发货,等待买家收货',
  84. self::OPERATE_REFUND_COMPLETE => '售后完成',
  85. self::OPERATE_REFUND_CONSENSUS => '商家手动完成退款',
  86. self::OPERATE_APPLY_SHOP => '商家操作退款',
  87. self::OPERATE_CHANGE_APPLY => '用户修改申请',
  88. self::OPERATE_CHANGE_AMOUNT => '商家修改退款金额',
  89. self::OPERATE_EDIT => '商家编辑售后',
  90. ];
  91. }
  92. }