seller_center.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <?php
  2. /**
  3. * 商户中心
  4. *
  5. * */
  6. defined('InShopNC') or exit('Access Invalid!');
  7. class seller_centerControl extends BaseSellerControl {
  8. /**
  9. * 构造方法
  10. *
  11. */
  12. public function __construct() {
  13. parent::__construct();
  14. }
  15. /**
  16. * 商户中心首页
  17. *
  18. */
  19. public function indexOp() {
  20. Language::read('member_home_index');
  21. // 店铺信息
  22. $store_info = $this->store_info;
  23. if(intval($store_info['store_end_time']) > 0) {
  24. $store_info['store_end_time_text'] = date('Y-m-d', $store_info['store_end_time']);
  25. $reopen_time = $store_info['store_end_time'] -3600*24 + 1 - TIMESTAMP;
  26. if (!checkPlatformStore() && $store_info['store_end_time'] - TIMESTAMP >= 0 && $reopen_time < 2592000) {
  27. //到期续签提醒(<30天)
  28. $store_info['reopen_tip'] = true;
  29. }
  30. } else {
  31. $store_info['store_end_time_text'] = L('store_no_limit');
  32. }
  33. // 店铺等级信息
  34. $store_info['grade_name'] = $this->store_grade['sg_name'];
  35. $store_info['grade_goodslimit'] = $this->store_grade['sg_goods_limit'];
  36. $store_info['grade_albumlimit'] = $this->store_grade['sg_album_limit'];
  37. Tpl::output('store_info',$store_info);
  38. // 商家帮助
  39. $model_help = Model('help');
  40. $condition = array();
  41. $condition['help_show'] = '1';//是否显示,0为否,1为是
  42. $help_list = $model_help->getStoreHelpTypeList($condition, '', 6);
  43. Tpl::output('help_list',$help_list);
  44. // 销售情况统计
  45. $field = ' COUNT(*) as ordernum,SUM(order_amount) as orderamount ';
  46. $where = array();
  47. $where['store_id'] = $_SESSION['store_id'];
  48. $where['order_isvalid'] = 1;//计入统计的有效订单
  49. // 昨日销量
  50. $where['order_add_time'] = array('between',array(strtotime(date('Y-m-d',(time()-3600*24))),strtotime(date('Y-m-d',time()))-1));
  51. $daily_sales = Model('stat')->getoneByStatorder($where, $field);
  52. Tpl::output('daily_sales', $daily_sales);
  53. // 月销量
  54. $where['order_add_time'] = array('gt',strtotime(date('Y-m',time())));
  55. $monthly_sales = Model('stat')->getoneByStatorder($where, $field);
  56. Tpl::output('monthly_sales', $monthly_sales);
  57. unset($field,$where);
  58. //单品销售排行
  59. //最近30天
  60. $stime = strtotime(date('Y-m-d',(time()-3600*24))) - (86400*29);//30天前
  61. $etime = strtotime(date('Y-m-d',time())) - 1;//昨天23:59
  62. $where = array();
  63. $where['store_id'] = $_SESSION['store_id'];
  64. $where['order_isvalid'] = 1;//计入统计的有效订单
  65. $where['order_add_time'] = array('between',array($stime,$etime));
  66. $field = ' goods_id,goods_name,SUM(goods_num) as goodsnum,goods_image ';
  67. $orderby = 'goodsnum desc,goods_id';
  68. $goods_list = Model('stat')->statByStatordergoods($where, $field, 0, 8, $orderby, 'goods_id');
  69. unset($stime,$etime,$where,$field,$orderby);
  70. Tpl::output('goods_list', $goods_list);
  71. if (!checkPlatformStore()) {
  72. if (C('groupbuy_allow') == 1){
  73. // 抢购套餐
  74. $groupquota_info = Model('groupbuy_quota')->getGroupbuyQuotaCurrent($_SESSION['store_id']);
  75. Tpl::output('groupquota_info', $groupquota_info);
  76. }
  77. if (intval(C('promotion_allow')) == 1){
  78. // 限时折扣套餐
  79. $xianshiquota_info = Model('p_xianshi_quota')->getXianshiQuotaCurrent($_SESSION['store_id']);
  80. Tpl::output('xianshiquota_info', $xianshiquota_info);
  81. // 满即送套餐
  82. $mansongquota_info = Model('p_mansong_quota')->getMansongQuotaCurrent($_SESSION['store_id']);
  83. Tpl::output('mansongquota_info', $mansongquota_info);
  84. // 优惠套装套餐
  85. $binglingquota_info = Model('p_bundling')->getBundlingQuotaInfoCurrent($_SESSION['store_id']);
  86. Tpl::output('binglingquota_info', $binglingquota_info);
  87. // 推荐展位套餐
  88. $boothquota_info = Model('p_booth')->getBoothQuotaInfoCurrent($_SESSION['store_id']);
  89. Tpl::output('boothquota_info', $boothquota_info);
  90. }
  91. if (C('voucher_allow') == 1){
  92. $voucherquota_info = Model('voucher')->getCurrentQuota($_SESSION['store_id']);
  93. Tpl::output('voucherquota_info', $voucherquota_info);
  94. }
  95. } else {
  96. Tpl::output('isOwnShop', true);
  97. }
  98. $phone_array = explode(',',C('site_phone'));
  99. Tpl::output('phone_array',$phone_array);
  100. Tpl::output('menu_sign','index');
  101. Tpl::showpage('index');
  102. }
  103. /**
  104. * 异步取得卖家统计类信息
  105. *
  106. */
  107. public function statisticsOp() {
  108. $add_time_to = strtotime(date("Y-m-d")+60*60*24); //当前日期 ,从零点来时
  109. $add_time_from = strtotime(date("Y-m-d",(strtotime(date("Y-m-d"))-60*60*24*30))); //30天前
  110. $goods_online = 0; // 出售中商品
  111. $goods_waitverify = 0; // 等待审核
  112. $goods_verifyfail = 0; // 审核失败
  113. $goods_offline = 0; // 仓库待上架商品
  114. $goods_lockup = 0; // 违规下架商品
  115. $consult = 0; // 待回复商品咨询
  116. $no_payment = 0; // 待付款
  117. $no_delivery = 0; // 待发货
  118. $no_receipt = 0; // 待收货
  119. $refund_lock = 0; // 售前退款
  120. $refund = 0; // 售后退款
  121. $return_lock = 0; // 售前退货
  122. $return = 0; // 售后退货
  123. $complain = 0; //进行中投诉
  124. $model_goods = Model('goods');
  125. // 全部商品数
  126. $goodscount = $model_goods->getGoodsCommonCount(array('store_id' => $_SESSION['store_id']));
  127. // 出售中的商品
  128. $goods_online = $model_goods->getGoodsCommonOnlineCount(array('store_id' => $_SESSION['store_id']));
  129. if (C('goods_verify')) {
  130. // 等待审核的商品
  131. $goods_waitverify = $model_goods->getGoodsCommonWaitVerifyCount(array('store_id' => $_SESSION['store_id']));
  132. // 审核失败的商品
  133. $goods_verifyfail = $model_goods->getGoodsCommonVerifyFailCount(array('store_id' => $_SESSION['store_id']));
  134. }
  135. // 仓库待上架的商品
  136. $goods_offline = $model_goods->getGoodsCommonOfflineCount(array('store_id' => $_SESSION['store_id']));
  137. // 违规下架的商品
  138. $goods_lockup = $model_goods->getGoodsCommonLockUpCount(array('store_id' => $_SESSION['store_id']));
  139. // 等待回复商品咨询
  140. $consult = Model('consult')->getConsultCount(array('store_id' => $_SESSION['store_id'], 'consult_reply' => ''));
  141. // 商品图片数量
  142. $imagecount = Model('album')->getAlbumPicCount(array('store_id' => $_SESSION['store_id']));
  143. $model_order = Model('order');
  144. // 交易中的订单
  145. $progressing = $model_order->getOrderCountByID('store',$_SESSION['store_id'],'TradeCount');
  146. // 待付款
  147. $no_payment = $model_order->getOrderCountByID('store',$_SESSION['store_id'],'NewCount');
  148. // 待发货
  149. $no_delivery = $model_order->getOrderCountByID('store',$_SESSION['store_id'],'PayCount');
  150. $model_refund_return = Model('refund_return');
  151. // 售前退款
  152. $condition = array();
  153. $condition['store_id'] = $_SESSION['store_id'];
  154. $condition['refund_type'] = 1;
  155. $condition['order_lock'] = 2;
  156. $condition['refund_state'] = array('lt', 3);
  157. $refund_lock = $model_refund_return->getRefundReturnCount($condition);
  158. // 售后退款
  159. $condition = array();
  160. $condition['store_id'] = $_SESSION['store_id'];
  161. $condition['refund_type'] = 1;
  162. $condition['order_lock'] = 1;
  163. $condition['refund_state'] = array('lt', 3);
  164. $refund = $model_refund_return->getRefundReturnCount($condition);
  165. // 售前退货
  166. $condition = array();
  167. $condition['store_id'] = $_SESSION['store_id'];
  168. $condition['refund_type'] = 2;
  169. $condition['order_lock'] = 2;
  170. $condition['refund_state'] = array('lt', 3);
  171. $return_lock = $model_refund_return->getRefundReturnCount($condition);
  172. // 售后退货
  173. $condition = array();
  174. $condition['store_id'] = $_SESSION['store_id'];
  175. $condition['refund_type'] = 2;
  176. $condition['order_lock'] = 1;
  177. $condition['refund_state'] = array('lt', 3);
  178. $return = $model_refund_return->getRefundReturnCount($condition);
  179. $condition = array();
  180. $condition['accused_id'] = $_SESSION['store_id'];
  181. $condition['complain_state'] = array(array('gt',10),array('lt',90),'and');
  182. $complain = Model()->table('complain')->where($condition)->count();
  183. //待确认的结算账单
  184. $model_bill = Model('bill');
  185. $condition = array();
  186. $condition['ob_store_id'] = $_SESSION['store_id'];
  187. $condition['ob_state'] = BILL_STATE_CREATE;
  188. $bill_confirm_count = $model_bill->getOrderBillCount($condition);
  189. //统计数组
  190. $statistics = array(
  191. 'goodscount' => $goodscount,
  192. 'online' => $goods_online,
  193. 'waitverify' => $goods_waitverify,
  194. 'verifyfail' => $goods_verifyfail,
  195. 'offline' => $goods_offline,
  196. 'lockup' => $goods_lockup,
  197. 'imagecount' => $imagecount,
  198. 'consult' => $consult,
  199. 'progressing' => $progressing,
  200. 'payment' => $no_payment,
  201. 'delivery' => $no_delivery,
  202. 'refund_lock' => $refund_lock,
  203. 'refund' => $refund,
  204. 'return_lock' => $return_lock,
  205. 'return' => $return,
  206. 'complain' => $complain,
  207. 'bill_confirm' => $bill_confirm_count
  208. );
  209. exit(json_encode($statistics));
  210. }
  211. /**
  212. * 添加快捷操作
  213. */
  214. function quicklink_addOp() {
  215. if(!empty($_POST['item'])) {
  216. $_SESSION['seller_quicklink'][$_POST['item']] = $_POST['item'];
  217. }
  218. $this->_update_quicklink();
  219. echo 'true';
  220. }
  221. /**
  222. * 删除快捷操作
  223. */
  224. function quicklink_delOp() {
  225. if(!empty($_POST['item'])) {
  226. unset($_SESSION['seller_quicklink'][$_POST['item']]);
  227. }
  228. $this->_update_quicklink();
  229. echo 'true';
  230. }
  231. private function _update_quicklink() {
  232. $quicklink = implode(',', $_SESSION['seller_quicklink']);
  233. $update_array = array('seller_quicklink' => $quicklink);
  234. $condition = array('seller_id' => $_SESSION['seller_id']);
  235. $model_seller = Model('seller');
  236. $model_seller->editSeller($update_array, $condition);
  237. }
  238. }