Your Name 2 years ago
parent
commit
3851935331

+ 16 - 0
app/cash/database/order.php

@@ -552,5 +552,21 @@ return array
             'type' => 'all',
             'col' => '*',
         ),
+        'getCardAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'start' => array('yes-cdate', '>='),
+                'end' => array('yes-cdate', '<='),
+                'type' => 'yes',
+                'type_id' => 'yes',
+                'pay_type' => 'yes',
+                'status' => array('yes', 'in'),
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'col' => 'sum(cash) as cash',
+        ),
     ),
 );

+ 20 - 1
app/cash/lib/Set.php

@@ -95,9 +95,28 @@ class Set
         $table = 'cash/' . $type;
 
         $info = Dever::db($table)->one($id);
-
+        
         if ($info) {
             Dever::db($table)->update(array('where_id' => $id, 'status' => 2));
+            $data = Dever::db('cash/shop')->find($info);
+            $card = Dever::db('cash/order')->getCardAll(array('start'=>$data['start'],'end'=>$data['end'],'pay_type'=>2,'status'=>2,'type'=>1,'type_id'=>$data['shop_id'],'state'=>1));
+            $shop = Dever::db('shop/info')->find($data['shop_id']);
+            if($card && $card['cash']>0){
+               $cash = sprintf("%01.2f", $card['cash']);
+               $yue = $shop['price'] + $cash;
+               $explan = date('Y年m月d日',$data['end']).'礼品卡对账金额';
+               Dever::load('shop/lib/record')->pingtai($data['shop_id'],$shop['sid'],8,$data['shop_id'],$cash,$yue,$explan);
+               Dever::db('shop/info')->update(array('where_id'=>$shop['id'],'price'=>$yue));
+            }
+            $bao = Dever::db('cash/order')->getCardAll(array('start'=>$data['start'],'end'=>$data['end'],'pay_type'=>3,'status'=>2,'type'=>1,'type_id'=>$data['shop_id'],'state'=>1));
+            if($bao && $bao['cash']>0){
+               $shop = Dever::db('shop/info')->find(array('id'=>$shop['id'],'s'=>1));
+               $cash = sprintf("%01.2f", $bao['cash']);
+               $yue = $shop['price'] + $cash;
+               $explan = date('Y年m月d日',$data['end']).'钱包对账金额';
+               Dever::load('shop/lib/record')->pingtai($data['shop_id'],$shop['sid'],8,$data['shop_id'],$cash,$yue,$explan);
+               Dever::db('shop/info')->update(array('where_id'=>$shop['id'],'price'=>$yue));
+            }
         }
 
         return 'reload';

+ 15 - 1
app/mshop/lib/Buy.php

@@ -309,7 +309,7 @@ class Buy
     }
 
     # 发起支付
