rabin 2 yıl önce
ebeveyn
işleme
8f8cce51df

+ 4 - 7
app/shop/database/user_money.php

@@ -23,17 +23,14 @@ $type = array
     11 => '提现',
 );
 $excel = false;
-if(Dever::load('manage/auth')->checkFunc('menu_244.menu_245', 'editCout', '数据导出')){
-    $excel[] = array('数据导出','代理商分润', 'bill/lib/cash.out_cash');
-}
 
 $list_button = array();
-$list_button['list'] = array('查看详情', '"push_cash&project=bill&id={id}&page_type=1&[refer]"');
+$list_button['list'] = array('查看详情', '"user_money_push&project=shop&id={id}&page_type=1&[refer]"');
 if (Dever::load('manage/auth')->checkFunc('bill.tixian', 'edit', '审核')) {
     $list_button['fast'] = array('审核', '"cash&where_id={id}&col=audit,audit_desc&oper_save_jump=cash&oper_table=cash&oper_parent=cash"', '{status} == 1');
 }
 $mul = false;
-if (Dever::load('manage/auth')->checkFunc('bill.tixian', 'tixianedit', '批量审核')) {
+if (Dever::load('manage/auth')->checkFunc('shop.user_money', 'user_money', '批量审核')) {
     $mul = '{status} == 1';
 }
 $button = array();
@@ -131,7 +128,7 @@ return array
             'update'    => 'text',
             'list_name' => '交易金额<br />账户余额',
             'list'      =>'Dever::load("shop/lib/money.getCash", {id})',
-            'list_order' => 4,
+            'list_order' => 3,
         ),
 
         'yue'      => array
@@ -158,7 +155,7 @@ return array
             'search'    => 'select',
             'list'      => true,
             'list_name' => '交易状态',
-            'list_order' => 3,
+            'list_order' => 4,
         ),
 
         'audit'        => array

+ 80 - 0
app/shop/database/user_money_sign.php

@@ -0,0 +1,80 @@
+<?php
+
+$status = array
+(
+    1 => array('name' => '待入账', 'style' => 'font-weight:bold;color:#436EEE'),
+    2 => array('name' => '已入账', 'style' => 'font-weight:bold;color:green'),
+    3 => array('name' => '已作废', 'style' => 'font-weight:bold;color:#CD3700'),
+);
+
+return array
+(
+    # 表名
+    'name' => 'use_money_sign',
+    # 显示给用户看的名称
+    'lang' => '用户资金流水',
+    'order' => 99,
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            //'list'        => true,
+        ),
+
+        'uid'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '用户信息',
+            'default'   => '-1',
+            'desc'      => '用户信息',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'list'      =>'Dever::load("shop/lib/money.showUser", {uid})',
+            'list_order' => 2,
+        ),
+
+        
+        'state'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '请选择状态',
+            'match'     => 'is_numeric',
+        ),
+        
+        'cdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '交易时间',
+            'match'     => array('is_numeric', time()),
+            'desc'      => '',
+            # 只有insert时才生效
+            'insert'    => true,
+            'search'    => 'date',
+            //'list_name'      => '交易时间<br />审核时间',
+            //'list'      => 'Dever::load("bill/lib/cash.order_num#num", {id})',
+            //'list_order'  => 20,
+        ),
+    ),
+
+    'manage' => array
+    (
+        'insert' => false,
+        'delete' => false,
+        'edit' => false,
+    ),
+
+    'request' => array
+    (
+        
+    ),
+);

+ 395 - 0
app/shop/lib/Money.php

