Commit 396da28a authored by zhuwei's avatar zhuwei

全部门店成本

parent 739f83cd
...@@ -9,6 +9,7 @@ use app\index\untils\ExportExcelUntil; ...@@ -9,6 +9,7 @@ use app\index\untils\ExportExcelUntil;
use app\model\AStore; use app\model\AStore;
use app\model\CActivity; use app\model\CActivity;
use app\model\FApplyForFeeCheck; use app\model\FApplyForFeeCheck;
use app\model\FStoreCost;
use app\model\FStoreCostExt; use app\model\FStoreCostExt;
use think\Request; use think\Request;
...@@ -431,40 +432,26 @@ class CostDetail extends Basic ...@@ -431,40 +432,26 @@ class CostDetail extends Basic
/** /**
* 我的门店成本 * 全部门店成本
* @return \think\Response * @return \think\Response
*/ */
public function getMyCostDetailList() public function getAllStoreCost()
{ {
$params = $this->params; $params = $this->params;
/* $params = array( $params = array(
"district_id" => '12'
);*/ );
$checkResult = $this->validate($params, "CostDetailValidate.getMyCostDetailList"); $checkResult = $this->validate($params, "CostDetailValidate.getAllStoreCost");
if (true !== $checkResult) { if (true !== $checkResult) {
return $this->response("101", $checkResult); return $this->response("101", $checkResult);
} }
$conditions = []; $conditions = [];
//计入月份 $conditions["b.district_id"] = $params["district_id"];
$conditions["b.setting_date"] = $params["setting_date"]; $field = 'c.district_name,a.store_name';
//门店id $m_store_cost = new FStoreCost();
$conditions["a.store_id"] = $params["store_id"]; $list = $m_store_cost->getAllStoreCost($field, $conditions);
$field = 'a.id,a.cost_id,b.setting_date,a.create_time,b.operator_name,
a.type,a.fee_item,a.purpose,b.store_id,a.assume_fee';
$list = $this->storeCostExt->getMyCostDetailList($field, $conditions);
if(!$list)
return $this->response("200", "success", []);
foreach ($list as $k => $v) {
$list[$k]['type_name'] = $this->getTypeName($v['type']);
$list[$k]['fee_item_name'] = $this->getFeeItemName($v['fee_item']);
$list[$k]['store_name'] = $this->getStoreName($v['store_id']);
}
$result["list"] = $list; $result["list"] = $list;
return $this->response("200", "success", $result); return $this->response("200", "success", $result);
} }
......
...@@ -11,6 +11,9 @@ class CostDetailValidate extends Validate { ...@@ -11,6 +11,9 @@ class CostDetailValidate extends Validate {
'type' => 'require|number|in:0,1,2', 'type' => 'require|number|in:0,1,2',
'setting_date' => 'require', 'setting_date' => 'require',
'district_id' => 'require|number|gt:0',
]; ];
protected $message = [ protected $message = [
...@@ -24,11 +27,16 @@ class CostDetailValidate extends Validate { ...@@ -24,11 +27,16 @@ class CostDetailValidate extends Validate {
'setting_date.require' => '时间为必填字段', 'setting_date.require' => '时间为必填字段',
'district_id.require' => 'store_id为必填字段',
'district_id.number' => 'store_id只能为数字',
'district_id.gt' => 'store_id必须大于0',
]; ];
protected $scene = [ protected $scene = [
'getCostInfo' => [ 'id', 'type' ], 'getCostInfo' => [ 'id', 'type' ],
'getMyCostDetailList' => [ 'store_id', 'setting_date' ], 'getMyCostDetailList' => [ 'store_id', 'setting_date' ],
'getAllStoreCost' => [ 'district_id' ],
]; ];
} }
\ No newline at end of file
...@@ -105,4 +105,15 @@ class FStoreCost extends BaseModel ...@@ -105,4 +105,15 @@ class FStoreCost extends BaseModel
->where($where) ->where($where)
->sum($field); ->sum($field);
} }
public function getAllStoreCost($field, $where)
{
$where['a.status'] = 0;
return $this->field($field)
->alias('a')
->join('a_store b', 'a.store_id=b.id', 'left')
->join('a_district c', 'b.district_id=c.id', 'left')
->where($where)
->select();
}
} }
...@@ -542,7 +542,7 @@ Route::group('index', [ ...@@ -542,7 +542,7 @@ Route::group('index', [
'getCostDetailList' => ['index/CostDetail/getCostDetailList', ['method' => 'POST|GET']], 'getCostDetailList' => ['index/CostDetail/getCostDetailList', ['method' => 'POST|GET']],
'getCostDetailListExcel' => ['index/CostDetail/getCostDetailListExcel', ['method' => 'POST|GET']], 'getCostDetailListExcel' => ['index/CostDetail/getCostDetailListExcel', ['method' => 'POST|GET']],
'getMyCostDetailList' => ['index/CostDetail/getMyCostDetailList', ['method' => 'POST|GET']], 'getAllStoreCost' => ['index/CostDetail/getAllStoreCost', ['method' => 'POST|GET']],
'getCostInfo' => ['index/CostDetail/getCostInfo', ['method' => 'POST|GET']], 'getCostInfo' => ['index/CostDetail/getCostInfo', ['method' => 'POST|GET']],
'addApplyFor' => ['index/StoreFee/addApplyFor', ['method' => 'POST']],//新增报销申请 'addApplyFor' => ['index/StoreFee/addApplyFor', ['method' => 'POST']],//新增报销申请
......
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