dever 3 年之前
父節點
當前提交
886fa0c757

+ 16 - 5
app/shop/database/buy_order.php

@@ -231,8 +231,10 @@ return array
             'option' => array
             (
                 'name' => array('yes', 'like'),
-                'shop_id' => 'yes',
-                'mobile' => 'yes',
+                'type' => 'yes',
+                'type_id' => 'yes',
+                'source_type' => 'yes',
+                'source_id' => 'yes',
                 'start' => array('yes-cdate', '>='),
                 'end' => array('yes-cdate', '<='),
                 'status' => array('yes', 'in'),
@@ -252,7 +254,10 @@ return array
             (
                 'start' => array('yes-cdate', '>='),
                 'end' => array('yes-cdate', '<='),
-                'shop_id' => 'yes',
+                'type' => 'yes',
+                'type_id' => 'yes',
+                'source_type' => 'yes',
+                'source_id' => 'yes',
                 'status' => array('yes', 'in'),
                 'state' => 1,
             ),
@@ -268,7 +273,10 @@ return array
             (
                 'start' => array('yes-cdate', '>='),
                 'end' => array('yes-cdate', '<='),
-                'shop_id' => 'yes',
+                'type' => 'yes',
+                'type_id' => 'yes',
+                'source_type' => 'yes',
+                'source_id' => 'yes',
                 'status' => array('yes', 'in'),
                 'state' => 1,
             ),
@@ -284,7 +292,10 @@ return array
             (
                 'start' => array('yes-cdate', '>='),
                 'end' => array('yes-cdate', '<='),
-                'shop_id' => 'yes',
+                'type' => 'yes',
+                'type_id' => 'yes',
+                'source_type' => 'yes',
+                'source_id' => 'yes',
                 'status' => array('yes', 'in'),
                 'state' => 1,
             ),

+ 153 - 0
app/shop/database/buy_stat_month.php

@@ -0,0 +1,153 @@
+<?php
+
+$type = array
+(
+    1 => '未对账',
+    2 => '已对账',
+);
+
+return array
+(
+    # 表名
+    'name' => 'buy_stat_month',
+    # 显示给用户看的名称
+    'lang' => '门店月度对账单',
+    'order' => 100,
+    'menu' => false,
+    'config_type' => $type,
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            //'list'      => true,
+        ), 
+
+        'shop_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '所属门店',
+            'default'   => '',
+            'desc'      => '所属门店',
+            'match'     => 'is_numeric',
+            //'search'    => '',
+            'update'    => 'hidden',
+            'value'     => Dever::input('search_option_shop_id'),
+            'list'      => 'Dever::load("shop/info-find#name", {shop_id})',
+        ),
+
+        'month'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '账单时间',
+            'default'   => '',
+            'match'     => 'is_numeric',
+            'desc'      => '',
+            'search'	=> 'day',
+            'order'		=> 'desc',
+            'list'      => 'date("Y-m", {month})',
+        ),
+
+        'order'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '订单量',
+            'default'   => '0',
+            'desc'      => '订单量',
+            'match'     => 'option',
+            'update'    => 'text',
+            'list'		=> true,
+        ),
+
+        'goods'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '商品数',
+            'default'   => '0',
+            'desc'      => '商品数',
+            'match'     => 'option',
+            'update'    => 'text',
+            'list'		=> true,
+        ),
+
+        'cash'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '销售额',
+            'default'   => '0',
+            'desc'      => '销售额',
+            'match'     => 'option',
+            'update'    => 'text',
+            'list'		=> true,
+        ),
+
+        'type'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '是否已对账',
+            'default'   => '1',
+            'desc'      => '是否已对账',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $type,
+            'list'      => true,
+            'edit'      => 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,
+    ),
+
+    'request' => array
+    (
+        # 获取总金额
+        'getAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'start' => array('yes-month', '>='),
+                'end' => array('yes-month', '<='),
+                'shop_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'page' => array(10, 'list'),
+            'col' => '*',
+        ),
+    ),
+);

+ 153 - 0
app/shop/database/factory_stat_month.php

