Exemplo n.º 1
0
 /**
  * 迈豆充值
  *
  * @param \App\Models\Customer $customer
  * @param string $action
  * @param int $value
  * @return bool
  */
 protected function recharge(Customer $customer, $action, $value = 1)
 {
     $beanRate = BeanRate::where('action_en', $action)->firstOrFail();
     $result = $beanRate->rate * $value;
     $this->update($customer, $action, $result);
     $bean = new CustomerBean();
     $bean->customer_id = $customer->id;
     $bean->bean_rate_id = $beanRate->id;
     $bean->value = $value;
     $bean->result = $beanRate->rate * $value;
     return $bean->save();
 }
Exemplo n.º 2
0
 protected function persist()
 {
     $bean_rate = BeanRate::where('action_en', '=', $this->name)->firstOrFail();
     $this->customer->beans()->create(['bean_rate_id' => $bean_rate->id, 'value' => 1, 'result' => $this->beans, 'before' => $this->before, 'after' => $this->after]);
 }