-    public function action($uid, $type, $type_id, $name, $num, $goods, $price, $info, $refer = '', $area = '')
+    public function action($uid, $type, $type_id, $name, $num, $goods, $price, $info, $refer = '', $area = '',$method=false)
     {
         $openid = false;
         if ($uid > 0) {
@@ -337,6 +337,19 @@ class Buy
         $order_data['refund_cash'] = 0;
         $order_data['refund_p_cash'] = 0;
         $id = Dever::db('shop/buy_order')->insert($order_data);
+        if($id && $method && $method['method'] == 1){
+           if($method && isset($method['price']) && $method['price'] && $method['yue']>=0){
+                $shop = Dever::db('shop/info')->find($type_id);
+                $record = Dever::load('shop/lib/record')->pingtai($type_id,$shop['sid'],4,$id,$method['price'],$method['yue']);
+                Dever::db('shop/info')->update(array('where_id'=>$type_id,'set_price'=>$method['yue']));
+                if($method['type'] ==1){
+                    $record_cash = $method['price'];
+                }elseif($method['type'] == 2){
+                    $record_cash = $shop['price'];
+                }
+                Dever::db('shop/buy_order')->update(array('where_id'=>$id,'set_record_cash'=>$record_cash));
+           } 
+        }
 
         if (!$id) {
             Dever::alert('支付失败');
@@ -352,6 +365,7 @@ class Buy
             Dever::db('shop/buy_order_goods')->insert($data);
         }
 
+        // return  'ok';
         if ($price <= 0) {
 
             $param['pay_product_id'] = $id;

+ 24 - 1
app/mshop/src/Buy.php

@@ -74,6 +74,8 @@ class Buy extends Core
             Dever::alert('请传入商品数量');
         }
         $num = explode(',', $num);
+        #新加:
+        $method = Dever::input('method');#1是资金账户抵扣
 
         $this->data['price'] = 0;
         $this->data['num'] = 0;
@@ -95,6 +97,27 @@ class Buy extends Core
             $this->data['price'] += $this->data['list'][$k]['price'] * $n;
             $this->data['name'][] = $this->data['list'][$k]['name'];
         }
+        $this->data['method'] =array();
+        if($method == 1){
+            $this->data['method']['method'] = $method;
+            if($this->shop && $this->shop['price']){
+                if($this->shop['price']  >= $this->data['price']){
+                    $this->data['method']['type'] = 1;
+                    #花的钱
+                    $this->data['method']['price'] = $this->data['price'];
+                    $this->data['price'] = $this->shop['price'] - $this->data['price'];
+                    #余额
+                    $this->data['method']['yue'] = $this->data['price'];
+                }elseif($this->shop['price'] < $this->data['price']){
+                    $this->data['method']['type'] = 2;
+                    $this->data['method']['price'] = $this->shop['price'];
+                    $this->data['price'] = $this->data['price'] - $this->shop['price'];
+                    $this->data['method']['yue'] = 0;
+                }
+            }
+        }else{
+            $this->data['method'] = false;
+        }
 
         $this->data['name'] = implode(',', $this->data['name']);
     }
@@ -108,7 +131,7 @@ class Buy extends Core
 
         $this->goods();
 
-        $pay = Dever::load('mshop/lib/buy')->set(1,1)->action($this->passport_uid, 1, $this->shop_id, $this->data['name'], $this->data['num'], $this->data['list'], $this->data['price'], $info, $refer, $this->shop['area']);
+        $pay = Dever::load('mshop/lib/buy')->set(1,1)->action($this->passport_uid, 1, $this->shop_id, $this->data['name'], $this->data['num'], $this->data['list'], $this->data['price'], $info, $refer, $this->shop['area'],$this->data['method']);
         return $pay;
     }
 

+ 26 - 0
app/shop/assets/manage/html/record.html

@@ -0,0 +1,26 @@
+<form class="layui-form form10" action="" target="f10" method="post">
+<iframe id="f10" name="f10" style="display:none;"></iframe>
+<div class="layui-form-item" id="show">
+    <table class="layui-table">
+      <thead>
+        <tr>
+          <th>昵称</th>
+          <th>加入时间</th>
+          <th>签名</th>
+        </tr> 
+      </thead>
+      <tbody>
+        <tr>
+          <td>贤心</td>
+          <td>2016-11-29</td>
+          <td>人生就像是一场修行</td>
+        </tr>
+        <tr>
+          <td>许闲心</td>
+          <td>2016-11-28</td>
+          <td>于千万人之中遇见你所遇见的人,于千万年之中,时间的无涯的荒野里…</td>
+        </tr>
+      </tbody>
+    </table>
+</div>
+</form>

+ 25 - 0
app/shop/database/buy_order.php

@@ -280,6 +280,16 @@ $struct = array
         'list_order' => 6,
     ),
 
+    'record_cash'      => array
+    (
+        'type'      => 'varchar-50',
+        'name'      => '资金账户抵扣金额',
+        'default'   => '0',
+        'desc'      => '资金账户抵扣金额',
+        'match'     => 'option',
+        'update'    => 'text',
+    ),
+
     'refund_num'        => array
     (
         'type'      => 'int-11',
@@ -945,6 +955,21 @@ $config = array
             'type' => 'one',
             'col' => 'sum(price) as total',
         ),
+        'getNewAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'start' => array('yes-fdate', '>='),
+                'end' => array('yes-fdate', '<='),
+                'area' => array('yes', 'like'),
+                'type' => 1,
+                'status' => array('yes', 'in'),
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'col' => 'id,price',
+        ),
     ),
 );
 

