ajaxReturn($res); } } /** * 获取商城DIY数据(未分包版) */ public function getStoreDiy() { $Diy = new Diy(self::$store_id, self::$merchant_id); $data = $Diy->getDiy(); $result = $data['data']; if ($data['status'] != 1 || empty($result['data'])) { $result['status'] = 0; } else { $result['status'] = 1; } //把地址改为未分包时的数据 if ($result['status'] == 1) { $arr = array( '\/pages\/lives\/lives' => '\/pages\/index\/lives\/lives', '\/pages\/Coupon\/Coupon' => '\/pages\/index\/Coupon\/Coupon', '\/pages\/Group-purchase-details\/Group-purchase-details' => '\/pages\/index\/Group-purchase-details\/Group-purchase-details', '\/pages\/Group-purchase\/Group-purchase' => '\/pages\/index\/Group-purchase\/Group-purchase', '\/pages\/Seckill-purchase-details\/Seckill-purchase-details' => '\/pages\/index\/Seckill-purchase-details\/Seckill-purchase-details', '\/pages\/Seckill-purchase\/Seckill-purchase' => '\/pages\/index\/Seckill-purchase\/Seckill-purchase', '\/pages\/advanceDetails\/advanceDetails' => '\/pages\/index\/advanceDetails\/advanceDetails', '\/pages\/advanceSale\/advanceSale' => '\/pages\/index\/advanceSale\/advanceSale', '\/pages\/MyCollect\/MyCollect' => '\/pages\/mine\/MyCollect\/MyCollect', '\/pages\/card\/card' => '\/pages\/mine\/card\/card', '\/pages\/gift_home\/gift_home' => '\/pages\/mine\/gift_home\/gift_home', '\/pages\/gift_purchase\/gift_purchase' => '\/pages\/mine\/gift_purchase\/gift_purchase', '\/pages\/recharge\/recharge' => '\/pages\/mine\/recharge\/recharge', '\/pages\/subCard\/subCard' => '\/pages\/mine\/subCard\/subCard', '\/pages\/MyAddress\/MyAddress' => '\/pages\/mine\/MyAddress\/MyAddress', '\/pages\/plusHome\/plusHome' => '\/pages\/mine\/plusHome\/plusHome', '\/pages\/details\/details' => '\/pages\/product\/details\/details', '\/pages\/new-goods\/new-goods' => '\/pages\/product\/new-goods\/new-goods', '\/pages\/plusGoods\/plusGoods' => '\/pages\/product\/plusGoods\/plusGoods', '\/pages\/productList\/productList' => '\/pages\/product\/productList\/productList', '\/pages\/promotion\/promotion' => '\/pages\/product\/promotion\/promotion', ); foreach ($arr as $key => $value) { $result['data'] = str_replace($value, $key, $result['data']); } } $this->ajaxReturn($result); } /** * 获取商城DIY数据(分包版) */ public function getStoreDiy_v1() { $Diy = new Diy(self::$store_id, self::$merchant_id); $data = $Diy->getDiy(); $result = $data['data']; if ($data['status'] != 1 || empty($result['data'])) { $result['status'] = 0; } else { $result['status'] = 1; } $this->ajaxReturn($result); } /** * 获取推荐商品 */ public function getRecommendGoods() { if (IS_POST) { $store_id = self::$store_id; $ids = I('post.ids'); //商品ID $StoreXcxConfigModel = new RetailStoreXcxConfigModel(); $sMap = array( 'storeid' => $store_id, ); $sFields = array( 'recommend_status', 'promotion_status', ); $store_config = $StoreXcxConfigModel->getFind($sMap, $sFields); $GoodsModel = new RetailGoodsModel(); $gMap = [ 'store_id' => $store_id, 'online_state' => 1, 'status' => 0, 'online_price' => ['gt', 0], ]; $gFields = [ 'id as goods_id', 'goods_img_id', 'goods_name', 'online_price', 'company', 'attribute_state', 'plus_mem_status',//1开启 2关闭 plus会员价 'plus_price',//plus会员价 'shop_mem_status', 'shop_mem_price', 'store_mem_price',//店内会员价格 'store_mem_status',//是否开启店内会员价1.开启2关闭 ]; $idsType = I('post.ids_type');//1:商户ids,2:门店ids if($idsType == 1 && $ids !== ''){ //商户商品ids,替换成门店商品ids $whereMid = [ 'store_id'=>$store_id,//门店id 'status' => 0,//状态:0,正常,1,下架,2,删除。 'online_state' => 1,//是否在商城中出售:0,不在,1,在商城出售。 'online_price' => ['gt',0],//小程序商城价格 'm_goods_id' => ['in', $ids],//调拨商户的商品id ]; $fieldMid = 'id'; $orderMid = 'id desc'; //获取门店商品ids $mIds = $GoodsModel->getOrderFindField($whereMid,$fieldMid,$orderMid,true); $ids = implode(',', $mIds);//数组变成字符串 } if (empty($ids)) { //自动获取 $page = I('post.page') ? I('post.page') : 1; $limit = I('post.limit') ? I('post.limit') : 10; $HostModel = new RetailHostModel(); $map = array( 'h.status' => 1, 'h.type' => 1, 'g.store_id' => $store_id, 'g.online_state' => 1, 'g.status' => 0, 'g.online_price' => array('gt', 0), ); if ($store_config['promotion_status'] == 1) { //开启促销 $field = array( 'h.id as h_id', 'h.goods_id', 'h1.status as promotion_status', 'h1.act_price', 'g.goods_img_id', 'g.goods_name', 'g.online_price', 'g.attribute_state', 'g.plus_mem_status',//1开启 2关闭 plus会员价 'g.plus_price',//plus会员价 'g.shop_mem_status', 'g.shop_mem_price', 'g.company', 'g.store_mem_price',//店内会员价格 'g.store_mem_status',//是否开启店内会员价1.开启2关闭 ); $order = 'h.sort asc,h.id desc,g.goods_order asc,h1.act_price asc'; $goodsList = $HostModel->getOtherGoods($map, $field, $order, $page . ',' . $limit); } else { //未开启促销 $field = array( 'h.id as h_id', 'h.goods_id', 'g.goods_img_id', 'g.goods_name', 'g.online_price', 'g.attribute_state', 'g.plus_mem_status',//1开启 2关闭 plus会员价 'g.plus_price',//plus会员价 'g.shop_mem_status', 'g.shop_mem_price', 'g.company', 'g.store_mem_price',//店内会员价格 'g.store_mem_status',//是否开启店内会员价1.开启2关闭 ); $order = 'h.sort asc,g.goods_order asc,h.id desc'; $goodsList = $HostModel->getActGoods($map, $field, $order, $page . ',' . $limit); } $count = count($goodsList); if ($count < 20) { //推荐商品不足20个,补充普通商品 $appendGoods = $GoodsModel->getSelect($gMap, $gFields, 'goods_order asc,id desc', '1,' . bcsub(20, $count)); $goodsList = array_merge($goodsList, $appendGoods); } } else { //根据选择的商品返回 if ($store_config['promotion_status'] == 1) { //开启促销 $map = array( 'g.store_id' => $store_id, 'g.status' => 0, 'g.online_state' => 1, 'g.online_price' => array('gt', 0), 'g.id' => array('in', $ids) ); $field = array( 'g.id as goods_id', 'g.goods_img_id', 'g.goods_name', 'g.online_price', 'g.attribute_state', 'g.plus_mem_status',//1开启 2关闭 plus会员价 'g.plus_price',//plus会员价 'g.shop_mem_status', 'g.shop_mem_price', 'g.company', 'h.act_price', 'h.status as promotion_status', 'g.store_mem_price',//店内会员价格 'g.store_mem_status',//是否开启店内会员价1.开启2关闭 ); $goodsList = $GoodsModel->getHostGoods($map, $field, 'g.goods_order asc,g.id desc', '1,20'); } else { $map = array( 'store_id' => $store_id, 'status' => 0, 'online_state' => 1, 'online_price' => array('gt', 0), 'id' => array('in', $ids) ); $field = array( 'id as goods_id', 'goods_img_id', 'goods_name', 'online_price', 'attribute_state', 'plus_mem_status',//1开启 2关闭 plus会员价 'plus_price',//plus会员价 'shop_mem_status', 'shop_mem_price', 'company', 'store_mem_price',//店内会员价格 'store_mem_status',//是否开启店内会员价1.开启2关闭 ); $goodsList = $GoodsModel->getSelect($map, $field, 'goods_order asc,id desc'); } } $Plug = new Plug(); // 判断商户是否开启分销插件 $PlugData = $Plug->PlugPermissions([ 'merchant_id' => self::$merchant_id, 'identification_arr' => ['malldistribution'] ]); if (!empty($PlugData['data']['plug']['malldistribution'])) { $OpenDistribution = 1; } if (!empty($goodsList)) { foreach ($goodsList as &$val) { $val['goods_img'] = getGoodsImage($val['goods_img_id'], $store_id); $val['goods_img'] = $val['goods_img'] ? $val['goods_img'] : ''; $online_price = $val['online_price']; if ($val['promotion_status'] && $val['act_price']) { $online_price = $val['act_price']; } //首页展示预估佣金 待定 if (self::$uid && $OpenDistribution) { $MiniDistributorController = new \Distribution\Controller\MiniDistributorController(); try { $propReturnRes = $MiniDistributorController->disStorePropReturn(self::$uid, $val['id'], $online_price); } catch (\Exception $e) { } if ($propReturnRes['status'] == 1) { $val['disStoreProp'] = $propReturnRes['disStoreProp']; } } unset($val['goods_img_id']); } $res['status'] = 1; $res["msg"] = "获取成功"; $res['data'] = $goodsList; } else { $res['status'] = 1; $res['data'] = []; $res['msg'] = '暂无推荐商品'; } } else { $res['status'] = 0; $res['msg'] = '网络错误'; } $this->ajaxReturn($res); } //获取商户商品列表 public function merchantGoods(){ if (IS_POST) { $merchant_id = self::$merchant_id; $ids = I('post.ids'); //商品ID $retailMgoods = new RetailMgoodsModel(); $map = array( 'merchantid' => $merchant_id,//门店id—>商户id 'status' => 0,//状态:0,正常,1,下架,2,删除。 'issellonline' => 1,//是否在商城中出售:0,不在,1,在商城出售。 'online_price' => array('gt', 0),//小程序商城价格 'id' => array('in', $ids)//商品ids ); $field = array( 'id as goods_id',//门店商品id—>商户商品id 'goods_image_id as goods_img_id',//图片id 'goods_name',//商品名称 'online_price',//小程序商城价格—>线上价 'attribute as attribute_state',//是否开启sku :1不开启,2开启 —> 是否开启sku :1关闭,2开启 'plus_mem_status',//1开启 2关闭 plus会员价 'plus_price',//plus会员价 'shop_mem_status',//是否开启商城会员价1.开启2.关闭 'shop_mem_price',//商城会员价格 'store_mem_price',//店内会员价格 'store_mem_status',//是否开启店内会员价1.开启2关闭 ); $goodsList = $retailMgoods->getSelect($map, $field, 'goods_order asc,id desc'); $Plug = new Plug(); // 判断商户是否开启分销插件 $PlugData = $Plug->PlugPermissions([ 'merchant_id' => $merchant_id, 'identification_arr' => ['malldistribution'] ]); if (!empty($PlugData['data']['plug']['malldistribution'])) { $OpenDistribution = 1; } if (!empty($goodsList)) { foreach ($goodsList as &$val) { $val['goods_img'] = getGoodsImage($val['goods_img_id']); $val['goods_img'] = $val['goods_img'] ? $val['goods_img'] : ''; $online_price = $val['online_price']; if ($val['promotion_status'] && $val['act_price']) { $online_price = $val['act_price']; } //首页展示预估佣金 待定 if (self::$uid && $OpenDistribution) { $MiniDistributorController = new \Distribution\Controller\MiniDistributorController(); try { $propReturnRes = $MiniDistributorController->disStorePropReturn(self::$uid, $val['id'], $online_price); } catch (\Exception $e) { } if ($propReturnRes['status'] == 1) { $val['disStoreProp'] = $propReturnRes['disStoreProp']; } } unset($val['goods_img_id']); } $res['status'] = 1; $res["msg"] = "获取成功"; $res['data'] = $goodsList; } else { $res['status'] = 1; $res['data'] = []; $res['msg'] = '暂无商品'; } } else { $res['status'] = 0; $res['msg'] = '网络错误'; } $this->ajaxReturn($res); } /** * 获取秒杀活动 */ public function getSeckill() { if (IS_POST) { $ids = I('post.ids'); $page = I('post.page') ? I('post.page') : 1; $limit = I('post.limit') ? I('post.limit') : 10; // 实例化模型 $SpikeViewModel = new RetailSpikeViewModel(); $map = array( 'RetailSpike.storeid' => self::$store_id, 'RetailSpike.active_status' => 1, 'RetailSpike.active_endtime' => array('gt', time()), 'RetailGoods.status' => 0, 'RetailGoods.online_state' => 1 ); if (!empty($ids)) { //指定活动 $map['RetailSpike.id'] = array('in', $ids); $page = ''; $limit = ''; } $field = array( 'id', 'active_title as act_name', 'spike_price', 'retail_price', 'goods_name', 'goods_brand_id', 'goods_img_id', 'company', 'weight_value', 'start_time', 'end_time' ); // 查询秒杀活动 $spike_list = $SpikeViewModel->getSelect($map, $field, $page, $limit); if (!$spike_list) { $res = array( 'status' => 0, 'msg' => '暂无秒杀活动' ); $this->ajaxReturn($res); } $BrandModel = new \Common\Model\RetailGoodsBrandModel(); // 处理数据 foreach ($spike_list as &$val) { $val['spike_price'] = $val['spike_price'] ? number_format(floatval($val['spike_price']), 2) : 0; // 商品图片 $val['goods_img'] = getGoodsImage($val['goods_img_id'], self::$store_id); $val['goods_img'] = $val['goods_img'] ? $val['goods_img'] : ''; $goods_brand = ''; if (!empty($val['goods_brand_id'])) { $goods_brand = $BrandModel->getFindField(['id' => $val['goods_brand_id']], 'name'); } $val['broadcast'] = [ 'title' => sprintf('%s %s %skg %s', $goods_brand, $val['goods_name'], (int)$val['weight_value'], $val['company']), 'startTime' => date('Y-m-d H:i:s', $val['start_time']), 'endTime' => date('Y-m-d H:i:s', $val['end_time']), ]; $val['time'] = time(); unset($val['goods_img_id']); } $res = array( 'status' => 1, 'msg' => '获取成功', 'data' => $spike_list, ); $this->ajaxReturn($res); } else { $res = array( 'status' => 0, 'msg' => '网络错误' ); $this->ajaxReturn($res); } } /** * 获取拼团活动 */ public function getGroup() { if (IS_POST) { $ids = I('post.ids'); $page = I('post.page') ? I('post.page') : 1; $limit = I('post.limit') ? I('post.limit') : 10; // 实例化模型 $GroupViewModel = new RetailGroupViewModel(); // 查询活动 $map = array( 'RetailGroup.storeid' => self::$store_id, 'RetailGroup.acttype' => 1, 'RetailGroup.endtime' => array('gt', time()), 'RetailGoods.status' => 0, 'RetailGoods.online_state' => 1 ); if (!empty($ids)) { //指定活动 $map['RetailGroup.id'] = array('in', $ids); $page = ''; $limit = ''; } $field = array( 'id', 'act_name', 'act_price', 'goods_name', 'goods_img_id', ); // 查询拼团活动 $group_list = $GroupViewModel->getSelect($map, $field, $page, $limit); if (!$group_list) { $res = array( 'status' => 0, 'msg' => '暂无拼团活动' ); $this->ajaxReturn($res); } // 处理数据 foreach ($group_list as &$val) { $val['act_price'] = $val['act_price'] ? floatval($val['act_price']) : 0; $val['act_price'] = number_format($val['act_price'], 2); // 商品图片 $val['goods_img'] = getGoodsImage($val['goods_img_id'], self::$store_id); $val['goods_img'] = $val['goods_img'] ? $val['goods_img'] : ''; unset($val['goods_img_id']); } $res = array( 'status' => 1, 'msg' => '获取成功', 'data' => $group_list, ); $this->ajaxReturn($res); } else { $res = array( 'status' => 0, 'msg' => '网络错误' ); $this->ajaxReturn($res); } } /** * 获取促销商品 */ public function getPromotion() { $page = I('post.page') ? I('post.page') : 1; $limit = I('post.limit') ? I('post.limit') : 10; $ids = I('post.ids'); $store_id = self::$store_id; $StoreXcxConfigModel = new RetailStoreXcxConfigModel(); $map = array( 'storeid' => $store_id, ); $promotion_status = $StoreXcxConfigModel->getFindField($map, 'promotion_status'); if (empty($promotion_status)) { $res['status'] = 0; $res['msg'] = '商家未开启促销功能'; $this->ajaxReturn($res); } $HostModel = new RetailHostModel(); //促销 $time = time(); $map = array( 'h.type' => 2, 'h.status' => 1, 'h.state' => 1, 'h.starttime' => array('elt', $time), 'h.endtime' => array('egt', $time), 'g.store_id' => $store_id, 'g.online_state' => 1, 'g.status' => 0, ); $field = array( 'h.id', 'h.goods_id', 'h.act_price', 'g.goods_img_id', 'g.goods_name', 'g.online_price', ); $order = 'h.id desc,g.id desc,h.act_price asc'; if (!empty($ids)) { //获取指定促销活动 $map['h.id'] = array('in', $ids); $promotion = $HostModel->getHostGoods_v1($map, $field, $order, ''); } else { $promotion = $HostModel->getHostGoods_v1($map, $field, $order, $page . ',' . $limit); } foreach ($promotion as &$val) { $val['goods_img'] = getGoodsImage($val['goods_img_id'], $store_id); $val['goods_img'] = $val['goods_img'] ? $val['goods_img'] : ''; unset($val['goods_img_id']); } $res['status'] = 1; $res['msg'] = '获取成功'; $res['data'] = $promotion; $this->ajaxReturn($res); } /** * 获取礼品卡 */ public function getGiftCard() { $page = I('post.page') ? I('post.page') : 1; $limit = I('post.limit') ? I('post.limit') : 10; $ids = I('post.ids'); $merchant_id = self::$merchant_id; $GiftCardModel = new RetailGiftCardModel(); $time = time(); $map = array( 'merchantid' => $merchant_id, 'status' => 1, 'state' => 1, 'start_time' => array('elt', $time), 'end_time' => array('gt', $time), ); $fields = array( 'id', 'title', ); if (!empty($ids)) { //获取指定礼品卡 $map['id'] = array('in', $ids); $list = $GiftCardModel->getSelect($map, $fields, 'id desc'); } else { $list = $GiftCardModel->getSelect($map, $fields, 'id desc', $page . ',' . $limit); } if (!empty($list)) { $GiftCardCoverModel = new RetailGiftCardCoverModel(); foreach ($list as &$val) { $map = array( 'gift_cardid' => $val['id'], 'status' => 1, 'state' => 1, ); $img_url_id = $GiftCardCoverModel->getOrderFindField($map, 'img_url_id', 'id desc'); $val['img_url'] = getImage($img_url_id); } $res['status'] = 1; $res['msg'] = '获取成功'; $res['data'] = $list; } else { $res['status'] = 0; $res['msg'] = '暂无礼品卡'; } $this->ajaxReturn($res); } /** * 预售活动列表 */ public function getAdvanceList() { if (IS_POST) { $data = I("post."); $advance_model = new AdvanceGoodsModel(); $AdvanceSkuGoodsModel = new AdvanceSkuGoodsModel(); $page = $data['page'] ? $data['page'] : 1; $limit = $data['limit'] ? $data['limit'] : 10; $where = array( 'a.store_id' => self::$store_id, 'a.advance_state' => 1, 'a.advance_end_time' => array('gt', time()), 'g.status' => 0, ); if (!empty($data['ids'])) { //指定活动 $where['a.id'] = array('in', $data['ids']); $page = ''; $limit = ''; } $parameter = array( 'where' => $where, 'page' => $page, 'limit' => $limit, 'field' => array( 'a.id', 'a.goods_id', 'a.attribute_state', 'a.surplus_num', 'a.advance_type', 'a.advance_price', 'g.goods_name', 'g.goods_img_id', ) ); $info = $advance_model->getList($parameter); $advance_list = $info['data']['list']; if ($info['status'] != 1 || !$advance_list) { $res = array('status' => 0, 'msg' => '暂无预售活动'); $this->ajaxReturn($res); } $list = array(); foreach ($advance_list as $key => &$val) { $frozen_param = array( 'id' => $val['id'], 'goods_id' => $val['goods_id'], 'sku_id' => '', 'attribute_state' => $val['attribute_state'] ); $frozen_num = $advance_model->frozen_num($frozen_param); $val['surplus_num'] = round($val['surplus_num'] - $frozen_num, 3); if ($val['surplus_num'] <= 0) { continue; } switch ($val['attribute_state']) { case 1: $val['advance_price'] = number_format($val['advance_price'], 2); break; case 2: $sku_info = $AdvanceSkuGoodsModel->where(array('advance_id' => $val['id'], 'goods_id' => $val['goods_id'], 'advance_state' => 1))->order("advance_price asc")->find(); $val['advance_price'] = $sku_info['advance_price'] ? number_format($sku_info['advance_price'], 2) : ''; break; } $val['goods_img'] = getGoodsImage($val['goods_img_id'], self::$store_id); $val['goods_img'] = $val['goods_img'] ? $val['goods_img'] : ''; array_push($list, $val); } $res = array( 'status' => 1, 'msg' => '获取成功', 'data' => $list ? $list : array(), ); } else { $res = array( 'status' => 0, 'msg' => '请求方式有误' ); } $this->ajaxReturn($res); } /** * 商户DIY */ //获取商户DIY设置 public function merchantDiy() { $merchantId = self::$merchant_id;//商户id if (!$merchantId) { $res = callBack(statusCode()['error'], '失败'); $this->ajaxReturn($res); } $merchantConfigModel = new MerchantConfigModel(); $where = [ 'merchant_id' => $merchantId, ]; $fields = [ 'merchant_diy' ]; $data = $merchantConfigModel->getFindField($where, $fields);//获取商户DIY $plugClass = new Plug(); $result = $plugClass->PlugPermissions([ 'merchant_id' => $merchantId, 'identification_arr' => [ 'shopcoupon',//微信商家券插件 'wxpaycoupon',//微信支付代金券插件 'malldistribution',//分销插件,distribution_state 'presale',//预售插件,advance_state 'seckill',//秒杀插件,seckill_state 'group',//拼团插件,group_state 'giftcard',//礼品卡插件,gift_state ] ]); //处理优惠券、商家券、代金券插件 $plug_state['coupon'] = array( array('name' => '优惠券', 'type' => 1, 'status' => 1), array('name' => '商家券', 'type' => 2, 'status' => (isset($result['data']['plug']['shopcoupon']) && $result['data']['plug']['shopcoupon'] > 0) ? 1 : 0), array('name' => '代金券', 'type' => 3, 'status' => (isset($result['data']['plug']['wxpaycoupon']) && $result['data']['plug']['wxpaycoupon'] > 0) ? 1 : 0), ); //处理分销插件 $plug_state['distribution_state'] = (isset($result['data']['plug']['malldistribution']) && $result['data']['plug']['malldistribution'] > 0) ? 1 : 0; //处理预售插件 $plug_state['advance_state'] = (isset($result['data']['plug']['presale']) && $result['data']['plug']['presale'] > 0) ? 1 : 0; //处理秒杀插件 $plug_state['seckill_state'] = (isset($result['data']['plug']['seckill']) && $result['data']['plug']['seckill'] > 0) ? 1 : 0; //处理拼团插件 $plug_state['group_state'] = (isset($result['data']['plug']['group']) && $result['data']['plug']['group'] > 0) ? 1 : 0; //礼品卡插件 $plug_state['gift_state'] = (isset($result['data']['plug']['giftcard']) && $result['data']['plug']['giftcard'] > 0) ? 1 : 0; $plug_state['promotion_state'] = 1;//处理促销状态 if ($data) { $res = callBack(statusCode()['success'], '成功', $data); } else { $res = callBack(statusCode()['error'], '失败'); } $res['plug_state'] = $plug_state; $this->ajaxReturn($res); } //获取商户商品列表 public function mGoodsList() { $keyword = I('post.keyword'); $merchantId = I('post.merchant_id') ? I('post.merchant_id') : 1; $page = I('post.page') ? I('post.page') : 1; $limit = I('post.limit') ? I('post.limit') : 10; $ids = I('post.ids'); $map = array( 'merchantid' => $merchantId,//商户id 'status' => 0,//状态:0,正常,1,下架,2,删除。 'issellonline' => 1,//是否在商城中出售:0,不在,1,在商城出售。 'online_price' => array('gt', 0),//线上价 ); if ($keyword) { $map['goods_name|goods_code|good_number'] = array('like', '%' . $keyword . '%'); } if($ids){ $map['id'] = array('not in', $ids);//商品ids } $fields = array( 'id', 'goods_name',//零售货物名称。 'goods_code',//商品条码。 'good_number',//货号 'goods_image_id',//商品图片id 'online_price',//线上价 'addtime',//添加时间 ); $order = 'id desc'; $GoodsModel = new RetailMgoodsModel(); $goods = $GoodsModel->getSelect($map, $fields, $order, "{$page},{$limit}");//获取商品列表 $count = $GoodsModel->getCount($map);//获取商品数量 $ImageGalleryModel = new ImageGalleryModel(); foreach ($goods as &$value) { $value['add_time'] = date('Y-m-d H:i:s', $value['addtime']); $value['goods_code'] = $value['goods_code'] ? $value['goods_code'] : '---'; $value['goods_number'] = $value['good_number'] ? $value['good_number'] : '---'; $value['goods_img'] = $ImageGalleryModel->getImagePath($value['goods_image_id']); $value['goods_img'] = $value['goods_img'] ? $value['goods_img'] : ''; unset($value['goods_image_id'],$value['good_number'],$value['addtime']); } $res['status'] = 1; $res['msg'] = empty($goods) ? '暂无数据' : '获取成功'; $res['count'] = $count; $res['data'] = $goods; $this->ajaxReturn($res); } }