'timestamp', 'close_time' => 'timestamp', ]; /** * 支付状态字段转化 * @param $value * @param $data * @return mixed */ public function getStatusNameAttr($value, $data) { if (empty($data['status'])) return ''; return RefundDict::getStatus()[$data['status']] ?? ''; } /** * 支付方式字段转化 * @param $value * @param $data * @return mixed */ public function getTypeNameAttr($value, $data) { if (empty($data['type'])) return ''; return PayDict::getPayType()[$data['type']]['name'] ?? ''; } /** * 退款方式 * @param $value * @param $data * @return mixed|string * */ public function getRefundTypeNameAttr($value, $data) { if (empty($data['refund_type'])) return ''; return RefundDict::getType()[$data['refund_type']] ?? ''; } /** * 创建时间搜索器 * @param $query * @param $value * @param $data */ public function searchCreateTimeAttr($query, $value, $data) { $start_time = empty($value[0]) ? 0 : strtotime($value[0]); $end_time = empty($value[1]) ? 0 : strtotime($value[1]); if ($start_time > 0 && $end_time > 0) { $query->whereBetweenTime('create_time', $start_time, $end_time); } else if ($start_time > 0 && $end_time == 0) { $query->where([['create_time', '>=', $start_time]]); } else if ($start_time == 0 && $end_time > 0) { $query->where([['create_time', '<=', $end_time]]); } } /** * 查询交易流水号 * @param $query * @param $value * @return void */ public function searchOutTradeNoAttr($query, $value) { if (!empty($value)) { $query->whereLike([['out_trade_no', '%'.$value.'%']]); } } /** * 退款号查询 * @param $query * @param $value * @return void */ public function searchRefundNoAttr($query, $value) { if (!empty($value)) { $query->whereLike([['refund_no', '%'.$value.'%']]); } } /** * 查询交易状态 * @param $query * @param $value * @return void */ public function searchStatusAttr($query, $value) { if ($value != '') { $query->where([['status', '=', $value]]); } } }