示例#1
0
 public function express($express_name, $express_no, $transaction = TRUE)
 {
     $transaction && DB::beginTransaction();
     $order = static::where($this->getKeyName(), $this->getKey())->lockForUpdate()->first();
     if ($order->status != static::PAID) {
         $transaction && DB::rollback();
         return false;
     }
     $express = OrderExpress::where($this->getKeyName(), $this->getKey())->lockForUpdate()->first();
     $express->update(['express_name' => $express_name, 'no' => $express_no]);
     $order->status = static::DELIVERED;
     $order->save();
     $transaction && DB::commit();
     return true;
 }