12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235 |
- <?php
- namespace app\abutment\controller;
- use app\admin\model\ActionLog;
- use app\admin\model\ProcessOrder;
- use think\facade\Db;
- use think\facade\Validate;
- class Consult extends HomeBaseController
- {
- private $noble = ['0' => '', '1' => '18K', '2' => '24K', '3' => '白银'];
- //招标工作台列表
- public function crontablist()
- {
- $this->post = $this->request->filter('trim')->post();
- $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) : "1";
- $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) : "10";
- //过滤贵金属相关的记录
- $where = [['a.is_del', "=", 0], ['b.is_del', "=", 0], ['a.cat_id', "not in", [6, 65, 88, 396, 718, 719, 819]]];
- $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
- if ($zxNo !== "") $where[] = ['a.zxNo', '=', $zxNo];
- $salesman = isset($this->post['salesman']) && $this->post['salesman'] !== "" ? trim($this->post['salesman']) : "";
- if ($salesman !== "") $where[] = ["b.salesman", 'like', "%$salesman%"];
- $cpName = isset($this->post['cpName']) && $this->post['cpName'] !== "" ? trim($this->post['cpName']) : "";
- if ($cpName !== "") $where[] = ["a.good_Name", 'like', "%$cpName%"];
- $khNo = isset($this->post['khNo']) && $this->post['khNo'] !== "" ? trim($this->post['khNo']) : "";
- if ($khNo !== "") $where[] = ["b.khNo", 'like', "%$khNo%"];
- $start = isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start'] : "";
- if ($start != "") $where[] = ["a.addtime", '>=', $start];
- $end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] : "";
- if ($end != "") $where[] = ["a.addtime", '<=', $end];
- $status = isset($this->post['status']) && $this->post['status'] !== "" ? trim($this->post['status']) : "";
- if ($status !== "") $where[] = ["a.status", '=', $status];
- $count = Db::name('consult_info')
- ->alias("a")
- ->leftJoin("consult_order b", "a.zxNo=b.zxNo")
- ->where($where)
- ->count();
- $total = ceil($count / $size);
- $page = $page >= $total ? $total : $page;
- $list = Db::name('consult_info')
- ->alias("a")
- ->leftJoin("consult_order b", "a.zxNo=b.zxNo")
- ->where($where)
- ->page($page, $size)
- ->field("a.*,b.createrid,b.creater,b.is_project,b.projectNo,b.khNo,b.endtime,b.platform_code,b.saleid,b.salesman,b.depart")
- ->select()
- ->toArray();
- $data = [];
- $all_cat = Db::name('cat')
- ->whereIn('id', array_column($list, 'cat_id'))
- ->column('order_rate', 'id');
- $all_brand = Db::name('brand')
- ->whereIn('id', array_column($list, 'brand_id'))
- ->column('brand_name', 'id');
- foreach ($list as $value) {
- $value['can'] = isset($value['cat_id']) && $value['cat_id'] != 0 ? made($value['cat_id']) : [];
- // $cat = Db::name("cat")->where(["id" => $value['cat_id']])->find();
- $budget = isset($all_cat[$value['cat_id']]) ? $all_cat[$value['cat_id']] : 0;
- $value['original_price'] = sprintf("%.2f", $value['budget_price'] * (1 - $budget / 100));
- // $brand = Db::name("brand")->where(['id' => $value['brand_id']])->find();
- $value['brand_name'] = isset($all_brand[$value['brand_id']]) && $all_brand[$value['brand_id']] != '' ? $all_brand[$value['brand_id']] : "";
- $value['khname'] = "";
- $value['specinfo'] = isset($value['specinfo']) && $value['specinfo'] != "" ? json_decode($value['specinfo'], true) : [];
- if ($value['khNo'] !== "") {
- $kh = Db::name("customer_info")
- ->where(['companyNo' => $value['khNo']])
- ->find();
- $value['khname'] = isset($kh['companyName']) ? $kh['companyName'] : "";
- }
- $consult = Db::name("consult_bids")
- ->where(["infoNo" => $value['infoNo'], "createrid" => $this->request->user['uid'], "is_del" => 0])
- ->find();
- $consults = Db::name("consult_bids")
- ->where(["infoNo" => $value['infoNo'], "is_del" => 0])
- ->find();
- $value['is_feed'] = $consult == false ? 0 : 1;
- $value['is_all_feed'] = $consults == false ? 0 : 1;
- $value['metal_name'] = isset($value['metal_id']) && $value['metal_id'] != 0 ? $this->noble[$value['metal_id']] : "";
- $data[] = $value;
- }
- return json_show(0, "获取成功", ['count' => $count, 'list' => $data]);
- }
- //招标工作台详情
- public function zxinfo()
- {
- $this->post = $this->request->filter('trim')->post();
- $infoNo = isset($this->post['infoNo']) && $this->post['infoNo'] != "" ? trim($this->post['infoNo']) : "";
- if ($infoNo == "") {
- return json_show(1004, "参数infoNo不能为空");
- }
- $zxinfo = Db::name("consult_info")->where(["infoNo" => $infoNo, "is_del" => 0])->find();
- if ($zxinfo == false) {
- return json_show(1004, "未找到信息数据");
- }
- $zxorder = Db::name("consult_order")->where(["zxNo" => $zxinfo['zxNo'], "is_del" => 0])->find();
- if ($zxorder == false) {
- return json_show(1004, "未找到咨询信息数据");
- }
- $cat = Db::name("cat")->where(["id" => $zxinfo['cat_id']])->find();
- $budget = isset($cat['order_rate']) ? $cat['order_rate'] : 0;
- $zxinfo['can'] = isset($zxinfo['cat_id']) && $zxinfo['cat_id'] != 0 ? made($zxinfo['cat_id'], []) : [];
- $zxinfo['khname'] = "";
- $zxinfo['original_price'] = sprintf("%.2f", $zxinfo['budget_price'] * (1 - $budget / 100));
- $zxinfo['khNo'] = "";
- $zxinfo['brand_id'] = $zxinfo['brand_id'] == 0 ? "" : $zxinfo['brand_id'];
- $zxinfo['brand'] = "";
- $zxinfo['companyNo'] = isset($zxorder['companyNo']) ? $zxorder['companyNo'] : "";
- $zxinfo['projectNo'] = isset($zxorder['projectNo']) ? $zxorder['projectNo'] : "";
- $zxinfo['is_project'] = isset($zxorder['is_project']) ? $zxorder['is_project'] : "";
- $zxinfo['company'] = "";
- $zxinfo['endtime'] = isset($zxorder['endtime']) ? $zxorder['endtime'] : "";
- $zxinfo['platform_code'] = isset($zxorder['platform_code']) ? $zxorder['platform_code'] : "";
- $zxinfo['salesman'] = isset($zxorder['salesman']) ? $zxorder['salesman'] : "";
- $zxinfo['saleid'] = isset($zxorder['saleid']) ? $zxorder['saleid'] : "";
- $zxinfo['depart'] = isset($zxorder['depart']) ? $zxorder['depart'] : "";
- $zxinfo['project_name'] = "";
- $zxinfo['budget_total'] = "";
- $zxinfo['departinfo'] = [];
- $zxinfo['unit_name'] = "";
- $zxinfo['metal_name'] = isset($zxinfo['metal_id']) && $zxinfo['metal_id'] != 0 ? $this->noble[$zxinfo['metal_id']] : "";
- $zxinfo['specinfo'] = json_decode($zxinfo['specinfo'], true);
- if ($zxorder['khNo'] !== "") {
- $kh = Db::name("customer_info")->where(['companyNo' => $zxorder['khNo']])->find();
- $zxinfo['khname'] = isset($kh['companyName']) ? $kh['companyName'] : "";
- $zxinfo['khNo'] = $zxorder['khNo'];
- }
- if ($zxinfo['unit'] !== "") {
- $unit = Db::name("unit")->where(['id' => $zxinfo['unit']])->find();
- $zxinfo['unit_name'] = isset($unit['unit']) ? $unit['unit'] : "";
- }
- if ($zxinfo['brand_id'] !== "") {
- $unit = Db::name("brand")->where(['id' => $zxinfo['brand_id']])->find();
- $zxinfo['brand'] = isset($unit['brand_name']) ? $unit['brand_name'] : "";
- }
- if ($zxorder['companyNo'] !== "") {
- $kh = Db::name("business")->where(['companyNo' => $zxorder['companyNo']])->find();
- $zxinfo['company'] = isset($kh['company']) ? $kh['company'] : "";
- }
- if ($zxorder['is_project'] == 1 && $zxorder['projectNo'] !== "") {
- $project = Db::name("project")->where(["projectNo" => $zxorder['projectNo'], "is_del" => 0])->find();
- $zxinfo['project_name'] = isset($project['project_name']) ? $project['project_name'] : "";
- $zxinfo['budget_total'] = isset($project['budget_total']) ? $project['budget_total'] : "";
- $zxinfo['project_use_desc'] = isset($project['use_desc']) ? $project['use_desc'] : "";
- $projectinfo = Db::name("project_info")->where(["pgNo" => $zxinfo['pgNo']])->find();
- $zxinfo['pgNo'] = isset($projectinfo['pgNo']) ? $projectinfo['pgNo'] : "";
- }
- if ($zxorder['depart'] > 0) {
- $zxinfo['departinfo'] = GetPart($zxorder['depart']);
- }
- if ($zxorder['platform_code'] > 0) {
- $palt = Db::name("platform")->where(["id" => $zxorder['platform_code']])->find();
- $zxinfo['platform_name'] = isset($palt['platform_name']) ? $palt['platform_name'] : "";
- }
- return json_show(0, "获取成功", $zxinfo);
- }
- //采反商品列表
- public function bidlist()
- {
- $this->post = $this->request->filter('trim')->post();
- $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) : "1";
- $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) : "10";
- $where = [['is_del', "=", 0]];
- $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
- if ($zxNo !== "") {
- $where[] = ['zxNo', 'like', '%' . $zxNo . '%'];
- }
- $infoNo = isset($this->post['infoNo']) && $this->post['infoNo'] !== "" ? trim($this->post['infoNo']) : "";
- if ($infoNo !== "") {
- $where[] = ['infoNo', 'like', '%' . $infoNo . '%'];
- }
- $bidNo = isset($this->post['bidNo']) && $this->post['bidNo'] !== "" ? trim($this->post['bidNo']) : "";
- if ($bidNo !== "") {
- $where[] = ['bidNo', 'like', '%' . $bidNo . '%'];
- }
- $pgNo = isset($this->post['pgNo']) && $this->post['pgNo'] !== "" ? trim($this->post['pgNo']) : "";
- if ($pgNo !== "") {
- $bidinfo = Db::name("consult_info")->where([["pgNo", "=", $pgNo], ["is_del", "=", 0]])->column("infoNo");
- $where[] = ['infoNo', 'in', $bidinfo];
- }
- $bargain_status = isset($this->post['bargain_status']) && $this->post['bargain_status'] !== "" ? intval($this->post['bargain_status']) : "";
- if ($bargain_status !== "") {
- $bidinfo = Db::name("consult_info")->where([["bargain_status", "=", $bargain_status], ["is_del", "=", 0]])->column("infoNo");
- $where[] = ['infoNo', 'in', $bidinfo];
- }
- $projectNo = isset($this->post['projectNo']) && $this->post['projectNo'] !== "" ? trim($this->post['projectNo']) : "";
- if ($projectNo !== "") {
- $zxlist = Db::name("consult_order")->where(["projectNo" => $projectNo, "is_del" => 0, "is_project" => 1])->column("zxNo");
- $where[] = ['zxNo', 'in', $zxlist];
- }
- $is_own = isset($this->post['is_own']) ? intval($this->post['is_own']) : "0";
- if ($is_own == 1) {
- // $token = isset($this->post['token']) ? trim($this->post['token']) : "";
- // if($token==""){
- // return json_show(101,'token不能为空');
- // }
- // $apply_id =GetUserInfo($token);
- // if(empty($apply_id)||$apply_id['code']!=0){
- // return json_show(1002,"申请人数据不存在");
- // }
- $rm = $this->request->user['uid'];
- $where[] = ['createrid', "=", $rm];
- }
- $count = Db::name('consult_bids')->where($where)->count();
- $total = ceil($count / $size);
- $page = $page >= $total ? $total : $page;
- $list = Db::name('consult_bids')->where($where)->page($page, $size)->select()->toArray();
- $data = [];
- foreach ($list as $value) {
- $catinfo = Db::name("cat")->where(["id" => $value['cat_id']])->find();
- $value['can'] = isset($value['cat_id']) && $value['cat_id'] != 0 ? made($value['cat_id']) : [];
- $unit = Db::name("unit")->where(["id" => $value['unit_id']])->find();
- $value['unit'] = isset($unit['unit']) ? $unit['unit'] : '';
- $supplier = Db::name("supplier")->where(["code" => $value['supplierNo']])->find();
- $value['supplierName'] = isset($supplier['name']) ? $supplier['name'] : "";
- if ($value['brand_id'] != 0) {
- $brand = Db::name("brand")->where(["id" => $value['brand_id']])->find();
- $value["brand_name"] = isset($brand['brand_name']) ? $brand['brand_name'] : "";
- } else {
- $value["brand_name"] = "";
- $value["brand_id"] = "";
- }
- $bidinfo = Db::name("consult_info")->where(["infoNo" => $value["infoNo"]])->find();
- $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate'] : 0;
- $god = [
- "metal_id" => $value['metal_id'],
- "weight" => $value["good_weight"],
- "demo_fee" => $value["demo_fee"],
- "delivery_fee" => $value["delivery_fee"],
- "open_fee" => $value["open_fee"],
- "packing_fee" => $value["pakge_fee"],
- "mark_fee" => $value["mark_fee"],
- "nake_fee" => $value["nake_fee"],
- "cert_fee" => $value["cert_fee"],
- // "cost_fee"=>$value["cost_fee"],
- "cost_fee" => $value["sale_cost_fee"] != $value['origin_cost_fee'] ? $value["sale_cost_fee"] : $value["cost_fee"],
- "num" => $bidinfo["num"],
- ];
- $top_cat = made($value['cat_id']);
- $top_cat_id = isset($top_cat[0]['id']) ? $top_cat[0]['id'] : 0;
- if ($value['is_gold_price'] == 1 && $top_cat_id == 6) {
- $price = GoldPrice($god, $budget / 100);
- $value['sale_price'] = round($price, 2);
- $value['origin_price'] = $value["sale_cost_fee"] != $value['origin_cost_fee'] ? $value["sale_price"] :
- $value["origin_price"];
- }
- $value['cost_fee'] = $value['origin_cost_fee'];
- $value['specinfo'] = json_decode($value['specinfo'], true);
- $value['metal_name'] = isset($value['metal_id']) && $value['metal_id'] != 0 ? $this->noble[$value['metal_id']] : "";
- $value['bargain_status'] = $bidinfo['bargain_status'];
- //reject驳回原因,status==5表示驳回
- $value['reject'] = [];
- if ($value['status'] >= 5) {
- $value['reject'] = Db::name('bargain_order')
- ->field('id,remark,status')
- ->where(['infoNo' => $infoNo, 'bidsNo' => $value['bidNo']])
- ->whereIn('status', [3, 8, 11])->order("id desc")
- ->find();
- }
- //产地
- $place = ["provice_code" => "", "city_code" => "", "area_code" => ""];
- if ($value['delivery_place'] != "") {
- list($place['provice_code'], $place['city_code'], $place['area_code']) = explode(",", $value['delivery_place']);
- }
- $value['delivery_place_cn'] = GetAddr(json_encode($place));
- $place = ["provice_code" => "", "city_code" => "", "area_code" => ""];
- if ($value['origin_place'] != "") {
- list($place['provice_code'], $place['city_code'], $place['area_code']) = explode(",", $value['origin_place']);
- }
- $value['origin_addr'] = GetAddr(json_encode($place));
- // if($value['origin_place']!=''){
- // $code = explode(",",$value['origin_place']);
- // $temp=[];
- // $temp['provice_code']=isset($code[0])?$code[0]:"";
- // $temp['city_code']=isset($code[1])?$code[1]:"";
- // $temp['area_code']=isset($code[2])?$code[2]:"";
- // $addr= GetAddr(json_encode($temp));
- // $value['origin_addr'] = $addr;
- // }
- $data[] = $value;
- }
- return json_show(0, "获取成功", ['count' => $count, 'list' => $data]);
- }
- //创建采反商品
- public function create()
- {
- $this->post = $this->request->filter('trim')->post();
- $is_project = isset($this->post['is_project']) && $this->post['is_project'] !== "" ? intval($this->post['is_project']) : "";
- if ($is_project === "") {
- return json_show(1002, "参数is_project不能为空");
- }
- if ($is_project == 1) {
- $projectNo = isset($this->post['projectNo']) && $this->post['projectNo'] !== "" ? trim($this->post['projectNo']) : "";
- if ($projectNo === "") {
- return json_show(1002, "参数projectNo不能为空");
- }
- }
- $khNo = isset($this->post['khNo']) && $this->post['khNo'] !== "" ? trim($this->post['khNo']) : "";
- if ($khNo === "") {
- return json_show(1002, "参数khNo不能为空");
- }
- $companyNo = isset($this->post['companyNo']) && $this->post['companyNo'] !== "" ? trim($this->post['companyNo']) : "";
- if ($companyNo === "") {
- return json_show(1002, "参数companyNo不能为空");
- }
- $endtime = isset($this->post['endtime']) && $this->post['endtime'] !== "" ? $this->post['endtime'] : "";
- if ($endtime === "") {
- return json_show(1002, "参数endtime不能为空");
- }
- $platform_code = isset($this->post['platform_code']) && $this->post['platform_code'] !== "" ? trim($this->post['platform_code']) :
- "";
- if ($platform_code === "") {
- return json_show(1002, "参数platform_code不能为空");
- }
- $ladder = isset($this->post['ladder']) && !empty($this->post['ladder']) ? $this->post['ladder'] : "";
- if ($ladder == "") {
- return json_show(1005, "参数ladder不能为空");
- }
- // $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
- // if($token==''){
- // return json_show(105,"参数token不能为空");
- // }
- // $user =GetUserInfo($token);
- // if(empty($user)||$user['code']!=0){
- // return json_show(102,"用户数据不存在");
- // }
- $createrid = $this->request->user['uid'];
- $creater = $this->request->user['nickname'];
- $depart = Db::name("depart_user")->where(["uid" => $createrid, "status" => 1, "is_del" => 0])->find();
- $zxNo = makeNo("ZX");
- Db::startTrans();
- try {
- $data = [
- "zxNo" => $zxNo,
- "createrid" => $createrid,
- "creater" => $creater,
- "is_project" => $is_project,
- "projectNo" => isset($projectNo) ? $projectNo : "",
- "khNo" => $khNo,
- "companyNo" => $companyNo,
- "endtime" => $endtime,
- "salesman" => $creater,
- "platform_code" => $platform_code,
- "saleid" => $createrid,
- "depart" => isset($depart['itemid']) ? $depart['itemid'] : 0,
- "status" => 0,
- "is_del" => 0,
- "addtime" => date("Y-m-d H:i:s"),
- "updatetime" => date("Y-m-d H:i:s"),
- ];
- $zx = Db::name("consult_order")->insert($data);
- if ($zx) {
- //判断是否是项目,且该项目是否存在台账记录中
- if ($is_project == 1) $stand_exists = Db::name('standing_book')->field('id')->where('projectNo', $projectNo)->find();
- foreach ($ladder as $value) {
- $infoNo = makeNo("IF");
- $specinfo = [];
- if (isset($value['specinfo']) && !empty($value['specinfo'])) {
- foreach ($value["specinfo"] 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;
- }
- }
- $info = [
- "infoNo" => $infoNo,
- "zxNo" => $zxNo,
- "spuCode" => "",
- "good_name" => $value['good_name'],
- "good_img" => $value['good_img'],
- "cat_id" => $value['cat_id'],
- "unit" => $value['unit'],
- "brand_id" => $value['brand_id'],
- "arrival_time" => $value['arrival_time'],
- "specinfo" => empty($specinfo) ? "" : json_encode($specinfo),
- "cost_desc" => isset($value['cost_desc']) ? $value['cost_desc'] : '',
- "is_addrs" => $value['is_addrs'],
- "is_custom" => $value['is_custom'],
- "metal_id" => $value['metal_id'],
- "config" => isset($value['config']) ? $value['config'] : "",
- "other_config" => isset($value['other_config']) ? $value['other_config'] : "",
- "specs_weight" => isset($value['specs_weight']) ? $value['specs_weight'] : "0",
- "gold_price" => isset($value['gold_price']) ? $value['gold_price'] : "0",
- "is_gold_price" => isset($value['is_gold_price']) ? $value['is_gold_price'] : "0",
- "total_weight" => isset($value['total_weight']) ? $value['total_weight'] : "0",
- "budget_price" => $value['budget_price'],
- "num" => $value['num'],
- "pgNo" => isset($value['pgNo']) && $value['pgNo'] !== "" ? trim($value['pgNo']) : "",
- "use_desc" => $value['use_desc'],
- "remark" => $value['remark'],
- "status" => 1,
- "is_del" => 0,
- "addtime" => date("Y-m-d H:i:s"),
- "updatetime" => date("Y-m-d H:i:s"),
- 'enclosure_file' => isset($value['enclosure_file']) ? $value['enclosure_file'] : '',
- ];
- $up = Db::name("consult_info")->insertGetId($info);
- if (!$up) {
- Db::rollback();
- return json_show(1004, '添加失败');
- } else {
- //修改状态
- ActionLog::logAdd(['id' => $createrid, 'nickname' => $creater], [
- "order_code" => $infoNo,//咨询单详情编号
- "status" => 1,//这里的status是之前的值
- "action_remark" => '',//备注
- "action_type" => "create"//新建create,编辑edit,更改状态status
- ], "ZXD", 1, $info);
- //竞价单不走流程,不推待办已办
- // ProcessOrder::AddProcess(['id' => $createrid, 'nickname' => $creater], [
- // "order_type" => 'ZXD',
- // "order_code" => $infoNo,//咨询单详情编号
- // "order_id" => $up,
- // "order_status" => 1,
- // 'before_status'=>0
- // ]);
- //如果存在该项目编码,更新对应的第一个竞价单编码,其他竞价单编码新增(带着项目编码)
- if (isset($stand_exists)) {
- Db::name('standing_book')
- ->where('id', $stand_exists['id'])
- ->update([
- 'infoNo' => $infoNo,
- 'updatetime' => date('Y-m-d H:i:s')
- ]);
- unset($stand_exists);//后面的竞价单编码不用更新,都是新增
- } else {
- //添加台账信息
- Db::name('standing_book')
- ->insert([
- 'standBookNo' => makeNo("IO"),
- 'projectNo' => isset($projectNo) ? $projectNo : '',
- 'infoNo' => $infoNo,
- 'companyNo' => $companyNo,
- 'customer_code' => $khNo,
- 'addtime' => date('Y-m-d H:i:s'),
- 'updatetime' => date('Y-m-d H:i:s')
- ]);
- }
- }
- }
- Db::commit();
- return json_show(0, "新建成功", ["zxNo" => $zxNo]);
- } else {
- Db::rollback();
- return json_show(1004, "新建失败");
- }
- } catch (\Exception $e) {
- Db::rollback();
- return json_show(1003, $e->getMessage());
- }
- }
- //复制上面的bidlist方法,只更改排序方式
- public function bidlistCopy()
- {
- $this->post = $this->request->filter('trim')->post();
- $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) : "1";
- $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) : "10";
- $where = [['cb.is_del', "=", 0], ['c.status', '<>', 6]];//不要'取消转单'状态下的数据
- $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
- if ($zxNo !== "") {
- $where[] = ['cb.zxNo', 'like', '%' . $zxNo . '%'];
- }
- $infoNo = isset($this->post['infoNo']) && $this->post['infoNo'] !== "" ? trim($this->post['infoNo']) : "";
- if ($infoNo !== "") {
- $where[] = ['cb.infoNo', 'like', '%' . $infoNo . '%'];
- }
- $bidNo = isset($this->post['bidNo']) && $this->post['bidNo'] !== "" ? trim($this->post['bidNo']) : "";
- if ($bidNo !== "") {
- $where[] = ['cb.bidNo', 'like', '%' . $bidNo . '%'];
- }
- $pgNo = isset($this->post['pgNo']) && $this->post['pgNo'] !== "" ? trim($this->post['pgNo']) : "";
- if ($pgNo !== "") {
- $bidinfo = Db::name("consult_info")->where([["pgNo", "=", $pgNo], ["is_del", "=", 0]])->column("infoNo");
- $where[] = ['cb.infoNo', 'in', $bidinfo];
- }
- $bargain_status = isset($this->post['bargain_status']) && $this->post['bargain_status'] !== "" ? intval($this->post['bargain_status']) : "";
- if ($bargain_status !== "") {
- $bidinfo = Db::name("consult_info")->where([["bargain_status", "=", $bargain_status], ["is_del", "=", 0]])->column("infoNo");
- $where[] = ['cb.infoNo', 'in', $bidinfo];
- }
- $projectNo = isset($this->post['projectNo']) && $this->post['projectNo'] !== "" ? trim($this->post['projectNo']) : "";
- if ($projectNo !== "") {
- $zxlist = Db::name("consult_order")->where(["projectNo" => $projectNo, "is_del" => 0, "is_project" => 1])->column
- ("zxNo");
- $where[] = ['cb.zxNo', 'in', $zxlist];
- }
- $is_own = isset($this->post['is_own']) ? intval($this->post['is_own']) : "0";
- if ($is_own == 1) {
- // $token = isset($this->post['token']) ? trim($this->post['token']) : "";
- // if ($token == "") {
- // return json_show(101, 'token不能为空');
- // }
- // $apply_id = GetUserInfo($token);
- // if (empty($apply_id) || $apply_id['code'] != 0) {
- // return json_show(1002, "申请人数据不存在");
- // }
- $where[] = ['cb.createrid', "=", $this->request->user['uid']];
- $where[] = ['cb.supplierNo', "=", $this->request->user['supplierNo']];
- }
- $company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
- if ($company_name !== "") $where[] = ["cb.createrid", 'in', get_company_item_user_by_name($company_name)];
- $count = Db::name('consult_bids')
- ->alias('cb')
- ->leftJoin("depart_user u", "u.uid=cb.createrid AND u.is_del=0")
- ->leftJoin("consult_info c", "c.infoNo=cb.infoNo")
- ->where($where)
- ->count();
- $total = ceil($count / $size);
- $page = $page >= $total ? $total : $page;
- $list = Db::name('consult_bids')
- ->alias('cb')
- ->field('cb.*,u.itemid')
- ->leftJoin("depart_user u", "u.uid=cb.createrid AND u.is_del=0")
- ->leftJoin("consult_info c", "c.infoNo=cb.infoNo")
- ->where($where)
- ->page($page, $size)
- ->order('cb.addtime', 'desc')
- ->cursor();
- $data = [];
- foreach ($list as $value) {
- $catinfo = Db::name("cat")->where(["id" => $value['cat_id']])->find();
- $value['can'] = isset($value['cat_id']) && $value['cat_id'] != 0 ? made($value['cat_id']) : [];
- $unit = Db::name("unit")->where(["id" => $value['unit_id']])->find();
- $value['unit'] = isset($unit['unit']) ? $unit['unit'] : '';
- $supplier = Db::name("supplier")->where(["code" => $value['supplierNo']])->find();
- $value['supplierName'] = isset($supplier['name']) ? $supplier['name'] : "";
- if ($value['brand_id'] != 0) {
- $brand = Db::name("brand")->where(["id" => $value['brand_id']])->find();
- $value["brand_name"] = isset($brand['brand_name']) ? $brand['brand_name'] : "";
- } else {
- $value["brand_name"] = "";
- $value["brand_id"] = "";
- }
- $bidinfo = Db::name("consult_info")->where(["infoNo" => $value["infoNo"]])->find();
- $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate'] : 0;
- $god = [
- "metal_id" => $value['metal_id'],
- "weight" => $value["good_weight"],
- "demo_fee" => $value["demo_fee"],
- "delivery_fee" => $value["delivery_fee"],
- "open_fee" => $value["open_fee"],
- "packing_fee" => $value["pakge_fee"],
- "mark_fee" => $value["mark_fee"],
- "nake_fee" => $value["nake_fee"],
- "cert_fee" => $value["cert_fee"],
- "cost_fee" => $value["sale_cost_fee"] != $value["origin_cost_fee"] ? $value["sale_cost_fee"] : $value["cost_fee"],
- "num" => $bidinfo["num"],
- ];
- if ($value['is_gold_price'] == 1) {
- $price = GoldPrice($god, $budget / 100);
- $value['sale_price'] = round($price, 2);
- }
- $value['cost_fee'] = $value['origin_cost_fee'];
- $value['specinfo'] = json_decode($value['specinfo'], true);
- $value['metal_name'] = isset($value['metal_id']) && $value['metal_id'] != 0 ? $this->noble[$value['metal_id']] : "";
- $value['bargain_status'] = $bidinfo['bargain_status'];
- //reject驳回原因,status==5表示驳回
- $value['reject'] = [];
- if ($value['status'] >= 5) {
- $value['reject'] = Db::name('bargain_order')
- ->field('id,remark,status')
- ->where(['infoNo' => $infoNo, 'bidsNo' => $value['bidNo']])
- ->whereIn('status', [3, 8, 11])->order("id desc")
- ->find();
- }
- //产地
- $place = ["provice_code" => "", "city_code" => "", "area_code" => ""];
- if ($value['delivery_place'] != "") {
- list($place['provice_code'], $place['city_code'], $place['area_code']) = explode(",", $value['delivery_place']);
- }
- $value['delivery_place_cn'] = GetAddr(json_encode($place));
- $place = ["provice_code" => "", "city_code" => "", "area_code" => ""];
- if ($value['origin_place'] != "") {
- list($place['provice_code'], $place['city_code'], $place['area_code']) = explode(",", $value['origin_place']);
- }
- $value['origin_addr'] = GetAddr(json_encode($place));
- // if($value['origin_place']!=''){
- // $code = explode(",",$value['origin_place']);
- // $temp=[];
- // $temp['provice_code']=isset($code[0])?$code[0]:"";
- // $temp['city_code']=isset($code[1])?$code[1]:"";
- // $temp['area_code']=isset($code[2])?$code[2]:"";
- // $addr= GetAddr(json_encode($temp));
- // $value['origin_addr'] = $addr;
- // }
- $value['company_name'] = implode('/', array_column(GetPart($value['itemid']), 'name'));
- $data[] = $value;
- }
- return json_show(0, "获取成功", ['count' => $count, 'list' => $data]);
- }
- //反馈商品详情
- public function feadinfo()
- {
- $this->post = $this->request->filter('trim')->post();
- $bidNo = isset($this->post['bidNo']) && $this->post['bidNo'] != "" ? trim($this->post['bidNo']) : "";
- if ($bidNo == "") {
- return json_show(1004, "参数bidNo不能为空");
- }
- $info = Db::name("consult_bids")->where(['bidNo' => $bidNo, "is_del" => 0])->find();
- if ($info == false) {
- return json_show(1004, "未找到商品数据");
- }
- $unit = Db::name("unit")->where(["id" => $info['unit_id']])->find();
- $info['unit'] = isset($unit['unit']) ? $unit['unit'] : '';
- $info['cat_info'] = made($info['cat_id'], []);
- $info['noble_weight'] = $info['good_weight'];
- $supplier = Db::name("supplier")->where(["code" => $info['supplierNo']])->find();
- $info['supplierName'] = isset($supplier['name']) ? $supplier['name'] : "";
- if ($info['brand_id'] != 0) {
- $brand = Db::name("brand")->where(["id" => $info['brand_id']])->find();
- $info["brand_name"] = isset($brand['brand_name']) ? $brand['brand_name'] : "";
- } else {
- $info["brand_name"] = "";
- $info["brand_id"] = "";
- }
- $catinfo = Db::name("cat")->where(["id" => $info['cat_id']])->find();
- $bidinfo = Db::name("consult_info")->where(["infoNo" => $info["infoNo"]])->find();
- $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate'] : 0;
- $god = [
- "metal_id" => $info['metal_id'],
- "weight" => $info["good_weight"],
- "demo_fee" => $info["demo_fee"],
- "delivery_fee" => $info["delivery_fee"],
- "open_fee" => $info["open_fee"],
- "packing_fee" => $info["pakge_fee"],
- "mark_fee" => $info["mark_fee"],
- "nake_fee" => $info["nake_fee"],
- "cert_fee" => $info["cert_fee"],
- "cost_fee" => $info["cost_fee"],
- "num" => $bidinfo["num"],
- ];
- if ($info['is_gold_price'] == 1) {
- $price = GoldPrice($god, $budget / 100);
- $info['sale_price'] = round($price, 2);
- }
- $info['specinfo'] = json_decode($info['specinfo'], true);
- $place = ["provice_code" => "", "city_code" => "", "area_code" => ""];
- if ($info['delivery_place'] != "") {
- list($place['provice_code'], $place['city_code'], $place['area_code']) = explode(",", $info['delivery_place']);
- }
- $info['delivery_place_cn'] = GetAddr(json_encode($place));
- $place = ["provice_code" => "", "city_code" => "", "area_code" => ""];
- if ($info['origin_place'] != "") {
- list($place['provice_code'], $place['city_code'], $place['area_code']) = explode(",", $info['origin_place']);
- }
- $info['origin_place_cn'] = GetAddr(json_encode($place));
- $info['metal_name'] = isset($info['metal_id']) && $info['metal_id'] != 0 ? $this->noble[$info['metal_id']] : "";
- $bargain = Db::name("bargain_order")->where(['bidsNo' => $bidNo, "is_del" => 0])->find();
- $info['bargain'] = $bargain;
- $info['good_img'] = explode(',', $info['good_img']);
- return json_show(0, "获取成功", $info);
- }
- //反馈商品添加
- public function feadback()
- {
- $this->post = $this->request->filter('trim')->post();
- $infoNo = isset($this->post['infoNo']) && $this->post['infoNo'] != "" ? trim($this->post['infoNo']) : "";
- if ($infoNo == "") {
- return json_show(1002, "参数infoNo不能为空");
- }
- $zxinfo = Db::name("consult_info")->where(["infoNo" => $infoNo, "is_del" => 0])->find();
- if ($zxinfo == false) {
- return json_show(1003, "未找到信息数据");
- }
- if ($zxinfo['status'] != 1) {
- return json_show(1004, "任务未进行");
- }
- $zx = Db::name("consult_order")->where(["zxNo" => $zxinfo['zxNo'], "is_del" => 0])->find();
- if ($zx == false) {
- return json_show(1003, "未找咨询信息数据");
- }
- $pname = isset($this->post['pname']) && $this->post['pname'] != "" ? trim($this->post['pname']) : "";
- if ($pname == "") {
- return json_show(1002, "参数pname不能为空");
- }
- $brandid = isset($this->post['brandid']) && $this->post['brandid'] != "" ? intval($this->post['brandid']) : "";
- $cat_id = isset($this->post['cat_id']) && $this->post['cat_id'] != "" ? trim($this->post['cat_id']) : "";
- if ($cat_id == "") {
- return json_show(1002, "参数cat_id不能为空");
- }
- $specin = isset($this->post['specinfo']) && !empty($this->post['specinfo']) ? $this->post['specinfo'] : "";
- if ($specin == "") {
- return json_show(1003, "参数specinfo不能为空");
- }
- $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;
- }
- $unit_id = isset($this->post['unit_id']) && $this->post['unit_id'] != "" ? intval($this->post['unit_id']) : "";
- $cost_desc = isset($this->post['cost_desc']) && $this->post['cost_desc'] != "" ? trim($this->post['cost_desc']) : "";
- $work_day = isset($this->post['work_day']) && $this->post['work_day'] != "" ? intval($this->post['work_day']) : "";
- $delivery_day = isset($this->post['delivery_day']) && $this->post['delivery_day'] != "" ? intval($this->post['delivery_day']) : "";
- $good_img = isset($this->post['good_img']) && $this->post['good_img'] != "" ? $this->post['good_img'] : [];
- $expire_day = isset($this->post['expire_day']) && $this->post['expire_day'] != "" ? intval($this->post['expire_day']) : "";
- $origin_place = isset($this->post['origin_place']) && $this->post['origin_place'] != "" ? trim($this->post['origin_place']) : "";
- $supplierNo = isset($this->post['supplierNo']) && $this->post['supplierNo'] != "" ? trim($this->post['supplierNo']) : "";
- $pay_way = isset($this->post['pay_way']) && $this->post['pay_way'] != "" ? intval($this->post['pay_way']) : "";
- $tax = isset($this->post['tax']) && $this->post['tax'] != "" ? trim($this->post['tax']) : "";
- $send_way = isset($this->post['send_way']) && $this->post['send_way'] != "" ? intval($this->post['send_way']) : "";
- $metal_id = isset($this->post['metal_id']) && $this->post['metal_id'] != "" ? intval($this->post['metal_id']) : "0";
- $is_gold_price = isset($this->post['is_gold_price']) && $this->post['is_gold_price'] != "" ? intval($this->post['is_gold_price']) : "0";
- $config = isset($this->post['config']) && $this->post['config'] != "" ? $this->post['config'] : "";
- $other_config = isset($this->post['other_config']) && $this->post['other_config'] != "" ? $this->post['other_config'] : "";
- $weight = isset($this->post['weight']) && $this->post['weight'] !== "" ? floatval($this->post['weight']) : "0";
- $good_weight = isset($this->post['noble_weight']) && $this->post['noble_weight'] !== "" ? floatval($this->post['noble_weight']) : "0";
- $demo_fee = isset($this->post['demo_fee']) && $this->post['demo_fee'] !== "" ? floatval($this->post['demo_fee']) : "0";
- $delivery_fee = isset($this->post['delivery_fee']) && $this->post['delivery_fee'] !== "" ? floatval($this->post['delivery_fee']) : "0";
- $open_fee = isset($this->post['open_fee']) && $this->post['open_fee'] !== "" ? floatval($this->post['open_fee']) : "0";
- $pakge_fee = isset($this->post['pakge_fee']) && $this->post['pakge_fee'] !== "" ? floatval($this->post['pakge_fee']) : "0";
- $nake_fee = isset($this->post['nake_fee']) && $this->post['nake_fee'] !== "" ? floatval($this->post['nake_fee']) : "0";
- $mark_fee = isset($this->post['mark_fee']) && $this->post['mark_fee'] !== "" ? floatval($this->post['mark_fee']) : "0";
- $cert_fee = isset($this->post['cert_fee']) && $this->post['cert_fee'] !== "" ? floatval($this->post['cert_fee']) : "0";
- $cost_fee = isset($this->post['cost_fee']) && $this->post['cost_fee'] !== "" ? floatval($this->post['cost_fee']) : "0";
- if ($nake_fee === "") {
- return json_show(1004, "参数nake_fee不能为空");
- }
- $is_diff = isset($this->post['is_diff']) && $this->post['is_diff'] !== "" ? intval($this->post['is_diff']) : "";
- $supply_area = isset($this->post['supply_area']) && $this->post['supply_area'] !== "" ? intval($this->post['supply_area']) : "";
- $remark = isset($this->post['remark']) && $this->post['remark'] != "" ? trim($this->post['remark']) : "";
- $delivery_place = isset($this->post['delivery_place']) && $this->post['delivery_place'] != '' ? trim($this->post['delivery_place']) : "";
- if ($delivery_place == '') {
- return json_show(1002, "参数delivery_place不能为空");
- }
- // $token = isset($this->post['token']) && $this->post['token'] != '' ? trim($this->post['token']) : "";
- // if ($token == '') {
- // return json_show(1002, "参数token不能为空");
- // }
- // $user = GetUserInfo($token);
- // if (empty($user) || $user['code'] != 0) {
- // return json_show(1005, "用户数据不存在");
- // }
- $createrid = $this->request->user['uid'];
- $creater = $this->request->user['nickname'];
- $bidNo = makeNo("BD");
- $spucode = makeNo("SKU");
- $catinfo = Db::name("cat")->where(["id" => $cat_id])->find();
- $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate'] / 100 : 0;
- //部分参数的大小校验
- $vali = Validate::rule([
- 'expire_day|有效时长' => 'require|elt:214748364',
- 'delivery_day|物流时长' => 'require|elt:214748364',
- 'work_day|生产工期' => 'require|elt:214748364',
- 'weight|总重量' => 'require|max:10',
- ]);
- $temp = [
- 'expire_day' => $expire_day,
- 'delivery_day' => $delivery_day,
- 'work_day' => $work_day,
- 'weight' => $weight,
- ];
- if (!$vali->check($temp)) return json_show(0, $vali->getError());
- $sale_cost_fee = $cost_fee;//销售工艺费默认取传值
- $cat_top_list = made($cat_id);
- $cat_top_id = isset($cat_top_list[0]['id']) ? $cat_top_list[0]['id'] : 0;
- if ($is_gold_price == 1 && $cat_top_id == 6) {
- $gold = Db::name("gold_price1")->where(["type" => $metal_id, "is_del" => 0, "status" => 1])->order("addtime desc")->find();
- //$total_fee = $open_fee/$zxinfo['num'] + $weight* $gold["price"] + $cost_fee*$weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee;
- //$total_fee(成本合计初始价格) =打样费/购买数量 + 开模费/购买数量 + 商品重量* 最新金价 + 工艺费* 商品重量+包装费+加标费+证书费+产品裸价0+运费;
- $total_fee = $demo_fee / $zxinfo['num'] + $open_fee / $zxinfo['num'] + $good_weight * $gold["price"] + $cost_fee * $good_weight + $pakge_fee + $mark_fee + $cert_fee + $nake_fee + $delivery_fee;
- // $saleprice = $open_fee/$zxinfo['num'] + $weight* $gold["price"] + $cost_fee/(1-$budget)* $weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee;
- //$saleprice(最终售价) = (开模费/购买数量 + 商品重量* 最新金价 + 工艺费* 商品重量+包装费+加标费+证书费+产品裸价)/(1-成本售价/100);
- // $saleprice = ($open_fee / $zxinfo['num'] + $weight * $gold["price"] + $cost_fee * $weight + $pakge_fee + $mark_fee + $cert_fee + $nake_fee) / (1 - $budget);
- $saleprice = $total_fee / (1 - $budget);
- //销售工艺费=((开模费/购买数量 + 商品重量* 最新金价 + 工艺费* 商品重量+包装费+加标费+证书费+产品裸价)/(1-成本售价/100)-(打样费/购买数量 + 开模费/购买数量 +包装费+加标费+证书费+产品裸价0+运费) )/商品重量-最新金价
- $sale_cost_fee = ($saleprice - ($demo_fee / $zxinfo['num'] + $open_fee / $zxinfo['num'] + $pakge_fee + $mark_fee + $cert_fee + $nake_fee + $delivery_fee)) / $good_weight - $gold["price"];
- } else {
- if ($nake_fee) {
- $saleprice = ($demo_fee / $zxinfo['num'] + $delivery_fee + $open_fee / $zxinfo['num'] + $cost_fee * $good_weight + $pakge_fee + $mark_fee + $cert_fee + $nake_fee) / (1 - $budget);
- $total_fee = $demo_fee / $zxinfo['num'] + $delivery_fee + $open_fee / $zxinfo['num'] + $cost_fee * $good_weight + $pakge_fee + $mark_fee + $cert_fee + $nake_fee;
- } else {
- $saleprice = ($demo_fee / $zxinfo['num'] + $delivery_fee + $open_fee / $zxinfo['num'] + $cost_fee * $good_weight + $pakge_fee + $mark_fee + $cert_fee) / (1 - $budget);
- $total_fee = $demo_fee / $zxinfo['num'] + $delivery_fee + $open_fee / $zxinfo['num'] + $cost_fee * $good_weight + $pakge_fee + $mark_fee + $cert_fee;
- }
- }
- $supplier = Db::name('supplier')
- ->field('id,person,personid')
- ->where('code',$supplierNo)
- ->findOrEmpty();
- $data = [
- "bidNo" => $bidNo,
- "infoNo" => $infoNo,
- "zxNo" => $zxinfo['zxNo'],
- "spuCode" => $spucode,
- "good_name" => $pname,
- "brand_id" => $brandid,
- "cat_id" => $cat_id,
- "specinfo" => json_encode($specinfo),
- "unit_id" => $unit_id,
- "cost_desc" => $cost_desc,
- "work_day" => $work_day,
- "delivery_day" => $delivery_day,
- "good_img" => is_array($good_img) ? implode(',', $good_img) : $good_img,
- "expire_day" => $expire_day,
- "origin_place" => $origin_place,
- "supplierNo" => $supplierNo,
- "pay_way" => $pay_way,
- "tax" => $tax,
- "send_way" => $send_way,
- "metal_id" => $metal_id,
- "is_gold_price" => $is_gold_price,
- "config" => $config,
- "other_config" => $other_config,
- "weight" => $weight,
- "good_weight" => $good_weight,
- "gold_price" => isset($gold["price"]) ? $gold["price"] : 0,
- "is_diff" => $is_diff,
- "demo_fee" => $demo_fee,
- "delivery_fee" => $delivery_fee,
- "open_fee" => $open_fee,
- "pakge_fee" => $pakge_fee,
- "nake_fee" => $nake_fee,
- "mark_fee" => $mark_fee,
- "cert_fee" => $cert_fee,
- "cost_fee" => $cost_fee,
- "total_fee" => $total_fee,
- "supply_area" => $supply_area,
- "remark" => $remark,
- "sale_price" => $saleprice,
- "sale_cost_fee" => $sale_cost_fee,
- "origin_cost_fee" => $sale_cost_fee,
- "origin_price" => $saleprice,
- "createrid" => $createrid,
- "creater" => $creater,
- "status" => $zxinfo['status'] == 1 ? 1 : 2,
- "is_del" => 0,
- "addtime" => date("Y-m-d H:i:s"),
- "updatetime" => date("Y-m-d H:i:s"),
- 'delivery_place' => $delivery_place,//发货地
- 'cgder' => $supplier['person'] ?? '',
- 'cgderid' => $supplier['personid'] ?? 0,
- ];
- Db::startTrans();
- try {
- $insert = Db::name("consult_bids")->insert($data);
- if ($insert) {
- if ($zx['is_project'] == 1 && $zx['projectNo'] != "" && $zxinfo['pgNo'] != "") {
- $projectinfo = Db::name("project_info")->where(["pgNo" => $zxinfo["pgNo"], "projectNo" => $zx['projectNo'], "is_del" => 0])->find();
- if ($projectinfo == false) {
- Db::rollback();
- return json_show(1006, "未找到项目信息");
- }
- $temp = [];
- $temp['spuCode'] = $spucode;
- $temp['skuCode'] = "";
- $temp['pgNo'] = $zxinfo['pgNo'];
- $temp['projectNo'] = $zx['projectNo'];
- $temp['good_name'] = $pname;
- $temp['good_type'] = $projectinfo['good_type'];
- $temp['data_source'] = 2;
- $temp['cat_id'] = $cat_id;
- $temp['budget_price'] = $projectinfo['budget_price'];
- $temp['sale_price'] = $saleprice;
- $temp['origin_price'] = $total_fee;
- $temp['num'] = $zxinfo['num'];
- $temp['status'] = 0;
- $temp['is_del'] = 0;
- $temp['creater'] = $creater;
- $temp['createrid'] = $createrid;
- $temp['addtime'] = date("Y-m-d H:i:s");
- $temp['updatetime'] = date("Y-m-d H:i:s");
- $nu = Db::name("project_feedback")->insert($temp);
- if ($nu == false) {
- Db::rollback();
- return json_show(1006, "项目反馈失败");
- } else {
- $old_projectinfo_status = $projectinfo['status'];
- $projectinfo['status'] = 2;
- $projectinfo['updatetime'] = date("Y-m-d H:i:s");
- $up = Db::name("project_info")->save($projectinfo);
- if ($up) {
- //修改状态,添加待办,只记录动作
- ActionLog::logAdd(['id' => $createrid, 'nickname' => $creater], [
- "order_code" => $projectinfo['pgNo'],//编码
- "status" => $old_projectinfo_status,//这里的status是之前的值
- "action_remark" => '',//备注
- "action_type" => "status"//新建create,编辑edit,更改状态status
- ], "PRI", 2, $projectinfo);
- $count = Db::name("project_info")->where(["projectNo" => $projectinfo['projectNo'], "status" => 1])->count();
- if ($count == 0) {
- $projetc = Db::name("project")->where(["projectNo" => $projectinfo['projectNo'], "status" => 1])->find();
- if ($projetc != false) {
- $proc = Db::name("project")->where(["projectNo" => $projectinfo['projectNo'], "status" => 1])->save
- (["status" => 2, "updatetime" => date("Y-m-d H:i:s")]);
- if ($proc == false) {
- Db::rollback();
- return json_show(1006, "项目反馈失败");
- } else {
- //修改状态,添加待办
- ActionLog::logAdd(['id' => $createrid, 'nickname' => $creater], [
- "order_code" => $projetc['projectNo'],//项目编码
- "status" => 1,//这里的status是之前的值
- "action_remark" => '',//备注
- "action_type" => "status"//新建create,编辑edit,更改状态status
- ], "PRO", 2, $projetc);
- ProcessOrder::AddProcess(['id' => $createrid, 'nickname' => $creater], [
- "order_type" => 'PRO',
- "order_code" => $projetc['projectNo'],
- "order_id" => $projetc['id'],
- "order_status" => 2,
- "before_status" => 1,
- 'holder_id'=>$projetc['createrid']
- ]);
- }
- }
- }
- }
- }
- }
- Db::commit();
- return json_show(0, "反馈成功", ["bidNo" => $bidNo]);
- } else {
- Db::rollback();
- return json_show(1006, "反馈失败");
- }
- } catch (\Exception $e) {
- Db::rollback();
- return json_show(1006, $e->getMessage());
- }
- }
- //反馈商品编辑
- public function feededit()
- {
- $this->post = $this->request->filter('trim')->post();
- $bidNo = isset($this->post['bidNo']) && $this->post['bidNo'] != "" ? trim($this->post['bidNo']) : "";
- if ($bidNo == "") {
- return json_show(1002, "参数bidNo不能为空");
- }
- $bidinfo = Db::name("consult_bids")->where(["bidNo" => $bidNo, "is_del" => 0])->find();
- if ($bidinfo == false) {
- return json_show(1003, "未找到信息数据");
- }
- if ($bidinfo['status'] >= 5) {
- return json_show(1004, "咨询单已确认无法修改");
- }
- $zxinfo = Db::name("consult_info")->where(["infoNo" => $bidinfo['infoNo'], "is_del" => 0])->find();
- if ($zxinfo == false) {
- return json_show(1003, "未找到信息数据");
- }
- $zx = Db::name("consult_order")->where(["zxNo" => $zxinfo['zxNo'], "is_del" => 0])->find();
- if ($zx == false) {
- return json_show(1003, "未找咨询信息数据");
- }
- $pname = isset($this->post['pname']) && $this->post['pname'] != "" ? trim($this->post['pname']) : "";
- if ($pname == "") {
- return json_show(1002, "参数pname不能为空");
- }
- $brandid = isset($this->post['brandid']) && $this->post['brandid'] != "" ? intval($this->post['brandid']) : "";
- // if($brandid==""){
- // return json_show(1002,"参数brandid不能为空");
- // }
- $cat_id = isset($this->post['cat_id']) && $this->post['cat_id'] != "" ? trim($this->post['cat_id']) : "";
- if ($cat_id == "") {
- return json_show(1002, "参数cat_id不能为空");
- }
- $specin = isset($this->post['specinfo']) && !empty($this->post['specinfo']) ? $this->post['specinfo'] : "";
- if ($specin == "") {
- return json_show(1003, "参数specinfo不能为空");
- }
- $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;
- }
- $unit_id = isset($this->post['unit_id']) && $this->post['unit_id'] != "" ? intval($this->post['unit_id']) : "";
- $cost_desc = isset($this->post['cost_desc']) && $this->post['cost_desc'] != "" ? trim($this->post['cost_desc']) : "";
- $work_day = isset($this->post['work_day']) && $this->post['work_day'] != "" ? intval($this->post['work_day']) : "";
- $delivery_day = isset($this->post['delivery_day']) && $this->post['delivery_day'] != "" ? intval($this->post['delivery_day']) : "";
- $good_img = isset($this->post['good_img']) && $this->post['good_img'] != "" ? $this->post['good_img'] : [];
- $expire_day = isset($this->post['expire_day']) && $this->post['expire_day'] != "" ? intval($this->post['expire_day']) : "";
- $origin_place = isset($this->post['origin_place']) && $this->post['origin_place'] != "" ? trim($this->post['origin_place']) : "";
- $supplierNo = isset($this->post['supplierNo']) && $this->post['supplierNo'] != "" ? trim($this->post['supplierNo']) : "";
- $pay_way = isset($this->post['pay_way']) && $this->post['pay_way'] != "" ? intval($this->post['pay_way']) : "";
- $tax = isset($this->post['tax']) && $this->post['tax'] != "" ? trim($this->post['tax']) : "";
- $send_way = isset($this->post['send_way']) && $this->post['send_way'] != "" ? intval($this->post['send_way']) : "0";
- $metal_id = isset($this->post['metal_id']) && $this->post['metal_id'] != "" ? intval($this->post['metal_id']) : "0";
- $is_gold_price = isset($this->post['is_gold_price']) && $this->post['is_gold_price'] != "" ? intval($this->post['is_gold_price']) : "0";
- $config = isset($this->post['config']) && $this->post['config'] != "" ? $this->post['config'] : "";
- $other_config = isset($this->post['other_config']) && $this->post['other_config'] != "" ? $this->post['other_config'] : "";
- $weight = isset($this->post['weight']) && $this->post['weight'] != "" ? floatval($this->post['weight']) : "0";
- $noble_weight = isset($this->post['noble_weight']) && $this->post['noble_weight'] != "" ? floatval($this->post['noble_weight']) : "0";
- $demo_fee = isset($this->post['demo_fee']) && $this->post['demo_fee'] != "" ? floatval($this->post['demo_fee']) : "0";
- $delivery_fee = isset($this->post['delivery_fee']) && $this->post['delivery_fee'] != "" ? floatval($this->post['delivery_fee']) : "0";
- $open_fee = isset($this->post['open_fee']) && $this->post['open_fee'] != "" ? floatval($this->post['open_fee']) : "0";
- $pakge_fee = isset($this->post['pakge_fee']) && $this->post['pakge_fee'] != "" ? floatval($this->post['pakge_fee']) : "0";
- $nake_fee = isset($this->post['nake_fee']) && $this->post['nake_fee'] !== "" ? floatval($this->post['nake_fee']) : 0;
- $mark_fee = isset($this->post['mark_fee']) && $this->post['mark_fee'] != "" ? floatval($this->post['mark_fee']) : "0";
- $cert_fee = isset($this->post['cert_fee']) && $this->post['cert_fee'] != "" ? floatval($this->post['cert_fee']) : "0";
- $cost_fee = isset($this->post['cost_fee']) && $this->post['cost_fee'] != "" ? floatval($this->post['cost_fee']) : "0";
- $is_diff = isset($this->post['is_diff']) && $this->post['is_diff'] !== "" ? intval($this->post['is_diff']) : "";
- $supply_area = isset($this->post['supply_area']) && $this->post['supply_area'] !== "" ? intval($this->post['supply_area']) : "";
- $remark = isset($this->post['remark']) && $this->post['remark'] != "" ? trim($this->post['remark']) : "";
- $delivery_place = isset($this->post['delivery_place']) && $this->post['delivery_place'] != '' ? trim($this->post['delivery_place']) : "";
- if ($delivery_place == '') {
- return json_show(1002, "参数delivery_place不能为空");
- }
- $catinfo = Db::name("cat")->where(["id" => $cat_id])->find();
- $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate'] / 100 : 0;
- $sale_cost_fee = $bidinfo['sale_cost_fee'];
- $cat_top_list = made($cat_id);
- $cat_top_id = isset($cat_top_list[0]['id']) ? $cat_top_list[0]['id'] : 0;
- if ($is_gold_price == 1 && $cat_top_id == 6) {
- $gold = Db::name("gold_price1")->where(["type" => $metal_id, "is_del" => 0, "status" => 1])->order("addtime desc")->find();
- //$total_fee(成本合计初始价格) =打样费/购买数量 + 开模费/购买数量 + 商品重量* 最新金价 + 工艺费* 商品重量+包装费+加标费+证书费+产品裸价0+运费;
- $total_fee = $demo_fee / $zxinfo['num'] + $open_fee / $zxinfo['num'] + $noble_weight * $gold["price"] + $cost_fee * $noble_weight + $pakge_fee + $mark_fee + $cert_fee + $nake_fee + $delivery_fee;
- // $saleprice = $open_fee/$zxinfo['num'] + $weight* $gold["price"] + $cost_fee/(1-$budget)* $weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee;
- //$saleprice(最终售价) = (开模费/购买数量 + 商品重量* 最新金价 + 工艺费* 商品重量+包装费+加标费+证书费+产品裸价)/(1-成本售价/100);
- $saleprice = $total_fee / (1 - $budget);
- //销售工艺费=((开模费/购买数量 + 商品重量* 最新金价 + 工艺费* 商品重量+包装费+加标费+证书费+产品裸价)/(1-成本售价/100)-(打样费/购买数量 + 开模费/购买数量 +包装费+加标费+证书费+产品裸价0+运费) )/商品重量-最新金价
- $sale_cost_fee = ($saleprice - ($demo_fee / $zxinfo['num'] + $open_fee / $zxinfo['num'] + $pakge_fee + $mark_fee + $cert_fee + $nake_fee + $delivery_fee)) / $noble_weight - $gold["price"];
- } else {
- $saleprice = ($demo_fee / $zxinfo['num'] + $delivery_fee + $open_fee / $zxinfo['num'] + $cost_fee * $noble_weight + $pakge_fee + $mark_fee + $cert_fee + $nake_fee) / (1 - $budget);
- $total_fee = $demo_fee / $zxinfo['num'] + $delivery_fee + $open_fee / $zxinfo['num'] + $cost_fee * $noble_weight + $pakge_fee + $mark_fee + $cert_fee + $nake_fee;
- }
- Db::startTrans();
- try {
- $createrid = $this->request->user['uid'];
- $creater = $this->request->user['nickname'];
- $data = [
- "good_name" => $pname,
- "brand_id" => $brandid,
- "cat_id" => $cat_id,
- "specinfo" => json_encode($specinfo),
- // "material"=>$material,
- "unit_id" => $unit_id,
- "cost_desc" => $cost_desc,
- "work_day" => $work_day,
- "delivery_day" => $delivery_day,
- "good_img" => is_array($good_img) ? implode(',', $good_img) : $good_img,
- "expire_day" => $expire_day,
- "origin_place" => $origin_place,
- "supplierNo" => $supplierNo,
- "pay_way" => $pay_way,
- "tax" => $tax,
- "send_way" => $send_way,
- "metal_id" => $metal_id,
- "is_gold_price" => $is_gold_price,
- "config" => $config,
- "other_config" => $other_config,
- "weight" => $weight,
- "good_weight" => $noble_weight,
- "is_diff" => $is_diff,
- "demo_fee" => $demo_fee,
- "gold_price" => isset($gold["price"]) ? $gold["price"] : 0,
- "delivery_fee" => $delivery_fee,
- "open_fee" => $open_fee,
- "pakge_fee" => $pakge_fee,
- "nake_fee" => $nake_fee,
- "mark_fee" => $mark_fee,
- "cert_fee" => $cert_fee,
- "cost_fee" => $cost_fee,
- "sale_cost_fee" => $sale_cost_fee,
- "origin_cost_fee" => $sale_cost_fee,
- "total_fee" => $total_fee,
- "sale_price" => $saleprice,
- "origin_price" => $saleprice,
- "supply_area" => $supply_area,
- "remark" => $remark,
- "status" => 0,
- "updatetime" => date("Y-m-d H:i:s"),
- 'delivery_place' => $delivery_place
- ];
- $insert = Db::name("consult_bids")->where($bidinfo)->save($data);
- if ($insert) {
- if ($zxinfo['bargain_status'] == 1) {
- $zxinfo['bargain_status'] = 0;
- $infoip = Db::name("consult_info")->save($zxinfo);
- if ($infoip == false) {
- Db::rollback();
- return json_show(1006, "咨询信息状态更新失败");
- }
- }
- if ($zx['is_project'] == 1 && $zx['projectNo'] != "" && $zxinfo['pgNo'] != "") {
- $projectinfo = Db::name("project_info")->where(["pgNo" => $zxinfo["pgNo"], "projectNo" => $zx['projectNo'], "is_del" => 0])->find();
- if ($projectinfo == false) {
- Db::rollback();
- return json_show(1006, "未找到项目信息");
- }
- $feed = Db::name("project_feedback")->where(["pgNo" => $zxinfo["pgNo"], "projectNo" => $zx['projectNo'], "spuCode" => $bidinfo['spuCode'], "is_del" => 0])->find();
- if ($feed != false) {
- $feed['good_name'] = $pname;
- $feed['good_type'] = $projectinfo['good_type'];
- $feed['cat_id'] = $cat_id;
- $feed['sale_price'] = $saleprice;
- $feed['origin_price'] = $total_fee;
- $feed['updatetime'] = date("Y-m-d H:i:s");
- $temp['updatetime'] = date("Y-m-d H:i:s");
- $nu = Db::name("project_feedback")->save($feed);
- if ($nu == false) {
- Db::rollback();
- return json_show(1006, "项目反馈失败");
- } else {
- $old_projectinfo_status = $projectinfo['status'];
- $projectinfo['status'] = 2;
- $projectinfo['updatetime'] = date("Y-m-d H:i:s");
- $up = Db::name("project_info")->save($projectinfo);
- if ($up) {
- //修改状态,添加待办,只记录动作
- ActionLog::logAdd(['id' => $createrid, 'nickname' => $creater], [
- "order_code" => $projectinfo['pgNo'],//编码
- "status" => $old_projectinfo_status,//这里的status是之前的值
- "action_remark" => '',//备注
- "action_type" => "status"//新建create,编辑edit,更改状态status
- ], "PRI", 2, $projectinfo
- );
- $count = Db::name("project_info")->where(["projectNo" => $projectinfo['projectNo'], "status" => 1])->count();
- if ($count == 0) {
- //先查询是否存在status==1的项目,有的话再更新,否则跳过
- $project_id = Db::name("project")->where(["projectNo" => $projectinfo['projectNo'], "status" => 1])->field('id,createrid')->findOrEmpty();
- if ($project_id) {
- $proc = Db::name("project")->where(["id" => $project_id['id']])->update(["status" => 2, "updatetime" => date("Y-m-d H:i:s")]);
- if ($proc == false) {
- Db::rollback();
- return json_show(1006, "项目反馈失败");
- } else {
- //修改状态,添加待办
- ActionLog::logAdd(['id' => $createrid, 'nickname' => $creater], [
- "order_code" => $projectinfo['projectNo'],//项目编码
- "status" => 1,//这里的status是之前的值
- "action_remark" => '',//备注
- "action_type" => "status"//新建create,编辑edit,更改状态status
- ], "PRO", 2, $this->post);
- ProcessOrder::AddProcess(['id' => $createrid, 'nickname' => $creater], [
- "order_type" => 'PRO',
- "order_code" => $projectinfo['projectNo'],
- "order_id" => $project_id['id'],
- "order_status" => 2,
- "before_status" => 1,
- 'holder_id'=>$project_id['createrid']
- ]
- );
- }
- }
- }
- }
- }
- }
- }
- Db::commit();
- return json_show(0, "编辑成功");
- } else {
- Db::rollback();
- return json_show(1004, "编辑失败");
- }
- } catch (\Exception $e) {
- Db::rollback();
- return json_show(1004, $e->getMessage());
- }
- }
- }
|