rabin 2 年之前
父节点
当前提交
823475e6fb

+ 10 - 1
app/cash/database/order.php

@@ -398,6 +398,7 @@ return array
                 'type_id' => 'yes',
                 'source_type' => 'yes',
                 'source_id' => 'yes',
+                'pay_type' => array('yes', 'in'),
                 'status' => array('yes', 'in'),
                 'state' => 1,
             ),
@@ -417,6 +418,7 @@ return array
                 'type_id' => 'yes',
                 'source_type' => 'yes',
                 'source_id' => 'yes',
+                'pay_type' => array('yes', 'in'),
                 'status' => array('yes', 'in'),
                 'state' => 1,
             ),
@@ -436,6 +438,7 @@ return array
                 'type_id' => 'yes',
                 'source_type' => 'yes',
                 'source_id' => 'yes',
+                'pay_type' => array('yes', 'in'),
                 'status' => array('yes', 'in'),
                 'state' => 1,
             ),
@@ -454,6 +457,7 @@ return array
                 'type_id' => 'yes',
                 'source_type' => 'yes',
                 'source_id' => 'yes',
+                'pay_type' => array('yes', 'in'),
                 'status' => array('yes', 'in'),
                 'state' => 1,
             ),
@@ -473,6 +477,7 @@ return array
                 'type_id' => array('yes-type_id', '=', 'and )'),
                 'source_type' => array('yes-source_type', '=', 'or ( '),
                 'source_id' => array('yes-source_id', '=', 'and )) '),
+                'pay_type' => array('yes', 'in'),
                 'status' => array('yes', 'in'),
                 'state' => 1,
             ),
@@ -492,6 +497,7 @@ return array
                 'type_id' => 'yes',
                 'source_type' => 'yes',
                 'source_id' => 'yes',
+                'pay_type' => array('yes', 'in'),
                 'status' => array('yes', 'in'),
                 'state' => 1,
             ),
@@ -510,6 +516,7 @@ return array
                 'type_id' => array('yes-type_id', '=', 'and )'),
                 'source_type' => array('yes-source_type', '=', 'or ( '),
                 'source_id' => array('yes-source_id', '=', 'and )) '),
+                'pay_type' => array('yes', 'in'),
                 'status' => array('yes', 'in'),
                 'state' => 1,
             ),
@@ -527,6 +534,7 @@ return array
                 'source_type' => 'yes',
                 'source_id' => 'yes',
                 'source_order_id' => array('yes', 'in'),
+                'pay_type' => array('yes', 'in'),
                 'status' => array('yes', 'in'),
                 'state' => 1,
             ),
@@ -546,6 +554,7 @@ return array
                 'pay_type' => 'yes',
                 'audit' => 'yes',
                 'jstype' => 'yes',
+                'pay_type' => array('yes', 'in'),
                 'status' => array('yes', 'in'),
                 'state' => 1,
             ),
@@ -561,7 +570,7 @@ return array
                 'end' => array('yes-cdate', '<='),
                 'type' => 'yes',
                 'type_id' => 'yes',
-                'pay_type' => 'yes',
+                'pay_type' => array('yes', 'in'),
                 'status' => array('yes', 'in'),
                 'state' => 1,
             ),

+ 211 - 0
app/cash/database/shop_sell.php

