|
@@ -0,0 +1,556 @@
|
|
|
+<?php
|
|
|
+require_once(BASE_ROOT_PATH . '/mobile/control/merchantweb.php');
|
|
|
+
|
|
|
+class merchant_infoControl extends mbMerchantControl
|
|
|
+{
|
|
|
+ public function __construct()
|
|
|
+ {
|
|
|
+ parent::__construct();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function indexOp()
|
|
|
+ {
|
|
|
+ $mchid = $this->mchid();
|
|
|
+ $model_merchant = Model('merchant');
|
|
|
+ $field = 'mchid,admin_id,name,alarm_amount,ip_white_list,use_key,contact_name,contact_phone,warning_phone,company_name,quality,time_out,credit_bonus';
|
|
|
+ $merchant_info = $model_merchant->getMerchantInfo(['mchid' => $mchid], $field);
|
|
|
+ $model_member = Model('member');
|
|
|
+ $member_info = $model_member->getMemberInfo(['member_id' => $merchant_info['admin_id']], 'available_predeposit');
|
|
|
+ if (empty($member_info)) {
|
|
|
+ $member_info['available_predeposit'] = 0;
|
|
|
+ }
|
|
|
+ $merchant_info['member'] = $member_info;
|
|
|
+
|
|
|
+ if (empty($merchant_info['ip_white_list'])) {
|
|
|
+ $merchant_info['ips'] = [];
|
|
|
+ } else {
|
|
|
+ $merchant_info['ips'] = unserialize($merchant_info['ip_white_list']);
|
|
|
+ }
|
|
|
+ if (empty($merchant_info['warning_phone'])) {
|
|
|
+ $merchant_info['warning_phone'] = [];
|
|
|
+ } else {
|
|
|
+ $merchant_info['warning_phone'] = unserialize($merchant_info['warning_phone']);
|
|
|
+ }
|
|
|
+
|
|
|
+ $cond['status'] = $cond['is_operation'] = 2;
|
|
|
+ $cond['mchid'] = $mchid;
|
|
|
+ $stats = Model('')->table('refill_evidence')
|
|
|
+ ->field('sum(amount) as amounts')
|
|
|
+ ->where($cond)->select();
|
|
|
+ $merchant_info['evidence_amounts'] = empty($stats) ? 0 : $stats[0]['amounts'];
|
|
|
+ $cond['add_time'] = ['between', [strtotime(date("Y-m-d",time())), time()]];
|
|
|
+ $day_evidence = $model_merchant->getRefillEvidence($cond);
|
|
|
+ $merchant_info['evidence_count'] = count($day_evidence);
|
|
|
+ $merchant_info['time_out'] = intval($merchant_info['time_out'] / 60);
|
|
|
+ $merchant_info['quality'] = intval($merchant_info['quality']);
|
|
|
+
|
|
|
+ $pub = new message\publisher();
|
|
|
+ $pub->modify_refill_merchant();
|
|
|
+
|
|
|
+ return self::outsuccess($merchant_info);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function SetQualityTimeOutOp()
|
|
|
+ {
|
|
|
+ $mchid = $this->mchid();
|
|
|
+ $save = [];
|
|
|
+ $quality = intval($_POST['quality']);
|
|
|
+ if($quality > 0) {
|
|
|
+ if(!in_array($quality , [1,2,3])) {
|
|
|
+ return self::outerr(errcode::ErrParamter, "通道质量类型错误");
|
|
|
+ }
|
|
|
+ $save['quality'] = $quality;
|
|
|
+ }
|
|
|
+ $time_out = intval($_POST['time_out']);
|
|
|
+ if($quality > 0) {
|
|
|
+ if($time_out <3) {
|
|
|
+ return self::outerr(errcode::ErrParamter, "超时时间应大于3分钟");
|
|
|
+ }
|
|
|
+ $time_out = intval($time_out * 60);
|
|
|
+ $save['time_out'] = $time_out;
|
|
|
+ }
|
|
|
+ if(empty($save)) {
|
|
|
+ return self::outsuccess([]);
|
|
|
+ }
|
|
|
+ $model_merchant = Model('merchant');
|
|
|
+ $resp = $model_merchant->editMerchant($save, ['mchid' => $mchid]);
|
|
|
+ if($resp) {
|
|
|
+ return self::outsuccess([]);
|
|
|
+ }else{
|
|
|
+ return self::outerr(errcode::ErrOperation, "系统错误.");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function homeOp()
|
|
|
+ {
|
|
|
+ $mchid = $this->mchid();
|
|
|
+ $model_merchant = Model('merchant');
|
|
|
+ $merchant_info = $model_merchant->getMerchantInfo(['mchid' => $mchid], 'mchid,admin_id,name,company_name');
|
|
|
+ $model_member = Model('member');
|
|
|
+ $member_info = $model_member->getMemberInfo(['member_id' => $merchant_info['admin_id']], 'available_predeposit');
|
|
|
+ if (empty($member_info)) {
|
|
|
+ $merchant_info['available_predeposit'] = 0;
|
|
|
+ } else {
|
|
|
+ $merchant_info['available_predeposit'] = ncPriceFormat($member_info['available_predeposit']);
|
|
|
+ }
|
|
|
+
|
|
|
+ $statistics = $this->statistics();
|
|
|
+ ksort($statistics);
|
|
|
+ $result['merchant_info'] = $merchant_info;
|
|
|
+ $result['todayStatistics'] = $statistics[strtotime(date("Y-m-d",time()))];
|
|
|
+ $result['weeksStatistics'] = $statistics;
|
|
|
+ $max = 0;
|
|
|
+ foreach ($statistics as $key => $val){
|
|
|
+ if($max == 0){
|
|
|
+ $max = $val['successAmounts'];
|
|
|
+
|
|
|
+ }
|
|
|
+ if($max < $val['count']){
|
|
|
+ $max = $val['successAmounts'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $result['max'] = ncPriceFormat(ceil($max * 1.1));
|
|
|
+ $week_month_stats = $this->refillStats();
|
|
|
+ $result['month'] = $week_month_stats['month'];
|
|
|
+ $result['week'] = $week_month_stats['week'];
|
|
|
+ return self::outsuccess($result);
|
|
|
+ }
|
|
|
+
|
|
|
+ private function statistics()
|
|
|
+ {
|
|
|
+ $date = date('Y-m-d',time());
|
|
|
+ $today = strtotime("{$date}");
|
|
|
+
|
|
|
+ $times_begin = function ($start) {
|
|
|
+ $times = [];
|
|
|
+ $begin = $start;
|
|
|
+ for($i = 0; $i < 7; $i++) {
|
|
|
+ $times[] = $begin;
|
|
|
+ $begin -= 86400;
|
|
|
+ }
|
|
|
+ return $times;
|
|
|
+ };
|
|
|
+
|
|
|
+ $reader = function ($mchid,$time) {
|
|
|
+ $cond['mchid'] = $mchid;
|
|
|
+ $cond['inner_status'] = 0;
|
|
|
+ $cond['refill_order.order_time'] = ['between', [$time, $time + 86400 -1]];
|
|
|
+
|
|
|
+ $items = Model('')->table('refill_order,vr_order')->join('inner')
|
|
|
+ ->on('refill_order.order_id=vr_order.order_id')
|
|
|
+ ->field('count(*) as order_count, vr_order.order_state, sum(mch_amount) as mch_amounts')
|
|
|
+ ->group('order_state')
|
|
|
+ ->where($cond)->select();
|
|
|
+
|
|
|
+ return $this->refillCountDispose($items);
|
|
|
+ };
|
|
|
+
|
|
|
+ $begins = $times_begin($today);
|
|
|
+
|
|
|
+ $states = rcache($this->mchid() , 'refillstat-');
|
|
|
+
|
|
|
+ if(empty($states)){
|
|
|
+ $states = [];
|
|
|
+ }else{
|
|
|
+ $states = unserialize($states['data']);
|
|
|
+ }
|
|
|
+ $result = [];
|
|
|
+ $cache = [];
|
|
|
+ foreach ($begins as $begin)
|
|
|
+ {
|
|
|
+ if(array_key_exists($begin,$states)) {
|
|
|
+ $item = $states[$begin];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ $item = $reader($this->mchid(),$begin);
|
|
|
+ }
|
|
|
+ $result[$begin] = $item;
|
|
|
+
|
|
|
+ //判断item 中充值中的状态是否为0,为0且不是今天的情况下放进cache
|
|
|
+ if($item['sendCount'] == 0 && $begin != $today){
|
|
|
+ $cache[$begin] = $item;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!empty($cache) && !$this->isSame($states,$cache)) {
|
|
|
+ wcache($this->mchid() ,['data' => serialize($cache)], 'refillstat-');
|
|
|
+ }
|
|
|
+
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
+
|
|
|
+ private function isSame($arr1, $arr2)
|
|
|
+ {
|
|
|
+ ksort($arr1);
|
|
|
+ ksort($arr2);
|
|
|
+ return $arr1 == $arr2;
|
|
|
+ }
|
|
|
+
|
|
|
+ private function refillCountDispose($stats)
|
|
|
+ {
|
|
|
+ $result['count'] = $result['sendCount'] = $result['errorCount'] = $result['successCount'] = $result['amountCount'] = $result['errorAmounts'] = $result['successAmounts'] = 0;
|
|
|
+ foreach ($stats as $count) {
|
|
|
+ $result['count'] += $count['order_count'];
|
|
|
+ $result['amountCount'] += ncPriceFormat($count['mch_amounts']);
|
|
|
+ if($count['order_state'] == ORDER_STATE_SEND) {
|
|
|
+ $result['sendCount'] = $count['order_count'];
|
|
|
+ }
|
|
|
+ if($count['order_state'] == ORDER_STATE_CANCEL) {
|
|
|
+ $result['errorCount'] = $count['order_count'];
|
|
|
+ $result['errorAmounts'] = ncPriceFormat($count['mch_amounts']);
|
|
|
+ }
|
|
|
+ if($count['order_state'] == ORDER_STATE_SUCCESS) {
|
|
|
+ $result['successCount'] = $count['order_count'];
|
|
|
+ $result['successAmounts'] = ncPriceFormat($count['mch_amounts']);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $result['amountCount'] = ncPriceFormat($result['amountCount']);
|
|
|
+ $result['errorAmounts'] = ncPriceFormat($result['errorAmounts']);
|
|
|
+ $result['successAmounts'] = ncPriceFormat($result['successAmounts']);
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
+
|
|
|
+ private function refillStats()
|
|
|
+ {
|
|
|
+ $reader = function ($mchid,$time,$end_time) {
|
|
|
+ $cond['mchid'] = $mchid;
|
|
|
+ $cond['inner_status'] = 0;
|
|
|
+ $cond['refill_order.order_time'] = ['between', [$time, $end_time]];
|
|
|
+
|
|
|
+ $items = Model('')->table('refill_order,vr_order')->join('inner')
|
|
|
+ ->on('refill_order.order_id=vr_order.order_id')
|
|
|
+ ->field('count(*) as order_count, vr_order.order_state, sum(mch_amount) as mch_amounts')
|
|
|
+ ->group('order_state')
|
|
|
+ ->where($cond)->select();
|
|
|
+
|
|
|
+ return $this->refillCountDispose($items);
|
|
|
+ };
|
|
|
+ $date = date("Y-m-d");
|
|
|
+ $first = 1;
|
|
|
+ $w = date('w',strtotime($date));
|
|
|
+ $week_start = strtotime(date('Y-m-d',strtotime("$date -".($w ? $w - $first : 6).' days')));
|
|
|
+ $w = 7 - $w + 1;
|
|
|
+ $week_end = strtotime(date('Y-m-d',strtotime("+{$w} days"))) - 1;
|
|
|
+ $week = $reader($this->mchid(), $week_start,$week_end);
|
|
|
+
|
|
|
+ $month_start = strtotime(date("Y-m-1"));
|
|
|
+ $month_end = strtotime(date("Y-m-1",strtotime("+1month")))-1;
|
|
|
+ $month = $reader($this->mchid(), $month_start, $month_end);
|
|
|
+
|
|
|
+ return ['week' => $week , 'month' => $month];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function addipOp()
|
|
|
+ {
|
|
|
+ $mchid = $this->mchid();
|
|
|
+ $ip = $_POST['ip'];
|
|
|
+ if (empty($ip)) {
|
|
|
+ return self::outerr(errcode::ErrParamter, "参数错误");
|
|
|
+ }
|
|
|
+ $ip = trim($ip);
|
|
|
+ if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4))
|
|
|
+ {
|
|
|
+ $model_merchant = Model('merchant');
|
|
|
+ $merchant_info = $model_merchant->getMerchantInfo(['mchid' => $mchid]);
|
|
|
+ if (empty($merchant_info['ip_white_list'])) {
|
|
|
+ $ips = [];
|
|
|
+ } else {
|
|
|
+ $ips = unserialize($merchant_info['ip_white_list']);
|
|
|
+ }
|
|
|
+
|
|
|
+ $ips[] = $ip;
|
|
|
+ $ips = array_unique($ips);
|
|
|
+
|
|
|
+ $model_merchant->editMerchant(['ip_white_list' => serialize($ips)], ['mchid' => $merchant_info['mchid']]);
|
|
|
+ return self::outsuccess([]);
|
|
|
+ } else {
|
|
|
+ return self::outerr(errcode::ErrParamter, "ip地址错误");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function ipdelOp()
|
|
|
+ {
|
|
|
+ $mchid = $this->mchid();
|
|
|
+ $ip = $_POST['ip'];
|
|
|
+ if (empty($ip)) {
|
|
|
+ return self::outerr(errcode::ErrParamter, "参数错误");
|
|
|
+ }
|
|
|
+ $ip = trim($ip);
|
|
|
+ $model_merchant = Model('merchant');
|
|
|
+ $merchant_info = $model_merchant->getMerchantInfo(['mchid' => $mchid]);
|
|
|
+ $ips = unserialize($merchant_info['ip_white_list']);
|
|
|
+ $new_ips = [];
|
|
|
+ foreach ($ips as $value) {
|
|
|
+ if ($value != $ip) {
|
|
|
+ $new_ips[] = $value;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (empty($new_ips)) {
|
|
|
+ $new_ips = '';
|
|
|
+ } else {
|
|
|
+ $new_ips = serialize($new_ips);
|
|
|
+ }
|
|
|
+ $model_merchant->editMerchant(['ip_white_list' => $new_ips], ['mchid' => $merchant_info['mchid']]);
|
|
|
+ return self::outsuccess([]);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function setcontactOp(){
|
|
|
+ $mchid = $this->mchid();
|
|
|
+ if(!empty($_POST['contact_name']))
|
|
|
+ {
|
|
|
+ $params['contact_name'] = trim($_POST['contact_name']);
|
|
|
+ }
|
|
|
+ if(!empty($_POST['contact_phone']))
|
|
|
+ {
|
|
|
+ $params['contact_phone'] = trim($_POST['contact_phone']);
|
|
|
+ }
|
|
|
+ if(!empty($_POST['alarm_amount']))
|
|
|
+ {
|
|
|
+ $params['alarm_amount'] = trim($_POST['alarm_amount']);
|
|
|
+ }
|
|
|
+ if(empty($params))
|
|
|
+ {
|
|
|
+ return self::outsuccess([]);
|
|
|
+ }
|
|
|
+ $model_merchant = Model('merchant');
|
|
|
+ $ret = $model_merchant->editMerchant($params, ['mchid' => $mchid]);
|
|
|
+ if ($ret) {
|
|
|
+ return self::outsuccess([]);
|
|
|
+ } else {
|
|
|
+ return self::outerr(errcode::ErrOperation, "系统错误.");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function addwphoneOp()
|
|
|
+ {
|
|
|
+ $mchid = $this->mchid();
|
|
|
+ $phone = $_POST['phone'];
|
|
|
+ if (empty($phone)) {
|
|
|
+ return self::outerr(errcode::ErrParamter, "参数错误");
|
|
|
+ }
|
|
|
+ $phone = explode(',' ,trim($phone));
|
|
|
+ $model_merchant = Model('merchant');
|
|
|
+ $merchant_info = $model_merchant->getMerchantInfo(['mchid' => $mchid]);
|
|
|
+ if (empty($merchant_info['warning_phone'])) {
|
|
|
+ $phones = [];
|
|
|
+ } else {
|
|
|
+ $phones = unserialize($merchant_info['warning_phone']);
|
|
|
+ }
|
|
|
+ foreach ($phone as $item) {
|
|
|
+ $phones[] = $item;
|
|
|
+ }
|
|
|
+ $phones = array_unique($phones);
|
|
|
+ $model_merchant->editMerchant(['warning_phone' => serialize($phones)], ['mchid' => $merchant_info['mchid']]);
|
|
|
+ return self::outsuccess([]);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function wphonedelOp()
|
|
|
+ {
|
|
|
+ $mchid = $this->mchid();
|
|
|
+ $phone = $_POST['phone'];
|
|
|
+ if (empty($phone)) {
|
|
|
+ return self::outerr(errcode::ErrParamter, "参数错误");
|
|
|
+ }
|
|
|
+ $phone = trim($phone);
|
|
|
+ $model_merchant = Model('merchant');
|
|
|
+ $merchant_info = $model_merchant->getMerchantInfo(['mchid' => $mchid]);
|
|
|
+ $phones = unserialize($merchant_info['warning_phone']);
|
|
|
+ $new_phones = [];
|
|
|
+ foreach ($phones as $value) {
|
|
|
+ if ($value != $phone) {
|
|
|
+ $new_phones[] = $value;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (empty($new_phones)) {
|
|
|
+ $new_phones = '';
|
|
|
+ } else {
|
|
|
+ $new_phones = serialize($new_phones);
|
|
|
+ }
|
|
|
+ $model_merchant->editMerchant(['warning_phone' => $new_phones], ['mchid' => $merchant_info['mchid']]);
|
|
|
+ return self::outsuccess([]);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function setkeyOp()
|
|
|
+ {
|
|
|
+ $mchid = $this->mchid();
|
|
|
+ $secure_key = $_POST['secure_key'];
|
|
|
+ if (empty($secure_key)) {
|
|
|
+ return self::outerr(errcode::ErrParamter, "参数错误");
|
|
|
+ }
|
|
|
+ $model_merchant = Model('merchant');
|
|
|
+ $ret = $model_merchant->editMerchant(['secure_key' => $secure_key, 'use_key' => 1], ['mchid' => $mchid]);
|
|
|
+ if ($ret) {
|
|
|
+ return self::outsuccess([]);
|
|
|
+ } else {
|
|
|
+ return self::outerr(errcode::ErrOperation, "系统错误.");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function modifypwOp()
|
|
|
+ {
|
|
|
+ $mchid = $this->mchid();
|
|
|
+ $new_pw = $_POST['new_pw'];
|
|
|
+ $new_pw2 = $_POST['new_pw2'];
|
|
|
+ if (trim($new_pw) !== trim($new_pw2)) {
|
|
|
+ return self::outerr(errcode::ErrPasswd, "密码错误");
|
|
|
+ }
|
|
|
+ $model_merchant = Model('merchant');
|
|
|
+ $merchant_info = $model_merchant->getMerchantInfo(['mchid' => $mchid]);
|
|
|
+ if (!$merchant_info) {
|
|
|
+ return self::outerr(errcode::ErrMemberNotExist, "用户不存在.");
|
|
|
+ }
|
|
|
+ $pwd = trim($new_pw);
|
|
|
+ if (md5($pwd) == $merchant_info['password']) {
|
|
|
+ return self::outsuccess([]);
|
|
|
+ }
|
|
|
+ $ret = $model_merchant->editMerchant(['password' => md5($pwd), 'org_pwd' => $pwd], ['mchid' => $merchant_info['mchid']]);
|
|
|
+ if ($ret) {
|
|
|
+ return self::outsuccess([]);
|
|
|
+ } else {
|
|
|
+ return self::outerr(errcode::ErrOperation, "系统错误.");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function pdlogOp()
|
|
|
+ {
|
|
|
+ $mchid = $this->mchid();
|
|
|
+ $model_merchant = Model('merchant');
|
|
|
+ $merchant_info = $model_merchant->getMerchantInfo(['mchid' => $mchid]);
|
|
|
+ if (!$merchant_info) {
|
|
|
+ return self::outerr(errcode::ErrMemberNotExist, "用户不存在.");
|
|
|
+ }
|
|
|
+ $model_pd = Model('merchant');
|
|
|
+ if (empty($merchant_info['admin_id'])) {
|
|
|
+ $result['data'] = [];
|
|
|
+ $result['total'] = 0;
|
|
|
+ return self::outsuccess($result);
|
|
|
+ }
|
|
|
+ $cond['lg_member_id'] = $merchant_info['admin_id'];
|
|
|
+ if (!empty($_GET['lg_type'])) {
|
|
|
+ $cond['lg_type'] = $_GET['lg_type'];
|
|
|
+ }
|
|
|
+ if ($_GET['start_time'] && $_GET['end_time']) {
|
|
|
+ $cond['lg_add_time'] = ['between', [$_GET['start_time'], $_GET['end_time']]];
|
|
|
+ }
|
|
|
+ $list = $model_pd->getPdlog($cond, $this->page, '*', 'lg_id desc');
|
|
|
+ $list = $this->PdLogFormat($list);
|
|
|
+ $result['data'] = $list;
|
|
|
+ $result['total'] = $model_pd->gettotalpage();
|
|
|
+ return self::outsuccess($result);
|
|
|
+ }
|
|
|
+
|
|
|
+ private function PdLogFormat($pdlog)
|
|
|
+ {
|
|
|
+ $data = [];
|
|
|
+ foreach ($pdlog as $key => $value) {
|
|
|
+ if (isset($value['lg_add_time'])) {
|
|
|
+ $value['lg_add_time'] = date('Y-m-d H:i:s', $value['lg_add_time']);
|
|
|
+ }
|
|
|
+ switch ($value['lg_type']) {
|
|
|
+ case 'order_pay':
|
|
|
+ $value['lg_type_text'] = '下单减款';
|
|
|
+ break;
|
|
|
+ case 'order_cancel':
|
|
|
+ $value['lg_type_text'] = '下单失败返回余款';
|
|
|
+ break;
|
|
|
+ case 'recharge':
|
|
|
+ $value['lg_type_text'] = '余款充值';
|
|
|
+ break;
|
|
|
+ case 'sys_add_money':
|
|
|
+ $value['lg_type_text'] = '管理员调节预存款【增加】';
|
|
|
+ break;
|
|
|
+ case 'sys_del_money':
|
|
|
+ $value['lg_type_text'] = '管理员调节预存款【减少】';
|
|
|
+ break;
|
|
|
+ case 'sys_freeze_money':
|
|
|
+ $value['lg_type_text'] = '管理员调节预存款【冻结】';
|
|
|
+ break;
|
|
|
+ case 'sys_unfreeze_money':
|
|
|
+ $value['lg_type_text'] = '管理员调节预存款【解冻】';
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ $value['lg_type_text'] = 'unknown';
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ $data[] = $value;
|
|
|
+ }
|
|
|
+ return $data;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function pdlogexportOp()
|
|
|
+ {
|
|
|
+ $mchid = $this->mchid();
|
|
|
+ $model_merchant = Model('merchant');
|
|
|
+ $merchant_info = $model_merchant->getMerchantInfo(['mchid' => $mchid]);
|
|
|
+ if (!$merchant_info) {
|
|
|
+ return self::outerr(errcode::ErrMemberNotExist, "用户不存在.");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $condition['lg_member_id'] = $merchant_info['admin_id'];
|
|
|
+ if (!empty($_GET['lg_type'])) {
|
|
|
+ $condition['lg_type'] = $_GET['lg_type'];
|
|
|
+ }
|
|
|
+ if ($_GET['start_time'] && $_GET['end_time']) {
|
|
|
+ $condition['lg_add_time'] = ['between', [$_GET['start_time'], $_GET['end_time']]];
|
|
|
+ }
|
|
|
+ $list = Model('')->table('pd_log,refill_order')->join('left')
|
|
|
+ ->on('pd_log.lg_order_sn=refill_order.order_sn')
|
|
|
+ ->field('pd_log.lg_type,pd_log.lg_av_amount,pd_log.lg_add_time,refill_order.card_no,refill_order.mchid,refill_order.card_type,pd_log.lg_available,refill_order.refill_amount')
|
|
|
+ ->where($condition)->select();
|
|
|
+ $result = $this->export_pdlog_exec($list);
|
|
|
+ return self::outsuccess($result);
|
|
|
+ }
|
|
|
+
|
|
|
+ private function export_pdlog_exec($list)
|
|
|
+ {
|
|
|
+ $title = [
|
|
|
+ ['value' => '代理商账号'],
|
|
|
+ ['value' => '金额'],
|
|
|
+ ['value' => '账户余额'],
|
|
|
+ ['value' => '交易日期'],
|
|
|
+ ['value' => '类型'],
|
|
|
+ ['value' => '备注']
|
|
|
+ ];
|
|
|
+ $mchid = $this->mchid();
|
|
|
+ $card_type = ['1'=>'中石油' , '2' =>'中石化' , '4' => '移动' , '5' => '联通' , '6' => '电信'];
|
|
|
+ foreach ($list as $value) {
|
|
|
+ if (isset($value['lg_add_time'])) {
|
|
|
+ $value['lg_add_time'] = date('Y-m-d H:i:s', $value['lg_add_time']);
|
|
|
+ }
|
|
|
+ switch ($value['lg_type']) {
|
|
|
+ case 'order_pay':
|
|
|
+ $value['lg_type_text'] = '消费';
|
|
|
+ break;
|
|
|
+ case 'order_cancel':
|
|
|
+ $value['lg_type_text'] = '退款';
|
|
|
+ break;
|
|
|
+ case 'recharge':
|
|
|
+ $value['lg_type_text'] = '充值';
|
|
|
+ break;
|
|
|
+ case 'sys_add_money':
|
|
|
+ $value['lg_type_text'] = '管理员充值【增加】';
|
|
|
+ break;
|
|
|
+ case 'sys_del_money':
|
|
|
+ $value['lg_type_text'] = '管理员减款';
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ $value['lg_type_text'] = '';
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ $data = [];
|
|
|
+ $str = "{$value['card_no']}-{$card_type[$value['card_type']]}{$value['refill_amount']}元";
|
|
|
+ if(empty($value['card_no']) || empty($value['card_type']) || empty($value['refill_amount'])) {
|
|
|
+ $str = '';
|
|
|
+ }
|
|
|
+ $data[] = ['value' => $mchid];
|
|
|
+ $data[] = ['value' => $value['lg_av_amount']];
|
|
|
+ $data[] = ['value' => ncPriceFormat($value['lg_available'] + $value['lg_av_amount'])];
|
|
|
+ $data[] = ['value' => $value['lg_add_time']];
|
|
|
+ $data[] = ['value' => $value['lg_type_text']];
|
|
|
+ $data[] = ['value' => $str];
|
|
|
+ $datas[] = $data;
|
|
|
+ }
|
|
|
+ Log::record(json_encode($datas),Log::DEBUG);
|
|
|
+ return ['title' => $title , 'data' => $datas];
|
|
|
+ }
|
|
|
+}
|