@@ -0,0 +1,153 @@
+<?php
+
+$type = array
+(
+    1 => '未对账',
+    2 => '已对账',
+);
+
+return array
+(
+    # 表名
+    'name' => 'factory_stat_month',
+    # 显示给用户看的名称
+    'lang' => '工厂月度对账单',
+    'order' => 100,
+    'menu' => false,
+    'config_type' => $type,
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            //'list'      => true,
+        ), 
+
+        'factory_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '所属工厂',
+            'default'   => '',
+            'desc'      => '所属工厂',
+            'match'     => 'is_numeric',
+            //'search'    => '',
+            'update'    => 'hidden',
+            'value'     => Dever::input('search_option_factory_id'),
+            'list'      => 'Dever::load("factory/info-find#name", {factory_id})',
+        ),
+
+        'month'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '账单时间',
+            'default'   => '',
+            'match'     => 'is_numeric',
+            'desc'      => '',
+            'search'	=> 'day',
+            'order'		=> 'desc',
+            'list'      => 'date("Y-m", {month})',
+        ),
+
+        'order'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '订单量',
+            'default'   => '0',
+            'desc'      => '订单量',
+            'match'     => 'option',
+            'update'    => 'text',
+            'list'		=> true,
+        ),
+
+        'goods'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '商品数',
+            'default'   => '0',
+            'desc'      => '商品数',
+            'match'     => 'option',
+            'update'    => 'text',
+            'list'		=> true,
+        ),
+
+        'cash'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '销售额',
+            'default'   => '0',
+            'desc'      => '销售额',
+            'match'     => 'option',
+            'update'    => 'text',
+            'list'		=> true,
+        ),
+
+        'type'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '是否已对账',
+            'default'   => '1',
+            'desc'      => '是否已对账',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $type,
+            'list'      => true,
+            'edit'      => 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,
+    ),
+
+    'request' => array
+    (
+        # 获取总金额
+        'getAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'start' => array('yes-month', '>='),
+                'end' => array('yes-month', '<='),
+                'factory_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'page' => array(10, 'list'),
+            'col' => '*',
+        ),
+    ),
+);

+ 153 - 0
app/shop/database/store_stat_month.php

@@ -0,0 +1,153 @@
+<?php
+
+$type = array
+(
+    1 => '未对账',
+    2 => '已对账',
+);
+
+return array
+(
+    # 表名
+    'name' => 'store_stat_month',
+    # 显示给用户看的名称
+    'lang' => '仓库月度对账单',
+    'order' => 100,
+    'menu' => false,
+    'config_type' => $type,
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            //'list'      => true,
+        ), 
+
+        'store_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '所属仓库',
+            'default'   => '',
+            'desc'      => '所属仓库',
+            'match'     => 'is_numeric',
+            //'search'    => '',
+            'update'    => 'hidden',
+            'value'     => Dever::input('search_option_store_id'),
+            'list'      => 'Dever::load("store/info-find#name", {store_id})',
+        ),
+
+        'month'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '账单时间',
+            'default'   => '',
+            'match'     => 'is_numeric',
+            'desc'      => '',
+            'search'	=> 'day',
+            'order'		=> 'desc',
+            'list'      => 'date("Y-m", {month})',
+        ),
+
+        'order'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '订单量',
+            'default'   => '0',
+            'desc'      => '订单量',
+            'match'     => 'option',
+            'update'    => 'text',
+            'list'		=> true,
+        ),
+
+        'goods'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '商品数',
+            'default'   => '0',
+            'desc'      => '商品数',
+            'match'     => 'option',
+            'update'    => 'text',
+            'list'		=> true,
+        ),
+
+        'cash'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '销售额',
+            'default'   => '0',
+            'desc'      => '销售额',
+            'match'     => 'option',
+            'update'    => 'text',
+            'list'		=> true,
+        ),
+
+        'type'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '是否已对账',
+            'default'   => '1',
+            'desc'      => '是否已对账',
+            'match'     => 'is_numeric',
+            //'update'    => 'radio',
+            'option'    => $type,
+            //'list'      => true,
+            //'edit'      => 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,
+    ),
+
+    'request' => array
+    (
+        # 获取总金额
+        'getAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'start' => array('yes-month', '>='),
+                'end' => array('yes-month', '<='),
+                'store_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'page' => array(10, 'list'),
+            'col' => '*',
+        ),
+    ),
+);

+ 112 - 1
app/shop/lib/Cron.php

@@ -59,7 +59,7 @@ class Cron
     # 处理月度对账数据
     public function sell_month_api()
     {
-        $num = Dever::input('num', 1);
+        $num = Dever::input('num', -1);
         if ($num > 0) {
             $month = Dever::input('start', date('Y-m', strtotime('-'.$num.' month')));
         } else {
@@ -91,4 +91,115 @@ class Cron
             }
         }
     }
