Refund.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. /**
  5. * 短信验证码
  6. */
  7. class Refund Extends Model
  8. {
  9. protected $name='order_info_refund';
  10. const REFUND_ING=10;
  11. const REFUND_PASS=20;
  12. const REFUND_REJECT=30;
  13. const REFUND_CANCEL=40;
  14. public static $refundStatus=[
  15. self::REFUND_ING=>'申请处理中',
  16. self::REFUND_PASS=>'申请通过',
  17. self::REFUND_REJECT=>'申请驳回',
  18. self::REFUND_CANCEL=>'已取消',
  19. ];
  20. /**
  21. * @return string[]
  22. */
  23. public static function getRefundStatus(): array
  24. {
  25. return self::$refundStatus;
  26. }
  27. const REFUND_TYPE_MONEY=1;
  28. const REFUND_TYPE_ALL=2;
  29. const REFUND_TYPE_GOODS=3;
  30. public static $refundTypes=[
  31. self::REFUND_TYPE_MONEY=>'退款',
  32. self::REFUND_TYPE_ALL=>'退款退货',
  33. self::REFUND_TYPE_GOODS=>'仅退货',
  34. ];
  35. /**
  36. * @return string[]
  37. */
  38. public static function getRefundTypes(): array
  39. {
  40. return self::$refundTypes;
  41. }
  42. protected $autoWriteTimestamp=true;
  43. public function allowCancel(){
  44. return in_array($this['refund_status'],[
  45. self::REFUND_ING,
  46. ]);
  47. }
  48. public function makeCancel(){
  49. $this['refund_status']=self::REFUND_CANCEL;
  50. $this->save();
  51. OrderInfo::where('id',$this['order_info_id'])->update([
  52. 'refund_id'=>null,
  53. ]);
  54. }
  55. public function allowAudit(){
  56. return $this['refund_status']==self::REFUND_ING;
  57. }
  58. public function makeAudit($pass){
  59. if($pass){
  60. }else{
  61. }
  62. }
  63. protected static function init()
  64. {
  65. self::beforeInsert(function (self $refund){
  66. $refund['refund_status']=self::REFUND_ING;
  67. });
  68. }
  69. }