public function add() { $sales['email'] = I('email'); $sales['password'] = I('password'); $sales['phone'] = I('phone'); $sales['real_name'] = I('real_name'); $sales['saleor_name'] = I('saleor_name'); $sales['address'] = I('address'); $sales['describe'] = I('describe'); $salesLogo = $_FILES['logo']; $logoUrl = null; $salesLogic = new l\SalesLogic(); if ($salesLogo != '' && $salesLogo != null) { $filepath = UploadBeforeOss($salesLogo); $logoName = "sales/pic/" . uniqid() . strrchr($salesLogo['name'], 46); $logoUrl = C('OSS_FILE_PREFIX') . '/' . $logoName; //上传文件到OSS if (!ImgOssUpload($logoName, $filepath)) { $data['status'] = 300; $data['message'] = '图片上传失败'; $data['error_code'] = 10002; $this->ajaxReturn($data, 'JSON'); } } $result = $salesLogic->addSales($sales, $logoUrl); $data['status'] = $result['status']; $data['message'] = $result['message']; S('sales', NULL); $this->ajaxReturn($data, 'JSON'); }
public function add() { if (I('brand-name') == null) { $this->display(); } else { $brandName = I('brand-name'); $brandLogo = $_FILES['brand-logo']; $img_name = "brand/pic/" . uniqid() . strrchr($brandLogo['name'], 46); $filepath = UploadBeforeOss($brandLogo); //上传图片到服务器,获取服务器文件路径 $brandLogic = new l\BrandLogic(); $logoUrl = null; if ($brandLogo != '') { //上传文件到OSS if (ImgOssUpload($img_name, $filepath)) { $logoUrl = C('OSS_FILE_PREFIX') . '/' . $img_name; } else { $data['status'] = 300; $data['message'] = '图片上传失败'; $data['error_code'] = 10002; $this->ajaxReturn($data, 'JSON'); } } $result = $brandLogic->addBrand($brandName, $logoUrl); $data['status'] = $result['status']; $data['message'] = $result['message']; S('brands', NULL); $this->ajaxReturn($data, 'JSON'); } }
public function add() { $initialLogic = new l\InitialLogic(); $brandList = $initialLogic->getAllBrands(); $salesList = $initialLogic->getAllSales(); $brandName = I('brandName'); $brandID = $brandList['Map'][$brandName]; $salesName = I('salesName'); $salesID = $salesList['Map'][$salesName]; $break_pic = $_FILES['break_pics']; $bill_pic = $_FILES['billphoto']; $break_pics = null; $invoice_pic = null; if ($break_pic != '' && $break_pic != null) { $break_photo_name = "order/pic/breakphoto/" . uniqid() . strrchr($break_pic['name'], 46); $filepath = UploadBeforeOss($break_pic); $break_pics = C('OSS_FILE_PREFIX') . '/' . $break_photo_name; if (!ImgOssUpload($break_photo_name, $filepath)) { $data['status'] = 300; $data['message'] = '图片上传失败'; $data['error_code'] = 10002; $this->ajaxReturn($data, 'JSON'); } } if ($bill_pic != '' && $bill_pic != null) { $bill_photo_name = "order/pic/billphoto/" . uniqid() . strrchr($bill_pic['name'], 46); $filepath = UploadBeforeOss($bill_pic); $invoice_pic = C('OSS_FILE_PREFIX') . '/' . $bill_photo_name; if (!ImgOssUpload($bill_photo_name, $filepath)) { $data['status'] = 300; $data['message'] = '图片上传失败'; $data['error_code'] = 10002; $this->ajaxReturn($data, 'JSON'); } } $order['send_type'] = I('order_type'); $order['appliance_id'] = I('appliance-father'); $order['uappliance_id'] = I('appliance'); $order['brand_id'] = $brandID; $order['servicetime'] = I('servicetime'); $order['phone'] = I('customerPhone'); $order['user_name'] = I('customerName'); $order['address'] = I('prov') . "-" . I('city') . "-" . I('dist') . "-" . I('address') . "-" . I('doorNumber'); $order['is_auto'] = I('pushMethod'); $order['mer_only_code'] = I('merchant_code'); $order['buy_time'] = I('buytime'); $order['invoice'] = I('billNumber'); $order['buy_mer_id'] = $salesID; $order['break_describe'] = I('break_describe'); $order['invoice_pic'] = $invoice_pic; $order['break_pics'] = $break_pics; //$logdata = json_encode($order); //addErrorLog("Order","add","address",$logdata); $orderLogic = new l\OrderLogic(); $result = $orderLogic->addOrder($order); $data['success'] = true; $data['status'] = $result['status']; $data['message'] = $result['message']; $this->ajaxReturn($data, 'JSON'); }
public function addpar() { if (I('applianceName') == null) { $applianceLogic = new l\ApplianceLogic(); $father_list = $applianceLogic->getApplianceFatherList(); $this->assign('father_list', $father_list); $this->display(); } else { $applianceName = I('applianceName'); $fid = I('appliance-father'); $img1 = $_FILES['shd-photo']; $img2 = $_FILES['shd-photo-little']; $img3 = $_FILES['yhd-photo']; $img4 = $_FILES['yhd-qxby-photo']; $big_logo = null; $small_logo = null; $middle_logo = null; $middle2_logo = null; if ($img1 != '' && $img1 != null) { $img_name1 = "appliance/pic/shd_img/" . uniqid() . strrchr($img1['name'], 46); $filepath1 = UploadBeforeOss($img1); $big_logo = C('OSS_FILE_PREFIX') . '/' . $img_name1; if (!ImgOssUpload($img_name1, $filepath1)) { $data['status'] = 300; $data['message'] = '图片上传失败'; $data['error_code'] = 10002; $this->ajaxReturn($data, 'JSON'); } } if ($img2 != '' && $img2 != null) { $img_name2 = "appliance/pic/shd_little_img/" . uniqid() . strrchr($img2['name'], 46); $filepath2 = UploadBeforeOss($img2); $small_logo = C('OSS_FILE_PREFIX') . '/' . $img_name2; if (!ImgOssUpload($img_name2, $filepath2)) { $data['status'] = 300; $data['message'] = '图片上传失败'; $data['error_code'] = 10002; $this->ajaxReturn($data, 'JSON'); } } if ($img3 != '' && $img3 != null) { $img_name3 = "appliance/pic/yhd_img/" . uniqid() . strrchr($img3['name'], 46); $filepath3 = UploadBeforeOss($img3); $middle_logo = C('OSS_FILE_PREFIX') . '/' . $img_name3; if (!ImgOssUpload($img_name3, $filepath3)) { $data['status'] = 300; $data['message'] = '图片上传失败'; $data['error_code'] = 10002; $this->ajaxReturn($data, 'JSON'); } } if ($img4 != '' && $img4 != null) { $img_name4 = "appliance/pic/yhd_qxby_img/" . uniqid() . strrchr($img4['name'], 46); $filepath4 = UploadBeforeOss($img4); $middle2_logo = C('OSS_FILE_PREFIX') . '/' . $img_name4; if (!ImgOssUpload($img_name4, $filepath4)) { $data['status'] = 300; $data['message'] = '图片上传失败'; $data['error_code'] = 10002; $this->ajaxReturn($data, 'JSON'); } } $applianceLogic = new l\ApplianceLogic(); $result = $applianceLogic->addAppliance($applianceName, $fid, $big_logo, $small_logo, $middle_logo, $middle2_logo); S('appliances', NULL); $data['status'] = $result['status']; $data['message'] = $result['message']; $this->ajaxReturn($data, 'JSON'); } }