Commit 6db6a93a authored by clone's avatar clone

11

parent c493ae49
......@@ -489,12 +489,13 @@ class StoreFeeService
{
$applyForFeeModel = new FApplyForFee();
$field = "a.id,a.type,a.fee_item,a.purpose,a.total_fee,a.office_id,a.agent_id,a.store_id,a.assume_fee,
a.status,a.count_time,a.site_id,a.create_time,b.id as old_store_id,b.office_id as old_office_id,b.site_id";
$params["b.id"] = $store_id;
a.status,a.count_time,a.create_time,b.id as old_store_id,b.office_id as old_office_id,b.site_id";
/* $params["b.id"] = $store_id;
$params["a.count_time"] = $setting_date;
$params["a.is_del"] = 0;
$params["a.status"] = 4;
return $applyForFeeModel->getApplyForFeeList($field, $params);
$params["a.status"] = 4;*/
$condition = "b.id =".$store_id." and a.count_time='".$setting_date. "' and a.is_del = 0 and a.status = 4";
return $applyForFeeModel->getApplyForFeeList($field, $condition);
}
/**
......
......@@ -8,7 +8,7 @@ use think\Model;
class FApplyForFee extends BaseModel
{
protected $table = 'f_apply_for_fee';
private $db_;
private $db_;
public function __construct($data = [])
{
......@@ -22,7 +22,8 @@ class FApplyForFee extends BaseModel
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function saveData($data) {
public function saveData($data)
{
$id = $this->db_->insertGetId($data);
return $id;
}
......@@ -42,7 +43,8 @@ class FApplyForFee extends BaseModel
/**
* 查询单条数据
*/
public function findByOne($field,$params) {
public function findByOne($field, $params)
{
$result = $this->db_
->field($field)
->where($params)
......@@ -59,9 +61,10 @@ class FApplyForFee extends BaseModel
* @param string $params
* @return false|\PDOStatement|string|\think\Collection
*/
public function getJoinAgentList($pageNo = 1, $pageSize = 15, $order_ = 'a.id desc', $field = '', $params = '') {
public function getJoinAgentList($pageNo = 1, $pageSize = 15, $order_ = 'a.id desc', $field = '', $params = '')
{
return $this->field($field)->alias('a')
->join('a_agents b', 'a.agent_id=b.id','left')
->join('a_agents b', 'a.agent_id=b.id', 'left')
->where($params)
->order($order_)
->limit($pageSize)
......@@ -73,37 +76,47 @@ class FApplyForFee extends BaseModel
* @param string $params
* @return int|string
*/
public function getJoinAgentListTotal($params = '') {
public function getJoinAgentListTotal($params = '')
{
return $this->alias('a')
->join('a_agents b', 'a.agent_id=b.id','left')
->join('a_agents b', 'a.agent_id=b.id', 'left')
->where($params)
->count('a.id');
}
/**
/**
* @param $field
* @param $params
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getApplyForFeeList($field,$params){
$result1 = $this->db_
->field($field)
->alias("a")
->join("f_office c","a.office_id = c.id","left")
->join("a_store b","b.office_id = c.id","left")
->where($params)
->select();
$result2 = $this->db_
->field($field)
->alias("a")
->join("f_apply_for_fee b","a.store_id = b.id","left")
->select();
array_merge($result1,$result2);
//echo $this->db_->getLastSql();
return $result1;
public function getApplyForFeeList($field, $params)
{
$sql = "SELECT * FROM
(
(
SELECT
$field
FROM
`f_apply_for_fee` `a`
LEFT JOIN `f_office` `c` ON `a`.`office_id` = `c`.`id`
LEFT JOIN `a_store` `b` ON `b`.`office_id` = `c`.`id`
WHERE
$params
)
UNION
(
SELECT
$field
FROM
`f_apply_for_fee` `a`
LEFT JOIN `a_store` `b` ON `a`.`store_id` = `b`.`id`
WHERE
$params
)
) AS aaa group by aaa.id ";
$result = $this->db_->query($sql);
return $result;
}
/**
......@@ -115,7 +128,7 @@ class FApplyForFee extends BaseModel
{
return $this->field($field)->alias('a')
->join('f_store_cost_ext b', 'a.id = b.apply_for_id', 'left')
->join('a_store c', 'a.store_id=c.id','left')
->join('a_store c', 'a.store_id=c.id', 'left')
->where($where)
->select();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment