Commit 8f897514 authored by hujun's avatar hujun

新增报销申请

parent d324cc71
......@@ -35,14 +35,14 @@ class StoreFeeService
* @param $card_no
* @param $count_time
* @param $img_arr
* @param int $id
* @return int|string
* @throws \think\Exception
* @throws \think\exception\PDOException
* @throws \app\model\Exception
*/
public function addApplyFor($type, $fee_item, $total_fee, $agent_id, $store_id, $purpose, $site_id, $card_name,
$bank, $card_no, $count_time, $img_arr)
$bank, $card_no, $count_time, $img_arr, $id = 0)
{
$arr = $this->applyForFeeBin(0, $type, $fee_item, $total_fee, $agent_id, $store_id, $purpose, $site_id, $card_name,
$arr = $this->applyForFeeBin($id, $type, $fee_item, $total_fee, $agent_id, $store_id, $purpose, $site_id, $card_name,
$bank, $card_no, $count_time);
$feeId = $this->applyForFeeModel->saveData($arr);
if ($feeId > 0) {
......
......@@ -14,6 +14,7 @@ use think\Validate;
class StoreFeeValidate extends Validate
{
protected $rule = [
'id' => 'require|between:1,999999999',
'type' => 'require|number',
'fee_item' => 'require|number',
'total_fee' => 'require|number',
......@@ -35,10 +36,13 @@ class StoreFeeValidate extends Validate
'store_id.number' => '状门店只能为数字',
'site_id.require' => '站点不能为空',
'site_id.number' => '站点只能为数字',
'id.require' => 'id必传',
'id.between' => '请求参数错误',
];
protected $scene = [
'addApplyFor' => ['type', 'fee_item', 'total_fee', 'agent_id', 'store_id', 'site_id'],
'addApplyFor' => ['type', 'fee_item', 'total_fee', 'agent_id', 'store_id', 'assume_fee', 'site_id'],
'editApplyFor' => ['id','type', 'fee_item', 'total_fee', 'agent_id', 'store_id', 'assume_fee', 'site_id'],
];
}
\ No newline at end of file
......@@ -8,6 +8,8 @@ namespace app\index\controller;
*/
use app\api_broker\service\StoreFeeService;
use app\api_broker\validate\StoreFeeValidate;
use app\index\extend\Basic;
use app\model\AAgents;
use app\model\AStore;
......@@ -309,8 +311,70 @@ class StoreFee extends Basic
return $this->response("200", "成功",$store_result);
}
/**
* @return \think\Response
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function addApplyFor()
{
$params = $this->params;
/* $params = array(
'type' => 1,//费用类型
'fee_item' => 100,//费用项目
'total_fee' => 123.43,//总费用
'purpose' => 111, //详细用途
'agent_id' => 11,//经纪人id
'store_id' => 12,//门店id
'site_id' => 10001, //站点id
'card_name' => "123123",//收款卡户名 非必填
'bank' => "123123",//开户行 非必填
'card_no' => "123123",//银行卡号 非必填
'count_time' => "2019-07-01",//计入日期, pc后台的字段 非必填
'img_arr' => [],//数组模式 同收款一样
);*/
$check_url = ltrim($this->request->baseUrl(), '/');
$validate = new StoreFeeValidate();
$id = 0;
if ($check_url == 'index/addApplyFor') {
$checkResult = $validate->scene("StoreFeeValidate.addApplyFor")->check($params);
} else {
$id = $params['id'];
$checkResult = $validate->scene("StoreFeeValidate.editApplyFor")->check($params);
}
if (true !== $checkResult) {
return $this->response("101", $checkResult);
}
$type = $params["type"];
$fee_item = $params["fee_item"];
$total_fee = $params["total_fee"];
$agent_id = $params["agent_id"];
$store_id = $params["store_id"];
$purpose = $params["purpose"];
$site_id = $params["site_id"];
$card_name = $params["card_name"];
$bank = $params["bank"];
$card_no = $params["card_no"];
$count_time = $params["count_time"];
$img_arr = isset($params["img_arr"]) ? json_decode($params["img_arr"], true) : "";
if (!$img_arr) {
return $this->response("101", "请上传图片");
}
$service_ = new StoreFeeService();
$if_verify = $service_->verifyType($type, $fee_item);
if(!$if_verify){
return $this->response("101", "类型选择错误");
}
$is_ok = $service_->addApplyFor($type, $fee_item, $total_fee, $agent_id, $store_id, $purpose, $site_id, $card_name,
$bank, $card_no, $count_time, $img_arr, $id);
if ($is_ok > 0) {
return $this->response("200", "request success", []);
} else {
return $this->response("101", "save exception");
}
}
}
\ No newline at end of file
......@@ -541,6 +541,8 @@ Route::group('index', [
'getCostDetailList' => [ 'index/CostDetail/getCostDetailList', [ 'method' => 'POST|GET' ] ],
'getCostDetailListExcel' => [ 'index/CostDetail/getCostDetailListExcel', [ 'method' => 'POST|GET' ] ],
'getCostInfo' => [ 'index/CostDetail/getCostInfo', [ 'method' => 'POST|GET' ] ],
'addApplyFor' => ['index/StoreFee/addApplyFor', ['method' => 'POST']],//新增报销申请
'editApplyFor' => ['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