Commit 48d40704 authored by clone's avatar clone

1

parent d85f113b
<?php <?php
namespace app\api_broker\controller; namespace app\api_broker\controller;
/** /**
* Created by PhpStorm. * Created by PhpStorm.
...@@ -17,6 +18,7 @@ use think\Request; ...@@ -17,6 +18,7 @@ use think\Request;
class Amercement extends Basic class Amercement extends Basic
{ {
protected $s_amercement; protected $s_amercement;
public function __construct($request = null) public function __construct($request = null)
{ {
parent::__construct($request); parent::__construct($request);
...@@ -28,27 +30,28 @@ class Amercement extends Basic ...@@ -28,27 +30,28 @@ class Amercement extends Basic
* @return \think\Response * @return \think\Response
* http://showdoc.tonglianjituan.com/index.php?s=/1&page_id=918 * http://showdoc.tonglianjituan.com/index.php?s=/1&page_id=918
*/ */
public function addAmercement(){ public function addAmercement()
{
$params = $this->params; $params = $this->params;
/* $params = array( /* $params = array(
"type" => 1, "type" => 1,
"money" => 200, "money" => 200,
"agent_id" => 5776, "agent_id" => 5776,
"remarks" => '理由', "remarks" => '理由',
"img" => '["20190902\\/20190902161242125.jpg","20190902\\/201909021612421258499.jpg"]', "img" => '["20190902\\/20190902161242125.jpg","20190902\\/201909021612421258499.jpg"]',
);*/ );*/
$checkResult = $this->validate($params, "AmercementValidate.addAmercement"); $checkResult = $this->validate($params, "AmercementValidate.addAmercement");
if (true !== $checkResult) { if (true !== $checkResult) {
return $this->response("101", $checkResult); return $this->response("101", $checkResult);
} }
$vip = new VipService();//0:有权限 1:无权限 $vip = new VipService();//0:有权限 1:无权限
$is_can_edit = $vip->checkRule($this->agentId, 'addAmercement'); $is_can_edit = $vip->checkRule($this->agentId, 'addAmercement');
if($is_can_edit == 1){ if ($is_can_edit == 1) {
return $this->response("101", "暂无权限"); return $this->response("101", "暂无权限");
} }
$father_id = $this->s_amercement->addAmercement($params,$this->agentId);//int(1) $father_id = $this->s_amercement->addAmercement($params, $this->agentId);//int(1)
if ($father_id) { if ($father_id) {
if (isset($params['img']) && !empty($params['img'])) { if (isset($params['img']) && !empty($params['img'])) {
$this->s_amercement->addAmercementImg($params['img'], $father_id); $this->s_amercement->addAmercementImg($params['img'], $father_id);
...@@ -64,9 +67,10 @@ class Amercement extends Basic ...@@ -64,9 +67,10 @@ class Amercement extends Basic
* 获取类型 * 获取类型
* @return \think\Response * @return \think\Response
*/ */
public function getAmercementType(){ public function getAmercementType()
{
$res = $this->s_amercement->getAmercementType(); $res = $this->s_amercement->getAmercementType();
return $this->response("200", "成功",$res); return $this->response("200", "成功", $res);
} }
...@@ -74,7 +78,8 @@ class Amercement extends Basic ...@@ -74,7 +78,8 @@ class Amercement extends Basic
* 罚款账单 * 罚款账单
* @return \think\Response * @return \think\Response
*/ */
public function getAmercementList(){ public function getAmercementList()
{
$params = $this->params; $params = $this->params;
// $params = array( // $params = array(
...@@ -87,14 +92,48 @@ class Amercement extends Basic ...@@ -87,14 +92,48 @@ class Amercement extends Basic
return $this->response("300", $checkResult); return $this->response("300", $checkResult);
} }
$page_no = empty($params["page_no"]) ? 1 : $params["page_no"]; $page_no = empty($params["page_no"]) ? 1 : $params["page_no"];
$page_size = empty($params["page_size"]) ? 15 : $params["page_size"]; $page_size = empty($params["page_size"]) ? 15 : $params["page_size"];
$status = $params['status']; $status = $params['status'];
$amercement_type = $params['amercement_type'];//0我需要支付的 1我提交的 $amercement_type = $params['amercement_type'];//0我需要支付的 1我提交的
$result = $this->s_amercement->getAmercementList($status,$amercement_type,$params['agent_id'], $page_no, $page_size);//int(1) $result = $this->s_amercement->getAmercementList($status, $amercement_type, $params['agent_id'], $page_no, $page_size);//int(1)
return $this->response("200", "成功",$result); return $this->response("200", "成功", $result);
}
public function savePayAmercement()
{
$params = $this->params;
/* $params = array(
"amercement_id" => 11,
"trade_no" => "12323123123",
"pay_type" => 1,//支付类型 1支付宝 2微信
"status" => 0,
"remark" => "qweqweqweqwe",
"pay_money" => 111,
"pay_time" => 111,
);*/
$checkResult = $this->validate($params, "AmercementValidate.savePayAmercement");
if (true !== $checkResult) {
return $this->response("101", $checkResult);
}
$amercement_id = $params["amercement_id"];
$trade_no = $params["trade_no"];
$pay_type = $params["pay_type"];//支付类型 1支付宝 2微信
$status = $params["status"];
$remark = $params["remark"];
$pay_money = $params["pay_money"];
$pay_time = $params["pay_time"];
$result = $this->s_amercement->savePayAmercement($amercement_id, $trade_no, $pay_type, $status, $remark, $pay_money, $pay_time);
if ($result) {
return $this->response("200", "成功", $result);
} else {
return $this->response("101", "保存失败,请求异常");
}
} }
......
<?php <?php
namespace app\api_broker\validate; namespace app\api_broker\validate;
use think\Validate; use think\Validate;
/** /**
...@@ -8,15 +10,22 @@ use think\Validate; ...@@ -8,15 +10,22 @@ use think\Validate;
* Date: 2019-09-02 * Date: 2019-09-02
* Time: 16:27:00 * Time: 16:27:00
*/ */
class AmercementValidate extends Validate{ class AmercementValidate extends Validate
{
protected $rule = [ protected $rule = [
'type' => 'require|number|in:0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17', 'type' => 'require|number|in:0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17',
'money' => 'require|number|gt:0', 'money' => 'require|number|gt:0',
'agent_id' => 'require|number|gt:0', 'agent_id' => 'require|number|gt:0',
'remarks' => 'require', 'remarks' => 'require',
'status' => 'require|number|in:0,1,2', 'status' => 'require|number|in:0,1,2',
'amercement_type' => 'require|number|in:0,1', 'amercement_type' => 'require|number|in:0,1',
'amercement_id' => 'require|number',
'trade_no' => 'require',
'pay_type' => 'require|number|in:1,2',
'pay_money' => 'require|number|gt:0',
'pay_time' => 'require',
]; ];
...@@ -44,10 +53,26 @@ class AmercementValidate extends Validate{ ...@@ -44,10 +53,26 @@ class AmercementValidate extends Validate{
'amercement_type.number' => 'amercement_type只能为数字', 'amercement_type.number' => 'amercement_type只能为数字',
'amercement_type.in' => 'amercement_type范围错误', 'amercement_type.in' => 'amercement_type范围错误',
'amercement_id.require' => 'amercement_id为必填字段',
'amercement_id.number' => 'amercement_id只能为数字',
'trade_no.require' => 'trade_no只能为数字',
'pay_type.require' => 'pay_type为必填字段',
'pay_type.number' => 'pay_type只能为数字',
'pay_type.in' => 'pay_type范围错误',
'pay_money.require' => 'pay_money为必填字段',
'pay_money.number' => 'pay_money只能为数字',
'pay_money.gt' => 'pay_money必须大于0',
'pay_time.require' => 'pay_time为必填字段',
]; ];
protected $scene = [ protected $scene = [
'addAmercement' => [ 'type', 'money', 'agent_id', 'remarks'], 'addAmercement' => ['type', 'money', 'agent_id', 'remarks'],
'getAmercementList' => [ 'agent_id', 'status', 'amercement_type'], 'getAmercementList' => ['agent_id', 'status', 'amercement_type'],
'savePayAmercement' => ['amercement_id', 'trade_no', 'pay_type', 'pay_money', 'pay_time'],
]; ];
} }
...@@ -26,7 +26,7 @@ class AmercementService ...@@ -26,7 +26,7 @@ class AmercementService
public function __construct() public function __construct()
{ {
$this->m_amercement = new OAmercementModel(); $this->m_amercement = new OAmercementModel();
$this->m_amercement_img = new OAmercementImgModel(); $this->m_amercement_img = new OAmercementImgModel();
if (CURRENT_URL == 'https://api.tonglianjituan.com/') { if (CURRENT_URL == 'https://api.tonglianjituan.com/') {
...@@ -43,23 +43,23 @@ class AmercementService ...@@ -43,23 +43,23 @@ class AmercementService
public function getAmercementType() public function getAmercementType()
{ {
return [ return [
['id'=>'1','name'=>'班主任早会监督'], ['id' => '1', 'name' => '班主任早会监督'],
['id'=>'2','name'=>'晚会表监督'], ['id' => '2', 'name' => '晚会表监督'],
['id'=>'3','name'=>'学习视频监督'], ['id' => '3', 'name' => '学习视频监督'],
['id'=>'4','name'=>'投诉'], ['id' => '4', 'name' => '投诉'],
['id'=>'5','name'=>'日报'], ['id' => '5', 'name' => '日报'],
['id'=>'6','name'=>'房源上架'], ['id' => '6', 'name' => '房源上架'],
['id'=>'7','name'=>'视频审核'], ['id' => '7', 'name' => '视频审核'],
['id'=>'8','name'=>'商学院评论'], ['id' => '8', 'name' => '商学院评论'],
['id'=>'9','name'=>'弟子班自律'], ['id' => '9', 'name' => '弟子班自律'],
['id'=>'10','name'=>'弟子班心得评论'], ['id' => '10', 'name' => '弟子班心得评论'],
['id'=>'11','name'=>'将帅赢心得评论'], ['id' => '11', 'name' => '将帅赢心得评论'],
['id'=>'12','name'=>'各项会议处罚机制'], ['id' => '12', 'name' => '各项会议处罚机制'],
['id'=>'13','name'=>'五星好评'], ['id' => '13', 'name' => '五星好评'],
['id'=>'14','name'=>'投诉暂扣'], ['id' => '14', 'name' => '投诉暂扣'],
['id'=>'15','name'=>'独家协议'], ['id' => '15', 'name' => '独家协议'],
['id'=>'16','name'=>'其他处罚'], ['id' => '16', 'name' => '其他处罚'],
]; ];
} }
public function getTypeName($type) public function getTypeName($type)
...@@ -136,6 +136,7 @@ class AmercementService ...@@ -136,6 +136,7 @@ class AmercementService
} }
return $str; return $str;
} }
/** /**
* 新增 * 新增
* *
...@@ -143,15 +144,15 @@ class AmercementService ...@@ -143,15 +144,15 @@ class AmercementService
* @param $submit_agent_id * @param $submit_agent_id
* @return int|string * @return int|string
*/ */
public function addAmercement($params,$submit_agent_id) public function addAmercement($params, $submit_agent_id)
{ {
$params_['status'] = 0;//'状态 0待支付 1已支付 2已取消' $params_['status'] = 0;//'状态 0待支付 1已支付 2已取消'
$params_['type'] = $params['type'];//'罚款类型 $params_['type'] = $params['type'];//'罚款类型
$params_['money'] = $params['money'];//罚款金额 $params_['money'] = $params['money'];//罚款金额
$params_['submit_agent_id'] = $submit_agent_id;//提交人 $params_['submit_agent_id'] = $submit_agent_id;//提交人
$params_['agent_id'] = $params['agent_id'];//被罚款人 $params_['agent_id'] = $params['agent_id'];//被罚款人
$params_['remarks'] = $params['remarks'];//备注 $params_['remarks'] = $params['remarks'];//备注
$id = $this->m_amercement->saveAmercement($params_); $id = $this->m_amercement->saveAmercement($params_);
$push = new PushMessageService(); $push = new PushMessageService();
$push->pushAmercementMessage($params['agent_id'], $id, $submit_agent_id); //推送 $push->pushAmercementMessage($params['agent_id'], $id, $submit_agent_id); //推送
...@@ -164,16 +165,17 @@ class AmercementService ...@@ -164,16 +165,17 @@ class AmercementService
* @param $father_id * @param $father_id
* @return bool * @return bool
*/ */
public function addAmercementImg($img_info,$father_id){ public function addAmercementImg($img_info, $father_id)
if(!$img_info) {
if (!$img_info)
return false; return false;
$sublet_img = json_decode($img_info, true); $sublet_img = json_decode($img_info, true);
if(!$sublet_img) if (!$sublet_img)
return false; return false;
foreach ($sublet_img as $k=>$v){ foreach ($sublet_img as $k => $v) {
$insert=[]; $insert = [];
$insert["file_name"] = $v; $insert["file_name"] = $v;
$insert["amercement_id"] = $father_id; $insert["amercement_id"] = $father_id;
$this->m_amercement_img->saveAmercementImg($insert); $this->m_amercement_img->saveAmercementImg($insert);
} }
...@@ -190,18 +192,18 @@ class AmercementService ...@@ -190,18 +192,18 @@ class AmercementService
* @param $page_size * @param $page_size
* @return array|false|\PDOStatement|string|\think\Collection * @return array|false|\PDOStatement|string|\think\Collection
*/ */
public function getAmercementList($status,$amercement_type,$agent_id, $page_no, $page_size) public function getAmercementList($status, $amercement_type, $agent_id, $page_no, $page_size)
{ {
$field = "id,status,type,money,submit_agent_id,agent_id,remarks,create_time,forfeit_penalty,money_sum"; $field = "id,status,type,money,submit_agent_id,agent_id,remarks,create_time,forfeit_penalty,money_sum";
$condition = []; $condition = [];
if($amercement_type == 0){ if ($amercement_type == 0) {
$condition ['agent_id']= $agent_id; $condition ['agent_id'] = $agent_id;
}else{ } else {
$condition ['submit_agent_id']= $agent_id; $condition ['submit_agent_id'] = $agent_id;
} }
$condition ['status']= $status; $condition ['status'] = $status;
$result = $this->m_amercement->getAmercementList($condition, $field, $page_no, $page_size); $result = $this->m_amercement->getAmercementList($condition, $field, $page_no, $page_size);
if(!$result){ if (!$result) {
return []; return [];
} }
...@@ -210,19 +212,19 @@ class AmercementService ...@@ -210,19 +212,19 @@ class AmercementService
foreach ($result as $key => $val) { foreach ($result as $key => $val) {
$result[$key]['type_name'] = $this->getTypeName($val['type']); $result[$key]['type_name'] = $this->getTypeName($val['type']);
$agent_data = $redis_cache->getRedisCache(2, $val['submit_agent_id']); $agent_data = $redis_cache->getRedisCache(2, $val['submit_agent_id']);
$result[$key]['submit_agent_name'] = $agent_data['name']; $result[$key]['submit_agent_name'] = $agent_data['name'];
$result[$key]['submit_agent_phone'] = $agent_data['phone']; $result[$key]['submit_agent_phone'] = $agent_data['phone'];
if($status == 0){//待支付 if ($status == 0) {//待支付
$now_time = date("Y-m-d H:i:s", time()); $now_time = date("Y-m-d H:i:s", time());
$forfeit_penalty = $this->updateForfeitPenalty($val['id'],$val['create_time'],$now_time,$val['money']); $forfeit_penalty = $this->updateForfeitPenalty($val['id'], $val['create_time'], $now_time, $val['money']);
$result[$key]['forfeit_penalty'] = $forfeit_penalty;//滞纳金 $result[$key]['forfeit_penalty'] = $forfeit_penalty;//滞纳金
$money_sum = $forfeit_penalty + $result[$key]['money']; $money_sum = $forfeit_penalty + $result[$key]['money'];
$result[$key]['money_sum'] = $money_sum;//罚款总金额 $result[$key]['money_sum'] = $money_sum;//罚款总金额
$this->updateAmercement($val['id'],['money_sum'=>$money_sum]); $this->updateAmercement($val['id'], ['money_sum' => $money_sum]);
} }
$result[$key]['img'] = $this->getAmercementImage($val['id']); $result[$key]['img'] = $this->getAmercementImage($val['id']);
} }
...@@ -238,15 +240,15 @@ class AmercementService ...@@ -238,15 +240,15 @@ class AmercementService
* @param $money * @param $money
* @return int|number * @return int|number
*/ */
public function updateForfeitPenalty($id,$time,$now_time,$money) public function updateForfeitPenalty($id, $time, $now_time, $money)
{ {
$forfeit_penalty = 0; $forfeit_penalty = 0;
$num = $this->diffBetweenTwoDays ($time, $now_time); $num = $this->diffBetweenTwoDays($time, $now_time);
if(($num > 0) && ($money > 0)){ if (($num > 0) && ($money > 0)) {
$money_every_day = $money * 0.2; $money_every_day = $money * 0.2;
$forfeit_penalty = $num * $money_every_day; $forfeit_penalty = $num * $money_every_day;
} }
$this->updateAmercement($id,['forfeit_penalty'=>$forfeit_penalty]); $this->updateAmercement($id, ['forfeit_penalty' => $forfeit_penalty]);
return $forfeit_penalty; return $forfeit_penalty;
} }
...@@ -258,8 +260,8 @@ class AmercementService ...@@ -258,8 +260,8 @@ class AmercementService
*/ */
public function getAmercementImage($id) public function getAmercementImage($id)
{ {
$where['amercement_id'] = $id; $where['amercement_id'] = $id;
$img_data = $this->m_amercement_img->getListAll('id,file_name', $where); $img_data = $this->m_amercement_img->getListAll('id,file_name', $where);
if ($img_data) { if ($img_data) {
foreach ($img_data as $k => $v) { foreach ($img_data as $k => $v) {
$img_data[$k]['image_path'] = $this->internet_path . $v['file_name']; $img_data[$k]['image_path'] = $this->internet_path . $v['file_name'];
...@@ -270,30 +272,30 @@ class AmercementService ...@@ -270,30 +272,30 @@ class AmercementService
public function getAmercementInfo($id) public function getAmercementInfo($id)
{ {
$conditions =[]; $conditions = [];
$conditions["id"] = $id; $conditions["id"] = $id;
$field = "id,status,type,money,submit_agent_id,agent_id,remarks,create_time, $field = "id,status,type,money,submit_agent_id,agent_id,remarks,create_time,
operation_id,operation_time,forfeit_penalty,money_sum"; operation_id,operation_time,forfeit_penalty,money_sum";
$result = $this->m_amercement->getAmercementInfo($conditions, $field); $result = $this->m_amercement->getAmercementInfo($conditions, $field);
if(!$result){ if (!$result) {
return false; return false;
} }
$redis_cache = new RedisCacheService(); $redis_cache = new RedisCacheService();
$result['type_name'] = $this->getTypeName($result['type']); $result['type_name'] = $this->getTypeName($result['type']);
$result['status_name'] = $this->getStatusName($result['status']); $result['status_name'] = $this->getStatusName($result['status']);
$agent_data = $redis_cache->getRedisCache(2, $result['submit_agent_id']); $agent_data = $redis_cache->getRedisCache(2, $result['submit_agent_id']);
$result['submit_agent_name'] = $agent_data['name']; $result['submit_agent_name'] = $agent_data['name'];
$agent_data = $redis_cache->getRedisCache(2, $result['agent_id']); $agent_data = $redis_cache->getRedisCache(2, $result['agent_id']);
$result['agent_name'] = $agent_data['name']; $result['agent_name'] = $agent_data['name'];
if ($result['status'] == 1) {//已支付 if ($result['status'] == 1) {//已支付
$result['pay_time'] = ''; $result['pay_time'] = '';
$result['operation_name'] = ''; $result['operation_name'] = '';
if ($result['operation_id']) { if ($result['operation_id']) {
$agent_data = $redis_cache->getRedisCache(2, $result['operation_id']); $agent_data = $redis_cache->getRedisCache(2, $result['operation_id']);
$result['operation_name'] = $agent_data['name']; $result['operation_name'] = $agent_data['name'];
} }
} }
...@@ -310,17 +312,17 @@ class AmercementService ...@@ -310,17 +312,17 @@ class AmercementService
* @param $operation_id * @param $operation_id
* @return array * @return array
*/ */
public function editAmercement($id,$params,$edit_type,$operation_id) public function editAmercement($id, $params, $edit_type, $operation_id)
{ {
switch ($edit_type) { switch ($edit_type) {
case 0 : case 0 :
//0编辑 //0编辑
$this->updateAmercement($id,$params); $this->updateAmercement($id, $params);
if(isset($params['img']) && !empty($params['img'])){ if (isset($params['img']) && !empty($params['img'])) {
//处理图片 //处理图片
$result_img = $this->getAmercementImage($id); $result_img = $this->getAmercementImage($id);
if(!$result_img){ if (!$result_img) {
break; break;
} }
$list_img = []; $list_img = [];
...@@ -329,9 +331,9 @@ class AmercementService ...@@ -329,9 +331,9 @@ class AmercementService
} }
$params_img = json_decode($params['img'], true); $params_img = json_decode($params['img'], true);
foreach ($params_img as $key => $val) { foreach ($params_img as $key => $val) {
if(!in_array($val,$list_img)){ if (!in_array($val, $list_img)) {
$insert=[]; $insert = [];
$insert["file_name"] = $val; $insert["file_name"] = $val;
$insert["amercement_id"] = $id; $insert["amercement_id"] = $id;
$this->m_amercement_img->saveAmercementImg($insert); $this->m_amercement_img->saveAmercementImg($insert);
} }
...@@ -344,9 +346,9 @@ class AmercementService ...@@ -344,9 +346,9 @@ class AmercementService
break; break;
default : default :
//2转已支付 //2转已支付
$this->consummationAmercement($id,$operation_id); $this->consummationAmercement($id, $operation_id);
} }
return ['code'=>200,'msg'=>'成功']; return ['code' => 200, 'msg' => '成功'];
} }
/** /**
...@@ -355,13 +357,13 @@ class AmercementService ...@@ -355,13 +357,13 @@ class AmercementService
* @param $params * @param $params
* @return bool money_sum * @return bool money_sum
*/ */
public function updateAmercement($id,$params) public function updateAmercement($id, $params)
{ {
$data = []; $data = [];
if ((isset($params['money'])) && ($params['money'] > 0)) if ((isset($params['money'])) && ($params['money'] > 0))
$data['money'] = $params['money']; $data['money'] = $params['money'];
if ((isset($params['type'])) && (in_array($params['type'], [ 0, 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 ]))) if ((isset($params['type'])) && (in_array($params['type'], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16])))
$data['type'] = $params['type']; $data['type'] = $params['type'];
if ((isset($params['remarks'])) && $params['remarks']) if ((isset($params['remarks'])) && $params['remarks'])
...@@ -389,8 +391,8 @@ class AmercementService ...@@ -389,8 +391,8 @@ class AmercementService
*/ */
public function cancelAmercement($id) public function cancelAmercement($id)
{ {
$data = []; $data = [];
$data['id'] = $id; $data['id'] = $id;
$data['status'] = 2; $data['status'] = 2;
$this->m_amercement->updateAmercementData($data); $this->m_amercement->updateAmercementData($data);
return true; return true;
...@@ -403,12 +405,12 @@ class AmercementService ...@@ -403,12 +405,12 @@ class AmercementService
* @param $operation_id * @param $operation_id
* @return bool * @return bool
*/ */
public function consummationAmercement($id,$operation_id) public function consummationAmercement($id, $operation_id)
{ {
$data = []; $data = [];
$data['id'] = $id; $data['id'] = $id;
$data['status'] = 1; $data['status'] = 1;
$data['operation_id'] = $operation_id; $data['operation_id'] = $operation_id;
$data['operation_time'] = date("Y-m-d H:i:s", time()); $data['operation_time'] = date("Y-m-d H:i:s", time());
$this->m_amercement->updateAmercementData($data); $this->m_amercement->updateAmercementData($data);
return true; return true;
...@@ -421,31 +423,31 @@ class AmercementService ...@@ -421,31 +423,31 @@ class AmercementService
* @param $page_size * @param $page_size
* @return false|\PDOStatement|string|\think\Collection * @return false|\PDOStatement|string|\think\Collection
*/ */
public function getAmercementListPc($params,$page_no, $page_size) public function getAmercementListPc($params, $page_no, $page_size)
{ {
$conditions = $this->buildConditions($params); $conditions = $this->buildConditions($params);
$field = "id,status,type,money,submit_agent_id,agent_id,remarks,create_time,forfeit_penalty,money_sum"; $field = "id,status,type,money,submit_agent_id,agent_id,remarks,create_time,forfeit_penalty,money_sum";
$result = $this->m_amercement->getAmercementList($conditions, $field, $page_no, $page_size); $result = $this->m_amercement->getAmercementList($conditions, $field, $page_no, $page_size);
$redis_cache = new RedisCacheService(); $redis_cache = new RedisCacheService();
foreach ($result as $key => $val) { foreach ($result as $key => $val) {
if($val['status'] == 0){ if ($val['status'] == 0) {
$now_time = date("Y-m-d H:i:s", time()); $now_time = date("Y-m-d H:i:s", time());
$forfeit_penalty = $this->updateForfeitPenalty($val['id'],$val['create_time'],$now_time,$val['money']); $forfeit_penalty = $this->updateForfeitPenalty($val['id'], $val['create_time'], $now_time, $val['money']);
$result[$key]['forfeit_penalty'] = $forfeit_penalty; $result[$key]['forfeit_penalty'] = $forfeit_penalty;
$money_sum = $forfeit_penalty + $val['money']; $money_sum = $forfeit_penalty + $val['money'];
$result[$key]['money_sum'] = $money_sum;//罚款总金额 $result[$key]['money_sum'] = $money_sum;//罚款总金额
$this->updateAmercement($val['id'],['money_sum'=>$money_sum]); $this->updateAmercement($val['id'], ['money_sum' => $money_sum]);
} }
$result[$key]['type_name'] = $this->getTypeName($val['type']); $result[$key]['type_name'] = $this->getTypeName($val['type']);
$result[$key]['status_name'] = $this->getStatusName($val['status']); $result[$key]['status_name'] = $this->getStatusName($val['status']);
$agent_data = $redis_cache->getRedisCache(2, $val['submit_agent_id']); $agent_data = $redis_cache->getRedisCache(2, $val['submit_agent_id']);
$result[$key]['submit_agent_name'] = $agent_data['name']; $result[$key]['submit_agent_name'] = $agent_data['name'];
$agent_data = $redis_cache->getRedisCache(2, $val['agent_id']); $agent_data = $redis_cache->getRedisCache(2, $val['agent_id']);
$result[$key]['agent_name'] = $agent_data['name']; $result[$key]['agent_name'] = $agent_data['name'];
$result[$key]['money_sum'] = $result[$key]['forfeit_penalty'] + $val['money'];//罚款总金额 $result[$key]['money_sum'] = $result[$key]['forfeit_penalty'] + $val['money'];//罚款总金额
} }
...@@ -462,28 +464,28 @@ class AmercementService ...@@ -462,28 +464,28 @@ class AmercementService
*/ */
public function getAmercementListExcel($params) public function getAmercementListExcel($params)
{ {
$conditions=$this->buildConditions($params); $conditions = $this->buildConditions($params);
$field = "id,status,type,money,submit_agent_id,agent_id,remarks,create_time,forfeit_penalty"; $field = "id,status,type,money,submit_agent_id,agent_id,remarks,create_time,forfeit_penalty";
$result = $this->m_amercement->getAmercementListExcel($conditions, $field); $result = $this->m_amercement->getAmercementListExcel($conditions, $field);
$redis_cache = new RedisCacheService(); $redis_cache = new RedisCacheService();
foreach ($result as $key => $val) { foreach ($result as $key => $val) {
if($val['status'] == 0){ if ($val['status'] == 0) {
$now_time = date("Y-m-d H:i:s", time()); $now_time = date("Y-m-d H:i:s", time());
$forfeit_penalty = $this->updateForfeitPenalty($val['id'],$val['create_time'],$now_time,$val['money']); $forfeit_penalty = $this->updateForfeitPenalty($val['id'], $val['create_time'], $now_time, $val['money']);
$result[$key]['forfeit_penalty'] = $forfeit_penalty; $result[$key]['forfeit_penalty'] = $forfeit_penalty;
} }
$result[$key]['type_name'] = $this->getTypeName($val['type']); $result[$key]['type_name'] = $this->getTypeName($val['type']);
$result[$key]['status_name'] = $this->getStatusName($val['status']); $result[$key]['status_name'] = $this->getStatusName($val['status']);
$agent_data = $redis_cache->getRedisCache(2, $val['submit_agent_id']); $agent_data = $redis_cache->getRedisCache(2, $val['submit_agent_id']);
$result[$key]['submit_agent_name'] = $agent_data['name']; $result[$key]['submit_agent_name'] = $agent_data['name'];
$agent_data = $redis_cache->getRedisCache(2, $val['agent_id']); $agent_data = $redis_cache->getRedisCache(2, $val['agent_id']);
$result[$key]['agent_name'] = $agent_data['name']; $result[$key]['agent_name'] = $agent_data['name'];
$result[$key]['money_sum'] = $result[$key]['forfeit_penalty'] + $val['money'];//罚款总金额 $result[$key]['money_sum'] = $result[$key]['forfeit_penalty'] + $val['money'];//罚款总金额
} }
$export = new ExportExcelUntil(); $export = new ExportExcelUntil();
$e_data_new = []; $e_data_new = [];
foreach ($result as $key => $v) { foreach ($result as $key => $v) {
$e_data_old['1'] = $v['id']; $e_data_old['1'] = $v['id'];
...@@ -495,21 +497,18 @@ class AmercementService ...@@ -495,21 +497,18 @@ class AmercementService
$e_data_old['7'] = $v['status_name']; $e_data_old['7'] = $v['status_name'];
$e_data_old['8'] = $v['forfeit_penalty']; $e_data_old['8'] = $v['forfeit_penalty'];
$e_data_old['9'] = $v['money_sum']; $e_data_old['9'] = $v['money_sum'];
$e_data_new[] = $e_data_old; $e_data_new[] = $e_data_old;
} }
$field_num = 9; $field_num = 9;
$title = [ '罚款ID', '罚款项目', '提交时间', '提交人', '罚款金额', '被罚款人', '状态', '滞纳金','付款金额']; $title = ['罚款ID', '罚款项目', '提交时间', '提交人', '罚款金额', '被罚款人', '状态', '滞纳金', '付款金额'];
$title2 = '罚款账单表'; $title2 = '罚款账单表';
$export->exportTable('罚款账单表', $e_data_new, $field_num, $title2, $title); $export->exportTable('罚款账单表', $e_data_new, $field_num, $title2, $title);
return ''; return '';
} }
/** /**
* 构建搜索条件 * 构建搜索条件
* @param $params * @param $params
...@@ -534,26 +533,25 @@ class AmercementService ...@@ -534,26 +533,25 @@ class AmercementService
} }
//罚款ID //罚款ID
if (isset($params['id'])&& is_numeric($params["id"])) { if (isset($params['id']) && is_numeric($params["id"])) {
$conditions["id"] = $params["id"]; $conditions["id"] = $params["id"];
} }
//提交人姓名 //提交人姓名
if (!empty($params['submit_name'])) { if (!empty($params['submit_name'])) {
$user_id_str = $this->getAgentIDList($params['submit_name']); $user_id_str = $this->getAgentIDList($params['submit_name']);
$conditions['submit_agent_id'] = ['in', $user_id_str]; $conditions['submit_agent_id'] = ['in', $user_id_str];
} }
//被罚款人姓名 //被罚款人姓名
if (!empty($params['name'])) { if (!empty($params['name'])) {
$user_id_str = $this->getAgentIDList($params['name']); $user_id_str = $this->getAgentIDList($params['name']);
$conditions['agent_id'] = ['in', $user_id_str]; $conditions['agent_id'] = ['in', $user_id_str];
} }
return $conditions; return $conditions;
} }
/** /**
* 求两个日期之间相差的天数 * 求两个日期之间相差的天数
* (针对1970年1月1日之后,求之前可以采用泰勒公式) * (针对1970年1月1日之后,求之前可以采用泰勒公式)
...@@ -561,13 +559,13 @@ class AmercementService ...@@ -561,13 +559,13 @@ class AmercementService
* @param string $day2 * @param string $day2
* @return number * @return number
*/ */
function diffBetweenTwoDays ($day1, $day2) function diffBetweenTwoDays($day1, $day2)
{ {
$second1 = strtotime($day1); $second1 = strtotime($day1);
$second2 = strtotime($day2); $second2 = strtotime($day2);
if ($second1 < $second2) { if ($second1 < $second2) {
$tmp = $second2; $tmp = $second2;
$second2 = $second1; $second2 = $second1;
$second1 = $tmp; $second1 = $tmp;
} }
...@@ -583,11 +581,11 @@ class AmercementService ...@@ -583,11 +581,11 @@ class AmercementService
public function getAgentIDList($name) public function getAgentIDList($name)
{ {
//查询总监下面门店的所有经纪人 //查询总监下面门店的所有经纪人
$params = []; $params = [];
$params['name'] = [ 'LIKE', '%' . $name . '%' ]; $params['name'] = ['LIKE', '%' . $name . '%'];
$m_agent = new AAgents(); $m_agent = new AAgents();
$field = 'id'; $field = 'id';
$res = $m_agent->getStoreIdByAgentId($field, $params); $res = $m_agent->getStoreIdByAgentId($field, $params);
$user_id_str = ""; $user_id_str = "";
if (count($res) > 0) { if (count($res) > 0) {
...@@ -606,12 +604,27 @@ class AmercementService ...@@ -606,12 +604,27 @@ class AmercementService
* @param $id * @param $id
* @return int|string * @return int|string
*/ */
public function delAmercementImage($id){ public function delAmercementImage($id)
{
$params_['status'] = 1; $params_['status'] = 1;
$res = $this->m_amercement_img->updateImage($id,$params_);//int(1) $res = $this->m_amercement_img->updateImage($id, $params_);//int(1)
return $res; return $res;
} }
public function savePayAmercement($amercement_id, $trade_no, $pay_type, $status, $remark, $pay_money, $pay_time)
{
//todo 判断是否有支付过
$arr["amercement_id"] = $amercement_id;
$arr["trade_no"] = $trade_no;
$arr["pay_type"] = $pay_type;
$arr["status"] = $status;
$arr["remark"] = $remark;
$arr["pay_money"] = $pay_money;
$arr["pay_time"] = $pay_time;
}
} }
\ No newline at end of file
...@@ -815,6 +815,8 @@ Route::group('task', [ ...@@ -815,6 +815,8 @@ Route::group('task', [
'delAgentUserLog' => ['task/AgentLookUserTask/delAgentUserLog', ['method' => 'get']], //清理经纪人看客户记录 'delAgentUserLog' => ['task/AgentLookUserTask/delAgentUserLog', ['method' => 'get']], //清理经纪人看客户记录
'selectDailyUncommitted' => ['task/DailyUncommittedTask/selectDailyUncommitted', ['method' => 'get']], //未提交财务日报的门店 'selectDailyUncommitted' => ['task/DailyUncommittedTask/selectDailyUncommitted', ['method' => 'get']], //未提交财务日报的门店
'saveLookUser' => ['task/SaveLookUserHistoryTask/saveLookUser', ['method' => 'get']], //保存经纪人看客户的记录
]); ]);
Route::group('broker', [ Route::group('broker', [
......
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