dever 5 éve
szülő
commit
8239ab1357
5 módosított fájl, 712 hozzáadás és 1 törlés
  1. 26 0
      act/database/order.php
  2. 568 0
      act/database/order_bak.php
  3. 37 0
      act/lib/Cron.php
  4. 69 0
      act/lib/Pay.php
  5. 12 1
      combine/lib/Core.php

+ 26 - 0
act/database/order.php

@@ -538,5 +538,31 @@ return array
             'page' => array(10, 'list'),
             'col' => 'order_id,name,buy_num,cdate,cash,product_id,buy_id',
         ),
+
+        # 删除未支付订单
+        'drop' => array
+        (
+            # 匹配的正则或函数 选填项
+            'where' => array
+            (
+                'time' => array('yes-cdate', '<='),
+                'status' => 1,
+                'state' => 1,
+            ),
+            'type' => 'delete',
+            'col' => 'id,order_id',
+        ),
+
+        # 获取数据
+        'getAllByDate' => array
+        (
+            # 匹配的正则或函数 选填项
+            'where' => array
+            (
+                'time' => array('yes-cdate', '<='),
+            ),
+            'type' => 'all',
+            'col' => 'id,order_id',
+        ),
     ),
 );

+ 568 - 0
act/database/order_bak.php

@@ -0,0 +1,568 @@
+<?php
+
+$type = array
+(
+    //1 => '购买小刊',
+    //2 => '兑换小刊',
+    3 => '购买兑换码',
+    //4 => '使用通用兑换码',
+);
+
+# 系统
+$system = array
+(
+    1 => '小程序',
+    2 => 'H5',
+    3 => 'ios',
+    4 => '安卓',
+);
+
+# 渠道
+$source = function()
+{
+    return Dever::db('source/info')->state();
+};
+
+$status = array
+(
+    1 => '待支付',
+    2 => '已支付',
+    3 => '支付失败',
+    //4 => '申请退款',
+    5 => '已退款',
+);
+
+$product = function()
+{
+    return Dever::db('journal/info')->state();
+};
+
+$buy = function()
+{
+    return Dever::db('journal/buy_num')->state();
+};
+# 获取小刊分类权限
+$auth = Dever::tops();
+$cate = function() use ($auth)
+{
+    $array = array();
+    if ($auth) {
+        $info = Dever::db('journal/cate')->getIds(array('ids' => $auth));
+    } else {
+        $info = Dever::db('journal/cate')->state();
+    }
+    if($info)
+    {
+        $array += $info;
+    }
+    return $array;
+};
+
+$seller = function()
+{
+    return Dever::db('code/seller')->state();
+};
+
+return array
+(
+    # 表名
+    'name' => 'order_bak',
+    # 显示给用户看的名称
+    'lang' => '历史订单管理',
+    'order' => -10,
+    'menu' => 'journal',
+
+    'end' => array
+    (
+        'update' => 'act/lib/pay.order_bak',
+    ),
+
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            //'list'      => true,
+        ),
+
+        'order_id'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '订单id',
+            'default'   => '',
+            'desc'      => '付款订单id',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'        => true,
+            //'list'        => '"{order_id}" ? "{order_id}" : "{code}"',
+        ), 
+
+        'cate_journal'     => array
+        (
+            'name'      => '小刊',
+            'default'   => '',
+            'desc'      => '小刊',
+            'search'    => 'linkage',
+            'search_col' => 'cate_id,product_id',
+            'option'    => Dever::url('lib/manage.search_cate_journal', 'journal'),
+        ),
+
+        'cate_id'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '小刊分类',
+            'default'   => '1',
+            'desc'      => '小刊分类',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'option'    => $cate,
+            //'search'    => 'select',
+            'list'      => true,
+        ),
+
+        'name'      => array
+        (
+            'type'      => 'varchar-80',
+            'name'      => '订单名称',
+            'default'   => '',
+            'desc'      => '订单名称',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list_name' => '订单信息',
+            'list'      => 'Dever::load("journal/lib/manage.showOrderUserV1", "{id}")',
+        ),
+
+        'uid'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '用户名',
+            'default'   => '',
+            'desc'      => '用户id',
+            'match'     => 'is_numeric',
+            'search'    => array
+            (
+                'api' => 'passport/user-all',
+                'col' => 'username',
+                'result' => 'id',
+            ),
+            'update'    => 'text',
+        ),
+
+        'source_uid'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '邀请人',
+            'default'   => '',
+            'desc'      => '邀请人',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+        ),
+
+        'note'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '是否发送状态提醒-1未发送,2已发送',
+            'default'   => '1',
+            'desc'      => '请选择状态',
+            'match'     => 'is_numeric',
+        ),
+
+        'product_id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '小刊',
+            'default'   => '',
+            'desc'      => '小刊',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'option'    => $product,
+            //'search'    => 'select',
+            //'list'        => true,
+        ),
+
+        'buy_id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '购买本数',
+            'default'   => '',
+            'desc'      => '购买本数',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'option'    => $buy,
+            //'search'    => 'select',
+            //'list'        => true,
+        ),
+
+        'buy_num'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '购买本数',
+            'default'   => '',
+            'desc'      => '购买本数',
+            'match'     => 'is_numeric',
+            //'search'    => 'select',
+            //'list'        => true,
+        ),
+
+        'type'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '支付方式',
+            'default'   => '1',
+            'desc'      => '支付方式',
+            'match'     => 'is_numeric',
+            'option'    => $type,
+            'search'    => 'select',
+            'update'    => 'radio',
+            //'list'        => true,
+            'control'   => 'type',
+        ),
+
+        'system'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '系统',
+            'default'   => '1',
+            'desc'      => '系统',
+            'match'     => 'is_numeric',
+            'option'    => $system,
+            'search'    => 'select',
+            'update'    => 'radio',
+            'list'        => true,
+        ),
+
+        'source'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '渠道来源',
+            'default'   => '1',
+            'desc'      => '支付方式',
+            'match'     => 'is_numeric',
+            'option'    => $source,
+            'search'    => 'select',
+            'update'    => 'radio',
+            'list'        => true,
+        ),
+
+        'seller_id'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '销售商',
+            'default'   => '1',
+            'desc'      => '销售商',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'option'    => $seller,
+            'search'    => 'select',
+            //'list'      => true,
+        ),
+
+        'notice'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '模板消息提醒次数',
+            'default'   => '0',
+            'desc'      => '模板消息提醒次数',
+            'match'     => 'is_numeric',
+        ),
+
+        'cash'      => array
+        (
+            'type'      => 'varchar-50',
+            'name'      => '支付金额',
+            'default'   => '',
+            'desc'      => '支付金额',
+            'match'     => 'option',
+            'update'    => 'text',
+            //'list'        => true,
+            'show'      => 'type=1',
+        ),
+
+        'code'      => array
+        (
+            'type'      => 'varchar-50',
+            'name'      => '使用的兑换码',
+            'default'   => '',
+            'desc'      => '使用的兑换码',
+            'match'     => 'option',
+            'update'    => 'text',
+            //'list'        => true,
+            'show'      => 'type=2',
+        ),
+
+        'status'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '订单状态',
+            'default'   => '1',
+            'desc'      => '请选择订单状态',
+            'match'     => 'is_numeric',
+            'option'    => $status,
+            'search'    => 'select',
+            'update'    => 'radio',
+            'list'      => 'Dever::load("journal/lib/manage.showOrderStatusV1", "{id}")',
+            'control'   => 'status',
+        ),
+
+        'tk_pic'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '退款截图',
+            'default'   => '',
+            'desc'      => '退款截图',
+            'match'     => 'is_string',
+            'update'    => 'image',
+            'key'       => 1
+        ),
+
+        'tk_time'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '退款时间',
+            'default'   => '',
+            'desc'      => '退款时间',
+            'match'     => 'option',
+            //'list'        => true,
+            //'update'    => 'date',
+            'callback'  => 'maketime',
+            'show'      => 'status=5',
+        ),
+
+        'tk_admin'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '退款审核人',
+            'default'   => '1',
+            'desc'      => '退款审核人',
+            'match'     => 'option',
+            //'list'        => true,
+            'show'      => 'status=5',
+        ),
+
+        'tk_desc'       => array
+        (
+            'type'      => 'varchar-300',
+            'name'      => '退款备注',
+            'default'   => '',
+            'desc'      => '退款备注',
+            'match'     => 'option',
+            'update'    => 'textarea',
+            //'show'        => 'status=5',
+        ),
+
+        '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}")',
+        ),
+
+        'info'      => array
+        (
+            'type'      => 'varchar-300',
+            'name'      => '备注',
+            'default'   => '',
+            'desc'      => '备注',
+            'match'     => 'option',
+            'update'    => 'textarea',
+            //'show'        => 'status=5'
+            //'list'      => '"{info}" ? "{info}" : "双击添加备注"',
+            //'edit'      => true,
+        ),
+
+        'mobile'        => array
+        (
+            'type'      => 'varchar-300',
+            'name'      => '手机号',
+            'default'   => '',
+            'desc'      => '手机号',
+            'match'     => 'option',
+            //'show'        => 'status=5'
+            'search'    => array
+            (
+                'api' => 'passport/user-all',//接口地址,最好是获取多条数据的地址
+                'col' => 'mobile',//要查询的字段
+                'result' => 'id',//返回的字段
+                'search' => 'uid',//本表的字段,默认为当前的字段
+            ),
+        ),
+    ),
+
+    'top' => Dever::config('base')->top,
+
+    # 增加这个,为了给当前的list增加一个option
+    'top_option' => array
+    (
+        'value' => $auth,
+        'col' => 'cate_id',
+    ),
+
+    'manage' => array
+    (
+        'delete' => false,
+        'edit' => false,
+        'insert' => false,
+
+        'button' => array
+        (
+            //'导出订单' => array('location', 'journal/lib/manage.out'),
+        ),
+
+        'list_button' => array(
+            'edit' => array('退款', 'status,tk_time,tk_pic,tk_desc,tk_admin', '{status} == 2 && ({type} == 1 || {type} == 3)'),
+            //'delete' => array('删除', '', '{status} == 1'),
+        ),
+    ),
+
+    'request' => array
+    (
+        'getAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'type' => 'yes',
+                'create_uid' => 'yes',
+                'status' => array('1', '!='),
+                'uid' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('cdate' => 'desc'),
+            'page' => array(10, 'list'),
+            'col' => '*',
+        ),
+
+        'getYes' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'product_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('cdate' => 'desc'),
+            'col' => '*',
+        ),
+
+        # 获取提交订单超过12个小时
+        'getDataByTime' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'cdate' => array('yes', '>='),
+                'notice' => 'yes',
+                'note' => 'yes',
+                'type' => array('yes', 'in'),
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('cdate' => 'desc'),
+            'col' => '*',
+        ),
+
+        # 获取没有兑换码的订单
+        'getUnCode' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'code' => array('yes', '='),
+                'status' => 'yes',
+                'type' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('id' => 'desc'),
+            'limit' => '0,100',
+            'col' => '*',
+        ),
+
+        # 获取1,2
+        'getBuy' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'status' => 'yes',
+                'type' => array('yes', 'in'),
+                'product_id' => 'yes',
+                'order_id' => 'yes',
+                'uid' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('id' => 'desc'),
+            'col' => '*',
+        ),
+
+        'getMyAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'type' => 'yes',
+                'uid' => 'yes',
+                'status' => 'yes',
+                'cate_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('id' => 'desc'),
+            'page' => array(10, 'list'),
+            'col' => 'order_id,name,buy_num,cdate,cash,product_id,buy_id',
+        ),
+
+        # 删除未支付订单
+        'drop' => array
+        (
+            # 匹配的正则或函数 选填项
+            'where' => array
+            (
+                'time' => array('yes-cdate', '<='),
+                'status' => 1,
+                'state' => 1,
+            ),
+            'type' => 'delete',
+            'col' => 'id',
+        ),
+
+        # 获取数据
+        'getAllByDate' => array
+        (
+            # 匹配的正则或函数 选填项
+            'where' => array
+            (
+                'time' => array('yes-cdate', '<='),
+            ),
+            'type' => 'all',
+            'col' => 'id',
+        ),
+    ),
+);

