diff --git a/addon/futures/api/controller/Futures.php b/addon/futures/api/controller/Futures.php index 433fe733..13a286cf 100644 --- a/addon/futures/api/controller/Futures.php +++ b/addon/futures/api/controller/Futures.php @@ -6,21 +6,127 @@ use addon\futures\model\Futures as FuturesModel; class Futures extends BaseApi{ /** - * 列表 + * 售卖列表 * @return false|string */ public function list() { - return $this->response(); + $token = $this->checkToken(); + if ($token['code'] < 0) return $this->response($token); + + $fenxiao = model('fenxiao')->getInfo([['member_id', '=', $this->member_id]]); + // $is_read = FALSE; + // if(empty($fenxiao) || $fenxiao['diamond'] < 0){ + // $is_read = + // }//TODO 判断当前时间是否在秒杀开启时间,并区分有无钻石用户 + + $status = input('status', 'miaosha'); + + $condition = [ + ['a.site_id','=',$this->site_id] + ]; + + switch($status){ + case 'miaosha': + $condition[] = ['status', '=', '2']; + break; + case 'jianlou': + $condition[] = ['status', '=', '7']; + break; + default: + $condition[] = ['status', '=', '2']; + break; + } + + + // 获取内容 + $field = [ + 'seller.username as seller_username', + 'seller.nickname as seller_nickname', + 'seller.headimg as seller_headimg', + 'g.goods_name', + 'g.goods_image', + 'a.id', + 'a.total', + 'a.unit_price', + 'a.price', + 'a.status', + 'a.release_time', + 'a.sell_time', + 'a.created_time', + 'a.take_time', + ]; + // 表关联 + $join = [ + ['member seller', 'seller.member_id = a.seller_uid', 'left'],// 获取卖家信息 + ['goods g', 'g.goods_id = a.goods_id', 'left'],// 获取商品信息 + ]; + + $futuresModel = new FuturesModel; + $page = input('page', 1); + $page_size = input('page_size', PAGE_LIST_ROWS); + $list = $futuresModel->getPageList($condition, $page, $page_size, 'a.created_time desc,a.id desc', $field, 'a', $join); + return $this->response($list); } /** - * 列表 + * 个人中心列表 * @return false|string */ public function myList() { - return $this->response(); + $token = $this->checkToken(); + if ($token['code'] < 0) return $this->response($token); + + $status = input('status', 'all'); + + $condition = [ + ['a.seller_uid', '=', $this->member_id], + ['a.site_id','=',$this->site_id] + ]; + + switch($status){ + case 'stock': + $condition[] = ['a.status', '=', '1']; + break; + case 'release': + $condition[] = ['a.status', 'in', [2, 6, 7]]; + break; + case 'sold': + $condition[] = ['a.status', '=', '3']; + break; + default: + break; + } + + // 获取内容 + $field = [ + 'seller.username as seller_username', + 'seller.nickname as seller_nickname', + 'seller.headimg as seller_headimg', + 'g.goods_name', + 'g.goods_image', + 'a.id', + 'a.total', + 'a.unit_price', + 'a.price', + 'a.status', + 'a.release_time', + 'a.sell_time', + 'a.created_time', + 'a.take_time', + ]; + // 表关联 + $join = [ + ['member seller', 'seller.member_id = a.seller_uid', 'left'],// 获取卖家信息 + ['goods g', 'g.goods_id = a.goods_id', 'left'],// 获取商品信息 + ]; + + $futuresModel = new FuturesModel; + $page = input('page', 1); + $page_size = input('page_size', PAGE_LIST_ROWS); + $list = $futuresModel->getPageList($condition, $page, $page_size, 'a.created_time desc,a.id desc', $field, 'a', $join); + return $this->response($list); } /** @@ -29,10 +135,21 @@ class Futures extends BaseApi{ */ public function release() { - //TODO 身份验证,拆单 + $token = $this->checkToken(); + if ($token['code'] < 0) return $this->response($token); + $id = input('id', 0); $price = input('price', 0); + $date = model('futures')->getInfo([['id', '=', $id],['seller_uid' => $this->member_id]]); + if(empty($date)){ + return $this->response($this->error('','发布失败')); + } + if($price <= $date['unit_price'] * (1 + 0 / 100) || $price >= $date['unit_price'] * (1 + 8 / 100)){//TODO 后台配置范围 + return $this->response($this->error('','发布失败')); + } + //TODO 拆单 + $futuresModel = new FuturesModel; return $this->response($futuresModel->release($id, $price)); } @@ -42,11 +159,20 @@ class Futures extends BaseApi{ * @return false|string */ public function stock(){ - //TODO 身份验证 + $token = $this->checkToken(); + if ($token['code'] < 0) return $this->response($token); + $id = input('id', 0); + $date = model('futures')->getInfo([['id', '=', $id],['seller_uid' => $this->member_id]]); + if(empty($date)){ + return $this->response($this->error('','下架失败')); + } + $futuresModel = new FuturesModel; return $this->response($futuresModel->stock($id)); } + //TODO 提货 + } \ No newline at end of file diff --git a/addon/futures/model/Futures.php b/addon/futures/model/Futures.php index 787f302a..3dd71d82 100644 --- a/addon/futures/model/Futures.php +++ b/addon/futures/model/Futures.php @@ -1,6 +1,7 @@ set('addon_futures_'.$id,'1'); return $this->success(); } + + /** + * 写入基本设置 + * @param $data + * @param $is_use + * @param $site_id + * @return array + */ + public function setBasicsConfig($data, $is_use, $site_id) + { + $config = new ConfigModel(); + return $config->setConfig($data, '秒杀基本配置', $is_use, [['site_id', '=', $site_id], ['app_module', '=', 'shop'], ['config_key', '=', 'MIAOSHA_BASICS_CONFIG']]); + } + + /** + * 读取基本设置 + * @param $site_id + * @return array + */ + public function getBasicsConfig($site_id) + { + $config = new ConfigModel(); + return $config->getConfig([['site_id', '=', $site_id], ['app_module', '=', 'shop'], ['config_key', '=', 'MIAOSHA_BASICS_CONFIG']]); + } } \ No newline at end of file diff --git a/addon/futures/shop/controller/Config.php b/addon/futures/shop/controller/Config.php new file mode 100644 index 00000000..7b83d37c --- /dev/null +++ b/addon/futures/shop/controller/Config.php @@ -0,0 +1,28 @@ +isAjax()) { + $res = $model->setFenxiaoBasicsConfig($this->request->param(), 1, $this->site_id); + return $res; + } else { + $basics = $model->getFenxiaoBasicsConfig($this->site_id); + $this->assign("info", $basics[ 'data' ][ 'value' ]); + + $this->forthMenu(); + return $this->fetch('config/basics'); + } + + } +} \ No newline at end of file diff --git a/addon/futures/shop/view/config/basics.html b/addon/futures/shop/view/config/basics.html new file mode 100644 index 00000000..fff5e155 --- /dev/null +++ b/addon/futures/shop/view/config/basics.html @@ -0,0 +1,190 @@ +{extend name="app/shop/view/base.html"/} +{block name="resources"} + +{/block} +{block name="main"} + +
+
+ +
+ + +
+
+
+ +
+
+
+ +
+ + + + + + + +
+
+
+
+ +
+ + +
+
~
+
+ + +
+
+
+ +
+ + + +
+ +{/block} +{block name="script"} + +{/block} \ No newline at end of file