| New file |
| | |
| | | <?php |
| | | |
| | | namespace app\common\model\plus\release; |
| | | |
| | | use app\common\enum\order\OrderPayTypeEnum; |
| | | use app\common\model\BaseModel; |
| | | |
| | | |
| | | /** |
| | | * 订单模型 |
| | | */ |
| | | class Order extends BaseModel |
| | | { |
| | | protected $name = 'release_order'; |
| | | protected $pk = 'id'; |
| | | |
| | | /** |
| | | * 追加字段 |
| | | * @var string[] |
| | | */ |
| | | protected $append = [ |
| | | 'state_text', |
| | | ]; |
| | | |
| | | /** |
| | | * 需求用户 |
| | | * @return \think\model\relation\BelongsTo |
| | | */ |
| | | public function demanduser() |
| | | { |
| | | return $this->belongsTo('app\common\model\user\User','demand_user_id','user_id'); |
| | | } |
| | | |
| | | /** |
| | | * 供应用户 |
| | | * @return \think\model\relation\BelongsTo |
| | | */ |
| | | public function supplyuser() |
| | | { |
| | | return $this->belongsTo('app\common\model\user\User','supply_user_id','user_id'); |
| | | } |
| | | |
| | | /** |
| | | * 关联项目 |
| | | * @return \think\model\relation\hasMany |
| | | */ |
| | | public function project() |
| | | { |
| | | return $this->belongsTo('app\common\model\plus\release\Project','project_id','project_id'); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 订单状态文字描述 |
| | | * @param $value |
| | | * @param $data |
| | | * @return string |
| | | */ |
| | | public function getStateTextAttr($value, $data) |
| | | { |
| | | if($data['order_status'] == 20){ |
| | | return '已取消'; |
| | | } |
| | | // 订单状态 |
| | | if ($data['pay_status'] == 10 && $data['pay_type'] == 40) { |
| | | return '待确认支付'; |
| | | }else if ($data['pay_status'] == 10 && $data['pay_type'] != 40) { |
| | | return '未付款'; |
| | | }else if($data['pay_status'] == 20 && $data['order_status'] == 10){ |
| | | return '进行中'; |
| | | }else if($data['pay_status'] == 20 && $data['order_status'] == 30){ |
| | | return '已完成'; |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | /** |
| | | * 付款状态 |
| | | * @param $value |
| | | * @return array |
| | | */ |
| | | public function getPayTypeAttr($value) |
| | | { |
| | | if(empty($value)){ |
| | | return ['text' => '', 'value' => 0]; |
| | | } |
| | | return ['text' => OrderPayTypeEnum::data()[$value]['name'], 'value' => $value]; |
| | | } |
| | | |
| | | /** |
| | | * 详情 |
| | | */ |
| | | public static function detail($id) |
| | | { |
| | | $model = new static(); |
| | | return $model->with(['demanduser','supplyuser',"project"])->find($id); |
| | | } |
| | | |
| | | /** |
| | | * 详情 |
| | | */ |
| | | public static function getDetail($order_no) |
| | | { |
| | | $model = new static(); |
| | | return $model->with(["project"])->where("order_no",'=',$order_no)->find(); |
| | | } |
| | | |
| | | } |