dever 3 年之前
父節點
當前提交
c9a1a284d2
共有 4 個文件被更改,包括 381 次插入1 次删除
  1. 46 0
      database/address.php
  2. 212 0
      database/invoice.php
  3. 29 1
      src/Address.php
  4. 94 0
      src/Invoice.php

+ 46 - 0
database/address.php

@@ -5,6 +5,17 @@ $type = array
 	1 => '普通地址',
 	2 => '默认地址',
 );
+
+$sex = Dever::db('passport/user')->config['sex'];
+
+$tag = array
+(
+    1 => '公司',
+    2 => '家',
+    3 => '学校',
+    //4 => '其他',
+);
+
 return array
 (
     # 表名
@@ -70,6 +81,18 @@ return array
 			//'list'		=> true,
 		),
 
+        'sex'       => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '性别',
+            'default'   => '3',
+            'desc'      => '性别',
+            'match'     => 'is_numeric',
+            'option'    => $sex,
+            'update'    => 'radio',
+            //'list'        => true,
+        ),
+
 		'mobile'		=> array
 		(
 			'type' 		=> 'varchar-100',
@@ -146,6 +169,29 @@ return array
 			//'list'		=> true,
 		),
 
+        'house_number'       => array
+        (
+            'type'      => 'varchar-500',
+            'name'      => '门牌号',
+            'default'   => '',
+            'desc'      => '门牌号',
+            'match'     => 'option',
+            //'update'  => 'text',
+            //'list'        => true,
+        ),
+
+        'tag'      => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '标签',
+            'default'   => '1',
+            'desc'      => '标签',
+            'match'     => 'is_numeric',
+            'option'    => $tag,
+            'update'    => 'radio',
+            //'list'        => true,
+        ),
+
         'state'     => array
         (
             'type'      => 'tinyint-1',

+ 212 - 0
database/invoice.php

@@ -0,0 +1,212 @@
+<?php
+
+$type = array
+(
+    1 => '普通发票',
+    2 => '默认发票',
+);
+
+$title_type = array
+(
+    1 => '企业单位',
+    2 => '个人',
+);
+
+return array
+(
+    # 表名
+    'name' => 'invoice',
+    # 显示给用户看的名称
+    'lang' => '用户发票库',
+    'menu' => false,
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'update'    => 'hidden',
+            //'list'        => true,
+        ),
+
+        'uid'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '用户名',
+            'default'   => '0',
+            'desc'      => '请选择用户',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            //'search'  => 'select',
+            'search'    => array
+            (
+                'api' => 'passport/user-all',
+                'col' => 'username',
+                'result' => 'id',
+            ),
+            'list'      => '{uid} > 0 ? Dever::load("passport/user-one#username", {uid}) : "匿名用户"',
+        ),
+
+        'type'      => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '类型',
+            'default'   => '2',
+            'desc'      => '类型',
+            'match'     => 'is_numeric',
+            'option'    => $type,
+            'update'    => 'select',
+            //'list'        => true,
+        ),
+
+        'title_type'      => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '抬头类型',
+            'default'   => '1',
+            'desc'      => '抬头类型',
+            'match'     => 'is_numeric',
+            'option'    => $title_type,
+            'update'    => 'radio',
+            //'list'        => true,
+        ),
+
+        'title'       => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '抬头名称',
+            'default'   => '',
+            'desc'      => '抬头名称',
+            'match'     => 'option',
+            'search'    => 'fulltext',
+            //'update'  => 'text',
+            //'list'        => true,
+        ),
+
+        'email'        => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '邮箱',
+            'default'   => '',
+            'desc'      => '邮箱',
+            'match'     => 'option',
+            'search'    => 'fulltext',
+            //'update'  => 'text',
+            //'list'        => true,
+        ),
+
+        'mobile'        => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '手机号',
+            'default'   => '',
+            'desc'      => '手机号',
+            'match'     => 'option',
+            'search'    => 'fulltext',
+            //'update'  => 'text',
+            //'list'        => true,
+        ),
+
+        'number'       => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '公司税号',
+            'default'   => '',
+            'desc'      => '公司税号',
+            'match'     => 'option',
+            //'update'  => 'text',
+        ),
+
+        'phone'       => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '公司电话',
+            'default'   => '',
+            'desc'      => '公司电话',
+            'match'     => 'option',
+            //'update'  => 'text',
+        ),
+
+        'address'       => array
+        (
+            'type'      => 'varchar-1000',
+            'name'      => '注册地址',
+            'default'   => '',
+            'desc'      => '注册地址',
+            'match'     => 'option',
+            //'update'  => 'text',
+            //'list'        => true,
+        ),
+
+        'bank'       => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '开户银行',
+            'default'   => '',
+            'desc'      => '开户银行',
+            'match'     => 'option',
+            //'update'  => 'text',
+            //'list'        => true,
+        ),
+
+        'bank_number'       => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '银行账号',
+            'default'   => '',
+            'desc'      => '银行账号',
+            'match'     => 'option',
+            //'update'  => 'text',
+            //'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})',
+        ),
+    ),
+
+    'manage' => array
+    (
+        
+    ),
+
+    'request' => array
+    (
+        'getList' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'uid' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('type' => 'desc','id' => 'desc'),
+            'page' => array(10, 'list'),
+            'col' => '*',
+        ),
+    ),
+);

