StoreRefundOrder.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. namespace app\common\model\store\order;
  3. use app\common\model\BaseModel;
  4. use app\common\model\system\merchant\Merchant;
  5. use app\common\model\user\User;
  6. class StoreRefundOrder extends BaseModel
  7. {
  8. public static function tablePk(): ?string
  9. {
  10. return 'refund_order_id';
  11. }
  12. public static function tableName(): string
  13. {
  14. return 'store_refund_order';
  15. }
  16. public function getPicsAttr($val)
  17. {
  18. return $val ? explode(',', $val) : [];
  19. }
  20. public function setPicsAttr($val)
  21. {
  22. return $val ? implode(',', $val) : '';
  23. }
  24. public function refundProduct()
  25. {
  26. return $this->hasMany(StoreRefundProduct::class, 'refund_order_id', 'refund_order_id');
  27. }
  28. public function merchant()
  29. {
  30. return $this->hasOne(Merchant::class, 'mer_id', 'mer_id');
  31. }
  32. public function user()
  33. {
  34. return $this->hasOne(User::class, 'uid', 'uid');
  35. }
  36. public function order()
  37. {
  38. return $this->hasOne(StoreOrder::class, 'order_id', 'order_id');
  39. }
  40. public function searchDataAttr($query, $value)
  41. {
  42. return getModelTime($query, $value);
  43. }
  44. public function getAutoRefundTimeAttr()
  45. {
  46. $merAgree = systemConfig('mer_refund_order_agree') ?: 7;
  47. return strtotime('+' . $merAgree . ' day', strtotime($this->status_time));
  48. }
  49. public function getCombineRefundParams()
  50. {
  51. return [
  52. 'sub_mchid' => $this->merchant->sub_mchid,
  53. 'order_sn' => $this->order->order_sn,
  54. 'refund_order_sn' => $this->refund_order_sn,
  55. 'refund_price' => $this->refund_price,
  56. 'pay_price' => $this->order->pay_price
  57. ];
  58. }
  59. }