+ 10 - 10
app/shop/database/info.php

@@ -594,15 +594,15 @@ return array
             'update'    => 'textarea',
         ),
 
-        // 'price'      => array
-        // (
-        //     'type'      => 'varchar-50',
-        //     'name'      => '资金账户-单位为元',
-        //     'default'   => '0',
-        //     'desc'      => '资金账户',
-        //     'match'     => 'option',
-        //     'update'    => 'text',
-        // ),
+        'price'      => array
+        (
+            'type'      => 'varchar-50',
+            'name'      => '资金账户-单位为元',
+            'default'   => '0',
+            'desc'      => '资金账户',
+            'match'     => 'option',
+            'update'    => 'text',
+        ),
 
         'stat_type'        => array
         (
@@ -710,7 +710,7 @@ return array
             'location' => array('商品设置', Dever::url('lib/set.home', 'shop')),
             //'add1' => array('批量设置商品', '"info&where_id={id}&col=goods&oper_save_jump=info&oper_table=info&oper_parent=info"'),
             'list22' => array('商品列表', '"goods&search_option_shop_id={id}&oper_table=info"'),
-
+            'list23' => array('账户管理', '"record&search_option_shop_id={id}&oper_table=info"'),
 
             'br2' => array('<br /><br />'),
 

+ 365 - 0
app/shop/database/record.php

@@ -0,0 +1,365 @@
+<?php
+$button = array();
+if (Dever::load('manage/auth')->checkFunc('shop.record', 'chongzhi', '充值')) {
+	$button['充值'] = array('fast',1,'record&type=1');
+}
+if (Dever::load('manage/auth')->checkFunc('shop.record', 'tixian', '提现')) {
+	$button['提现'] = array('fast',1,'record&type=2');
+}
+
+$excel = false;
+if (Dever::load('manage/auth')->checkFunc('shop.record', 'editrecord', '导出数据')) {
+    $excel[] = array('数据导出','资金记录明细','shop/lib/record.out_record');
+}
+$shop = function()
+{
+    $array = array();
+    $data = Dever::db('shop/info-state');
+    if($data)
+    {
+        $array += $data;
+    }
+    return $array;
+};
+$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'),
+);
+$type = array
+(
+	1 => '对公打款充值',
+	2 => '账户提现',
+	3 => '订单退货返还',
+	4 => '采购商品',
+	// 5 => '门店罚款',
+	// 6 => '平台发放',
+	// 7 => '保证金',
+	8 => '平台结算',
+);
+$manage_status = array
+(
+    //1 => '待审核',
+    2 => '已审核',
+    3 => '已作废',
+);
+$fafang_status = array
+(
+    //1 => '待审核',
+    2 => '已发放',
+    3 => '已作废',
+);
+$col = Dever::input('col');
+$list_button = array();
+$list_button['list'] = array('查看明细', '"record&project=shop&id={id}&page_type=1"');
+$list_button['fast'] = array('提现审核', '"record&where_id={id}&audit=3&col=audit,audit_desc&oper_save_jump=record&oper_table=record&oper_parent=record"', '{status} == 1');
+$shop_id = Dever::input('search_option_shop_id');
+$info = '';
+if($shop_id){
+	// print_R($shop_id);die;
+	$info = Dever::load('shop/lib/record')->getString($shop_id);
+}
+$config = array
+(
+    # 表名
+    'name' => 'record',
+    # 显示给用户看的名称
+    'lang' => '资金记录明细',
+    'order' => -10,
+    'config_type' => $type,
+    'config_status' => $status,
+    'info' => $info,
+    'end' => array
+    (
+    	'insert' => 'shop/lib/record.updateRecord', 
+    	'update' => 'shop/lib/record.RecordAuditUpdate',
+    ),
+    # 数据结构 不同的字段放这里
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            //'list'        => true,
+        ),
+
+        'shop_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '店铺名称/店铺编号',
+            'default'   => '',
+            'desc'      => '店铺名称',
+            'match'     => 'is_numeric',
+            'option'    => $shop,
+            'search'    => array
+            (
+                'api' => 'shop/info-like',
+                'col' => '*',
+                'result' => 'id',
+            ) ,
+            'list_name' => '门店信息',
+            'list'      => 'Dever::load("shop/lib/record.order_num#name", {id})',
+            'list_order' => 2,
+        ),
+
+        'sid'      => array
+        (
+            'type'      => 'varchar-30',
+            'name'      => '店铺编号-一般为5位数字,不能重复',
+            'default'   => '',
+            'desc'      => '店铺编号',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            # 绑定js脚本,更新时使用,第一个参数是执行的方式,第二个参数执行的方法,第三个参数是传值。
+            'bind'        => array('onblur', 'loading', array('url' => Dever::url("shop/lib/record.search"))),
+        ),
+      
+        'order_num'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '流水号',
+            'default'   => '',
+            'desc'      => '流水号',
+            'match'     => 'is_string',
+            // 'update'    => 'text',
+            // 'search'    => 'fulltext',
+            //'list'      => true,
+            'list_name' => '流水号<br />交易时间',
+            'list'      =>'Dever::load("shop/lib/record.order_num#num", {id})',
+            'list_order'  => 1,
+        ),
+
+        'price'      => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '金额',
+            'default'   => '0',
+            'desc'      => '金额',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            'list_name' => '交易金额<br />账户余额',
+            'list'      => 'Dever::load("shop/lib/record.order_num#price", {id})',
+            'list_order' => 5,
+        ),
+
+        'yue'      => array
+        (
+            'type'      => 'decimal-11,2',
+            'name'      => '操作后余额',
+            'default'   => '0',
+            'desc'      => '操作后余额',
+            'match'     => 'is_numeric',
+            // 'update'    => 'text',
+            // 'list'      => true,
+            // 'list_order' => 7,
+        ),
+
+        'explan'      => array
+        (
+            'type'      => 'varchar-600',
+            'name'      => '资金说明',
+            'default'   => '',
+            'desc'      => '资金说明',
+            'match'     => 'option',
+            'update'    => 'textarea',
+            // 'list'      => '"{audit_desc}" ? "{audit_desc}" : "-"',
+            // 'list_order'  => 9,
+        ),
+
+        'type'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '资金记录类型',
+            'default'   => '1',
+            'desc'      => '资金记录类型',
+            'match'     => 'is_numeric',
+            'option'    => $type,
+            'search'    => 'select',
+            'update'    => Dever::input('type') ? 'hidden' : 'select',
+            'value'     => Dever::input('type'),
+            //'search_after' => '<br />',
+            'list'      => true,
+            'list_order' => 3,
+        ),
+
+        'type_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '交易来源id',
+            'default'   => '-1',
+            'desc'      => '交易来源id',
+            'match'     => 'is_string',
+            // 'update'    => 'text',
+        ),
+
+        'status'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '资金记录状态',
+            'default'   => '1',
+            'desc'      => '资金记录状态',
+            'match'     => 'is_numeric',
+            'option'    => $status,
+            'search'    => 'select',
+            //'search_after' => '<br />',
+            'list'      => true,
+            'list_order' => 14,
+        ),
+
+        'audit'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '审核状态',
+            'default'   => '2',
+            'desc'      => '审核状态',
+            'match'     => 'is_numeric',
+            'update'    => $col ? 'radio' : false,
+            'option'    => $manage_status,
+            'mul'       => true,
+            'control'   => 'audit',
+        ),
+
+        'audit_desc'      => array
+        (
+            'type'      => 'varchar-600',
+            'name'      => '备注',
+            'default'   => '',
+            'desc'      => '审核说明',
+            'match'     => 'is_string',
+            'update'    => $col ? 'textarea' : false,
+            'list'      => '"{audit_desc}" ? "{audit_desc}" : "-"',
+            'list_order'  => 20,
+            'show'      => 'audit=3',
+        ),
+        'fafang'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '审核状态',
+            'default'   => '2',
+            'desc'      => '审核状态',
+            'match'     => 'is_numeric',
+            'update'    => $col ? 'radio' : false,
+            'option'    => $fafang_status,
+            'mul'       => true,
+            'control'   => 'fafang',
+        ),
+
+        'fafang_desc'      => array
+        (
+            'type'      => 'varchar-600',
+            'name'      => '备注',
+            'default'   => '',
+            'desc'      => '审核说明',
+            'match'     => 'is_string',
+            'update'    => $col ? 'textarea' : false,
+            // 'list'      => '"{audit_desc}" ? "{audit_desc}" : "-"',
+            // 'list_order'  => 20,
+            'show'      => 'fafang=3',
+        ),
+        'operdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '审核确认时间',
+            'default'   => '',
+            'match'     => 'is_numeric',
+            'desc'      => '',
+            //'list'      => '"{operdate}" > 0 ? date("Y-m-d H:i", {operdate}) : "-"',
+            //'list_order'  => 9,
+        ),
+
+        'pic'       => array
+        (
+            'type'      => 'text-255',
+            'name'      => '打款凭证',
+            'default'   => '',
+            'desc'      => '多张图片',
+            'match'     => 'is_string',
+            'update'    => 'images',
+            'key'       => '1',
+            // 'place'     => '759*562',
+        ),
+
+        'fpic'       => array
+        (
+            'type'      => 'text-255',
+            'name'      => '发放凭证',
+            'default'   => '',
+            'desc'      => '多张图片',
+            'match'     => 'is_string',
+            'update'    => $col ? 'images' : false,
+            'key'       => '1',
+            // 'place'     => '759*562',
+            'show'      => 'fafang=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'        => 'date("Y-m-d H:i:s", {cdate})',
+        ),
+    ),
+
+    'manage' => array
+    (
+        'insert' => false,
+        'edit' => false,
+        'delete' => false,
+        'excel' => $excel,
+        'page_list' => 'record',
+        'button' => $button,
+        'list_button' => $list_button,
+    ),
+
+    # request 请求接口定义
+    'request' => array
+    (
+        'getAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+            	'start' => array('yes-cdate','>='),
+            	'end' => array('yes-cdate','<='),
+                'shop_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('cdate'=>'desc'),
+            'col' => 'id,shop_id,price,yue,type,status,cdate',
+        ),
+        'getSearch' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'shop_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'order' => array('cdate'=>'desc'),
+            'col' => 'yue',
+        ),
+    ),
+);
+
+return $config;

