Commit bcae1fc3 authored by clone's avatar clone

1

parent 27491105
...@@ -43,6 +43,7 @@ class PayLogOpen extends Basic ...@@ -43,6 +43,7 @@ class PayLogOpen extends Basic
"house_address" => "123123", "house_address" => "123123",
"remark" => "123123", "remark" => "123123",
"open_img" => "123123", "open_img" => "123123",
"type" => 1 //默认为1 单独申请开业 2和该地址相关的收款全部申请开业
);*/ );*/
$checkResult = $this->validate($params, "PayLogOpenValidate.applyForOpen"); $checkResult = $this->validate($params, "PayLogOpenValidate.applyForOpen");
...@@ -57,6 +58,7 @@ class PayLogOpen extends Basic ...@@ -57,6 +58,7 @@ class PayLogOpen extends Basic
$house_id = $params["house_id"]; $house_id = $params["house_id"];
$house_address = $params["house_address"]; $house_address = $params["house_address"];
$intro = $params["intro"]; $intro = $params["intro"];
$type = $params["type"] ? $params["type"] : 1;
try { try {
$open_img = json_decode($params["open_img"], true); $open_img = json_decode($params["open_img"], true);
} catch (Exception $exception) { } catch (Exception $exception) {
...@@ -64,7 +66,7 @@ class PayLogOpen extends Basic ...@@ -64,7 +66,7 @@ class PayLogOpen extends Basic
} }
$return_id = $this->service_->addApplyForOpen($pay_log_id, $report_id, $bargain_id, $agent_id, $house_id, $intro, $return_id = $this->service_->addApplyForOpen($pay_log_id, $report_id, $bargain_id, $agent_id, $house_id, $intro,
$house_address, $open_img, $order_id, $this->agentId); $house_address, $open_img, $order_id, $this->agentId,$type);
if ($return_id > 0) { if ($return_id > 0) {
return $this->response("200", "success", ["id" => $return_id]); return $this->response("200", "success", ["id" => $return_id]);
} elseif ($return_id == -1){ } elseif ($return_id == -1){
......
...@@ -42,25 +42,47 @@ class PayLogOpenService ...@@ -42,25 +42,47 @@ class PayLogOpenService
* @return int * @return int
* @throws \think\Exception * @throws \think\Exception
*/ */
public function addApplyForOpen($pay_log_id, $report_id, $bargain_id, $agent_id, $house_id, $intro, $house_address, $open_img, $order_id, $operation_id) public function addApplyForOpen($pay_log_id, $report_id, $bargain_id, $agent_id, $house_id, $intro, $house_address,
$open_img, $order_id, $operation_id, $type)
{ {
$params["pay_log_id"] = $pay_log_id; $params["pay_log_id"] = $pay_log_id;
$params["agent_id"] = $agent_id; $params["agent_id"] = $agent_id;
$pay_open_data = $this->payLogOpenModel->getFind("id", 0, $params); $pay_open_data = $this->payLogOpenModel->getFind("id", 0, $params);
if($pay_open_data){ if ($pay_open_data) {
return -1; return -1;
} }
$return_id = 0;
switch ($type) {
case 1:
$return_id = $this->payLogOpenModel->addPayLogOpen(
$this->payLogOpenBin($pay_log_id, $report_id, $bargain_id, $agent_id, $house_id, $intro, $house_address, $order_id)
);
if ($return_id > 0) {
$this->oImgModel->addImgAll($return_id, 5, $open_img);
}
break;
case 2:
//查询所有和改地址相关的未申请开业的收款
$params["b.house_id"] = $house_id;
$params["a.is_open"] = 0;
$params["a.is_del"] = 0;
$payLogArr = $this->payLogModel->selectListByHouseId("id", $params);
foreach ($payLogArr as $item){
$return_id = $this->payLogOpenModel->addPayLogOpen(
$this->payLogOpenBin($item["id"], $report_id, $bargain_id, $agent_id, $house_id, $intro, $house_address, $order_id)
);
if ($return_id > 0) {
$this->oImgModel->addImgAll($return_id, 5, $open_img);
}
}
}
$return_id = $this->payLogOpenModel->addPayLogOpen(
$this->payLogOpenBin($pay_log_id, $report_id, $bargain_id, $agent_id, $house_id, $intro, $house_address, $order_id)
);
//save img //save img
if ($return_id > 0) { if ($return_id > 0) {
$this->oImgModel->addImgAll($return_id, 5, $open_img);
//todo 推送 //todo 推送
$verifyService = new VerifyService(); $verifyService = new VerifyService();
$leaderId = $verifyService->getLeaderIdByAgentId($agent_id); $leaderId = $verifyService->getLeaderIdByAgentId($agent_id);
if($leaderId > 0){ if ($leaderId > 0) {
$push_service = new PushMessageService(); $push_service = new PushMessageService();
$push_service->record(13, 0, [$leaderId], $operation_id, ['message' => "有业务员提交了开业申请,请及时审核"]); $push_service->record(13, 0, [$leaderId], $operation_id, ['message' => "有业务员提交了开业申请,请及时审核"]);
} }
...@@ -91,11 +113,11 @@ class PayLogOpenService ...@@ -91,11 +113,11 @@ class PayLogOpenService
$this->payLogOpenModel->editData(['status' => $status], $open_id); //更新状态 $this->payLogOpenModel->editData(['status' => $status], $open_id); //更新状态
if ($status == 3) { if ($status == 3) {
$pay_log_id = $this->payLogOpenModel->getFieldOneValue('pay_log_id', ['id'=>$open_id]); $pay_log_id = $this->payLogOpenModel->getFieldOneValue('pay_log_id', ['id' => $open_id]);
if ($pay_log_id) { if ($pay_log_id) {
$update_data['id'] = $pay_log_id; $update_data['id'] = $pay_log_id;
$update_data['is_open'] = 1; $update_data['is_open'] = 1;
$update_data['open_time'] = date('Y-m-d H:i:s'); $update_data['open_time'] = date('Y-m-d H:i:s');
$this->payLogModel->updatePayLog($update_data); $this->payLogModel->updatePayLog($update_data);
} }
...@@ -180,7 +202,7 @@ class PayLogOpenService ...@@ -180,7 +202,7 @@ class PayLogOpenService
$list[$key]["img_path"] = CHAT_IMG_URL; $list[$key]["img_path"] = CHAT_IMG_URL;
$list[$key]["img_arr"] = $img_arr; $list[$key]["img_arr"] = $img_arr;
$log_list = $this->payLogOpenLogModel->getAllList($field_log, 0, ["open_id"=>$item["id"]]); $log_list = $this->payLogOpenLogModel->getAllList($field_log, 0, ["open_id" => $item["id"]]);
$list[$key]["log_list"] = $log_list; $list[$key]["log_list"] = $log_list;
} }
return $list; return $list;
......
...@@ -350,6 +350,7 @@ class PayLogOpen extends Basic ...@@ -350,6 +350,7 @@ class PayLogOpen extends Basic
"house_address" => "123123", "house_address" => "123123",
"remark" => "123123", "remark" => "123123",
"open_img" => "123123", "open_img" => "123123",
"type" => 1 //默认为1 单独申请开业 2和该地址相关的收款全部申请开业
);*/ );*/
$checkResult = $this->validate($params, "api_broker/PayLogOpenValidate.applyForOpen"); $checkResult = $this->validate($params, "api_broker/PayLogOpenValidate.applyForOpen");
...@@ -366,6 +367,7 @@ class PayLogOpen extends Basic ...@@ -366,6 +367,7 @@ class PayLogOpen extends Basic
$house_id = $params["house_id"]; $house_id = $params["house_id"];
$house_address = $params["house_address"]; $house_address = $params["house_address"];
$intro = $params["intro"]; $intro = $params["intro"];
$type = $params["type"] ? $params["type"] : 1;
try { try {
$open_img = json_decode($params["open_img"], true); $open_img = json_decode($params["open_img"], true);
} catch (\Exception $exception) { } catch (\Exception $exception) {
...@@ -373,7 +375,7 @@ class PayLogOpen extends Basic ...@@ -373,7 +375,7 @@ class PayLogOpen extends Basic
} }
$return_id = $service_->addApplyForOpen($pay_log_id, $report_id, $bargain_id, $agent_id, $house_id, $intro, $return_id = $service_->addApplyForOpen($pay_log_id, $report_id, $bargain_id, $agent_id, $house_id, $intro,
$house_address, $open_img, $order_id, $this->userId); $house_address, $open_img, $order_id, $this->userId,$type);
if ($return_id > 0) { if ($return_id > 0) {
return $this->response("200", "success", ["id" => $return_id]); return $this->response("200", "success", ["id" => $return_id]);
} elseif ($return_id == -1){ } elseif ($return_id == -1){
......
...@@ -647,5 +647,15 @@ class OPayLogModel extends Model ...@@ -647,5 +647,15 @@ class OPayLogModel extends Model
return $result; return $result;
} }
public function selectListByHouseId($filed,$params)
{
return $this->db_->field($filed)
->alias("a")
->join("o_order b", "a.order_id = b.id", "left")
->where($params)
->select();
}
} }
\ No newline at end of file
...@@ -33,6 +33,19 @@ class OPayLogOpen extends BaseModel ...@@ -33,6 +33,19 @@ class OPayLogOpen extends BaseModel
} }
} }
public function addPayLogOpenAll($params)
{
Db::startTrans();
try {
$this->db_->insertAll($params);
Db::commit();
return 1;
} catch (\Exception $e) {
Db::rollback();
return 0;
}
}
/** /**
* @param int $pageNo * @param int $pageNo
* @param int $pageSize * @param int $pageSize
......
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