123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875 |
- <?php
- namespace app\abutment\controller;
- use app\admin\model\ActionLog;
- use app\admin\model\ChangeLog;
- use app\admin\model\ProcessOrder;
- use app\youzan\model\PlatformYouzan;
- use think\facade\Db;
- //商品模块
- class Good extends HomeBaseController
- {
- private $gold = [1 => '18K', 2 => '24K', 3 => '白银'];
- //获取商品列表
- public function list()
- {
- $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 = [["gb.is_del", "=", 0], ['gb.is_stock', '=', 0]];
- $condit = [["a.is_del", "=", 0]];
- $cat_id = isset($this->post['cat_id']) && $this->post['cat_id'] !== "" ? intval($this->post['cat_id']) : "";
- if ($cat_id !== "") {
- $cat_ids = catChild($cat_id);
- $where[] = ['gb.cat_id', "in", $cat_ids];
- $condit[] = ['a.cat_id', "in", $cat_ids];
- }
- $good_name = isset($this->post['good_name']) && $this->post['good_name'] !== "" ? trim($this->post['good_name']) : "";
- if ($good_name !== "") {
- $where[] = ['gb.good_name', "like", "%$good_name%"];
- $condit[] = ['a.good_name', "like", "%$good_name%"];
- }
- $spucode = isset($this->post['spucode']) && $this->post['spucode'] !== "" ? trim($this->post['spucode']) : "";
- if ($spucode !== "") {
- $where[] = ['gb.spuCode', "like", "%$spucode%"];
- $condit[] = ['a.spuCode', "like", "%$spucode%"];
- }
- $good_type = isset($this->post['good_type']) && $this->post['good_type'] !== "" ? trim($this->post['good_type']) : "";
- if ($good_type !== "") {
- $where[] = ['gb.good_type', "=", $good_type];
- $condit[] = ['a.good_type', "=", $good_type];
- }
- $companyNo = isset($this->post['companyNo']) && $this->post['companyNo'] !== "" ? trim($this->post['companyNo']) : "";
- if ($companyNo !== "") {
- $where[] = ['gb.companyNo', "like", "%$companyNo%"];
- $condit[] = ['a.companyNo', "like", "%$companyNo%"];
- }
- $supplierNo = isset($this->post['supplierNo']) && $this->post['supplierNo'] !== "" ? trim($this->post['supplierNo']) : "";
- if ($supplierNo !== "") {
- $where[] = ['gb.supplierNo', "like", "%$supplierNo%"];
- $condit[] = ['a.supplierNo', "like", "%$supplierNo%"];
- }
- $supplier = isset($this->post['supplier']) && $this->post['supplier'] !== "" ? trim($this->post['supplier']) : "";
- if ($supplier !== "") {
- $suppliernos = Db::name("supplier")->where([["name", "like", "%$supplier%"]])->column("code");
- $where[] = ['gb.supplierNo', "in", $suppliernos];
- $condit[] = ['a.supplierNo', "in", $suppliernos];
- }
- $company = isset($this->post['company']) && $this->post['company'] !== "" ? trim($this->post['company']) : "";
- if ($company !== "") {
- $companyNos = Db::name("business")->where([["company", "like", "%$company%"]])->column("companyNo");
- $where[] = ['gb.companyNo', "in", $companyNos];
- $condit[] = ['a.companyNo', "in", $companyNos];
- }
- $brandid = isset($this->post['brandid']) && $this->post['brandid'] !== "" ? intval($this->post['brandid']) : "";
- if ($brandid !== "") {
- $where[] = ['gb.brand_id', "=", $brandid];
- $condit[] = ['a.brand_id', "=", $brandid];
- }
- $status = isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) : "";
- if ($status !== "") {
- $where[] = ['gb.status', "=", $status];
- $condit[] = ['a.status', "=", $status];
- }
- // $is_stock = isset($this->post['is_stock']) && $this->post['is_stock'] !== "" ? intval($this->post['is_stock']) : '';
- // if ($is_stock !== '') {
- // $where[] = ['gb.is_stock', "=", $is_stock];
- // }
- $start = isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start'] : "";
- if ($start !== "") {
- $where[] = ['gb.addtime', ">=", date('Y-m-d H:i:s', strtotime($start))];
- $condit[] = ['a.addtime', ">=", date('Y-m-d H:i:s', strtotime($start))];
- }
- $end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] : "";
- if ($end !== "") {
- $where[] = ['gb.addtime', "<", date('Y-m-d H:i:s', strtotime($end) + 24 * 3600)];
- $condit[] = ['a.addtime', "<", date('Y-m-d H:i:s', strtotime($end) + 24 * 3600)];
- }
- $isonline = isset($this->post['isonline']) && $this->post['isonline'] !== "" ? $this->post['isonline'] : "";
- if ($isonline !== "") {
- $condit[] = ['b.exam_status', "=", 6];
- // if($isonline==1){
- // $condit[] =['b.exam_status',"=",6];
- // }else{
- // $condit[] =['b.exam_status',"<>",6];
- // }
- $sta = Db::name("good_basic")
- ->alias("a")
- ->leftJoin("good_platform b", "a.spuCode=b.spuCode")
- ->where($condit)
- ->group("a.spuCode")
- ->column('a.spuCode');
- if ($isonline == 1) $where[] = ["gb.spuCode", "in", $sta];
- else $where[] = ["gb.spuCode", "not in", $sta];
- }
- // $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(102,"申请人数据不存在");
- // }
- // $rm = $this->request->user['uid'];//isset($apply_id["data"]['id']) ? $apply_id["data"]['id'] : "";
- // $where[] = ['gb.createrid', "=", $rm];
- $where[] = ['gb.supplierNo', "=", $this->request->user['supplierNo']];
- // if($rm!=''){
- // $useinfo = Db::name("user_role")->where(['uid'=>$rm,"status"=>1,"is_del"=>0])->find();
- // if($useinfo==false){
- // return json_show(1002,"未找到用户角色权限");
- // }
- // $check = checkRole($useinfo['roleid'],115);
- // if($check){
- // $where[]=['gb.createrid', "=" ,$rm];
- // }
- // }
- // $role=$this->checkRole();
- // if(!empty($role['write'])){
- // $where[]=["gb.createrid","in",$role['write']];
- // }
- $company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
- if ($company_name !== "") $where[] = ["gb.createrid", 'in', get_company_item_user_by_name($company_name)];
- $count = Db::name('good_basic')->alias('gb')->where($where)->count();
- $total = ceil($count / $size);
- $page = $page >= $total ? $total : $page;
- $list = Db::name('good_basic')
- ->alias('gb')
- ->where($where)
- ->page($page, $size)
- ->order("addtime desc")
- ->select()
- ->toArray();
- $all_createrid = array_column($list,'chargerid');
- $item = get_company_name_by_uid($all_createrid);
- $data = [];
- //查询一下这些spucode是否在平台上成功上线
- $exam_statuss = Db::name('good_platform')
- ->whereIn('spuCode', array_column($list, 'spuCode'))
- ->where(['is_del' => 0, 'exam_status' => 3])//exam_status==3表示上线审核成功
- ->column('id', 'spuCode');
- $exam_status_yz = Db::name('platform_youzan')
- ->whereIn('spuCode', array_column($list, 'spuCode'))
- ->where(['is_del' => 0, 'exam_status' =>6])//exam_status==6表示上线审核成功
- ->column('id', 'spuCode');
- foreach ($list as $value) {
- $value["cat_info"] = made($value['cat_id'], []);
- $brand = Db::name("brand")->where(["id" => $value['brand_id']])->find();
- $value["brand_name"] = isset($brand['brand_name']) ? $brand['brand_name'] : "";
- $unit = Db::name("unit")->where(["id" => $value['good_unit']])->find();
- $value['unit'] = isset($unit['unit']) ? $unit['unit'] : "";
- $company = Db::name("business")->where(["companyNo" => $value['companyNo']])->find();
- $value['company'] = isset($company['company']) ? $company['company'] : "";
- $supplier = Db::name("supplier")->where(['code' => $value['supplierNo']])->find();
- $value['supplier_name'] = isset($supplier['name']) ? $supplier['name'] : "";
- $value['exclusive'] = makeExcluse($value['is_exclusive']);
- $value['noble_name'] = isset($value['noble_metal']) && $value['noble_metal'] != 0 ? $this->noble[$value['noble_metal']] : "";
- //如果一个spucode在任意平台上线,那么就视为它上线,即手动把它的is_online值改为1
- if (isset($exam_statuss[$value['spuCode']]) || isset($exam_status_yz[$value['spuCode']])) $value['is_online'] = 1;
- $value['charger_company_name'] = $item[$value['chargerid']]??'';
- $data[] = $value;
- }
- return json_show(0, "获取成功", ['list' => $data, 'count' => $count]);
- }
- //创建商品
- public function createGood()
- {
- $this->post = $this->request->filter('trim')->post();
- $good_name = isset($this->post['good_name']) && $this->post['good_name'] != "" ? trim($this->post['good_name']) : "";
- if ($good_name == "") {
- return json_show(1004, "商品名称不能为空");
- }
- $cat_id = isset($this->post['cat_id']) && $this->post['cat_id'] != "" ? intval($this->post['cat_id']) : "";
- if ($cat_id == '') {
- return json_show(1004, "商品分类不能为空");
- }
- //不允许创建贵金属商品
- $top_cat_id = made($cat_id);//获取所有分类
- $top_cat_id = isset($top_cat_id[0]['id']) ? $top_cat_id[0]['id'] : 0;//获取顶级分类id
- if($top_cat_id && $top_cat_id==6) return json_show(1004,'不允许创建贵金属商品');
- $brandid = isset($this->post['brandid']) && $this->post['brandid'] != "" ? intval($this->post['brandid']) : "";
- if ($brandid == '') {
- return json_show(1004, "商品品牌不能为空");
- }
- $unit = isset($this->post['unit']) && $this->post['unit'] != "" ? trim($this->post['unit']) : "";
- if ($unit == '') {
- return json_show(1004, "商品单位不能为空");
- }
- $good_type = isset($this->post['good_type']) && $this->post['good_type'] !== "" ? intval($this->post['good_type']) : "";
- if ($good_type === '') {
- return json_show(1004, "参数good_type不能为空");
- }
- $moq = 0;
- $customized = 0;
- if ($good_type == 1) {
- $moq = isset($this->post['moq']) && $this->post['moq'] !== "" ? intval($this->post['moq']) : "";
- if ($moq === '') {
- return json_show(1004, "定制商品起订量不能为空");
- }
- $customized = isset($this->post['customized']) && $this->post['customized'] !== "" ? intval($this->post['customized']) : "";
- if ($customized === '') {
- return json_show(1004, "参数customized不能为空");
- }
- }
- $is_exclusive = isset($this->post['is_exclusive']) && $this->post['is_exclusive'] !== "" ? intval($this->post['is_exclusive']) : "";
- if ($is_exclusive === '') {
- return json_show(1004, "参数is_exclusive不能为空");
- }
- $tax = isset($this->post['tax']) && $this->post['tax'] !== "" ? intval($this->post['tax']) : "";
- if ($tax === '') {
- return json_show(1004, "参数tax不能为空");
- }
- $supplierNo = isset($this->post['supplierNo']) && $this->post['supplierNo'] != "" ? trim($this->post['supplierNo']) : "";
- if ($supplierNo == '') {
- return json_show(1004, "参数supplierNo不能为空");
- }
- $good_size = isset($this->post['good_size']) && $this->post['good_size'] != "" ? trim($this->post['good_size']) : "";
- if ($good_size == '') {
- return json_show(1004, "参数good_size不能为空");
- }
- $company_id = isset($this->post['company_id']) && $this->post['company_id'] != "" ? trim($this->post['company_id']) : "";
- if ($company_id == '') {
- return json_show(1004, "参数company_id不能为空");
- }
- $is_auth = isset($this->post['is_auth']) && $this->post['is_auth'] !== "" ? intval($this->post['is_auth']) : "";
- if ($is_auth === '') {
- return json_show(1004, "参数is_auth不能为空");
- }
- $auth_img = isset($this->post['auth_img']) && $this->post['auth_img'] != "" ? trim($this->post['auth_img']) : "";
- // if($auth_img==''){
- // return json_show(1004,"商品不能为空");
- // }
- $after_sales = isset($this->post['after_sales']) && $this->post['after_sales'] != "" ? trim($this->post['after_sales']) : "";
- if ($after_sales == "") {
- return json_show(1004, "参数after_sales不能为空");
- }
- $craft_desc = isset($this->post['craft_desc']) && $this->post['craft_desc'] != "" ? trim($this->post['craft_desc']) : "";
- $good_remark = isset($this->post['good_remark']) && $this->post['good_remark'] != "" ? trim($this->post['good_remark']) : "";
- if ($good_remark === "") {
- return json_show(1004, "参数good_remark不能为空");
- }
- $weight = isset($this->post['weight']) && $this->post['weight'] !== "" ? floatval($this->post['weight']) : "";
- if ($weight === "") {
- return json_show(1004, "参数weight不能为空");
- }
- $packing_way = isset($this->post['packing_way']) && $this->post['packing_way'] !== "" ? trim($this->post['packing_way']) : "";
- if ($packing_way === "") {
- return json_show(1004, "参数packing_way不能为空");
- }
- $packing_size = isset($this->post['packing_size']) && $this->post['packing_size'] !== "" ? trim($this->post['packing_size']) : "";
- if ($packing_size === "") {
- return json_show(1004, "参数packing_size不能为空");
- }
- $packing_spec = isset($this->post['packing_spec']) && $this->post['packing_spec'] !== "" ? trim($this->post['packing_spec']) : "";
- if ($packing_spec === "") {
- return json_show(1004, "参数packing_spec不能为空");
- }
- $packing_weight = isset($this->post['packing_weight']) && $this->post['packing_weight'] !== "" ? floatval($this->post['packing_weight']) : "";
- if ($packing_weight === "") {
- return json_show(1004, "参数packing_weight不能为空");
- }
- $packing_list = isset($this->post['packing_list']) && $this->post['packing_list'] !== "" ? trim($this->post['packing_list']) : "";
- if ($packing_list === "") {
- return json_show(1004, "参数packing_list不能为空");
- }
- $good_bar = isset($this->post['good_bar']) && $this->post['good_bar'] !== "" ? trim($this->post['good_bar']) : "";
- $supply_area = isset($this->post['supply_area']) && $this->post['supply_area'] !== "" ? intval($this->post['supply_area']) : "";
- if ($supply_area === "") {
- return json_show(1004, "参数supply_area不能为空");
- }
- $delivery_place = isset($this->post['delivery_place']) && $this->post['delivery_place'] !== "" ? trim($this->post['delivery_place']) : "";
- if ($delivery_place === "") {
- return json_show(1004, "参数delivery_place不能为空");
- }
- $origin_place = isset($this->post['origin_place']) && $this->post['origin_place'] !== "" ? trim($this->post['origin_place']) : "";
- if ($origin_place === "") {
- return json_show(1004, "参数origin_place不能为空");
- }
- $delivery_day = isset($this->post['delivery_day']) && $this->post['delivery_day'] !== "" ? intval($this->post['delivery_day']) : "";
- if ($delivery_day === "") {
- return json_show(1004, "参数delivery_day不能为空");
- }
- $lead_time = isset($this->post['lead_time']) && $this->post['lead_time'] !== "" ? intval($this->post['lead_time']) : "0";
- $cgd_gold_price = isset($this->post['cgd_gold_price']) && $this->post['cgd_gold_price'] !== "" ? floatval($this->post['cgd_gold_price']) : "0";
- // if($lead_time===""){
- // return json_show(1004,"参数lead_time不能为空");
- // }
- $sample_day = isset($this->post['sample_day']) && $this->post['sample_day'] !== "" ? intval($this->post['sample_day']) : "0";
- // if($sample_day===""){
- // return json_show(1004,"参数sample_day不能为空");
- // }
- $sample_fee = isset($this->post['sample_fee']) && $this->post['sample_fee'] !== "" ? floatval($this->post['sample_fee']) : "0";
- $is_stock = isset($this->post['is_stock']) && $this->post['is_stock'] !== "" ? intval($this->post['is_stock']) : "";
- if ($is_stock === "") {
- return json_show(1004, "参数is_stock不能为空");
- }
- // $stock_moq=0 ;//库存品备库起订量; 如果是0 表示无限制;
- $stock_moq = isset($this->post['stock_moq']) && $this->post['stock_moq'] !== "" ? intval($this->post['stock_moq']) : "0";
- if ($is_stock == 1 && $stock_moq == 0) {
- return json_show(1004, "库存品备库起订量不能为零");
- }
- $is_diff = isset($this->post['is_diff']) && $this->post['is_diff'] !== "" ? intval($this->post['is_diff']) : "0";
- $good_img = isset($this->post['good_img']) && $this->post['good_img'] != "" ? trim($this->post['good_img']) : "";
- $config = isset($this->post['config']) && $this->post['config'] !== "" ? trim($this->post['config']) : "";
- $other_config = isset($this->post['other_config']) && $this->post['other_config'] !== "" ? trim($this->post['other_config']) : "";
- if ($good_img === "") {
- return json_show(1004, "参数good_img不能为空");
- }
- $good_thumb_img = isset($this->post['good_thumb_img']) && $this->post['good_thumb_img'] !== "" ? trim($this->post['good_thumb_img']) : "";
- if ($good_thumb_img === "") {
- return json_show(1004, "参数good_thumb_img不能为空");
- }
- $good_info_img = isset($this->post['good_info_img']) && $this->post['good_info_img'] != "" ? trim($this->post['good_info_img']) : "";
- if ($good_info_img === "") {
- return json_show(1004, "参数good_info_img不能为空");
- }
- $cert_fee = isset($this->post['cert_fee']) && $this->post['cert_fee'] !== "" ? floatval($this->post['cert_fee']) : "0";
- $packing_fee = isset($this->post['packing_fee']) && $this->post['packing_fee'] !== "" ? floatval($this->post['packing_fee']) : "0";
- $cost_fee = isset($this->post['cost_fee']) && $this->post['cost_fee'] !== "" ? floatval($this->post['cost_fee']) : "0";
- $mark_fee = isset($this->post['mark_fee']) && $this->post['mark_fee'] !== "" ? floatval($this->post['mark_fee']) : "0";
- $demo_fee = isset($this->post['demo_fee']) && $this->post['demo_fee'] !== "" ? floatval($this->post['demo_fee']) : "0";
- $open_fee = isset($this->post['open_fee']) && $this->post['open_fee'] !== "" ? floatval($this->post['open_fee']) : "0";
- $noble_metal = isset($this->post['noble_metal']) && $this->post['noble_metal'] !== "" ? intval($this->post['noble_metal']) : "0";
- $noble_weight = isset($this->post['noble_weight']) && $this->post['noble_weight'] !== "" ? floatval($this->post['noble_weight']) : "0";
- $is_gold_price = isset($this->post['is_gold_price']) && $this->post['is_gold_price'] !== "" ? intval($this->post['is_gold_price']) : "0";
- $market_price = isset($this->post['market_price']) && $this->post['market_price'] !== "" ? floatval($this->post['market_price']) : "";
- if ($market_price === "") {
- return json_show(1004, "参数market_price不能为空");
- }
- $nake_price = isset($this->post['nake_price']) && $this->post['nake_price'] !== "" ? floatval($this->post['nake_price']) : "0";
- // $is_step = isset($this->post['is_step'])&&$this->post['is_step']!==""? intval($this->post['is_step']):"";
- // if($is_step===""){
- // return json_show(1004,"参数is_step不能为空");
- // }
- $speclist = isset($this->post['speclist']) && !empty($this->post['speclist']) ? $this->post['speclist'] : "";
- $good_ladder = isset($this->post['good_ladder']) && !empty($this->post['good_ladder']) ? $this->post['good_ladder'] : "";
- // if($is_step==1 && $good_ladder==""){
- // return json_show(1004,"启用阶梯,阶梯价不能为空");
- // }
- $is_support_barter = isset($this->post['is_support_barter']) && $this->post['is_support_barter'] !== "" ? intval($this->post['is_support_barter']) : 1;
- // $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(1002,"创建人数据不存在");
- // }
- $createrid = $this->request->user['uid']; //isset($user["data"]['id']) ? $user["data"]['id'] : "";
- $creater = $this->request->user['nickname'];//isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
- $spucode = makeNo("SKU");
- Db::startTrans();
- try {
- $charger = Db::name('supplier')
- ->where(['code' => $this->request->user['supplierNo'], 'is_del' => 0])
- ->field('id,person,personid')
- ->findOrEmpty();
- $data = [
- "spuCode" => $spucode,
- "good_code" => '',
- "good_name" => $good_name,
- "cat_id" => $cat_id,
- 'brand_id' => $brandid,
- "good_unit" => $unit,
- "good_type" => $good_type,
- "moq" => $moq,
- "is_exclusive" => $is_exclusive,
- "customized" => $customized,
- "companyNo" => $company_id,
- "tax" => $tax,
- "supplierNo" => $supplierNo,
- "good_size" => $good_size,
- "is_auth" => $is_auth,
- "is_stock" => $is_stock,
- "auth_img" => $auth_img,
- "after_sales" => $after_sales,
- "craft_desc" => $craft_desc,
- "good_remark" => $good_remark,
- "weight" => $weight,
- "packing_way" => $packing_way,
- "packing_size" => $packing_size,
- "packing_spec" => $packing_spec,
- "packing_list" => $packing_list,
- "packing_weight" => $packing_weight,
- "good_bar" => $good_bar,
- "supply_area" => $supply_area,
- "delivery_place" => $delivery_place,
- "origin_place" => $origin_place,
- "delivery_day" => $delivery_day,
- "lead_time" => $lead_time,
- "sample_day" => $sample_day,
- "sample_fee" => $sample_fee,
- "good_img" => $good_img,
- "good_thumb_img" => $good_thumb_img,
- "good_info_img" => $good_info_img,
- "cert_fee" => $cert_fee,
- "packing_fee" => $packing_fee,
- "cost_fee" => $cost_fee,
- "mark_fee" => $mark_fee,
- "demo_fee" => $demo_fee,
- "open_fee" => $open_fee,
- "noble_metal" => $noble_metal,
- "cgd_gold_price" => $cgd_gold_price,
- "noble_weight" => $noble_weight,
- "is_gold_price" => $is_gold_price,
- "market_price" => $market_price,
- "nake_price" => $nake_price,
- "is_diff" => $is_diff,
- "config" => $config,
- "other_config" => $other_config,
- "field_change" => '',
- "is_step" => count($good_ladder) > 1 ? 1 : 0,//如果阶梯价个数大于1,说明启用阶梯价
- "is_online" => 0,
- "stock_moq" => $stock_moq,
- "status" => 0,
- "createrid" => $createrid,
- "creater" => $creater,
- "addtime" => date("Y-m-d H:i:s"),
- "updatetime" => date("Y-m-d H:i:s"),
- 'is_support_barter' => $is_support_barter,
- 'chargerid' => $charger['personid'] ?? 0,
- 'charger' => $charger['person'] ?? '',//负责人,取所属供应商的创建人
- ];
- $in = Db::name("good_basic")->insertGetId($data);
- if ($in) {
- if ($speclist !== "" && !empty($speclist)) {
- $temp = [];
- foreach ($speclist as $value) {
- $lemp = [];
- $lemp['spuCode'] = $spucode;
- $lemp['spec_id'] = $value['spec_id'];
- $lemp['spec_value_id'] = $value['spec_value_id'];
- $lemp['addtime'] = date("Y-m-d H:i:s");
- $lemp['updatetime'] = date("Y-m-d H:i:s");
- $temp[] = $lemp;
- }
- $count = Db::name("good_spec")->insertAll($temp);
- if ($count == 0) {
- Db::rollback();
- return json_show(1004, "商品规格值创建失败");
- }
- }
- // $catinfo = Db::name("cat")->where(["id" => $cat_id])->find();
- // $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate'] / 100 : 0;
- if ($good_ladder !== "" && !empty($good_ladder)) {
- $temp = [];
- foreach ($good_ladder as $value) {
- $lemp = [];
- $lemp['spuCode'] = $spucode;
- $lemp['min_num'] = $value['min_num'];
- $lemp['nake_fee'] = $value['nake_fee'];
- $lemp['cost_fee'] = $value['cost_fee'];
- $lemp['delivery_fee'] = $value['delivery_fee'];
- $lemp['cert_fee'] = $value['cert_fee'];
- $lemp['mark_fee'] = $value['mark_fee'];
- $lemp['package_fee'] = $value['package_fee'];
- $lemp['other_fee'] = $value['other_fee'];
- if ($is_gold_price == 1 && $top_cat_id == 6) {
- //$is_gold_price==1 表示启用实时金价,cat_id==6表示贵金属
- $gold = Db::name("gold_price1")->where(["type" => $noble_metal, "status" => 1, "is_del" => 0])->order("addtime desc")->find();
- //$lemp['nake_total'] = $noble_weight * $gold['price'] + $value['cost_fee'] * $noble_weight + $value['mark_fee'] + $value['package_fee'] + $value['cert_fee'] + $value['nake_fee'] + $value['delivery_fee'] + $value['other_fee'];
- //成本合计=贵金属重量*供应商采购金价 + 工艺费*贵金属重量+加标费+包装费+证书费+成本裸价+运费+其他费用
- //成本总计启用实时金价时,采用供应商实时金价
- $lemp['nake_total'] = $noble_weight * $gold['price'] + $value['cost_fee'] * $noble_weight +
- $value['mark_fee'] + $value['package_fee'] + $value['cert_fee'] + $value['nake_fee'] + $value['delivery_fee'] + $value['other_fee'];
- } else {
- $lemp['nake_total'] = $value['nake_fee'] + $value['delivery_fee'] + $value['cert_fee'] + $value['mark_fee'] + $value['package_fee'] + $value['other_fee'];
- }
- $lemp['creater_id'] = $createrid;
- $lemp['creater'] = $creater;
- $lemp['is_del'] = 0;
- $lemp['addtime'] = date("Y-m-d H:i:s");
- $lemp['updatetime'] = date("Y-m-d H:i:s");
- $temp[] = $lemp;
- }
- $count = Db::name("good_nake")->insertAll($temp);
- if ($count == 0) {
- Db::rollback();
- return json_show(1004, "商品规格值创建失败");
- }
- }
- //修改状态,添加待办
- ActionLog::logAdd(['id' => $createrid, 'nickname' => $creater], [
- "order_code" => $spucode,//咨询单详情编号
- "status" => 0,//这里的status是之前的值
- "action_remark" => '',//备注
- "action_type" => "create"//新建create,编辑edit,更改状态status
- ], "SPCB", 0, $data);
- ProcessOrder::AddProcess(['id' => $createrid, 'nickname' => $creater], [
- "order_type" => 'SPCB',
- "order_code" => $spucode,//咨询单详情编号
- "order_id" => $in,
- "order_status" => 0,
- "before_status" => 0,
- 'holder_id' => $data['createrid'],
- 'person_id' => Db::name('supplier')->where(['code' => $this->request->user['supplierNo'], 'is_del' => 0])->value('personid'),
- ]);
- Db::commit();
- return json_show(0, "创建成功", ["spuCode" => $spucode]);
- } else {
- Db::rollback();
- return json_show(1004, "商品创建失败");
- }
- } catch (\Exception $e) {
- Db::rollback();
- return json_show(1004, $e->getMessage());
- }
- }
- //修改商品基础信息
- public function updateGoodBasicsInfo()
- {
- $this->post = $this->request->filter('trim')->post();
- $supcode = isset($this->post['spuCode']) && $this->post['spuCode'] != "" ? trim($this->post['spuCode']) : "";
- if ($supcode == "") {
- return json_show(1004, "参数spuCode不能为空");
- }
- $data = Db::name("good_basic")->where(["spuCode" => $supcode, "is_del" => 0])->find();
- if ($data == false) {
- return json_show(1004, "未找到商品数据");
- }
- $is_down = Db::name("good_platform")->where(["spuCode" => $supcode, "is_del" => 0])->where("exam_status", "<>", 5)->find();
- if ($is_down != false) {
- return json_show(1004, "存在未下线商品数据");
- }
- if ($data['status'] != 1) return json_show(1005, '该状态下不允许修改基础信息');
- $good_name = isset($this->post['good_name']) && $this->post['good_name'] != "" ? trim($this->post['good_name']) : "";
- if ($good_name == "") {
- return json_show(1004, "商品名称不能为空");
- }
- $cat_id = isset($this->post['cat_id']) && $this->post['cat_id'] != "" ? intval($this->post['cat_id']) : "";
- if ($cat_id == '') {
- return json_show(1004, "商品分类不能为空");
- }
- $brandid = isset($this->post['brandid']) && $this->post['brandid'] != "" ? intval($this->post['brandid']) : "0";
- // if($brandid==''){
- // return json_show(1004,"商品品牌不能为空");
- // }
- $unit = isset($this->post['unit']) && $this->post['unit'] != "" ? trim($this->post['unit']) : "";
- if ($unit == '') {
- return json_show(1004, "商品单位不能为空");
- }
- $good_type = isset($this->post['good_type']) && $this->post['good_type'] !== "" ? intval($this->post['good_type']) : "";
- if ($good_type === '') {
- return json_show(1004, "参数good_type不能为空");
- }
- $moq = 0;
- $customized = 0;
- if ($good_type == 1) {
- $moq = isset($this->post['moq']) && $this->post['moq'] !== "" ? intval($this->post['moq']) : "";
- if ($moq === '') {
- return json_show(1004, "定制商品起订量不能为空");
- }
- $customized = isset($this->post['customized']) && $this->post['customized'] !== "" ? intval($this->post['customized']) : "";
- if ($customized === '') {
- return json_show(1004, "参数customized不能为空");
- }
- }
- $is_exclusive = isset($this->post['is_exclusive']) && $this->post['is_exclusive'] !== "" ? intval($this->post['is_exclusive']) : "";
- if ($is_exclusive === '') {
- return json_show(1004, "参数is_exclusive不能为空");
- }
- // $customized = isset($this->post['customized'])&&$this->post['customized']!==""? intval($this->post['customized']):"";
- // if($customized===''){
- // return json_show(1004,"参数customized不能为空");
- // }
- $tax = isset($this->post['tax']) && $this->post['tax'] !== "" ? intval($this->post['tax']) : "";
- if ($tax === '') {
- return json_show(1004, "参数tax不能为空");
- }
- $supplierNo = isset($this->post['supplierNo']) && $this->post['supplierNo'] != "" ? trim($this->post['supplierNo']) : "";
- if ($supplierNo == '') {
- return json_show(1004, "参数supplierNo不能为空");
- }
- $good_size = isset($this->post['good_size']) && $this->post['good_size'] != "" ? trim($this->post['good_size']) : "";
- if ($good_size == '') {
- return json_show(1004, "参数good_size不能为空");
- }
- $company_id = isset($this->post['company_id']) && $this->post['company_id'] != "" ? trim($this->post['company_id']) : "";
- if ($company_id == '') {
- return json_show(1004, "参数company_id不能为空");
- }
- $is_auth = isset($this->post['is_auth']) && $this->post['is_auth'] !== "" ? intval($this->post['is_auth']) : "";
- if ($is_auth === '') {
- return json_show(1004, "参数is_auth不能为空");
- }
- $auth_img = isset($this->post['auth_img']) && $this->post['auth_img'] != "" ? trim($this->post['auth_img']) : "";
- // if($auth_img==''){
- // return json_show(1004,"商品不能为空");
- // }
- $after_sales = isset($this->post['after_sales']) && $this->post['after_sales'] != "" ? trim($this->post['after_sales']) : "";
- if ($after_sales == "") {
- return json_show(1004, "参数after_sales不能为空");
- }
- $craft_desc = isset($this->post['craft_desc']) && $this->post['craft_desc'] != "" ? trim($this->post['craft_desc']) : "";
- $good_remark = isset($this->post['good_remark']) && $this->post['good_remark'] != "" ? trim($this->post['good_remark']) : "";
- if ($good_remark === "") {
- return json_show(1004, "参数good_remark不能为空");
- }
- $weight = isset($this->post['weight']) && $this->post['weight'] !== "" ? floatval($this->post['weight']) : "";
- if ($weight === "") {
- return json_show(1004, "参数weight不能为空");
- }
- $packing_way = isset($this->post['packing_way']) && $this->post['packing_way'] !== "" ? trim($this->post['packing_way']) : "";
- if ($packing_way === "") {
- return json_show(1004, "参数packing_way不能为空");
- }
- $packing_size = isset($this->post['packing_size']) && $this->post['packing_size'] !== "" ? trim($this->post['packing_size']) : "";
- if ($packing_size === "") {
- return json_show(1004, "参数packing_size不能为空");
- }
- $packing_spec = isset($this->post['packing_spec']) && $this->post['packing_spec'] !== "" ? trim($this->post['packing_spec']) : "";
- if ($packing_spec === "") {
- return json_show(1004, "参数packing_spec不能为空");
- }
- $packing_weight = isset($this->post['packing_weight']) && $this->post['packing_weight'] !== "" ? floatval($this->post['packing_weight']) : "";
- if ($packing_weight === "") {
- return json_show(1004, "参数packing_weight不能为空");
- }
- $packing_list = isset($this->post['packing_list']) && $this->post['packing_list'] !== "" ? trim($this->post['packing_list']) : "";
- if ($packing_list === "") {
- return json_show(1004, "参数packing_list不能为空");
- }
- $good_bar = isset($this->post['good_bar']) && $this->post['good_bar'] !== "" ? trim($this->post['good_bar']) : "";
- $supply_area = isset($this->post['supply_area']) && $this->post['supply_area'] !== "" ? intval($this->post['supply_area']) : "";
- if ($supply_area === "") {
- return json_show(1004, "参数supply_area不能为空");
- }
- $delivery_place = isset($this->post['delivery_place']) && $this->post['delivery_place'] !== "" ? $this->post['delivery_place'] : "";
- if ($delivery_place === "") {
- return json_show(1004, "参数delivery_place不能为空");
- }
- $origin_place = isset($this->post['origin_place']) && $this->post['origin_place'] !== "" ? $this->post['origin_place'] : "";
- if ($origin_place === "") {
- return json_show(1004, "参数origin_place不能为空");
- }
- $delivery_day = isset($this->post['delivery_day']) && $this->post['delivery_day'] !== "" ? intval($this->post['delivery_day']) : "";
- if ($delivery_day === "") {
- return json_show(1004, "参数delivery_day不能为空");
- }
- $lead_time = isset($this->post['lead_time']) && $this->post['lead_time'] !== "" ? intval($this->post['lead_time']) : "0";
- // if($lead_time===""){
- // return json_show(1004,"参数lead_time不能为空");
- // }
- $sample_day = isset($this->post['sample_day']) && $this->post['sample_day'] !== "" ? intval($this->post['sample_day']) : "0";
- // if($sample_day===""){
- // return json_show(1004,"参数sample_day不能为空");
- // }
- // $sample_fee = isset($this->post['sample_fee'])&&$this->post['sample_fee']!==""? floatval
- //($this->post['sample_fee']):"0";
- $config = isset($this->post['config']) && $this->post['config'] !== "" ? trim($this->post['config']) : "";
- $other_config = isset($this->post['other_config']) && $this->post['other_config'] !== "" ? trim($this->post['other_config']) : "";
- $is_diff = isset($this->post['is_diff']) && $this->post['is_diff'] !== "" ? intval($this->post['is_diff']) : "0";
- $is_stock = isset($this->post['is_stock']) && $this->post['is_stock'] !== "" ? intval($this->post['is_stock']) : "0";
- $stock_moq = isset($this->post['stock_moq']) && $this->post['stock_moq'] !== "" ? intval($this->post['stock_moq']) : "0";
- if ($is_stock == 1 && $stock_moq == 0) {
- return json_show(1004, "库存品备库起订量不能为零");
- }
- $good_img = isset($this->post['good_img']) && $this->post['good_img'] != "" ? trim($this->post['good_img']) : "";
- if ($good_img === "") {
- return json_show(1004, "参数good_img不能为空");
- }
- $good_thumb_img = isset($this->post['good_thumb_img']) && $this->post['good_thumb_img'] !== "" ? trim($this->post['good_thumb_img']) : "";
- if ($good_thumb_img === "") {
- return json_show(1004, "参数good_thumb_img不能为空");
- }
- $good_info_img = isset($this->post['good_info_img']) && !empty($this->post['good_info_img']) ? trim($this->post['good_info_img']) : "";
- if ($good_info_img === "") {
- return json_show(1004, "参数good_info_img不能为空");
- }
- $count = Db::name("good_nake")->where(["spuCode" => $supcode, "is_del" => 0])->count();
- $speclist = isset($this->post['speclist']) && !empty($this->post['speclist']) ? $this->post['speclist'] : "";
- $uid = $this->request->user['uid'];
- $nickname = $this->request->user['nickname'];
- Db::startTrans();
- try {
- $temp = [
- "good_name" => $good_name,
- "cat_id" => $cat_id,
- 'brand_id' => $brandid,
- "good_unit" => $unit,
- "good_type" => $good_type,
- "companyNo" => $company_id,
- "moq" => $moq,
- "is_exclusive" => $is_exclusive,
- "customized" => $customized,
- "tax" => $tax,
- "supplierNo" => $supplierNo,
- "is_auth" => $is_auth,
- "good_size" => $good_size,
- "auth_img" => $auth_img,
- "after_sales" => $after_sales,
- "craft_desc" => $craft_desc,
- "good_remark" => $good_remark,
- "weight" => $weight,
- "packing_way" => $packing_way,
- "packing_size" => $packing_size,
- "packing_spec" => $packing_spec,
- "packing_list" => $packing_list,
- "packing_weight" => $packing_weight,
- "good_bar" => $good_bar,
- "supply_area" => $supply_area,
- "delivery_place" => $delivery_place,
- "origin_place" => $origin_place,
- "delivery_day" => $delivery_day,
- "lead_time" => $lead_time,
- "sample_day" => $sample_day,
- "is_diff" => $is_diff,
- 'is_stock' => $is_stock,
- "config" => $config,
- "other_config" => $other_config,
- "good_img" => $good_img,
- "stock_moq" => $stock_moq,
- "good_thumb_img" => $good_thumb_img,
- "good_info_img" => $good_info_img,
- "status" => $count > 0 ? 2 : 1,
- "updatetime" => date("Y-m-d H:i:s")
- ];
- $field = array_diff_assoc($temp, $data);
- $temp['field_change'] = empty($field) ? "" : json_encode(array_keys($field));
- $up = Db::name("good_basic")->where(["spuCode" => $supcode, "is_del" => 0])->save($temp);
- $timp = array_diff($temp, $data);
- $json = json_encode($timp, JSON_UNESCAPED_UNICODE);
- $jsp = json_encode($data, JSON_UNESCAPED_UNICODE);
- if ($up) {
- ChangeLog::logAdd(3, $data['spuCode'], $jsp, $json, ['id' => $uid, 'nickname' => $nickname], $this->post);
- if ($speclist !== "" && !empty($speclist)) {
- foreach ($speclist as $value) {
- $lemp = [];
- isset($value["id"]) && $value["id"] != '' ? $lemp['id'] = $value['id'] : "";
- $lemp['spuCode'] = $supcode;
- $lemp['spec_id'] = $value['spec_id'];
- $lemp['spec_value_id'] = $value['spec_value_id'];
- $lemp['is_del'] = isset($value['is_del']) ? $value['is_del'] : 0;
- isset($value["id"]) && $value["id"] != '' ? "" : $lemp['addtime'] = date("Y-m-d H:i:s");
- $lemp['updatetime'] = date("Y-m-d H:i:s");
- $count = Db::name("good_spec")->save($lemp);
- if ($count == false) {
- Db::rollback();
- return json_show(1004, "商品规格值修改失败");
- }
- }
- }
- //修改状态,添加待办
- ActionLog::logAdd(['id' => $uid, 'nickname' => $nickname], [
- "order_code" => $supcode,//咨询单详情编号
- "status" => $data['status'],//这里的status是之前的值
- "action_remark" => '',//备注
- "action_type" => "edit"//新建create,编辑edit,更改状态status
- ], "SPCB", $temp['status'], $data);
- ProcessOrder::AddProcess(['id' => $uid, 'nickname' => $nickname], [
- "order_type" => 'SPCB',
- "order_code" => $supcode,//咨询单详情编号
- "order_id" => $data['id'],
- "order_status" => $temp['status'],
- "before_status" => $data['status'],
- 'holder_id' => $data['createrid'],
- 'person_id' => Db::name('supplier')->where(['code' => $this->request->user['supplierNo'], 'is_del' => 0])->value('personid'),
- ]);
- Db::commit();
- return json_show(0, "更新成功");
- } else {
- Db::rollback();
- return json_show(1005, "更新失败");
- }
- } catch (\Exception $e) {
- Db::rollback();
- return json_show(1004, $e->getMessage());
- }
- }
- //修改商品价格信息
- public function updateGoodPriceInfo()
- {
- $this->post = $this->request->filter('trim')->post();
- $supcode = isset($this->post['spuCode']) && $this->post['spuCode'] != "" ? trim($this->post['spuCode']) : "";
- if ($supcode == "") {
- return json_show(1004, "参数spuCode不能为空");
- }
- $datas = Db::name("good_basic")->where(["spuCode" => $supcode, "is_del" => 0])->find();
- if ($datas == false) {
- return json_show(1004, "未找到商品数据");
- }
- if ($datas['status'] != 1) return json_show(1005, '该状态下不允许修改价格信息');
- $is_down = Db::name("good_platform")
- ->where(["spuCode" => $supcode, "is_del" => 0])
- ->where("exam_status", "<>", 5)
- ->find();
- if ($is_down != false) {
- return json_show(1004, "存在未下线商品数据");
- }
- $cert_fee = isset($this->post['cert_fee']) && $this->post['cert_fee'] !== "" ? floatval($this->post['cert_fee']) : "0";
- $packing_fee = isset($this->post['packing_fee']) && $this->post['packing_fee'] !== "" ? floatval($this->post['packing_fee']) : "0";
- $cost_fee = isset($this->post['cost_fee']) && $this->post['cost_fee'] !== "" ? floatval($this->post['cost_fee']) : "0";
- $mark_fee = isset($this->post['mark_fee']) && $this->post['mark_fee'] !== "" ? floatval($this->post['mark_fee']) : "0";
- $demo_fee = isset($this->post['demo_fee']) && $this->post['demo_fee'] !== "" ? floatval($this->post['demo_fee']) : "0";
- $open_fee = isset($this->post['open_fee']) && $this->post['open_fee'] !== "" ? floatval($this->post['open_fee']) : "0";
- $sample_fee = isset($this->post['sample_fee']) && $this->post['sample_fee'] !== "" ? floatval($this->post['sample_fee']) : "0";
- $noble_metal = isset($this->post['noble_metal']) && $this->post['noble_metal'] !== "" ? intval($this->post['noble_metal']) : "0";
- $noble_weight = isset($this->post['noble_weight']) && $this->post['noble_weight'] !== "" ? floatval($this->post['noble_weight']) : "0";
- $is_gold_price = isset($this->post['is_gold_price']) && $this->post['is_gold_price'] !== "" ? intval($this->post['is_gold_price']) : "0";
- $market_price = isset($this->post['market_price']) && $this->post['market_price'] !== "" ? floatval($this->post['market_price']) : "";
- $cgd_gold_price = isset($this->post['cgd_gold_price']) && $this->post['cgd_gold_price'] !== "" ? floatval($this->post['cgd_gold_price']) : "0";
- if ($market_price === "") {
- return json_show(1004, "参数market_price不能为空");
- }
- $nake_price = isset($this->post['nake_price']) && $this->post['nake_price'] !== "" ? floatval($this->post['nake_price']) : "";
- // $is_step = isset($this->post['is_step'])&&$this->post['is_step']!==""? intval($this->post['is_step']):"";
- // if($is_step===""){
- // return json_show(1004,"参数is_step不能为空");
- // }
- $good_ladder = isset($this->post['good_ladder']) && !empty($this->post['good_ladder']) ? $this->post['good_ladder'] : "";
- // if($is_step==1 && $good_ladder==""){
- // return json_show(1004,"启用阶梯,阶梯价不能为空");
- // }
- $data = [
- "cert_fee" => $cert_fee,
- "packing_fee" => $packing_fee,
- "cost_fee" => $cost_fee,
- "mark_fee" => $mark_fee,
- "demo_fee" => $demo_fee,
- "open_fee" => $open_fee,
- "sample_fee" => $sample_fee,
- "noble_metal" => $noble_metal,
- "noble_weight" => $noble_weight,
- "is_gold_price" => $is_gold_price,
- "market_price" => $market_price,
- "nake_price" => $nake_price,
- "cgd_gold_price" => $cgd_gold_price,
- "is_step" => count($good_ladder) > 1 ? 1 : 0,
- "status" => "3",
- "updatetime" => date("Y-m-d H:i:s")
- ];
- $field = array_diff_assoc($data, $datas);
- $data['field_change'] = empty($field) ? "" : json_encode(array_keys($field));
- $uid = $this->request->user['uid'];
- $nickname = $this->request->user['nickname'];
- Db::startTrans();
- try {
- $up = Db::name("good_basic")->where(["spuCode" => $supcode, "is_del" => 0])->save($data);
- $temp = array_diff($data, $datas);
- $json = json_encode($temp, JSON_UNESCAPED_UNICODE);
- $jsp = json_encode($datas, JSON_UNESCAPED_UNICODE);
- if ($up) {
- ChangeLog::logAdd(3, $datas['spuCode'], $jsp, $json, ['id' => $uid, 'nickname' => $nickname], $this->post);
- //修改状态,添加待办
- ActionLog::logAdd(['id' => $uid, 'nickname' => $nickname], [
- "order_code" => $supcode,//咨询单详情编号
- "status" => $datas['status'],//这里的status是之前的值
- "action_remark" => '',//备注
- "action_type" => "edit"//新建create,编辑edit,更改状态status
- ], "SPCB", $data['status'], $data);
- ProcessOrder::AddProcess(['id' => $uid, 'nickname' => $nickname], [
- "order_type" => 'SPCB',
- "order_code" => $supcode,//咨询单详情编号
- "order_id" => $datas['id'],
- "order_status" => $data['status'],
- "before_status" => $datas['status'],
- 'holder_id' => $datas['createrid'],
- 'person_id' => Db::name('supplier')->where(['code' => $this->request->user['supplierNo'], 'is_del' => 0])->value('personid'),
- ]);
- // $online = Db::name("good_platform")->where(["spuCode"=>$supcode,"is_del"=>0])->find();
- // if($online){
- // $onup = Db::name("good_platform")->where(["spuCode"=>$supcode,"is_del"=>0])->save
- // (["exam_status"=>2,"updatetime"=>date("Y-m-d H:i:s")]);
- // if($onup==false){
- // Db::rollback();
- // return json_show(1004,"商品规成本修改失败");
- // }
- // //修改状态,添加待办
- // ActionLog::logAdd(['id'=>$uid,'nickname'=>$nickname], [
- // "order_code" =>$online['skuCode'],//咨询单详情编号
- // "status" => $online['exam_status'],//这里的status是之前的值
- // "action_remark" => '',//备注
- // "action_type" => "edit"//新建create,编辑edit,更改状态status
- // ], "SPSX",2,["exam_status"=>2,"updatetime"=>date("Y-m-d H:i:s")]);
- //
- // ProcessOrder::AddProcess(['id'=>$uid,'nickname'=>$nickname], [
- // "order_type" => 'SPSX',
- // "order_code" => $online['skuCode'],//咨询单详情编号
- // "order_id" => $online['id'],
- // "order_status" =>2,"before_status"=>$online['exam_status']
- // ]);
- // }
- if ($good_ladder !== "" && !empty($good_ladder)) {
- // $user =GetUserInfo($this->post['token']);
- foreach ($good_ladder as $value) {
- $lemp = [];
- isset($value["id"]) && $value["id"] != '' ? $lemp['id'] = $value['id'] : "";
- $lemp['spuCode'] = $supcode;
- $lemp['min_num'] = $value['min_num'];
- $lemp['nake_fee'] = $value['nake_fee'];
- $lemp['cost_fee'] = $value['cost_fee'];
- $lemp['delivery_fee'] = $value['delivery_fee'];
- $lemp['cert_fee'] = $value['cert_fee'];
- $lemp['mark_fee'] = $value['mark_fee'];
- $lemp['package_fee'] = $value['package_fee'];
- $lemp['other_fee'] = $value['other_fee'];
- $top_cat_id = made($datas['cat_id']);//获取所有分类
- $top_cat_id = isset($top_cat_id[0]['id']) ? $top_cat_id[0]['id'] : 0;//获取顶级分类id
- if ($is_gold_price == 1 && $top_cat_id == 6) {
- //$gold =Db::name("gold_price1")->where(["type"=>$noble_metal,"status"=>1,"is_del"=>0])
- // ->order("addtime desc")->find();
- //$lemp['nake_total'] =$noble_weight*$gold['price'] + $value['cost_fee']*$noble_weight+$value['mark_fee']+$value['package_fee']+$value['cert_fee']+$value['nake_fee']+$value['delivery_fee']+$value['other_fee'];
- //成本合计=贵金属重量*供应商采购金价 + 工艺费*贵金属重量+加标费+包装费+证书费+成本裸价+运费+其他费用
- //成本总计启用实时金价时,采用供应商实时金价
- $lemp['nake_total'] = $noble_weight * $cgd_gold_price + $value['cost_fee'] * $noble_weight +
- $value['mark_fee'] + $value['package_fee'] + $value['cert_fee'] + $value['nake_fee'] + $value['delivery_fee'] + $value['other_fee'];
- } else {
- $lemp['nake_total'] = $value['nake_fee'] + $value['delivery_fee'] + $value['cert_fee'] + $value['mark_fee'] + $value['package_fee'] + $value['other_fee'];
- }
- $lemp['is_del'] = isset($value['is_del']) ? $value['is_del'] : 0;
- $lemp['creater_id'] = $uid;
- $lemp['creater'] = $nickname;
- isset($value["id"]) && $value["id"] != '' ? "" : $lemp['addtime'] = date("Y-m-d H:i:s");
- $lemp['updatetime'] = date("Y-m-d H:i:s");
- $count = Db::name("good_nake")->save($lemp);
- if ($count == false) {
- Db::rollback();
- return json_show(1004, "商品规成本修改失败");
- }
- }
- }
- Db::commit();
- return json_show(0, "更新成功");
- } else {
- Db::rollback();
- return json_show(1005, "更新失败");
- }
- } catch (\Exception $e) {
- Db::rollback();
- return json_show(1005, $e->getMessage());
- }
- }
- //修改商品成本全部信息
- public function editGoodUp()
- {
- $this->post = $this->request->filter('trim')->post();
- $supcode = isset($this->post['spuCode']) && $this->post['spuCode'] != "" ? trim($this->post['spuCode']) : "";
- if ($supcode == "") {
- return json_show(1004, "参数spuCode不能为空");
- }
- $data = Db::name("good_basic")->where(["spuCode" => $supcode, "is_del" => 0])->find();
- if ($data == false) {
- return json_show(1004, "未找到商品数据");
- }
- $is_down = Db::name("good_platform")
- ->where(["spuCode" => $supcode, "is_del" => 0])
- ->where("exam_status", "not in", [1, 5])//exam_status=1待完善成本,8已下线,除了这两个状态外其他状态都不允许编辑
- ->find();
- if ($is_down != false) {
- return json_show(1004, "存在未下线商品数据");
- }
- if ($data['status'] != 6 && $data['status'] != 7 && $data['status'] != 8) {
- return json_show(1004, "商品状态有误");
- }
- $good_name = isset($this->post['good_name']) && $this->post['good_name'] != "" ? trim($this->post['good_name']) : "";
- if ($good_name == "") {
- return json_show(1004, "商品名称不能为空");
- }
- $cat_id = isset($this->post['cat_id']) && $this->post['cat_id'] != "" ? intval($this->post['cat_id']) : "";
- if ($cat_id == '') {
- return json_show(1004, "商品分类不能为空");
- }
- $brandid = isset($this->post['brandid']) && $this->post['brandid'] != "" ? intval($this->post['brandid']) : "0";
- // if($brandid==''){
- // return json_show(1004,"商品品牌不能为空");
- // }
- $unit = isset($this->post['unit']) && $this->post['unit'] != "" ? trim($this->post['unit']) : "";
- if ($unit == '') {
- return json_show(1004, "商品单位不能为空");
- }
- $good_type = isset($this->post['good_type']) && $this->post['good_type'] !== "" ? intval($this->post['good_type']) : "";
- if ($good_type === '') {
- return json_show(1004, "参数good_type不能为空");
- }
- $moq = 0;
- $customized = 0;
- if ($good_type == 1) {
- $moq = isset($this->post['moq']) && $this->post['moq'] !== "" ? intval($this->post['moq']) : "";
- if ($moq === '') {
- return json_show(1004, "定制商品起订量不能为空");
- }
- $customized = isset($this->post['customized']) && $this->post['customized'] !== "" ? intval($this->post['customized']) : "";
- if ($customized === '') {
- return json_show(1004, "参数customized不能为空");
- }
- }
- $is_exclusive = isset($this->post['is_exclusive']) && $this->post['is_exclusive'] !== "" ? intval($this->post['is_exclusive']) : "";
- if ($is_exclusive === '') {
- return json_show(1004, "参数is_exclusive不能为空");
- }
- // $customized = isset($this->post['customized'])&&$this->post['customized']!==""? intval($this->post['customized']):"";
- // if($customized===''){
- // return json_show(1004,"参数customized不能为空");
- // }
- $tax = isset($this->post['tax']) && $this->post['tax'] !== "" ? intval($this->post['tax']) : "";
- if ($tax === '') {
- return json_show(1004, "参数tax不能为空");
- }
- $supplierNo = isset($this->post['supplierNo']) && $this->post['supplierNo'] != "" ? trim($this->post['supplierNo']) : "";
- if ($supplierNo == '') {
- return json_show(1004, "参数supplierNo不能为空");
- }
- $good_size = isset($this->post['good_size']) && $this->post['good_size'] != "" ? trim($this->post['good_size']) : "";
- if ($good_size == '') {
- return json_show(1004, "参数good_size不能为空");
- }
- $company_id = isset($this->post['companyNo']) && $this->post['companyNo'] != "" ? trim($this->post['companyNo']) : "";
- if ($company_id == '') {
- return json_show(1004, "参数companyNo不能为空");
- }
- $is_auth = isset($this->post['is_auth']) && $this->post['is_auth'] !== "" ? intval($this->post['is_auth']) : "";
- if ($is_auth === '') {
- return json_show(1004, "参数is_auth不能为空");
- }
- $auth_img = isset($this->post['auth_img']) && $this->post['auth_img'] != "" ? trim($this->post['auth_img']) : "";
- // if($auth_img==''){
- // return json_show(1004,"商品不能为空");
- // }
- $after_sales = isset($this->post['after_sales']) && $this->post['after_sales'] != "" ? trim($this->post['after_sales']) : "";
- if ($after_sales == "") {
- return json_show(1004, "参数after_sales不能为空");
- }
- $craft_desc = isset($this->post['craft_desc']) && $this->post['craft_desc'] != "" ? trim($this->post['craft_desc']) : "";
- $good_remark = isset($this->post['good_remark']) && $this->post['good_remark'] != "" ? trim($this->post['good_remark']) : "";
- if ($good_remark === "") {
- return json_show(1004, "参数good_remark不能为空");
- }
- $weight = isset($this->post['weight']) && $this->post['weight'] !== "" ? floatval($this->post['weight']) : "";
- if ($weight === "") {
- return json_show(1004, "参数weight不能为空");
- }
- $packing_way = isset($this->post['packing_way']) && $this->post['packing_way'] !== "" ? trim($this->post['packing_way']) : "";
- if ($packing_way === "") {
- return json_show(1004, "参数packing_way不能为空");
- }
- $packing_size = isset($this->post['packing_size']) && $this->post['packing_size'] !== "" ? trim($this->post['packing_size']) : "";
- if ($packing_size === "") {
- return json_show(1004, "参数packing_size不能为空");
- }
- $packing_spec = isset($this->post['packing_spec']) && $this->post['packing_spec'] !== "" ? trim($this->post['packing_spec']) : "";
- if ($packing_spec === "") {
- return json_show(1004, "参数packing_spec不能为空");
- }
- $packing_weight = isset($this->post['packing_weight']) && $this->post['packing_weight'] !== "" ? floatval($this->post['packing_weight']) : "";
- if ($packing_weight === "") {
- return json_show(1004, "参数packing_weight不能为空");
- }
- $packing_list = isset($this->post['packing_list']) && $this->post['packing_list'] !== "" ? trim($this->post['packing_list']) : "";
- if ($packing_list === "") {
- return json_show(1004, "参数packing_list不能为空");
- }
- $good_bar = isset($this->post['good_bar']) && $this->post['good_bar'] !== "" ? trim($this->post['good_bar']) : "";
- $supply_area = isset($this->post['supply_area']) && $this->post['supply_area'] !== "" ? intval($this->post['supply_area']) : "";
- if ($supply_area === "") {
- return json_show(1004, "参数supply_area不能为空");
- }
- $delivery_place = isset($this->post['delivery_place']) && $this->post['delivery_place'] !== "" ? $this->post['delivery_place'] : "";
- if ($delivery_place === "") {
- return json_show(1004, "参数delivery_place不能为空");
- }
- $origin_place = isset($this->post['origin_place']) && $this->post['origin_place'] !== "" ? $this->post['origin_place'] : "";
- if ($origin_place === "") {
- return json_show(1004, "参数origin_place不能为空");
- }
- $delivery_day = isset($this->post['delivery_day']) && $this->post['delivery_day'] !== "" ? intval($this->post['delivery_day']) : "";
- if ($delivery_day === "") {
- return json_show(1004, "参数delivery_day不能为空");
- }
- $lead_time = isset($this->post['lead_time']) && $this->post['lead_time'] !== "" ? intval($this->post['lead_time']) : "0";
- // if($lead_time===""){
- // return json_show(1004,"参数lead_time不能为空");
- // }
- $sample_day = isset($this->post['sample_day']) && $this->post['sample_day'] !== "" ? intval($this->post['sample_day']) : "0";
- // if($sample_day===""){
- // return json_show(1004,"参数sample_day不能为空");
- // }
- $sample_fee = isset($this->post['sample_fee']) && $this->post['sample_fee'] !== "" ? floatval($this->post['sample_fee']) : "0";
- $good_img = isset($this->post['good_img']) && $this->post['good_img'] != "" ? trim($this->post['good_img']) : "";
- if ($good_img === "") {
- return json_show(1004, "参数good_img不能为空");
- }
- $good_thumb_img = isset($this->post['good_thumb_img']) && $this->post['good_thumb_img'] !== "" ? trim($this->post['good_thumb_img']) : "";
- if ($good_thumb_img === "") {
- return json_show(1004, "参数good_thumb_img不能为空");
- }
- $good_info_img = isset($this->post['good_info_img']) && !empty($this->post['good_info_img']) ? trim($this->post['good_info_img']) : "";
- if ($good_info_img === "") {
- return json_show(1004, "参数good_info_img不能为空");
- }
- $cert_fee = isset($this->post['cert_fee']) && $this->post['cert_fee'] !== "" ? floatval($this->post['cert_fee']) : "0";
- $packing_fee = isset($this->post['packing_fee']) && $this->post['packing_fee'] !== "" ? floatval($this->post['packing_fee']) : "0";
- $cost_fee = isset($this->post['cost_fee']) && $this->post['cost_fee'] !== "" ? floatval($this->post['cost_fee']) : "0";
- $mark_fee = isset($this->post['mark_fee']) && $this->post['mark_fee'] !== "" ? floatval($this->post['mark_fee']) : "0";
- $demo_fee = isset($this->post['demo_fee']) && $this->post['demo_fee'] !== "" ? floatval($this->post['demo_fee']) : "0";
- $open_fee = isset($this->post['open_fee']) && $this->post['open_fee'] !== "" ? floatval($this->post['open_fee']) : "0";
- $noble_metal = isset($this->post['noble_metal']) && $this->post['noble_metal'] !== "" ? intval($this->post['noble_metal']) : "0";
- $noble_weight = isset($this->post['noble_weight']) && $this->post['noble_weight'] !== "" ? floatval($this->post['noble_weight']) : "0";
- $is_gold_price = isset($this->post['is_gold_price']) && $this->post['is_gold_price'] !== "" ? intval($this->post['is_gold_price']) : "0";
- $market_price = isset($this->post['market_price']) && $this->post['market_price'] !== "" ? floatval($this->post['market_price']) : "";
- $cgd_gold_price = isset($this->post['cgd_gold_price']) && $this->post['cgd_gold_price'] !== "" ? floatval($this->post['cgd_gold_price']) : "0";
- if ($market_price === "") {
- return json_show(1004, "参数market_price不能为空");
- }
- $nake_price = isset($this->post['nake_price']) && $this->post['nake_price'] !== "" ? floatval($this->post['nake_price']) : "0";
- $config = isset($this->post['config']) && $this->post['config'] !== "" ? trim($this->post['config']) : "";
- $other_config = isset($this->post['other_config']) && $this->post['other_config'] !== "" ? trim($this->post['other_config']) : "";
- $is_diff = isset($this->post['is_diff']) && $this->post['is_diff'] !== "" ? intval($this->post['is_diff']) : "0";
- $is_stock = isset($this->post['is_stock']) && $this->post['is_stock'] !== "" ? intval($this->post['is_stock']) : "0";
- $stock_moq = isset($this->post['stock_moq']) && $this->post['stock_moq'] !== "" ? intval($this->post['stock_moq']) : "0";
- if ($is_stock == 1 && $stock_moq == 0) {
- return json_show(1004, "库存品备库起订量不能为零");
- }
- // $is_step = isset($this->post['is_step'])&&$this->post['is_step']!==""? intval($this->post['is_step']):"";
- // if($is_step===""){
- // return json_show(1004,"参数is_step不能为空");
- // }
- $good_ladder = isset($this->post['good_ladder']) && !empty($this->post['good_ladder']) ? $this->post['good_ladder'] : "";
- // if($is_step==1 && $good_ladder==""){
- // return json_show(1004,"启用阶梯,阶梯价不能为空");
- // }
- $speclist = isset($this->post['speclist']) && !empty($this->post['speclist']) ? $this->post['speclist'] : "";
- $is_support_barter = isset($this->post['is_support_barter']) && $this->post['is_support_barter'] !== "" ? intval($this->post['is_support_barter']) : 1;
- $uid = $this->request->user['uid'];
- $nickname = $this->request->user['nickname'];
- Db::startTrans();
- try {
- $temp = [
- "good_name" => $good_name,
- "cat_id" => $cat_id,
- 'brand_id' => $brandid,
- "good_unit" => $unit,
- "good_type" => $good_type,
- "companyNo" => $company_id,
- "moq" => $moq,
- "is_exclusive" => $is_exclusive,
- "customized" => $customized,
- "tax" => $tax,
- "supplierNo" => $supplierNo,
- "is_auth" => $is_auth,
- "good_size" => $good_size,
- "auth_img" => $auth_img,
- "after_sales" => $after_sales,
- "craft_desc" => $craft_desc,
- "good_remark" => $good_remark,
- "weight" => $weight,
- "packing_way" => $packing_way,
- "packing_size" => $packing_size,
- "packing_spec" => $packing_spec,
- "packing_list" => $packing_list,
- "packing_weight" => $packing_weight,
- "good_bar" => $good_bar,
- "supply_area" => $supply_area,
- "delivery_place" => $delivery_place,
- "origin_place" => $origin_place,
- "delivery_day" => $delivery_day,
- "lead_time" => $lead_time,
- "sample_day" => $sample_day,
- "sample_fee" => $sample_fee,
- "good_img" => $good_img,
- "good_thumb_img" => $good_thumb_img,
- "good_info_img" => $good_info_img,
- "cert_fee" => $cert_fee,
- "packing_fee" => $packing_fee,
- "is_diff" => $is_diff,
- "config" => $config,
- "other_config" => $other_config,
- "is_stock" => $is_stock,
- "cost_fee" => $cost_fee,
- "mark_fee" => $mark_fee,
- "demo_fee" => $demo_fee,
- "open_fee" => $open_fee,
- "noble_metal" => $noble_metal,
- "noble_weight" => $noble_weight,
- "is_gold_price" => $is_gold_price,
- "market_price" => $market_price,
- "nake_price" => $nake_price,
- "cgd_gold_price" => $cgd_gold_price,
- "is_step" => count($good_ladder) > 1 ? 1 : 0,
- "stock_moq" => $stock_moq,
- "status" => "0",
- "updatetime" => date("Y-m-d H:i:s"),
- 'is_support_barter' => $is_support_barter
- ];
- $field = array_diff_assoc($temp, $data);
- $temp['field_change'] = empty($field) ? "" : json_encode(array_keys($field));
- $up = Db::name("good_basic")->where(["spuCode" => $supcode, "is_del" => 0])->save($temp);
- $var = array_diff($temp, $data);
- $json = json_encode($var, JSON_UNESCAPED_UNICODE);
- $dat = json_encode($data, JSON_UNESCAPED_UNICODE);
- if ($up) {
- ChangeLog::logAdd(3, $data['spuCode'], $dat, $json, ['id' => $uid, 'nickname' => $nickname], $this->post);
- //修改状态,添加待办
- ActionLog::logAdd(['id' => $uid, 'nickname' => $nickname], [
- "order_code" => $supcode,//咨询单详情编号
- "status" => $data['status'],//这里的status是之前的值
- "action_remark" => '',//备注
- "action_type" => "create"//新建create,编辑edit,更改状态status
- ], "SPCB", 0, $temp);
- ProcessOrder::AddProcess(['id' => $uid, 'nickname' => $nickname], [
- "order_type" => 'SPCB',
- "order_code" => $supcode,//咨询单详情编号
- "order_id" => $data['id'],
- "order_status" => 0,
- "before_status" => 0,
- 'holder_id' => $data['createrid'],
- 'person_id' => Db::name('supplier')->where(['code' => $this->request->user['supplierNo'], 'is_del' => 0])->value('personid'),
- ]);
- if ($speclist !== "" && !empty($speclist)) {
- foreach ($speclist as $value) {
- $lemp = [];
- isset($value["id"]) && $value["id"] != '' ? $lemp['id'] = $value['id'] : "";
- $lemp['spuCode'] = $supcode;
- $lemp['spec_id'] = $value['spec_id'];
- $lemp['spec_value_id'] = $value['spec_value_id'];
- $lemp['is_del'] = isset($value['is_del']) ? $value['is_del'] : 0;
- isset($value["id"]) && $value["id"] != '' ? "" : $lemp['addtime'] = date("Y-m-d H:i:s");
- $lemp['updatetime'] = date("Y-m-d H:i:s");
- $count = Db::name("good_spec")->save($lemp);
- if ($count == false) {
- Db::rollback();
- return json_show(1004, "商品规格值修改失败");
- }
- }
- }
- if ($good_ladder !== "" && !empty($good_ladder)) {
- // $user =GetUserInfo($this->post['token']);//获取用户信息,下面更新成本表的创建人
- $top_cat_id = made($cat_id);//获取所有分类
- $top_cat_id = isset($top_cat_id[0]['id']) ? $top_cat_id[0]['id'] : 0;//获取顶级分类id
- foreach ($good_ladder as $value) {
- $lemp = [];
- isset($value["id"]) && $value["id"] != '' ? $lemp['id'] = $value['id'] : "";
- $lemp['spuCode'] = $supcode;
- $lemp['min_num'] = $value['min_num'];
- $lemp['nake_fee'] = $value['nake_fee'];
- $lemp['cost_fee'] = $value['cost_fee'];
- $lemp['delivery_fee'] = $value['delivery_fee'];
- $lemp['cert_fee'] = $value['cert_fee'];
- $lemp['mark_fee'] = $value['mark_fee'];
- $lemp['package_fee'] = $value['package_fee'];
- $lemp['other_fee'] = $value['other_fee'];
- if ($is_gold_price == 1 && $top_cat_id == 6) {
- // $gold =Db::name("gold_price1")->where(["type"=>$noble_metal,"status"=>1,"is_del"=>0])
- // ->order("addtime desc")->find();
- //$lemp['nake_total'] =$noble_weight*$gold['price'] + $value['cost_fee']*$noble_weight+$value['mark_fee']+$value['package_fee']+$value['cert_fee']+$value['nake_fee']+$value['delivery_fee']+$value['other_fee'];
- //成本合计=贵金属重量*供应商采购金价 + 工艺费*贵金属重量+加标费+包装费+证书费+成本裸价+运费+其他费用
- //成本总计启用实时金价时,采用供应商实时金价
- $lemp['nake_total'] = $noble_weight * $cgd_gold_price + $value['cost_fee'] * $noble_weight +
- $value['mark_fee'] + $value['package_fee'] + $value['cert_fee'] + $value['nake_fee'] + $value['delivery_fee'] + $value['other_fee'];
- } else {
- $lemp['nake_total'] = $value['nake_fee'] + $value['delivery_fee'] + $value['cert_fee'] + $value['mark_fee'] + $value['package_fee'] + $value['other_fee'];
- }
- $lemp['creater_id'] = $this->request->user['uid'];
- $lemp['creater'] = $this->request->user['nickname'];
- $lemp['is_del'] = isset($value['is_del']) ? $value['is_del'] : 0;
- isset($value["id"]) && $value["id"] != '' ? "" : $lemp['addtime'] = date("Y-m-d H:i:s");
- $lemp['updatetime'] = date("Y-m-d H:i:s");
- $count = Db::name("good_nake")->save($lemp);
- if ($count == false) {
- Db::rollback();
- return json_show(1004, "商品规成本修改失败");
- }
- }
- }
- Db::commit();
- return json_show(0, "更新成功");
- } else {
- Db::rollback();
- return json_show(1005, "更新失败");
- }
- } catch (\Exception $e) {
- Db::rollback();
- return json_show(1004, $e->getMessage());
- }
- }
- //获取商品详情
- public function read()
- {
- $this->post = $this->request->filter('trim')->post();
- $supcode = isset($this->post['spuCode']) && $this->post['spuCode'] != "" ? trim($this->post['spuCode']) : "";
- if ($supcode == "") {
- return json_show(1004, "参数spuCode不能为空");
- }
- $data = Db::name("good_basic")->where(["spuCode" => $supcode, "is_del" => 0])->find();
- if ($data == false) {
- return json_show(1004, "未找到商品数据");
- }
- $unit = Db::name("unit")->where(["id" => $data['good_unit']])->find();
- $data['unit'] = isset($unit['unit']) ? $unit['unit'] : '';
- $data['cat_info'] = made($data['cat_id'], []);
- $spec = Db::name("good_spec")->where(["spuCode" => $supcode, "is_del" => 0])->select()->toArray();
- $supplier = Db::name("supplier")->where(["code" => $data['supplierNo']])->find();
- $data['supplierName'] = isset($supplier['name']) ? $supplier['name'] : "";
- $supplier = Db::name("supplier")->where(["code" => $data['supplierNo']])->find();
- $data['supplierName'] = isset($supplier['name']) ? $supplier['name'] : "";
- $company = Db::name("business")->where(["companyNo" => $data['companyNo']])->find();
- $data['company'] = isset($company['company']) ? $company['company'] : "";
- $data['field_change'] = $data['field_change'] != '' ? json_decode($data['field_change']) : "";
- if ($data['brand_id'] != 0) {
- $brand = Db::name("brand")->where(["id" => $data['brand_id']])->find();
- $data["brand_name"] = isset($brand['brand_name']) ? $brand['brand_name'] : "";
- } else {
- $data["brand_name"] = "";
- $data["brand_id"] = "";
- }
- $excluse = makeExcluse($data['is_exclusive']);
- $data['exclusive'] = $excluse;
- $data['noble_name'] = isset($data['noble_metal']) && $data['noble_metal'] != 0 ? $this->noble[$data['noble_metal']] : "";
- $data["good_info_img"] = $data['good_info_img'] != "" ? $data['good_info_img'] : '';
- $data["good_img"] = $data['good_img'] != "" ? $data['good_img'] : [];
- $gold = [];
- if ($data['is_gold_price'] == 1) {
- $gold = Db::name("gold_price1")->where(["type" => $data['noble_metal'], "status" => 1, "is_del" => 0])->order("addtime desc")->find();
- }
- $data['gold_price'] = isset($gold["price"]) ? $gold["price"] : 0;
- $speclist = [];
- if (!empty($spec)) {
- foreach ($spec as $value) {
- $temp = [];
- $temp['id'] = $value['id'];
- $temp['spuCode'] = $value['spuCode'];
- $temp['spec_id'] = $value['spec_id'];
- $temp['spec_value_id'] = $value['spec_value_id'];
- $temp['is_del'] = $value['is_del'];
- $sp = Db::name("specs")->where(["id" => $value['spec_id']])->find();
- $temp['spec_name'] = isset($sp["spec_name"]) ? $sp["spec_name"] : "";
- $spv = Db::name("spec_value")->where(["id" => $value['spec_value_id']])->find();
- $temp['spec_value'] = isset($spv["spec_value"]) ? $spv["spec_value"] : "";
- $speclist[] = $temp;
- }
- }
- $data["speclist"] = empty($speclist) ? [] : $speclist;
- // $nake=[];
- $nakelist = Db::name("good_nake")->where(['spuCode' => $supcode, "is_del" => 0])->select()->toArray();
- // $catinfo = Db::name("cat")->where(["id"=>$data['cat_id']])->find();
- // $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']/100:0;
- $nakearry = [];
- if (!empty($nakelist)) {
- foreach ($nakelist as $value) {
- $nakearry[] = $value;
- }
- }
- $data["nakelist"] = $nakearry;
- return json_show(0, "获取成功", $data);
- }
- //创建规格值
- public function createSpec()
- {
- $this->post = $this->request->filter('trim')->post();
- $spec_id = isset($this->post['spec_id']) && $this->post['spec_id'] !== "" ? intval($this->post['spec_id']) : "";
- if ($spec_id == "") {
- return json_show(1002, "参数spec_id不能为空");
- }
- $spec_value = isset($this->post['spec_value']) && $this->post['spec_value'] !== "" ? trim($this->post['spec_value']) : "";
- if ($spec_value == "") {
- return json_show(1002, "参数spec_value不能为空");
- }
- $id_is_empty = Db::name('spec_value')
- ->field('id')
- ->where([
- 'spec_id' => $spec_id,
- 'spec_value' => $spec_value,
- 'is_del' => 0
- ])->find();
- if ($id_is_empty) return json_show(1005, '数据库已存在该规格值');
- else {
- $data = [
- "spec_id" => $spec_id,
- "spec_value" => $spec_value,
- "is_del" => 0,
- "addtime" => date("Y-m-d H:i:s"),
- "updatetime" => date("Y-m-d H:i:s")
- ];
- $info = Db::name("spec_value")->insert($data);
- if ($info) return json_show(0, "新建成功");
- else return json_show(1002, "新建失败");
- }
- }
- //所有规格值
- public function allSpec()
- {
- $spec_id = $this->request->filter('trim')->post('spec_id/d', 0);
- if ($spec_id == 0) {
- return json_show(1002, "参数spec_id不能为空");
- }
- $info = Db::name('spec_value')
- ->where(['spec_id' => $spec_id, 'is_del' => 0])
- ->select()
- ->toArray();
- return json_show(0, "获取成功", $info);
- }
- //分类信息
- public function catInfo()
- {
- // $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']) :"";
- $id = $this->request->filter('trim')->post('id/d', 0);
- if ($id == "") {
- return json_show(1002, "参数id不能为空");
- }
- $idinfo = Db::name('cat')->where(['id' => $id])->find();
- if ($idinfo == "") {
- return json_show(1002, "未找到数据");
- }
- $info = Db::name('cat_specs')->where(['cat_id' => $idinfo['id'], 'is_del' => 0])->column('specs_id');
- $temp = Db::name('specs')->where(['id' => $info, 'is_del' => 0])->field("id,spec_name")->select();
- //$idinfo['cat_id']=$info['cat_id'];
- $idinfo['spec'] = $temp;
- // $idinfo['specs_id']=$info;
- return json_show(0, "获取成功", $idinfo);
- }
- //实时金价列表
- public function goldPriceLastList()
- {
- $this->post = $this->request->filter('trim')->post();
- $where = [['g.is_del', '=', 0]];
- $type = isset($this->post['type']) && $this->post['type'] != "" ? intval($this->post['type']) : "";
- if ($type !== "") $where[] = ['g.type', '=', $type];
- $company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
- if ($company_name !== "") $where[] = ["g.action_id", 'in', get_company_item_user_by_name($company_name)];
- $ids = Db::name("gold_price1")
- ->where(['is_del' => 0])
- ->group("type")
- ->column("max(id) as id");
- $where[] = ['g.id', 'in', $ids];
- $list = Db::name("gold_price1")
- ->alias('g')
- ->where($where)
- ->select()
- ->toArray();
- $all_createrid = array_column($list,'action_id');
- $item = get_company_name_by_uid($all_createrid);
- $data = [];
- foreach ($list as $value) {
- $value['type_cn'] = $this->gold[$value['type']];
- $value['company_name'] = $item[$value['action_id']]??'';
- $data[] = $value;
- }
- return json_show(0, "获取成功", $data);
- }
- //贵金属种类列表
- public function linst()
- {
- $data = [];
- foreach ($this->gold as $key => $value) {
- $v = [];
- $v['type'] = $key;
- $v['type_cn'] = $value;
- $data[] = $v;
- }
- return json_show(0, "获取成功", $data);
- }
- //分类列表
- public function wlist()
- {
- $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], ['level', "=", 3]];
- $cat_name = isset($this->post['cat_name']) && $this->post['cat_name'] !== "" ? trim($this->post['cat_name']) : "";
- if ($cat_name !== "") {
- $where[] = ['cat_name', "like", "%$cat_name%"];
- }
- $search = isset($this->post['search']) && $this->post['search'] !== "" ? trim($this->post['search']) : "";
- if ($search !== "") {
- $where[] = ['search', "like", "%$search%"];
- }
- $pid = isset($this->post['pid']) && $this->post['pid'] !== "" ? intval($this->post['pid']) : "";
- if ($pid !== "") {
- $where[] = ['pid', "=", $pid];
- }
- $status = isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) : "";
- if ($status !== "") {
- $where[] = ['status', "=", $status];
- }
- $count = Db::name("cat")->where($where)->count();
- $total = ceil($count / $size);
- $page = $page >= $total ? $total : $page;
- $list = Db::name('cat')->where($where)->page($page, $size)->select();
- $data = [];
- foreach ($list as $value) {
- $temp = isset($value['id']) && $value['id'] != 0 ? made($value['id']) : [];
- $value['item'] = array_column($temp, 'id');
- $data[] = $value;
- }
- return json_show(0, "获取成功", ['list' => $data, 'count' => $count]);
- }
- //分类列表-全部
- public function title()
- {
- $this->post = $this->request->filter('trim')->post();
- $where = [["is_del", "=", 0]];
- $cat_name = isset($this->post['cat_name']) && $this->post['cat_name'] !== "" ? trim($this->post['cat_name']) : "";
- if ($cat_name !== "") $where[] = ['cat_name', "like", "%$cat_name%"];
- $pid = isset($this->post['pid']) && $this->post['pid'] !== "" ? intval($this->post['pid']) : "";
- if ($pid !== "") $where[] = ["pid", "=", $pid];
- $status = isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) : "";
- if ($status !== "") $where[] = ['status', "=", $status];
- $list = Db::name('cat')
- ->where($where)
- ->select()
- ->toArray();
- return json_show(0, "获取成功", $list);
- }
- //判断是否允许修改成本信息和基础信息
- public function checkIsUpdate()
- {
- $spuCode = $this->request->post('spuCode', '', 'trim');
- if ($spuCode == '') return json_show(1004, '成本商品编号不能为空');
- $is_allow_update = 1;
- //检查是否有上线记录
- $rs = Db::name('good_platform')
- ->field('id')
- ->where(['spuCode' => $spuCode, 'is_del' => 0])
- ->whereNotIn('exam_status', [0, 5])
- ->find();
- if (!empty($rs)) $is_allow_update = 0;
- else {
- $rs = PlatformYouzan::field('id')
- ->where(['spuCode' => $spuCode, 'is_del' => PlatformYouzan::$del_normal])
- ->whereNotIn('exam_status', [PlatformYouzan::$exam_status_8, PlatformYouzan::$exam_status_2])
- ->findOrEmpty()
- ->isEmpty();
- if (!$rs) $is_allow_update = 0;
- }
- return json_show(0, '请求成功', ['is_allow_update' => $is_allow_update]);
- }
- //上线商品复制
- public function copy()
- {
- $this->post = $this->request->filter('trim')->post();
- $supcode = isset($this->post['spuCode']) && $this->post['spuCode'] != "" ? trim($this->post['spuCode']) : "";
- if ($supcode == "") {
- return json_show(1004, "参数spuCode不能为空");
- }
- $data = Db::name("good_basic")->where(["spuCode" => $supcode, "is_del" => 0])->find();
- if ($data == false) {
- return json_show(1004, "未找到商品数据");
- }
- // $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'];
- $nake = Db::name("good_nake")->where(["spuCode" => $supcode, "is_del" => 0])->select()->toArray();
- $ladd = [];
- $newCode = makeNo("SKU");
- if (!empty($nake)) {
- foreach ($nake as $value) {
- $tmp = [];
- $tmp['spuCode'] = $newCode;
- $tmp['min_num'] = $value['min_num'];
- $tmp['nake_fee'] = $value['nake_fee'];
- $tmp['cost_fee'] = $value['cost_fee'];
- $tmp['delivery_fee'] = $value['delivery_fee'];
- $tmp['cert_fee'] = $value['cert_fee'];
- $tmp['mark_fee'] = $value['mark_fee'];
- $tmp['package_fee'] = $value['package_fee'];
- $tmp['other_fee'] = $value['other_fee'];
- $tmp['nake_total'] = $value['nake_total'];
- $tmp['creater_id'] = $createrid;
- $tmp['creater'] = $creater;
- $tmp['is_del'] = $value['is_del'];
- $tmp['addtime'] = date("Y-m-d H:i:s");
- $tmp['updatetime'] = date("Y-m-d H:i:s");
- $ladd[] = $tmp;
- }
- }
- $spec = Db::name("good_spec")
- ->where(["spuCode" => $supcode, "is_del" => 0])
- ->select()
- ->toArray();
- $specArr = [];
- if (!empty($spec)) {
- foreach ($spec as $value) {
- $tmp = [];
- $tmp['spuCode'] = $newCode;
- $tmp['spec_id'] = $value['spec_id'];
- $tmp['spec_value_id'] = $value['spec_value_id'];
- $tmp['is_del'] = $value['is_del'];
- $tmp['addtime'] = date("Y-m-d H:i:s");
- $tmp['updatetime'] = date("Y-m-d H:i:s");
- $specArr[] = $tmp;
- }
- }
- Db::startTrans();
- try {
- unset($data['id']);
- $data['spuCode'] = $newCode;
- $data['createrid'] = $createrid;
- $data['creater'] = $creater;
- $data['status'] = 7;
- $data['addtime'] = date("Y-m-d H:i:s");
- $data['updatetime'] = date("Y-m-d H:i:s");
- $cre = Db::name("good_basic")->insert($data);
- if ($cre) {
- //修改状态,添加待办
- ActionLog::logAdd(['id' => $createrid, 'nickname' => $creater], [
- "order_code" => $newCode,//咨询单详情编号
- "status" => 0,//这里的status是之前的值
- "action_remark" => '',//备注
- "action_type" => "create"//新建create,编辑edit,更改状态status
- ], "SPCB", 7, $data);
- ProcessOrder::AddProcess(['id' => $createrid, 'nickname' => $creater], [
- "order_type" => 'SPCB',
- "order_code" => $newCode,//咨询单详情编号
- "order_id" => Db::name("good_basic")->getLastInsID(),
- "order_status" => 7,
- "before_status" => 0,
- 'holder_id' => $data['createrid'],
- 'person_id' => Db::name('supplier')->where(['code' => $this->request->user['supplierNo'], 'is_del' => 0])->value('personid'),
- ]);
- if (!empty($ladd)) {
- $na = Db::name("good_nake")->insertAll($ladd);
- if ($na == 0) {
- Db::rollback();
- return json_show(1005, "成本数据复制失败");
- }
- }
- if (!empty($specArr)) {
- $sp = Db::name("good_spec")->insertAll($specArr);
- if ($sp == 0) {
- Db::rollback();
- return json_show(1005, "规格数据复制失败");
- }
- }
- Db::commit();
- return json_show(0, "复制数据成功", ["spuCode" => $newCode]);
- } else {
- Db::rollback();
- return json_show(1005, "数据复制失败");
- }
- } catch (\Exception $e) {
- Db::rollback();
- return json_show(1004, $e->getMessage());
- }
- }
- //上线商品详情
- public function info()
- {
- $this->post = $this->request->filter('trim')->post();
- $skucode = isset($this->post['skuCode']) && $this->post['skuCode'] != "" ? trim($this->post['skuCode']) : "";
- if ($skucode == "") {
- return json_show(1005, "参数skuCode不能为空");
- }
- $good_platform = Db::name("good_platform")->where(['skuCode' => $skucode, "is_del" => 0])->find();
- if ($good_platform == false) {
- return json_show(1004, "未找到商品数据");
- }
- $data = Db::name("good")->where(["spuCode" => $good_platform['spuCode'], "is_del" => 0])->find();
- if ($data == false) {
- return json_show(1004, "未找到商品数据");
- }
- $plat = Db::name("platform")->where(["id" => $good_platform['platform_code']])->find();
- $data['skuCode'] = $good_platform['skuCode'];
- $data['platform_code'] = $good_platform['id'];
- $data['platform_code_en'] = isset($plat['platform_code']) ? $plat['platform_code'] : "";
- $data['platform_name'] = isset($plat['platform_name']) ? $plat['platform_name'] : "";
- $data['online_reason'] = $good_platform['online_reason'];
- $data['online_time'] = $good_platform['online_time'];
- $data['online_remark'] = $good_platform['online_remark'];
- $data['exam_status'] = $good_platform['exam_status'];
- $data['is_online'] = $good_platform['is_online'];
- $data['plat_code'] = $good_platform['plat_code'];
- $data['exclusive'] = makeExcluse($data['is_exclusive']);
- $unit = Db::name("unit")->where(["id" => $data['good_unit']])->find();
- $data['unit'] = isset($unit['unit']) ? $unit['unit'] : '';
- $data['cat_info'] = made($data['cat_id'], []);
- $spec = Db::name("good_spec")->where(["spuCode" => $good_platform['spuCode'], "is_del" => 0])->select()->toArray();
- $supplier = Db::name("supplier")->where(["code" => $data['supplierNo']])->find();
- $data['supplierName'] = isset($supplier['name']) ? $supplier['name'] : "";
- $data['noble_name'] = isset($data['noble_metal']) && $data['noble_metal'] != 0 ? $this->noble[$data['noble_metal']] : "";
- $company = Db::name("business")->where(["companyNo" => $data['companyNo']])->find();
- $data['company'] = isset($company['company']) ? $company['company'] : "";
- if ($data['brand_id'] != 0) {
- $brand = Db::name("brand")->where(["id" => $data['brand_id']])->find();
- $data["brand_name"] = isset($brand['brand_name']) ? $brand['brand_name'] : "";
- } else {
- $data["brand_name"] = "";
- $data["brand_id"] = "";
- }
- $data['origin_place_cn'] = "";
- $data['delivery_place_cn'] = "";
- if ($data['delivery_place'] !== "") {
- $place = ["provice_code" => "", "city_code" => "", "area_code" => ""];
- list($place['provice_code'], $place['city_code'], $place['area_code']) = explode(",", $data['delivery_place']);
- $data['delivery_place_cn'] = GetAddr(json_encode($place));
- }
- if ($data['origin_place'] !== "") {
- $place = ["provice_code" => "", "city_code" => "", "area_code" => ""];
- list($place['provice_code'], $place['city_code'], $place['area_code']) = explode(",", $data['origin_place']);
- $data['origin_place_cn'] = GetAddr(json_encode($place));
- }
- $excluse = makeExcluse($data['is_exclusive']);
- $data['exclusive'] = $excluse;
- $data["good_info_img"] = $data['good_info_img'] != "" ? $data['good_info_img'] : [];
- $data["good_img"] = $data['good_img'] != "" ? $data['good_img'] : [];
- $speclist = [];
- if (!empty($spec)) {
- foreach ($spec as $value) {
- $temp = [];
- $temp['id'] = $value['id'];
- $temp['spuCode'] = $value['spuCode'];
- $temp['spec_id'] = $value['spec_id'];
- $temp['spec_value_id'] = $value['spec_value_id'];
- $temp['is_del'] = $value['is_del'];
- $sp = Db::name("specs")->where(["id" => $value['spec_id']])->find();
- $temp['spec_name'] = isset($sp["spec_name"]) ? $sp["spec_name"] : "";
- $spv = Db::name("spec_value")->where(["id" => $value['spec_value_id']])->find();
- $temp['spec_value'] = isset($spv["spec_value"]) ? $spv["spec_value"] : "";
- $speclist[] = $temp;
- }
- }
- $data["speclist"] = empty($speclist) ? [] : $speclist;
- $ladder = Db::name("good_ladder")->where(['skuCode' => $skucode, "is_del" => 0])->select()->toArray();
- $data["ladderlist"] = !empty($ladder) ? $ladder : [];
- $nakelist = Db::name("good_nake")->where(['spuCode' => $good_platform['spuCode'], "is_del" => 0])->select()->toArray();
- // $catinfo = Db::name("cat")->where(["id"=>$data['cat_id']])->find();
- $cat_top_list = $data['cat_info'];
- $cat_top_id = isset($cat_top_list[0]['id']) ? $cat_top_list[0]['id'] : 0;
- // $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']/100:0;
- $gold_price = 0;
- if ($data['is_gold_price'] == 1 && $cat_top_id == 6) {
- $gold_price = Db::name("gold_price1")->where(["type" => $data['noble_metal'], "status" => 1, "is_del" => 0])->order("addtime desc")->value('price', 0);
- }
- $data['gold_price'] = $gold_price;
- $nakearry = [];
- if (!empty($nakelist)) {
- //实时金价
- foreach ($nakelist as $value) {
- $value['sale_price'] = $value['nake_total'];
- //计算最终售价
- if ($data['is_gold_price'] == 1 && $cat_top_id == 6) {
- //普通商品:直接用财务提交的售价字段;
- //贵金属( 商品重量* 最新金价 + 工艺费(财务定价提交的)* 商品重量+包装费+加标费+证书费+产品裸价+其他费用)=商品库商品直接下单的售价
- $value['sale_price'] = ($data['weight'] * $gold_price + $value['cost_fee'] * $data['weight'] + $value['package_fee'] + $value['mark_fee'] + $value['cert_fee'] + $value['nake_fee'] + $value['other_fee']);
- }
- $nakearry[] = $value;
- }
- }
- $proof = Db::name("good_proof")->where(["spuCode" => $good_platform['spuCode'], "is_del" => 0])->order("updatetime desc")->field("id,proof_type,proof_url")->find();
- $data['proof'] = isset($proof) && $proof != false ? $proof : [];
- $data["nakelist"] = $nakearry;
- //补充采购员字段
- //成本表里的创建人,也是线上商品的采购人,为了防止混淆,给creater取个别名
- $temp_basic_info = Db::name('good_basic')
- ->field('id,createrid purchase_id,creater purchase')
- ->where(['spuCode' => $data['spuCode'], 'is_del' => 0])
- ->find();
- $data['purchase_id'] = $temp_basic_info['purchase_id'];
- $data['purchase'] = $temp_basic_info['purchase'];
- return json_show(0, "获取成功", $data);
- }
- }
|