Seller.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  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. {
  19. public function initialize()
  20. {
  21. parent::initialize();
  22. Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/seller.lang.php');
  23. }
  24. /**
  25. * 商户中心首页
  26. *
  27. */
  28. public function index()
  29. {
  30. // 店铺信息
  31. $store_info = $this->store_info;
  32. $store_info['reopen_tip'] = FALSE;
  33. if (intval($store_info['store_endtime']) > 0) {
  34. $store_info['store_endtime_text'] = date('Y-m-d', $store_info['store_endtime']);
  35. $reopen_time = $store_info['store_endtime'] - 3600 * 24 + 1 - TIMESTAMP;
  36. if (!session('is_platform_store') && $store_info['store_endtime'] - TIMESTAMP >= 0 && $reopen_time < 2592000) {
  37. //到期续签提醒(<30天)
  38. $store_info['reopen_tip'] = true;
  39. }
  40. } else {
  41. $store_info['store_endtime_text'] = lang('store_no_limit');
  42. }
  43. // 店铺等级信息
  44. $store_info['grade_name'] = $this->store_grade['storegrade_name'];
  45. $store_info['grade_goodslimit'] = $this->store_grade['storegrade_goods_limit'];
  46. $store_info['grade_albumlimit'] = $this->store_grade['storegrade_album_limit'];
  47. View::assign('store_info', $store_info);
  48. // 商家帮助
  49. $help_model = model('help');
  50. $condition = [];
  51. $condition[] = ['helptype_show', '=', '1']; //是否显示,0为否,1为是
  52. $help_list = $help_model->getStoreHelptypeList($condition, '', 6);
  53. View::assign('help_list', $help_list);
  54. // 销售情况统计
  55. $field = ' COUNT(*) as ordernum,SUM(order_amount) as orderamount ';
  56. $where = [];
  57. $where[] = ['store_id', '=', session('store_id')];
  58. $where[] = ['order_isvalid', '=', 1]; //计入统计的有效订单
  59. // 昨日销量
  60. $where[] = ['order_add_time', 'between', [strtotime(date('Y-m-d', (TIMESTAMP - 3600 * 24))), strtotime(date('Y-m-d', TIMESTAMP)) - 1]];
  61. $daily_sales = model('stat')->getoneByStatorder($where, $field);
  62. View::assign('daily_sales', $daily_sales);
  63. // 月销量
  64. $where[] = ['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 = [];
  73. $where[] = ['store_id', '=', session('store_id')];
  74. $where[] = ['order_isvalid', '=', 1]; //计入统计的有效订单
  75. $where[] = ['order_add_time', 'between', [$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. {
  123. // $add_time_to = strtotime(date("Y-m-d") + 60 * 60 * 24); //当前日期 ,从零点来时
  124. // $add_time_from = strtotime(date("Y-m-d", (strtotime(date("Y-m-d")) - 60 * 60 * 24 * 30))); //30天前
  125. $goods_online = 0; // 出售中商品
  126. $goods_waitverify = 0; // 等待审核
  127. $goods_verifyfail = 0; // 审核失败
  128. $goods_offline = 0; // 仓库待上架商品
  129. $goods_lockup = 0; // 违规下架商品
  130. $consult = 0; // 待回复商品咨询
  131. $no_payment = 0; // 待付款
  132. $no_delivery = 0; // 待发货
  133. $no_receipt = 0; // 待收货
  134. $refund_lock = 0; // 售前退款
  135. $refund = 0; // 售后退款
  136. $return_lock = 0; // 售前退货
  137. $return = 0; // 售后退货
  138. $complain = 0; //进行中投诉
  139. $goods_model = model('goods');
  140. // 全部商品数
  141. $goodscount = $goods_model->getGoodsCommonCount(['store_id' => session('store_id')]);
  142. // 出售中的商品
  143. $goods_online = $goods_model->getGoodsCommonOnlineCount([['store_id', '=', session('store_id')]]);
  144. if (config('ds_config.goods_verify')) {
  145. // 等待审核的商品
  146. $goods_waitverify = $goods_model->getGoodsCommonWaitVerifyCount([['store_id', '=', session('store_id')]]);
  147. // 审核失败的商品
  148. $goods_verifyfail = $goods_model->getGoodsCommonVerifyFailCount([['store_id', '=', session('store_id')]]);
  149. }
  150. // 仓库待上架的商品
  151. $goods_offline = $goods_model->getGoodsCommonOfflineCount([['store_id', '=', session('store_id')]]);
  152. // 违规下架的商品
  153. $goods_lockup = $goods_model->getGoodsCommonLockUpCount([['store_id', '=', session('store_id')]]);
  154. // 等待回复商品咨询
  155. $consult = model('consult')->getConsultCount(['store_id' => session('store_id'), 'consult_reply' => '']);
  156. // 商品图片数量
  157. $imagecount = model('album')->getAlbumpicCount(['store_id' => session('store_id')]);
  158. $order_model = model('order');
  159. // 交易中的订单
  160. $progressing = $order_model->getOrderCountByID('store', session('store_id'), 'TradeCount');
  161. // 待付款
  162. $no_payment = $order_model->getOrderCountByID('store', session('store_id'), 'NewCount');
  163. // 待发货
  164. $no_delivery = $order_model->getOrderCountByID('store', session('store_id'), 'PayCount');
  165. $refundreturn_model = model('refundreturn');
  166. // 售前退款
  167. $condition = [];
  168. $condition[] = ['store_id', '=', session('store_id')];
  169. $condition[] = ['refund_type', '=', 1];
  170. $condition[] = ['order_lock', '=', 2];
  171. $condition[] = ['refund_state', '<', 3];
  172. $refund_lock = $refundreturn_model->getRefundreturnCount($condition);
  173. // 售后退款
  174. $condition = [];
  175. $condition[] = ['store_id', '=', session('store_id')];
  176. $condition[] = ['refund_type', '=', 1];
  177. $condition[] = ['order_lock', '=', 1];
  178. $condition[] = ['refund_state', '<', 3];
  179. $refund = $refundreturn_model->getRefundreturnCount($condition);
  180. // 售前退货
  181. $condition = [];
  182. $condition[] = ['store_id', '=', session('store_id')];
  183. $condition[] = ['refund_type', '=', 2];
  184. $condition[] = ['order_lock', '=', 2];
  185. $condition[] = ['refund_state', '<', 3];
  186. $return_lock = $refundreturn_model->getRefundreturnCount($condition);
  187. // 售后退货
  188. $condition = [];
  189. $condition[] = ['store_id', '=', session('store_id')];
  190. $condition[] = ['refund_type', '=', 2];
  191. $condition[] = ['order_lock', '=', 1];
  192. $condition[] = ['refund_state', '<', 3];
  193. $return = $refundreturn_model->getRefundreturnCount($condition);
  194. $condition = [];
  195. $condition[] = ['accused_id', '=', session('store_id')];
  196. $condition[] = ['complain_state', 'between', [10, 90]];
  197. $complain_mod = model('complain');
  198. $complain = $complain_mod->getComplainCount($condition);
  199. //待确认的结算账单
  200. $bill_model = model('bill');
  201. $condition = [];
  202. $condition[] = ['ob_store_id', '=', session('store_id')];
  203. $condition[] = ['ob_state', '=', BILL_STATE_CREATE];
  204. $bill_confirm_count = $bill_model->getOrderbillCount($condition);
  205. //统计数组
  206. $statistics = [
  207. 'goodscount' => $goodscount,
  208. 'online' => $goods_online,
  209. 'waitverify' => $goods_waitverify,
  210. 'verifyfail' => $goods_verifyfail,
  211. 'offline' => $goods_offline,
  212. 'lockup' => $goods_lockup,
  213. 'imagecount' => $imagecount,
  214. 'consult' => $consult,
  215. 'progressing' => $progressing,
  216. 'payment' => $no_payment,
  217. 'delivery' => $no_delivery,
  218. 'refund_lock' => $refund_lock,
  219. 'refund' => $refund,
  220. 'return_lock' => $return_lock,
  221. 'return' => $return,
  222. 'complain' => $complain,
  223. 'bill_confirm' => $bill_confirm_count,
  224. ];
  225. exit(json_encode($statistics));
  226. }
  227. /**
  228. * 获取到店付款码
  229. */
  230. public function getStorePayQrcode()
  231. {
  232. include_once root_path() . 'extend/qrcode/phpqrcode.php';
  233. $value = config('ds_config.h5_site_url') . '/home/store_check?store_id=' . session('store_id');
  234. $errorCorrectionLevel = "L";
  235. $matrixPointSize = "4";
  236. \QRcode::png($value, false, $errorCorrectionLevel, $matrixPointSize, 2);
  237. }
  238. }
  239. ?>