Commit 4f781903 authored by hujun's avatar hujun

add

parent 4daa2c20
......@@ -2,6 +2,7 @@
namespace app\api_broker\service;
use app\model\OfficeOImg;
use app\model\OfficeOPayLogAdjustment;
use app\model\OfficeOPayLogModel;
use app\model\OfficeORefundModel;
......@@ -85,9 +86,8 @@ class OfficePayLogService
if (count($pay_log_arr) < 0) {
return -1;
}
$oPayLogAdjustment = new OPayLogAdjustment();
$where_ = $this->adjustmentBin($new_pay_id, $pay_id, $money, $type, $agent_id, $pay_log_arr[0]["type"]);
$oPayLogAdjustment->addAdjustment($where_);
$this->payLogAdjustmentModel->addAdjustment($where_);
}
/**
......@@ -271,7 +271,7 @@ class OfficePayLogService
*/
private function addOImg($id, $type, $transfer_img)
{
$oImgModel = new OImg();
$oImgModel = new OfficeOImg();
$oImgModel->addImgAll($id, $type, $transfer_img);
}
......@@ -283,7 +283,7 @@ class OfficePayLogService
private function getOImg($id, $img_type)
{
//查询图片
$oImgModel = new OImg();
$oImgModel = new OfficeOImg();
$params["img_id"] = $id;
$params["img_type"] = $img_type;
$img_arr = $oImgModel->getImgList($params);
......@@ -295,7 +295,7 @@ class OfficePayLogService
* @param $del_img
*/
private function delOImg($type, $del_img){
$oImgModel = new OImg();
$oImgModel = new OfficeOImg();
$ids = rtrim($del_img, ",");
$where_["id"] = array("in",$ids);
$where_["img_type"] = $type;
......
......@@ -26,6 +26,7 @@ use app\model\OBargainLogModel;
use app\model\OBargainModel;
use app\model\ODaily;
use app\model\OfficeOImg;
use app\model\OfficeOPayLogModel;
use app\model\OImg;
use app\model\OMarchInModel;
use app\model\OPayLogAdjustment;
......@@ -3526,7 +3527,6 @@ class Finance extends Basic
}
}
/**
* 收款列表记录上传图片
* 朱伟 2018-07-04
......@@ -3565,44 +3565,6 @@ class Finance extends Basic
}
}
/**
* 收款列表记录上传图片
* 朱伟 2018-07-04
*/
public function addReceiptOfficeImg(){
$params = $this->params;
$result = 0;
/*$params = array(
"img_id" => 1,
"img_name" => 123,
);*/
if(!isset($params["img_id"])){
return $this->response("101","请求参数错误");
}
if(!isset($params["img_name"])){
return $this->response("101","请求参数错误");
}
$order = new OfficeOImg();
foreach (explode(',',$params["img_name"]) as $k => $v){
$time = date("Y-m-d H:i:s", time());
$save_data["img_id"] = $params["img_id"];//id根据img_type区分是收款还是进场还是其他'
$save_data["img_type"] = 2 ;//图片类型:1进场,2收款
$save_data["img_name"] = $v;//图片名称
$save_data["img_status"] = 0 ;//删除状态 0正常 1删除
$save_data["update_time"] = $time;//更新时间
$save_data["create_time"] = $time;//创建时间
$result = $order->addImgOnce($save_data);
}
if($result){
return $this->response("200","成功");
}else{
return $this->response("101","失败");
}
}
/**
* 收款列表-删除上传图片
* 朱伟 2018-07-04
......
......@@ -4,12 +4,14 @@
namespace app\index\controller;
use app\api_broker\service\OfficePayLogService;
use app\api_broker\service\RedisCacheService;
use app\index\extend\Basic;
use app\index\untils\ExportExcelUntil;
use app\model\OfficeGBuilding;
use app\model\OfficeGRoom;
use app\model\OfficeOBargainModel;
use app\model\OfficeOImg;
use app\model\OfficeOPayLogAdjustment;
use app\model\OfficeOPayLogModel;
use app\model\OfficeOrderModel;
......@@ -982,4 +984,330 @@ class OfficePayLog extends Basic
return $this->response("200","success",["residue_money"=>$result]);
}
/**
* 编辑收款详情
*
* @return \think\Response
*/
public function getCollectionEdit() {
if (empty($this->params['pay_id'])) {
return $this->response(101, '参数错误');
}
$msg = "";
$code = 200;
try {
$m_pay = new OfficeOPayLogModel();
$id = $m_pay->selectReceiptImgList('id,source,type', ['id'=>$this->params['pay_id']]);
if (empty($id[0]['id'])) {
return $this->response(101, '没有该记录');
}
if ($id[0]['source'] == 2) {
unset($this->params['receipt_number']);
unset($this->params['transfer_name']);
unset($this->params['pay_type']);
} else {
$save_data['transfer_name'] = isset($this->params['transfer_name']) ? $this->params['transfer_name']:'';
$save_data['money'] = $this->params['money'];
$save_data['receipt_number'] = isset($this->params['receipt_number'])? $this->params['receipt_number']:'';
$save_data['pay_type'] = $this->params['pay_type'];
if (!empty($this->params['bargain_id'])) {
$save_data['bargain_id'] = $this->params['bargain_id'];
}
}
if (($id[0]['type'] == 10 && $this->params['type'] == 30) || ($id[0]['type'] == 30 && $this->params['type'] == 10)) {
$save_data['type'] = $this->params['type'];
}
if (($id[0]['type'] == 91 && $this->params['type'] == 92) || ($id[0]['type'] == 92 && $this->params['type'] == 91)) {
$save_data['type'] = $this->params['type'];
}
if (!empty($this->params['order_id'])) {
$save_data['order_id'] = $this->params['order_id'];
}
if (!empty($this->params['report_id'])) {
$save_data['report_id'] = $this->params['report_id'];
}
$save_data['id'] = $this->params['pay_id'];
$save_data['income_time'] = $this->params['income_time'];
$save_data['real_money'] = $this->params['real_money'];
$save_data['money'] = $this->params['money'];
$save_data['transaction_fee'] = $this->params['transaction_fee'];
$save_data['last_transfer_time'] = $this->params['last_transfer_time'];
$save_data['type_ext'] = empty($this->params['type_ext']) ? 0 : 1;
$save_data['received_money'] = empty($this->params['received_money']) ? 0 : $this->params['received_money'];
$save_data['type_ext'] = empty($this->params['type_ext']) ? 0 : $this->params['type_ext'];
$save_data['is_dividend'] = empty($this->params['is_dividend']) ? 0 : $this->params['is_dividend'];
$m_pay->updatePayLog($save_data);
if (isset($this->params['is_open']) && !empty($this->params['bargain_id'])) {
$this->m_bargain ->updateBargainById($this->params['bargain_id'], ['is_open'=>$this->params['is_open']]);
}
} catch (\Exception $e) {
$code = 101;
$msg = '内部错误:'. $e->getMessage();
}
return $this->response($code, $msg, []);
}
/**
* 收款列表记录上传图片
* 朱伟 2018-07-04
*/
public function addReceiptOfficeImg(){
$params = $this->params;
$result = 0;
/*$params = array(
"img_id" => 1,
"img_name" => 123,
);*/
if(!isset($params["img_id"])){
return $this->response("101","请求参数错误");
}
if(!isset($params["img_name"])){
return $this->response("101","请求参数错误");
}
$order = new OfficeOImg();
foreach (explode(',',$params["img_name"]) as $k => $v){
$time = date("Y-m-d H:i:s", time());
$save_data["img_id"] = $params["img_id"];//id根据img_type区分是收款还是进场还是其他'
$save_data["img_type"] = 2 ;//图片类型:1进场,2收款
$save_data["img_name"] = $v;//图片名称
$save_data["img_status"] = 0 ;//删除状态 0正常 1删除
$save_data["update_time"] = $time;//更新时间
$save_data["create_time"] = $time;//创建时间
$result = $order->addImgOnce($save_data);
}
if($result){
return $this->response("200","成功");
}else{
return $this->response("101","失败");
}
}
/**
* 收款列表-收款图片列表
* 朱伟 2018-07-04
*/
public function receiptOfficeImgList(){
$params = $this->params;
/*$params = array(
"id" => 6,
);*/
if(!isset($params["id"])){
return $this->response("101","请求参数错误");
}
$params['id'] = $params["id"];
$field = 'id,father_id';
//先查询收款表
$order = new OfficeOPayLogModel();
$order_res = $order->selectReceiptImgList($field , $params);
//判断收款表数据father_id是否大于o,如果大于0图片需要按img_id=father_id查询
if(!empty($order_res[0]['father_id']) && ($order_res[0]['father_id'] > 0)){
$params_img['img_id'] = $order_res[0]['father_id'];
}else{
$params_img['img_id'] = $params['id'];
}
$field = 'id,img_name';
$order = new OfficeOImg();
$res = $order->getImgList($params_img,$field);
foreach ($res as $k => $v) {
$res[$k]['img_name'] = CHAT_IMG_URL . $v['img_name'];
}
if($res){
return $this->response("200","成功",$res);
}else{
return $this->response("200","成功",$res);
}
}
/**
* 退款
*
* @return \think\Response
* @throws \think\Exception
*/
public function refundPayLog() {
$params = $this->params;
if (!isset($params["agent_id"]) || !isset($params["agent_name"]) || !isset($params["report_id"]) ||
!isset($params["order_id"]) || !isset($params["order_no"]) || !isset($params["name"]) || !isset($params["phone"])
|| !isset($params["refund_money"]) || !isset($params["bank"]) || !isset($params["card_no"])
|| !isset($params["receipt_number"]) || !isset($params["type"])
|| !isset($params["refund_cause"]) || !isset($params["refund_way"]) || empty($params["pay_log_id"])) {
return $this->response("101", "请求参数错误");
}
/* $params = array(
"agent_id" => 1,//退款经纪人id
"agent_name" => 1,//退款经纪人id
"report_id" => 1,//报备id
"order_id" => 1, //关联order表id
"order_no" => "12312312312312", //订单no
"refund_money" => 1200, //退款金额
"name" => "qweqwe", //收款人姓名
"phone" => "123123123", //收款人电话
"bank" => "asdasdasd", //收款人银行
"card_no" => "123123123123", //银行卡号
"remark" => "没什么备注", //其他说明
"remark_img" => "12312312312",
"receipt_number" => "12312312312",
"type" => "12312312312", //退款类型:0退意向金1意向金转定2退保管金3保管金转定4退中介费5退案场费
"refund_cause" => "12312312312", //退款原因
"pay_log_id" => 1, //支付id
"refund_way" => 0, //退款方式:0银行卡
);*/
$refund_id = isset($params["refund_id"]) ? $params["refund_id"] : 0;
if($refund_id == 0 && !isset($params["remark_img"])){
return $this->response("101", "请上传图片");
}
$agent_id = $params["agent_id"];
$agent_name = $params["agent_name"];
$report_id = $params["report_id"];
$order_id = $params["order_id"];
$order_no = $params["order_no"];
$refund_money = $params["refund_money"];
$name = $params["name"];
$phone = $params["phone"];
$bank = $params["bank"];
$card_no = $params["card_no"];
$receipt_number = $params["receipt_number"];
$type = $params["type"];
$refund_cause = $params["refund_cause"];
$pay_log_id = $params["pay_log_id"];
$refund_way = $params["refund_way"];
$remark = isset($params["remark"]) ? $params["remark"] : "";
$remark_img = isset($params["remark_img"]) ? $params["remark_img"] : "";
$del_img =isset($params["del_img"]) ? $params["del_img"] : "";
//todo 判断此单是否有付款
$service = new OfficePayLogService();
$is_ok = $service->addRefund($agent_id, $agent_name, $report_id, $order_id, $order_no, $refund_money, $name,
$phone, $bank, $card_no, $receipt_number, $type, $refund_cause, $pay_log_id, $refund_way, $remark, $remark_img
,$refund_id,$del_img);
if ($is_ok > 0) {
return $this->response("200", "request success", []);
} elseif ($is_ok == -2) {
return $this->response("101", "退款金不能大于剩余的支付金额");
} elseif ($is_ok == -3) {
return $this->response("101", "有财务驳回退款,请在原退款上修改.");
}
return $this->response("101", "request faild");
}
/**
* 删除收款
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function delPayLog() {
$code = 101;
$msg = '';
if (empty($this->params['pay_id'])) {
return $this->response($code, '参数错误');
}
$m_pay = new OfficeOPayLogModel();
$pay_data = $m_pay->selectPayLogByOrderNo('id,source', ['id'=>$this->params['pay_id']]);
if (empty($pay_data[0]['id'])) {
return $this->response($code, '无收款信息');
}
$m_pay_adjustment = new OfficeOPayLogAdjustment();
$where['is_del'] = 0;
if ($pay_data[0]['source'] != 2) {
$where['paylog_id'] = $pay_data[0]['id'];
} else {
$where['new_paylog_id'] = $pay_data[0]['id'];
}
$adjustment_id = $m_pay_adjustment->getAdjustmentList('id,paylog_id', $where);
if (count($adjustment_id) > 0) {
return $this->response($code, '存在调整,不能删除');
}
$m_refund = new OfficeORefundModel();
$refund_id = $m_refund->getFind('id', ['pay_log_id'=>$this->params['pay_id'],'is_del'=>0]);
if ($refund_id > 0) {
return $this->response($code, '存在退款,不能删除');
}
$num = $m_pay->updatePayLog(['is_del'=>1, 'id'=>$this->params['pay_id']]);
if ($num > 0) {
$code = 200;
} else {
$code = 101;
$msg = '删除失败';
}
return $this->response($code, $msg);
}
/**
* 撤销调整
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function delAdjustment() {
$code = 101;
if (empty($this->params['id'])) {
return $this->response($code, '参数错误');
}
$m_pay_adjustment = new OfficeOPayLogAdjustment();
$where_adjustment = [
'is_del'=>0,
'id' => $this->params['id'],
];
$new_paylog_id = $m_pay_adjustment->getFieldValue('new_paylog_id', $where_adjustment);
if (empty($new_paylog_id)) {
return $this->response($code, '无调整信息');
}
$where_2['is_del'] = $where['is_del'] = 0;
$where['paylog_id'] = $new_paylog_id;
$pay_log_id = $m_pay_adjustment->getFieldColumn('paylog_id', $where);
if (count($pay_log_id) > 0) {
return $this->response($code, '存在调整,不能删除.');
}
$m_refund = new OfficeORefundModel();
$refund_id = $m_refund->getFind('id', ['pay_log_id'=>$new_paylog_id, 'is_del'=>0]);
if ($refund_id > 0) {
return $this->response($code, '入账存在退款,不能删除');
}
$num = $m_pay_adjustment->updatePayLogAdjustment(['is_del'=>1, 'id'=>$this->params['id']]);
if ($num > 0) {
$m_pay = new OfficeOPayLogModel();
$save_data['id'] = $new_paylog_id;
$save_data['is_del'] = 1;
$m_pay->updatePayLog($save_data);
$code = 200;
$msg = '撤销成功';
} else {
$msg = '撤销失败';
}
return $this->response($code, $msg);
}
}
\ No newline at end of file
......@@ -1251,7 +1251,7 @@ class OfficeRoomService
$order = 'a.home_page_sort desc';
}
$field = 'a.id,b.disc,b.title,b.address,c.name as business_name,a.building_id,a.price,a.price_total';
$field = 'a.id,b.disc,b.title,b.address,c.name as business_name,a.building_id,a.price,a.price_total,b.status';
try {
$data = $this->m_office_room->getRoomBuilding($page_no, $page_size, $order, $field, $where);
} catch (\Exception $e) {
......
......@@ -1046,6 +1046,9 @@ Route::group('office_index', [
'getPayLogImg' => ['index/DailyPaper/getPayLogOfficeImg', ['method' => 'get|post']],
'receiptImgList' => ['index/officePayLog/receiptOfficeImgList', ['method' => 'post|get']],//收款列表-收款图片列表
'getCollectionEdit' => ['index/officePayLog/getCollectionEdit', ['method' => 'post']],//收款修改保存
'refundPayLog' => ['index/officePayLog/refundPayLog', ['method' => 'POST']],//退款
'delPayLog' => ['index/officePayLog/delPayLog', ['method' => 'POST']],//删除收款
'delAdjustment' => ['index/officePayLog/delAdjustment', ['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