You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
115 lines
3.9 KiB
115 lines
3.9 KiB
<?php
|
|
|
|
// +----------------------------------------------------------------------
|
|
// | 天诚科技 [ 刘海东 17600099397赋能开发者,助力企业发展 ]
|
|
// +----------------------------------------------------------------------
|
|
// | Copyright (c) 2016~2020 https://www.tczxkj.com All rights reserved.
|
|
// +----------------------------------------------------------------------
|
|
// | Licensed 该系统并不是自由软件,未经许可不能去掉相关版权
|
|
// +----------------------------------------------------------------------
|
|
// | Author:甘肃天诚志信电子商务有限公司 刘海东 联系电话维系17600099397
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace app\agent\model\merchant;
|
|
|
|
|
|
use traits\ModelTrait;
|
|
use basic\ModelBasic;
|
|
use service\PhpSpreadsheetService;
|
|
use app\admin\model\merchant\Merchant;
|
|
use app\admin\model\order\StoreOrder;
|
|
|
|
/**
|
|
* Class MerchantFlowingWater
|
|
* @package app\merchant\model\merchant
|
|
*/
|
|
class MerchantFlowingWater extends ModelBasic
|
|
{
|
|
use ModelTrait;
|
|
|
|
/**条件处理
|
|
* @param $where
|
|
* @return mixed
|
|
*/
|
|
public static function setWhereList($where)
|
|
{
|
|
$time['data'] = '';
|
|
if ($where['start_time'] != '' && $where['end_time'] != '') {
|
|
$time['data'] = $where['start_time'] . ' - ' . $where['end_time'];
|
|
}
|
|
$model = self::getModelTime($time, self::alias('f')
|
|
->join('AgentUser m', 'm.id=f.agent_id')
|
|
->order('f.add_time desc'), 'f.add_time');
|
|
if (isset($where['agent_id']) && $where['agent_id']) $model = $model->where('f.agent_id', $where['agent_id']);
|
|
$model = $model->where('f.price', '<>', 0);
|
|
return $model->field(['f.*', 'FROM_UNIXTIME(f.add_time,"%Y-%m-%d %H:%i:%s") as add_time', 'm.lecturer_name']);
|
|
}
|
|
|
|
/**讲师流水
|
|
* @param $where
|
|
* @return array
|
|
*/
|
|
public static function getBillList($where)
|
|
{
|
|
$data = ($data = self::setWhereList($where)->page((int)$where['page'], (int)$where['limit'])->select()) && count($data) ? $data->toArray() : [];
|
|
foreach ($data as &$v) {
|
|
$v['title'] = self::get_order_type($v['type']);
|
|
}
|
|
$count = self::setWhereList($where)->count();
|
|
return compact('data', 'count');
|
|
}
|
|
|
|
/**流水导出
|
|
* @param $where
|
|
*/
|
|
public static function SaveExport($where)
|
|
{
|
|
$data = ($data = self::setWhereList($where)->select()) && count($data) ? $data->toArray() : [];
|
|
$export = [];
|
|
foreach ($data as $value) {
|
|
$title = self::get_order_type($value['type']);
|
|
$export[] = [
|
|
$value['mer_id'],
|
|
$value['mer_name'],
|
|
$title,
|
|
$value['total_price'],
|
|
$value['pay_price'],
|
|
$value['refund_price'],
|
|
$value['status'] == 0 ? '-' . $value['price'] : $value['price'],
|
|
$value['add_time'],
|
|
];
|
|
}
|
|
$filename = '分成记录' . time() . '.xlsx';
|
|
$head = ['讲师ID', '讲师昵称', '订单类型', '订单总价', '实际金额', '退款金额', '分成/退还', '创建时间'];
|
|
PhpSpreadsheetService::outdata($filename, $export, $head);
|
|
}
|
|
|
|
/**订单类型
|
|
* @param $type
|
|
* @return string
|
|
*/
|
|
public static function get_order_type($type)
|
|
{
|
|
switch ($type) {
|
|
case 0:
|
|
$title = '课程订单';
|
|
break;
|
|
case 1:
|
|
$title = '会员订单';
|
|
break;
|
|
case 2:
|
|
$title = '商品订单';
|
|
break;
|
|
case 3:
|
|
$title = '资料订单';
|
|
break;
|
|
case 4:
|
|
$title = '报名订单';
|
|
break;
|
|
case 5:
|
|
$title = '考试订单';
|
|
break;
|
|
}
|
|
return $title;
|
|
}
|
|
}
|
|
|