OrderService.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  1. <?php
  2. namespace app\api\service;
  3. use app\common\model\ActivityProductModel;
  4. use app\common\model\AdminModel;
  5. use app\common\model\ConfigModel;
  6. use app\common\model\CreditCardConfigModel;
  7. use app\common\model\CustomerModel;
  8. use app\common\model\OrderAnnualFeeModel;
  9. use app\common\model\OrderModel;
  10. use app\common\model\OrderPaymentModel;
  11. use app\common\model\OrderProceedsModel;
  12. use app\common\model\OrderProductModel;
  13. use app\common\model\PaymentChannelModel;
  14. use app\common\model\ProductModel;
  15. use app\common\model\StoreModel;
  16. use app\common\model\StoreProductModel;
  17. use think\facade\Db;
  18. class OrderService extends \app\BaseService
  19. {
  20. private $storeModel;
  21. private $orderModel;
  22. private $productModel;
  23. private $orderAnnualFeeModel;
  24. private $orderPaymentModel;
  25. private $orderProductModel;
  26. private $orderProceedsModel;
  27. private $activityProductModel;
  28. private $storeProductModel;
  29. private $configModel;
  30. private $adminModel;
  31. private $customerModel;
  32. private $paymentChannelModel;
  33. private $creditCardModel;
  34. public function __construct()
  35. {
  36. $this->storeModel = new StoreModel();
  37. $this->orderModel = new OrderModel();
  38. $this->productModel = new ProductModel();
  39. $this->configModel = new ConfigModel();
  40. $this->storeProductModel = new StoreProductModel();
  41. $this->orderAnnualFeeModel = new OrderAnnualFeeModel();
  42. $this->orderPaymentModel = new OrderPaymentModel();
  43. $this->orderProductModel = new OrderProductModel();
  44. $this->orderProceedsModel = new OrderProceedsModel();
  45. $this->activityProductModel = new ActivityProductModel();
  46. $this->adminModel = new AdminModel();
  47. $this->customerModel = new CustomerModel();
  48. $this->paymentChannelModel = new PaymentChannelModel();
  49. $this->creditCardModel = new CreditCardConfigModel();
  50. }
  51. /**
  52. * @param $params
  53. * @param array $store_products_params
  54. * @return \SResult
  55. * @throws \think\db\exception\DataNotFoundException
  56. * @throws \think\db\exception\DbException
  57. * @throws \think\db\exception\ModelNotFoundException
  58. */
  59. public function create($params, array $store_products_params) {
  60. // 客户
  61. $customer = $this->customerModel->findById($params['customer_id']);
  62. if (!$customer)
  63. return $this->fail(lang("The Customer does not exist"));
  64. // 门店
  65. $store = $this->storeModel->findById($params['store_id']);
  66. if (!$store)
  67. return $this->fail(lang("The store does not exist"));
  68. // 顾问 or 老师 ids
  69. $user_ids = [];
  70. // 门店商品ids
  71. $store_product_ids = [];
  72. for ($i = 0; $i < count($store_products_params); $i++) {
  73. $store_products_param = $store_products_params[$i];
  74. $ids = [];
  75. if(isset($store_products_param->adviser_1_id)) array_push($ids, $store_products_param->adviser_1_id);
  76. if(isset($store_products_param->adviser_2_id)) array_push($ids, $store_products_param->adviser_2_id);
  77. if(isset($store_products_param->teacher_id)) array_push($ids, $store_products_param->teacher_id);
  78. $user_ids = array_unique(array_merge($user_ids, $ids));
  79. array_push($store_product_ids, $store_products_param->store_product_id);
  80. }
  81. // Adviser|Teacher
  82. $users = $this->adminModel->findByIds($user_ids)->toArray();
  83. if(count($users) != count($user_ids))
  84. return $this->fail(lang("The Adviser|Teacher does not exist"));
  85. $fmt_users = array_reduce($users, function ($result, $item) {
  86. $result[$item['id']] = $item;
  87. return $result;
  88. }, []);
  89. // 门店商品
  90. $store_products = $this->storeProductModel->fetchRelationsByOrder($store_product_ids)->toArray();
  91. if(count($store_products) != count($store_product_ids))
  92. return $this->fail(lang("The Product does not exist"));
  93. // 商品信息
  94. $products = array_map(function ($p) {
  95. return $p['product'] ? $p['product'] : null;
  96. }, $store_products);
  97. if(in_array(null, $products))
  98. return $this->fail(lang("The Product does not exist"));
  99. $config = $this->configModel->findConfig();
  100. $activityProducts = $this->activityProductModel->fetchByProductIds(array_map(function ($data) {
  101. return $data['id'];
  102. }, $products))->toArray();
  103. $fmt_store_products = [];
  104. foreach ($store_products as &$item) {
  105. $aProducts = array_filter($activityProducts, function ($aProduct) use ($item) {
  106. return $aProduct['product_id'] == $item['product_id'];
  107. });
  108. $res = compare($item['product']['real_price'] ?? 0, $aProducts);
  109. $item['activity'] = $res['item'];
  110. $item['product']['origin_price'] = $item['product']['real_price'];
  111. $item['product']['real_price'] = fixed2Float($res['min_num'] > 0 ? $res['min_num'] : 0);
  112. $sales_tax_rate = $item['product']['sales_tax_rate'] > 0 ? $item['product']['sales_tax_rate'] : $config->sales_tax_rate;
  113. $sales_tax = fixed2Float($sales_tax_rate > 0 && $item['product']['real_price'] > 0 ? ($item['product']['real_price'] * ($sales_tax_rate / 100)) : 0);
  114. $item['product']['sales_tax_rate'] = $sales_tax_rate;
  115. $item['product']['sales_tax'] = $sales_tax;
  116. $fmt_store_products[$item['id']] = $item;
  117. }
  118. $order_products = [];
  119. //项目总额
  120. $rental_amount = 0;
  121. $product_amount = 0;
  122. // 总消费税
  123. $total_sales_tax = 0;
  124. $advisor_1_ids = [];
  125. $product_names = [];
  126. $total_annual_fee = 0;
  127. $order_no = $this->orderModel->genOrderNo($store->id, $store->abbr);
  128. for ($i = 0; $i < count($store_products_params); $i++) {
  129. $store_products_param = $store_products_params[$i];
  130. $store_product = $fmt_store_products[$store_products_param->store_product_id];
  131. if($store_product['now_stock'] < $store_products_param->quantity)
  132. return $this->fail(lang("inventory shortage"));
  133. array_push($advisor_1_ids, $store_products_param->adviser_1_id);
  134. for ($j = 0; $j < $store_products_param->quantity; $j++) {
  135. array_push($product_names, $store_product['product']['name']);
  136. array_push($order_products, [
  137. 'order_id' => 0,
  138. 'order_no' => $order_no,
  139. 'customer_id' => $customer->id,
  140. 'product_id' => $store_product['product']['id'],
  141. 'product_category_id' => $store_product['product']['category_id'],
  142. 'is_serve' => $store_product['product']['is_serve'],
  143. 'store_product_id' => $store_product['id'],
  144. 'product_name' => $store_product['product']['name'],
  145. 'adviser_1_id' => isset($store_products_param->adviser_1_id) ? $store_products_param->adviser_1_id : null,
  146. 'adviser_1_name' => isset($store_products_param->adviser_1_id) ? $fmt_users[$store_products_param->adviser_1_id]['nickname'] : null,
  147. 'adviser_2_id' => isset($store_products_param->adviser_2_id) ? $store_products_param->adviser_2_id : null,
  148. 'adviser_2_name' => isset($store_products_param->adviser_2_id) ? $fmt_users[$store_products_param->adviser_2_id]['nickname'] : null,
  149. 'teacher_id' => isset($store_products_param->teacher_id) ? $store_products_param->teacher_id : null,
  150. 'teacher_name' => isset($store_products_param->teacher_id) ? $fmt_users[$store_products_param->teacher_id]['nickname'] : null,
  151. 'is_upload_numerology' => $store_product['product']['is_upload_numerology'],
  152. 'is_upload' => 0,
  153. 'report' => null,
  154. 'is_gather_annuity' => $store_product['product']['is_gather_annuity'],
  155. 'annuity' => $store_product['product']['annuity'],
  156. 'real_price' => $store_product['product']['real_price'],
  157. 'service_charge' => 0,
  158. 'reduce_price' => $store_product['activity'] ? $store_product['product']['origin_price'] - $store_product['product']['real_price'] : 0,
  159. 'reduce_type' => $store_product['activity'] ? $store_product['activity']['type'] : 0,
  160. 'sales_tax_rate' => $store_product['product']['sales_tax_rate'],
  161. 'sales_tax' => $store_product['product']['sales_tax'],
  162. 'create_time' => time(),
  163. 'update_time' => time(),
  164. ]);
  165. $product_amount += $store_product['product']['real_price'];
  166. $total_sales_tax += $store_product['product']['sales_tax'];
  167. if($store_product['product']['is_gather_annuity'] == 1) {
  168. $total_annual_fee += $store_product['product']['annuity'];
  169. $rental_amount += ($store_product['product']['real_price'] + $store_product['product']['sales_tax'] + $store_product['product']['annuity']);
  170. } else {
  171. $rental_amount += ($store_product['product']['real_price'] + $store_product['product']['sales_tax']);
  172. }
  173. }
  174. }
  175. $order = $this->orderModel->create([
  176. 'no' => $order_no,
  177. 'customer_id' => $customer->id,
  178. 'customer_name' => "{$customer->name_en}|{$customer->name_zh}",
  179. 'obj_names' => join(',',array_unique($product_names)),
  180. 'rental_amount' => $rental_amount,
  181. 'receivable_amount' => $rental_amount,
  182. 'receive_amount' => 0,
  183. 'imposed_amount' => $rental_amount,
  184. 'product_amount' => $product_amount,
  185. 'total_sales_tax' => $total_sales_tax,
  186. 'service_charge_amount' => 0,
  187. 'total_annual_fee' => $total_annual_fee,
  188. 'type' => 2,
  189. 'store_id' => $store->id,
  190. 'advisor_ids' => join(',', $advisor_1_ids),
  191. 'create_time' => time(),
  192. 'update_time' => time()
  193. ]);
  194. foreach ($order_products as &$order_product) $order_product['order_id'] = $order->id;
  195. Db::startTrans();
  196. try {
  197. Db::table('erp_order_product')->insertAll($order_products);
  198. Db::commit();
  199. } catch (\Exception $e) {
  200. Db::rollback();
  201. Db::table('erp_order')->delete($order->id);
  202. return $this->fail(lang($e->getMessage()));
  203. }
  204. return $this->ok($order);
  205. }
  206. /**
  207. * @param $params
  208. * @param $channels
  209. * @return \SResult
  210. * @throws \app\exception\BaseException
  211. * @throws \think\db\exception\DataNotFoundException
  212. * @throws \think\db\exception\DbException
  213. * @throws \think\db\exception\ModelNotFoundException
  214. */
  215. public function payment($params, $channels) {
  216. $order = $this->orderModel->findById($params);
  217. if(!$order)
  218. return $this->fail('订单不存在!');
  219. if($order->type == 1)
  220. return $this->fail('订单状态为历史订单!不支持付款');
  221. // 客户
  222. $customer = $this->customerModel->findById($order->customer_id);
  223. if (!$customer)
  224. return $this->fail(lang("The Customer does not exist"));
  225. $pay_channels = $this->paymentChannelModel->where('is_delete', 0)->select()->toArray();
  226. $fmt_pay_channels = array_reduce($pay_channels, function ($result, $item) {
  227. $result[$item['id']] = $item;
  228. return $result;
  229. },[]);
  230. $credit_card_configs = $this->creditCardModel->findAll()->toArray();
  231. $fmt_credit_card_configs = array_reduce($credit_card_configs, function ($result, $item) {
  232. $result[$item['id']] = $item;
  233. return $result;
  234. },[]);
  235. // 本次总计支付费用
  236. $total_fee = 0;
  237. // 本次信用卡支付手续费
  238. $service_charge = 0;
  239. // 本次御龙币
  240. $zue_coin = 0;
  241. $order_payments = [];
  242. $record_channel_names = [];
  243. for ($i = 0; $i < count($channels); $i++) {
  244. $channel = $channels[$i];
  245. $fmt_pay_channel = $fmt_pay_channels[$channel->channel_id];
  246. if (!$fmt_pay_channel)
  247. return $this->fail("支付渠道错误!");
  248. array_push($record_channel_names, '['.$fmt_pay_channel['name'].']');
  249. $item = [
  250. 'order_id' => $order->id,
  251. 'channel_id' => $channel->channel_id,
  252. 'create_time' => time(),
  253. 'update_time' => time(),
  254. ];
  255. if ($fmt_pay_channel['type'] == 1) { // 正常支付
  256. predicate(isset($channel->fee) && $channel->fee > 0, '支付费用未填写');
  257. $item['fee'] = $channel->fee;
  258. $total_fee += $channel->fee;
  259. if ($fmt_pay_channel['is_upload_code']) {
  260. predicate(isset($channel->code),'必须上传付款编号');
  261. $item['code'] = $channel->code;
  262. }
  263. array_push($order_payments, $item);
  264. } else if($fmt_pay_channel['type'] == 2) { // 御龙币支付
  265. predicate(isset($channel->fee) && $channel->fee > 0, '支付费用未填写');
  266. $item['fee'] = $channel->fee;
  267. // TODO: 御龙币需求未明确
  268. array_push($order_payments, $item);
  269. } else {
  270. for ($j = 0; $j < count($channel->credit_card); $j++) {
  271. $credit_card = $channel->credit_card[$j];
  272. $fmt_credit_card_config = $fmt_credit_card_configs[$credit_card->credit_card_id];
  273. if (!$fmt_credit_card_config)
  274. return $this->fail("信用卡支付渠道错误!");
  275. predicate(isset($credit_card->fee) && $credit_card->fee > 0, '支付费用未填写');
  276. $total_fee += $credit_card->fee;
  277. $el = [
  278. 'order_id' => $order->id,
  279. 'channel_id' => $channel->channel_id,
  280. 'fee' => $credit_card->fee,
  281. 'credit_card_id' => $credit_card->credit_card_id,
  282. 'credit_card_name' => $fmt_credit_card_config['bank'],
  283. 'create_time' => time(),
  284. 'update_time' => time(),
  285. ];
  286. if ($fmt_pay_channel['is_upload_code']) {
  287. predicate(isset($credit_card->code),'必须填写付款编号');
  288. $el['code'] = $credit_card->code;
  289. }
  290. if ($fmt_credit_card_config['is_stage'] == 1) {
  291. predicate(isset($credit_card->stage_num),'必须选择分期数');
  292. $el['stage_num'] = $credit_card->stage_num;
  293. $config = [
  294. '6' => $fmt_credit_card_config['stage_6'],
  295. '9' => $fmt_credit_card_config['stage_9'],
  296. '12' => $fmt_credit_card_config['stage_12'],
  297. '24' => $fmt_credit_card_config['stage_24'],
  298. '36' => $fmt_credit_card_config['stage_36'],
  299. ];
  300. $now_config = $config[$credit_card->stage_num];
  301. predicate($now_config[0] == 1,'该分期未启用!');
  302. if ($now_config[1] > 0) { // 收取手续费
  303. $el['service_charge_rate'] = $now_config[1];
  304. $now_service_charge = $el['fee'] * ($now_config[1] / 100);
  305. $el['service_charge'] = $now_service_charge;
  306. $service_charge += $now_service_charge;
  307. }
  308. }
  309. array_push($order_payments, $el);
  310. }
  311. }
  312. }
  313. // 信用卡手续费
  314. $total_service_charge_amount = ($order->service_charge_amount + $service_charge);
  315. // 总共需要收取这么多费用; (商品的价格 + 商品税费 + 年费 + 信用卡手续费) - 御龙币抵扣的费用
  316. $imposed_amount = fixed2Float($order->product_amount + $order->total_sales_tax + $order->total_annual_fee + $total_service_charge_amount);
  317. // 总计实收金额
  318. $receive_amount = fixed2Float($order->receive_amount + $total_fee);
  319. if (round($receive_amount) > round($imposed_amount)) return $this->fail("实收金额大于待收金额! 应该支付 {$imposed_amount} (商品总价:{$order->product_amount} + 商品总消费税:{$order->total_sales_tax} + 第一年年费:{$order->total_annual_fee} + 信用卡总手续费:{$total_service_charge_amount})");
  320. $order_annual_fees = [];
  321. $update_store_products = [];
  322. if (round($receive_amount) == round($imposed_amount)) { // 减库存
  323. $order_products = $this->orderProductModel->findByOrderId($order->id)->toArray();
  324. $store_products = $this->storeProductModel->findByIds(array_map(function ($r) {return $r['store_product_id'];}, $order_products))->toArray();
  325. $fmt_store_products = array_reduce($store_products, function ($result, $item) {
  326. $result[$item['id']] = $item;
  327. return $result;
  328. },[]);
  329. foreach ($order_products as $order_product) {
  330. predicate($fmt_store_products[$order_product['store_product_id']]['now_stock'] > 0, lang('inventory shortage'));
  331. $fmt_store_products[$order_product['store_product_id']]['now_stock'] -= 1;
  332. if (isset($update_store_products[$order_product['store_product_id']])) {
  333. $update_store_products[$order_product['store_product_id']]['reduce_num'] += 1;
  334. } else {
  335. $update_store_products[$order_product['store_product_id']] = ['id' => $order_product['store_product_id'], 'reduce_num' => 1];
  336. }
  337. if ($order_product['is_gather_annuity']) {
  338. array_push($order_annual_fees, [
  339. 'order_id' => $order->id,
  340. 'customer_id' => $customer->id,
  341. 'customer_name' => "{$customer->name_en}|{$customer->name_zh}",
  342. 'customer_mobile' => $customer->mobile,
  343. 'customer_create_username' => $customer->create_username,
  344. 'index' => 1,
  345. 'order_product_id' => $order_product['id'],
  346. 'order_product_name' => $order_product['product_name'],
  347. 'fee' => $order_product['annuity'],
  348. 'is_pay' => 1,
  349. 'start_time' => time(),
  350. 'end_time' => time() + (365 * 24 * 60 * 60),
  351. 'order_create_time' => $order->create_time,
  352. 'adviser_1_id' => $order_product['adviser_1_id'],
  353. 'store_id' => $order->store_id,
  354. 'create_time' => time(),
  355. 'update_time' => time()
  356. ]);
  357. }
  358. }
  359. }
  360. Db::startTrans();
  361. try {
  362. $update_order = [
  363. 'rental_amount' => $imposed_amount,
  364. 'receivable_amount' => $imposed_amount,
  365. 'receive_amount' => $receive_amount,
  366. 'imposed_amount' => $imposed_amount - $receive_amount,
  367. 'service_charge_amount' => $order->service_charge_amount + $service_charge,
  368. ];
  369. if (round($receive_amount) == round($imposed_amount)) { // 支付满了
  370. $update_order['type'] = 1;
  371. Db::table('erp_order_product')->where('order_id', $order->id)->update(['is_pay' => 1]);
  372. if(count($order_annual_fees) > 0) {
  373. Db::table('erp_order_annual_fee')->insertAll($order_annual_fees);
  374. }
  375. if(count($update_store_products) > 0) {
  376. foreach ($update_store_products as $update) {
  377. Db::table('erp_store_product')->where('id', $update['id'])->dec('now_stock',1);
  378. Db::table('erp_store_product')->where('id', $update['id'])->inc('sale_stock',1);
  379. }
  380. }
  381. }
  382. Db::table('erp_order_proceeds')->save([
  383. 'order_id' => $order->id,
  384. 'channels' => join(' ',$record_channel_names),
  385. 'fee' => $total_fee,
  386. 'admin_id' => $params['admin_id'],
  387. 'admin_name' => $params['admin_name'],
  388. 'create_time' => time(),
  389. 'update_time' => time(),
  390. ]);
  391. if(count($order_payments) > 0) {
  392. Db::table('erp_order_payment')->insertAll(array_map(function ($data) {
  393. return [
  394. "order_id" => isset($data['order_id']) ? $data['order_id'] : null,
  395. "channel_id" => isset($data['channel_id']) ? $data['channel_id'] : null,
  396. "fee" => isset($data['fee']) ? $data['fee'] : null,
  397. "credit_card_id" => isset($data['credit_card_id']) ? $data['credit_card_id'] : null,
  398. "credit_card_name" => isset($data['credit_card_name']) ? $data['credit_card_name'] : null,
  399. "create_time" => isset($data['create_time']) ? $data['create_time'] : null,
  400. "update_time" => isset($data['update_time']) ? $data['update_time'] : null,
  401. "code" => isset($data['code']) ? $data['code'] : null,
  402. "stage_num" => isset($data['stage_num']) ? $data['stage_num'] : null,
  403. "service_charge_rate" => isset($data['service_charge_rate']) ? $data['service_charge_rate'] : null,
  404. "service_charge" => isset($data['service_charge']) ? $data['service_charge'] : null
  405. ];
  406. },$order_payments));
  407. }
  408. Db::table('erp_order')->where('id', $order->id)->update($update_order);
  409. Db::commit();
  410. } catch (\Exception $e) {
  411. Db::rollback();
  412. return $this->fail(lang($e->getMessage()));
  413. }
  414. return $this->ok(true);
  415. }
  416. public function fetch($params) {
  417. $is_look_all = AuthService::is_look_all($params['admin_id'],$params['type'] == 1 ? 10003 : 10004);
  418. $res = $this->orderModel->search($params, $is_look_all);
  419. $items = $res['data'];
  420. foreach ($items as &$item) {
  421. $item['is_need_upload'] = $item['type'] == 1 && in_array(true, array_map(function ($product) {
  422. return $product['is_upload_numerology'] == 1 && $product['is_upload'] == 0;
  423. }, $item['products']));
  424. }
  425. return [$items, $res['total']];
  426. }
  427. /**
  428. * @param $params
  429. * @return array
  430. * @throws \think\db\exception\DbException
  431. */
  432. public function fetchByCustomerId($params) {
  433. $res = $this->orderModel->fetchByCustomerId($params['customer_id'], $params['page'] ?? 1, $params['size'] ?? 20);
  434. $items = $res['data'];
  435. foreach ($items as &$item) {
  436. $item['is_need_upload'] = $item['type'] == 1 && in_array(true, array_map(function ($product) {
  437. return $product['is_upload_numerology'] == 1 && $product['is_upload'] == 0;
  438. }, $item['products']));
  439. }
  440. return [$items, $res['total']];
  441. }
  442. public function upload_numerology($order_product_id, $report) {
  443. $order_product = $this->orderProductModel->findById($order_product_id);
  444. if (!$order_product) return $this->fail('订单商品不存在,无法上传命理报告!');
  445. if (!$order_product->is_pay) return $this->fail('订单未支付,无法上传商品');
  446. $order_product->is_upload = 1;
  447. $order_product->report = $report;
  448. $order_product->save();
  449. return $this->ok($order_product);
  450. }
  451. public function fetchWaitGatherAnnualFee($admin_id, $text = null, $start_time = null, $end_time = null, $page = 1, $size = 10) {
  452. $res = $this->orderAnnualFeeModel->fetchByAdviser($admin_id, $text, $start_time, $end_time, $page, $size);
  453. return [$res->items(),$res->total()];
  454. }
  455. public function paymentAnnualFee($annual_fee_id) {
  456. $annual_fee = $this->orderAnnualFeeModel->findById($annual_fee_id);
  457. if(!$annual_fee_id) {
  458. return $this->fail('年费记录不存在!');
  459. }
  460. if($annual_fee->is_pay == 1)
  461. return $this->fail('该条年费记录已经支付!');
  462. $annual_fee->is_pay = 1;
  463. $annual_fee->update_time = time();
  464. $annual_fee->save();
  465. return $this->ok($annual_fee);
  466. }
  467. }