+ 315 - 0
app/shop/lib/Record.php

@@ -0,0 +1,315 @@
+<?php
+
+namespace Shop\Lib;
+
+use Dever;
+
+class Record
+{
+
+    #生成订单号
+    public function getOrderId()
+    {
+        $where['order_num'] = Dever::order('R');
+        $where['clear'] = true;
+        $state = Dever::db('shop/record')->one($where);
+        if (!$state) {
+            return $where['order_num'];
+        } else {
+            return $this->getOrderId();
+        }
+    }
+    public function pingtai($shop_id,$sid,$type,$type_id,$price,$yue,$explan=false){
+    	$where['shop_id'] = $shop_id;
+    	$where['sid'] = $sid;
+    	$where['type'] = $type;
+    	$where['type_id'] = $type_id;
+    	$where['price'] = $price;
+    	$where['yue'] = $yue;
+    	$where['order_num'] = $this->getOrderId();
+    	if($explan){
+    		$where['explan'] = $explan;
+    	}
+    	if($type == 4){
+    		$where['explan'] = '采购商品';
+    	}
+    	$where['status'] = 2;
+    	$where['state'] = 1;
+    	$where['cdate'] = time();
+    	// print_R($where);die;
+    	$ids = Dever::db('shop/record')->insert($where);
+    	return $ids;
+    }
+    #充值和提现
+    public function updateRecord($id,$name,$data){
+    	$audit = Dever::input('audit',$data);
+    	$sid = Dever::input('sid',$data);
+        $info = Dever::db('shop/record')->find($id);
+       	$shop = Dever::db('shop/info')->find(array('sid'=>$info['sid']));
+        if ($info) {
+            $where['where_id'] = $shop['id'];
+            $where['price'] = $info['price'];
+            if($info['type'] ==2){
+            	if($info['price']>$shop['price']){
+            		Dever::alert('提现大于余额');
+            	}
+            	$where['price'] = 0;
+            	$insert['yue'] = $shop['price'];
+            }
+            Dever::db('shop/info')->upCash($where);
+            $ids = Dever::db('shop/info')->find(array('sid'=>$info['sid'],'s'=>1));
+            if($info['type'] == 1){
+            	$insert['yue'] = $ids['price'];
+            }
+            $insert['where_id'] = $info['id'];
+            $insert['shop_id'] = $shop['id'];
+            $insert['order_num'] = $this->getOrderId();
+            if($info['type'] == 1){
+            	$insert['status'] = 2;
+            	$insert['operdate'] = time();
+            }elseif($info['type'] == 2){
+            	$insert['status'] = 1;
+            	$insert['audit'] = 1;
+            	$insert['fafang'] = 1;
+            }
+            
+            Dever::db('shop/record')->update($insert);
+        }
+    }
+    #审核和发放
+    public function RecordAuditUpdate($id, $name, $data)
+    {
+    	Dever::config('base')->hook = true;
+        $audit = Dever::param('audit', $data);
+        if ($audit > 1) {
+            $mul_type = Dever::config('base')->mul_type;
+            if ($mul_type == 2) {
+                $list = Dever::db('shop/record')->select(array('status' => 1));
+            } else {
+                $list = explode(',', $id);
+            }
+
+            $info  = Dever::db('shop/record')->find(array('id' => $id));
+            #已审核
+            if ($audit == 2) {
+            	$shop = Dever::db('shop/info')->find($info['shop_id']);
+
+                $info = Dever::db('shop/record')->find($id);
+                if ($info) {
+                    $where['where_id'] = $info['shop_id'];
+                    
+                    if($info['type'] == 2){
+                    	if($info['price']>$shop['price']){
+                    		Dever::alert('提现大于余额');
+                    	}
+                    	$where['price'] = -1*$info['price'];
+                    	
+                		$yue = $shop['price'] + $where['price'];
+                		Dever::db('shop/record')->update(array('where_id' => $id, 'yue'=>$yue,'status' => 2, 'operdate' => time()));
+                    }else{
+                    	$where['price'] = $info['price'];
+                    	Dever::db('shop/record')->update(array('where_id' => $id, 'status' => 2, 'operdate' => time()));
+                    }
+                    
+                    Dever::db('shop/info')->upCash($where);
+                }
+            }else {
+                #作废
+                Dever::db('shop/record')->update(array('where_id' => $id, 'status' => 3, 'operdate' => time()));
+                $info = Dever::db('shop/record')->find($id);
+                if ($info && $info['type'] == 2) {
+                    $where['where_id'] = $info['shop_id'];
+                    $where['cash'] = -1*$info['price'];
+                    Dever::db('shop/info')->upCash($where);
+                }
+            }
+        }
+    }
+    #列表页展示
+    public function order_num($id){
+    	$info = Dever::db('shop/record')->find($id);
+    	$data = array();
+    	$data['num'] = $info['order_num'].'<br/>'.date('Y-m-d H:i',$info['cdate']);
+    	$shop = Dever::db('shop/info')->find($info['shop_id']);
+    	$data['name'] = $shop['name'].'<br/>'.$shop['sid'];
+    	$data['price'] = $info['price'].'<br/>'.$info['yue'];
+    	return $data;
+    }
+    #详情页展示
+    public function show(){
+    	$id = Dever::input('id');
+    	$info = Dever::db('shop/record')->find($id);
+    	$shop = Dever::db('shop/info')->find($info['shop_id']);
+    	$typeconfig = Dever::db('shop/record')->config['config_type'];
+		$type = Dever::status($typeconfig,$info['type']);
+    	$config = Dever::db('shop/record')->config['config_status'];
+		$status = Dever::status($config,$info['status']);
+		$operdate = '-';
+		if($info['operdate']){
+			$operdate = date('Y/m/d H:i',$info['operdate']);
+		}
+		$audit_name = '-';
+		if($info['audit'] == 1){
+			$audit_name = '待审核';
+		}elseif($info['audit'] == 2){
+			$audit_name = '已审核';
+		}else{
+			$audit_name = '已作废';
+		}
+		$f_name = '-';
+		if($info['fafang'] == 1){
+			$f_name = '待发放';
+		}elseif($info['fafang'] == 2){
+			$f_name = '已发放';
+		}else{
+			$f_name = '已作废';
+		}
+		
+    	$result = array();
+    	$result['门店信息'] = array
+        (
+            'type' => 'info',
+            'content' => array
+            (
+            	array
+            	(
+            		array('门店名称', $shop['name']),
+	                array('门店编号', $shop['sid']),
+	                array('负责人', $shop['truename']),
+	                array('联系电话', $shop['mobile']),
+            	),
+            ),
+        );
+        $result['交易信息'] = array
+        (
+            'type' => 'info',
+            'content' => array
+            (
+            	array
+            	(
+            		array('流水号', $info['order_num']),
+	                array('交易时间', date('Y/m/d H:i',$info['cdate'])),
+	                array('交易类型', $type),
+	                array('交易状态', $status),
+	                array('交易金额', $info['price']),
+	                array('交易后金额', $info['yue']),
+	                array('交易说明', $info['explan']),
+            	),
+            ),
+        );
+        if($info['type'] == 2){
+        	$result['提现信息'] = array
+        (
+            'type' => 'info',
+            'content' => array
+            (
+            	array
+            	(
+            		array('审核时间', $operdate),
+	                array('审核状态', $audit_name),
+	                array('备注', $info['audit_desc']),
+	                array('发放状态', $f_name),
+	                array('备注', $info['fafang_desc']),
+            	),
+            	array
+            	(
+            		array('支付凭证', $info['pic']),
+            	),
+            ),
+        );
+        }
+        $button = array();
+        if($info['type'] == 2){
+        	$purl = Dever::url('project/database/update?project=shop&table=record&where_id='.$info['id'].'&status=1&col=id,audit,audit_desc', 'manage');
+        	if($info['audit'] == 1){
+        		$button[] = array
+	            (
+	                'type' => 'edit',
+	                'link' => $purl,
+	                'name' => '审核',
+	            );
+        	}
+        	if($info['audit'] == 2 && $info['fafang'] == 1){
+        		$purl = Dever::url('project/database/update?project=shop&table=record&where_id='.$info['id'].'&status=1&col=id,fafang,fafang_desc,fpic', 'manage');
+        		$button[] = array
+	            (
+	                'type' => 'edit',
+	                'link' => $purl,
+	                'name' => '发放',
+	            );
+        	} 
+        }
+        $head = array
+        (
+            'name' => '基本资料',
+            'btn' => $button,
+        );
+        $foot = $button;
+        $html = Dever::show($head, $result, $foot);
+
+        return $html;
+    }
+
+    public function search_api()
+    {
+        $value = Dever::input('value');
+        if(!$value){
+                return '店铺编号不正确';
+            }
+        if ($value) {
+            $data = Dever::db('shop/info')->one(array('sid' => $value,'state' =>1));
+            $table = array();
+            if ($data) {
+                $table = array();
+                $table['head'] = array('序列号', '门店编号','姓名', '手机号');
+                $table['body'] = array();
+                $table['body'] = array($data['id'], $data['sid'],$data['name'], $data['mobile']);
+                
+                $result[] = array
+                (
+                    'type' => 'table',
+                    'content' => $table,
+                );
+
+                $html = Dever::show('', $result, false, false);
+                return $html;
+            }else{
+                return '店铺不存在';
+            }
+        } else {
+            return '';
+        }
+    }
+    public function out_record($data){
+    	$header = array('交易流水号','交易时间','门店名称','门店编号','门店手机号','交易类型','交易金额','交易后余额','交易状态','备注');
+    	$body = array();
+    	foreach($data as $k => $v){
+    		$shop = Dever::db('shop/info')->find($v['shop_id']);
+    		$typeconfig = Dever::db('shop/record')->config['config_type'];
+			$type = Dever::status($typeconfig,$v['type']);
+	    	$config = Dever::db('shop/record')->config['config_status'];
+			$status = Dever::status($config,$v['status']);
+			$d = array
+			(
+				$v['order_num'],
+				date('Y-m-d H:i',$v['cdate']),
+				$shop['name'],
+				$shop['sid'],
+				$shop['mobile'],
+				$type,
+				$v['price'],
+				$v['yue'],
+				$status,
+				$v['audit_desc'],
+			);
+			$body[] = $d;
+    	}
+    	$file = Dever::input('excel_name');
+        return Dever::excelExport($body, $header, $file);
+    }
+    public function getString($shop_id){
+    	$info = Dever::db('shop/info')->find($shop_id);
+    	return '门店信息:'.$info['name'].' '.$info['sid'].' '.$info['truename'].' '.$info['mobile'];
+    }
+    
+}

