=', $start_unixtime); } if ($end_unixtime) { $condition[] = array('storemoneylog_add_time', '<=', $end_unixtime); } $storemoneylog_desc = input('param.storemoneylog_desc'); if ($storemoneylog_desc) { $condition[] = array('storemoneylog_desc', 'like', '%' . $storemoneylog_desc . '%'); } $storemoneylog_model = model('storemoneylog'); $list_log = $storemoneylog_model->getStoremoneylogList($condition, 10, '*', 'storemoneylog_id desc'); View::assign('show_page', $storemoneylog_model->page_info->render()); View::assign('list_log', $list_log); /* 设置买家当前菜单 */ $this->setSellerCurMenu('seller_money');; /* 设置买家当前栏目 */ $this->setSellerCurItem('index'); $store_info = Db::name('store')->where(array('store_id' => session('store_id')))->field('store_avaliable_money,store_freeze_money')->find(); View::assign('store_info', $store_info); return View::fetch($this->template_dir . 'index'); } /** * 会员余额充值店铺资金 */ public function add() { $member_info = model('member')->getMemberInfoByID(session('member_id')); if (request()->isPost()) { $amount = floatval(input('post.amount')); $storemoneylog_model = model('storemoneylog'); $predeposit_model = model('predeposit'); if ($amount > floatval($member_info['available_predeposit'])) { ds_json_encode(10001, lang('sellermoney_rechargew_money_max') . $member_info['available_predeposit'] . lang('currency_zh')); } $storedata = array( 'store_id' => $this->store_info['store_id'], 'store_name' => $this->store_info['store_name'], 'storemoneylog_type' => Storemoneylog::TYPE_MEMBER_IN, 'storemoneylog_state' => Storemoneylog::STATE_VALID, 'storemoneylog_add_time' => TIMESTAMP, 'store_avaliable_money' => $amount, 'storemoneylog_desc' => lang('sellermoney_member_money') . lang('sellermoney_rechargew') . ',' . lang('sellermoney_money') . ':' . $amount, ); $order_sn = makePaySn($member_info['member_id']); $memberdata = array( 'member_id' => $member_info['member_id'], 'amount' => $amount, 'member_name' => $member_info['member_name'], 'order_sn' => $order_sn, ); try { Db::startTrans(); $storemoneylog_model->changeStoremoney($storedata); $predeposit_model->changePd('store_rechargew_pay', $memberdata); Db::commit(); $this->recordSellerlog(lang('sellermoney_rechargew_money')); ds_json_encode(10000, lang('ds_common_op_succ')); } catch (\Exception $e) { Db::rollback(); ds_json_encode(10001, $e->getMessage()); } } else { View::assign('member_info', $member_info); return View::fetch($this->template_dir . 'add'); } } /** * 店铺资金提现到会员余额 */ public function withdraw_member() { $member_info = model('member')->getMemberInfoByID(session('member_id')); if (request()->isPost()) { $amount = floatval(input('post.amount')); $storemoneylog_model = model('storemoneylog'); $predeposit_model = model('predeposit'); if ($amount > floatval($this->store_info['store_avaliable_money'])) { ds_json_encode(10001, lang('sellermoney_withdraw_money_max') . $this->store_info['store_avaliable_money'] . lang('currency_zh')); } $storedata = array( 'store_id' => $this->store_info['store_id'], 'store_name' => $this->store_info['store_name'], 'storemoneylog_type' => Storemoneylog::TYPE_MEMBER_OUT, 'storemoneylog_state' => Storemoneylog::STATE_VALID, 'storemoneylog_add_time' => TIMESTAMP, 'store_avaliable_money' => -$amount, 'storemoneylog_desc' => lang('sellermoney_withdraw_member') . ',' . lang('sellermoney_money') . ':' . $amount, ); $order_sn = makePaySn($member_info['member_id']); $memberdata = array( 'member_id' => $member_info['member_id'], 'amount' => $amount, 'member_name' => $member_info['member_name'], 'order_sn' => $order_sn, ); try { Db::startTrans(); $storemoneylog_model->changeStoremoney($storedata); $predeposit_model->changePd('store_withdraw', $memberdata); Db::commit(); $this->recordSellerlog(lang('sellermoney_apply_withdraw')); ds_json_encode(10000, lang('ds_common_op_succ')); } catch (\Exception $e) { Db::rollback(); ds_json_encode(10001, $e->getMessage()); } } else { View::assign('store_avaliable_money', $this->store_info['store_avaliable_money']); return View::fetch($this->template_dir . 'member'); } } /** * 申请提现 */ public function withdraw_add() { $store_info = Db::name('store')->where(array('store_id' => session('store_id')))->field('store_avaliable_money,store_freeze_money')->find(); if (request()->isPost()) { $data = [ 'pdc_amount' => floatval(input('post.pdc_amount')), ]; $sellermoney_validate = ds_validate('sellermoney'); if (!$sellermoney_validate->scene('withdraw_add')->check($data)) { ds_json_encode(10001, $sellermoney_validate->getError()); } $pdc_amount = $data['pdc_amount']; $storemoneylog_model = model('storemoneylog'); //是否超过提现周期 $last_withdraw = $storemoneylog_model->getStoremoneylogInfo(array(array('store_id', '=', $this->store_info['store_id']), array('storemoneylog_state', 'in', [Storemoneylog::STATE_WAIT, Storemoneylog::STATE_AGREE]), array('storemoneylog_type', '=', Storemoneylog::TYPE_WITHDRAW), array('storemoneylog_add_time', '>', TIMESTAMP - intval(config('ds_config.store_withdraw_cycle')) * 86400)), 'storemoneylog_add_time'); if ($last_withdraw) { ds_json_encode(10001, lang('sellermoney_last_withdraw_time_error') . date('Y-m-d', $last_withdraw['storemoneylog_add_time'])); } //是否不小于最低提现金额 if ($pdc_amount < floatval(config('ds_config.store_withdraw_min'))) { ds_json_encode(10001, lang('sellermoney_withdraw_min') . config('ds_config.store_withdraw_min') . lang('ds_yuan')); } //是否不超过最高提现金额 if ($pdc_amount > floatval(config('ds_config.store_withdraw_max'))) { ds_json_encode(10001, lang('sellermoney_withdraw_max') . config('ds_config.store_withdraw_max') . lang('ds_yuan')); } $data = array( 'store_id' => $this->store_info['store_id'], 'store_name' => $this->store_info['store_name'], 'storemoneylog_type' => Storemoneylog::TYPE_WITHDRAW, 'storemoneylog_state' => Storemoneylog::STATE_WAIT, 'storemoneylog_add_time' => TIMESTAMP, ); $data['store_avaliable_money'] = -$pdc_amount; $data['store_freeze_money'] = $pdc_amount; $storejoinin_info = Db::name('storejoinin')->where(array('member_id' => $this->store_info['member_id']))->field('settlement_bank_account_name,settlement_bank_account_number,settlement_bank_name,settlement_bank_address')->find(); $joinin_detail = model('storejoinin')->getOneStorejoinin(array('member_id' => $this->store_info['member_id'])); if ($joinin_detail['business_licence_address'] != '') { $sml_desc = lang('sellermoney_bank_user') . ':' . $storejoinin_info['settlement_bank_account_name'] . ',' . lang('sellermoney_bank_number') . ':' . $storejoinin_info['settlement_bank_account_number'] . ',' . lang('sellermoney_bank_sub_name') . ':' . $storejoinin_info['settlement_bank_name'] . ',' . lang('sellermoney_bank_name') . ':' . $storejoinin_info['settlement_bank_address']; } else { $sml_desc = lang('sellermoney_alipay_name') . ':' . $storejoinin_info['settlement_bank_account_name'] . ',' . lang('sellermoney_alipay_number') . ':' . $storejoinin_info['settlement_bank_account_number']; } $data['storemoneylog_desc'] = $sml_desc; try { Db::startTrans(); $storemoneylog_model->changeStoremoney($data); Db::commit(); $this->recordSellerlog(lang('sellermoney_apply_withdraw')); ds_json_encode(10000, lang('ds_common_op_succ')); } catch (\Exception $e) { Db::rollback(); ds_json_encode(10001, $e->getMessage()); } } else { View::assign('store_withdraw_cycle', config('ds_config.store_withdraw_cycle')); View::assign('store_withdraw_min', config('ds_config.store_withdraw_min')); View::assign('store_withdraw_max', config('ds_config.store_withdraw_max')); View::assign('store_info', $store_info); return View::fetch($this->template_dir . 'withdraw_add'); } } /** * 提现列表 */ public function withdraw_list() { $condition = array(); $condition[] = array('store_id', '=', session('store_id')); $condition[] = array('storemoneylog_type', '=', Storemoneylog::TYPE_WITHDRAW); $paystate_search = input('param.paystate_search'); if (isset($paystate_search) && $paystate_search !== '') { $condition[] = array('storemoneylog_state', '=', intval($paystate_search)); } $storemoneylog_model = model('storemoneylog'); $withdraw_list = $storemoneylog_model->getStoremoneylogList($condition, 10, '*', 'storemoneylog_id desc'); View::assign('show_page', $storemoneylog_model->page_info->render()); View::assign('withdraw_list', $withdraw_list); /* 设置买家当前菜单 */ $this->setSellerCurMenu('seller_money');; /* 设置买家当前栏目 */ $this->setSellerCurItem('withdraw_list'); $store_info = Db::name('store')->where(array('store_id' => session('store_id')))->field('store_avaliable_money,store_freeze_money')->find(); View::assign('store_info', $store_info); return View::fetch($this->template_dir . 'withdraw_list'); } /** * 栏目菜单 */ function getSellerItemList() { $item_list = array( array( 'name' => 'index', 'text' => lang('sellermoney_log_list'), 'url' => (string) url('Sellermoney/index'), ), array( 'name' => 'withdraw_list', 'text' => lang('sellermoney_withdraw_list'), 'url' => (string) url('Sellermoney/withdraw_list'), ), ); return $item_list; } }