seller_info; $store_info = $this->store_info; //最后登陆 $seller_info['last_logintime_fmt'] = date('Y-m-d H:i:s', $seller_info['last_logintime']); $order_model = model('order'); // 待付款 $seller_info['order_nopay_count'] = intval($order_model->getOrderCountByID('store', $store_info['store_id'], 'NewCount')); // 待发货 $seller_info['order_noship_count'] = intval($order_model->getOrderCountByID('store', $store_info['store_id'], 'PayCount')); // 待收货 $seller_info['order_noreceipt_count'] = intval($order_model->getOrderCountByID('store', $store_info['store_id'], 'SendCount')); $goods_model = model('goods'); // 出售中的商品 $seller_info['goods_online'] = $goods_model->getGoodsCommonOnlineCount(array(array('store_id', '=', $store_info['store_id']))); // 仓库待上架的商品 $seller_info['goods_offline'] = $goods_model->getGoodsCommonOfflineCount(array(array('store_id', '=', $store_info['store_id']))); // 违规下架的商品 $seller_info['goods_lockup'] = $goods_model->getGoodsCommonLockUpCount(array(array('store_id', '=', $store_info['store_id']))); //店铺头像 $store_info['store_avatar'] = get_store_logo($store_info['store_avatar'], 'store_avatar'); //店铺标志 $store_info['store_logo'] = get_store_logo($store_info['store_logo'], 'store_logo'); //等级信息 $store_info['grade_name'] = $this->store_grade['storegrade_name']; //商品数量限制 $store_info['grade_goodslimit'] = $this->store_grade['storegrade_goods_limit']; //图片空间数量限制 $store_info['grade_albumlimit'] = $this->store_grade['storegrade_album_limit']; /** * 销售情况统计 */ $field = 'COUNT(*) as ordernum,SUM(order_amount) as orderamount'; $where = array(); $where[] = array('store_id', '=', $this->store_info['store_id']); //有效订单 $where[] = array('order_isvalid', '=', 1); //昨日销量 $where[] = array('order_add_time', 'between', array(strtotime(date('Y-m-d', (TIMESTAMP - 3600 * 24))), strtotime(date('Y-m-d', TIMESTAMP)) - 1)); $daily_sales = model('stat')->getoneByStatorder($where, $field); //月销量 $where[] = array('order_add_time', '>', strtotime(date('Y-m', TIMESTAMP))); $monthly_sales = model('stat')->getoneByStatorder($where, $field); $store_info['daily_sales'] = $daily_sales; $store_info['monthly_sales'] = $monthly_sales; //统计 $statics = $this->getStatics(); ds_json_encode(10000, '', array('seller_info' => $seller_info, 'store_info' => $store_info, 'statics' => $statics)); } /** * @api {POST} api/Sellerindex/getStatics 取得卖家统计类信息 * @apiVersion 1.0.0 * @apiGroup Sellerindex * * @apiHeader {String} X-DS-KEY 卖家授权token * * @apiSuccess {String} code 返回码,10000为成功 * @apiSuccess {String} message 返回消息 * @apiSuccess {Object} result 返回数据 */ private function getStatics() { $add_time_to = strtotime(date("Y-m-d")) + 60 * 60 * 24; //当前日期 ,从零点来时 $add_time_from = strtotime(date("Y-m-d", (strtotime(date("Y-m-d")) - 60 * 60 * 24 * 30))); //30天前 $goods_online = 0; // 出售中商品 $goods_waitverify = 0; // 等待审核 $goods_verifyfail = 0; // 审核失败 $goods_offline = 0; // 仓库待上架商品 $goods_lockup = 0; // 违规下架商品 $consult = 0; // 待回复商品咨询 $no_payment = 0; // 待付款 $no_delivery = 0; // 待发货 $no_receipt = 0; // 待收货 $refund_lock = 0; // 售前退款 $refund = 0; // 售后退款 $return_lock = 0; // 售前退货 $return = 0; // 售后退货 $complain = 0; //进行中投诉 $goods_model = model('goods'); // 全部商品数 $goodscount = $goods_model->getGoodsCommonCount(array('store_id' => $this->store_info['store_id'])); // 出售中的商品 $goods_online = $goods_model->getGoodsCommonOnlineCount(array(array('store_id', '=', $this->store_info['store_id']))); if (config('ds_config.goods_verify')) { // 等待审核的商品 $goods_waitverify = $goods_model->getGoodsCommonWaitVerifyCount(array(array('store_id', '=', $this->store_info['store_id']))); // 审核失败的商品 $goods_verifyfail = $goods_model->getGoodsCommonVerifyFailCount(array(array('store_id', '=', $this->store_info['store_id']))); } // 仓库待上架的商品 $goods_offline = $goods_model->getGoodsCommonOfflineCount(array(array('store_id', '=', $this->store_info['store_id']))); // 违规下架的商品 $goods_lockup = $goods_model->getGoodsCommonLockUpCount(array(array('store_id', '=', $this->store_info['store_id']))); // 等待回复商品咨询 $consult = model('consult')->getConsultCount(array('store_id' => $this->store_info['store_id'], 'consult_reply' => '')); // 商品图片数量 $imagecount = model('album')->getAlbumpicCount(array('store_id' => $this->store_info['store_id'])); $order_model = model('order'); // 交易中的订单 $progressing = $order_model->getOrderCountByID('store', $this->store_info['store_id'], 'TradeCount'); // 待付款 $no_payment = $order_model->getOrderCountByID('store', $this->store_info['store_id'], 'NewCount'); // 待发货 $no_delivery = $order_model->getOrderCountByID('store', $this->store_info['store_id'], 'PayCount'); $refundreturn_model = model('refundreturn'); // 售前退款 $condition = array(); $condition[] = array('store_id', '=', $this->store_info['store_id']); $condition[] = array('refund_type', '=', 1); $condition[] = array('order_lock', '=', 2); $condition[] = array('refund_state', '<', 3); $refund_lock = $refundreturn_model->getRefundreturnCount($condition); // 售后退款 $condition = array(); $condition[] = array('store_id', '=', $this->store_info['store_id']); $condition[] = array('refund_type', '=', 1); $condition[] = array('order_lock', '=', 1); $condition[] = array('refund_state', '<', 3); $refund = $refundreturn_model->getRefundreturnCount($condition); // 售前退货 $condition = array(); $condition[] = array('store_id', '=', $this->store_info['store_id']); $condition[] = array('refund_type', '=', 2); $condition[] = array('order_lock', '=', 2); $condition[] = array('refund_state', '<', 3); $return_lock = $refundreturn_model->getRefundreturnCount($condition); // 售后退货 $condition = array(); $condition[] = array('store_id', '=', $this->store_info['store_id']); $condition[] = array('refund_type', '=', 2); $condition[] = array('order_lock', '=', 1); $condition[] = array('refund_state', '<', 3); $return = $refundreturn_model->getRefundreturnCount($condition); $condition = array(); $condition[] = array('accused_id', '=', $this->store_info['store_id']); $condition[] = array('complain_state', 'between', array(10, 90)); $complain_model = model('complain'); $complain = $complain_model->getComplainCount($condition); //待确认的结算账单 $bill_model = model('bill'); $condition = array(); $condition[] = array('ob_store_id', '=', $this->store_info['store_id']); $condition[] = array('ob_state', '=', BILL_STATE_CREATE); $bill_confirm_count = $bill_model->getOrderbillCount($condition); //统计数组 $statistics = array( 'goodscount' => $goodscount, 'online' => $goods_online, 'waitverify' => $goods_waitverify, 'verifyfail' => $goods_verifyfail, 'offline' => $goods_offline, 'lockup' => $goods_lockup, 'imagecount' => $imagecount, 'consult' => $consult, 'progressing' => $progressing, 'payment' => $no_payment, 'delivery' => $no_delivery, 'refund_lock' => $refund_lock, 'refund' => $refund, 'return_lock' => $return_lock, 'return' => $return, 'complain' => $complain, 'bill_confirm' => $bill_confirm_count ); return $statistics; } }