应用场景:目前的版本中,用户用余额支付下单是不会在个人充值记录里面显示的,个人希望用户清楚的知道余额的消费记录,所以进行如下改良:

1。添加变量:
application/extra/global.php中找到pay_cause_type_arr 增加

'pay_cause_type_arr' => array(
        0   => '升级消费',
        1   => '账户充值',
        2   => '产品消费',
        // 3   => '后续添加',
    ),

2。控制器中方法:
application/user/controller/Pay.php中找到余额支付balance_payment

在 if (!empty($users_id)) { 内加上

 // 数据添加到订单表
                        $pay_cause_type_arr = Config::get('global.pay_cause_type_arr');
                        $time = getTime();
                        $cause_type = 2;
                        $order_number = date('Ymd') . $time . rand(10,100); //订单生成规则
                        $data = [
                            'users_id'      => $this->users_id,
                            'money'         => $Data['order_amount'],
                            'users_money'   => '',
                            'cause'         => $pay_cause_type_arr[$cause_type],
                            'cause_type'    => $cause_type,
                            'status'        => 2,
                            'pay_details'   => '',
                            'order_number'  => $order_number,
                            'lang'          => $this->home_lang,
                            'add_time'      => $time,
                            'update_time'   => $time,
                        ];
                        $this->users_money_db->add($data);

3。最后在模版列表中改一下负值
pay_consumer_details.htm 中把判断改成消费-值