getConfigValue('sys_address'); $investData = Invest::where('id', 1)->select(['id', 'invest_money'])->first(); if (empty($investData)) { return $this->apiResponseError('sys.key_error'); } $investData->{'sysAddress'} = $sysAddress; return $this->apiResponseSuccess('', $investData); } /** * 执行报单 * @return \Illuminate\Http\JsonResponse */ function setInvest() { $mId = MemberServer::creatServer()->getMemberId(); $redis_on_name = 'setInvest' . $mId; $redis_time = RedisDataServer::creatServer()->getData($redis_on_name); $time = time(); if (!empty($redis_time) && $redis_time > $time - 2) { return $this->apiResponseError('sys.key_num'); } RedisDataServer::creatServer()->setData($redis_on_name, $time, 'str', 2, false); $investId = request()->input('id'); $txid = request()->input('txid'); if (empty($investId)) { return $this->apiResponseError('sys.key_error'); } if (empty($txid)) { return $this->apiResponseError('sys.key_error'); } $num = Contract::where('hash', $txid)->count(); if ($num > 0) { return $this->apiResponseError('contract.no_hash'); } $investData = Invest::where('id', $investId)->first(); $contractData = Contract::create([ 'm_id' => $mId, 'type' => $investId, 'status' => 1, 'hash' => $txid, 'broadcast_data' => '', 'is_out' => '0', 'error_msg' => '', 'money' => $investData->{'invest_money'}, 'platform_money' => $investData->{'platform_money'}, 'direct_proportion' => $investData->{'direct_proportion'}, 'indirect_proportion' => $investData->{'indirect_proportion'}, 'team_proportion' => $investData->{'team_proportion'}, 'common_proportion' => $investData->{'common_proportion'}, 'sediment_proportion' => $investData->{'sediment_proportion'}, 'agency_proportion' => $investData->{'agency_proportion'}, 'contract_sn' => IndentNumServer::creatServer()->getIndentNum(1), ]); if (empty($contractData)) { return $this->apiResponseError('contract.no'); } else { ContractServer::creatServer()->addContractLog($contractData, '合约创建成功'); return $this->apiResponseSuccess('contract.ok'); } } /** * 获取收益明细 * @return \Illuminate\Http\JsonResponse */ function getEarnings() { $mId = MemberServer::creatServer()->getMemberId(); $list = ContractDistribution::from('contract_distributions as cd') ->leftJoin('broadcasts as b', 'b.id', '=', 'cd.broadcast_id') ->where('to_m_id', $mId) ->whereIn('cd.status',[1,3]) ->select(['cd.id', 'db_money', 'nbn_money', 'cd.created_at', 'cd.type', 'cd.status', 'b.hash','cd.service_money'])->paginate(15); return $this->apiResponseSuccess('', ['total' => $list->total(), 'items' => $list->items()]); } /** * 获取我的合约列表 * @return \Illuminate\Http\JsonResponse */ function getContractList(){ $mId = MemberServer::creatServer()->getMemberId(); $list=Contract::where('m_id',$mId)->select(['id','status','hash','money','created_at','is_out'])->orderBy('id','desc')->paginate(15); foreach ($list as $item){ $item->{'statusName'}=__('contract.status'.$item->{'status'}); if($item->{'status'}!=4){ $item->{'out_num'}=Contract::where('status','=',2)->where('id','<=',$item->{'id'})->count(); }else{ $item->{'out_num'}=0; } } return $this->apiResponseSuccess('', ['total' => $list->total(), 'items' => $list->items()]); } }