| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578 |
- <?php
- namespace app\api\service;
- use app\common\model\ActivityProductModel;
- use app\common\model\AdminModel;
- use app\common\model\ConfigModel;
- use app\common\model\CreditCardConfigModel;
- use app\common\model\CustomerModel;
- use app\common\model\CustomerZueCoinModel;
- use app\common\model\OrderAnnualFeeModel;
- use app\common\model\OrderModel;
- use app\common\model\OrderPaymentModel;
- use app\common\model\OrderProceedsModel;
- use app\common\model\OrderProductModel;
- use app\common\model\PaymentChannelModel;
- use app\common\model\ProductModel;
- use app\common\model\StoreModel;
- use app\common\model\StoreProductModel;
- use think\facade\Db;
- class OrderService extends \app\BaseService
- {
- private $storeModel;
- private $orderModel;
- private $productModel;
- private $orderAnnualFeeModel;
- private $orderPaymentModel;
- private $orderProductModel;
- private $orderProceedsModel;
- private $activityProductModel;
- private $storeProductModel;
- private $configModel;
- private $adminModel;
- private $customerModel;
- private $paymentChannelModel;
- private $creditCardModel;
- private $zueCoinModel;
- public function __construct()
- {
- $this->storeModel = new StoreModel();
- $this->orderModel = new OrderModel();
- $this->productModel = new ProductModel();
- $this->configModel = new ConfigModel();
- $this->storeProductModel = new StoreProductModel();
- $this->orderAnnualFeeModel = new OrderAnnualFeeModel();
- $this->orderPaymentModel = new OrderPaymentModel();
- $this->orderProductModel = new OrderProductModel();
- $this->orderProceedsModel = new OrderProceedsModel();
- $this->activityProductModel = new ActivityProductModel();
- $this->adminModel = new AdminModel();
- $this->customerModel = new CustomerModel();
- $this->paymentChannelModel = new PaymentChannelModel();
- $this->creditCardModel = new CreditCardConfigModel();
- $this->zueCoinModel = new CustomerZueCoinModel();
- }
- /**
- * @param $params
- * @param array $store_products_params
- * @return \SResult
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function create($params, array $store_products_params) {
- // 客户
- $customer = $this->customerModel->findById($params['customer_id']);
- if (!$customer)
- return $this->fail(lang("The Customer does not exist"));
- // 门店
- $store = $this->storeModel->findById($params['store_id']);
- if (!$store)
- return $this->fail(lang("The store does not exist"));
- // 顾问 or 老师 ids
- $user_ids = [];
- // 门店商品ids
- $store_product_ids = [];
- for ($i = 0; $i < count($store_products_params); $i++) {
- $store_products_param = $store_products_params[$i];
- $ids = [];
- if(isset($store_products_param->adviser_1_id)) array_push($ids, $store_products_param->adviser_1_id);
- if(isset($store_products_param->adviser_2_id)) array_push($ids, $store_products_param->adviser_2_id);
- if(isset($store_products_param->teacher_id)) array_push($ids, $store_products_param->teacher_id);
- $user_ids = array_unique(array_merge($user_ids, $ids));
- array_push($store_product_ids, $store_products_param->store_product_id);
- }
- // Adviser|Teacher
- $users = $this->adminModel->findByIds($user_ids)->toArray();
- if(count($users) != count($user_ids))
- return $this->fail(lang("The Adviser|Teacher does not exist"));
- $fmt_users = array_reduce($users, function ($result, $item) {
- $result[$item['id']] = $item;
- return $result;
- }, []);
- // 门店商品
- $store_products = $this->storeProductModel->fetchRelationsByOrder($store_product_ids)->toArray();
- if(count($store_products) != count($store_product_ids))
- return $this->fail(lang("The Product does not exist"));
- // 商品信息
- $products = array_map(function ($p) {
- return $p['product'] ? $p['product'] : null;
- }, $store_products);
- if(in_array(null, $products))
- return $this->fail(lang("The Product does not exist"));
- $config = $this->configModel->findConfig();
- $activityProducts = $this->activityProductModel->fetchByProductIds(array_map(function ($data) {
- return $data['id'];
- }, $products))->toArray();
- $fmt_store_products = [];
- foreach ($store_products as &$item) {
- $aProducts = array_filter($activityProducts, function ($aProduct) use ($item) {
- return $aProduct['product_id'] == $item['product_id'];
- });
- $res = compare($item['product']['real_price'] ?? 0, $aProducts);
- $item['activity'] = $res['item'];
- $item['product']['origin_price'] = $item['product']['real_price'];
- $item['product']['real_price'] = fixed2Float($res['min_num'] > 0 ? $res['min_num'] : 0);
- $sales_tax_rate = $item['product']['sales_tax_rate'] > 0 ? $item['product']['sales_tax_rate'] : $config->sales_tax_rate;
- $sales_tax = fixed2Float($sales_tax_rate > 0 && $item['product']['real_price'] > 0 ? ($item['product']['real_price'] * ($sales_tax_rate / 100)) : 0);
- $item['product']['sales_tax_rate'] = $sales_tax_rate;
- $item['product']['sales_tax'] = $sales_tax;
- $fmt_store_products[$item['id']] = $item;
- }
- $order_products = [];
- //项目总额
- $rental_amount = 0;
- $product_amount = 0;
- // 总消费税
- $total_sales_tax = 0;
- $advisor_1_ids = [];
- $product_names = [];
- $total_annual_fee = 0;
- $order_no = $this->orderModel->genOrderNo($store->id, $store->abbr);
- for ($i = 0; $i < count($store_products_params); $i++) {
- $store_products_param = $store_products_params[$i];
- $store_product = $fmt_store_products[$store_products_param->store_product_id];
- if($store_product['now_stock'] < $store_products_param->quantity)
- return $this->fail(lang("inventory shortage"));
- array_push($advisor_1_ids, $store_products_param->adviser_1_id);
- for ($j = 0; $j < $store_products_param->quantity; $j++) {
- array_push($product_names, $store_product['product']['name']);
- array_push($order_products, [
- 'order_id' => 0,
- 'order_no' => $order_no,
- 'customer_id' => $customer->id,
- 'product_id' => $store_product['product']['id'],
- 'product_category_id' => $store_product['product']['category_id'],
- 'is_serve' => $store_product['product']['is_serve'],
- 'store_product_id' => $store_product['id'],
- 'product_name' => $store_product['product']['name'],
- 'adviser_1_id' => isset($store_products_param->adviser_1_id) ? $store_products_param->adviser_1_id : null,
- 'adviser_1_name' => isset($store_products_param->adviser_1_id) ? $fmt_users[$store_products_param->adviser_1_id]['nickname'] : null,
- 'adviser_2_id' => isset($store_products_param->adviser_2_id) ? $store_products_param->adviser_2_id : null,
- 'adviser_2_name' => isset($store_products_param->adviser_2_id) ? $fmt_users[$store_products_param->adviser_2_id]['nickname'] : null,
- 'teacher_id' => isset($store_products_param->teacher_id) ? $store_products_param->teacher_id : null,
- 'teacher_name' => isset($store_products_param->teacher_id) ? $fmt_users[$store_products_param->teacher_id]['nickname'] : null,
- 'is_upload_numerology' => $store_product['product']['is_upload_numerology'],
- 'is_upload' => 0,
- 'report' => null,
- 'is_gather_annuity' => $store_product['product']['is_gather_annuity'],
- 'annuity' => $store_product['product']['annuity'],
- 'real_price' => $store_product['product']['real_price'],
- 'service_charge' => 0,
- 'reduce_price' => $store_product['activity'] ? $store_product['product']['origin_price'] - $store_product['product']['real_price'] : 0,
- 'reduce_type' => $store_product['activity'] ? $store_product['activity']['type'] : 0,
- 'sales_tax_rate' => $store_product['product']['sales_tax_rate'],
- 'sales_tax' => $store_product['product']['sales_tax'],
- 'create_time' => time(),
- 'update_time' => time(),
- ]);
- $product_amount += $store_product['product']['real_price'];
- $total_sales_tax += $store_product['product']['sales_tax'];
- if($store_product['product']['is_gather_annuity'] == 1) {
- $total_annual_fee += $store_product['product']['annuity'];
- $rental_amount += ($store_product['product']['real_price'] + $store_product['product']['sales_tax'] + $store_product['product']['annuity']);
- } else {
- $rental_amount += ($store_product['product']['real_price'] + $store_product['product']['sales_tax']);
- }
- }
- }
- $order = $this->orderModel->create([
- 'no' => $order_no,
- 'customer_id' => $customer->id,
- 'customer_name' => "{$customer->name_en}|{$customer->name_zh}",
- 'obj_names' => join(',',array_unique($product_names)),
- 'rental_amount' => $rental_amount,
- 'receivable_amount' => $rental_amount,
- 'receive_amount' => 0,
- 'imposed_amount' => $rental_amount,
- 'product_amount' => $product_amount,
- 'total_sales_tax' => $total_sales_tax,
- 'service_charge_amount' => 0,
- 'total_annual_fee' => $total_annual_fee,
- 'type' => 2,
- 'store_id' => $store->id,
- 'advisor_ids' => join(',', $advisor_1_ids),
- 'create_time' => time(),
- 'update_time' => time()
- ]);
- foreach ($order_products as &$order_product) $order_product['order_id'] = $order->id;
- Db::startTrans();
- try {
- Db::table('erp_order_product')->insertAll($order_products);
- Db::commit();
- } catch (\Exception $e) {
- Db::rollback();
- Db::table('erp_order')->delete($order->id);
- return $this->fail(lang($e->getMessage()));
- }
- return $this->ok($order);
- }
- /**
- * @param $params
- * @param $channels
- * @return \SResult
- * @throws \app\exception\BaseException
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function payment($params, $channels) {
- $order = $this->orderModel->findById($params);
- if(!$order)
- return $this->fail('订单不存在!');
- if($order->type == 1)
- return $this->fail('订单状态为历史订单!不支持付款');
- // 客户
- $customer = $this->customerModel->findById($order->customer_id);
- if (!$customer)
- return $this->fail(lang("The Customer does not exist"));
- $pay_channels = $this->paymentChannelModel->where('is_delete', 0)->select()->toArray();
- $fmt_pay_channels = array_reduce($pay_channels, function ($result, $item) {
- $result[$item['id']] = $item;
- return $result;
- },[]);
- $credit_card_configs = $this->creditCardModel->findAll()->toArray();
- $fmt_credit_card_configs = array_reduce($credit_card_configs, function ($result, $item) {
- $result[$item['id']] = $item;
- return $result;
- },[]);
- // 本次总计支付费用
- $total_fee = 0;
- // 本次信用卡支付手续费
- $service_charge = 0;
- // 本次御龙币
- $zue_coin = 0;
- $order_payments = [];
- $record_channel_names = [];
- for ($i = 0; $i < count($channels); $i++) {
- $channel = $channels[$i];
- $fmt_pay_channel = $fmt_pay_channels[$channel->channel_id];
- if (!$fmt_pay_channel)
- return $this->fail("支付渠道错误!");
- array_push($record_channel_names, '['.$fmt_pay_channel['name'].']');
- $item = [
- 'order_id' => $order->id,
- 'channel_id' => $channel->channel_id,
- 'create_time' => time(),
- 'update_time' => time(),
- ];
- if ($fmt_pay_channel['type'] == 1) { // 正常支付
- predicate(isset($channel->fee) && $channel->fee > 0, '支付费用未填写');
- $item['fee'] = $channel->fee;
- $total_fee += $channel->fee;
- if ($fmt_pay_channel['is_upload_code']) {
- predicate(isset($channel->code),'必须上传付款编号');
- $item['code'] = $channel->code;
- }
- array_push($order_payments, $item);
- } else if($fmt_pay_channel['type'] == 2) { // 御龙币支付
- predicate(isset($channel->fee) && $channel->fee > 0, '支付费用未填写');
- $item['fee'] = $channel->fee;
- // TODO: 御龙币需求未明确
- array_push($order_payments, $item);
- $zue_coin += $channel->fee;
- } else {
- for ($j = 0; $j < count($channel->credit_card); $j++) {
- $credit_card = $channel->credit_card[$j];
- $fmt_credit_card_config = $fmt_credit_card_configs[$credit_card->credit_card_id];
- if (!$fmt_credit_card_config)
- return $this->fail("信用卡支付渠道错误!");
- predicate(isset($credit_card->fee) && $credit_card->fee > 0, '支付费用未填写');
- $total_fee += $credit_card->fee;
- $el = [
- 'order_id' => $order->id,
- 'channel_id' => $channel->channel_id,
- 'fee' => $credit_card->fee,
- 'credit_card_id' => $credit_card->credit_card_id,
- 'credit_card_name' => $fmt_credit_card_config['bank'],
- 'create_time' => time(),
- 'update_time' => time(),
- ];
- if ($fmt_pay_channel['is_upload_code']) {
- predicate(isset($credit_card->code),'必须填写付款编号');
- $el['code'] = $credit_card->code;
- }
- if ($fmt_credit_card_config['is_stage'] == 1) {
- predicate(isset($credit_card->stage_num),'必须选择分期数');
- $el['stage_num'] = $credit_card->stage_num;
- $config = [
- '6' => $fmt_credit_card_config['stage_6'],
- '9' => $fmt_credit_card_config['stage_9'],
- '12' => $fmt_credit_card_config['stage_12'],
- '24' => $fmt_credit_card_config['stage_24'],
- '36' => $fmt_credit_card_config['stage_36'],
- ];
- $now_config = $config[$credit_card->stage_num];
- predicate($now_config[0] == 1,'该分期未启用!');
- if ($now_config[1] > 0) { // 收取手续费
- $el['service_charge_rate'] = $now_config[1];
- $now_service_charge = $el['fee'] * ($now_config[1] / 100);
- $el['service_charge'] = $now_service_charge;
- $service_charge += $now_service_charge;
- }
- }
- array_push($order_payments, $el);
- }
- }
- }
- // 信用卡手续费
- $total_service_charge_amount = ($order->service_charge_amount + $service_charge);
- // 总共需要收取这么多费用; (商品的价格 + 商品税费 + 年费 + 信用卡手续费) - 御龙币抵扣的费用
- $imposed_amount = fixed2Float($order->product_amount + $order->total_sales_tax + $order->total_annual_fee + $total_service_charge_amount);
- $order_use_zue_coin = $order->zue_coin;
- $order_use_zue_coin_amount = $order->zue_coin_amount;
- if($zue_coin > 0) {
- $zue_coin_model = $this->zueCoinModel->findByCustomerId($customer->id);
- if ($zue_coin > $zue_coin_model->zue_coin)
- return $this->fail("当前客户御龙币账户余额:{$zue_coin_model->zue_coin}");
- $zue_coin_config = $fmt_pay_channels['11'];
- if(!$zue_coin_config)
- return $this->fail("御龙币设置不存在!");
- $zue_coin_exchange_rate = $zue_coin_config['zue_coin_exchange_rate'] ?? 0; // 兑换比例
- $zue_coin_consume_rate = $zue_coin_config['zue_coin_consume_rate'] ?? 0; // 报销比例
- if($zue_coin_exchange_rate == 0 || $zue_coin_consume_rate == 0) {
- return $this->fail("该笔订单不支持御龙币支付");
- }
- // 1.计算出该订单能使用多少御龙币
- // 2.结合之前已使用的御龙币 算出还能使用多少御龙币
- // 3.判断当前御龙币是否符合兑换数额
- // 4.进行扣除并记录
- // 总共能报销这么多钱
- $total_consume_amount = fixed2Float($imposed_amount * ($zue_coin_consume_rate / 100));
- // 总共能消耗这么多御龙币
- $total_can_zue_coin = fixed2Float($total_consume_amount / $zue_coin_exchange_rate);
- // 还能使用多少御龙币
- $now_can_consume_zue_coin = $total_can_zue_coin - $order_use_zue_coin;
- // 判断当前还能使用
- if ($now_can_consume_zue_coin - $zue_coin < 0)
- return $this->fail("
- 当前已使用御龙币数额: {$order_use_zue_coin}/{$total_can_zue_coin},
- 当前已兑换金额: {$order_use_zue_coin_amount}/{$total_consume_amount},
- 御龙币兑换比例: {$zue_coin_exchange_rate},
- 御龙币报销比例:{$zue_coin_consume_rate}
- ");
- // 总共使用了这么多御龙币
- $order_use_zue_coin += $zue_coin;
- // 总共兑换了这么多钱
- $order_use_zue_coin_amount = fixed2Float($order_use_zue_coin * $zue_coin_exchange_rate);
- }
- // 总计费用 - 御龙币抵消费用;
- $imposed_amount -= $order_use_zue_coin_amount;
- // 总计实收金额
- $receive_amount = fixed2Float($order->receive_amount + $total_fee);
- 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})");
- $order_annual_fees = [];
- $update_store_products = [];
- if (round($receive_amount) == round($imposed_amount)) { // 减库存
- $order_products = $this->orderProductModel->findByOrderId($order->id)->toArray();
- $store_products = $this->storeProductModel->findByIds(array_map(function ($r) {return $r['store_product_id'];}, $order_products))->toArray();
- $fmt_store_products = array_reduce($store_products, function ($result, $item) {
- $result[$item['id']] = $item;
- return $result;
- },[]);
- foreach ($order_products as $order_product) {
- predicate($fmt_store_products[$order_product['store_product_id']]['now_stock'] > 0, lang('inventory shortage'));
- $fmt_store_products[$order_product['store_product_id']]['now_stock'] -= 1;
- if (isset($update_store_products[$order_product['store_product_id']])) {
- $update_store_products[$order_product['store_product_id']]['reduce_num'] += 1;
- } else {
- $update_store_products[$order_product['store_product_id']] = ['id' => $order_product['store_product_id'], 'reduce_num' => 1];
- }
- if ($order_product['is_gather_annuity']) {
- array_push($order_annual_fees, [
- 'order_id' => $order->id,
- 'customer_id' => $customer->id,
- 'customer_name' => "{$customer->name_en}|{$customer->name_zh}",
- 'customer_mobile' => $customer->mobile,
- 'customer_create_username' => $customer->create_username,
- 'index' => 1,
- 'order_product_id' => $order_product['id'],
- 'order_product_name' => $order_product['product_name'],
- 'fee' => $order_product['annuity'],
- 'is_pay' => 1,
- 'start_time' => time(),
- 'end_time' => time() + (365 * 24 * 60 * 60),
- 'order_create_time' => $order->create_time,
- 'adviser_1_id' => $order_product['adviser_1_id'],
- 'store_id' => $order->store_id,
- 'create_time' => time(),
- 'update_time' => time()
- ]);
- }
- }
- }
- return $this->ok(true);
- Db::startTrans();
- try {
- $update_order = [
- 'rental_amount' => $imposed_amount + $order_use_zue_coin_amount,
- 'receivable_amount' => $imposed_amount,
- 'receive_amount' => $receive_amount,
- 'imposed_amount' => $imposed_amount - $receive_amount,
- 'service_charge_amount' => $order->service_charge_amount + $service_charge,
- 'zue_coin' => $order_use_zue_coin,
- 'zue_coin_amount' => $order_use_zue_coin_amount,
- 'remarks' => $params['remarks']
- ];
- if (round($receive_amount) == round($imposed_amount)) { // 支付满了
- $update_order['type'] = 1;
- Db::table('erp_order_product')->where('order_id', $order->id)->update(['is_pay' => 1]);
- if(count($order_annual_fees) > 0) {
- Db::table('erp_order_annual_fee')->insertAll($order_annual_fees);
- }
- if(count($update_store_products) > 0) {
- foreach ($update_store_products as $update) {
- Db::table('erp_store_product')->where('id', $update['id'])->dec('now_stock',1);
- Db::table('erp_store_product')->where('id', $update['id'])->inc('sale_stock',1);
- }
- }
- }
- Db::table('erp_order_proceeds')->save([
- 'order_id' => $order->id,
- 'channels' => join(' ',$record_channel_names),
- 'fee' => $total_fee,
- 'admin_id' => $params['admin_id'],
- 'admin_name' => $params['admin_name'],
- 'create_time' => time(),
- 'update_time' => time(),
- ]);
- if(count($order_payments) > 0) {
- Db::table('erp_order_payment')->insertAll(array_map(function ($data) {
- return [
- "order_id" => isset($data['order_id']) ? $data['order_id'] : null,
- "channel_id" => isset($data['channel_id']) ? $data['channel_id'] : null,
- "fee" => isset($data['fee']) ? $data['fee'] : null,
- "credit_card_id" => isset($data['credit_card_id']) ? $data['credit_card_id'] : null,
- "credit_card_name" => isset($data['credit_card_name']) ? $data['credit_card_name'] : null,
- "create_time" => isset($data['create_time']) ? $data['create_time'] : null,
- "update_time" => isset($data['update_time']) ? $data['update_time'] : null,
- "code" => isset($data['code']) ? $data['code'] : null,
- "stage_num" => isset($data['stage_num']) ? $data['stage_num'] : null,
- "service_charge_rate" => isset($data['service_charge_rate']) ? $data['service_charge_rate'] : null,
- "service_charge" => isset($data['service_charge']) ? $data['service_charge'] : null
- ];
- },$order_payments));
- }
- Db::table('erp_order')->where('id', $order->id)->update($update_order);
- Db::commit();
- } catch (\Exception $e) {
- Db::rollback();
- return $this->fail(lang($e->getMessage()));
- }
- return $this->ok(true);
- }
- public function fetch($params) {
- $is_look_all = AuthService::is_look_all($params['admin_id'],$params['type'] == 1 ? 10003 : 10004);
- $res = $this->orderModel->search($params, $is_look_all);
- $items = $res['data'];
- foreach ($items as &$item) {
- $item['is_need_upload'] = $item['type'] == 1 && in_array(true, array_map(function ($product) {
- return $product['is_upload_numerology'] == 1 && $product['is_upload'] == 0;
- }, $item['products']));
- }
- return [$items, $res['total']];
- }
- /**
- * @param $params
- * @return array
- * @throws \think\db\exception\DbException
- */
- public function fetchByCustomerId($params) {
- $res = $this->orderModel->fetchByCustomerId($params['customer_id'], $params['page'] ?? 1, $params['size'] ?? 20);
- $items = $res['data'];
- foreach ($items as &$item) {
- $item['is_need_upload'] = $item['type'] == 1 && in_array(true, array_map(function ($product) {
- return $product['is_upload_numerology'] == 1 && $product['is_upload'] == 0;
- }, $item['products']));
- }
- return [$items, $res['total']];
- }
- public function upload_numerology($order_product_id, $report) {
- $order_product = $this->orderProductModel->findById($order_product_id);
- if (!$order_product) return $this->fail('订单商品不存在,无法上传命理报告!');
- if (!$order_product->is_pay) return $this->fail('订单未支付,无法上传商品');
- $order_product->is_upload = 1;
- $order_product->report = $report;
- $order_product->save();
- return $this->ok($order_product);
- }
- public function fetchWaitGatherAnnualFee($admin_id, $text = null, $start_time = null, $end_time = null, $page = 1, $size = 10) {
- $res = $this->orderAnnualFeeModel->fetchByAdviser($admin_id, $text, $start_time, $end_time, $page, $size);
- return [$res->items(),$res->total()];
- }
- public function paymentAnnualFee($annual_fee_id) {
- $annual_fee = $this->orderAnnualFeeModel->findById($annual_fee_id);
- if(!$annual_fee_id) {
- return $this->fail('年费记录不存在!');
- }
- if($annual_fee->is_pay == 1)
- return $this->fail('该条年费记录已经支付!');
- $annual_fee->is_pay = 1;
- $annual_fee->update_time = time();
- $annual_fee->save();
- return $this->ok($annual_fee);
- }
- }
|