<?php

namespace app\controller\Order;

use Overtrue\Pinyin\Pinyin;
use think\facade\Db;

class RefundRecord
{
    public function RefundRecord($openid){
        $area = Db::table('user')->where('openid',$openid)->value('area');
        $pinyin = new Pinyin();
        $s = $pinyin->sentence($area);
        $s = strtr($s,array(' '=>''));
        $table_refund = 'refund_'.$s;
        $message = Db::table($table_refund)->where('openid',$openid)->order('create_time desc')->select()->toArray();
        for($i=0;$i<count($message);$i++){
            $message[$i]['refund_total'] = round($message[$i]['refund_total']/100,2);
            if ($message[$i]['status']=='SUCCESS'){
                $message[$i]['status'] = '退款成功';
            }elseif ($message[$i]['status']=='PROCESSING'){
                $message[$i]['status'] = '退款处理中';
            }elseif ($message[$i]['status']=='ABNORMAL'){
                $message[$i]['status'] = '退款异常';
            }elseif ($message[$i]['status']=='CLOSED'){
                $message[$i]['status'] = '退款关闭';
            }
        }
        return json($message);
    }
}