@@ -0,0 +1,395 @@
+<?php
+
+namespace Shop\Lib;
+
+use Dever;
+
+class Money
+{
+    # 查看用户信息
+    public function showUser($uid)
+    {
+        $user = Dever::db('passport/user')->one($uid);
+
+        return $user['username'] . '<br />' . $user['mobile'];
+    }
+
+    public function getCash($id)
+    {
+        $info = Dever::db('shop/user_money')->find($id);
+        $cdate = date('Y-m-d H:i',$info['cdate']);
+        $odate = '';
+        if ($info['operdate']) {
+            $odate = date('Y-m-d H:i',$info['operdate']);
+        }
+        return $info['cash'] . '<br />' . $info['yue'];
+    }
+
+    # 发起支付
+    public function pay($uid, $cash)
+    {
+        $openid = false;
+        if ($uid > 0) {
+            $wechat = Dever::db('passport/wechat')->one(array('uid' => $uid, 'type' => 1, 'system_id' => 1));
+
+            if (!$wechat) {
+                Dever::alert('错误的用户信息');
+            }
+
+            $openid = $wechat['openid'];
+        }
+        $param = array
+        (
+            'project_id' => 5,
+            'channel_id' => 1,
+            'system_source' => 5,
+            'account_id' => 5,
+            'uid' => $uid,
+            'name' => '用户充值',
+            'openid' => $openid,
+            'cash' => $cash,
+            'product_id' => $uid,
+            'refer' => '',
+        );
+
+        $result = Dever::load('pay/api.pay', $param);
+        return $result;
+    }
+
+    # 支付成功回调 安全加密 设置token
+    public function success_secure_api_token()
+    {
+        $project_id = Dever::input('pay_project_id');
+        $info = Dever::db('pay/project')->one($project_id);
+        if ($info) {
+            return $info['key'];
+        }
+        return 'cash_buy_dever_2020';
+    }
+
+    # 支付成功回调 安全加密
+    public function success_secure_api($param = array())
+    {
+        $this->success($param);
+    }
+
+    # 支付成功回调
+    public function success($param = array())
+    {
+        $send = $param ? $param : Dever::preInput('pay_');
+        $product_id = $send['pay_product_id'];
+        $order_id = $send['pay_order_id'];
+        $status = $send['pay_status'];
+        $cash = $send['pay_cash'];
+        $msg = $send['pay_msg'];
+        if ($status == 2) {
+            $this->up($product_id, 1, $cash, $send['pay_id'], '充值', 2);
+        }
+
+        return 'ok';
+    }
+
+    public function up($uid, $type, $cash, $type_id, $desc, $status)
+    {
+        if ($cash == 0) {
+            return false;
+        }
+        $user = Dever::db('passport/user')->find(array('id' => $uid, 'clear' => true));
+        if ($user) {
+        	$where['uid'] = $uid;
+            if ($type == 11) {
+                $cash = -1*$cash;
+            }
+        	$where['type'] = $type;
+        	$where['type_id'] = $type_id;
+        	$where['clear'] = true;
+        	$info = Dever::db('shop/user_money')->find($where);
+        	if (!$info) {
+        		$data = $where;
+        		$data['order_num'] = $this->getOrderId();
+        		$data['yue'] = $user['cash'] + $cash;
+        		$data['cash'] = $cash;
+        		$data['desc'] = $desc;
+        		$data['status'] = $status;
+                if ($status == 2) {
+                    $data['operdate'] = time();
+                }
+
+                $update['where_id'] = $uid;
+                $update['set_cash'] = $cash;
+                //$update['clear'] = true;
+                Dever::db('passport/user')->upCash($update);
+                return Dever::db('shop/user_money')->insert($data);
+        	}
+            return $info['id'];
+        }
+
+        return false;
+    }
+
+    /**
+     * 生成订单号
+     *
+     * @return mixed
+     */
+    public function getOrderId()
+    {
+        $where['order_num'] = Dever::order('UM');
+        $where['clear'] = true;
+        $state = Dever::db('shop/user_money')->one($where);
+        if (!$state) {
+            return $where['order_num'];
+        } else {
+            return $this->getOrderId();
+        }
+    }
+
+    # 展示详情
+    public function show()
+    {
+        $id = Dever::input('id');
+
+        $config = Dever::db('shop/user_money')->config['set'];
+
+        $info = Dever::db('shop/user_money')->one($id);
+
+        $status = $config['status'][$info['status']];
+
+        $type = $config['type'][$info['type']];
+
+        $user = Dever::db('passport/user')->find($info['uid']);
+
+        $cdate = date('Y-m-d H:i', $info['cdate']);
+        if ($info['operdate']) {
+            $opertime = date('Y-m-d H:i', $info['operdate']);
+        } else {
+            $opertime = '';
+        }
+
+        $result = array();
+
+        $result['用户信息'] = array
+        (
+            'type' => 'info',
+            'content' => array
+            (
+                array
+                (
+                    array('昵称', $user['username']),
+                    array('手机号', $user['mobile']),
+                    array('资金余额', '¥' . $member['cash'] . '元'),
+                ),
+            ),
+        );
+
+        $result['交易信息'] = array
+        (
+            'type' => 'info',
+            'content' => array
+            (
+                array
+                (
+                    array('流水号', $info['order_num']),
+                    array('交易时间', $cdate),
+                    array('交易类型', $type),
+                ),
+
+                array
+                (
+                    array('交易金额', '¥' . $info['cash'] . '元'),
+                    array('交易后账户余额', '¥' . $info['yue'] . '元'),
+                    array('交易说明', $info['desc']),
+                ),
+            )
+        );
+
+        $result['审核信息'] = array
+        (
+            'type' => 'info',
+            'content' => array
+            (
+                array
+                (
+                    array('审核时间', $opertime),
+                    array('审核状态', $status),
+                    array('备注', $info['audit_desc']),
+                ),
+            )
+        );
+        
+        # 提现信息
+        $button = array();
+        
+        if (Dever::load('manage/auth')->checkFunc('bill.tixian', 'edit', '审核')) {
+        	if ($info['status'] == 1) {
+                $button[] = array
+                (
+                    'type' => 'edit',
+                    'link' => Dever::url('project/database/update?project=bill&table=cash&where_id='.$info['id'].'&col=audit,audit_desc&oper_save_jump=cash&oper_table=cash&oper_parent=cash', 'manage'),
+                    'name' => '审核',
+                );
+            }
+        }
+        if ($info['type'] == 11) {
+            $tixian = Dever::db('bill/tixian')->find($info['type_id']);
+            if ($tixian) {
+                $config = Dever::db('bill/tixian')->config['set'];
+                $status = $config['status'][$tixian['status']];
+
+                if (Dever::load('manage/auth')->checkFunc('bill.tixian', 'edit1', '发放')) {
+                    if ($info['status'] == 2 && $tixian['status'] == 1) {
+                        $button[] = array
+                        (
+                            'type' => 'edit',
+                            'link' => Dever::url('project/database/update?project=bill&table=tixian&where_id='.$tixian['id'].'&col=audit,audit_desc,pic&oper_save_jump=tixian&oper_table=tixian&oper_parent=tixian', 'manage'),
+                            'name' => '发放',
+                        );
+                    }
+                }
+
+                /*
+                $bank = Dever::db('setting/bank')->find($tixian['bank']);
+                $result['提现信息'] = array
+                (
+                    'type' => 'info',
+                    'content' => array
+                    (
+                        array
+                        (
+                            array('银行名称', $bank['name']),
+                            array('开户行', $tixian['bankname']),
+                        ),
+
+                        array
+                        (
+                            array('姓名', $tixian['name']),
+                            array('卡号', $tixian['card']),
+                        ),
+                    )
+                );
+                */
+
+                if ($tixian['status']) {
+                    if ($tixian['operdate']) {
+                        $opertime = date('Y-m-d H:i', $tixian['operdate']);
+                    } else {
+                        $opertime = '';
+                    }
+                    $pic = '';
+                    if ($tixian['pic']) {
+                        $temp = explode(',', $tixian['pic']);
+                        foreach ($temp as $k => $v) {
+                            $pic .= '<a href="'.Dever::pic($v).'" target="_blank"><img src="'.Dever::pic($v).'" width="150" /></a>';
+                        }
+                    }
+                    $result['发放信息'] = array
+                    (
+                        'type' => 'info',
+                        'content' => array
+                        (
+                            array
+                            (
+                                array('发放时间', $opertime),
+                                array('发放状态', $status),
+                                array('备注', $tixian['audit_desc']),
+                            ),
+                            array
+                            (
+                                array('凭证', $pic),
+                            ),
+                        )
+                    );
+                }
+                
+            }
+        }
+         $button[] = array
+        (
+            'type' => 'link',
+            'link' => 'refer',
+            'name' => '返回上一页',
+        );
+        $head = array
+        (
+            'name' => '基本信息',
+            'btn' => $button,
+        );
+        $html = Dever::show($head, $result);
+
+        return $html;
+    }
+    public function order_num($id){
+        $info = Dever::db('shop/user_money')->find($id);
+        $cdate = date('Y-m-d H:i',$info['cdate']);
+        $odate = '';
+        if ($info['operdate']) {
+            $odate = date('Y-m-d H:i',$info['operdate']);
+        }
+        $html['num'] = $cdate . '<br/>'.$odate;
+        $html['cash'] = $info['cash'] . '<br />' . $info['yue'];
+        return $html;
+    }
+    #钱包管理数据导出
+    public function out_cash_api($data){
+        $header = array('邀请码', '姓名', '手机号', '身份证号', '代理角色', '代理商区域', '代理费', '审核时间', '直推收入', '团队收入', '管理员备注');
+        $body = array();
+        foreach($data as $k =>$v){
+            $arr[] = Dever::db('agent/member')->find(array('id'=>$v['mid']));
+            foreach($arr as $k1=>$v1){
+                if($v['mid'] == $v1['id']){
+                    $arr[$k1]['operdate'] = $v['operdate'];
+                    $arr[$k1]['audit_desc'] = $v['audit_desc'];
+                }
+            }
+        }
+        $member = array();
+        $arr=array_unique($arr, SORT_REGULAR);
+        $rest=array();
+        foreach($arr as $k=>$v){
+            $rest[$v['id']]=$v;
+        }
+        $member=array_values($rest);
+        foreach($member as $k => $v){
+            $code = Dever::load("invite/api.code", $v['id']);
+            $role = Dever::db('setting/role')->find(array('id'=>$v['role']));
+            $area = Dever::load("area/api.string", $v['area']);
+            $order = Dever::db('agent/order')->state(array('mid'=>$v['id']));
+            $zhitui = Dever::db('shop/user_money')->state(array('mid'=>$v['id'],'type'=>1));
+            $total = 0;
+            foreach($zhitui as $key => $val){
+                $total += $val['cash'];
+            }
+            $tuandui = Dever::db('shop/user_money')->state(array('mid'=>$v['id'],'type'=>2));
+            $tuan = 0;
+            foreach($tuandui as $t){
+                $tuan += $t['cash'];
+            }
+            $sum = 0;
+            foreach($order as $k1 => $v1){
+                $sum += $v1['agent_cash']; 
+            }
+            $operdate = '';
+            if($v['operdate']){
+                $operdate = date('Y-m-d',$v['operdate']);
+            }
+            $d = array
+            (
+                $code,
+                $v['name'],
+                $v['mobile'],
+                $v['idcard'],
+                $role['name'],
+                $area,
+                $sum,
+                $operdate,
+                $total,
+                $tuan,
+                $v['audit_desc'],
+            );
+            $body[] = $d;
+        }
+        $file = Dever::input('excel_name');
+        return Dever::excelExport($body, $header, $file);
+    }
+
+}

