Seller.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. <?php
  2. namespace app\home\controller;
  3. use think\facade\View;
  4. use think\facade\Lang;
  5. /**
  6. * ============================================================================
  7. *
  8. * ============================================================================
  9. * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司,并保留所有权利。
  10. * 网站地址: https://www.valimart.net/
  11. * ----------------------------------------------------------------------------
  12. *
  13. * ============================================================================
  14. * 控制器
  15. */
  16. class Seller extends BaseSeller {
  17. public function initialize() {
  18. parent::initialize();
  19. Lang::load(base_path() . 'home/lang/'.config('lang.default_lang').'/seller.lang.php');
  20. }
  21. /**
  22. * 商户中心首页
  23. *
  24. */
  25. public function index() {
  26. // 店铺信息
  27. $store_info = $this->store_info;
  28. $store_info['reopen_tip'] = FALSE;
  29. if (intval($store_info['store_endtime']) > 0) {
  30. $store_info['store_endtime_text'] = date('Y-m-d', $store_info['store_endtime']);
  31. $reopen_time = $store_info['store_endtime'] - 3600 * 24 + 1 - TIMESTAMP;
  32. if (!session('is_platform_store') && $store_info['store_endtime'] - TIMESTAMP >= 0 && $reopen_time < 2592000) {
  33. //到期续签提醒(<30天)
  34. $store_info['reopen_tip'] = true;
  35. }
  36. } else {
  37. $store_info['store_endtime_text'] = lang('store_no_limit');
  38. }
  39. // 店铺等级信息
  40. $store_info['grade_name'] = $this->store_grade['storegrade_name'];
  41. $store_info['grade_goodslimit'] = $this->store_grade['storegrade_goods_limit'];
  42. $store_info['grade_albumlimit'] = $this->store_grade['storegrade_album_limit'];
  43. View::assign('store_info', $store_info);
  44. // 商家帮助
  45. $help_model = model('help');
  46. $condition = array();
  47. $condition[]=array('helptype_show','=','1'); //是否显示,0为否,1为是
  48. $help_list = $help_model->getStoreHelptypeList($condition, '', 6);
  49. View::assign('help_list', $help_list);
  50. // 销售情况统计
  51. $field = ' COUNT(*) as ordernum,SUM(order_amount) as orderamount ';
  52. $where = array();
  53. $where[]=array('store_id','=',session('store_id'));
  54. $where[]=array('order_isvalid','=',1); //计入统计的有效订单
  55. // 昨日销量
  56. $where[] = array('order_add_time','between', array(strtotime(date('Y-m-d', (TIMESTAMP - 3600 * 24))), strtotime(date('Y-m-d', TIMESTAMP)) - 1));
  57. $daily_sales = model('stat')->getoneByStatorder($where, $field);
  58. View::assign('daily_sales', $daily_sales);
  59. $where = array();
  60. $where[]=array('store_id','=',session('store_id'));
  61. $where[]=array('order_isvalid','=',1); //计入统计的有效订单
  62. // 月销量
  63. $where[] = array('order_add_time','>', strtotime(date('Y-m', TIMESTAMP)));
  64. $monthly_sales = model('stat')->getoneByStatorder($where, $field);
  65. View::assign('monthly_sales', $monthly_sales);
  66. unset($field, $where);
  67. //单品销售排行
  68. //最近30天
  69. $stime = strtotime(date('Y-m-d', (TIMESTAMP - 3600 * 24))) - (86400 * 29); //30天前
  70. $etime = strtotime(date('Y-m-d', TIMESTAMP)) - 1; //昨天23:59
  71. $where = array();
  72. $where[]=array('store_id','=',session('store_id'));
  73. $where[]=array('order_isvalid','=',1); //计入统计的有效订单
  74. $where[] = array('order_add_time','between', array($stime, $etime));
  75. $field = ' goods_id,goods_name,SUM(goods_num) as goodsnum,goods_image ';
  76. $orderby = 'goodsnum desc,goods_id';
  77. $goods_list = model('stat')->statByStatordergoods($where, $field, 0, 8, $orderby, 'goods_id');
  78. unset($stime, $etime, $where, $field, $orderby);
  79. View::assign('goods_list', $goods_list);
  80. if (!session('is_platform_store')) {
  81. if (config('ds_config.groupbuy_allow') == 1) {
  82. // 抢购套餐
  83. $groupquota_info = model('groupbuyquota')->getGroupbuyquotaCurrent(session('store_id'));
  84. View::assign('groupquota_info', $groupquota_info);
  85. }
  86. if (intval(config('ds_config.promotion_allow')) == 1) {
  87. // 秒杀套餐
  88. $xianshiquota_info = model('pxianshiquota')->getXianshiquotaCurrent(session('store_id'));
  89. View::assign('xianshiquota_info', $xianshiquota_info);
  90. // 满即送套餐
  91. $mansongquota_info = model('pmansongquota')->getMansongquotaCurrent(session('store_id'));
  92. View::assign('mansongquota_info', $mansongquota_info);
  93. // 优惠套装套餐
  94. $binglingquota_info = model('pbundling')->getBundlingQuotaInfoCurrent(session('store_id'));
  95. View::assign('binglingquota_info', $binglingquota_info);
  96. // 推荐展位套餐
  97. $boothquota_info = model('pbooth')->getBoothquotaInfoCurrent(session('store_id'));
  98. View::assign('boothquota_info', $boothquota_info);
  99. }
  100. if (config('ds_config.voucher_allow') == 1) {
  101. $voucherquota_info = model('voucher')->getVoucherquotaCurrent(session('store_id'));
  102. View::assign('voucherquota_info', $voucherquota_info);
  103. }
  104. } else {
  105. View::assign('isPlatformStore', true);
  106. }
  107. $phone_array = explode(',', config('ds_config.site_phone'));
  108. View::assign('phone_array', $phone_array);
  109. View::assign('menu_sign', 'index');
  110. /* 设置卖家当前菜单 */
  111. $this->setSellerCurMenu('seller_index');
  112. /* 设置卖家当前栏目 */
  113. $this->setSellerCurItem();
  114. return View::fetch($this->template_dir.'index');
  115. }
  116. /**
  117. * 异步取得卖家统计类信息
  118. *
  119. */
  120. public function statistics() {
  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. }
  226. ?>