1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
 
namespace app\api\model\plus\operations;
use app\common\model\plus\operations\Operations as OperationsModel;
/**
 * 运营中心用户模型
 */
class Operations extends OperationsModel
{
    public static function getOrderOperations($order)
    {
        $model = new self;
        $province_id=0;
        $city_id=0;
        $area_id=0;
        if ($order['delivery_type']['value'] == 10){
            $province_id=$order['address']['province_id'];
            $city_id=$order['address']['city_id'];
            $area_id=$order['address']['region_id'];
        }else if($order['delivery_type']['value'] == 20||$order['delivery_type']['value'] == 40){
            $province_id=$order['extractStore']['province_id'];
            $city_id=$order['extractStore']['city_id'];
            $area_id=$order['extractStore']['region_id'];
        }
        $province=$model->where('province_id', $province_id)->where(['operations_level'=>1])->find();
        $city=$model->where('city_id', $city_id)->where(['operations_level'=>2])->find();
        $area=$model->where('area_id', $area_id)->where(['operations_level'=>3])->find();
        $data=['province_user_id'=>0,'city_user_id'=>0,'area_user_id'=>0];
        if ($province){
            $data['province_user_id']=$province['user_id'];
        }
        if($city){
            $data['city_user_id']=$city['user_id'];
        }
        if($area){
            $data['area_user_id']=$area['user_id'];
        }
        return $data;
    }
    /**
     * 资金冻结
     */
    public function freezeMoney($money)
    {
        return $this->save([
            'money' => $this['money'] - $money,
            'freeze_money' => $this['freeze_money'] + $money,
        ]);
    }
}