StoreOrder.php 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. <?php
  2. /**
  3. *
  4. * @author: xaboy<365615158@qq.com>
  5. * @day: 2017/11/11
  6. */
  7. namespace app\admin\model\order;
  8. use app\admin\model\wechat\WechatUser;
  9. use app\admin\model\ump\StorePink;
  10. use app\admin\model\store\StoreProduct;
  11. use service\PHPExcelService;
  12. use traits\ModelTrait;
  13. use basic\ModelBasic;
  14. use service\WechatTemplateService;
  15. use think\Url;
  16. use think\Db;
  17. /**
  18. * 订单管理Model
  19. * Class StoreOrder
  20. * @package app\admin\model\store
  21. */
  22. class StoreOrder extends ModelBasic
  23. {
  24. use ModelTrait;
  25. /**
  26. * @param $where
  27. * @return array
  28. */
  29. public static function systemPage($where,$userid){
  30. $model = self::getOrderWhere($where,self::alias('a')->join('user r','r.uid=a.uid','LEFT'),'a.','r')->field('a.*,r.nickname');
  31. if($where['order']){
  32. $model = $model->order('a.'.$where['order']);
  33. }else{
  34. $model = $model->order('a.id desc');
  35. }
  36. if($where['export'] == 1){
  37. $list = $model->select()->toArray();
  38. $export = [];
  39. foreach ($list as $index=>$item){
  40. if ($item['pay_type'] == 'weixin'){
  41. $payType = '微信支付';
  42. }elseif($item['pay_type'] == 'yue'){
  43. $payType = '余额支付';
  44. }elseif($item['pay_type'] == 'offline'){
  45. $payType = '线下支付';
  46. }else{
  47. $payType = '其他支付';
  48. }
  49. $_info = db('store_order_cart_info')->where('oid',$item['id'])->column('cart_info');
  50. $goodsName = [];
  51. foreach ($_info as $k=>$v){
  52. $v = json_decode($v,true);
  53. $goodsName[] = implode(
  54. [$v['productInfo']['store_name'],
  55. isset($v['productInfo']['attrInfo']) ? '('.$v['productInfo']['attrInfo']['suk'].')' : '',
  56. "[{$v['cart_num']} * {$v['truePrice']}]"
  57. ],' ');
  58. }
  59. $item['cartInfo'] = $_info;
  60. $export[] = [
  61. $item['order_id'],$payType,
  62. $item['total_num'],$item['total_price'],$item['total_postage'],$item['pay_price'],$item['refund_price'],
  63. $item['mark'],$item['remark'],
  64. [$item['real_name'],$item['user_phone'],$item['user_address']],
  65. $goodsName,
  66. [$item['paid'] == 1? '已支付':'未支付','支付时间: '.($item['pay_time'] > 0 ? date('Y/md H:i',$item['pay_time']) : '暂无')]
  67. ];
  68. $list[$index] = $item;
  69. }
  70. PHPExcelService::setExcelHeader(['订单号','支付方式','商品总数','商品总价','邮费','支付金额','退款金额','用户备注','管理员备注','收货人信息','商品信息','支付状态'])
  71. ->setExcelTile('订单导出','订单信息'.time(),' 生成时间:'.date('Y-m-d H:i:s',time()))
  72. ->setExcelContent($export)
  73. ->ExcelSave();
  74. }
  75. return self::page($model,function ($item){
  76. $item['nickname'] = WechatUser::where('uid',$item['uid'])->value('nickname');
  77. $_info = db('store_order_cart_info')->where('oid',$item['id'])->field('cart_info')->select();
  78. foreach ($_info as $k=>$v){
  79. $_info[$k]['cart_info'] = json_decode($v['cart_info'],true);
  80. }
  81. $item['_info'] = $_info;
  82. if($item['pink_id'] && $item['combination_id']){
  83. $pinkStatus = StorePink::where('order_id_key',$item['id'])->value('status');
  84. if($pinkStatus == 1){
  85. $item['pink_name'] = '[拼团订单]正在进行中';
  86. $item['color'] = '#f00';
  87. }else if($pinkStatus == 2){
  88. $item['pink_name'] = '[拼团订单]已完成';
  89. $item['color'] = '#00f';
  90. }else if($pinkStatus == 3){
  91. $item['pink_name'] = '[拼团订单]未完成';
  92. $item['color'] = '#f0f';
  93. }else{
  94. $item['pink_name'] = '[拼团订单]历史订单';
  95. $item['color'] = '#457856';
  96. }
  97. }else{
  98. if($item['seckill_id']){
  99. $item['pink_name'] = '[秒杀订单]';
  100. $item['color'] = '#32c5e9';
  101. }else{
  102. $item['pink_name'] = '[普通订单]';
  103. $item['color'] = '#895612';
  104. }
  105. }
  106. },$where);
  107. }
  108. public static function statusByWhere($status,$model = null,$alert='')
  109. {
  110. if($model == null) $model = new self;
  111. if('' === $status)
  112. return $model;
  113. else if($status == 0)//未支付
  114. return $model->where($alert.'paid',0)->where($alert.'status',0)->where($alert.'refund_status',0);
  115. else if($status == 1)//已支付 未发货
  116. return $model->where($alert.'paid',1)->where($alert.'status',0)->where($alert.'refund_status',0);
  117. else if($status == 2)//已支付 待收货
  118. return $model->where($alert.'paid',1)->where($alert.'status',1)->where($alert.'refund_status',0);
  119. else if($status == 3)// 已支付 已收货 待评价
  120. return $model->where($alert.'paid',1)->where($alert.'status',2)->where($alert.'refund_status',0);
  121. else if($status == 4)// 交易完成
  122. return $model->where($alert.'paid',1)->where($alert.'status',3)->where($alert.'refund_status',0);
  123. else if($status == -1)//退款中
  124. return $model->where($alert.'paid',1)->where($alert.'refund_status',1);
  125. else if($status == -2)//已退款
  126. return $model->where($alert.'paid',1)->where($alert.'refund_status',2);
  127. else if($status == -3)//退款
  128. return $model->where($alert.'paid',1)->where($alert.'refund_status','in','1,2');
  129. else
  130. return $model;
  131. }
  132. public static function timeQuantumWhere($startTime = null,$endTime = null,$model = null)
  133. {
  134. if($model === null) $model = new self;
  135. if($startTime != null && $endTime != null)
  136. $model = $model->where('add_time','>',strtotime($startTime))->where('add_time','<',strtotime($endTime));
  137. return $model;
  138. }
  139. public static function changeOrderId($orderId)
  140. {
  141. $ymd = substr($orderId,2,8);
  142. $key = substr($orderId,16);
  143. return 'wx'.$ymd.date('His').$key;
  144. }
  145. /**
  146. * 线下付款
  147. * @param $id
  148. * @return $this
  149. */
  150. public static function updateOffline($id){
  151. $orderId = self::where('id',$id)->value('order_id');
  152. $res = self::where('order_id',$orderId)->update(['paid'=>1,'pay_time'=>time()]);
  153. return $res;
  154. }
  155. /**
  156. * 退款发送模板消息
  157. * @param $oid
  158. * $oid 订单id key
  159. */
  160. public static function refundTemplate($data,$oid)
  161. {
  162. $order = self::where('id',$oid)->find();
  163. WechatTemplateService::sendTemplate(WechatUser::uidToOpenid($order['uid']),WechatTemplateService::ORDER_REFUND_STATUS, [
  164. 'first'=>'亲,您购买的商品已退款,本次退款'.$data['refund_price'].'金额',
  165. 'keyword1'=>$order['order_id'],
  166. 'keyword2'=>$order['pay_price'],
  167. 'keyword3'=>date('Y-m-d H:i:s',$order['add_time']),
  168. 'remark'=>'点击查看订单详情'
  169. ],Url::build('wap/My/order',['uni'=>$order['order_id']],true,true));
  170. }
  171. /**
  172. * 处理where条件
  173. * @param $where
  174. * @param $model
  175. * @return mixed
  176. */
  177. public static function getOrderWhere($where,$model,$aler='',$join=''){
  178. // $model = $model->where('combination_id',0);
  179. if($where['status'] != '') $model = self::statusByWhere($where['status'],$model,$aler);
  180. if($where['is_del'] != '' && $where['is_del'] != -1) $model = $model->where($aler.'is_del',$where['is_del']);
  181. if($where['combination_id'] =='普通订单'){
  182. $model = $model->where($aler.'combination_id',0)->where($aler.'seckill_id',0);
  183. }
  184. if($where['combination_id'] =='拼团订单'){
  185. $model = $model->where($aler.'combination_id',">",0)->where($aler.'pink_id',">",0);
  186. }
  187. if($where['combination_id'] =='秒杀订单'){
  188. $model = $model->where($aler.'seckill_id',">",0);
  189. }
  190. if($where['real_name'] != ''){
  191. $model = $model->where($aler.'order_id|'.$aler.'real_name|'.$aler.'user_phone'.($join ? '|'.$join.'.nickname|'.$join.'.uid':''),'LIKE',"%$where[real_name]%");
  192. }
  193. if($where['data'] !== ''){
  194. list($startTime,$endTime) = explode(' - ',$where['data']);
  195. $model = $model->where($aler.'add_time','>',strtotime($startTime));
  196. $model = $model->where($aler.'add_time','<',strtotime($endTime));
  197. }
  198. return $model;
  199. }
  200. /**
  201. * 处理订单金额
  202. * @param $where
  203. * @return array
  204. */
  205. public static function getOrderPrice($where){
  206. $model = new self;
  207. $price = array();
  208. $price['pay_price'] = 0;//支付金额
  209. $price['refund_price'] = 0;//退款金额
  210. $price['pay_price_wx'] = 0;//微信支付金额
  211. $price['pay_price_yue'] = 0;//余额支付金额
  212. $price['pay_price_offline'] = 0;//线下支付金额
  213. $price['pay_price_other'] = 0;//其他支付金额
  214. $price['use_integral'] = 0;//用户使用积分
  215. $price['back_integral'] = 0;//退积分总数
  216. $price['deduction_price'] = 0;//抵扣金额
  217. $price['total_num'] = 0; //商品总数
  218. $model = self::getOrderWhere($where,$model);
  219. $list = $model->select()->toArray();
  220. foreach ($list as $v){
  221. $price['total_num'] = bcadd($price['total_num'],$v['total_num'],0);
  222. $price['pay_price'] = bcadd($price['pay_price'],$v['pay_price'],2);
  223. $price['refund_price'] = bcadd($price['refund_price'],$v['refund_price'],2);
  224. $price['use_integral'] = bcadd($price['use_integral'],$v['use_integral'],2);
  225. $price['back_integral'] = bcadd($price['back_integral'],$v['back_integral'],2);
  226. $price['deduction_price'] = bcadd($price['deduction_price'],$v['deduction_price'],2);
  227. if ($v['pay_type'] == 'weixin'){
  228. $price['pay_price_wx'] = bcadd($price['pay_price_wx'],$v['pay_price'],2);
  229. }elseif($v['pay_type'] == 'yue'){
  230. $price['pay_price_yue'] = bcadd($price['pay_price_yue'],$v['pay_price'],2);
  231. }elseif($v['pay_type'] == 'offline'){
  232. $price['pay_price_offline'] = bcadd($price['pay_price_offline'],$v['pay_price'],2);
  233. }else{
  234. $price['pay_price_other'] = bcadd($price['pay_price_other'],$v['pay_price'],2);
  235. }
  236. }
  237. return $price;
  238. }
  239. public static function systemPagePink($where){
  240. $model = new self;
  241. $model = self::getOrderWherePink($where,$model);
  242. $model = $model->order('id desc');
  243. if($where['export'] == 1){
  244. $list = $model->select()->toArray();
  245. $export = [];
  246. foreach ($list as $index=>$item){
  247. if ($item['pay_type'] == 'weixin'){
  248. $payType = '微信支付';
  249. }elseif($item['pay_type'] == 'yue'){
  250. $payType = '余额支付';
  251. }elseif($item['pay_type'] == 'offline'){
  252. $payType = '线下支付';
  253. }else{
  254. $payType = '其他支付';
  255. }
  256. $_info = db('store_order_cart_info')->where('oid',$item['id'])->column('cart_info');
  257. $goodsName = [];
  258. foreach ($_info as $k=>$v){
  259. $v = json_decode($v,true);
  260. $goodsName[] = implode(
  261. [$v['productInfo']['store_name'],
  262. isset($v['productInfo']['attrInfo']) ? '('.$v['productInfo']['attrInfo']['suk'].')' : '',
  263. "[{$v['cart_num']} * {$v['truePrice']}]"
  264. ],' ');
  265. }
  266. $item['cartInfo'] = $_info;
  267. $export[] = [
  268. $item['order_id'],$payType,
  269. $item['total_num'],$item['total_price'],$item['total_postage'],$item['pay_price'],$item['refund_price'],
  270. $item['mark'],$item['remark'],
  271. [$item['real_name'],$item['user_phone'],$item['user_address']],
  272. $goodsName,
  273. [$item['paid'] == 1? '已支付':'未支付','支付时间: '.($item['pay_time'] > 0 ? date('Y/md H:i',$item['pay_time']) : '暂无')]
  274. ];
  275. $list[$index] = $item;
  276. }
  277. ExportService::exportCsv($export,'订单导出'.time(),['订单号','支付方式','商品总数','商品总价','邮费','支付金额','退款金额','用户备注','管理员备注','收货人信息','商品信息','支付状态']);
  278. }
  279. return self::page($model,function ($item){
  280. $item['nickname'] = WechatUser::where('uid',$item['uid'])->value('nickname');
  281. $_info = db('store_order_cart_info')->where('oid',$item['id'])->field('cart_info')->select();
  282. foreach ($_info as $k=>$v){
  283. $_info[$k]['cart_info'] = json_decode($v['cart_info'],true);
  284. }
  285. $item['_info'] = $_info;
  286. },$where);
  287. }
  288. /**
  289. * 处理where条件
  290. * @param $where
  291. * @param $model
  292. * @return mixed
  293. */
  294. public static function getOrderWherePink($where,$model){
  295. $model = $model->where('combination_id','GT',0);
  296. if($where['status'] != '') $model = $model::statusByWhere($where['status']);
  297. // if($where['is_del'] != '' && $where['is_del'] != -1) $model = $model->where('is_del',$where['is_del']);
  298. if($where['real_name'] != ''){
  299. $model = $model->where('order_id|real_name|user_phone','LIKE',"%$where[real_name]%");
  300. }
  301. if($where['data'] !== ''){
  302. list($startTime,$endTime) = explode(' - ',$where['data']);
  303. $model = $model->where('add_time','>',strtotime($startTime));
  304. $model = $model->where('add_time','<',strtotime($endTime));
  305. }
  306. return $model;
  307. }
  308. /**
  309. * 处理订单金额
  310. * @param $where
  311. * @return array
  312. */
  313. public static function getOrderPricePink($where){
  314. $model = new self;
  315. $price = array();
  316. $price['pay_price'] = 0;//支付金额
  317. $price['refund_price'] = 0;//退款金额
  318. $price['pay_price_wx'] = 0;//微信支付金额
  319. $price['pay_price_yue'] = 0;//余额支付金额
  320. $price['pay_price_offline'] = 0;//线下支付金额
  321. $price['pay_price_other'] = 0;//其他支付金额
  322. $price['use_integral'] = 0;//用户使用积分
  323. $price['back_integral'] = 0;//退积分总数
  324. $price['deduction_price'] = 0;//抵扣金额
  325. $price['total_num'] = 0; //商品总数
  326. $model = self::getOrderWherePink($where,$model);
  327. $list = $model->select()->toArray();
  328. foreach ($list as $v){
  329. $price['total_num'] = bcadd($price['total_num'],$v['total_num'],0);
  330. $price['pay_price'] = bcadd($price['pay_price'],$v['pay_price'],2);
  331. $price['refund_price'] = bcadd($price['refund_price'],$v['refund_price'],2);
  332. $price['use_integral'] = bcadd($price['use_integral'],$v['use_integral'],2);
  333. $price['back_integral'] = bcadd($price['back_integral'],$v['back_integral'],2);
  334. $price['deduction_price'] = bcadd($price['deduction_price'],$v['deduction_price'],2);
  335. if ($v['pay_type'] == 'weixin'){
  336. $price['pay_price_wx'] = bcadd($price['pay_price_wx'],$v['pay_price'],2);
  337. }elseif($v['pay_type'] == 'yue'){
  338. $price['pay_price_yue'] = bcadd($price['pay_price_yue'],$v['pay_price'],2);
  339. }elseif($v['pay_type'] == 'offline'){
  340. $price['pay_price_offline'] = bcadd($price['pay_price_offline'],$v['pay_price'],2);
  341. }else{
  342. $price['pay_price_other'] = bcadd($price['pay_price_other'],$v['pay_price'],2);
  343. }
  344. }
  345. return $price;
  346. }
  347. /**
  348. * 获取昨天的订单 首页在使用
  349. * @param int $preDay
  350. * @param int $day
  351. * @return $this|StoreOrder
  352. */
  353. public static function isMainYesterdayCount($preDay = 0,$day = 0){
  354. $model = new self();
  355. $model = $model->where('add_time','gt',$preDay);
  356. $model = $model->where('add_time','lt',$day);
  357. return $model;
  358. }
  359. /**
  360. * 获取用户购买次数
  361. * @param int $uid
  362. * @return int|string
  363. */
  364. public static function getUserCountPay($uid = 0){
  365. if(!$uid) return 0;
  366. return self::where('uid',$uid)->where('paid',1)->count();
  367. }
  368. /**
  369. * 获取单个用户购买列表
  370. * @param array $where
  371. * @return array
  372. */
  373. public static function getOneorderList($where){
  374. return self::where(['uid'=>$where['uid']])
  375. ->order('add_time desc')
  376. ->page((int)$where['page'],(int)$where['limit'])
  377. ->field(['order_id','real_name','total_num','total_price','pay_price',
  378. 'FROM_UNIXTIME(pay_time,"%Y-%m-%d") as pay_time','paid','pay_type',
  379. 'pink_id','seckill_id','bargain_id'
  380. ])->select()
  381. ->toArray();
  382. }
  383. /*
  384. * 设置订单统计图搜索
  385. * $where array 条件
  386. * return object
  387. */
  388. public static function setEchatWhere($where,$status=null,$time=null){
  389. $model=self::statusByWhere($where['status']);
  390. if($status!==null) $where['type']=$status;
  391. if($time===true) $where['data']='';
  392. switch ($where['type']){
  393. case 1:
  394. //普通商品
  395. $model=$model->where('combination_id',0)->where('seckill_id',0);
  396. break;
  397. case 2:
  398. //拼团商品
  399. $model=$model->where('combination_id',">",0)->where('pink_id',">",0);
  400. break;
  401. case 3:
  402. //秒杀商品
  403. $model=$model->where('seckill_id',">",0);
  404. break;
  405. case 4:
  406. //砍价商品
  407. $model=$model->where('bargain_id','>',0);
  408. break;
  409. }
  410. return self::getModelTime($where,$model);
  411. }
  412. /*
  413. * 获取订单数据统计图
  414. * $where array
  415. * $limit int
  416. * return array
  417. */
  418. public static function getEchartsOrder($where,$limit=20){
  419. $orderlist=self::setEchatWhere($where)->field([
  420. 'FROM_UNIXTIME(add_time,"%Y-%m-%d") as _add_time',
  421. 'sum(total_num) total_num',
  422. 'count(*) count',
  423. 'sum(total_price) total_price',
  424. 'sum(refund_price) refund_price',
  425. 'group_concat(cart_id SEPARATOR "|") cart_ids'
  426. ])->group('_add_time')->order('_add_time asc')->select();
  427. count($orderlist) && $orderlist=$orderlist->toArray();
  428. $legend=['商品数量','订单数量','订单金额','退款金额'];
  429. $seriesdata=[
  430. [
  431. 'name'=>$legend[0],
  432. 'type'=>'line',
  433. 'data'=>[],
  434. ],
  435. [
  436. 'name'=>$legend[1],
  437. 'type'=>'line',
  438. 'data'=>[]
  439. ],
  440. [
  441. 'name'=>$legend[2],
  442. 'type'=>'line',
  443. 'data'=>[]
  444. ],
  445. [
  446. 'name'=>$legend[3],
  447. 'type'=>'line',
  448. 'data'=>[]
  449. ]
  450. ];
  451. $xdata=[];
  452. $zoom='';
  453. foreach ($orderlist as $item){
  454. $xdata[]=$item['_add_time'];
  455. $seriesdata[0]['data'][]=$item['total_num'];
  456. $seriesdata[1]['data'][]=$item['count'];
  457. $seriesdata[2]['data'][]=$item['total_price'];
  458. $seriesdata[3]['data'][]=$item['refund_price'];
  459. }
  460. count($xdata) > $limit && $zoom=$xdata[$limit-5];
  461. $badge=self::getOrderBadge($where);
  462. $bingpaytype=self::setEchatWhere($where)->group('pay_type')->field(['count(*) as count','pay_type'])->select();
  463. count($bingpaytype) && $bingpaytype=$bingpaytype->toArray();
  464. $bing_xdata=['微信支付','余额支付','其他支付'];
  465. $color=['#ffcccc','#99cc00','#fd99cc','#669966'];
  466. $bing_data=[];
  467. foreach ($bingpaytype as $key=>$item){
  468. if($item['pay_type']=='weixin'){
  469. $value['name']=$bing_xdata[0];
  470. }else if($item['pay_type']=='yue'){
  471. $value['name']=$bing_xdata[1];
  472. }else{
  473. $value['name']=$bing_xdata[2];
  474. }
  475. $value['value']=$item['count'];
  476. $value['itemStyle']['color']=isset($color[$key]) ? $color[$key]:$color[0];
  477. $bing_data[]=$value;
  478. }
  479. return compact('zoom','xdata','seriesdata','badge','legend','bing_data','bing_xdata');
  480. }
  481. public static function getOrderBadge($where){
  482. return [
  483. [
  484. 'name'=>'拼团订单数量',
  485. 'field'=>'个',
  486. 'count'=>self::setEchatWhere($where,2)->count(),
  487. 'content'=>'拼团总订单数量',
  488. 'background_color'=>'layui-bg-cyan',
  489. 'sum'=>self::setEchatWhere($where,2,true)->count(),
  490. 'class'=>'fa fa-line-chart',
  491. 'col'=>2
  492. ],
  493. [
  494. 'name'=>'砍价订单数量',
  495. 'field'=>'个',
  496. 'count'=>self::setEchatWhere($where,4)->count(),
  497. 'content'=>'砍价总订单数量',
  498. 'background_color'=>'layui-bg-cyan',
  499. 'sum'=>self::setEchatWhere($where,4,true)->count(),
  500. 'class'=>'fa fa-line-chart',
  501. 'col'=>2
  502. ],
  503. [
  504. 'name'=>'秒杀订单数量',
  505. 'field'=>'个',
  506. 'count'=>self::setEchatWhere($where,3)->count(),
  507. 'content'=>'秒杀总订单数量',
  508. 'background_color'=>'layui-bg-cyan',
  509. 'sum'=>self::setEchatWhere($where,3,true)->count(),
  510. 'class'=>'fa fa-line-chart',
  511. 'col'=>2
  512. ],
  513. [
  514. 'name'=>'普通订单数量',
  515. 'field'=>'个',
  516. 'count'=>self::setEchatWhere($where,1)->count(),
  517. 'content'=>'普通总订单数量',
  518. 'background_color'=>'layui-bg-cyan',
  519. 'sum'=>self::setEchatWhere($where,1,true)->count(),
  520. 'class'=>'fa fa-line-chart',
  521. 'col'=>2,
  522. ],
  523. [
  524. 'name'=>'使用优惠卷金额',
  525. 'field'=>'元',
  526. 'count'=>self::setEchatWhere($where)->sum('coupon_price'),
  527. 'content'=>'普通总订单数量',
  528. 'background_color'=>'layui-bg-cyan',
  529. 'sum'=>self::setEchatWhere($where,null,true)->sum('coupon_price'),
  530. 'class'=>'fa fa-line-chart',
  531. 'col'=>2
  532. ],
  533. [
  534. 'name'=>'积分消耗数',
  535. 'field'=>'个',
  536. 'count'=>self::setEchatWhere($where)->sum('use_integral'),
  537. 'content'=>'积分消耗总数',
  538. 'background_color'=>'layui-bg-cyan',
  539. 'sum'=>self::setEchatWhere($where,null,true)->sum('use_integral'),
  540. 'class'=>'fa fa-line-chart',
  541. 'col'=>2
  542. ],
  543. [
  544. 'name'=>'积分抵扣金额',
  545. 'field'=>'个',
  546. 'count'=>self::setEchatWhere($where)->sum('deduction_price'),
  547. 'content'=>'积分抵扣总金额',
  548. 'background_color'=>'layui-bg-cyan',
  549. 'sum'=>self::setEchatWhere($where,null,true)->sum('deduction_price'),
  550. 'class'=>'fa fa-money',
  551. 'col'=>2
  552. ],
  553. [
  554. 'name'=>'在线支付金额',
  555. 'field'=>'元',
  556. 'count'=>self::setEchatWhere($where)->where('pay_type','weixin')->sum('pay_price'),
  557. 'content'=>'在线支付总金额',
  558. 'background_color'=>'layui-bg-cyan',
  559. 'sum'=>self::setEchatWhere($where,null,true)->where('pay_type','weixin')->sum('pay_price'),
  560. 'class'=>'fa fa-weixin',
  561. 'col'=>2
  562. ],
  563. [
  564. 'name'=>'余额支付金额',
  565. 'field'=>'元',
  566. 'count'=>self::setEchatWhere($where)->where('pay_type','yue')->sum('pay_price'),
  567. 'content'=>'余额支付总金额',
  568. 'background_color'=>'layui-bg-cyan',
  569. 'sum'=>self::setEchatWhere($where,null,true)->where('pay_type','yue')->sum('pay_price'),
  570. 'class'=>'fa fa-balance-scale',
  571. 'col'=>2
  572. ],
  573. [
  574. 'name'=>'赚取积分',
  575. 'field'=>'分',
  576. 'count'=>self::setEchatWhere($where)->sum('gain_integral'),
  577. 'content'=>'赚取总积分',
  578. 'background_color'=>'layui-bg-cyan',
  579. 'sum'=>self::setEchatWhere($where,null,true)->sum('gain_integral'),
  580. 'class'=>'fa fa-gg-circle',
  581. 'col'=>2
  582. ],
  583. [
  584. 'name'=>'交易额',
  585. 'field'=>'元',
  586. 'count'=>self::setEchatWhere($where)->sum('pay_price'),
  587. 'content'=>'总交易额',
  588. 'background_color'=>'layui-bg-cyan',
  589. 'sum'=>self::setEchatWhere($where,null,true)->sum('pay_price'),
  590. 'class'=>'fa fa-jpy',
  591. 'col'=>2
  592. ],
  593. [
  594. 'name'=>'订单商品数量',
  595. 'field'=>'元',
  596. 'count'=>self::setEchatWhere($where)->sum('total_num'),
  597. 'content'=>'订单商品总数量',
  598. 'background_color'=>'layui-bg-cyan',
  599. 'sum'=>self::setEchatWhere($where,null,true)->sum('total_num'),
  600. 'class'=>'fa fa-cube',
  601. 'col'=>2
  602. ]
  603. ];
  604. }
  605. /*
  606. * 退款列表
  607. * $where array
  608. * return array
  609. */
  610. // public static function getRefundList($where){
  611. // $refundlist=self::setEchatWhere($where)->field([
  612. // 'order_id','total_price','coupon_price','deduction_price',
  613. // 'use_integral','FROM_UNIXTIME(add_time,"%Y-%m-%d") as add_time','FROM_UNIXTIME(pay_time,"%Y-%m-%d") as pay_time','combination_id',
  614. // 'seckill_id','bargain_id','cost','status','cart_id','pay_price','refund_status'
  615. // ])->page((int)$where['page'],(int)$where['limit'])->select();
  616. // count($refundlist) && $refundlist=$refundlist->toArray();
  617. // foreach($refundlist as &$item){
  618. // $item['product']=StoreProduct::where('id','in',function ($quers) use($item){
  619. // $quers->name('store_cart')->where('id','in',json_decode($item['cart_id'],true))->field('product_id');
  620. // })->field(['store_name','cost','price','image'])->select()->toArray();
  621. // if($item['refund_status']==1) {
  622. // $item['_refund'] = '申请退款中';
  623. // }elseif ($item['refund_status']==2){
  624. // $item['_refund'] = '退款成功';
  625. // }
  626. // }
  627. // return $refundlist;
  628. // }
  629. }