123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- <?php
- /**
- * GoodsController.php UTF-8
- *
- *
- * @date : 2018/7/31 10:34
- *
- * @license 这不是一个自由软件,未经授权不许任何使用和传播。
- * @author : wuyonghong <wyh@huosdk.com>
- * @version : Huosdk 8.0
- */
- namespace api\accountdeal\controller;
- use api\common\controller\V2ApiBaseController;
- use huoAccountDeal\controller\AccountOut;
- use huoAccountDeal\controller\MemGameOut;
- use huolib\constant\AccountConst;
- use huolib\sms\Sms;
- use huolib\status\MemberStatus;
- use think\Lang;
- class GoodsController extends V2ApiBaseController {
- public function _initialize() {
- parent::_initialize();
- $langSet = $this->request->langset();
- Lang::load([APP_PATH.'accountdeal'.DS.'lang'.DS.$langSet.DS.'account'.EXT,]);
- }
- /**
- * 商品-商品列表
- * http://doc.huosdk.com/138?page_id=3426
- * 【域名】/account/goods/list
- */
- public function getGoodsList() {
- $_sort_type = $this->request->param('sort_type/d', 1);
- $_app_id = $this->request->param('game_id/d', 0);
- $_keyword = $this->request->param('keyword/s', '');
- $_is_like = $this->request->param('is_like/d', 0);
- $_status = $this->request->param('status/d', 0);
- $_is_me_sell = $this->request->param('is_me_sell/d', 0);
- $_page = $this->request->param('page/d', 1);
- $_offset = $this->request->param('offset/d', 10);
- $_where = [];
- !empty($_keyword) && $_where['keyword'] = trim($_keyword);
- !empty($_app_id) && $_where['app_id'] = $_app_id;
- !empty($_status) && $_where['status'] = $_status;
- !empty($_is_me_sell) && $_where['is_me_sell'] = $_is_me_sell;
- if (2 == $_is_like) {
- $_where['is_like'] = $_is_like;
- }
- $_where['mem_id'] = $this->mem_id;
- $_rdata = (new AccountOut())->goodsList($_where, $_sort_type, $_page.','.$_offset);
- $this->returnData($_rdata);
- }
- /**
- * 商品-商品详情
- * http://doc.huosdk.com/138?page_id=3802
- * 【域名】/account/goods/detail
- */
- public function getGoodsDetail() {
- $_goods_id = $this->request->param('goods_id/d', 0);
- $_mem_id = $this->mem_id;
- $_rdata = (new AccountOut())->getGoodsDetail($_goods_id, $_mem_id);
- $this->returnData($_rdata);
- }
- /**
- * 玩家-收藏(取消)
- * http://doc.huosdk.com/138?page_id=3431
- * 【域名】/user/goods/like
- */
- public function like() {
- $this->checkLogin();
- $_goods_id = $this->request->param('goods_id/d', 0);
- $_mem_id = $this->getMemId();
- $_rdata = (new AccountOut())->like($_mem_id, $_goods_id);
- $this->returnData($_rdata);
- }
- /**
- * 商品-游戏列表
- * http://doc.huosdk.com/138?page_id=3427
- * 【域名】/account/game/list
- */
- public function getGameList() {
- $_page = $this->request->param('page/d', 1);
- $_offset = $this->request->param('offset/d', 10);
- $_is_mine = $this->request->param('is_mine/d', 0);
- $_page = $_page.','.$_offset;
- if (AccountConst::ACCOUNT_IS_MINE == $_is_mine) {
- $this->checkLogin();
- $_rdata = (new MemGameOut())->getSellMyGameList($this->mem_id, $_page);
- } else {
- $_rdata = (new MemGameOut())->getSellGameList($_page);
- }
- $this->returnData($_rdata);
- }
- /**
- * 卖号-出售小号
- * http://doc.huosdk.com/138?page_id=3430
- * 【域名】/account/goods/sell
- */
- public function sell() {
- $this->checkLogin();
- $_param = $this->request->param();
- $_result = $this->validate($_param, 'Account.sell');
- if ($_result !== true) {
- $this->error($_result);
- }
- $_sms_data = $this->rq_data['sms'];
- $_mobile = $_sms_data['mobile'];
- $_type = $_sms_data['type'];
- $_code = $_sms_data['code'];
- /* 校验短信是否正确 */
- $_sms_rs = (new Sms())->check($_mobile, $_code, $_type);
- if (MemberStatus::NO_ERROR != $_sms_rs['code']) {
- $this->error($_sms_rs['msg'], [], $_sms_rs['code']);
- }
- $_mem_id = $this->mem_id;
- $_mg_mem_id = $this->request->param('mg_mem_id/d', 0);
- $_mg_role_id = $this->request->param('mg_role_id/d');
- $_title = $this->request->param('title/s');
- $_description = $this->request->param('description/s');
- $_price = $this->request->param('price/f', 0);
- $_image = $this->request->param('image', '', 'htmlspecialchars_decode');
- $_rs = (new AccountOut())->sell(
- $_mem_id, $_mg_mem_id, $_mg_role_id, $_title, $_description, $_price, $_image
- );
- $this->returnData($_rs);
- }
- /**
- * 卖号-小号商品修改
- * http://doc.huosdk.com/138?page_id=3851
- * 【域名】/account/goods/edit
- */
- public function edit() {
- $this->checkLogin();
- $_param = $this->request->param();
- $_result = $this->validate($_param, 'Account.edit');
- if ($_result !== true) {
- $this->error($_result);
- }
- $_sms_data = $this->rq_data['sms'];
- $_mobile = $_sms_data['mobile'];
- $_type = $_sms_data['type'];
- $_code = $_sms_data['code'];
- /* 校验短信是否正确 */
- $_sms_rs = (new Sms())->check($_mobile, $_code, $_type);
- if (MemberStatus::NO_ERROR != $_sms_rs['code']) {
- $this->error($_sms_rs['msg'], [], $_sms_rs['code']);
- }
- $_mem_id = $this->mem_id;
- $_mg_role_id = $this->request->param('mg_role_id/d');
- $_title = $this->request->param('title/s');
- $_description = $this->request->param('description/s');
- $_goods_id = $this->request->param('goods_id/d', '');
- $_price = $this->request->param('price/f', 0);
- $_image = $this->request->param('image', '', 'htmlspecialchars_decode');
- $_rs = (new AccountOut())->edit(
- $_goods_id, $_mem_id, $_mg_role_id, $_title, $_description, $_price, $_image
- );
- $this->returnData($_rs);
- }
- /**
- * http://doc.huosdk.com/138?page_id=3849
- * 卖号-下架小号
- * 【域名】/account/goods/cancel
- */
- public function cancel() {
- $this->checkLogin();
- $_param = $this->request->param();
- $_result = $this->validate($_param, 'Account.cancel');
- if ($_result !== true) {
- $this->error($_result);
- }
- $_goods_id = $this->request->param('goods_id/d', '');
- $_rs = (new AccountOut())->cancel($_goods_id);
- $this->returnData($_rs);
- }
- }
|