+ 47 - 0
app/shop/src/My.php

@@ -444,4 +444,51 @@ class My extends Core
 			return 'ok';
 		}
 	}
+
+	#资金账户列表
+	public function record_list(){
+		$shop_id = Dever::input('shop_id');
+		$month = Dever::input('month');
+		$shop = Dever::db('shop/info')->find($shop_id);
+		$data = array();
+		$data['price'] = $shop['price'];
+		if($month){
+			$start = $month .'-01 00:00:00';
+			$end = date('Y-m-d', strtotime($start. ' +1 month -1 day')).' 23:59:59';
+		}else{
+			$start = strtotime(date('Y-m'));
+			$end = strtotime(date('Y-m-d 23:59:59',strtotime(date('Y-m-01', $start)."+1 month - 1 day")));
+		}
+		$data['list'] = Dever::db('shop/record')->getAll(array('start'=>$start,'end'=>$end,'shop_id'=>$shop_id,'state'=>1));
+		foreach($data['list'] as $k=>$v){
+			if($v['type'] == 1 || $v['type'] == 3 || $v['type'] == 6 || $v['type'] == 7 || $v['type'] == 8){
+				$data['list'][$k]['price'] = '+'.$v['price'];
+			}else{
+				$data['list'][$k]['price'] = '-'.$v['price'];
+			}
+			$data['list'][$k]['cdate'] = date('Y.m.d H:i',$v['cdate']);
+			$typeconfig = Dever::db('shop/record')->config['config_type'];
+			$data['list'][$k]['type_name'] = Dever::status($typeconfig,$v['type']);
+	    	$config = Dever::db('shop/record')->config['config_status'];
+			$data['list'][$k]['status_name'] = Dever::status($config,$v['status']);
+		}
+		$data['fund'] = Dever::db('main/manage_config')->getFund(array('state'=>1));
+		return $data;
+	}
+	#资金账户详情页
+	public function record_desc(){
+		$id = Dever::input('id');
+		$data = Dever::db('shop/record')->find($id);
+		if($data['type'] == 1 || $data['type'] == 3 || $data['type'] == 6 || $data['type'] == 7 || $data['type'] == 8){
+			$data['price'] = '+'.$data['price'];
+		}else{
+			$data['price'] = '-'.$data['price'];
+		}
+		$typeconfig = Dever::db('shop/record')->config['config_type'];
+		$data['type_name'] = Dever::status($typeconfig,$data['type']);
+    	$config = Dever::db('shop/record')->config['config_status'];
+		$data['status_name'] = Dever::status($config,$data['status']);
+		$data['cdate'] = date('Y.m.d H:i',$data['cdate']);
+		return $data;
+	}
 }

+ 5 - 0
app/shop/template/manage/record.php

@@ -0,0 +1,5 @@
+<?php
+
+$view
+->fetch('#show', 'shop/lib/record.show')
+->display();

+ 24 - 0
main/database/manage_config.php

@@ -150,6 +150,17 @@ return array
             'key'       => 1,
         ),
 
+        'fund'      => array
+        (
+            'type'      => 'text-1000',
+            'name'      => '门店资金规则',
+            'default'   => '',
+            'desc'      => '门店资金规则',
+            'match'     => 'option',
+            'update'    => 'editor',
+            'key'       => 1,
+        ),
+
         'state'     => array
         (
             'type'      => 'tinyint-1',
@@ -184,4 +195,17 @@ return array
         # 后台管理不要列表页
         'list' => 'update',
     ),
+    'request' => array
+    (
+        'getFund' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'col' => 'fund',
+        ),
+    ),
 );