edit-licheb-order

This commit is contained in:
lccsw
2021-07-29 14:18:22 +08:00
parent 5851e5d520
commit daf0ede906
9 changed files with 69 additions and 107 deletions
+7 -26
View File
@@ -243,7 +243,7 @@ class Orders extends HD_Controller{
];
$bill['id'] = $this->order_bills_model->add($add_data);
}
$bill['file'] = $bill['file'] ? build_qiniu_image_url($bill['file']):'';
$bill['src_file'] = $bill['file'] ? build_qiniu_image_url($bill['file']):'';
$this->data['bill'] = $bill;
return $this->show_view('receiver/orders/get_bill');
}
@@ -251,31 +251,9 @@ class Orders extends HD_Controller{
public function edit_bill(){
$id = $this->input->post('id');
$money = $this->input->post('money');
$file = $_FILES['file'];
if($file){ //上传文件
$path = FCPATH.'temp/';
if (!file_exists($path)){
$oldumask = umask(0);
mkdir($path, 0777, true);
umask($oldumask);
}
$file_name = md5($file['name'] . uniqid()) . '.'.end(explode('.',$file['name']));
$tmp = $path.$file_name;
move_uploaded_file($file['tmp_name'], $tmp);
if (!filesize($tmp)) {
return $this->show_json(SYS_CODE_FAIL, '上传文件失败!');
}
$this->load->library('qiniu');
$res= $this->qiniu->save($file_name, file_get_contents($tmp));
unlink($tmp);
if (!$res) {
return $this->show_json(SYS_CODE_FAIL, '上传文件失败!');
}
$size = getimagesize($res['url']);
$update['file'] = $res['file'];
}
$file = $this->input->post('file');
$money && $update['money'] = $money;
$file && $update['file'] = $file;
$result = $this->order_bills_model->update($update,['id'=>$id]);
if($result){
return $this->show_json(SYS_CODE_SUCCESS,'保存成功');
@@ -298,6 +276,9 @@ class Orders extends HD_Controller{
if(!$bill['file'] || !$bill['money']){
return $this->show_json(SYS_CODE_FAIL, '未上传开票文件或未填写到账金额!');
}
if(!$bill['cardidA']){
return $this->show_json(SYS_CODE_FAIL, '未上传用户身份证!');
}
$result = $this->order_bills_model->update(['status'=>1],['o_id'=>$oid]);
$this->orders_model->update(['status'=>4],['id'=>$bill['o_id']]);
if(!$this->order_agents_model->get(['o_id'=>$oid])){
@@ -320,7 +301,7 @@ class Orders extends HD_Controller{
$update['if_ins'] = $params['if_ins'] ? 1:0;
if($params['bx_imgs']){
$imgs = explode(',',$params['bx_imgs']);
$update['ins_img'] = json_encode($imgs,JSON_UNESCAPED_UNICODE);
$update['bx_imgs'] = json_encode($imgs,JSON_UNESCAPED_UNICODE);
}
if($agent){
$result = $this->order_agents_model->update($update,['id'=>$agent['id']]);
+15 -69
View File
@@ -1,5 +1,5 @@
<form class="am-form am-form-horizontal" action="/receiver/orders/edit_bill" data-auto="true" method="post"
style="width: 90%;padding-top: 10px" enctype="multipart/form-data">
style="width: 90%;padding-top: 10px">
<input type="hidden" name="id" value="<?= $bill['id'] ?>">
<div class="am-form-group">
<label class="am-para-label">到账金额:</label>
@@ -9,81 +9,27 @@
</div>
<div class="am-form-group">
<label class="am-para-label">pdf文件:</label>
<div class="input-group">
<label class="input-group-btn">
<span class="am-btn am-btn-default am-btn-sm">
<i class="am-icon-cloud-upload"></i> 选择文件
<input type="file" id="fp_file" style="display: none;" accept=".pdf" onchange="getfilename()">
</span>
</label>
<span class="ml10 mt5 absolute">
<span style="" id="temp_filename"></span>
<?if($bill['file']){?>
<a href="<?=$bill['file']?>" target="_blank" class="ml10" >查看文件</a>
<?}?>
</span>
<label class="am-para-label">发票文件:</label>
<div class="am-para-input">
<div class="am-form-group am-form-file">
<button type="button" class="am-btn am-btn-default am-btn-sm"
data-file="1" data-type="jpg,png,gif,png,jpeg"
data-uptype="qiniu" data-field="file">
<i class="am-icon-cloud-upload"></i> 选择图片
</button>
<input type="hidden" name="file" value="<?=$bill['file']?>" class="layui-input">
<img data-tips-image style="height:auto;max-height:32px;max-width:32px" src="<?=$bill['src_file']?>"/>
</div>
</div>
</div>
<div class="am-form-group" style="margin-bottom: 2rem">
<div class="am-para-input">
<span class="am-btn am-btn-secondary" id="bc">保存</span>
<button class="am-btn am-btn-secondary" type="submit">保存</button>
</div>
</div>
</form>
<script>
$("#fp_file").on("change",function(){
var filePath=$(this).val();
if(filePath){
var arr=filePath.split('\\');
var fileName=arr[arr.length-1];
$("#temp_filename").html(fileName);
}else{
$("#temp_filename").html("您未上传文件,或者您上传文件类型有误!");
return false
}
});
$("#bc").click(function(){
var that = this;
var formData = new FormData();
formData.append('id',<?=$bill['id']?>);
file = $("#fp_file").get(0).files[0];
money = $("#fp_money").val();
if(file){
formData.append("file",file);
}
if(money){
formData.append('money',money);
}
$.ajax({
url: '/receiver/orders/edit_bill',
dataType: "json",
type: "post",
data: formData,
processData: false,//不去处理发送的数据
contentType: false,//不去设置Content-Type请求头
error: function (res) {
layer.msg('保存失败')
return;
},
success: function (res) {
console.dir(res)
if(res.code){
layer.msg(res.msg, {
time: 2000,
icon:1
}, function () {
layer.closeAll();
$.form.reload();
});
}else{
layer.msg(res.msg,{icon:2});
}
return;
}
})
})
</script>
+1 -1
View File
@@ -86,7 +86,7 @@
上传文件
</a>
</label>
<a :href="info.bill.file" v-if="info.bill && info.bill.file" target="_blank" class="ml10 mt5 absolute">查看文件</a>
<img data-tips-image v-if="info.bill && info.bill.file" style="height:auto;max-height:32px;max-width:32px;" class="ml5 mt5" :src="info.bill.file"/>
</div>
</div>
</div>
@@ -275,6 +275,7 @@ class Cusorder extends Wxapp{
'carid_a_path' => $bill['cardidA'] ? $bill['cardidA'] : '',
'carid_b' => $bill['cardidB'] ? build_qiniu_image_url($bill['cardidB']) : '',
'carid_b_path' => $bill['cardidB'] ? $bill['cardidB'] : '',
'bill_img' => $bill['file'] ? build_qiniu_image_url($bill['file']) : ''
];
}
$bill_status = $bill['status'] ? 2 : 1;
@@ -310,6 +311,9 @@ class Cusorder extends Wxapp{
$result = $this->order_deliverys_model->update(['status'=>2],['id'=>$row['id']]);
if($result){
$this->orders_model->update(['status'=>6],['id'=>$row['o_id']]);
//完成支付订单
$this->load->library('receiver/orders_entity');
$this->orders_entity->finish_after($row['o_id'],1);
throw new Exception('修改成功', API_CODE_SUCCESS);
}else{
throw new Exception('修改失败', ERR_PARAMS_ERROR);
@@ -45,11 +45,12 @@ class Customerlogs extends Wxapp{
if($val['type']==2){
$rec_row = $this->receiver_xz_model->get(['id'=>$val['log']],'rec_url,duration');
$content = '拨打电话';
!$rec_row['duration'] && $content .= '(未接通)';
$rec_row['rec_url'] && $record = $rec_row['rec_url'];
$rec_row['duration'] && $second = intval($rec_row['duration']/1000);
}
$lists[] = [
'content' => $content,
'content' => "{$val['uname']}".$content,
'record_url' => $record,
'second' => $second,
'c_time' => date('Y.m.d',$val['c_time'])
+1 -1
View File
@@ -146,7 +146,7 @@ class Customers extends Wxapp{
if($result){
$uname = $this->session['uname'];
$this->load->library('receiver/customers_entity');
$this->customers_entity->add_log($result,$this->session['uid'],$uname,"{$uname}创建客户");
$this->customers_entity->add_log($result,$this->session['uid'],$uname,"创建客户");
throw new Exception('创建成功', API_CODE_SUCCESS);
}else{
throw new Exception('创建失败', ERR_PARAMS_ERROR);
+5 -3
View File
@@ -74,21 +74,23 @@ class Sms extends Wxapp{
//通过订单发短信
protected function post_cusorder(){
$this->load->model('receiver/order/receiver_orders_model','orders_model');
$this->load->model('receiver/receiver_customers_model','customers_model');
$uid = $this->session['uid'];
$id = $this->input_param('id');
$content = $this->input_param('content');
$row = $this->orders_model->get(['id'=>$id,'admin_id'=>$uid]);
$order = $this->orders_model->get(['id'=>$id,'admin_id'=>$uid]);
$row = $this->customers_model->get(['id'=>$order['rid']]);
if(!$row || !$content){
throw new Exception('参数错误', ERR_PARAMS_ERROR);
}
$mobile = $row['mobile'];
$content = '【狸车】'.$content;
b2m_send_sms($mobile,$content);
$this->load->library('receiver/orders_entity');
$this->load->library('receiver/customers_entity');
$log = '发送短信+1';
$this->orders_entity->add_log($id,$uid,$this->session['uname'],$log,1);
$this->customers_entity->add_log($row['id'],$uid,$this->session['uname'],$log,1);
throw new Exception('短信发送成功', API_CODE_SUCCESS);
}
}
+6 -6
View File
@@ -28,13 +28,13 @@ class Xz extends Wxapp{
!$type && $type = 0;
$session = $this->session;
$admin_id = $session['uid'];
$cf_title = 'customer';
$cus_id = $id;
if($type==1){ //订单
$row = $this->orders_model->get(['id'=>$id]);
$cf_title = 'order';
}else{//客户
$cf_title = 'customer';
$row = $this->customers_model->get(['id'=>$id]);
$order = $this->orders_model->get(['id'=>$id]);
$cus_id = $order['rid'];
}
$row = $this->customers_model->get(['id'=>$cus_id]);
if(!$row || !$row['mobile']){
throw new Hd_Exception('用户不存在', API_CODE_INVILD_PARAM);
}
@@ -90,7 +90,7 @@ class Xz extends Wxapp{
$add_data = [
'call_id' => $seq_id,
'display_number' => $result['data']['virtualMobile'],
'cf_id' => $id,
'cf_id' => $cus_id,
'cf_uid' => $admin_id,
'cf_title' => $cf_title,
'cf_platform' => 'api',
@@ -199,6 +199,34 @@ class Orders_entity{
$result = $this->ci->order_oplogs_model->add($add_data);
return $result;
}
/**
* 确认交车
* @param $oid int 订单id
* @param $app_id int 小程序id
* return boolean
*/
public function finish_after($oid,$app_id){
$this->ci->load->model('receiver/order/receiver_orders_model','orders_model');
$this->ci->load->model('receiver/receiver_customers_model','customers_model');
$this->ci->load->model('apporder/order_purchase_model');
$row = $this->ci->orders_model->get(['id'=>$oid]);
if(!$row){
return false;
}
$customers = $this->ci->customers_model->get(['id'=>$row['rid']],'rid');
$res = false;
//获取线索生成的支付订单
$clu_order = $this->ci->order_purchase_model->get(['type'=>3,'status'=>2,'cf_id'=>$customers['rid'],'app_id'=>$app_id]);
if($clu_order){
$res = $this->ci->order_purchase_model->update(['status'=>3],['id'=>$clu_order['id']]);
}
//获取合同生成的支付订单
$o_order = $this->ci->order_purchase_model->get(['type'=>4,'status'=>2,'cf_id'=>$row['id'],'app_id'=>$app_id]);
if($o_order){
$res = $this->ci->order_purchase_model->update(['status'=>3],['id'=>$o_order['id']]);
}
return $res;
}
}
?>