dever 3 jaren geleden
bovenliggende
commit
c2f98c8fd6

+ 174 - 0
app/card/database/code.php

@@ -0,0 +1,174 @@
+<?php
+$status = array
+(
+    1 => '已生成',
+    2 => '未兑换',
+    3 => '已使用',
+    5 => '已过期',
+);
+
+return array
+(
+    # 表名
+    'name' => 'code',
+    # 显示给用户看的名称
+    'lang' => '礼品卡卡号',
+    'status' => $status,
+    # 后台菜单排序
+    'order' => 99,
+    'menu'  => false,
+    # 数据结构
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'list'      => true,
+            'order'     => 'desc',
+        ),
+        
+        'card_id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '礼品卡',
+            'default'   => '',
+            'desc'      => '礼品卡',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'value'     => Dever::input('search_option_card_id'),
+            'list'      => 'Dever::load("card/info-find#name", "{card_id}")',
+        ),
+
+        'card'      => array
+        (
+            'type'      => 'varchar-32',
+            'name'      => '卡号',
+            'default'   => '',
+            'desc'      => '卡号',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'        => true,
+        ),
+
+        'status'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '使用状态',
+            'default'   => '1',
+            'desc'      => '使用状态',
+            'match'     => 'is_numeric',
+            'option'    => $status,
+            'search'    => 'select',
+            'update'    => 'select',
+            'list'      => true,
+            //'mul'       => array(1 => '恢复使用', 4 => '已作废'),
+        ),
+
+        'uid'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '用户信息',
+            'default'   => '0',
+            'desc'      => '用户信息',
+            'match'     => 'is_numeric',
+            'list_name' => '兑换信息',
+            //'list'      => 'Dever::load("goods/lib/manage.showUserInfo", "{id}")',
+        ),
+
+        'shop_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '兑换门店',
+            'default'   => '',
+            'desc'      => '兑换门店',
+            'match'     => 'is_numeric',
+        ),
+
+        'order_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '订单表id',
+            'default'   => '',
+            'desc'      => '订单表id',
+            'match'     => 'is_numeric',
+        ),
+
+        'ddate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '兑换时间',
+            'match'     => 'option',
+            'default'   => '',
+            'desc'      => '',
+            //'search'  => 'date',
+        ),
+
+        'edate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '失效时间',
+            'match'     => 'is_numeric',
+            'default'   => '',
+            'desc'      => '',
+            'list'      => 'date("Y-m-d H:i:s", {edate})',
+        ),
+
+        '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,
+            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+        ),
+    ),
+
+    'manage' => array
+    (
+        'excel' => true,
+        'delete' => false,
+        'edit' => false,
+        'insert' => false,
+       // 'mul' => '{type} == 1 || {type} == 4',
+
+        'list_button' => array
+        (
+            //'oper' => array('作废', 'goods/lib/manage.drop?id={id}', '{type} == 1'),
+
+            //'oper2' => array('恢复使用', 'goods/lib/manage.recovery?id={id}', '{type} == 4'),
+        ),
+    ),
+
+    # 索引
+    'index' => array
+    (
+        # 索引名 => 索引id
+        1 => array
+        (
+            'card' => 'card'
+        ),
+        'version' => 1,
+    ),
+
+    'request' => array
+    (
+        
+    ),
+);

+ 10 - 0
app/card/database/info.php

@@ -60,6 +60,16 @@ return array
             'update'    => 'text',
         ),
 
+        'price'        => array
+        (
+            'type'      => 'varchar-80',
+            'name'      => '售价',
+            'default'   => '100',
+            'desc'      => '售价',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+        ),
+
         'type'        => array
         (
             'type'      => 'int-11',

+ 2 - 2
app/card/database/order_card.php

@@ -124,7 +124,7 @@ return array
             'option' => array
             (
                 'uid' => 'yes',
-                'shop_id' => 'yes',
+                'card_id' => 'yes',
                 'order_id' => 'yes',
                 'status' => 1,
                 'state' => 1,
@@ -141,7 +141,7 @@ return array
             (
                 'ids' => array('yes-id', 'in'),
                 'uid' => 'yes',
-                'shop_id' => 'yes',
+                'card_id' => 'yes',
                 'order_id' => 'yes',
                 'state' => 1,
             ),

+ 4 - 4
app/card/lib/Manage.php

@@ -59,7 +59,7 @@ class Manage
         # 生成卡号
         $card = $info['card_prefix'] . Dever::rand($info['card_len'], $info['card_type'] - 1);
         $where['card'] = $card;
-        $state = Dever::db('card/order')->find($where);
+        $state = Dever::db('card/code')->find($where);
 
         if (!$state) {
             $where['card_id'] = $info['id'];
@@ -68,7 +68,7 @@ class Manage
             }
 
             $where['edate'] = time() + ($info['day']*86400);
-            Dever::db('card/order')->insert($where);
+            Dever::db('card/code')->insert($where);
         } else {
             $this->createCode($info);
         }
@@ -83,7 +83,7 @@ class Manage
     {
         $update['where_id'] = $id;
         $update['type'] = 4;
-        Dever::db('card/order')->update($update);
+        Dever::db('card/code')->update($update);
         return 'ok';
     }
 
@@ -91,7 +91,7 @@ class Manage
     {
         $update['where_id'] = $id;
         $update['type'] = 1;
-        Dever::db('card/order')->update($update);
+        Dever::db('card/code')->update($update);
         return 'ok';
     }
 }