+ 29 - 1
src/Address.php

@@ -25,8 +25,26 @@ class Address
         return $data;
     }
 
+    # 添加或者更新地址接口
+    public function up()
+    {
+        $uid = $this->check();
+        $id = Dever::input('id');
+        $type = Dever::input('type', 2);
+        $province = Dever::input('province');
+        $city = Dever::input('city');
+        $county = Dever::input('county');
+        $address = Dever::input('address');
+        $country = Dever::input('country');
+        $sex = Dever::input('sex');
+        $house_number = Dever::input('house_number');
+        $tag = Dever::input('tag');
+
+        return $this->upAddress($id, $uid, $type, $province, $city, $county, $address, $country, $sex, $house_number, $tag);
+    }
+
     # 添加或者更新地址
-    public function upAddress($id, $uid, $type = 2, $province = '', $city = '', $county = '', $address = '', $country = '')
+    public function upAddress($id, $uid, $type = 2, $province = '', $city = '', $county = '', $address = '', $country = '', $sex = '', $house_number = '', $tag = '')
     {
     	if ($country) {
     		$update['country'] = $country;
@@ -41,6 +59,16 @@ class Address
         }
 
         $update['type'] = $type;
+
+        if ($sex) {
+            $update['sex'] = $sex;
+        }
+        if ($house_number) {
+            $update['house_number'] = $house_number;
+        }
+        if ($tag) {
+            $update['tag'] = $tag;
+        }
         
         if ($id) {
             $update['where_id'] = $id;

+ 94 - 0
src/Invoice.php

@@ -0,0 +1,94 @@
+<?php
+namespace Passport\Src;
+
+use Dever;
+use Passport\Lib\Base;
+
+class Invoice
+{
+    # 获取默认地址
+    public function getDefault($uid)
+    {
+        $where['uid'] = $uid;
+        $where['type'] = 2;
+        $data = Dever::db('passport/invoice')->find($where);
+
+        return $data;
+    }
+
+    # 获取地址列表
+    public function get($uid)
+    {
+        $where['uid'] = $uid;
+        $data = Dever::db('passport/invoice')->getList($where);
+
+        return $data;
+    }
+
+    # 添加或者更新地址接口
+    public function up()
+    {
+        $uid = $this->check();
+        $id = Dever::input('id');
+        $type = Dever::input('type', 2);
+        $title_type = Dever::input('title_type');
+        $title = Dever::input('title');
+        $email = Dever::input('email');
+        $mobile = Dever::input('mobile');
+        $number = Dever::input('number');
+        $phone = Dever::input('phone');
+        $address = Dever::input('address');
+        $bank = Dever::input('bank');
+        $bank_number = Dever::input('bank_number');
+
+        return $this->update($id, $uid, $type, $title_type, $title, $email, $mobile, $number, $phone, $address, $bank, $bank_number);
+    }
+
+    # 添加或者更新地址
+    public function update($id, $uid, $type = 2, $title_type = 1, $title = '', $email = '', $mobile = '', $number = '', $phone = '', $address = '', $bank = '', $bank_number = '')
+    {
+        $update['title_type'] = $title_type;
+        if ($title_type == 1) {
+            if (!$number) {
+                Dever::alert('公司税号不能为空');
+            }
+            $update['number'] = $number;
+        }
+
+        $update['type'] = $type;
+        $update['title'] = $title;
+
+        if (!$title) {
+            Dever::alert('发票抬头不能为空');
+        }
+
+        if ($email) {
+            $update['email'] = $email;
+        }
+        if ($mobile) {
+            $update['mobile'] = $mobile;
+        }
+        if ($phone) {
+            $update['phone'] = $phone;
+        }
+        if ($address) {
+            $update['address'] = $address;
+        }
+        if ($bank) {
+            $update['bank'] = $bank;
+        }
+        if ($bank_number) {
+            $update['bank_number'] = $bank_number;
+        }
+        
+        if ($id) {
+            $update['where_id'] = $id;
+            Dever::db('passport/invoice')->update($update);
+        } else {
+            $update['uid'] = $uid;
+            $id = Dever::db('passport/invoice')->insert($update);
+        }
+
+        return $id;
+    }
+}