edit-api-biz-mchid

This commit is contained in:
lccsw
2022-04-30 12:57:28 +08:00
parent 38cb716de1
commit eb20c3e463
5 changed files with 90 additions and 41 deletions
+20 -14
View File
@@ -332,22 +332,28 @@ class Ordersv2List
} else {
$fields1['name'] = ['title' => '客户', 'width' => '14%'];
}
if (strlen($status_pid) && $status_pid == 0) {
$fields2 = ['car_name' => ['title' => '车辆', 'width' => '27%'],
'biz_name' => ['title' => '门店', 'width' => '12%'], 'price' => ['title' => '车辆平台价', 'width' => '9%'],
'payway_name' => ['title' => '付款方式', 'width' => '8%'], 'of_title' => ['title' => '客户来源', 'width' => '10%'],
'status_name' => ['title' => '状态', 'width' => '9%'], 'order_time' => ['title' => '下定时间', 'width' => '9%']];
if (!strlen($status_pid)) {
$fields2 = [
'car_name' => ['title' => '车辆', 'width' => '27%'], 'biz_name' => ['title' => '门店', 'width' => '12%'],
'price' => ['title' => '车辆平台价', 'width' => '9%'], 'payway_name' => ['title' => '付款方式', 'width' => '8%'],
'of_title' => ['title' => '客户来源', 'width' => '10%'], 'status_name' => ['title' => '状态', 'width' => '9%'],
'c_time' => ['title' => '订单时间', 'width' => '9%'
]
];
} elseif ($status_pid == 3) {
$fields2 = ['car_name' => ['title' => '车辆', 'width' => '27%'],
'biz_name' => ['title' => '门店', 'width' => '12%'], 'price' => ['title' => '车辆平台价', 'width' => '9%'],
'payway_name' => ['title' => '付款方式', 'width' => '8%'], 'of_title' => ['title' => '客户来源', 'width' => '10%'],
'status_name' => ['title' => '状态', 'width' => '9%'], 'bill_time' => ['title' => '开票时间', 'width' => '9%']];
$fields2 = [
'car_name' => ['title' => '车辆', 'width' => '27%'], 'biz_name' => ['title' => '门店', 'width' => '12%'],
'price' => ['title' => '车辆平台价', 'width' => '9%'], 'payway_name' => ['title' => '付款方式', 'width' => '8%'],
'of_title' => ['title' => '客户来源', 'width' => '10%'], 'status_name' => ['title' => '状态', 'width' => '9%'],
'bill_time' => ['title' => '开票时间', 'width' => '9%']
];
} else {
$fields2 = ['car_name' => ['title' => '车辆', 'width' => '27%'],
'biz_name' => ['title' => '门店', 'width' => '12%'], 'price' => ['title' => '车辆平台价', 'width' => '9%'],
'payway_name' => ['title' => '付款方式', 'width' => '8%'], 'of_title' => ['title' => '客户来源', 'width' => '10%'],
'status_name' => ['title' => '状态', 'width' => '9%'],
'c_time' => ['title' => '订单时间', 'width' => '9%']];
$fields2 = [
'car_name' => ['title' => '车辆', 'width' => '27%'], 'biz_name' => ['title' => '门店', 'width' => '12%'],
'price' => ['title' => '车辆平台价', 'width' => '9%'], 'payway_name' => ['title' => '付款方式', 'width' => '8%'],
'of_title' => ['title' => '客户来源', 'width' => '10%'], 'status_name' => ['title' => '状态', 'width' => '9%'],
'order_time' => ['title' => '下定时间', 'width' => '9%']
];
}
$fields = array_merge($fields1, $fields2);
if ($export) {
+8 -1
View File
@@ -19,6 +19,7 @@ class Business extends Wxapp{
$this->load->model('auto/auto_cars_model');
$this->load->model('auto/auto_business_model');
$this->load->model("biz/biz_model");
$this->load->library('receiver/orders_v2_entity');
}
protected function get(){
@@ -60,6 +61,11 @@ class Business extends Wxapp{
$price_color = in_array($color_id,$color_arr) ? $row['price_color'] : 0;
$price_coplus = $main_type ? $row['price_coplus'] : 0;
$city_list = $this->orders_v2_entity->local_bill_citys;
$show_local_bill = false;
if(in_array($city_id,$city_list)){
$show_local_bill = true;
}
$data = [
'id' => $row['id'],
'price' => $car['price_car'] ? floatval($car['price_car']) : 0,
@@ -70,7 +76,8 @@ class Business extends Wxapp{
'dis_fine_money_list' => $dis_fine_money_list,
'deposit_list' => $deposit_list,
'price_color' => floatval($price_color),
'price_coplus' => floatval($price_coplus)
'price_coplus' => floatval($price_coplus),
'show_local_bill' => $show_local_bill,
];
return $data;
+41 -18
View File
@@ -35,6 +35,7 @@ class CusorderV2 extends Wxapp{
$this->load->model('auto/auto_business_model');
$this->load->model("biz/biz_model");
$this->load->model('items/items_model');
$this->load->model('sys/sys_finance_model');
$this->load->model('sys/sys_city_model');
@@ -88,6 +89,7 @@ class CusorderV2 extends Wxapp{
$car_city_id = $this->input_param('c_city_id');//上牌城市
$pro = $this->input_param('pro'); //省市数组
$sa = $this->input_param('sa'); //补充协商
$if_local_bill = $this->input_param('if_local_bill');//是否需要开具本地发票
$row = $this->customers_model->get(['id'=>$cus_id]);
$series_row = $this->auto_series_model->get(['id'=>$car_id]);
@@ -95,6 +97,9 @@ class CusorderV2 extends Wxapp{
if(!$row || !$series_row ||!$delry_time || !$name || !$mobile || !$business_row || !$deposit){
throw new Exception('参数错误', ERR_PARAMS_ERROR);
}
if($if_local_bill && !$car_city_id){
throw new Exception('请填写上牌城市', ERR_PARAMS_ERROR);
}
if($main_type){//公司
if(!$company || !$c_credit){
throw new Exception('请填写公司信息', ERR_PARAMS_ERROR);
@@ -173,6 +178,7 @@ class CusorderV2 extends Wxapp{
$car_city_id && $info_json['car_city_id'] = $car_city_id;
$info_json && $data['info_json'] = json_encode($info_json,JSON_UNESCAPED_UNICODE);
$finance_row && $data['finance_id'] = $finance_row['id'];
$if_local_bill && $data['if_local_bill'] = 1;
//获取金额json数据
$orders_entity = new orders_v2_entity();
@@ -319,7 +325,7 @@ class CusorderV2 extends Wxapp{
$main_type = $this->input_param('main_type');
$delry_time = $this->input_param('delry_time');
$finance_id = $this->input_param('finance_id');
$deposit = $this->input_param('deposit');
$deposit = floatval($this->input_param('deposit'));
$disc_money = floatval($this->input_param('disc_money'));//优惠金额
$disc_fine_money = floatval($this->input_param('disc_fine_money'));//精品优惠金额
$if_fine = $this->input_param('if_fine');
@@ -327,6 +333,7 @@ class CusorderV2 extends Wxapp{
$fines = $this->input_param('fines');
$business_id = $this->input_param('business_id'); //商务政策id
$sa = $this->input_param('sa'); //补充协商
$if_local_bill = $this->input_param('if_local_bill');//是否需要开具本地发票
$row = $this->orders_model->get(['id'=>$id]);
$series_row = $this->auto_series_model->get(['id'=>$car_id]);
@@ -341,6 +348,7 @@ class CusorderV2 extends Wxapp{
if(!$row || !$series_row || !$car_row || !$business_row){
throw new Exception('参数错误', ERR_PARAMS_ERROR);
}
if($deposit<2000){
throw new Exception('定金不得少于2000', ERR_PARAMS_ERROR);
}
@@ -379,7 +387,8 @@ class CusorderV2 extends Wxapp{
'incor_id' => $incolor_id,
'payway' => $payway ? 1 : 0,
'if_insure' => 0,
'if_num' => 0
'if_num' => 0,
'if_local_bill' => $if_local_bill ? 1 : 0
];
$main_type && $data['main_type'] = 1;
$delry_time && $data['delry_time'] = $delry_time;
@@ -457,32 +466,33 @@ class CusorderV2 extends Wxapp{
$car_data['车辆级别'] = $version;
$car_data['车身颜色'] = $color;
$car_data['平台售价'] = $money_json['price_car'];
$money_json['price_coplus'] && $car_data['公司加价'] = $money_json['price_coplus'];
$money_json['price_color'] && $car_data['颜色加价'] = $money_json['price_color'];
$car_data['定金'] = $money_json['price_book'];
$money_json['price_coplus'] && $car_data['公司加价'] = sprintf("%.2f",$money_json['price_coplus']);
$money_json['price_color'] && $car_data['颜色加价'] = sprintf("%.2f",$money_json['price_color']);
$car_data['定金'] = sprintf("%.2f",$money_json['price_book']);
$car_price_list = [];
$money_json['price_discount'] && $car_price_list['优惠'] = $money_json['price_discount'];
$money_json['price_discount'] && $car_price_list['优惠'] = sprintf("%.2f",$money_json['price_discount']);
$car_data['最终售价'] =[
'list' => $car_price_list,
'value' => $orders_entity->total_price($row['id'])
'value' => sprintf("%.2f",$orders_entity->total_price($row['id']))
];
//服务费
$srv_data = $orders_entity->order_srv_money($row['id'],1);
if($srv_data['total']>0){
$car_data['委托代办']['value'] = $srv_data['total'];
$car_data['委托代办']['value'] = sprintf("%.2f",$srv_data['total']);
foreach($srv_data['list'] as $val){
$car_data['委托代办']['list'][$val['title']] = is_numeric($val['money']) ? $val['money']:'';
$car_data['委托代办']['list'][$val['title']] = is_numeric($val['money']) ? sprintf("%.2f",$val['money']):'';
}
if($row['fines']){
$fines = json_decode($row['fines'],true);
$fines_list = [];
foreach ($fines as $item) {
$fines_list['list'][$item['txt']] = $item['price'] ? $item['price'] : '';
$fines_list['list'][$item['txt']] = $item['price'] ? sprintf("%.2f",$item['price']) : '';
}
$fines_list['value'] = $money_json['price_fine_select'] ? $money_json['price_fine_select'] : 0.00;
$fines_list['value'] = $money_json['price_fine_select'] ? sprintf("%.2f",$money_json['price_fine_select']) : 0.00;
$car_data['委托代办']['list']['精品选装'] = $fines_list;
}
}
$car_data['需开具本地发票'] = $row['if_local_bill'] ? '需要' : '不需要';
}
if(!$row['payway'] && $row['brand_id']){
$finance_row = $this->sys_finance_model->get(['id'=>$row['finance_id']],'title');
@@ -518,9 +528,9 @@ class CusorderV2 extends Wxapp{
'incolor_id' => $row['incor_id'],
'delry_time' => $row['delry_time']!='0000-00-00 00:00:00' ? date('Y-m-d',strtotime($row['delry_time'])):'',
'finance_id' => !$row['payway'] ? $row['finance_id'] : '',
'deposit' => $money_json['price_book'] ? $money_json['price_book'] : 0,
'disc_money' => $money_json['price_discount'] ? $money_json['price_discount'] : '',
'disc_fine_money' => $money_json['price_fine_discount'] ? $money_json['price_fine_discount'] : 0,
'deposit' => $money_json['price_book'] ? sprintf("%.2f",$money_json['price_book']): 0,
'disc_money' => $money_json['price_discount'] ? sprintf("%.2f",$money_json['price_discount']) : '',
'disc_fine_money' => $money_json['price_fine_discount'] ? sprintf("%.2f",$money_json['price_fine_discount']) : 0,
'srv_arr' => $row['srv_ids'] ? json_decode($row['srv_ids'],true) : [],
'cus_id' => $row['customer_id'],
'status' => $row['status'],
@@ -529,7 +539,8 @@ class CusorderV2 extends Wxapp{
'fines' => $row['fines'] ? json_decode($row['fines'],true) : [],
'address' => $info_json['c_address'] ? $info_json['c_address'] : '',
'pro' => $info_json['pro'] ? $info_json['pro'] : [],
'c_city_id' => $info_json['car_city_id']
'c_city_id' => $info_json['car_city_id'],
'if_local_bill' => $row['if_local_bill'],
];
if($row['main_type']){
$info_json['c_credit'] && $data['credit'] = $info_json['c_credit'];
@@ -620,7 +631,7 @@ class CusorderV2 extends Wxapp{
}else{
strlen($status) && $where['status'] = $status;
}
$fileds = 'id,customer_id,name,mobile,brand_id,s_id,v_id,cor_id,incor_id,payway,status,c_time,money_json,if_num,info_json,main_type,owner_name,owner_mobile';
$fileds = 'id,customer_id,name,mobile,brand_id,s_id,v_id,cor_id,incor_id,payway,status,c_time,money_json,if_num,info_json,main_type,owner_name,owner_mobile,item_id';
$count = $this->orders_model->count($where);
$lists = [];
if($count){
@@ -647,7 +658,15 @@ class CusorderV2 extends Wxapp{
];
$old_rows = $this->receiver_orders_model->map('id','status',$where,'','','','id,status');
}
$item_map = [];
$item_arr_ids = array_unique(array_column($rows,'item_id'));
if($item_arr_ids){
$str_ids = implode(',',$item_arr_ids);
$where = [
"id in ({$str_ids})" => null
];
$item_map = $this->items_model->map('id','vin',$where,'','','','id,vin');
}
//获取订单资料
$order_datas = $this->receiver_order_datas_model->get_map_by_oids(array_column($rows,'id'),'id,o_id,cardida,business_licence,car_img,register_img,ins_img,other_img');
$status_arr = $this->orders_model->get_status();
@@ -703,7 +722,11 @@ class CusorderV2 extends Wxapp{
if(!$val['payway']){
$other_data['分期办理'] = ['type'=> 'text','value'=>$this->orders_status_entity->status_cn($val['id'],1),'bg_color'=>''];
}
$other_data['车辆分配'] = ['type'=> 'text','value'=>$this->orders_status_entity->status_cn($val['id'],2),'bg_color'=>''];
$pc_cn = '待分配';
if($this->orders_status_entity->get_finish($val['id'],2,1)){ //已配车
$pc_cn = $item_map[$val['item_id']];
}
$other_data['车辆分配'] = ['type'=> 'text','value'=>$pc_cn,'bg_color'=>''];
$other_data['发票'] = ['type'=> 'text','value'=>$this->orders_status_entity->status_cn($val['id'],3),'bg_color'=>''];
if($val['main_type']){//公司
$other_data['营业执照'] = ['type'=> 'text','value'=>$img_status['business_licence']['text'],'bg_color'=>$img_status['business_licence']['color']];
+1 -1
View File
@@ -393,7 +393,7 @@ class Protocol extends CI_Controller{
$imgs = $this->pdf->pdf2img($pdf_url);
if($imgs){
if(!$row['flag']){
$companys = $this->orders_v2_entity->get_biz_mchid($order['biz_id'],$order['brand_id']);
$companys = $this->orders_v2_entity->get_biz_mchid($order['biz_id'],$order['brand_id'],$order['if_local_bill']);
$img_seal = build_qiniu_image_url($companys['company']['img_seal']);
$width = 325;
if($row['type']==1){
+20 -7
View File
@@ -14,6 +14,7 @@ class Orders_v2_entity{
const V2_START_ID = 10000; //升级后订单开始
private $ci;
public $local_bill_citys = ['350200','350500','350100']; //厦门、泉州、福州 显示本地开票按钮
public function __construct(){
$this->ci = & get_instance();
@@ -71,7 +72,7 @@ class Orders_v2_entity{
$sub_row = $this->ci->app_liche_orders_model->get(['o_id'=>$this->order_row['id'],'type'=>4,'status>='=>0]);
if($pid && !$sub_row){
//获取微信商户号
$companys = $this->get_biz_mchid($this->order_row['biz_id'],$this->order_row['brand_id']);
$companys = $this->get_biz_mchid($this->order_row['biz_id'],$this->order_row['brand_id'],$this->order_row['if_local_bill']);
$sid = create_order_no(350200,'liche',1,4);
$sub_data = [
'o_id' => $this->order_row['id'],
@@ -98,9 +99,10 @@ class Orders_v2_entity{
* 获取商家微信商户号
* @param $biz_id int 商家id
* @param $car_brand_id int 品牌id
* @param $if_local_bill int 是否开具本地发票
* @return array ['company'=>[],'srv_company'=>[]]
*/
public function get_biz_mchid($biz_id,$car_brand_id=0){
public function get_biz_mchid($biz_id,$car_brand_id=0,$if_local_bill=false){
$biz = $this->ci->biz_model->get(['id'=>$biz_id],'type,city_id,company_id,srv_company_id,car_brand_id');
$filed = 'id,wx_mchid,title,short,credit_code,wx_mchid,img_seal';
if(in_array($biz['type'],[1])){ //品牌店
@@ -121,10 +123,14 @@ class Orders_v2_entity{
$srv_company = $companys[$brand_biz['srv_company_id']][0];
}
}
if(!$company){ //获取城市销售公司
$local_city = false;
if(in_array($biz['city_id'],$this->local_bill_citys) && $if_local_bill){ //是否开具本地发票且在指定城市用本地城市
$local_city = true;
}
if(!$company || $local_city){ //获取城市销售公司
$company = $this->ci->sys_company_model->get(['city_id'=>$biz['city_id'],'type'=>1,'status'=>1],$filed);
}
if(!$srv_company){ //获取城市服务公司
if(!$srv_company || $local_city){ //获取城市服务公司
$srv_company = $this->ci->sys_company_model->get(['city_id'=>$biz['city_id'],'type'=>0,'status'=>1],$filed);
}
if(!$company){ //获取固定id销售公司
@@ -262,7 +268,7 @@ class Orders_v2_entity{
$sub_row = $this->ci->app_liche_orders_model->get(['o_id'=>$this->order_row['id'],'type'=>1,'status>='=>0]);
if($pid && !$sub_row){
//获取微信商户号
$companys = $this->get_biz_mchid($this->order_row['biz_id'],$this->order_row['brand_id']);
$companys = $this->get_biz_mchid($this->order_row['biz_id'],$this->order_row['brand_id'],$this->order_row['if_local_bill']);
$sid = create_order_no(350200,'liche',1,1);
$sub_data = [
'o_id' => $this->order_row['id'],
@@ -302,7 +308,7 @@ class Orders_v2_entity{
}
//获取微信商户号
$companys = $this->get_biz_mchid($this->order_row['biz_id'],$this->order_row['brand_id']);
$companys = $this->get_biz_mchid($this->order_row['biz_id'],$this->order_row['brand_id'],$this->order_row['if_local_bill']);
$srv_money = $this->order_srv_money($oid); //服务费
$money_json = json_decode($this->order_row['money_json'],true);
@@ -452,7 +458,14 @@ class Orders_v2_entity{
}
$this->add_order($row['id'],$userinfo['id']);
//合同重新生成
$need_del_con = false;
if($this->ci->receiver_order_contracts_model->count(['o_id'=>$row['id'],'type in (0,1)'=>null])){
$need_del_con = true;
}
if($new_data['if_local_bill']!=$row['if_local_bill']){
$need_del_con = true;
}
if($need_del_con){
$this->ci->receiver_order_contracts_model->delete(['o_id'=>$row['id'],'type in (0,1)'=>null]);
}
}
@@ -605,7 +618,7 @@ class Orders_v2_entity{
}
$data['now_day'] = date('Y-m-d');
$data['companys'] = $this->get_biz_mchid($row['biz_id'],$row['brand_id']);
$data['companys'] = $this->get_biz_mchid($row['biz_id'],$row['brand_id'],$row['if_local_bill']);
if($type==1){
$items = $this->ci->items_model->get(['id'=>$row['item_id']],'vin');
$delivery = $this->ci->deliverys_model->get(['o_id'=>$row['id']],'info,tool,remark');