+ 3 - 3
app/shop/lib/Sell.php

@@ -751,9 +751,9 @@ class Sell
             $param['receipt'] = $receipt;
         }
 
-        //$result = Dever::load('pay/api.pay', $param);
-        $result['type'] = 'test';
-        $result['order'] = '';
+        $result = Dever::load('pay/api.pay', $param);
+        //$result['type'] = 'test';
+        //$result['order'] = '';
         if ($cart) {
             # 来自购物车,要清空一下
             $this->dropCart($cart, $uid, $goods, $shop['id']);

+ 116 - 0
app/shop/src/Card.php

@@ -0,0 +1,116 @@
+<?php
+
+namespace Shop\Src;
+
+use Dever;
+use Main\Lib\Core;
+
+class Card extends Core
+{
+	public function __construct()
+	{
+		parent::__construct();
+		$this->checkLogin();
+		$this->shop_id = Dever::input('shop_id');
+	}
+
+	# 购买礼品卡基本信息
+	public function getList()
+	{
+		$this->data['config'] = Dever::db('main/sell_config')->find();
+
+		# 列表
+		$this->data['list'] = Dever::db('card/info')->select();
+
+		return $this->data;
+	}
+
+	# 确认订单页面
+	public function confirm()
+	{
+		$this->data['uid'] = $this->uid;
+		$this->getCard();
+
+		return $this->data;
+	}
+
+	# 获取下单的礼品卡信息
+	public function getCard()
+	{
+		$card_id = Dever::input('card_id');
+		$num = Dever::input('num');
+
+		if (!$card_id) {
+			Dever::alert('请选择礼品卡');
+		}
+
+		$card = explode(',', $card_id);
+
+		$this->data['price'] = 0;
+        $this->data['num'] = 0;
+		$this->data['list'] = array();
+		$i = 0;
+		foreach ($card as $k => $v) {
+			$n = isset($num[$k]) ? $num[$k] : 1;
+
+			$info = Dever::db('card/info')->find($v);
+			if ($info) {
+				$this->data['list'][$i] = $info;
+				$this->data['list']['buy_num'] = $n;
+
+				$this->data['price'] += $data['list'][$k]['value'] * $n;
+				$this->data['num'] += $n;
+				$i++;
+			}
+		}
+	}
+
+	# 开始下单
+	public function pay_commit()
+	{
+		$refer = Dever::input('refer');
+		$cart = Dever::input('cart', 1);
+		$address_id = Dever::input('address_id');
+		$invoice_id = Dever::input('invoice_id');
+		
+		$info = Dever::input('info');
+
+		$this->data['uid'] = $this->uid;
+		$this->data['user'] = $this->user;
+		$this->data['shop'] = $this->shop;
+
+		Dever::load('shop/lib/sell')->goods($this->data);
+		Dever::load('shop/lib/sell')->coupon($this->data, 2);
+
+
+		if ($this->data['pay_method'] > 1) {
+			$cart = false;
+		}
+
+		if (!$this->data['coupon_id'] && $this->data['price'] <= 0) {
+			Dever::alert('已售空');
+		}
+
+		if ($this->data['method'] == 2 && !$address_id) {
+			Dever::alert('收货地址不能为空');
+		}
+
+		if (!isset($this->data['card'])) {
+			$this->data['card'] = false;
+		}
+
+		$pay = Dever::load('shop/lib/sell')->pay($this->data['method'], $this->data['pay_method'], 1, $this->user, $this->shop, $this->data['name'], $this->data['num'], $this->data['list'], $this->data['price'], 0, $address_id, $invoice_id, $info, $this->data['card'], $this->data['coupon_id'], $this->data['user_coupon_id'], $this->data['coupon_cash'], $cart, 5, $refer);
+		return $pay;
+	}
+
+	# 再次付款
+	public function r_pay()
+	{
+		$refer = Dever::input('refer');
+		$order_id = Dever::input('order_id');
+
+		$pay = Dever::load('shop/lib/sell')->rpay($order_id, 5, $refer);
+
+		return $pay;
+	}
+}

+ 12 - 0
main/database/sell_config.php

@@ -69,6 +69,18 @@ return array
             'place'     => '150*150',
         ),
 
+        'card'       => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '礼品卡封面',
+            'default'   => '',
+            'desc'      => '礼品卡封面',
+            'match'     => 'option',
+            'update'    => 'image',
+            'key'       => '1',
+            'place'     => '150*150',
+        ),
+
         'phone'      => array
         (
             'type'      => 'varchar-100',