<?php


namespace app\common\logic;

use app\common\enum\OrderEnum;
use app\common\model\store_order\StoreOrder;
use app\common\model\store_order_cart_info\StoreOrderCartInfo;
use app\common\model\system_store\SystemStore;
use app\common\model\user\User;
use app\common\model\user\UserAddress;
use app\common\model\user_sign\UserSign;
use think\facade\Db;

/**
 * vip结算逻辑
 * Class VipLogic
 * @package app\common\logic
 */
class VipLogic  extends BaseLogic
{


    public static function dealVipAmount($order,$pay_type =1, $transaction_id = 0)
    {
        $detail = StoreOrderCartInfo::where('oid',$order['id'])->select()->toArray();
        $total_vip = 0;
        foreach ($detail as $value){
            $total_vip +=$value['cart_info']['vip_frozen_price'];
        }
        $data=[
            'order_id' => $order['id'],
            'transaction_id' => $transaction_id??0,
            'order_sn' =>$order['order_id'],
            'user_id' => $order['uid'],
//            'financial_type' => $financialType,
            'number' => $total_vip,
            'pay_type' => $pay_type??1,
            'status' => 0,
            'store_id' => $order['store_id'],
            'staff_id' => $order['staff_id'],
            'create_time'=>time()
        ];
        Db::name('vip_flow')->insert($data);
        return true;
    }
    
}