redis = new \Redis(); $this->redis->connect('127.0.0.1', 6379); } public function addShoppingCar($user_isli, $goods_isli, $use_years){ $user = User::where('user_isli', $user_isli)->find(); if(!$user){ // throw new \think\Exception('没有该用户', 400); } $goods = Goods::where('goods_islicode', $goods_isli)->where('is_deleted', 0)->find(); if(!$goods){ throw new \think\Exception('没有该标的', 400); } if($goods->goods_status != 1){ throw new \think\Exception('该标的现不在上架中', 400); } if($goods->contract_status != 1){ throw new \think\Exception('标的未申请合约关联,不可购买', 400); } if($goods->user_islicode == $user_isli){ throw new \think\Exception('您是标的的授权方,不可添加', 400); } $order_exists = Order::alias('order') ->join('order_goods_detail detail', 'order.batchcode = detail.batchcode') ->where('order.buy_islicode', $user_isli) ->where('detail.goods_islicode', $goods_isli) ->where('detail.is_deleted', 0) ->where('order.status', '<>', 5) ->value('order.id'); if($order_exists){ throw new \think\Exception('该标的已有订单,添加购物车失败', 400); } $goods_detail = GoodsDetail::where('id', $goods->goods_detail_id)->find(); if($goods_detail->stock <= 0 && $goods_detail->goods_entrust == 1){ throw new \think\Exception('标的库存为0,不可添加', 400); } if($goods_detail->contractual_period == 3){ if(strtotime($goods->contractual_start_time) > time() || strtotime($goods->contractualtime_end_time) < time()){ throw new \think\Exception('标的委托已结束', 400); } } // 获取购物车 $car = $this->redis->get('car_'.$user_isli); if(!empty($car)){ $car = unserialize(stripslashes($car)); $goods_islis = array_column($car, 'goods_isli'); if(in_array($goods_isli, $goods_islis)){ throw new \think\Exception('该标的已添加到购物车', 400); } $car[] = [ 'goods_isli' => $goods_isli, 'use_years' => $use_years, ]; $this->redis->set('car_'.$user_isli, serialize($car)); }else{ $goods = [[ 'goods_isli' => $goods_isli, 'use_years' => $use_years, ]]; $this->redis->set('car_'.$user_isli, serialize($goods)); } } public function delShoppingCar($user_isli, $goods_isli){ // 获取购物车 $car = $this->redis->get('car_'.$user_isli); if(!empty($car)){ $car = unserialize(stripslashes($car)); $callback = function($car)use($goods_isli){ if($car['goods_isli'] == $goods_isli){ return false; } return true; }; $car = array_values(array_filter($car, $callback)); if(count($car) >= 1){ $this->redis->set('car_'.$user_isli, serialize($car)); }else{ $this->redis->del('car_'.$user_isli); } } } public function addCarGoodsCount($user_isli, $goods_isli){ $goods = Goods::where('goods_islicode', $goods_isli)->where('is_deleted', 0)->find(); if(!$goods){ throw new \think\Exception('没有该标的', 400); } if($goods->goods_status != 1){ throw new \think\Exception('该标的现不能购买', 400); } $goods_detail = GoodsDetail::where('id', $goods->goods_detail_id)->find(); // 获取购物车 $redis = new Redis(); $car = $redis->get('car_'.$user_isli); if(!empty($car)){ $car = unserialize(stripslashes($car)); $goods_islis = array_column($car, 'goods_isli'); if(!in_array($goods_isli, $goods_islis)){ throw new \think\Exception('该标的未添加到购物车', 400); } foreach($car as $key => &$value){ if($value['goods_isli'] != $goods_isli){ continue; } $value['goods_num'] += 1; if($value['goods_num'] > $goods_detail->surplus_inventory){ throw new \think\Exception('超出标的库存上限', 400); } } $redis->set('car_'.$user_isli, serialize($car)); } } public function decCarGoodsCount($user_isli, $goods_isli){ $goods = Goods::where('goods_islicode', $goods_isli)->where('is_deleted', 0)->find(); if(!$goods){ throw new \think\Exception('没有该标的', 400); } if($goods->goods_status != 1){ throw new \think\Exception('该标的现不能购买', 400); } $goods_detail = GoodsDetail::where('id', $goods->goods_detail_id)->find(); // 获取购物车 $redis = new Redis(); $car = $redis->get('car_'.$user_isli); if(!empty($car)){ $car = unserialize(stripslashes($car)); $goods_islis = array_column($car, 'goods_isli'); if(!in_array($goods_isli, $goods_islis)){ throw new \think\Exception('该标的未添加到购物车', 400); } foreach($car as $key => &$value){ if($value['goods_isli'] != $goods_isli){ continue; } $value['goods_num'] -= 1; } $redis->set('car_'.$user_isli, serialize($car)); } } public function getShoppingCar($user_isli){ // 获取购物车 $car = $this->redis->get('car_'.$user_isli); if(empty($car)){ return []; } $car = unserialize(stripslashes($car)); $car = array_values($car); $result = []; $ratio_setting = AccountRatioSetting::where('is_deleted', 0)->where('status', 1)->find(); $ratio_detail = AccountRatioDetail::where('setting_id', $ratio_setting->id)->where('role_type', 2)->find(); for($i=count($car)-1; $i >= 0; $i--){ // 商品 $goods = Goods::where('goods_islicode', $car[$i]['goods_isli'])->find(); if(empty($goods) || $goods['goods_status'] != 1){ $goods_isli = $car[$i]['goods_isli']; $callback = function($car)use($goods_isli){ if($car['goods_isli'] == $goods_isli){ return false; } return true; }; $car = array_filter($car, $callback); if(count($car) >= 1){ $this->redis->set('car_'.$user_isli, serialize($car)); }else{ $this->redis->del('car_'.$user_isli); } continue; } // 商品明细 $goods_detail = GoodsDetail::where('id', $goods->goods_detail_id)->find(); $goods_detail->entrust_month = $goods_detail->contractual_period; $goods_detail->hidden(['id', 'total_inventory', 'surplus_inventory', 'goods_islicode', 'data_json', 'source_json', 'is_deleted']); $goods['detail'] = $goods_detail->toArray(); $count = $car[$i]['use_years']; if($goods_detail->goods_entrust == 1){ $count = 1; } if($goods_detail->charges_type == 2){ // 付费 if($ratio_detail->calculate == 1){ // 比例 $service_charge = $count * $goods_detail->price * ($ratio_detail->ratio / 100); }else{ // 固定 $service_charge = $count * $goods_detail->price + $ratio_detail->amount; } $total_money = ($count * $goods_detail->price) + $service_charge + $goods_detail->earnest_money; }else{ // 免费 $service_charge = 0; $total_money = 0; } $goods['service_charge'] = round($service_charge, 2); $goods['total_money'] = round($total_money, 2); $goods['goods_price'] = round($count * $goods_detail->price, 2); if($goods_detail->goods_entrust == 1 || ($goods_detail->charges_type == 1 && $goods_detail->goods_entrust == 2)){ $goods['transaction_count'] = "-"; }else{ $goods['transaction_count'] = $count; } // 商品资源 $goods_source = GoodsSource::where('goods_isli_code', $goods->goods_islicode)->where('is_deleted', 0)->select(); $goods_source->hidden(['id', 'goods_isli_code', 'is_deleted']); $goods['source'] = $goods_source->toArray(); $goods['user'] = (new UserService())->getApiUser($user_isli); $goods->hidden(['is_deleted', 'updatetime', 'goodsDetail', 'goods_detail_id', 'id', 'user_id']); $goods = $goods->toArray(); $result[] = array_merge($car[$i], $goods); } return $result; } public function getTypeGoods($type, $createtime, $goods_type = ""){ $where = []; // type 类型;1:点击;2:销售;3:推荐 if($type == 1){ $limit = 10; $where['order'] = "goods.click_count desc"; }elseif($type == 2){ $limit = 10; $where['order'] = "goods.sale_count desc"; }else{ $limit = 8; $where['order'] = "goods.recommend_sort desc"; $where['is_recommend'] = 1; $where['goods.goods_status'] = 1; } if(!empty($createtime)){ $where['createtime'] = $createtime; } if(!empty($goods_type)){ $where['goodsDetail.goods_type'] = $goods_type; } // $where['is_deleted'] = 0; $goods = new Goods(); $search = $this->buildSearch(['order', 'createtime'], $where); $res = $goods->list($search, $where, "select", ['goodsDetail', 'withJoin' => true], $limit); $res = $res->each(function ($item){ $item['user'] = (new UserService())->getApiUser($item['user_islicode']); $item['entrust_month'] = $item['contractual_period']; $goods_source = GoodsSource::where('goods_isli_code', $item['goods_islicode'])->where('is_deleted', 0)->select(); $goods_source->hidden(['id', 'goods_isli_code', 'is_deleted']); // $item['source'] = $goods_source->toArray(); return $item; }); $res->hidden(['goodsDetail', 'id', 'user_id', 'updatetime', 'is_deleted', 'user_isli']); $res->toArray(); return $res; } public function searchGoods($data){ $where = []; $where['goods.is_deleted'] = 0; $goods_islicode = ""; if(!empty($data['entrust_time'])){ $where['createtime'] = $data['entrust_time']; } if(!empty($data['record_type'])){ $where['goodsDetail.goods_type'] = $data['record_type']; } if(!empty($data['entrust_user_name'])){ $where['username'] = $data['entrust_user_name']; } if(!empty($data['authorization'])){ $where['goodsDetail.goods_entrust'] = $data['authorization']; } if(!empty($data['pay_type'])){ $where['goodsDetail.charges_type'] = $data['pay_type']; } if(!empty($data['entrust_name'])){ $where['goods_field'] = $data['entrust_name']; } if(!empty($data['goods_islicode'])){ $goods_islicode = $data['goods_islicode']; $where['goods_islicode'] = $data['goods_islicode']; } if(!empty($data['entrust_islicode'])){ $where['goods.user_islicode'] = $data['entrust_islicode']; } if(!empty($data['goods_status'])){ $where['goods_status'] = $data['goods_status']; } if(!empty($data['source_type'])){ // 后续改with $source_arr = GoodsSource::whereLike('source_type', "%".$data['source_type']."%")->where('is_deleted', 0)->field('goods_isli_code')->select()->toArray(); $source_ids = implode(',', array_column($source_arr, 'goods_isli_code')); if(empty($source_ids)){ $source_ids = '-1'; } if(isset($where['goods_islicode'])){ $where['goods_islicode'] .= ',' . $source_ids; }else{ $where['goods_islicode'] = $source_ids; } } switch ($data['order_type'] ?? null){ case 'createtime': $where['order'] = ' goods.createtime ' . $data['order'] ?? 'desc'; break; case 'price': $where['order'] = ' goodsDetail.price ' . $data['order'] ?? 'desc'; break; default: $where['order'] = ' goods.id desc'; break; } $limit = 20; if(!empty($data['limit'])){ $limit = $data['limit']; } $goods = new Goods(); $search = $this->buildSearch(['username', 'goods_field', 'order', 'goods_islicode', 'createtime', 'goods_status'], $where); $list = $goods->list($search, $where, $limit, ['goodsDetail', 'withJoin' => true]); $list = $list->each(function ($item){ $item['user'] = (new UserService())->getApiUser($item['user_islicode']); $item['entrust_month'] = $item['contractual_period']; $goods_source = GoodsSource::where('goods_isli_code', $item['goods_islicode'])->where('is_deleted', 0)->select(); $goods_source->hidden(['id', 'goods_isli_code', 'is_deleted']); $item['source'] = $goods_source->toArray(); return $item; }); $list->hidden(['goodsDetail', 'is_deleted', 'id', 'user_id', 'goods_detail_id']); if(!empty($goods_islicode)){ Goods::whereIn('goods_islicode', $goods_islicode)->inc('click_count', 1)->update(); } return $list->toArray(); } public function list($goods, $islicode, $entrust_name, $goods_entrust, $goods_type, $data_type, $createtime, $transaction, $show, $order_status, $entrust_status, $page = 1, $limit = 20){ $where = []; if(!empty($islicode)){ $where['goods.islicode'] = $islicode; } if(!empty($goods)){ $where['goods'] = $goods; } if(!empty($entrust_name)){ $where['search_user'] = $entrust_name; } if(!empty($goods_entrust)){ $where['goodsDetail.goods_entrust'] = $goods_entrust; } if(!empty($goods_type)){ $where['goodsDetail.goods_type'] = $goods_type; } if(!empty($data_type)){ $where['goods.goods_status'] = $data_type; } if(!empty($createtime)){ $where['createtime'] = $createtime; } if(!empty($transaction)){ //交易方式 // $where['goodsDetail.'] = $createtime; $where['goodsDetail.goods_entrust'] = $transaction; } if(!empty($show)){ if($show > 1){ $where['goods.is_recommend'] = 0; }else{ $where['goods.is_recommend'] = $show; } } if(!empty($order_status)){ switch ($order_status){ case 1: $where['order'] = "goods.sale_count desc"; break; case 2: $where['order'] = "goodsDetail.price desc"; break; case 3: $where['order'] = "goods.click_count desc"; break; } } if(!empty($entrust_status)){ $where['goods.entrust_status'] = $entrust_status; } $search = $this->buildSearch(['goods', 'search_user', 'createtime', 'order'], $where); $list = (new Goods())->list($search, $where, $limit, ['goodsDetail', 'withJoin' => true]); $list->each(function ($item){ $item['key'] = $item['goods_islicode']; return $item; }); $list->visible(['id', 'createtime', 'goods_islicode', 'key', 'goods_name', 'username', 'user_islicode', 'goods_type', 'goods_status', 'goods_detail_id', 'is_recommend', 'entrust_status']); $list->hidden(['user', 'goodsDetail']); $list = $list->toArray(); $start = ($page - 1) * $limit + 1; $end = $page * $limit; if($list['total'] < $end){ $end = $list['total']; } if($list['total'] < $start){ $start = $end = $list['total']; } $list['start'] = $start; $list['end'] = $end; return $list; } public function goodsDetail($goods_isli){ $goods = Goods::alias('goods')->join('goods_detail detail', 'goods.goods_detail_id = detail.id') ->where('goods.is_deleted', 0) ->where('goods.goods_islicode', $goods_isli) ->field('detail.goods_image,detail.goods_name,goods.goods_islicode,detail.goods_type,detail.goods_entrust,detail.goods_ownership_str, detail.contractual_period,detail.charges_type,detail.earnest_money,detail.price,goods.contractual_start_time, goods.contractualtime_end_time,goods.user_islicode,goods.islicode,detail.id as goods_detail_id') ->find(); if(!$goods){ throw new \think\Exception('未查询到该标的', 400); } $result = []; $user_isli = $goods->user_islicode; $result['userinfo'] = (new UserService())->getApiUser($user_isli); if(!empty($goods_image)){ $goods->goods_image = $this->getGoodsImageStatus($goods->goods_image, $goods->goods_detail_id); } $result['entrust_goods'] = $goods; $source_gather = GoodsSource::where('goods_isli_code', $goods->goods_islicode)->where('is_deleted', 0)->select()->toArray(); $gather_arr = []; $oneSource = []; foreach($source_gather as $val){ $source_data = json_decode($val['source_data'], true); if($val['datatype'] && !isset($gather_arr[ explode(' ', $val['sourceIdentify'])[1] ])){ $info = [ "name" => $val['source_name'], "class" => $val['source_type'], "registerDate" => $source_data['registerDate'], "identifier" => $source_data['identifier'], "count" => GoodsSource::where('goods_isli_code', $goods->goods_islicode)->where('datatype', 1)->where('is_deleted', 0)->whereLike('sourceIdentify', "%{$val['sourceIdentify']}%")->count(), ]; $gather_arr[explode(' ', $val['sourceIdentify'])[1]] = $info; }elseif(!$val['datatype']){ $filesize = getSourceFileSize($source_data['metadataFileSize']); $info = [ "name" => $val['source_name'], "class" => $val['source_type'], "registerDate" => $source_data['registerDate'], "identifier" => $source_data['identifier'], "filesize" => $filesize, "metadataFileFormat" => $source_data['metadataFileFormat'] ]; $oneSource[] = $info; } } $result['gather_arr'] = array_values($gather_arr); $result['oneSource'] = $oneSource; return $result; } public function sourceDetail($identifier, $batchcode = '', $islicode = ''){ if(empty($batchcode)){ $goods_source = GoodsSource::whereLike('sourceIdentify', "%{$identifier}%")->where('goods_isli_code', $islicode)->where('datatype', 1)->select()->toArray(); if(!$goods_source){ throw new \think\Exception('未查询到该标的资源', 400); } }else{ $goods_source = OrderGoodsSource::whereLike('sourceIdentify', "%{$identifier}%")->where('batchcode', $batchcode)->where('datatype', 1)->select()->toArray(); if(!$goods_source){ throw new \think\Exception('未查询到该标的资源', 400); } } $result = []; $gather_arr = []; $ind = 0; $repetition = []; foreach($goods_source as $val){ $source_data = json_decode($val['source_data'], true); $target_data = json_decode($val['target_data'], true); if($ind < 1){ $info = [ "source_name" => $val['source_name'], "otherIdentifiers" => !empty($source_data['otherIdentifiers']) ? $source_data['otherIdentifiers'] : "-", "identifier" => $source_data['identifier'], "collectionType" => $source_data['collectionType'], "serviceType" => $source_data['serviceType'], "classification" => $source_data['classification'], "contributors" => $source_data['contributors'], "copyrightOwner" => $source_data['copyrightOwner'], "carrier" => $source_data['carrier'], "registrant" => $source_data['registrant'], "registerDate" => $source_data['registerDate'], "repositoryName" => $source_data['repositoryName'], "dimensions" => !empty($source_data['dimensions']) ? $source_data['dimensions'] : "-", "quantity" => $source_data['quantity'], "label" => $source_data['label'], "description" => $source_data['description'], "md5Val" => $source_data['md5Val'], "databaseId" => $source_data['databaseId'], "edition" => $source_data['edition'], "collectionCondition" => $source_data['collectionCondition'], "cover" => $source_data['cover'], ]; $ind++; } if(!in_array($target_data['identifier'], $repetition)){ $filesize = getSourceFileSize($target_data['metadataFileSize']); $gather = [ "target_name" => $val['target_name'], "identifier" => $target_data['identifier'], "linkCode" => $val['linkcode'], "filesize" => $filesize, "metadataFileFormat" => $target_data['metadataFileFormat'], "registerDate" => $target_data['registerDate'], ]; if(!empty($batchcode) && !empty($islicode)){ $source_download = OrderGoodsDetail::where('batchcode', $batchcode)->where('goods_islicode', $islicode)->where('is_deleted', 0)->value('source_download'); $source_download = json_decode($source_download, true); foreach($source_download as $item){ if($item['islicode'] == $val['linkcode']){ $gather['download_status'] = $item['status']; break; } } } $gather_arr[ $target_data['serviceType'] ]['source'][] = $gather; $gather_arr[ $target_data['serviceType'] ]['serviceType'] = $target_data['serviceType']; $repetition[] = $target_data['identifier']; } } $result['info'] = $info; $result['gather_arr'] = array_values($gather_arr); return $result; } public function exhibition($type, $limit = 20){ $where = []; if($type == 1){ $where['goods.platform_products'] = 2; $order = "goods.platform desc"; }elseif($type == 2){ $where['goods.hot_products'] = 2; $order = "goods.hot desc"; }else{ $where['goods.hotsale_products'] = 2; $order = "goods.hotsale desc"; } $list = (new Goods())->list([], $where, $limit, ['goodsDetail', 'withJoin' => true]); $list->order($order); $list->hidden(['goodsDetail']); return $list->toArray(); } public function rankingList($type){ $where = []; $where['goods.is_deleted'] = 0; if($type == 1){ $limit = 10; $where['order'] = "goods.click_count desc"; }elseif($type == 2){ $limit = 10; $where['order'] = "goods.sale_count desc"; }else{ $limit = 8; $where['order'] = "goods.recommend_sort desc"; $where['goods.goods_status'] = 1; $where['goods.is_recommend'] = 1; } $search = $this->buildSearch(['order'], $where); $list = (new Goods())->list($search, $where, "select", ["goodsDetail", 'withJoin' => true], $limit); $index = 1; $list->each(function ($item) use(&$index){ // $item['username'] = User::where('user_isli', $item['user_islicode'])->value('username'); $item['key'] = $item['goods_islicode']; $item['id'] = $index; $index++; return $item; }); $list->visible(['id', 'createtime', 'goods_islicode', 'key', 'goods_name', 'goods_type', 'username', 'goods_status', 'recommend_sort']); $list->hidden(['goodsDetail']); $list = $list->toArray(); return $list; } public function addRanking(array $goods_isli = []){ $count = Goods::where('is_deleted', 0)->where('goods_status', 1)->where('is_recommend', 1)->count(); if($count >= 8){ throw new \think\Exception('推荐数量已8个,无法继续添加', 400); } foreach($goods_isli as $val){ if($count >= 8){ throw new \think\Exception('推荐数量已8个,无法继续添加', 400); } $goods = Goods::where('goods_islicode', $val)->where('goods_status', 1)->where('is_deleted', 0)->find(); if(!$goods){ continue; } if($goods->is_recommend == 1){ continue; } $goods->is_recommend = 1; $goods->save(); $count++; } } public function delRanking(array $goods_isli = []){ foreach($goods_isli as $val){ $goods = Goods::where('goods_islicode', $val)->where('is_deleted', 0)->find(); if(!$goods){ continue; } if($goods->is_recommend == 0){ continue; } $goods->is_recommend = 0; $goods->save(); } } public function rankingSort($goods_isli, $type){ $list = $this->rankingList(3); for($i = 0; $i <= count($list) -1; $i++){ if($list[$i]['goods_islicode'] == $goods_isli){ if($type == 1){// 上移 if($i == 0){ break; }else{ $front_sort = $list[$i-1]['recommend_sort']; $sort = $list[$i]['recommend_sort']; Goods::where('goods_islicode', $list[$i]['goods_islicode'])->update(['recommend_sort' => $front_sort]); Goods::where('goods_islicode', $list[$i-1]['goods_islicode'])->update(['recommend_sort' => $sort]); } }else{ if($i == count($list) - 1){ break; }else{ $behind_sort = $list[$i+1]['recommend_sort']; $sort = $list[$i]['recommend_sort']; Goods::where('goods_islicode', $list[$i]['goods_islicode'])->update(['recommend_sort' => $behind_sort]); Goods::where('goods_islicode', $list[$i+1]['goods_islicode'])->update(['recommend_sort' => $sort]); } } } } } public function manualGetGoods(){ $goodsService = new \app\service\task\GoodsService(); $count = $goodsService->getApiGoods(); return ['count' => $count]; } public function getGoodsImageStatus($image, $id){ // todo 被请求委托查询 接口 $image_headers = get_headers($image); if(!strpos($image_headers[0], "200")){ $path = env("app.real_url") . "/dist/api/v2/preview?url={$image}"; $sign = parent::createSign("distribute"); $headers = array( CURLOPT_HTTPHEADER => array( "dist_token:{$sign}", "Content-Type: application/json" ) ); $res = Http::get($path, [], $headers); if($res['code'] != 200){ throw new \think\Exception($res['msg'], 400); } $res = json_decode($res['data'], true); if($res['resultCode'] != "00000000"){ throw new \think\Exception($res['resultMsg'], 400); } GoodsDetail::where('id', $id)->update(['goods_image' => $res['data']]); return $res['data']; } return $image; } public function offGoods($goods_isli, $reason){ $goods = Goods::where('goods_islicode', $goods_isli)->find(); if(!$goods){ throw new \think\Exception("没有该条委托数据", 400); } if($goods->goods_status != 1 && $goods->goods_status != 5){ throw new \think\Exception("暂时只支持对已发布/暂停中文化数据进行撤销!", 400); } if($goods->apply_out == 1){ throw new \think\Exception("请勿重复提交撤销委托申请!", 400); } if($goods->goods_status == 5){ // throw new \think\Exception("该标的有未完成订单,请完成订单或终止订单后再申请!", 400); } $url = env("app.entrust_url") . "/consign/exchange/v1/exchangeRevokeEntrust"; $sign = parent::createSign("entrust"); $headers = array( CURLOPT_HTTPHEADER => array( "entrust_token:{$sign}" ) ); $post = [ "revokeReason" => $reason, "isliCode" => $goods->islicode, "status" => 3, ]; //todo 请求交易所撤销委托接口 接口1.4 $res = Http::get($url, $post, $headers); if($res['code'] != 200){ throw new \think\Exception($res['msg'], 400); } $res = json_decode($res['data'], true); if($res['resultCode'] != "00000000"){ throw new \think\Exception($res['resultMsg'], 400); } Goods::where('id', $goods->id)->update(['apply_out' => 1]); $operation_log = [ "type" => "goods", "log_id" => $goods->id, "message" => date('Y-m-d H:i:s') . " 由{$this->account_name}申请撤销委托,撤销原因:{$reason}" ]; (new OperationLog())->insert($operation_log); } public function whetherOff($goods_isli){ $goods = Goods::where('goods_islicode', $goods_isli)->find(); if(!$goods){ throw new \think\Exception("没有该条委托数据", 400); } if($goods->goods_status != 1 && $goods->goods_status != 5){ throw new \think\Exception("暂时只支持对已发布/暂停中文化数据进行撤销!", 400); } if($goods->apply_out == 1){ throw new \think\Exception("请勿重复提交撤销委托申请!", 400); } } public function test(){ $detail = OrderGoodsDetail::field('goods_islicode,data_json')->select()->toArray(); foreach($detail as $val){ $json = $val['data_json']; $json = json_decode($json, true); $islicode = $json['isliCode']; OrderGoodsDetail::where('goods_islicode', $val['goods_islicode'])->update(['islicode' => $islicode]); } } }