39 lines
1.4 KiB
PHP
39 lines
1.4 KiB
PHP
<?php
|
|
namespace app\model;
|
|
|
|
use think\facade\Db;
|
|
|
|
class Backs extends base
|
|
{
|
|
public function into() {
|
|
return $this->belongsTo(Admins::class, 'admin_id')->visible(['name','username','avatar']);
|
|
}
|
|
|
|
public function outto() {
|
|
return $this->belongsTo(Admins::class, 'admin')->visible(['name','username','avatar']);
|
|
}
|
|
|
|
public function orders(){
|
|
return $this->belongsTo(Orders::class, 'order_id');
|
|
}
|
|
|
|
public static function change(Backs $item) {
|
|
Db::transaction(function() use ($item) {
|
|
Backs::where('id', $item->id)->where('status', 0)->update(['status' => 1]);
|
|
Orders::where('id', $item->order_id)->where('admin_id', $item->admin)->update(['admin_id'=> $item->admin_id]);
|
|
Logs::todo($item->order_id, $item->admin, 8); //转单
|
|
$other = Backs::where('order_id', $item->order_id)->where('status', 0)->lock()->select();
|
|
foreach($other as $o) {
|
|
Backs::where('id', $o->id)->where('status', 0)->update(['status' => 3]);
|
|
Logs::todo($o->order_id, $o->admin, 10); //取消其他转单需求
|
|
}
|
|
});
|
|
}
|
|
|
|
public static function refuse(Backs $item) {
|
|
Db::transaction(function() use ($item) {
|
|
Backs::where('id', $item->id)->where('status', 0)->update(['status' => 2]);
|
|
Logs::todo($item->order_id, $item->admin, 9); //拒绝请求
|
|
});
|
|
}
|
|
} |