| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 | 
							- <?php
 
- /**
 
-  * Goods.php  UTF-8
 
-  * 金币(积分)兑换商品
 
-  *
 
-  * @date    : 2018/9/28 17:56
 
-  *
 
-  * @license 这不是一个自由软件,未经授权不许任何使用和传播。
 
-  * @author  : chenbingling <cbl@huosdk.com>
 
-  * @version : HuoMP 1.0
 
-  */
 
- namespace huomp\controller\goods;
 
- use huo\model\shop\GoodsModel;
 
- use huo\model\shop\ItgOrderModel;
 
- use huolib\constant\MemItgConst;
 
- class Goods {
 
-     /**
 
-      * 获取条件
 
-      */
 
-     public function getWhere($param = []) {
 
-         $_map = [];
 
-         return $_map;
 
-     }
 
-     /**
 
-      * 获取数据字段
 
-      */
 
-     public function getField() {
 
-         $_field = [
 
-             'id'           => 'good_id',
 
-             'goods_name'   => 'goods_name',
 
-             'object_type'  => 'object_type',
 
-             'remain_cnt'   => 'remain_cnt',
 
-             'market_price' => 'market_price',
 
-             'integral'     => 'integral',
 
-             'mem_times'    => 'mem_times',
 
-             'original_img' => 'original_img',
 
-             'is_real'      => 'is_real'
 
-         ];
 
-         return $_field;
 
-     }
 
-     /**
 
-      *获取所有上架的商品
 
-      *
 
-      * @param array  $param
 
-      * @param string $page
 
-      * @param string $order
 
-      *
 
-      * @return array
 
-      */
 
-     public function getList($param = [], $page = '1,10', $order = '-list_order') {
 
-         $_rdata = ['count' => 0, 'list' => []];
 
-         $_map = $this->getWhere($param);
 
-         if (empty($_map['flag'])) {
 
-             $_map['flag'] = ['neq', 5];
 
-         }
 
-         $_model = new GoodsModel();
 
-         $_count = $_model->where($_map)->count('id');
 
-         if (empty($_count)) {
 
-             return $_rdata;
 
-         }
 
-         $_field = $this->getField();
 
-         $_order = $_model->orderFilter($order);
 
-         $_data = $_model->where($_map)->field($_field)->page($page)->order($_order)->select();
 
-         if (is_object($_data)) {
 
-             $_data = $_data->toArray();
 
-         }
 
-         if (empty($_data)) {
 
-             return $_rdata;
 
-         }
 
-         $_rdata['count'] = $_count;
 
-         $_rdata['list'] = $_data;
 
-         return $_rdata;
 
-     }
 
-     /**
 
-      * 获取积分兑换/抽奖记录
 
-      *
 
-      * @param array  $param
 
-      * @param string $page
 
-      * @param string $order
 
-      *
 
-      * @return array
 
-      */
 
-     public function getItgLog($param = [], $page = '1,10', $order = '-id') {
 
-         $_rdata = ['count' => 0, 'list' => []];
 
-         $_model = new ItgOrderModel();
 
-         $_count = $_model->where($param)->count('id');
 
-         if (empty($_count)) {
 
-             return $_rdata;
 
-         }
 
-         $_order = $_model->orderFilter($order);
 
-         $_field = 'id, mem_id, goods_id, integral,create_time';
 
-         $_item = $_model->with('goods')
 
-                         ->field($_field)
 
-                         ->where($param)
 
-                         ->order($_order)
 
-                         ->page($page)
 
-                         ->select();
 
-         if (is_object($_item)) {
 
-             $_item = $_item->toArray();
 
-         }
 
-         if (empty($_item)) {
 
-             return $_rdata;
 
-         }
 
-         $_list = [];
 
-         $_title = '兑换';
 
-         if (MemItgConst::SHOP_FLAG_LOTTERY == $param['flag']) {
 
-             $_title = '';
 
-         }
 
-         foreach ($_item as $_k => $_v) {
 
-             $_good_name = empty($_v['goods']['goods_name']) ? '' : $_v['goods']['goods_name'];
 
-             $_list[] = [
 
-                 'title'    => $_title.$_good_name,
 
-                 'time'     => date('y-m-d H:i:s', $_v['create_time']),
 
-                 'integral' => $_v['integral'],
 
-             ];
 
-         }
 
-         $_rdata['count'] = $_count;
 
-         $_rdata['list'] = $_list;
 
-         return $_rdata;
 
-     }
 
- }
 
 
  |