+ 37 - 0
act/lib/Cron.php

@@ -0,0 +1,37 @@
+<?php
+#计划任务
+namespace Act\Lib;
+
+use Dever;
+
+class Cron
+{
+	# 清理一小时前的待支付数据
+	public function drop_order_api()
+	{
+		$where['where_time'] = time() - 3600;
+		Dever::db('act/order')->drop($where);
+		return 'ok';
+	}
+
+	# 将七天前的数据进行迁移
+	public function mv_order()
+	{
+		$where['where_time'] = time() - (86400 * 7);
+		$data = Dever::db('act/order')->getAllByDate($where);
+		if ($data) {
+			$db = Dever::db('act/order_bak');
+			foreach ($data as $k => $v) {
+				$info = $db->one(array('order_id' => $v['order_id']));
+				if (!$info) {
+					$id = $v['id'];
+					unset($v['id']);
+					$db->insert($v);
+					Dever::db('act/order')->delete($id);
+				}
+			}
+		}
+
+		return 'ok';
+	}
+}

+ 69 - 0
act/lib/Pay.php

@@ -77,6 +77,75 @@ class Pay
         }
     }
 
+    # 退款操作
+    public function order_bak($id, $name, $data)
+    {
+        $status = Dever::param('status', $data);
+
+        if ($status == 5 && $id > 0) {
+            $send = array();
+            $info = Dever::db('act/order_bak')->one($id);
+            $send['pay_project_id'] = 1;
+            $send['pay_uid'] = $info['uid'];
+            $send['pay_order_id'] = $info['order_id'];
+            $send['pay_tk_pic'] = Dever::param('tk_pic', $data);
+            $send['pay_tk_time'] = Dever::param('tk_time', $data);
+            $send['pay_tk_desc'] = Dever::param('tk_desc', $data);
+            $send['pay_status'] = $status;
+            $send['dever_token'] = $this->key;
+
+            if ($info['buy_id'] > 0) {
+                $buy = Dever::db('journal/buy_num')->one($info['buy_id']);
+
+                if ($buy) {
+                    if ($info['buy_num'] > 0) {
+                        $num = $info['buy_num'];
+                    } else {
+                        $num = $buy['num'];
+                    }
+                    # 减少积分
+                    $score = $num * 20;
+
+                    $user = Dever::db('score/user')->one(array('uid' => $info['uid']));
+                    if ($user) {
+                        $user_id = $user['id'];
+                        $user_score = $user['score'];
+                        $user_score = $user_score - $score;
+                        if ($user_score < 0) {
+                            $user_score = 0;
+                        }
+                        Dever::db('score/user')->update(array('where_id' => $user_id, 'score' => $user_score));
+                    }
+
+                    # 减少排行榜
+                    $journal_num = Dever::db('act/journal_num')->one(array('uid' => $info['uid'], 'journal_id' => $info['product_id']));
+                    if ($journal_num) {
+                        $journal_num_id = $journal_num['id'];
+                        $journal_num = $journal_num['num'];
+                        $journal_num = $journal_num - $num;
+                        if ($journal_num < 0) {
+                            $journal_num = 0;
+                        }
+                        Dever::db('act/journal_num')->update(array('where_id' => $journal_num_id, 'num' => $journal_num));
+                    }
+
+                    # 减少订阅本数 这个定时跑就行了 不管了
+                    $journal = Dever::db('journal/info')->one($info['product_id']);
+                    if ($journal) {
+                        $journal_id = $journal['id'];
+                        $journal_num = $journal['num_ding'];
+                        $journal_num = $journal_num - $num;
+                        if ($journal_num < 0) {
+                            $journal_num = 0;
+                        }
+                        Dever::db('journal/info')->update(array('where_id' => $journal_id, 'num_ding' => $journal_num));
+                    }
+                }
+            }
+            Dever::load('pay/lib/set.updateStatus', $send);
+        }
+    }
+
 	/**
 	 * 支付成功后,调取的接口 这里的安全以后再升级吧,升级成和pay/lib/set.updateStatus一样的
 	 *

+ 12 - 1
combine/lib/Core.php

@@ -26,7 +26,7 @@ class Core
             'act/share_reflux',
             'act/subscribe',
             'act/watch',
-            'code/info',
+            //'code/info',
             'source/user',
             'score/action_log',
             //'score/user',//积分相关的要加上,不能直接修改
@@ -60,7 +60,18 @@ class Core
 
     private function other($uid, $drop_uid)
     {
+        Dever::db('code/info')->updates(array('set_uid' => $uid, 'option_uid' => $drop_uid));
         Dever::db('code/info')->updates(array('set_create_uid' => $uid, 'option_create_uid' => $drop_uid));
+
+        $journal = Dever::db('journal/info')->state();
+        if ($journal) {
+            foreach ($journal as $k => $v) {
+                Dever::setInput('set_product_id', $v['id']);
+                Dever::db('code/info')->updates(array('set_uid' => $uid, 'option_uid' => $drop_uid));
+                Dever::db('code/info')->updates(array('set_create_uid' => $uid, 'option_create_uid' => $drop_uid));
+            }
+        }
+        
         Dever::db('invite/relation')->updates(array('set_to_uid' => $uid, 'option_to_uid' => $drop_uid));
     }