Seller.php 12 KB

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