|
@@ -5,8 +5,10 @@ namespace app\abutment\controller;
|
|
|
|
|
|
|
|
|
use app\admin\model\ActionLog;
|
|
|
+use app\admin\model\ProcessOrder;
|
|
|
use app\BaseController;
|
|
|
use think\facade\Db;
|
|
|
+use think\facade\Validate;
|
|
|
|
|
|
class Consult extends BaseController
|
|
|
{
|
|
@@ -485,7 +487,6 @@ class Consult extends BaseController
|
|
|
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]];
|
|
@@ -619,4 +620,600 @@ class Consult extends BaseController
|
|
|
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;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $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//发货地
|
|
|
+ ];
|
|
|
+ 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
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ 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])->value('id', 0);
|
|
|
+ if ($project_id) {
|
|
|
+ $proc = Db::name("project")->where(["id" => $project_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,
|
|
|
+ "order_status" => 2,
|
|
|
+ "before_status" => 1
|
|
|
+ ]
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Db::commit();
|
|
|
+ return json_show(0, "编辑成功");
|
|
|
+ } else {
|
|
|
+ Db::rollback();
|
|
|
+ return json_show(1004, "编辑失败");
|
|
|
+ }
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ Db::rollback();
|
|
|
+ return json_show(1004, $e->getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|