+
+    # 处理月度对账数据:门店采购
+    public function buy_month_api()
+    {
+        $num = Dever::input('num', -1);
+        if ($num > 0) {
+            $month = Dever::input('start', date('Y-m', strtotime('-'.$num.' month')));
+        } else {
+            $month = Dever::input('start', date('Y-m'));
+        }
+
+        $where['status'] = '5,6';
+        $start = Dever::maketime($month . '-01 00:00:00');
+        $end = Dever::maketime($month . '-31 23:59:59');
+
+        $shop = Dever::db('shop/info')->select();
+
+        foreach ($shop as $k => $v) {
+            $where['type'] = 1;
+            $where['type_id'] = $v['id'];
+            $where['start'] = $start;
+            $where['end'] = $end;
+            $data = array();
+            $data['shop_id'] = $v['id'];
+            $data['month'] = $start;
+            $info = Dever::db('shop/buy_stat_month')->find($data);
+            $data['cash'] = Dever::db('shop/buy_order')->getCashNum($where);
+            $data['order'] = Dever::db('shop/buy_order')->getOrderNum($where);
+            $data['goods'] = Dever::db('shop/buy_order')->getGoodsNum($where);
+            if (!$info) {
+                Dever::db('shop/buy_stat_month')->insert($data);
+            } else {
+                $data['where_id'] = $info['id'];
+                Dever::db('shop/buy_stat_month')->update($data);
+            }
+        }
+    }
+
+    # 处理月度对账数据:仓库对账
+    public function store_month_api()
+    {
+        $num = Dever::input('num', -1);
+        if ($num > 0) {
+            $month = Dever::input('start', date('Y-m', strtotime('-'.$num.' month')));
+        } else {
+            $month = Dever::input('start', date('Y-m'));
+        }
+
+        $where['status'] = '5,6';
+        $start = Dever::maketime($month . '-01 00:00:00');
+        $end = Dever::maketime($month . '-31 23:59:59');
+
+        $store = Dever::db('store/info')->select();
+
+        foreach ($store as $k => $v) {
+            $where['type'] = 2;
+            $where['type_id'] = $v['id'];
+            $where['start'] = $start;
+            $where['end'] = $end;
+            $data = array();
+            $data['store_id'] = $v['id'];
+            $data['month'] = $start;
+            $info = Dever::db('shop/store_stat_month')->find($data);
+            $data['cash'] = Dever::db('shop/buy_order')->getCashNum($where);
+            $data['order'] = Dever::db('shop/buy_order')->getOrderNum($where);
+            $data['goods'] = Dever::db('shop/buy_order')->getGoodsNum($where);
+            if (!$info) {
+                Dever::db('shop/store_stat_month')->insert($data);
+            } else {
+                $data['where_id'] = $info['id'];
+                Dever::db('shop/store_stat_month')->update($data);
+            }
+        }
+    }
+
+    # 处理月度对账数据:工厂对账
+    public function factory_month_api()
+    {
+        $num = Dever::input('num', -1);
+        if ($num > 0) {
+            $month = Dever::input('start', date('Y-m', strtotime('-'.$num.' month')));
+        } else {
+            $month = Dever::input('start', date('Y-m'));
+        }
+
+        $where['status'] = '5,6';
+        $start = Dever::maketime($month . '-01 00:00:00');
+        $end = Dever::maketime($month . '-31 23:59:59');
+
+        $factory = Dever::db('factory/info')->select();
+
+        foreach ($factory as $k => $v) {
+            $where['source_type'] = 3;
+            $where['source_id'] = $v['id'];
+            $where['start'] = $start;
+            $where['end'] = $end;
+            $data = array();
+            $data['factory_id'] = $v['id'];
+            $data['month'] = $start;
+            $info = Dever::db('shop/factory_stat_month')->find($data);
+            $data['cash'] = Dever::db('shop/buy_order')->getCashNum($where);
+            $data['order'] = Dever::db('shop/buy_order')->getOrderNum($where);
+            $data['goods'] = Dever::db('shop/buy_order')->getGoodsNum($where);
+            if (!$info) {
+                Dever::db('shop/factory_stat_month')->insert($data);
+            } else {
+                $data['where_id'] = $info['id'];
+                Dever::db('shop/factory_stat_month')->update($data);
+            }
+        }
+    }
 }