123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <?php
- namespace huo\controller\shop;
- use huo\controller\common\Base;
- use huo\controller\gift\Gift;
- use huo\controller\member\MemCache;
- use huo\logic\shop\GoodsLogic;
- use huolib\constant\MemItgConst;
- use huolib\status\CommonStatus;
- use huolib\status\ShopStatus;
- class Goods extends Base {
-
- public function getList($where = [], $page = '1,10', $mem_id, $can_ex = false) {
- $_order = '-list_order';
- $_map['is_real'] = $this->getVal($where, 'is_real', 0);
- if (isset($where['flag'])) {
- $_map['flag'] = $where['flag'];
- }
- $_integral = 0;
- if (!empty($mem_id) && true == $can_ex) {
- $_me_data = MemCache::ins()->getMeInfoById($mem_id);
- if (!empty($_me_data['my_integral'])) {
- $_integral = $_me_data['my_integral'];
- }
- }
- if (!empty($_integral)) {
- $_map['integral'] = ['gt', 0];
- }
- $_data = (new GoodsLogic())->getList($_map, $page, $_order);
- if (is_numeric($_data)) {
- return $this->huoError($_data, ShopStatus::getMsg($_data));
- }
-
- if (!empty($_data['count'])) {
- foreach ($_data['list'] as $key => $goods) {
- if (MemItgConst::GOODS_IS_GIFT == $goods['object_name']) {
- $_gift_class = new Gift();
- $_gift_data = $_gift_class->getGiftDetail($goods['object_id'], $mem_id);
- if (CommonStatus::NO_ERROR == $_gift_data['code']) {
- $goods['integral'] = $_gift_data['data']['condition'];
- $goods['remain_cnt'] = $_gift_data['data']['remain_cnt'];
- $_data['list'][$key] = $goods;
- }
- }
- $_data['list'][$key]['integral'] = (int)$_data['list'][$key]['integral'];
- }
- }
- return $this->retSucMsg(CommonStatus::NO_ERROR, $_data);
- }
-
- public function getDetail($goods_id = 0) {
- if (empty($goods_id)) {
- return $this->retErrMsg(CommonStatus::INVALID_PARAMS);
- }
- $_data = GoodsCache::ins()->getInfoByGoodsId($goods_id);
- return $this->retSucMsg(CommonStatus::NO_ERROR, $_data);
- }
- }
|