Commit 6db6a93a authored by clone's avatar clone

11

parent c493ae49
...@@ -489,12 +489,13 @@ class StoreFeeService ...@@ -489,12 +489,13 @@ class StoreFeeService
{ {
$applyForFeeModel = new FApplyForFee(); $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, $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"; 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["b.id"] = $store_id;
$params["a.count_time"] = $setting_date; $params["a.count_time"] = $setting_date;
$params["a.is_del"] = 0; $params["a.is_del"] = 0;
$params["a.status"] = 4; $params["a.status"] = 4;*/
return $applyForFeeModel->getApplyForFeeList($field, $params); $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; ...@@ -8,7 +8,7 @@ use think\Model;
class FApplyForFee extends BaseModel class FApplyForFee extends BaseModel
{ {
protected $table = 'f_apply_for_fee'; protected $table = 'f_apply_for_fee';
private $db_; private $db_;
public function __construct($data = []) public function __construct($data = [])
{ {
...@@ -22,7 +22,8 @@ class FApplyForFee extends BaseModel ...@@ -22,7 +22,8 @@ class FApplyForFee extends BaseModel
* @throws \think\Exception * @throws \think\Exception
* @throws \think\exception\PDOException * @throws \think\exception\PDOException
*/ */
public function saveData($data) { public function saveData($data)
{
$id = $this->db_->insertGetId($data); $id = $this->db_->insertGetId($data);
return $id; return $id;
} }
...@@ -42,7 +43,8 @@ class FApplyForFee extends BaseModel ...@@ -42,7 +43,8 @@ class FApplyForFee extends BaseModel
/** /**
* 查询单条数据 * 查询单条数据
*/ */
public function findByOne($field,$params) { public function findByOne($field, $params)
{
$result = $this->db_ $result = $this->db_
->field($field) ->field($field)
->where($params) ->where($params)
...@@ -59,9 +61,10 @@ class FApplyForFee extends BaseModel ...@@ -59,9 +61,10 @@ class FApplyForFee extends BaseModel
* @param string $params * @param string $params
* @return false|\PDOStatement|string|\think\Collection * @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') 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) ->where($params)
->order($order_) ->order($order_)
->limit($pageSize) ->limit($pageSize)
...@@ -73,37 +76,47 @@ class FApplyForFee extends BaseModel ...@@ -73,37 +76,47 @@ class FApplyForFee extends BaseModel
* @param string $params * @param string $params
* @return int|string * @return int|string
*/ */
public function getJoinAgentListTotal($params = '') { public function getJoinAgentListTotal($params = '')
{
return $this->alias('a') 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) ->where($params)
->count('a.id'); ->count('a.id');
} }
/**
/**
* @param $field * @param $field
* @param $params * @param $params
* @return false|\PDOStatement|string|\think\Collection * @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function getApplyForFeeList($field,$params){ public function getApplyForFeeList($field, $params)
$result1 = $this->db_ {
->field($field) $sql = "SELECT * FROM
->alias("a") (
->join("f_office c","a.office_id = c.id","left") (
->join("a_store b","b.office_id = c.id","left") SELECT
->where($params) $field
->select(); FROM
`f_apply_for_fee` `a`
$result2 = $this->db_ LEFT JOIN `f_office` `c` ON `a`.`office_id` = `c`.`id`
->field($field) LEFT JOIN `a_store` `b` ON `b`.`office_id` = `c`.`id`
->alias("a") WHERE
->join("f_apply_for_fee b","a.store_id = b.id","left") $params
->select(); )
array_merge($result1,$result2); UNION
//echo $this->db_->getLastSql(); (
return $result1; 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 ...@@ -115,7 +128,7 @@ class FApplyForFee extends BaseModel
{ {
return $this->field($field)->alias('a') return $this->field($field)->alias('a')
->join('f_store_cost_ext b', 'a.id = b.apply_for_id', 'left') ->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) ->where($where)
->select(); ->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