Seller.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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. * ============================================================================
  13. * 控制器
  14. */
  15. class Seller extends BaseSeller {
  16. public function initialize() {
  17. parent::initialize();
  18. Lang::load(base_path() . 'home/lang/'.config('lang.default_lang').'/seller.lang.php');
  19. }
  20. /**
  21. * 商户中心首页
  22. *
  23. */
  24. public function index() {
  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. // $add_time_to = strtotime(date("Y-m-d") + 60 * 60 * 24); //当前日期 ,从零点来时
  121. // $add_time_from = strtotime(date("Y-m-d", (strtotime(date("Y-m-d")) - 60 * 60 * 24 * 30))); //30天前
  122. $goods_online = 0; // 出售中商品
  123. $goods_waitverify = 0; // 等待审核
  124. $goods_verifyfail = 0; // 审核失败
  125. $goods_offline = 0; // 仓库待上架商品
  126. $goods_lockup = 0; // 违规下架商品
  127. $consult = 0; // 待回复商品咨询
  128. $no_payment = 0; // 待付款
  129. $no_delivery = 0; // 待发货
  130. $no_receipt = 0; // 待收货
  131. $refund_lock = 0; // 售前退款
  132. $refund = 0; // 售后退款
  133. $return_lock = 0; // 售前退货
  134. $return = 0; // 售后退货
  135. $complain = 0; //进行中投诉
  136. $goods_model = model('goods');
  137. // 全部商品数
  138. $goodscount = $goods_model->getGoodsCommonCount(array('store_id' => session('store_id')));
  139. // 出售中的商品
  140. $goods_online = $goods_model->getGoodsCommonOnlineCount(array(array('store_id' ,'=', session('store_id'))));
  141. if (config('ds_config.goods_verify')) {
  142. // 等待审核的商品
  143. $goods_waitverify = $goods_model->getGoodsCommonWaitVerifyCount(array(array('store_id' ,'=', session('store_id'))));
  144. // 审核失败的商品
  145. $goods_verifyfail = $goods_model->getGoodsCommonVerifyFailCount(array(array('store_id' ,'=', session('store_id'))));
  146. }
  147. // 仓库待上架的商品
  148. $goods_offline = $goods_model->getGoodsCommonOfflineCount(array(array('store_id' ,'=', session('store_id'))));
  149. // 违规下架的商品
  150. $goods_lockup = $goods_model->getGoodsCommonLockUpCount(array(array('store_id' ,'=', session('store_id'))));
  151. // 等待回复商品咨询
  152. $consult = model('consult')->getConsultCount(array('store_id' => session('store_id'), 'consult_reply' => ''));
  153. // 商品图片数量
  154. $imagecount = model('album')->getAlbumpicCount(array('store_id' => session('store_id')));
  155. $order_model = model('order');
  156. // 交易中的订单
  157. $progressing = $order_model->getOrderCountByID('store', session('store_id'), 'TradeCount');
  158. // 待付款
  159. $no_payment = $order_model->getOrderCountByID('store', session('store_id'), 'NewCount');
  160. // 待发货
  161. $no_delivery = $order_model->getOrderCountByID('store', session('store_id'), 'PayCount');
  162. $refundreturn_model = model('refundreturn');
  163. // 售前退款
  164. $condition = array();
  165. $condition[]=array('store_id','=',session('store_id'));
  166. $condition[]=array('refund_type','=',1);
  167. $condition[]=array('order_lock','=',2);
  168. $condition[]=array('refund_state','<', 3);
  169. $refund_lock = $refundreturn_model->getRefundreturnCount($condition);
  170. // 售后退款
  171. $condition = array();
  172. $condition[]=array('store_id','=',session('store_id'));
  173. $condition[]=array('refund_type','=',1);
  174. $condition[]=array('order_lock','=',1);
  175. $condition[]=array('refund_state','<', 3);
  176. $refund = $refundreturn_model->getRefundreturnCount($condition);
  177. // 售前退货
  178. $condition = array();
  179. $condition[]=array('store_id','=',session('store_id'));
  180. $condition[]=array('refund_type','=',2);
  181. $condition[]=array('order_lock','=',2);
  182. $condition[]=array('refund_state','<', 3);
  183. $return_lock = $refundreturn_model->getRefundreturnCount($condition);
  184. // 售后退货
  185. $condition = array();
  186. $condition[]=array('store_id','=',session('store_id'));
  187. $condition[]=array('refund_type','=',2);
  188. $condition[]=array('order_lock','=',1);
  189. $condition[]=array('refund_state','<', 3);
  190. $return = $refundreturn_model->getRefundreturnCount($condition);
  191. $condition = array();
  192. $condition[]=array('accused_id','=',session('store_id'));
  193. $condition[] = array('complain_state','between', array(10, 90));
  194. $complain_mod=model('complain');
  195. $complain = $complain_mod->getComplainCount($condition);
  196. //待确认的结算账单
  197. $bill_model = model('bill');
  198. $condition = array();
  199. $condition[] = array('ob_store_id','=',session('store_id'));
  200. $condition[] = array('ob_state','=',BILL_STATE_CREATE);
  201. $bill_confirm_count = $bill_model->getOrderbillCount($condition);
  202. //统计数组
  203. $statistics = array(
  204. 'goodscount' => $goodscount,
  205. 'online' => $goods_online,
  206. 'waitverify' => $goods_waitverify,
  207. 'verifyfail' => $goods_verifyfail,
  208. 'offline' => $goods_offline,
  209. 'lockup' => $goods_lockup,
  210. 'imagecount' => $imagecount,
  211. 'consult' => $consult,
  212. 'progressing' => $progressing,
  213. 'payment' => $no_payment,
  214. 'delivery' => $no_delivery,
  215. 'refund_lock' => $refund_lock,
  216. 'refund' => $refund,
  217. 'return_lock' => $return_lock,
  218. 'return' => $return,
  219. 'complain' => $complain,
  220. 'bill_confirm' => $bill_confirm_count
  221. );
  222. exit(json_encode($statistics));
  223. }
  224. }