dever vor 3 Jahren
Ursprung
Commit
fc1526b015

+ 2 - 6
app/cash/database/factory.php

@@ -6,16 +6,12 @@ $status = array
     2 => '已对账',
 );
 
-$type = array
-(
-    1 => '按月对账',
-    2 => '按周对账',
-);
+$type = Dever::db('cash/shop')->config['config_type'];
 
 $factory = function()
 {
     $array = array();
-    $info = Dever::db('factory/info')->all();
+    $info = Dever::db('factory/info')->state();
     if($info)
     {
         $array += $info;

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

@@ -75,17 +75,14 @@ if ($search == 1) {
     $search_name = '结算门店';
     $search_option = $shop;
     $search_url = 'shop/lib/manage.search';
-    Dever::setInput('search_option_type', 1);
 } elseif ($search == 2) {
     $search_name = '结算仓库';
     $search_option = $store;
     $search_url = 'store/lib/manage.search';
-    Dever::setInput('search_option_type', 2);
 } if ($search == 3) {
     $search_name = '结算工厂';
     $search_option = $factory;
     $search_url = 'factory/lib/manage.search';
-    Dever::setInput('search_option_source_type', 3);
 }
 
 return array

+ 2 - 1
app/cash/database/shop.php

@@ -10,12 +10,13 @@ $type = array
 (
     1 => '按月对账',
     2 => '按周对账',
+    3 => '按天对账',
 );
 
 $shop = function()
 {
 	$array = array();
-	$info = Dever::db('shop/info')->all();
+	$info = Dever::db('shop/info')->state();
 	if($info)
 	{
 		$array += $info;

+ 2 - 6
app/cash/database/store.php

@@ -6,16 +6,12 @@ $status = array
     2 => '已对账',
 );
 
-$type = array
-(
-    1 => '按月对账',
-    2 => '按周对账',
-);
+$type = Dever::db('cash/shop')->config['config_type'];
 
 $store = function()
 {
     $array = array();
-    $info = Dever::db('store/info')->all();
+    $info = Dever::db('store/info')->state();
     if($info)
     {
         $array += $info;

+ 39 - 7
app/cash/lib/Cron.php

@@ -6,11 +6,34 @@ use Dever;
 
 class Cron
 {
+    private function check($info)
+    {
+        if (!$info['stat_day']) {
+            $info['stat_day'] = 1;
+        }
+
+        if ($info['stat_type'] == 1) {
+            $day = intval(date('d'));
+            if ($day != $info['stat_day']) {
+                return false;
+            }
+        } elseif ($info['stat_type'] == 2) {
+            $day = intval(date('w'));
+            if (!$day || $day == 0) {
+                $day = 7;
+            }
+            if ($day != $info['stat_day']) {
+                return false;
+            }
+        }
+        return true;
+    }
+
     # 处理门店对账单
     public function shop_api(){}
     public function shop()
     {
-        $num = Dever::input('num', -1);
+        $num = Dever::input('num', 1);
 
         $where['status'] = 2;
        
@@ -26,7 +49,7 @@ class Cron
     public function store_api(){}
     public function store()
     {
-        $num = Dever::input('num', -1);
+        $num = Dever::input('num', 1);
 
         $where['status'] = 2;
        
@@ -36,13 +59,17 @@ class Cron
             $where['type'] = 2;
             $where['type_id'] = $v['id'];
             $this->up($where, $v, 'store', $num);
+
+            $where['source_type'] = 2;
+            $where['source_id'] = $v['id'];
+            $this->up($where, $v, 'store', $num);
         }
     }
 
     public function factory_api(){}
     public function factory()
     {
-        $num = Dever::input('num', -1);
+        $num = Dever::input('num', 1);
 
         $where['status'] = 2;
        
@@ -57,11 +84,17 @@ class Cron
 
     private function up($where, $info, $type, $num)
     {
-        if ($info['stat_type'] == 2) {
+        $state = $this->check($info);
+        if (!$state) {
+            return;
+        }
+        if ($info['stat_type'] == 1) {
+    		$method = 'month';
+    	} elseif ($info['stat_type'] == 2) {
     		$method = 'week';
     	} else {
-    		$method = 'month';
-    	}
+            $method = 'day';
+        }
 
     	list($start, $end) = Dever::$method($num);
 
@@ -88,7 +121,6 @@ class Cron
         $data['num'] = $num['total'] ? $num['total'] : 0;
         $data['start'] = $start;
         $data['end'] = $end;
-
         if (!$find) {
             $id = Dever::db('cash/' . $type)->insert($data);
         } else {

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

@@ -52,7 +52,7 @@ class Set
             Dever::load('shop/lib/refund')->set('buy')->action($info['refund_id'], $audit, false, false);
 
             if ($audit == 2) {
-                Dever::db('cash/order')->update(array('where_id' => $id, 'status' => 2));
+                Dever::db('cash/order')->update(array('where_id' => $id, 'status' => 2, 'operdate' => time()));
             }
         }
     }

+ 3 - 1
app/factory/database/info.php

@@ -325,12 +325,13 @@ return array
         'stat_type'        => array
         (
             'type'      => 'int-11',
-            'name'      => '对账周期-可以选择按月还是按周生成对账单',
+            'name'      => '对账周期-可以选择周生成对账单,选择按天生成对账单,则每天会生成前一天的对账单',
             'default'   => '1',
             'desc'      => '对账周期',
             'match'     => 'is_numeric',
             'update'    => 'radio',
             'option'    => $stat_type,
+            'control'   => 'stat_type',
         ),
 
         'stat_day'      => array
@@ -341,6 +342,7 @@ return array
             'desc'      => '对账单生成日期',
             'match'     => 'option',
             'update'    => 'text',
+            'show'      => 'stat_type=1,2',
         ),
 
         'reorder'       => array

+ 3 - 1
app/shop/database/info.php

@@ -514,12 +514,13 @@ return array
         'stat_type'        => array
         (
             'type'      => 'int-11',
-            'name'      => '对账周期-可以选择按月还是按周生成对账单',
+            'name'      => '对账周期-可以选择周生成对账单,选择按天生成对账单,则每天会生成前一天的对账单',
             'default'   => '1',
             'desc'      => '对账周期',
             'match'     => 'is_numeric',
             'update'    => 'radio',
             'option'    => $stat_type,
+            'control'   => 'stat_type',
         ),
 
         'stat_day'      => array
@@ -530,6 +531,7 @@ return array
             'desc'      => '对账单生成日期',
             'match'     => 'option',
             'update'    => 'text',
+            'show'      => 'stat_type=1,2',
         ),
 
         'status'        => array

+ 3 - 1
app/shop/lib/Manage.php

@@ -11,7 +11,9 @@ class Manage
         $url = Dever::load('manage/database')->url('list', $order_id, 'buy_order_goods&project=shop&order_id='.$order_id.'&page_type=1');
 
         if ($search == 3) {
-            $url .= '&type=2&search_option_type=2';
+            $url .= '&type=2&search_option_source_type=3';
+        } elseif ($search == 2) {
+            $url .= '&type=1&search_option_type=2';
         } else {
             $url .= '&type=1&search_option_type=1';
         }

+ 3 - 1
app/store/database/info.php

@@ -277,12 +277,13 @@ return array
         'stat_type'        => array
         (
             'type'      => 'int-11',
-            'name'      => '对账周期-可以选择按月还是按周生成对账单',
+            'name'      => '对账周期-可以选择周生成对账单,选择按天生成对账单,则每天会生成前一天的对账单',
             'default'   => '1',
             'desc'      => '对账周期',
             'match'     => 'is_numeric',
             'update'    => 'radio',
             'option'    => $stat_type,
+            'control'   => 'stat_type',
         ),
 
         'stat_day'      => array
@@ -293,6 +294,7 @@ return array
             'desc'      => '对账单生成日期',
             'match'     => 'option',
             'update'    => 'text',
+            'show'      => 'stat_type=1,2',
         ),
 
         'reorder'       => array