|
@@ -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;
|
|
|
|
+ }
|
|
|
|
+}
|