@@ -0,0 +1,211 @@
+<?php
+
+$status = array
+(
+    1 => '未对账',
+    2 => '已对账',
+);
+
+$type = array
+(
+    1 => '按月对账',
+    2 => '按周对账',
+    3 => '按天对账',
+);
+
+$shop = function()
+{
+	$array = array();
+	$info = Dever::db('shop/info')->state();
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+return array
+(
+    # 表名
+    'name' => 'shop_sell',
+    # 显示给用户看的名称
+    'lang' => '门店零售对账单',
+    'order' => 89,
+    'config_status' => $status,
+    'config_type' => $type,
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            //'list'      => true,
+        ),
+
+        'type'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '对账单类型',
+            'default'   => '1',
+            'desc'      => '对账单类型',
+            'match'     => 'is_numeric',
+        ),
+
+        'day'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '对账单时间',
+            'default'   => '',
+            'match'     => 'is_numeric',
+            'desc'      => '',
+            'search'	=> 'day',
+            'order'		=> 'desc',
+            'list'      => 'Dever::load("cash/lib/set.statDate", "{type}", "{day}")',
+        ),
+
+        'shop_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '对账门店',
+            'default'   => '',
+            'desc'      => '对账门店',
+            'match'     => 'is_numeric',
+            'search'    => 'select',
+            'option'    => $shop,
+            'update'    => 'hidden',
+            'value'     => Dever::input('search_option_shop_id'),
+            'list'      => 'Dever::load("shop/info-one#name", {shop_id})',
+        ),
+
+        'start'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '对账单开始时间',
+            'default'   => '',
+            'match'     => 'is_numeric',
+            'desc'      => '',
+        ),
+
+        'end'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '对账单结束时间',
+            'default'   => '',
+            'match'     => 'is_numeric',
+            'desc'      => '',
+            'list_name'	=> '对账周期',
+            'list'		=> 'Dever::load("cash/lib/set.statTime", "{start}", "{end}")',
+        ),
+
+        'cash'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '对账金额',
+            'default'   => '0',
+            'desc'      => '对账金额',
+            'match'     => 'option',
+            'update'    => 'text',
+            'list'      => 'Dever::load("cash/lib/set.getCash", "{cash}")',
+        ),
+
+        'num'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '对账数量',
+            'default'   => '0',
+            'desc'      => '对账数量',
+            'match'     => 'option',
+            'update'    => 'text',
+            //'list'		=> true,
+        ),
+
+        'shop_status'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '门店对账状态',
+            'default'   => '1',
+            'desc'      => '门店对账状态',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'search'    => 'select',
+            'option'    => $status,
+            'list'      => true,
+        ),
+
+        'status'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '平台对账状态',
+            'default'   => '1',
+            'desc'      => '平台对账状态',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'search'    => 'select',
+            'option'    => $status,
+            'list'      => true,
+        ),
+
+        '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})',
+            //'list'      => 'Dever::load("service/lib/manage.showOrderTime", "{id}")',
+        ),
+    ),
+
+    'manage' => array
+    (
+        'delete' => false,
+        'edit' => false,
+        'insert' => false,
+        'excel'	=> true,
+
+        'list_button' => array(
+
+        	'list' => array('查看详情', '"order&project=cash&id={id}&page_type=1&type=shop_sell"'),
+
+            'oper'  => array('确认对账金额', '"cash/lib/set.audit?id={id}&type=shop_sell"', '{status} == 1', 'Dever::load("cash/lib/set.statYes", "{id}", "shop_sell")', '请确认'),
+        ),
+    ),
+
+    'request' => array
+    (
+        # 获取总金额
+        'getAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'start' => array('yes-day', '>='),
+                'end' => array('yes-day', '<='),
+                'shop_id' => 'yes',
+                'status' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'page' => array(10, 'list'),
+            'col' => '*',
+        ),
+    ),
+);

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

@@ -29,7 +29,7 @@ class Cron
         return true;
     }
 
-    # 处理门店对账单
+    # 处理门店采购对账单
     public function shop_api(){}
     public function shop()
     {
@@ -42,10 +42,29 @@ class Cron
         foreach ($shop as $k => $v) {
         	$where['type'] = 1;
             $where['type_id'] = $v['id'];
+            $where['pay_type'] = 1;
         	$this->up($where, $v, 'shop', $num);
         }
     }
 
+    # 处理门店零售对账单
+    public function shop_sell_api(){}
+    public function shop_sell()
+    {
+        $num = Dever::input('num', 1);
+
+        $where['status'] = 2;
+       
+        $shop = Dever::db('shop/info')->select();
+
+        foreach ($shop as $k => $v) {
+            $where['type'] = 1;
+            $where['type_id'] = $v['id'];
+            $where['pay_type'] = '2,3';
+            $this->up($where, $v, 'shop', $num);
+        }
+    }
+
     public function store_api(){}
     public function store()
     {

+ 39 - 26
app/cash/lib/Set.php

@@ -94,28 +94,28 @@ class Set
         $type = Dever::input('type', 'shop');
         $table = 'cash/' . $type;
 
-        $info = Dever::db($table)->one($id);
+        $data = Dever::db($table)->one($id);
         
-        if ($info) {
+        if ($data) {
             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));
+
+            if ($type == 'shop_sell') {
+                $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);
+                }
+                $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);
+                }
             }
         }
 
