Commit f427db70 authored by clone's avatar clone

申请报销

parent 5fd32b1d
...@@ -3,15 +3,10 @@ ...@@ -3,15 +3,10 @@
namespace app\api_broker\controller; namespace app\api_broker\controller;
use app\api_broker\extend\Basic; use app\api_broker\extend\Basic;
use app\api_broker\service\PushMessageService; use app\api_broker\service\StoreFeeService;
use app\api_broker\service\ReportService;
use app\api_broker\service\VipService;
use app\index\service\UserService; use app\index\service\UserService;
use app\model\AAgents; use app\model\AAgents;
use app\model\FollowUpLogModel; use app\model\FollowUpLogModel;
use app\model\GHousesToAgents;
use app\model\OReportModel;
use think\Exception;
/** /**
* Created by PhpStorm. * Created by PhpStorm.
...@@ -30,24 +25,23 @@ class StoreFee extends Basic ...@@ -30,24 +25,23 @@ class StoreFee extends Basic
public function __construct($request = null) public function __construct($request = null)
{ {
parent::__construct($request); parent::__construct($request);
$this->service_ = new ReportService(); $this->service_ = new StoreFeeService();
$this->fulModel = new FollowUpLogModel(); $this->fulModel = new FollowUpLogModel();
$this->userService = new UserService(); $this->userService = new UserService();
} }
/** /**
* 报备
* @return \think\Response * @return \think\Response
* @throws \think\db\exception\DataNotFoundException * @throws \think\Exception
* @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\PDOException
* @throws \think\exception\DbException
*/ */
public function report() public function addApplyFor()
{ {
$params = $this->params; $params = $this->params;
$params = array( /* $params = array(
'type' => 1, 'type' => 1,
'fee_item' => 100, 'fee_item' => 100,
'total_fee' => 123.43, 'total_fee' => 123.43,
...@@ -55,46 +49,38 @@ class StoreFee extends Basic ...@@ -55,46 +49,38 @@ class StoreFee extends Basic
'store_id' => 12, 'store_id' => 12,
'assume_fee' => 111, 'assume_fee' => 111,
'site_id' => 10001, 'site_id' => 10001,
); 'card_name' => "123123",//收款卡户名
'bank' => "123123",//开户行
'card_no' => "123123",//银行卡号
'count_time' => "2019-07-01",
'img_arr' => ["111"],//数组模式
);*/
$checkResult = $this->validate($params, "StoreFeeValidate.addApplyFor"); $checkResult = $this->validate($params, "StoreFeeValidate.addApplyFor");
if (true !== $checkResult) { if (true !== $checkResult) {
return $this->response("101", $checkResult); return $this->response("101", $checkResult);
} }
$type = $params["type"]; $type = $params["type"];
$fee_item = $params["fee_item"]; $fee_item = $params["fee_item"];
$total_fee = $params["total_fee"]; $total_fee = $params["total_fee"];
$agent_id = $params["agent_id"]; $agent_id = $params["agent_id"];
$store_id = $params["store_id"]; $store_id = $params["store_id"];
$assume_fee = $params["vehicle"]; $assume_fee = $params["vehicle"];
$site_id = $params["assume_fee"]; $site_id = $params["assume_fee"];
$predict_see_time = $params["site_id"]; $card_name = $params["card_name"];
$bank = $params["bank"];
//todo 验证用户id是否正常 $card_no = $params["card_no"];
/* $userArr = $this->service_->verifyUser($user_id); $count_time = $params["count_time"];
if (!$userArr) { $img_arr = isset($params["img_arr"]) ? json_decode($params["img_arr"], true) : "";
return $this->response("101", "不存在此用户"); if(!$img_arr){
return $this->response("101", "请上传图片");
} }
$is_ok = $this->service_->verifyReport($agent_id, $agent_phone, $this->agentName, $store_id, $user_id, $userArr["user_phone"], $is_ok = $this->service_->addApplyFor($type, $fee_item, $total_fee, $agent_id, $store_id, $assume_fee, $site_id, $card_name,
$userArr["user_name"], $house_ids, $vehicle, $intro, $predict_see_time); $bank, $card_no, $count_time,$img_arr);
if ($is_ok > 0) { if ($is_ok > 0) {
$this->userService->setUserSites($user_id, $this->siteId);//设置用户站点 朱伟 2018-10-22
$push = new PushMessageService();
$house_ids_arr = explode(',', $house_ids);
if (is_array($house_ids_arr)) {
foreach ($house_ids_arr as $k => $v) {
$push->pushReportMessage($v, $agent_id, 1, $this->agentId, $user_id); //推送报备信息
}
}
`
return $this->response("200", "request success", []); return $this->response("200", "request success", []);
} else { } else {
return $this->response("101", "save exception"); return $this->response("101", "save exception");
}*/ }
} }
/** /**
......
<?php
namespace app\api_broker\service;
use app\model\FApplyForFee;
use app\model\FImg;
/**
* Created by PhpStorm.
* User: zw
* Date: 2019/7/22
* Time: 10:16
*/
class StoreFeeService
{
private $applyForFeeModel;
private $imgModel;
public function __construct()
{
$this->applyForFeeModel = new FApplyForFee();
$this->imgModel = new FImg();
}
/**
* @param $type
* @param $fee_item
* @param $total_fee
* @param $agent_id
* @param $store_id
* @param $assume_fee
* @param $site_id
* @param $card_name
* @param $bank
* @param $card_no
* @param $count_time
* @param $img_arr
* @return int|string
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function addApplyFor($type, $fee_item, $total_fee, $agent_id, $store_id, $assume_fee, $site_id, $card_name,
$bank, $card_no, $count_time, $img_arr)
{
$arr = $this->applyForFeeBin(0, $type, $fee_item, $total_fee, $agent_id, $store_id, $assume_fee, $site_id, $card_name,
$bank, $card_no, $count_time);
$feeId = $this->applyForFeeModel->saveData($arr);
if ($feeId > 0) {
$this->imgModel->addImgAll($feeId,1,$img_arr);
}
return $feeId;
}
/**
* @param $id
* @param $type
* @param $fee_item
* @param $total_fee
* @param $agent_id
* @param $store_id
* @param $assume_fee
* @param $site_id
* @param $card_name
* @param $bank
* @param $card_no
* @param $count_time
* @return array
*/
private function applyForFeeBin($id, $type, $fee_item, $total_fee, $agent_id, $store_id, $assume_fee, $site_id, $card_name,
$bank, $card_no, $count_time)
{
$arr = [];
if ($type) {
$arr["type"] = $type;
}
if ($fee_item) {
$arr["fee_item"] = $fee_item;
}
if ($total_fee) {
$arr["total_fee"] = $total_fee;
}
if ($agent_id) {
$arr["agent_id"] = $agent_id;
}
if ($store_id) {
$arr["store_id"] = $store_id;
}
if ($site_id) {
$arr["site_id"] = $site_id;
}
if ($assume_fee) {
$arr["assume_fee"] = $assume_fee;
}
if ($card_name) {
$arr["card_name"] = $card_name;
}
if ($bank) {
$arr["bank"] = $bank;
}
if ($card_no) {
$arr["card_no"] = $card_no;
}
if ($count_time) {
$arr["count_time"] = $count_time;
} elseif ($id <= 0 && !$count_time) {
$arr["count_time"] = date("Y-m-01", time());
}
$arr["update_time"] = date("Y-m-d H:i:s", time());
if ($id <= 0) {
$arr["create_time"] = date("Y-m-d H:i:s", time());
}
return $arr;
}
}
\ No newline at end of file
...@@ -23,8 +23,6 @@ class FApplyForFee extends BaseModel ...@@ -23,8 +23,6 @@ class FApplyForFee extends BaseModel
* @throws \think\exception\PDOException * @throws \think\exception\PDOException
*/ */
public function saveData($data) { public function saveData($data) {
$data["is_del"] = 0;
$data['create_time'] = date("Y-m-d H:i:s", time());
$id = $this->db_->insertGetId($data); $id = $this->db_->insertGetId($data);
return $id; return $id;
} }
......
...@@ -22,14 +22,63 @@ class FImg extends BaseModel ...@@ -22,14 +22,63 @@ class FImg extends BaseModel
* @param $data * @param $data
* @return mixed * @return mixed
*/ */
public function saveOffice($data) { public function saveImg($data) {
$time = date("Y-m-d H:i:s", time()); $time = date("Y-m-d H:i:s", time());
$data["is_del"] = 0;
$data['create_time'] = $time; $data['create_time'] = $time;
$data['update_time'] = $time; $data['update_time'] = $time;
return $this->db_->insert($data); return $this->db_->insert($data);
} }
public function addImgAll(int $img_id, int $img_type, array $params): int
{
$imgBin = [];
foreach ($params as $item) {
$insert_["img_id"] = $img_id;
$insert_["img_type"] = $img_type;
$insert_["img_name"] = $item;
$insert_["img_status"] = 0;
array_push($imgBin, $this->imgBin($insert_));
}
Db::startTrans();
try {
$this->saveAll($imgBin);
Db::commit();
return 1;
} catch (Exception $exception) {
Db::rollback();
throw $exception;
}
}
/**
* bin
* @param $params
* @return array
*/
private function imgBin($params)
{
$arr = [];
if (isset($params["id"])) {
$arr["id"] = $params["id"];
} else {
$arr["create_time"] = date("Y-m-d H:i:s", time());
}
if (isset($params["img_id"])) {
$arr["img_id"] = $params["img_id"];
}
if (isset($params["img_type"])) {
$arr["img_type"] = $params["img_type"];
}
if (isset($params["img_name"])) {
$arr["img_name"] = $params["img_name"];
}
if (isset($params["img_status"])) {
$arr["img_status"] = $params["img_status"];
}
$arr["update_time"] = date("Y-m-d H:i:s", time());
return $arr;
}
/** /**
* 查询单条数据 * 查询单条数据
* 朱伟 2018-10-18 10:41:10 * 朱伟 2018-10-18 10:41:10
......
...@@ -994,6 +994,9 @@ Route::group('broker', [ ...@@ -994,6 +994,9 @@ Route::group('broker', [
'moveHouseAgent' => ['api_broker/User/moveHouseAgent', ['method' => 'GET|POST']],//客方同步到新表 'moveHouseAgent' => ['api_broker/User/moveHouseAgent', ['method' => 'GET|POST']],//客方同步到新表
'moveHouseSiteId' => ['api_broker/User/moveHouseSiteId', ['method' => 'GET|POST']],//站点同步到新表 'moveHouseSiteId' => ['api_broker/User/moveHouseSiteId', ['method' => 'GET|POST']],//站点同步到新表
'getFindShopListIsMy' => ['api_broker/FindShop/getFindShopList', ['method' => 'GET']],//委托找铺 'getFindShopListIsMy' => ['api_broker/FindShop/getFindShopList', ['method' => 'GET']],//委托找铺
'addApplyFor' => ['api_broker/StoreFee/addApplyFor', ['method' => 'GET']],//新增报销申请
]); ]);
Route::group('search', [ Route::group('search', [
......
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