Seller.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <?php
  2. namespace app\home\controller;
  3. use think\facade\View;
  4. use think\facade\Lang;
  5. /**
  6. *
  7. *
  8. * ----------------------------------------------------------------------------
  9. *
  10. * 控制器
  11. */
  12. class Seller extends BaseSeller
  13. {
  14. public function initialize()
  15. {
  16. parent::initialize();
  17. Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/seller.lang.php');
  18. }
  19. /**
  20. * 商户中心首页
  21. *
  22. */
  23. public function index()
  24. {
  25. // 店铺信息
  26. $store_info = $this->store_info;
  27. $store_info['reopen_tip'] = FALSE;
  28. if (intval($store_info['store_endtime']) > 0) {
  29. $store_info['store_endtime_text'] = date('Y-m-d', $store_info['store_endtime']);
  30. $reopen_time = $store_info['store_endtime'] - 3600 * 24 + 1 - TIMESTAMP;
  31. if (!session('is_platform_store') && $store_info['store_endtime'] - TIMESTAMP >= 0 && $reopen_time < 2592000) {
  32. //到期续签提醒(<30天)
  33. $store_info['reopen_tip'] = true;
  34. }
  35. } else {
  36. $store_info['store_endtime_text'] = lang('store_no_limit');
  37. }
  38. // 店铺等级信息
  39. $store_info['grade_name'] = $this->store_grade['storegrade_name'];
  40. $store_info['grade_goodslimit'] = $this->store_grade['storegrade_goods_limit'];
  41. $store_info['grade_albumlimit'] = $this->store_grade['storegrade_album_limit'];
  42. View::assign('store_info', $store_info);
  43. // 商家帮助
  44. $help_model = model('help');
  45. $condition = array();
  46. $condition[] = array('helptype_show', '=', '1'); //是否显示,0为否,1为是
  47. $help_list = $help_model->getStoreHelptypeList($condition, '', 6);
  48. View::assign('help_list', $help_list);
  49. // 销售情况统计
  50. $field = ' COUNT(*) as ordernum,SUM(order_amount) as orderamount ';
  51. $where = array();
  52. $where[] = array('store_id', '=', session('store_id'));
  53. $where[] = array('order_isvalid', '=', 1); //计入统计的有效订单
  54. // 昨日销量
  55. $where[] = array('order_add_time', 'between', array(strtotime(date('Y-m-d', (TIMESTAMP - 3600 * 24))), strtotime(date('Y-m-d', TIMESTAMP)) - 1));
  56. $daily_sales = model('stat')->getoneByStatorder($where, $field);
  57. View::assign('daily_sales', $daily_sales);
  58. $where = array();
  59. $where[] = array('store_id', '=', session('store_id'));
  60. $where[] = array('order_isvalid', '=', 1); //计入统计的有效订单
  61. // 月销量
  62. $where[] = array('order_add_time', '>', strtotime(date('Y-m', TIMESTAMP)));
  63. $monthly_sales = model('stat')->getoneByStatorder($where, $field);
  64. View::assign('monthly_sales', $monthly_sales);
  65. unset($field, $where);
  66. //单品销售排行
  67. //最近30天
  68. $stime = strtotime(date('Y-m-d', (TIMESTAMP - 3600 * 24))) - (86400 * 29); //30天前
  69. $etime = strtotime(date('Y-m-d', TIMESTAMP)) - 1; //昨天23:59
  70. $where = array();
  71. $where[] = array('store_id', '=', session('store_id'));
  72. $where[] = array('order_isvalid', '=', 1); //计入统计的有效订单
  73. $where[] = array('order_add_time', 'between', array($stime, $etime));
  74. $field = ' goods_id,goods_name,SUM(goods_num) as goodsnum,goods_image ';
  75. $orderby = 'goodsnum desc,goods_id';
  76. $goods_list = model('stat')->statByStatordergoods($where, $field, 0, 8, $orderby, 'goods_id');
  77. unset($stime, $etime, $where, $field, $orderby);
  78. View::assign('goods_list', $goods_list);
  79. if (!session('is_platform_store')) {
  80. if (config('ds_config.groupbuy_allow') == 1) {
  81. // 抢购套餐
  82. $groupquota_info = model('groupbuyquota')->getGroupbuyquotaCurrent(session('store_id'));
  83. View::assign('groupquota_info', $groupquota_info);
  84. }
  85. if (intval(config('ds_config.promotion_allow')) == 1) {
  86. // 秒杀套餐
  87. $xianshiquota_info = model('pxianshiquota')->getXianshiquotaCurrent(session('store_id'));
  88. View::assign('xianshiquota_info', $xianshiquota_info);
  89. // 满即送套餐
  90. $mansongquota_info = model('pmansongquota')->getMansongquotaCurrent(session('store_id'));
  91. View::assign('mansongquota_info', $mansongquota_info);
  92. // 优惠套装套餐
  93. $binglingquota_info = model('pbundling')->getBundlingQuotaInfoCurrent(session('store_id'));
  94. View::assign('binglingquota_info', $binglingquota_info);
  95. // 推荐展位套餐
  96. $boothquota_info = model('pbooth')->getBoothquotaInfoCurrent(session('store_id'));
  97. View::assign('boothquota_info', $boothquota_info);
  98. }
  99. if (config('ds_config.voucher_allow') == 1) {
  100. $voucherquota_info = model('voucher')->getVoucherquotaCurrent(session('store_id'));
  101. View::assign('voucherquota_info', $voucherquota_info);
  102. }
  103. } else {
  104. View::assign('isPlatformStore', true);
  105. }
  106. $phone_array = explode(',', config('ds_config.site_phone'));
  107. View::assign('phone_array', $phone_array);
  108. View::assign('menu_sign', 'index');
  109. /* 设置卖家当前菜单 */
  110. $this->setSellerCurMenu('seller_index');
  111. /* 设置卖家当前栏目 */
  112. $this->setSellerCurItem();
  113. return View::fetch($this->template_dir . 'index');
  114. }
  115. /**
  116. * 异步取得卖家统计类信息
  117. *
  118. */
  119. public function statistics()
  120. {
  121. // $add_time_to = strtotime(date("Y-m-d") + 60 * 60 * 24); //当前日期 ,从零点来时
  122. // $add_time_from = strtotime(date("Y-m-d", (strtotime(date("Y-m-d")) - 60 * 60 * 24 * 30))); //30天前
  123. $goods_online = 0; // 出售中商品
  124. $goods_waitverify = 0; // 等待审核
  125. $goods_verifyfail = 0; // 审核失败
  126. $goods_offline = 0; // 仓库待上架商品
  127. $goods_lockup = 0; // 违规下架商品
  128. $consult = 0; // 待回复商品咨询
  129. $no_payment = 0; // 待付款
  130. $no_delivery = 0; // 待发货
  131. $no_receipt = 0; // 待收货
  132. $refund_lock = 0; // 售前退款
  133. $refund = 0; // 售后退款
  134. $return_lock = 0; // 售前退货
  135. $return = 0; // 售后退货
  136. $complain = 0; //进行中投诉
  137. $goods_model = model('goods');
  138. // 全部商品数
  139. $goodscount = $goods_model->getGoodsCommonCount(array('store_id' => session('store_id')));
  140. // 出售中的商品
  141. $goods_online = $goods_model->getGoodsCommonOnlineCount(array(array('store_id', '=', session('store_id'))));
  142. if (config('ds_config.goods_verify')) {
  143. // 等待审核的商品
  144. $goods_waitverify = $goods_model->getGoodsCommonWaitVerifyCount(array(array('store_id', '=', session('store_id'))));
  145. // 审核失败的商品
  146. $goods_verifyfail = $goods_model->getGoodsCommonVerifyFailCount(array(array('store_id', '=', session('store_id'))));
  147. }
  148. // 仓库待上架的商品
  149. $goods_offline = $goods_model->getGoodsCommonOfflineCount(array(array('store_id', '=', session('store_id'))));
  150. // 违规下架的商品
  151. $goods_lockup = $goods_model->getGoodsCommonLockUpCount(array(array('store_id', '=', session('store_id'))));
  152. // 等待回复商品咨询
  153. $consult = model('consult')->getConsultCount(array('store_id' => session('store_id'), 'consult_reply' => ''));
  154. // 商品图片数量
  155. $imagecount = model('album')->getAlbumpicCount(array('store_id' => session('store_id')));
  156. $order_model = model('order');
  157. // 交易中的订单
  158. $progressing = $order_model->getOrderCountByID('store', session('store_id'), 'TradeCount');
  159. // 待付款
  160. $no_payment = $order_model->getOrderCountByID('store', session('store_id'), 'NewCount');
  161. // 待发货
  162. $no_delivery = $order_model->getOrderCountByID('store', session('store_id'), 'PayCount');
  163. $refundreturn_model = model('refundreturn');
  164. // 售前退款
  165. $condition = array();
  166. $condition[] = array('store_id', '=', session('store_id'));
  167. $condition[] = array('refund_type', '=', 1);
  168. $condition[] = array('order_lock', '=', 2);
  169. $condition[] = array('refund_state', '<', 3);
  170. $refund_lock = $refundreturn_model->getRefundreturnCount($condition);
  171. // 售后退款
  172. $condition = array();
  173. $condition[] = array('store_id', '=', session('store_id'));
  174. $condition[] = array('refund_type', '=', 1);
  175. $condition[] = array('order_lock', '=', 1);
  176. $condition[] = array('refund_state', '<', 3);
  177. $refund = $refundreturn_model->getRefundreturnCount($condition);
  178. // 售前退货
  179. $condition = array();
  180. $condition[] = array('store_id', '=', session('store_id'));
  181. $condition[] = array('refund_type', '=', 2);
  182. $condition[] = array('order_lock', '=', 2);
  183. $condition[] = array('refund_state', '<', 3);
  184. $return_lock = $refundreturn_model->getRefundreturnCount($condition);
  185. // 售后退货
  186. $condition = array();
  187. $condition[] = array('store_id', '=', session('store_id'));
  188. $condition[] = array('refund_type', '=', 2);
  189. $condition[] = array('order_lock', '=', 1);
  190. $condition[] = array('refund_state', '<', 3);
  191. $return = $refundreturn_model->getRefundreturnCount($condition);
  192. $condition = array();
  193. $condition[] = array('accused_id', '=', session('store_id'));
  194. $condition[] = array('complain_state', 'between', array(10, 90));
  195. $complain_mod = model('complain');
  196. $complain = $complain_mod->getComplainCount($condition);
  197. //待确认的结算账单
  198. $bill_model = model('bill');
  199. $condition = array();
  200. $condition[] = array('ob_store_id', '=', session('store_id'));
  201. $condition[] = array('ob_state', '=', BILL_STATE_CREATE);
  202. $bill_confirm_count = $bill_model->getOrderbillCount($condition);
  203. //统计数组
  204. $statistics = array(
  205. 'goodscount' => $goodscount,
  206. 'online' => $goods_online,
  207. 'waitverify' => $goods_waitverify,
  208. 'verifyfail' => $goods_verifyfail,
  209. 'offline' => $goods_offline,
  210. 'lockup' => $goods_lockup,
  211. 'imagecount' => $imagecount,
  212. 'consult' => $consult,
  213. 'progressing' => $progressing,
  214. 'payment' => $no_payment,
  215. 'delivery' => $no_delivery,
  216. 'refund_lock' => $refund_lock,
  217. 'refund' => $refund,
  218. 'return_lock' => $return_lock,
  219. 'return' => $return,
  220. 'complain' => $complain,
  221. 'bill_confirm' => $bill_confirm_count
  222. );
  223. exit(json_encode($statistics));
  224. }
  225. }