Sellerindex.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <?php
  2. namespace app\api\controller;
  3. /**
  4. * ============================================================================
  5. * DSMall多用户商城
  6. * ============================================================================
  7. * 版权所有 2014-2028 长沙德尚网络科技有限公司,并保留所有权利。
  8. * 网站地址: http://www.csdeshang.com
  9. * ----------------------------------------------------------------------------
  10. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
  11. * 不允许对程序代码以任何形式任何目的的再发布。
  12. * ============================================================================
  13. * 卖家中心控制器
  14. */
  15. class Sellerindex extends MobileSeller {
  16. public function initialize() {
  17. parent::initialize(); // TODO: Change the autogenerated stub
  18. }
  19. /**
  20. * @api {POST} api/Sellerindex/index 商家中心
  21. * @apiVersion 1.0.0
  22. * @apiGroup Sellerindex
  23. *
  24. * @apiHeader {String} X-DS-KEY 卖家授权token
  25. *
  26. * @apiSuccess {String} code 返回码,10000为成功
  27. * @apiSuccess {String} message 返回消息
  28. * @apiSuccess {Object} result 返回数据
  29. * @apiSuccess {Object} result.seller_info 卖家信息
  30. * @apiSuccess {Int} result.seller_info.goods_lockup 违规商品数
  31. * @apiSuccess {Int} result.seller_info.goods_offline 下架商品数
  32. * @apiSuccess {Int} result.seller_info.goods_online 上架商品数
  33. * @apiSuccess {Int} result.seller_info.is_admin 是否主账号 0否1是
  34. * @apiSuccess {Int} result.seller_info.last_logintime 上次登录时间
  35. * @apiSuccess {Int} result.seller_info.last_logintime_fmt 上次登录时间描述
  36. * @apiSuccess {Int} result.seller_info.member_id 用户ID
  37. * @apiSuccess {Int} result.seller_info.order_nopay_count 待付款订单数
  38. * @apiSuccess {Int} result.seller_info.order_noreceipt_count 待收货订单数
  39. * @apiSuccess {Int} result.seller_info.order_noship_count 待发货订单数
  40. * @apiSuccess {Int} result.seller_info.seller_clienttype 客户端
  41. * @apiSuccess {Int} result.seller_info.seller_id 卖家账号ID
  42. * @apiSuccess {Int} result.seller_info.seller_name 卖家账号名称
  43. * @apiSuccess {Int} result.seller_info.sellergroup_id 卖家账号组
  44. * @apiSuccess {Int} result.seller_info.store_id 店铺ID
  45. * @apiSuccess {Object} result.statics 统计信息
  46. * @apiSuccess {Int} result.statics.bill_confirm 待确认结算单数
  47. * @apiSuccess {Int} result.statics.complain 投诉数
  48. * @apiSuccess {Int} result.statics.consult 咨询数
  49. * @apiSuccess {Int} result.statics.delivery 待发货订单数
  50. * @apiSuccess {Int} result.statics.goodscount 商品数
  51. * @apiSuccess {Int} result.statics.imagecount 图片数
  52. * @apiSuccess {Int} result.statics.lockup 违商品规数
  53. * @apiSuccess {Int} result.statics.offline 下架商品数
  54. * @apiSuccess {Int} result.statics.online 上架商品数
  55. * @apiSuccess {Int} result.statics.payment 已付款订单数
  56. * @apiSuccess {Int} result.statics.progressing 交易中订单数
  57. * @apiSuccess {Int} result.statics.refund 退款数
  58. * @apiSuccess {Int} result.statics.refund_lock 退款中数
  59. * @apiSuccess {Int} result.statics.return 退货数
  60. * @apiSuccess {Int} result.statics.return_lock 退货中数
  61. * @apiSuccess {Int} result.statics.verifyfail 审核失败商品数
  62. * @apiSuccess {Int} result.statics.waitverify 等待审核商品数
  63. * @apiSuccess {Object} result.store_info 店铺信息 (返回字段参考store表)
  64. * @apiSuccess {Object} result.store_info.daily_sales 今日销量
  65. * @apiSuccess {Float} result.store_info.daily_sales.orderamount 订单金额
  66. * @apiSuccess {Int} result.store_info.daily_sales.ordernum 订单量
  67. * @apiSuccess {Int} result.store_info.goods_count 商品数量
  68. * @apiSuccess {Int} result.store_info.grade_albumlimit 商品图片限制,0不限制
  69. * @apiSuccess {Int} result.store_info.grade_goodslimit 商品数量限制,0不限制
  70. * @apiSuccess {Int} result.store_info.grade_id 店铺等级
  71. * @apiSuccess {Int} result.store_info.grade_name 店铺等级名称
  72. * @apiSuccess {Object} result.store_info.monthly_sales 月销量
  73. * @apiSuccess {Float} result.store_info.monthly_sales.orderamount 订单金额
  74. * @apiSuccess {Int} result.store_info.monthly_sales.ordernum 订单量
  75. */
  76. public function index() {
  77. $seller_info = array();
  78. $seller_info = $this->seller_info;
  79. $store_info = $this->store_info;
  80. //最后登陆
  81. $seller_info['last_logintime_fmt'] = date('Y-m-d H:i:s', $seller_info['last_logintime']);
  82. $order_model = model('order');
  83. // 待付款
  84. $seller_info['order_nopay_count'] = intval($order_model->getOrderCountByID('store', $store_info['store_id'], 'NewCount'));
  85. // 待发货
  86. $seller_info['order_noship_count'] = intval($order_model->getOrderCountByID('store', $store_info['store_id'], 'PayCount'));
  87. // 待收货
  88. $seller_info['order_noreceipt_count'] = intval($order_model->getOrderCountByID('store', $store_info['store_id'], 'SendCount'));
  89. $goods_model = model('goods');
  90. // 出售中的商品
  91. $seller_info['goods_online'] = $goods_model->getGoodsCommonOnlineCount(array(array('store_id' ,'=', $store_info['store_id'])));
  92. // 仓库待上架的商品
  93. $seller_info['goods_offline'] = $goods_model->getGoodsCommonOfflineCount(array(array('store_id' ,'=', $store_info['store_id'])));
  94. // 违规下架的商品
  95. $seller_info['goods_lockup'] = $goods_model->getGoodsCommonLockUpCount(array(array('store_id' ,'=', $store_info['store_id'])));
  96. //店铺头像
  97. $store_info['store_avatar'] = get_store_logo($store_info['store_avatar'], 'store_avatar');
  98. //店铺标志
  99. $store_info['store_logo'] = get_store_logo($store_info['store_logo'], 'store_logo');
  100. //等级信息
  101. $store_info['grade_name'] = $this->store_grade['storegrade_name'];
  102. //商品数量限制
  103. $store_info['grade_goodslimit'] = $this->store_grade['storegrade_goods_limit'];
  104. //图片空间数量限制
  105. $store_info['grade_albumlimit'] = $this->store_grade['storegrade_album_limit'];
  106. /**
  107. * 销售情况统计
  108. */
  109. $field = 'COUNT(*) as ordernum,SUM(order_amount) as orderamount';
  110. $where = array();
  111. $where[] = array('store_id', '=', $this->store_info['store_id']);
  112. //有效订单
  113. $where[] = array('order_isvalid', '=', 1);
  114. //昨日销量
  115. $where[] = array('order_add_time', 'between', array(strtotime(date('Y-m-d', (TIMESTAMP - 3600 * 24))), strtotime(date('Y-m-d', TIMESTAMP)) - 1));
  116. $daily_sales = model('stat')->getoneByStatorder($where, $field);
  117. //月销量
  118. $where[] = array('order_add_time', '>', strtotime(date('Y-m', TIMESTAMP)));
  119. $monthly_sales = model('stat')->getoneByStatorder($where, $field);
  120. $store_info['daily_sales'] = $daily_sales;
  121. $store_info['monthly_sales'] = $monthly_sales;
  122. //统计
  123. $statics = $this->getStatics();
  124. ds_json_encode(10000, '', array('seller_info' => $seller_info, 'store_info' => $store_info, 'statics' => $statics));
  125. }
  126. /**
  127. * @api {POST} api/Sellerindex/getStatics 取得卖家统计类信息
  128. * @apiVersion 1.0.0
  129. * @apiGroup Sellerindex
  130. *
  131. * @apiHeader {String} X-DS-KEY 卖家授权token
  132. *
  133. * @apiSuccess {String} code 返回码,10000为成功
  134. * @apiSuccess {String} message 返回消息
  135. * @apiSuccess {Object} result 返回数据
  136. */
  137. private function getStatics() {
  138. $add_time_to = strtotime(date("Y-m-d")) + 60 * 60 * 24; //当前日期 ,从零点来时
  139. $add_time_from = strtotime(date("Y-m-d", (strtotime(date("Y-m-d")) - 60 * 60 * 24 * 30))); //30天前
  140. $goods_online = 0; // 出售中商品
  141. $goods_waitverify = 0; // 等待审核
  142. $goods_verifyfail = 0; // 审核失败
  143. $goods_offline = 0; // 仓库待上架商品
  144. $goods_lockup = 0; // 违规下架商品
  145. $consult = 0; // 待回复商品咨询
  146. $no_payment = 0; // 待付款
  147. $no_delivery = 0; // 待发货
  148. $no_receipt = 0; // 待收货
  149. $refund_lock = 0; // 售前退款
  150. $refund = 0; // 售后退款
  151. $return_lock = 0; // 售前退货
  152. $return = 0; // 售后退货
  153. $complain = 0; //进行中投诉
  154. $goods_model = model('goods');
  155. // 全部商品数
  156. $goodscount = $goods_model->getGoodsCommonCount(array('store_id' => $this->store_info['store_id']));
  157. // 出售中的商品
  158. $goods_online = $goods_model->getGoodsCommonOnlineCount(array(array('store_id' ,'=', $this->store_info['store_id'])));
  159. if (config('ds_config.goods_verify')) {
  160. // 等待审核的商品
  161. $goods_waitverify = $goods_model->getGoodsCommonWaitVerifyCount(array(array('store_id' ,'=', $this->store_info['store_id'])));
  162. // 审核失败的商品
  163. $goods_verifyfail = $goods_model->getGoodsCommonVerifyFailCount(array(array('store_id' ,'=', $this->store_info['store_id'])));
  164. }
  165. // 仓库待上架的商品
  166. $goods_offline = $goods_model->getGoodsCommonOfflineCount(array(array('store_id' ,'=', $this->store_info['store_id'])));
  167. // 违规下架的商品
  168. $goods_lockup = $goods_model->getGoodsCommonLockUpCount(array(array('store_id' ,'=', $this->store_info['store_id'])));
  169. // 等待回复商品咨询
  170. $consult = model('consult')->getConsultCount(array('store_id' => $this->store_info['store_id'], 'consult_reply' => ''));
  171. // 商品图片数量
  172. $imagecount = model('album')->getAlbumpicCount(array('store_id' => $this->store_info['store_id']));
  173. $order_model = model('order');
  174. // 交易中的订单
  175. $progressing = $order_model->getOrderCountByID('store', $this->store_info['store_id'], 'TradeCount');
  176. // 待付款
  177. $no_payment = $order_model->getOrderCountByID('store', $this->store_info['store_id'], 'NewCount');
  178. // 待发货
  179. $no_delivery = $order_model->getOrderCountByID('store', $this->store_info['store_id'], 'PayCount');
  180. $refundreturn_model = model('refundreturn');
  181. // 售前退款
  182. $condition = array();
  183. $condition[] = array('store_id', '=', $this->store_info['store_id']);
  184. $condition[] = array('refund_type', '=', 1);
  185. $condition[] = array('order_lock', '=', 2);
  186. $condition[] = array('refund_state', '<', 3);
  187. $refund_lock = $refundreturn_model->getRefundreturnCount($condition);
  188. // 售后退款
  189. $condition = array();
  190. $condition[] = array('store_id', '=', $this->store_info['store_id']);
  191. $condition[] = array('refund_type', '=', 1);
  192. $condition[] = array('order_lock', '=', 1);
  193. $condition[] = array('refund_state', '<', 3);
  194. $refund = $refundreturn_model->getRefundreturnCount($condition);
  195. // 售前退货
  196. $condition = array();
  197. $condition[] = array('store_id', '=', $this->store_info['store_id']);
  198. $condition[] = array('refund_type', '=', 2);
  199. $condition[] = array('order_lock', '=', 2);
  200. $condition[] = array('refund_state', '<', 3);
  201. $return_lock = $refundreturn_model->getRefundreturnCount($condition);
  202. // 售后退货
  203. $condition = array();
  204. $condition[] = array('store_id', '=', $this->store_info['store_id']);
  205. $condition[] = array('refund_type', '=', 2);
  206. $condition[] = array('order_lock', '=', 1);
  207. $condition[] = array('refund_state', '<', 3);
  208. $return = $refundreturn_model->getRefundreturnCount($condition);
  209. $condition = array();
  210. $condition[] = array('accused_id', '=', $this->store_info['store_id']);
  211. $condition[] = array('complain_state', 'between', array(10, 90));
  212. $complain_model = model('complain');
  213. $complain = $complain_model->getComplainCount($condition);
  214. //待确认的结算账单
  215. $bill_model = model('bill');
  216. $condition = array();
  217. $condition[] = array('ob_store_id','=',$this->store_info['store_id']);
  218. $condition[] = array('ob_state','=',BILL_STATE_CREATE);
  219. $bill_confirm_count = $bill_model->getOrderbillCount($condition);
  220. //统计数组
  221. $statistics = array(
  222. 'goodscount' => $goodscount,
  223. 'online' => $goods_online,
  224. 'waitverify' => $goods_waitverify,
  225. 'verifyfail' => $goods_verifyfail,
  226. 'offline' => $goods_offline,
  227. 'lockup' => $goods_lockup,
  228. 'imagecount' => $imagecount,
  229. 'consult' => $consult,
  230. 'progressing' => $progressing,
  231. 'payment' => $no_payment,
  232. 'delivery' => $no_delivery,
  233. 'refund_lock' => $refund_lock,
  234. 'refund' => $refund,
  235. 'return_lock' => $return_lock,
  236. 'return' => $return,
  237. 'complain' => $complain,
  238. 'bill_confirm' => $bill_confirm_count
  239. );
  240. return $statistics;
  241. }
  242. }
  243. ?>