Beispiel #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();
 }
 public function beans($id)
 {
     $customer = Customer::findOrFail($id);
     return response()->json(['success' => true, 'data' => ['beans' => CustomerBean::where('customer_id', $customer->id)->with('rate')->orderBy('id', 'desc')->paginate(5)]]);
 }