@@ -147,11 +147,15 @@ class Set
         }
 
         $show = Dever::input('show', 1);
-
         $type = Dever::input('type', 'shop');
+        $pay_type = 1;
         if ($type == 'shop') {
             $search_option_type = 1;
             $name = '门店';
+        } if ($type == 'shop_sell') {
+            $search_option_type = 1;
+            $pay_type = '2,3';
+            $name = '门店零售';
         } elseif ($type == 'store') {
             $search_option_type = 3;
             $name = '仓库';
@@ -266,7 +270,7 @@ class Set
 
         $html .= '</tbody></table></div></div>';
 
-        $data = $this->getOrderData($type, $info, '');
+        $data = $this->getOrderData($type, $info, '', $pay_type);
 
         if ($data) {
             
@@ -394,12 +398,16 @@ class Set
         $id = Dever::input('id');
 
         $table = 'cash/' . $type;
+        $pay_type = 1;
+        if ($type == 'shop_sell') {
+            $pay_type = '2,3';
+        }
 
         $config = Dever::db($table)->config;
 
         $info = Dever::db($table)->one($id);
 
-        $data = $this->getOrderData($type, $info);
+        $data = $this->getOrderData($type, $info, 'NoPage', $pay_type);
 
         $stat_type = Dever::db('cash/shop')->config['config_type'];
         $other = Dever::db($type . '/info')->find($info[$type . '_id']);
@@ -470,8 +478,12 @@ class Set
         }
 
         $type = Dever::input('type', 'shop');
+        $pay_type = 1;
         if ($type == 'shop') {
             $name = '门店';
+        } elseif ($type == 'shop_sell') {
+            $pay_type = '2,3';
+            $name = '门店';
         } elseif ($type == 'store') {
             $name = '仓库';
         } elseif ($type == 'factory') {
@@ -506,7 +518,7 @@ class Set
 
         $pdf->hr();
 
-        $data = $this->getOrderData($type, $info);
+        $data = $this->getOrderData($type, $info, 'NoPage', $pay_type);
 
         $body = array();
         $body_total = array();
@@ -595,12 +607,13 @@ class Set
     }
 
     # 获取对账单数据
-    public function getOrderData($type, $info, $page = 'NoPage')
+    public function getOrderData($type, $info, $page = 'NoPage', $pay_type = 1)
     {
         $id = $info[$type . '_id'];;
-        if ($type == 'shop') {
+        if ($type == 'shop' || $type == 'shop_sell') {
             $where['type'] = 1;
             $where['type_id'] = $id;
+            $where['pay_type'] = $pay_type;
             $m = 'getAll';
         } elseif ($type == 'factory') {
             $where['source_type'] = 3;

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

@@ -341,7 +341,6 @@ class Buy
            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){

+ 5 - 3
app/shop/database/user_money.php

@@ -24,16 +24,18 @@ $type = array
     12 => '购买商品',
 );
 $excel = false;
-
+$mul = false;
 $list_button = array();
 $list_button['list'] = array('查看详情', '"user_money_sign&project=shop&id={id}&page_type=1&[refer]"');
-if (Dever::load('manage/auth')->checkFunc('bill.tixian', 'edit', '审核')) {
+
+/*
+if (Dever::load('manage/auth')->checkFunc('shop.user_money', '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('shop.user_money', 'user_money', '批量审核')) {
     $mul = '{status} == 1';
 }
+*/
 $button = array();
 
 return array

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

@@ -38,6 +38,10 @@ class Record
     	$where['cdate'] = time();
     	// print_R($where);die;
     	$ids = Dever::db('shop/record')->insert($where);
+
+        $update['where_id'] = $shop_id;
+        $update['set_price'] = $cash;
+        Dever::db('shop/info')->upCash($update);
     	return $ids;
     }
     #充值和提现