+ 76 - 5
app/shop/src/My.php

@@ -121,11 +121,82 @@ class My extends Core
 		return Dever::load('shop/lib/money')->pay($this->uid, $num);
 	}
 
-	# 提现
-	public function tixian()
-	{
-		
-	}
+	# 提现详情
+    public function tixianInfo()
+    {
+        $this->data['user'] = $this->user;
+        $this->data['config'] = Dever::db('main/sell_config')->one();
+        $this->data['config']['tax'] = $this->data['config']['cash_tx']/100;
+
+        # 是否签约过
+        
+        
+        return $this->data;
+    }
+
+    # 确定提现
+    public function tixian_commit()
+    {
+        if (!$this->user['idcard']) {
+            Dever::alert('未做身份证号认证,请先做身份认证');
+        }
+        $cash = Dever::input('cash');
+        if ($cash > $this->user['cash']) {
+            Dever::alert('您的可提现金额不足');
+        }
+        if ($cash < 50) {
+            Dever::alert('未满50元不可提现');
+        }
+        /*
+        $name = Dever::input('name');
+        if (!$name) {
+            Dever::alert('姓名不能为空');
+        }
+        $bank = Dever::input('bank');
+        if (!$bank) {
+            Dever::alert('银行不能为空');
+        }
+        $bankname = Dever::input('bankname');
+        if (!$bankname) {
+            Dever::alert('开户行不能为空');
+        }
+        $card = Dever::input('card');
+        if (!$card) {
+            Dever::alert('银行卡号不能为空');
+        }
+        $ycard = Dever::input('ycard');
+        if (!$ycard) {
+            Dever::alert('确认银行卡号不能为空');
+        }
+        if ($card != $ycard) {
+            Dever::alert('银行卡号和确认银行卡号不同');
+        }
+        */
+        $sign = Dever::input('sign');
+        if(!$sign){
+            //Dever::alert('手写签名不能为空');
+        }
+
+        $config = Dever::db('setting/base')->one();
+        $tax = $config['tax']/100;
+        $ycash = $cash;
+        $cash = $cash - $cash*$tax;
+
+        $id = Dever::load('bill/lib/tixian')->up($this->uid, $ycash, $cash, $sign);
+
+        if ($id) {
+            //$cash_id = Dever::load('bill/lib/cash')->up($this->uid, 11, $ycash, $this->user['role'], $id, '提现到'.substr($card, -4).'银行卡', 1);
+            $cash_id = Dever::load('bill/lib/cash')->up($this->uid, 11, $ycash, $this->user['role'], $id, '提现', 1);
+
+            Dever::db('bill/tixian')->update(array('where_id' => $id, 'cash_id' => $cash_id));
+
+            $where['where_id'] = $this->uid;
+            $where['cash'] = -1*$ycash;
+            Dever::db('agent/member')->upCash($where);
+        }
+
+        return 'ok';
+    }
 
 	public function getBindInfo()
 	{