|
@@ -383,6 +383,7 @@ class Consult extends Base
|
|
|
if($zxorder==false){
|
|
|
return error_show(1004,"未找到咨询信息数据");
|
|
|
}
|
|
|
+
|
|
|
// $cat =Db::name("cat")->where(["id"=>$zxinfo['cat_id']])->find();
|
|
|
// $budget = isset($cat['order_rate']) ? $cat['order_rate']:0;
|
|
|
|
|
@@ -2596,5 +2597,211 @@ class Consult extends Base
|
|
|
unset($list);
|
|
|
return app_show(0, "获取成功", ['count' => $count, 'list' => $data]);
|
|
|
}
|
|
|
+ /**复制数据
|
|
|
+ * @return \think\response\Json|void
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\DbException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ */
|
|
|
+ public function zxcopy(){
|
|
|
+ $infoNo= isset($this->post['infoNo'])&&$this->post['infoNo']!=""?trim($this->post['infoNo']):"";
|
|
|
+ if($infoNo==""){
|
|
|
+ return error_show(1004,"参数infoNo不能为空");
|
|
|
+ }
|
|
|
+ $zxinfo = Db::name("consult_info")->where(["infoNo"=>$infoNo,"is_del"=>0])->find();
|
|
|
+ if($zxinfo==false){
|
|
|
+ return error_show(1004,"未找到信息数据");
|
|
|
+ }
|
|
|
+ $zxorder = Db::name("consult_order")->where(["zxNo"=>$zxinfo['zxNo']])->value("is_project",0);
|
|
|
+ if($zxorder==1)return error_show(1003,"项目类型咨询单不可进行此项复制");
|
|
|
+ $zxinfo['status']=0;
|
|
|
+ $zxinfo['infoNo']=makeNo("IF");
|
|
|
+ $zxinfo['id']=null;
|
|
|
+ $zxinfo['bargain_status']=0;
|
|
|
+ $zxinfo['updatetime']=date("Y-m-d H:i:s");
|
|
|
+ $zxinfo['addtime']=date("Y-m-d H:i:s");
|
|
|
+ $copy=Db::name("consult_info")->insert($zxinfo,true);
|
|
|
+ if($copy==false)return error_show(1004,"咨询数据复制失败");
|
|
|
+ return app_show(0,"咨询数据复制成功",["infoNo"=>$zxinfo['infoNo']]);
|
|
|
+ }
|
|
|
+ /**修改编辑复制数据
|
|
|
+ * @return \think\response\Json|void
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\DbException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ */
|
|
|
+ public function zxCopyEdit(){
|
|
|
+ $infoNo= isset($this->post['infoNo'])&&$this->post['infoNo']!=""?trim($this->post['infoNo']):"";
|
|
|
+ if($infoNo==""){
|
|
|
+ return error_show(1004,"参数infoNo不能为空");
|
|
|
+ }
|
|
|
+ $zxinfo = Db::name("consult_info")->where(["infoNo"=>$infoNo,"is_del"=>0])->find();
|
|
|
+ if($zxinfo==false){
|
|
|
+ return error_show(1004,"未找到信息数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ $enclosure_file =isset($this->post['enclosure_file'])&&$this->post['enclosure_file']!=""?trim($this->post['enclosure_file']):$zxinfo['enclosure_file'];
|
|
|
+
|
|
|
+ $good_name= isset($this->post['good_name'])&&$this->post['good_name']!=""?trim($this->post['good_name']):"";
|
|
|
+ if($good_name==""){
|
|
|
+ return error_show(1003,"参数good_name不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ $good_img= isset($this->post['good_img'])&&$this->post['good_img']!=""?trim($this->post['good_img']):"";
|
|
|
+ if($good_img==""){
|
|
|
+ return error_show(1003,"参数good_img不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ $cat_id= isset($this->post['cat_id'])&&$this->post['cat_id']!=""?intval($this->post['cat_id']):"";
|
|
|
+ if($cat_id==""){
|
|
|
+ return error_show(1003,"参数cat_id不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ $unit= isset($this->post['unit'])&&$this->post['unit']!=""?trim($this->post['unit']):"";
|
|
|
+ if($unit==""){
|
|
|
+ return error_show(1003,"参数unit不能为空");
|
|
|
+ }
|
|
|
+ $brand_id= isset($this->post['brand_id'])&&$this->post['brand_id']!==""?intval($this->post['brand_id']):"0";
|
|
|
+
|
|
|
+ $arrival_time= isset($this->post['arrival_time'])&&$this->post['arrival_time']!=""?$this->post['arrival_time']:"";
|
|
|
+ if($arrival_time==""){
|
|
|
+ return error_show(1003,"参数arrival_time不能为空");
|
|
|
+ }
|
|
|
+ $specin= isset($this->post['specinfo'])&&!empty($this->post['specinfo'])?$this->post['specinfo']:"";
|
|
|
+ if($specin==""){
|
|
|
+ return error_show(1003,"参数specinfo不能为空");
|
|
|
+ }
|
|
|
+ $cost_desc= isset($this->post['cost_desc'])&&$this->post['cost_desc']!=""?trim($this->post['cost_desc']):"";
|
|
|
+// if($cost_desc==""){
|
|
|
+// return error_show(1003,"参数cost_desc不能为空");
|
|
|
+// }
|
|
|
+ $is_addrs= isset($this->post['is_addrs'])&&$this->post['is_addrs']!==""?intval($this->post['is_addrs']):"";
|
|
|
+ if($is_addrs===""){
|
|
|
+ return error_show(1003,"参数is_addrs不能为空");
|
|
|
+ }
|
|
|
+ $is_custom= isset($this->post['is_custom'])&&$this->post['is_custom']!==""?trim($this->post['is_custom']):"";
|
|
|
+ if($is_custom===""){
|
|
|
+ return error_show(1003,"参数is_custom不能为空");
|
|
|
+ }
|
|
|
+ $metal_id= isset($this->post['metal_id'])&&$this->post['metal_id']!==""?intval($this->post['metal_id']):"";
|
|
|
+ if($metal_id===""){
|
|
|
+ return error_show(1003,"参数metal_id不能为空");
|
|
|
+ }
|
|
|
+ $config = isset($this->post['config'])&& $this->post['config']!=""?trim($this->post['config']):"";
|
|
|
+ $other_config = isset($this->post['other_config'])&& $this->post['other_config']!=""?trim($this->post['other_config']):"";
|
|
|
+ $specs_weight = isset($this->post['specs_weight'])&& $this->post['specs_weight']!==""?floatval($this->post['specs_weight']):"";
|
|
|
+ $gold_price = isset($this->post['gold_price'])&& $this->post['gold_price']!==""?floatval($this->post['gold_price']):"";
|
|
|
+ $is_gold_price = isset($this->post['is_gold_price'])&& $this->post['is_gold_price']!==""?intval($this->post['is_gold_price']):"0";
|
|
|
+ $budget_price = isset($this->post['budget_price'])&& $this->post['budget_price']!==""?floatval($this->post['budget_price']):"";
|
|
|
+ $total_weight = isset($this->post['total_weight'])&& $this->post['total_weight']!==""?floatval($this->post['total_weight']):"";
|
|
|
+ $num = isset($this->post['num'])&& $this->post['num']!==""?intval($this->post['num']):"";
|
|
|
+ if($num===""){
|
|
|
+ return error_show(1003,"参数num不能为空");
|
|
|
+ }
|
|
|
+ if($budget_price===""){
|
|
|
+ return error_show(1003,"参数budget_price不能为空");
|
|
|
+ }
|
|
|
+ $pgNo = isset($this->post['pgNo'])&& $this->post['pgNo']!="" ? trim($this->post['pgNo']):"";
|
|
|
+ $use_desc = isset($this->post['use_desc'])&& $this->post['use_desc']!="" ? trim($this->post['use_desc']):"";
|
|
|
|
|
|
+ $remark = isset($this->post['remark'])&& $this->post['remark']!="" ? trim($this->post['remark']):"";
|
|
|
+ if($remark==""){
|
|
|
+ return error_show(1003,"参数remark不能为空");
|
|
|
+ }
|
|
|
+ $endtime = isset($this->post['endtime'])&& $this->post['endtime']!="" ? trim($this->post['endtime']):"";
|
|
|
+ if($endtime==""){
|
|
|
+ return error_show(1003,"参数endtime不能为空");
|
|
|
+ }
|
|
|
+ if($metal_id!=0){
|
|
|
+ if($config==""){
|
|
|
+ return error_show(1003,"参数config不能为空");
|
|
|
+ }
|
|
|
+ if($other_config==""){
|
|
|
+ return error_show(1003,"参数other_config不能为空");
|
|
|
+ }
|
|
|
+ if($specs_weight===""){
|
|
|
+ return error_show(1003,"参数specs_weight不能为空");
|
|
|
+ }
|
|
|
+ if($gold_price===""){
|
|
|
+ return error_show(1003,"参数gold_price不能为空");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $specinfo=[];
|
|
|
+ foreach ($specin as $v){
|
|
|
+ $spec =Db::name("specs")->where(["id"=>$v['specid']])->find();
|
|
|
+ $spec_value =Db::name("spec_value")->where(["id"=>$v['spec_value_id']])->find();
|
|
|
+ $v['spec_name']=isset($spec['spec_name'])?$spec['spec_name']:"";
|
|
|
+ $v['spec_value_name']=isset($spec_value['spec_value'])?$spec_value['spec_value']:"";
|
|
|
+ $specinfo[]=$v;
|
|
|
+ }
|
|
|
+ Db::startTrans();
|
|
|
+ try{
|
|
|
+ $info=[
|
|
|
+ "good_name"=>$good_name,
|
|
|
+ "good_img"=>$good_img,
|
|
|
+ "cat_id"=>$cat_id,
|
|
|
+ "unit"=>$unit,
|
|
|
+ "brand_id"=>$brand_id,
|
|
|
+ "arrival_time"=>$arrival_time,
|
|
|
+ "specinfo"=>json_encode($specinfo),
|
|
|
+ "cost_desc"=>$cost_desc,
|
|
|
+ "is_addrs"=>$is_addrs,
|
|
|
+ "is_custom"=>$is_custom,
|
|
|
+ "metal_id"=>$metal_id,
|
|
|
+ "config"=>$config,
|
|
|
+ "other_config"=>$other_config,
|
|
|
+ "specs_weight"=>$specs_weight===""?0:$specs_weight,
|
|
|
+ "gold_price"=>$gold_price===""? 0 : $gold_price,
|
|
|
+ "is_gold_price"=>$is_gold_price===""?0:$is_gold_price,
|
|
|
+ "total_weight"=>$total_weight===""? $num*$specs_weight :$total_weight,
|
|
|
+ "budget_price"=>$budget_price,
|
|
|
+ "num"=>$num,
|
|
|
+ "pgNo"=>$pgNo,
|
|
|
+ "use_desc"=>$use_desc,
|
|
|
+ "remark"=>$remark,
|
|
|
+ "bargain_num"=>$zxinfo['bargain_num']+1,
|
|
|
+ "status"=>1,
|
|
|
+ "is_del"=>0,
|
|
|
+ "updatetime"=>date("Y-m-d H:i:s"),
|
|
|
+ 'bargain_status'=>1,
|
|
|
+ 'enclosure_file'=>$enclosure_file
|
|
|
+ ];
|
|
|
+ $up = Db::name("consult_info")->insert($info);
|
|
|
+ if($up){
|
|
|
+
|
|
|
+ //操作记录
|
|
|
+ ActionLog::logAdd(['id'=>$this->uid,'nickname'=>$this->uname], [
|
|
|
+ "order_code" => $infoNo,//咨询单详情编号
|
|
|
+ "status" => 0,//这里的status是之前的值
|
|
|
+ "action_remark" => '',//备注
|
|
|
+ "action_type" => "edit"//新建create,编辑edit,更改状态status
|
|
|
+ ], "ZXD", 1, $this->post);
|
|
|
+ //更新consule_order记录
|
|
|
+ $op = Db::name('consult_order')->where('zxNo',$zxinfo['zxNo'])->update(['endtime'=>$endtime, 'updatetime'=>date('Y-m-d H:i:s')]);
|
|
|
+ if($op==false)throw new \Exception("咨询单结束时间更新失败");
|
|
|
+ //维护台账记录
|
|
|
+ $insert_standing_book_data=[
|
|
|
+ 'standBookNo'=>makeNo('IO'),
|
|
|
+ 'infoNo'=>$infoNo,
|
|
|
+ 'addtime' => date('Y-m-d H:i:s'),
|
|
|
+ 'updatetime' => date('Y-m-d H:i:s')
|
|
|
+ ];
|
|
|
+
|
|
|
+ $temp_project = Db::name('consult_order')->field('id,projectNo,khNo,companyNo')->where(['zxNo'=>$zxinfo['zxNo'], 'is_del'=>0])->find();
|
|
|
+
|
|
|
+ if(!empty($temp_project)){
|
|
|
+ $insert_standing_book_data['companyNo']=$temp_project['companyNo'];
|
|
|
+ $insert_standing_book_data['customer_code']=$temp_project['khNo'];
|
|
|
+ }
|
|
|
+
|
|
|
+ Db::name('standing_book')->insert($insert_standing_book_data);
|
|
|
+ Db::commit();
|
|
|
+ return app_show(0,"咨询修改成功",["infoNo"=>$infoNo]);
|
|
|
+ }
|
|
|
+ }catch (\Exception $e){
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1004,$e->getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|