| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934 |
- <?php
- declare (strict_types=1);
- namespace app\command;
- use app\common\model\merchant\order\OrderMerchant;
- use app\common\model\store\order\StoreOrder;
- use app\common\model\user\User;
- use app\common\model\user\UserCertification;
- use app\common\repositories\merchant\order\OrderGzcRepository;
- use app\common\repositories\merchant\order\OrderMerchantRepository;
- use app\common\repositories\store\order\StoreOrderStatusRepository;
- use app\common\repositories\store\product\ProductRepository;
- use app\common\repositories\user\UserBillRepository;
- use app\common\repositories\user\UserRepository;
- use app\traits\GzcApiRequest;
- use Carbon\Carbon;
- use think\console\Command;
- use think\console\Input;
- use think\console\Output;
- use think\Exception;
- use think\facade\Db;
- use think\facade\Log;
- use app\common\repositories\store\order\StoreOrderRepository;
- /**
- * Class PensionTasks
- * @package app\command
- * @author: php迷途小书童
- * @created: 2021/3/19 9:14
- */
- class PensionTasks extends Command
- {
- use GzcApiRequest;
- protected function configure()
- {
- // 指令配置
- $this->setName('pensiontask')
- ->setDescription('the pensiontask command');
- }
- protected function execute(Input $input, Output $output)
- {
- //1线下2在线3拼多多4京东5苏宁6淘宝7VIP
- $nowTime = time();
- try {
- //线下符合条件的养老金收集(线下交易后第8天)
- // $this->doOfflineOrderGzc($nowTime, $timeLimit = 1);
- // $this->doOnlineOrderGzc($timeLimit = 30);
- // $this->doOnlineHuuafeiOrderGzc($timeLimit = 30);
- $this->onlineOrderNew($timeLimit = 30);
- $this->huafeiOrderNew($timeLimit = 30);
- $this->pddOrderNew($timeLimit = 30);
- $this->jdOrderNew($timeLimit = 30);
- $this->suOrderNew($timeLimit = 30);
- $this->taobaoOrderNew($timeLimit = 30);
- $this->vipOrderNew($timeLimit = 30);
- // $this->dyOrderNew($timeLimit = 30);
- // $this->doThridPddOrderGzc($nowTime, $timeLimit = 30);
- // $this->doThridJdOrderGzc($nowTime, $timeLimit = 30);
- // $this->doThridSnOrderGzc($nowTime, $timeLimit = 30);
- // $this->doThridTaobaoOrderGzc($nowTime, $timeLimit = 30);
- // $this->doThridVipOrderGzc($nowTime, $timeLimit = 30);
- // $this->doThridDyOrderGzc($nowTime, $timeLimit = 30);
- // $this->doThridHfOrderGzc($nowTime, $timeLimit = 30);
- // $this->billGzcAdd($nowTime);
- //升级
- // $this -> doUpgrade();
- } catch (\Throwable $e) {
- Log::info('公证处入账:' . $e->getFile() . ':' . $e->getLine() . '【' . $e->getMessage() . '】');
- var_dump('公证处入账:' . $e->getFile() . ':' . $e->getLine() . '【' . $e->getMessage() . '】');
- }
- // 指令输出
- $output->writeln('pensiontask');
- }
- /**
- * 线下支付订单公证处IN10入账
- * @param $nowTime
- * author: php迷途小书童
- * created: 2021/3/20 9:26
- */
- public function billGzcAdd($nowTime)
- {
- $OrderGzcRepository = app()->make(OrderGzcRepository::class);
- $OrderMerchantRepository = app()->make(OrderMerchantRepository::class);
- $StoreOrderRepository = app()->make(StoreOrderRepository::class);
- $cursor = Db::name('user_bill')
- ->where('status', 1)
- ->where('is_gzc', 0)
- ->where('commission_type', 5)
- ->select()->toArray();
- if($cursor) {
- foreach ($cursor as $bill) {
- $type_shop = $bill['type_shop'] ?? 0;
- switch ($type_shop){
- case "0":
- $online = $cursor = Db::table('rrx_store_order')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->where('paid', 1)->find();
- break;
- case "1":
- $online = Db::table('rrx_order_pdd')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
- break;
- case "2":
- $online = Db::table('rrx_order_vip')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
- break;
- case "3":
- $online = Db::table('rrx_order_su')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
- break;
- case "4":
- $online = '';
- break;
- case "5":
- $online = Db::table('rrx_order_tb')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
- break;
- case "6":
- $online = Db::table('rrx_order_jd')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
- break;
- case "7":
- $online = '';
- break;
- case "8":
- $online = '';
- break;
- case "9":
- $online = Db::table('rrx_order_huafei')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->find();
- break;
- default:
- $online = Db::table('rrx_store_order')->where('uid', $bill['uid'])->where('order_sn', $bill['order_sn'])->where('paid', 1)->find();
- }
- if (!$online) {
- Log::info($bill['uid'] . '查询不到订单');
- continue;
- }
- $certification = UserCertification::getInstance()->where('uid', $bill['uid'])->find();
- if (!$certification) {
- Log::info($online['uid'] . '没有实名认证');
- continue;
- }
- $pension = $bill['number'] ?? 0;
- if ($pension <= 0) {
- Log::info($online['order_sn'] . 'pension' . $pension);
- continue;
- }
- //新增入账明细记录
- $orderId = $OrderMerchantRepository->getNewOrderId('IN10');
- $create = [
- 'uid' => $online['uid'],
- 'platform_no' => $orderId,
- 'account_type' => 1,
- 'user_name' => $certification['user_name'],
- 'mobile' => $certification['mobile'],
- 'user_card' => $certification['user_card'],
- 'pension' => $pension,
- 'order_type' => $type_shop,
- 'out_trade_no' => $online['order_sn'],
- 'link_id'=> $bill['bill_id']
- ];
- $test_user = Db::name('user')->where('uid', $online['uid'])->value('test_user');
- $check = Db::name("gzc_logs")->where("link_id", $bill['bill_id'])->where("order_type", $type_shop)->count();
- if ($test_user == 0 && $check <= 0) {
- $OrderGzcRepository->create($create);
- Db::name('user_bill')
- ->where('bill_id', $bill['bill_id'])
- ->where('commission_type', 5)
- ->update([
- 'is_gzc' => 1,
- 'gzc' => 1
- ]);
- }
- }
- }
- }
- /**
- * 线下支付订单公证处IN10入账
- * @param $nowTime
- * @param $timeLimit
- * author: php迷途小书童
- * created: 2021/3/20 9:26
- */
- public function doOfflineOrderGzc($nowTime, $timeLimit)
- {
- $cursor = Db::table('rrx_order_merchant')
- ->whereNotNull('pay_time')
- ->where('paid', 1)
- ->where('gzc', 0)
- ->whereTime('pay_time', '<', $nowTime - bcmul((string)$timeLimit, (string)86400))
- ->cursor();
- $OrderGzcRepository = app()->make(OrderGzcRepository::class);
- $OrderMerchantRepository = app()->make(OrderMerchantRepository::class);
- $StoreOrderRepository = app()->make(StoreOrderRepository::class);
- foreach ($cursor as $offline) {
- if ($offline['mer_id'] == 496) {
- continue;
- }
- $uid = 0;
- switch ($offline['trade_type']) {
- case 'WX':
- $uid = User::getInstance()->where('wechat_user_id', $offline['pay_user_id'])->value('uid');
- $accountType = 3;
- break;
- case 'ALI':
- $uid = User::getInstance()->where('ali_user_id', $offline['pay_user_id'])->value('uid');
- $accountType = 2;
- break;
- default:
- break;
- }
- if (!$uid) {
- Log::info($offline['pay_user_id'] . '未绑定用户');
- continue;
- }
- // $certification = UserCertification::getInstance()->where('uid', $uid)->find();
- // if (!$certification) {
- // Log::info($offline['pay_user_id'] . '未实名认证');
- // continue;
- // }
- //查询养老金金额
- $UserBillRepository = app()->make(UserBillRepository::class);
- $bill = $UserBillRepository->getWhere(['uid' => $uid, 'link_id' => $offline['id'], 'order_sn' => $offline['out_trade_no'], 'title' => '养老金']);
- $pension = $bill->number ?? 0;
- // if ($pension <= 0) {
- // Log::info($offline['out_trade_no'] . 'pension' . $pension);
- // continue;
- // }
- // Db::transaction(function () use ($uid, $certification, $accountType, $offline, $OrderGzcRepository, $OrderMerchantRepository, $pension, $StoreOrderRepository) {
- Db::transaction(function () use ($uid, $accountType, $offline, $OrderGzcRepository, $OrderMerchantRepository, $pension, $StoreOrderRepository) {
- $order = OrderMerchant::getInstance()->find($offline['id']);
- $order->gzc = 1;
- $order->is_settlement = 1;
- $order->settlement_time = date('Y-m-d H:i:s');
- $order->save();
- //新增入账明细记录
- // $orderId = $OrderMerchantRepository->getNewOrderId('IN10');
- // $create = [
- // 'uid' => $uid,
- // 'platform_no' => $orderId,
- // 'account_type' => $accountType,
- // 'user_name' => $certification['user_name'],
- // 'mobile' => $certification['mobile'],
- // 'user_card' => $certification['user_card'],
- // 'pension' => $pension,
- // 'order_type' => 1,
- // 'out_trade_no' => $offline['out_trade_no']
- // ];
- // $test_user = Db::name('user')->where('uid', $uid)->value('test_user');
- // if ($test_user == 0) {
- // $OrderGzcRepository->create($create);
- // }
- // // 养老金区域奖励
- // $order_data = [
- // 'pay_price' => $pension,
- // 'user_address_ids' => $offline['user_address_ids'],
- // 'uid' => $offline['uid'],
- // 'order_sn' => $offline['out_trade_no']
- // ];
- // $StoreOrderRepository->area_manage_details($order_data, 0, 2);
- // 结算红包
- // $user_sign_hongbao_list = Db::name('user_sign_hongbao')
- // ->where('status', -1)
- // ->where('order_id', $offline['id'])
- // ->whereIn('type', [1, 2])
- // ->select()
- // ->toArray();
- // foreach ($user_sign_hongbao_list as $user_sign_hongbao) {
- // if($user_sign_hongbao['uid']){
- // // 修改红包
- // Db::name('user')
- // ->where('uid', $user_sign_hongbao['uid'])
- // ->inc('hongbao', (float)$user_sign_hongbao['number'])
- // ->update();
- // Db::name('user_sign_hongbao')
- // ->where('status', -1)
- // ->where('id', $user_sign_hongbao['id'])
- // ->update([
- // 'status' => 1,
- // 'settlement_time' => date('Y-m-d H:i:s')
- // ]);
- // }
- // }
- // // 结算积分
- // $user_sign_score_list = Db::name('user_sign_score')
- // ->where('status', -1)
- // ->where('order_id', $offline['id'])
- // ->whereIn('type', [1, 2])
- // ->select()
- // ->toArray();
- // foreach ($user_sign_score_list as $user_sign_score) {
- // if($user_sign_score['uid']){
- // // 修改积分
- // Db::name('user')
- // ->where('uid', $user_sign_score['uid'])
- // ->inc('score', (float)$user_sign_score['reward_socre'])
- // ->update();
- // Db::name('user_sign_score')
- // ->where('status', -1)
- // ->where('id', $user_sign_score['id'])
- // ->update([
- // 'status' => 1,
- // 'settlement_time' => date('Y-m-d H:i:s')
- // ]);
- // }
- // }
- // // 结算贡献值
- // $user_sign_gongxian_list = Db::name('user_sign_gongxian')
- // ->where('status', -1)
- // ->where('order_id', $offline['id'])
- // ->whereIn('type', [1, 2])
- // ->select()
- // ->toArray();
- // foreach ($user_sign_gongxian_list as $user_sign_gongxian) {
- // if($user_sign_gongxian['uid']){
- // // 修改贡献值
- // Db::name('user')
- // ->where('uid', $user_sign_gongxian['uid'])
- // ->inc('contribute', (float)$user_sign_gongxian['number'])
- // ->update();
- // Db::name('user_sign_gongxian')
- // ->where('status', -1)
- // ->where('id', $user_sign_gongxian['id'])
- // ->update([
- // 'status' => 1,
- // 'settlement_time' => date('Y-m-d H:i:s')
- // ]);
- // }
- // }
- // // 结算佣金
- // $user_bill_list = Db::name('user_bill')
- // ->where('status', 0)
- // ->where('commission_type','<>', 5)
- // ->where([ 'link_id' => $offline['id'], 'order_sn' => $offline['order_sn']])
- // ->select()
- // ->toArray();
- // foreach ($user_bill_list as $user_bill) {
- // if($user_bill['uid']){
- // if ($user_bill['commission_type'] != 5) {
- // if (in_array($user_bill['commission_type'], [7,12,19])) {
- // Db::name("merchant")
- // ->where("mer_id", $user_bill['mer_id'])
- // ->inc('brokerage_price', (float)$user_bill['number'])
- // ->update();
- // } else {
- // Db::name('user')
- // ->where('uid', $user_bill['uid'])
- // ->inc('brokerage_price', (float)$user_bill['number'])
- // ->update();
- // }
- // }
- // }
- // }
- });
- }
- }
- /**
- * 话费支付订单公证处IN10入账
- * @param $nowTime
- * @param $timeLimit
- * author: php迷途小书童
- * created: 2021/3/20 9:26
- */
- public function doOnlineHuuafeiOrderGzc($timeLimit)
- {
- // 普通订单
- $cursor = Db::table('rrx_order_huafei')->where('status', 3)->where('gzc', 0)->cursor();
- $StoreOrderStatusRepository = app()->make(StoreOrderStatusRepository::class);
- $OrderMerchantRepository = app()->make(OrderMerchantRepository::class);
- $OrderGzcRepository = app()->make(OrderGzcRepository::class);
- foreach ($cursor as $online) {
-
- if (time() < strtotime($online['finish_time']) + 3600 * 24) {
- Log::info('还没有话费到账后' . $timeLimit . '天');
- continue;
- }
-
- $certification = UserCertification::getInstance()->where('uid', $online['uid'])->find();
- if (!$certification) {
- Log::info($online['uid'] . '没有实名认证');
- continue;
- }
- //查询养老金金额
- $UserBillRepository = app()->make(UserBillRepository::class);
- $bill = $UserBillRepository->getWhere(['uid' => $online['uid'], 'order_sn' => $online['order_sn'], 'commission_type' => 5]);
- $pension = $bill->number ?? 0;
- if ($pension <= 0) {
- Log::info($online['order_sn'] . 'pension' . $pension);
- continue;
- }
-
- //首信易分账
- // $StoreOrderRepository = app()->make(StoreOrderRepository::class);
- // if ($online['pay_type'] > 0) {
- // $StoreOrderRepository->splitOrder($online);
- // }
- $StoreOrderRepository = [];
- Db::transaction(function () use ($certification, $online, $pension, $OrderGzcRepository, $OrderMerchantRepository, $StoreOrderRepository) {
- //新增入账明细记录
- $orderId = $OrderMerchantRepository->getNewOrderId('IN10');
- $create = [
- 'uid' => $online['uid'],
- 'platform_no' => $orderId,
- 'account_type' => 3,//账号类型1银行卡2支付宝3微信
- 'user_name' => $certification['user_name'],
- 'mobile' => $certification['mobile'],
- 'user_card' => $certification['user_card'],
- 'pension' => $pension,
- 'order_type' => 2,
- 'out_trade_no' => $online['order_sn']
- ];
- $test_user = Db::name('user')->where('uid', $online['uid'])->value('test_user');
- $check = Db::name("gzc_logs")->where("out_trade_no", $online['order_sn'])->where("order_type", 2)->count();
- if ($test_user == 0 && $check <= 0) {
- $OrderGzcRepository->create($create);
- }
- $order = StoreOrder::getInstance()->find($online['order_id']);
- $order->gzc = 1;
- $order->save();
- });
- }
- // 普通订单(红包,积分,京东,佣金,复购金,养老金,贡献值)
- $cursor = Db::table('rrx_order_huafei')->where('status', 3)->where('bill_status', 0)->cursor();
- $StoreOrderStatusRepository = app()->make(StoreOrderStatusRepository::class);
- $OrderMerchantRepository = app()->make(OrderMerchantRepository::class);
- $OrderGzcRepository = app()->make(OrderGzcRepository::class);
- foreach ($cursor as $online) {
- if (time() < strtotime($online['finish_time']) + 3600 * 24) {
- Log::info('还没有话费到账后' . $timeLimit . '天');
- continue;
- }
-
- Db::transaction(function () use ($online) {
- //订单状态改为已结算
- Db::name('rrx_order_huafei')
- ->where('status', 3)->where('bill_status', 0)
- ->where('order_sn', $online['order_sn'])
- ->update([
- 'bill_status'=> 1,
- 'bill_create_time' => time()
- ]);
- // 结算积分
- $user_sign_score_list = Db::name('user_sign_score')
- ->where('status', -1)
- ->where('order_id', $online['order_sn'])
- ->whereIn('type', [1, 2])
- ->select()
- ->toArray();
- foreach ($user_sign_score_list as $user_sign_score) {
- // 修改积分
- Db::name('user')
- ->where('uid', $user_sign_score['uid'])
- ->inc('score', (float)$user_sign_score['reward_socre'])
- ->update();
- Db::name('user_sign_score')
- ->where('status', -1)
- ->where('id', $user_sign_score['id'])
- ->update([
- 'status' => 1,
- 'settlement_time' => date('Y-m-d H:i:s')
- ]);
- }
- // 结算复购金
- $user_sign_fugou_list = Db::name('user_sign_fugou')
- ->where('status', -1)
- ->where('order_id', $online['order_sn'])
- ->whereIn('type', [1, 2])
- ->select()
- ->toArray();
- foreach ($user_sign_fugou_list as $user_sign_fugou) {
- // 修改复购金
- Db::name('user')
- ->where('uid', $user_sign_fugou['uid'])
- ->inc('fugou', (float)$user_sign_fugou['number'])
- ->update();
- Db::name('user_sign_fugou')
- ->where('status', -1)
- ->where('id', $user_sign_fugou['id'])
- ->update([
- 'status' => 1,
- 'settlement_time' => date('Y-m-d H:i:s')
- ]);
- }
- // 结算贡献值
- $user_sign_gongxian_list = Db::name('user_sign_gongxian')
- ->where('status', -1)
- ->where('order_id', $online['order_sn'])
- ->whereIn('type', [1, 2])
- ->select()
- ->toArray();
- foreach ($user_sign_gongxian_list as $user_sign_gongxian) {
- // 修改贡献值
- Db::name('user')
- ->where('uid', $user_sign_gongxian['uid'])
- ->inc('contribute', (float)$user_sign_gongxian['number'])
- ->update();
- Db::name('user_sign_gongxian')
- ->where('status', -1)
- ->where('id', $user_sign_gongxian['id'])
- ->update([
- 'status' => 1,
- 'settlement_time' => date('Y-m-d H:i:s')
- ]);
- /** @var UserRepository $userRepository */
- $userRepository = app()->make(UserRepository::class);
- $userRepository->setUserIdentity($user_sign_gongxian['uid']);
- }
- });
- }
- }
-
- /**
- * 在线支付公证处IN10入账 (红包,积分,京东,佣金,复购金,养老金,贡献值)
- * @param $nowTime
- * @param $timeLimit
- * author: php迷途小书童
- * created: 2021/3/20 9:25
- */
- public function doOnlineOrderGzc($timeLimit)
- {
- return true;
- // 普通订单
- $cursor = Db::table('rrx_store_order')->where('paid', 1)->where('gzc', 0)->where('pay_type', 'in', '0,1,2,4')->cursor();
- $StoreOrderStatusRepository = app()->make(StoreOrderStatusRepository::class);
- $OrderMerchantRepository = app()->make(OrderMerchantRepository::class);
- $OrderGzcRepository = app()->make(OrderGzcRepository::class);
- foreach ($cursor as $online) {
- $status = $StoreOrderStatusRepository->getWhere(['order_id' => $online['order_id'], 'change_type' => 'take']);
- if ($online['mer_id'] == 496) {
- if (!in_array($online['status'], [0, 1, 2, 3])) {
- continue;
- }
- // if (time() < strtotime($online['pay_time']) + 3600 * 24) {
- // Log::info('还没有到收货后' . $timeLimit . '天');
- // continue;
- // }
- } else {
- if (!in_array($online['status'], [2, 3])) {
- continue;
- }
- if (Carbon::now()->modify("-{$timeLimit} days")->lt($status->change_time ?? $status['change_time'])) {
- Log::info('还没有到收货后' . $timeLimit . '天');
- continue;
- }
- }
- // $certification = UserCertification::getInstance()->where('uid', $online['uid'])->find();
- // if (!$certification) {
- // Log::info($online['uid'] . '没有实名认证');
- // continue;
- // }
- //查询养老金金额
- $UserBillRepository = app()->make(UserBillRepository::class);
- $bill = $UserBillRepository->getWhere(['uid' => $online['uid'], 'link_id' => $online['order_id'], 'order_sn' => $online['order_sn'], 'commission_type' => 5]);
- $pension = $bill->number ?? 0;
- // if ($pension <= 0) {
- // Log::info($online['order_sn'] . 'pension' . $pension);
- // continue;
- // }
- //首信易分账
- // $StoreOrderRepository = app()->make(StoreOrderRepository::class);
- // if ($online['pay_type'] > 0) {
- // $StoreOrderRepository->splitOrder($online);
- // }
- Db::transaction(function () use ($online, $pension, $OrderGzcRepository, $OrderMerchantRepository, $StoreOrderRepository) {
- //新增入账明细记录
- // $orderId = $OrderMerchantRepository->getNewOrderId('IN10');
- // $create = [
- // 'uid' => $online['uid'],
- // 'platform_no' => $orderId,
- // 'account_type' => $online['pay_type'] == 1 ? 3 : 2,
- // 'user_name' => $certification['user_name'],
- // 'mobile' => $certification['mobile'],
- // 'user_card' => $certification['user_card'],
- // 'pension' => $pension,
- // 'order_type' => 2,
- // 'out_trade_no' => $online['order_sn']
- // ];
- // $test_user = Db::name('user')->where('uid', $online['uid'])->value('test_user');
- // $check = Db::name("gzc_logs")->where("out_trade_no", $online['order_sn'])->where("order_type", 2)->count();
- // if ($test_user == 0 && $check <= 0) {
- // $OrderGzcRepository->create($create);
- // }
- $order = StoreOrder::getInstance()->find($online['order_id']);
- $order->gzc = 1;
- $order->save();
- Db::name('user_bill')
- ->where('order_sn', $online['order_sn'])
- ->where('commission_type', 5)
- ->update(['status'=> 1]);
- // 养老金区域奖励
- // $order_data = [
- // 'pay_price' => $pension,
- // 'user_address_ids' => $online['user_address_ids'],
- // 'uid' => $online['uid'],
- // 'order_sn' => $online['order_sn']
- // ];
- // $StoreOrderRepository->area_manage_details($order_data, 8, 2);
- });
- }
- // 普通订单(红包,积分,京东,佣金,复购金,贡献值)
- $cursor = Db::table('rrx_store_order')->where('paid', 1)->where('is_settlement', 0)->where('pay_type', 'in', '0,1,2,4')->cursor();
- $StoreOrderStatusRepository = app()->make(StoreOrderStatusRepository::class);
- $OrderMerchantRepository = app()->make(OrderMerchantRepository::class);
- $OrderGzcRepository = app()->make(OrderGzcRepository::class);
- foreach ($cursor as $online) {
- $status = $StoreOrderStatusRepository->getWhere(['order_id' => $online['order_id'], 'change_type' => 'take']);
- if ($online['mer_id'] == 496) {
- if (!in_array($online['status'], [0, 1, 2, 3])) {
- continue;
- }
- if (time() < strtotime($online['pay_time']) + 3600 * 24) {
- Log::info('还没有到收货后' . $timeLimit . '天');
- continue;
- }
- } else {
- if (!in_array($online['status'], [2, 3])) {
- continue;
- }
- if (Carbon::now()->modify("-{$timeLimit} days")->lt($status->change_time ?? $status['change_time'])) {
- Log::info('还没有到收货后' . $timeLimit . '天');
- continue;
- }
- }
- $StoreOrderRepository = app()->make(StoreOrderRepository::class);
- Db::transaction(function () use ($online, $StoreOrderRepository) {
- $order = StoreOrder::getInstance()->find($online['order_id']);
- $order->is_settlement = 1;
- $order->settlement_time = date('Y-m-d H:i:s');
- $order->save();
- // 结算积分
- $user_sign_score_list = Db::name('user_sign_score')
- ->where('status', -1)
- ->where('order_id', $online['order_id'])
- ->whereIn('type', [1, 2])
- ->select()
- ->toArray();
- foreach ($user_sign_score_list as $user_sign_score) {
- // 修改积分
- Db::name('user')
- ->where('uid', $user_sign_score['uid'])
- ->inc('score', (float)$user_sign_score['reward_socre'])
- ->update();
- Db::name('user_sign_score')
- ->where('status', -1)
- ->where('id', $user_sign_score['id'])
- ->update([
- 'status' => 1,
- 'settlement_time' => date('Y-m-d H:i:s')
- ]);
- }
- // 结算红包
- $user_sign_hongbao_list = Db::name('user_sign_hongbao')
- ->where('status', -1)
- ->where('order_id', $online['order_id'])
- ->whereIn('type', [1, 2])
- ->select()
- ->toArray();
- foreach ($user_sign_hongbao_list as $user_sign_hongbao) {
- // 修改红包
- Db::name('user')
- ->where('uid', $user_sign_hongbao['uid'])
- ->inc('hongbao', (float)$user_sign_hongbao['number'])
- ->update();
- Db::name('user_sign_hongbao')
- ->where('status', -1)
- ->where('id', $user_sign_hongbao['id'])
- ->update([
- 'status' => 1,
- 'settlement_time' => date('Y-m-d H:i:s')
- ]);
- }
- // 结算京豆
- $user_sign_jingdou_list = Db::name('user_sign_jingdou')
- ->where('status', -1)
- ->where('order_id', $online['order_id'])
- ->whereIn('type', [1, 2])
- ->select()
- ->toArray();
- foreach ($user_sign_jingdou_list as $user_sign_jingdou) {
- // 修改京豆
- Db::name('user')
- ->where('uid', $user_sign_jingdou['uid'])
- ->inc('jingdou', (float)$user_sign_jingdou['number'])
- ->update();
- Db::name('user_sign_jingdou')
- ->where('status', -1)
- ->where('id', $user_sign_jingdou['id'])
- ->update([
- 'status' => 1,
- 'settlement_time' => date('Y-m-d H:i:s')
- ]);
- }
- // 结算复购金
- $user_sign_fugou_list = Db::name('user_sign_fugou')
- ->where('status', -1)
- ->where('order_id', $online['order_id'])
- ->whereIn('type', [1, 2])
- ->select()
- ->toArray();
- foreach ($user_sign_fugou_list as $user_sign_fugou) {
- // 修改复购金
- Db::name('user')
- ->where('uid', $user_sign_fugou['uid'])
- ->inc('fugou', (float)$user_sign_fugou['number'])
- ->update();
- Db::name('user_sign_fugou')
- ->where('status', -1)
- ->where('id', $user_sign_fugou['id'])
- ->update([
- 'status' => 1,
- 'settlement_time' => date('Y-m-d H:i:s')
- ]);
- }
- // 结算贡献值
- $user_sign_gongxian_list = Db::name('user_sign_gongxian')
- ->where('status', -1)
- ->where('order_id', $online['order_id'])
- ->whereIn('type', [1, 2])
- ->select()
- ->toArray();
- foreach ($user_sign_gongxian_list as $user_sign_gongxian) {
- // 修改贡献值
- Db::name('user')
- ->where('uid', $user_sign_gongxian['uid'])
- ->inc('contribute', (float)$user_sign_gongxian['number'])
- ->update();
- Db::name('user_sign_gongxian')
- ->where('status', -1)
- ->where('id', $user_sign_gongxian['id'])
- ->update([
- 'status' => 1,
- 'settlement_time' => date('Y-m-d H:i:s')
- ]);
- /** @var UserRepository $userRepository */
- $userRepository = app()->make(UserRepository::class);
- $userRepository->setUserIdentity($user_sign_gongxian['uid']);
- }
- // 结算PV值
- $user_pv_list = Db::name('user_pv_log')
- ->where('status', -1)
- ->where('order_id', $online['order_id'])
- ->whereIn('type', [1, 2])
- ->select()
- ->toArray();
- if($user_pv_list) {
- foreach ($user_pv_list as $user_pv) {
- // 修改pv
- Db::name('user')
- ->where('uid', $user_pv['uid'])
- ->inc('pv', (float)$user_pv['pv'])
- ->update();
- Db::name('user_pv_log')
- ->where('status', -1)
- ->where('id', $user_pv['id'])
- ->update([
- 'status' => 1,
- 'settlement_time' => date('Y-m-d H:i:s')
- ]);
- }
- }
- // 结算佣金
- $user_bill_list = Db::name('user_bill')
- ->where('status', 0)
- ->where('commission_type','<>', 5)
- ->where([ 'link_id' => $online['order_id'], 'order_sn' => $online['order_sn']])
- ->select()
- ->toArray();
- foreach ($user_bill_list as $user_bill) {
- if ($user_bill['commission_type'] != 5) {
- if (in_array($user_bill['commission_type'], [7,12,19])) {
- Db::name("merchant")
- ->where("mer_id", $user_bill['mer_id'])
- ->inc('brokerage_price', (float)$user_bill['number'])
- ->update();
- } else {
- Db::name('user')
- ->where('uid', $user_bill['uid'])
- ->inc('brokerage_price', (float)$user_bill['number'])
- ->update();
- }
- }
- if ($online['pay_type'] == 0 && $user_bill['commission_type'] == 5) {
- } else {
- // 虚拟支付的养老金不修改不结算
- Db::name('user_bill')
- ->where('status', 0)
- ->where('bill_id', $user_bill['bill_id'])
- ->update([
- 'status' => 1,
- 'take_time' => time()
- ]);
- }
- if ($online['pay_type'] == 0 && $user_bill['commission_type'] == 5) {
- } else {
- // 虚拟支付的养老金不修改不结算
- Db::name('user_bill')
- ->where('status', 0)
- ->where('bill_id', $user_bill['bill_id'])
- ->update([
- 'status' => 1,
- 'take_time' => time()
- ]);
- }
- }
- //按角色结算
- $StoreOrderRepository->close_order($online['order_id']);
- });
- }
- }
- /**
- * 第三方订单拼多多IN10入账
- * @param $nowTime
- * @param $timeLimit
- * author: php迷途小书童
- * created: 2021/3/20 9:26
- */
- public function doThridPddOrderGzc($nowTime, $timeLimit)
- {
- $cursor = Db::table('rrx_order_pdd')
- ->where('gzc', 0)
- ->where('bill_status', 1)
- ->where('commission', '>', 0)
- ->whereTime('bill_end_time', '<', $nowTime - bcmul((string)$timeLimit, (string)86400))
- ->cursor();
- $ProductRepository = app()->make(ProductRepository::class);
- $OrderGzcRepository = app()->make(OrderGzcRepository::class);
- $OrderMerchantRepository = app()->make(OrderMerchantRepository::class);
- $StoreOrderRepository = app()->make(StoreOrderRepository::class);
- foreach ($cursor as $thrid) {
- $uid = $thrid['uid'];
- if (!$uid)
- continue;
- // $certification = UserCertification::getInstance()->where('uid', $uid)->find();
- // if (!$certification) {
- // Log::info('用户ID' . $uid . '未实名认证');
- // continue;
- // }
- $pension = $ProductRepository->yanglaojin(0, sprintf('%.2f', $thrid['commission']));
- Db::transaction(function () use ($uid, $thrid, $pension, $OrderGzcRepository, $OrderMerchantRepository, $StoreOrderRepository) {
- //新增入账明细记录
- // $orderId = $OrderMerchantRepository->getNewOrderId('IN10');
- // $create = [
- // 'uid' => $uid,
- // 'platform_no' => $orderId,
- // 'user_name' => $certification['user_name'],
- // 'mobile' => $certification['mobile'],
- // 'user_card' => $certification['user_card'],
- // 'pension' => $pension,
- // 'order_type' => 3,
- // 'out_trade_no' => $thrid['order_sn']
- // ];
- // $test_user = Db::name('user')->where('uid', $uid)->value('test_user');
- // if ($test_user == 0) {
- // $OrderGzcRepository->create($create);
- // }
- // $OrderGzcRepository->create($create);
- Db::table('rrx_order_pdd')
- ->update(['gzc' => 1, 'order_pdd_id' => $thrid['order_pdd_id']]);
- Db::name('user_bill')
- ->where('order_sn', $thrid['order_sn'])
- ->where('commission_type', 5)
- ->update(['status'=> 1]);
- // 养老金区域奖励
- $order_data = [
- 'pay_price' => $pension,
- 'user_address_ids' => $thrid['user_address_ids'],
- 'uid' => $thrid['uid'],
- 'order_sn' => $thrid['order_sn']
- ];
- // $StoreOrderRepository->area_manage_details($order_data, 1, 2);
- });
- }
- }
- /**
- * 第三方订单京东IN10入账
- * @param $nowTime
- * @param $timeLimit
- * author: php迷途小书童
- * created: 2021/3/20 9:26
- */
- public function doThridJdOrderGzc($nowTime, $timeLimit)
- {
- $cursor = Db::table('rrx_order_jd')
- ->where('gzc', 0)
- ->where('bill_status', 1)
- ->where('commission', '>', 0)
- ->whereTime('bill_end_time', '<', $nowTime - bcmul((string)$timeLimit, (string)86400))
- ->cursor();
- // Db::name('log')->insert(['data'=>'abbbb入库语句'.$nowTime - bcmul((string)$timeLimit, (string)86400)]);
- // Db::name('log')->insert(['data'=>'abbbb'.json_encode($cursor)]);
- $ProductRepository = app()->make(ProductRepository::class);
- $OrderGzcRepository = app()->make(OrderGzcRepository::class);
- $OrderMerchantRepository = app()->make(OrderMerchantRepository::class);
- $StoreOrderRepository = app()->make(StoreOrderRepository::class);
- foreach ($cursor as $thrid) {
- $uid = $thrid['uid'];
- if (!$uid)
- continue;
- // $certification = UserCertification::getInstance()->where('uid', $uid)->find();
- // if (!$certification) {
- // Log::info('用户ID' . $uid . '未实名认证');
- // continue;
- // }
- $pension = $ProductRepository->yanglaojin(0, sprintf('%.2f', $thrid['commission']));
- Db::transaction(function () use ($uid, $thrid, $pension, $OrderGzcRepository, $OrderMerchantRepository, $StoreOrderRepository) {
- //新增入账明细记录
- // $orderId = $OrderMerchantRepository->getNewOrderId('IN10');
- // $create = [
- // 'uid' => $uid,
- // 'platform_no' => $orderId,
- // 'user_name' => $certification['user_name'],
- // 'mobile' => $certification['mobile'],
- // 'user_card' => $certification['user_card'],
- // 'pension' => $pension,
- // 'order_type' => 4,
- // 'out_trade_no' => $thrid['order_sn']
- // ];
- // $test_user = Db::name('user')->where('uid', $uid)->value('test_user');
- // if ($test_user == 0) {
- // $OrderGzcRepository->create($create);
- // }
- // $OrderGzcRepository->create($create);
- Db::table('rrx_order_jd')
- ->update(['gzc' => 1, 'order_jd_id' => $thrid['order_jd_id']]);
- Db::name('user_bill')
- ->where('order_sn', $thrid['order_sn'])
- ->where('commission_type', 5)
- ->update(['status'=> 1]);
- // 养老金区域奖励
- // $order_data = [
- // 'pay_price' => $pension,
- // 'user_address_ids' => $thrid['user_address_ids'],
- // 'uid' => $thrid['uid'],
- // 'order_sn' => $thrid['order_sn']
- // ];
- // $StoreOrderRepository->area_manage_details($order_data, 6, 2);
- });
- }
- }
- /**
- * 第三方订单苏宁IN10入账
- * @param $nowTime
- * @param $timeLimit
- * author: php迷途小书童
- * created: 2021/3/20 9:26
- */
- public function doThridSnOrderGzc($nowTime, $timeLimit)
- {
- $cursor = Db::table('rrx_order_su')
- ->where('gzc', 0)
- ->where('bill_status', 1)
- ->where('commission', '>', 0)
- ->whereTime('bill_end_time', '<', $nowTime - bcmul((string)$timeLimit, (string)86400))
- ->cursor();
- $ProductRepository = app()->make(ProductRepository::class);
- $OrderGzcRepository = app()->make(OrderGzcRepository::class);
- $OrderMerchantRepository = app()->make(OrderMerchantRepository::class);
- $StoreOrderRepository = app()->make(StoreOrderRepository::class);
- foreach ($cursor as $thrid) {
- $uid = $thrid['uid'];
- if (!$uid)
- continue;
- // $certification = UserCertification::getInstance()->where('uid', $uid)->find();
- // if (!$certification) {
- // Log::info('用户ID' . $uid . '未实名认证');
- // continue;
- // }
- $pension = $ProductRepository->yanglaojin(0, sprintf('%.2f', $thrid['commission']));
- Db::transaction(function () use ($uid, $thrid, $pension, $OrderGzcRepository, $OrderMerchantRepository, $StoreOrderRepository) {
- //新增入账明细记录
- // $orderId = $OrderMerchantRepository->getNewOrderId('IN10');
- // $create = [
- // 'uid' => $uid,
- // 'platform_no' => $orderId,
- // 'user_name' => $certification['user_name'],
- // 'mobile' => $certification['mobile'],
- // 'user_card' => $certification['user_card'],
- // 'pension' => $pension,
- // 'order_type' => 5,
- // 'out_trade_no' => $thrid['order_sn']
- // ];
- // $test_user = Db::name('user')->where('uid', $uid)->value('test_user');
- // if ($test_user == 0) {
- // $OrderGzcRepository->create($create);
- // }
- // $OrderGzcRepository->create($create);
- Db::table('rrx_order_su')
- ->update(['gzc' => 1, 'order_su_id' => $thrid['order_su_id']]);
- Db::name('user_bill')
- ->where('order_sn', $thrid['order_sn'])
- ->where('commission_type', 5)
- ->update(['status'=> 1]);
- // 养老金区域奖励
- $order_data = [
- 'pay_price' => $pension,
- 'user_address_ids' => $thrid['user_address_ids'],
- 'uid' => $thrid['uid'],
- 'order_sn' => $thrid['order_sn']
- ];
- // $StoreOrderRepository->area_manage_details($order_data, 3, 2);
- });
- }
- }
- /**
- * 第三方订单话费IN10入账
- * @param $nowTime
- * @param $timeLimit
- * author: php迷途小书童
- * created: 2021/3/20 9:26
- */
- public function doThridHfOrderGzc($nowTime, $timeLimit)
- {
- $cursor = Db::table('rrx_order_huafei')
- ->where('gzc', 0)
- ->where('bill_status', 1)
- ->where('commission', '>', 0)
- ->whereTime('bill_end_time', '<', $nowTime - bcmul((string)$timeLimit, (string)86400))
- ->cursor();
- $ProductRepository = app()->make(ProductRepository::class);
- $OrderGzcRepository = app()->make(OrderGzcRepository::class);
- $OrderMerchantRepository = app()->make(OrderMerchantRepository::class);
- foreach ($cursor as $thrid) {
- $uid = $thrid['uid'];
- if (!$uid)
- continue;
- // $certification = UserCertification::getInstance()->where('uid', $uid)->find();
- // if (!$certification) {
- // Log::info('用户ID' . $uid . '未实名认证');
- // continue;
- // }
- $pension = $ProductRepository->yanglaojin(0, sprintf('%.2f', $thrid['commission']));
- Db::transaction(function () use ($uid, $thrid, $pension, $OrderGzcRepository, $OrderMerchantRepository) {
- // //新增入账明细记录
- // $orderId = $OrderMerchantRepository->getNewOrderId('IN10');
- // $create = [
- // 'uid' => $uid,
- // 'platform_no' => $orderId,
- // 'user_name' => $certification['user_name'],
- // 'mobile' => $certification['mobile'],
- // 'user_card' => $certification['user_card'],
- // 'pension' => $pension,
- // 'order_type' => 6,
- // 'out_trade_no' => $thrid['order_sn']
- // ];
- // $test_user = Db::name('user')->where('uid', $uid)->value('test_user');
- // if ($test_user == 0) {
- // $OrderGzcRepository->create($create);
- // }
- Db::table('rrx_order_huafei')->update(['gzc' => 1, 'order_tb_id' => $thrid['order_tb_id']]);
- Db::name('user_bill')
- ->where('order_sn', $thrid['order_sn'])
- ->where('commission_type', 5)
- ->update(['status'=> 1]);
- });
- }
- }
- /**
- * 第三方订单淘宝IN10入账
- * @param $nowTime
- * @param $timeLimit
- * author: php迷途小书童
- * created: 2021/3/20 9:26
- */
- public function doThridTaobaoOrderGzc($nowTime, $timeLimit)
- {
- $cursor = Db::table('rrx_order_tb')
- ->where('gzc', 0)
- ->where('bill_status', 1)
- ->where('commission', '>', 0)
- ->whereTime('bill_end_time', '<', $nowTime - bcmul((string)$timeLimit, (string)86400))
- ->cursor();
- $ProductRepository = app()->make(ProductRepository::class);
- $OrderGzcRepository = app()->make(OrderGzcRepository::class);
- $OrderMerchantRepository = app()->make(OrderMerchantRepository::class);
- $StoreOrderRepository = app()->make(StoreOrderRepository::class);
- foreach ($cursor as $thrid) {
- $uid = $thrid['uid'];
- if (!$uid)
- continue;
- // $certification = UserCertification::getInstance()->where('uid', $uid)->find();
- // if (!$certification) {
- // Log::info('用户ID' . $uid . '未实名认证');
- // continue;
- // }
- $pension = $ProductRepository->yanglaojin(0, sprintf('%.2f', $thrid['commission']));
- Db::transaction(function () use ($uid, $thrid, $pension, $OrderGzcRepository, $OrderMerchantRepository, $StoreOrderRepository) {
- //新增入账明细记录
- // $orderId = $OrderMerchantRepository->getNewOrderId('IN10');
- // $create = [
- // 'uid' => $uid,
- // 'platform_no' => $orderId,
- // 'user_name' => $certification['user_name'],
- // 'mobile' => $certification['mobile'],
- // 'user_card' => $certification['user_card'],
- // 'pension' => $pension,
- // 'order_type' => 6,
- // 'out_trade_no' => $thrid['order_sn']
- // ];
- // $test_user = Db::name('user')->where('uid', $uid)->value('test_user');
- // if ($test_user == 0) {
- // $OrderGzcRepository->create($create);
- // }
- // $OrderGzcRepository->create($create);
- Db::table('rrx_order_tb')
- ->update(['gzc' => 1, 'order_tb_id' => $thrid['order_tb_id']]);
- Db::name('user_bill')
- ->where('order_sn', $thrid['order_sn'])
- ->where('commission_type', 5)
- ->update(['status'=> 1]);
- // 养老金区域奖励
- $order_data = [
- 'pay_price' => $pension,
- 'user_address_ids' => $thrid['user_address_ids'],
- 'uid' => $thrid['uid'],
- 'order_sn' => $thrid['order_sn']
- ];
- // $StoreOrderRepository->area_manage_details($order_data, 5, 2);
- });
- }
- }
- /**
- * 第三方订单唯品会IN10入账
- * @param $nowTime
- * @param $timeLimit
- * author: php迷途小书童
- * created: 2021/3/20 9:26
- */
- public function doThridVipOrderGzc($nowTime, $timeLimit)
- {
- $cursor = Db::table('rrx_order_vip')
- ->where('gzc', 0)
- ->where('bill_status', 1)
- ->where('commission', '>', 0)
- ->whereTime('bill_end_time', '<', $nowTime - bcmul((string)$timeLimit, (string)86400))
- ->cursor();
- $ProductRepository = app()->make(ProductRepository::class);
- $OrderGzcRepository = app()->make(OrderGzcRepository::class);
- $OrderMerchantRepository = app()->make(OrderMerchantRepository::class);
- $StoreOrderRepository = app()->make(StoreOrderRepository::class);
- foreach ($cursor as $thrid) {
- $uid = $thrid['uid'];
- if (!$uid)
- continue;
- // $certification = UserCertification::getInstance()->where('uid', $uid)->find();
- // if (!$certification) {
- // Log::info('用户ID' . $uid . '未实名认证');
- // continue;
- // }
- $pension = $ProductRepository->yanglaojin(0, sprintf('%.2f', $thrid['commission']));
- Db::transaction(function () use ($uid, $thrid, $pension, $OrderGzcRepository, $OrderMerchantRepository, $StoreOrderRepository) {
- //新增入账明细记录
- // $orderId = $OrderMerchantRepository->getNewOrderId('IN10');
- // $create = [
- // 'uid' => $uid,
- // 'platform_no' => $orderId,
- // 'user_name' => $certification['user_name'],
- // 'mobile' => $certification['mobile'],
- // 'user_card' => $certification['user_card'],
- // 'pension' => $pension,
- // 'order_type' => 7,
- // 'out_trade_no' => $thrid['order_sn']
- // ];
- // $test_user = Db::name('user')->where('uid', $uid)->value('test_user');
- // if ($test_user == 0) {
- // $OrderGzcRepository->create($create);
- // }
- // $OrderGzcRepository->create($create);
- Db::table('rrx_order_vip')
- ->update(['gzc' => 1, 'order_vip_id' => $thrid['order_vip_id']]);
- Db::name('user_bill')
- ->where('order_sn', $thrid['order_sn'])
- ->where('commission_type', 5)
- ->update(['status'=> 1]);
- // 养老金区域奖励
- $order_data = [
- 'pay_price' => $pension,
- 'user_address_ids' => $thrid['user_address_ids'],
- 'uid' => $thrid['uid'],
- 'order_sn' => $thrid['order_sn']
- ];
- // $StoreOrderRepository->area_manage_details($order_data, 2, 2);
- });
- }
- }
- /**
- * 第三方订单抖音IN10入账
- * @param $nowTime
- * @param $timeLimit
- * author: php迷途小书童
- * created: 2021/3/20 9:26
- */
- public function doThridDyOrderGzc($nowTime, $timeLimit)
- {
- $cursor = Db::table('rrx_order_dy')
- ->where('gzc', 0)
- ->where('bill_status', 1)
- ->where('commission', '>', 0)
- ->whereTime('bill_end_time', '<', $nowTime - bcmul((string)$timeLimit, (string)86400))
- ->cursor();
- $ProductRepository = app()->make(ProductRepository::class);
- $OrderGzcRepository = app()->make(OrderGzcRepository::class);
- $OrderMerchantRepository = app()->make(OrderMerchantRepository::class);
- $StoreOrderRepository = app()->make(StoreOrderRepository::class);
- foreach ($cursor as $thrid) {
- $uid = $thrid['uid'];
- if (!$uid)
- continue;
- // $certification = UserCertification::getInstance()->where('uid', $uid)->find();
- // if (!$certification) {
- // Log::info('用户ID' . $uid . '未实名认证');
- // continue;
- // }
- $pension = $ProductRepository->yanglaojin(0, sprintf('%.2f', $thrid['commission']));
- Db::transaction(function () use ($uid, $thrid, $pension, $OrderGzcRepository, $OrderMerchantRepository, $StoreOrderRepository) {
- // //新增入账明细记录
- // $orderId = $OrderMerchantRepository->getNewOrderId('IN10');
- // $create = [
- // 'uid' => $uid,
- // 'platform_no' => $orderId,
- // 'user_name' => $certification['user_name'],
- // 'mobile' => $certification['mobile'],
- // 'user_card' => $certification['user_card'],
- // 'pension' => $pension,
- // 'order_type' => 8,
- // 'out_trade_no' => $thrid['order_sn']
- // ];
- // $test_user = Db::name('user')->where('uid', $uid)->value('test_user');
- // if ($test_user == 0) {
- // $OrderGzcRepository->create($create);
- // }
- Db::table('rrx_order_dy')
- ->update(['gzc' => 1, 'order_dy_id' => $thrid['order_dy_id']]);
- Db::name('user_bill')
- ->where('order_sn', $thrid['order_sn'])
- ->where('commission_type', 5)
- ->update(['status'=> 1]);
- // 养老金区域奖励
- $order_data = [
- 'pay_price' => $pension,
- 'user_address_ids' => $thrid['user_address_ids'],
- 'uid' => $thrid['uid'],
- 'order_sn' => $thrid['order_sn']
- ];
- // $StoreOrderRepository->area_manage_details($order_data, 9, 2);
- });
- }
- }
- /**
- * 志愿者升级
- * */
- public function doUpgrade()
- {
- set_time_limit(0);
- try {
- //志愿者条件
- $volunteer_achievement = systemConfig("volunteer_achievement"); //volunteer_achievement:用户本人满足养老金要求可升级为志愿者
- //一星条件
- $a_volunteer_achievement = systemConfig("a_volunteer_achievement");//团队养老金要求
- $a_volunteer_number = systemConfig("a_volunteer_number"); //团队人数要求
- //二星条件
- $b_volunteer_achievement = systemConfig("b_volunteer_achievement");//团队养老金要求
- $b_volunteer_number = systemConfig("b_volunteer_number"); //团队人数要求
- //三星条件
- $c_volunteer_achievement = systemConfig("c_volunteer_achievement");//团队养老金要求
- $c_volunteer_number = systemConfig("c_volunteer_number"); //团队人数要求
- //董事条件
- $d_volunteer_achievement = systemConfig("d_volunteer_achievement");//团队养老金要求
- $d_volunteer_number = systemConfig("d_volunteer_number"); //团队人数要求
- //用户列表
- $userList = Db::name("User")
- ->field("uid")
- ->select();
- foreach ($userList as $key => $value) {
- $volunteer = $this->volunteer($value['uid']);
- //本人养老金小于志愿者要求
- if ($volunteer['self_yanglao'] < $volunteer_achievement) {
- $this->grade($value['uid'], 0, $volunteer);
- }
- //满足志愿者要求
- if ($volunteer['self_yanglao'] >= $volunteer_achievement) {
- //志愿者
- if ($volunteer['team'] < $a_volunteer_number || $volunteer['yanglao'] < $a_volunteer_achievement) {
- $this->grade($value['uid'], 1, $volunteer);
- }
- //一星
- if ($volunteer['team'] >= $a_volunteer_number && $volunteer['yanglao'] >= $a_volunteer_achievement//满足一星条件
- &&
- ($volunteer['team'] < $b_volunteer_number || $volunteer['yanglao'] < $b_volunteer_achievement)//未满足二星条件
- ) {
- $this->grade($value['uid'], 2, $volunteer);
- }
- //二星
- if ($volunteer['team'] >= $b_volunteer_number && $volunteer['yanglao'] >= $b_volunteer_achievement//满足二星条件
- &&
- ($volunteer['team'] < $c_volunteer_number || $volunteer['yanglao'] < $c_volunteer_achievement)//未满足三星条件
- ) {
- $this->grade($value['uid'], 3, $volunteer);
- }
- //三星
- if ($volunteer['team'] >= $c_volunteer_number && $volunteer['yanglao'] >= $c_volunteer_achievement//满足三星条件
- &&
- ($volunteer['team'] < $d_volunteer_number || $volunteer['yanglao'] < $d_volunteer_achievement)//未满足董事条件
- ) {
- $this->grade($value['uid'], 4, $volunteer);
- }
- //董事
- if ($volunteer['team'] >= $d_volunteer_number && $volunteer['yanglao'] >= $d_volunteer_achievement) {
- $this->grade($value['uid'], 5, $volunteer);
- }
- }
- //团队各等级数量统计
- $this->statistics($value['uid']);
- }
- } catch (Exception $e) {
- Log::info('志愿者升级:' . $e->getMessage());
- }
- }
- //志愿者信息
- public function volunteer($uid)
- {
- if (!$uid) {
- return false;
- }
- //本人养老金
- $data['self_yanglao'] = $this->getYanglao($uid);
- //团队人数
- $data['team'] = $this->volunteer_number($uid);
- //团队养老金
- $data['yanglao'] = $this->volunteer_achievement($uid);
- //直推人数
- $data['extension'] = Db::name("user_identity_log")->where(["uid" => $uid])->count();
- //直推商户数量
- $data['shop'] = Db::name("user_identity_log")->where(["uid" => $uid, 'identity' => 4])->whereNotIn("identity", "0")->count();
- return $data;
- }
- //团队人数
- public function volunteer_number($uid)
- {
- $number = 0;
- $number1 = Db::name("user_identity_log")->where(["uid" => $uid])->field("link_id")->select();
- $number += count($number1);
- foreach ($number1 as $key => $value) {
- $number += Db::name("user_identity_log")->where(["uid" => $value['link_id']])->field("link_id")->count();
- }
- return $number;
- }
- //团队养老金
- public function volunteer_achievement($uid)
- {
- $yanglao = 0;
- $number1 = Db::name("user_identity_log")->where(["uid" => $uid])->field("link_id")->select();
- foreach ($number1 as $key => $value) {
- $yanglao += $this->getYanglao($value['link_id']);
- $number2 = Db::name("user_identity_log")->where(["uid" => $value['link_id']])->field("link_id")->select();
- foreach ($number2 as $k => $v) {
- $yanglao += $this->getYanglao($v['link_id']);
- }
- unset($number2);
- }
- return $yanglao;
- }
- //用户养老金
- public function getYanglao($uid)
- {
- return Db::name("UserBill")
- ->where([
- 'uid' => $uid,
- 'commission_type' => 5,
- 'status' => 1,
- 'pm' => 1
- ])
- ->sum("number");
- }
- //升级
- public function grade($uid, $grade, $volunteer)
- {
- $exist = Db::name("Volunteer")->where(["uid" => $uid])->find();
- if ($exist) {
- Db::name("Volunteer")
- ->where(["uid" => $uid])
- ->update([
- "grade" => $grade,
- "team" => $volunteer['team'],
- "yanglao" => $volunteer['yanglao'],
- "extension" => $volunteer['extension'],
- "shop" => $volunteer['shop'],
- "time" => time()
- ]);
- return true;
- }
- Db::name("Volunteer")
- ->insert([
- "uid" => $uid,
- "grade" => $grade,
- "team" => $volunteer['team'],
- "yanglao" => $volunteer['yanglao'],
- "extension" => $volunteer['extension'],
- "shop" => $volunteer['shop'],
- "time" => time()
- ]
- );
- return true;
- }
- //下级各等级数量统计
- public function statistics($uid)
- {
- $data = [
- 'v' => 0,
- 'v1' => 0,
- 'v2' => 0,
- 'v3' => 0,
- 'v4' => 0
- ];
- $fns = function ($uid) use (&$fns, &$data) {
- $identity = Db::name("user_identity_log")
- ->alias("u")
- ->join("Volunteer v", "u.link_id = v.uid")
- ->where(["u.uid" => $uid])
- ->field("u.link_id,v.grade")
- ->select();
- if ($identity) {
- foreach ($identity as $key => $value) {
- if ($value['grade'] == 1) {
- $data['v']++;
- }
- if ($value['grade'] == 2) {
- $data['v1']++;
- }
- if ($value['grade'] == 3) {
- $data['v2']++;
- }
- if ($value['grade'] == 4) {
- $data['v3']++;
- }
- if ($value['grade'] == 5) {
- $data['v4']++;
- }
- $fns($value['link_id']);
- }
- }
- };
- $fns($uid);
- Db::name("Volunteer")
- ->where(["uid" => $uid])
- ->update([
- "v" => $data['v'],
- "v1" => $data['v1'],
- "v2" => $data['v2'],
- "v3" => $data['v3'],
- "v4" => $data['v4'],
- "time" => time()
- ]);
- return $data;
- }
- /**
- * 线上订单结算
- * @param $timeLimit
- * @return void
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function onlineOrderNew($timeLimit)
- {
- // 普通订单
- $order_data = Db::name('store_order')->where('paid', 1)->where('is_settlement', 0)->where('pay_type', 'in', '0,1,2,4')->where([['status','in','2,3']])->select();
- $StoreOrderStatusRepository = app()->make(StoreOrderStatusRepository::class);
- if($order_data) {
- $order_data = $order_data->toArray();
- foreach ($order_data as $online) {
- $date = date('Y-m-d H:i:s', strtotime('-' . $timeLimit . ' days'));
- if($date < $online['create_time']) continue;
- Db::transaction(function () use ($online) {
- $this->settleAward($online,0);
- Db::name('store_order')->where('order_id', $online['order_id'])->update(['is_settlement' => 1 ,'settlement_time' => date('Y-m-d H:i:s')]);
- });
- }
- }
- }
- /**
- * 话费订单结算
- * @param $timeLimit
- * @return void
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function huafeiOrderNew($timeLimit)
- {
- // 普通订单
- $order_data = Db::name('order_huafei')->where('status', 2)->where('gzc' , 0)->select();
- if($order_data) {
- $order_data = $order_data->toArray();
- foreach ($order_data as $online) {
- $date = date('Y-m-d H:i:s', strtotime('-' . $timeLimit . ' days'));
- if($date < $online['create_time']) continue;
- $online['order_id'] = $online['order_huafei_id'];
- Db::transaction(function () use ($online) {
- $this->settleAward($online,9);
- Db::name('order_huafei')->where('order_huafei_id', $online['order_huafei_id'])->update(['gzc' => 1]);
- });
- }
- }
- }
- /**
- * 拼多多订单结算
- * @param $timeLimit
- * @return void
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function pddOrderNew($timeLimit)
- {
- // 普通订单
- $order_data = Db::name('order_pdd')->where('pin_order_status', 5)->where('gzc', 0)->select();
- if($order_data) {
- $order_data = $order_data->toArray();
- foreach ($order_data as $online) {
- $date = date('Y-m-d H:i:s', strtotime('-' . $timeLimit . ' days'));
- if($date < $online['create_time']) continue;
- $online['order_id'] = $online['order_pdd_id'];
- Db::transaction(function () use ($online) {
- $this->settleAward($online,1);
- Db::name('order_pdd')->where('order_pdd_id', $online['order_pdd_id'])->update(['gzc' => 1]);
- });
- }
- }
- }
- /**
- * 京东订单结算
- * @param $timeLimit
- * @return void
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function jdOrderNew($timeLimit)
- {
- // 普通订单
- $order_data = Db::name('order_jd')->where('status', 17)->where('gzc', 0)->select();
- if($order_data) {
- $order_data = $order_data->toArray();
- foreach ($order_data as $online) {
- $date = date('Y-m-d H:i:s', strtotime('-' . $timeLimit . ' days'));
- if($date < $online['create_time']) continue;
- $online['order_id'] = $online['order_jd_id'];
- Db::transaction(function () use ($online) {
- $this->settleAward($online,6);
- Db::name('order_jd')->where('order_jd_id', $online['order_jd_id'])->update(['gzc' => 1]);
- });
- }
- }
- }
- /**
- * 苏宁订单结算
- * @param $timeLimit
- * @return void
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function suOrderNew($timeLimit)
- {
- // 普通订单
- $order_data = Db::name('order_su')->where('status', '确认收货')->where('gzc', 0)->select();
- if($order_data) {
- $order_data = $order_data->toArray();
- foreach ($order_data as $online) {
- $date = date('Y-m-d H:i:s', strtotime('-' . $timeLimit . ' days'));
- if($date < $online['create_time']) continue;
- $online['order_id'] = $online['order_su_id'];
- Db::transaction(function () use ($online) {
- $this->settleAward($online,3);
- Db::name('order_su')->where('order_su_id', $online['order_su_id'])->update(['gzc' => 1]);
- });
- }
- }
- }
- /**
- * 淘宝订单结算
- * @param $timeLimit
- * @return void
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function taobaoOrderNew($timeLimit)
- {
- // 普通订单
- $order_data = Db::name('order_tb')->where('tk_status', 3)->where('gzc', 0)->select();
- if($order_data) {
- $order_data = $order_data->toArray();
- foreach ($order_data as $online) {
- $date = date('Y-m-d H:i:s', strtotime('-' . $timeLimit . ' days'));
- if($date < $online['create_time']) continue;
- $online['order_id'] = $online['order_tb_id'];
- Db::transaction(function () use ($online) {
- $this->settleAward($online,5);
- Db::name('order_tb')->where('order_tb_id', $online['order_tb_id'])->update(['gzc' => 1]);
- });
- }
- }
- }
- /**
- * 唯品会订单结算
- * @param $timeLimit
- * @return void
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function vipOrderNew($timeLimit)
- {
- // 普通订单
- $order_data = Db::name('order_vip')->where('status', 2)->where('gzc', 0)->select();
- if($order_data) {
- $order_data = $order_data->toArray();
- foreach ($order_data as $online) {
- $date = date('Y-m-d H:i:s', strtotime('-' . $timeLimit . ' days'));
- if($date < $online['create_time']) continue;
- $online['order_id'] = $online['order_vip_id'];
- Db::transaction(function () use ($online) {
- $this->settleAward($online,2);
- Db::name('order_vip')->where('order_vip_id', $online['order_vip_id'])->update(['gzc' => 1]);
- });
- }
- }
- }
- /**
- * 抖音订单结算
- * @param $timeLimit
- * @return void
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function dyOrderNew($timeLimit)
- {
- // 普通订单
- $order_data = Db::name('order_dy')->where('flow_point', 'SETTLE')->where('gzc', 0)->select();
- if($order_data) {
- $order_data = $order_data->toArray();
- foreach ($order_data as $online) {
- $date = date('Y-m-d H:i:s', strtotime('-' . $timeLimit . ' days'));
- if($date < $online['create_time']) continue;
- $online['order_id'] = $online['order_dy_id'];
- Db::transaction(function () use ($online) {
- $this->settleAward($online);
- Db::name('order_dy')->where('order_dy_id', $online['order_dy_id'])->update(['gzc' => 1]);
- });
- }
- }
- }
- /**
- * 结算奖励
- * @param $online
- * @return void
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function settleAward($online,$order_type)
- {
- // 结算积分
- $user_sign_score_list = Db::name('user_sign_score')
- ->where('status', -1)
- ->where('order_id', $online['order_id'])
- ->where('pm', 1)
- ->where('order_type', $order_type)
- ->select()
- ->toArray();
- if($user_sign_score_list){
- foreach ($user_sign_score_list as $user_sign_score) {
- // 修改积分
- Db::name('user')
- ->where('uid', $user_sign_score['uid'])
- ->inc('score', floatval($user_sign_score['reward_socre']))
- ->update();
- Db::name('user_sign_score')
- ->where('id', $user_sign_score['id'])
- ->update([
- 'status' => 1,
- 'settlement_time' => date('Y-m-d H:i:s')
- ]);
- }
- }
- // 结算红包
- $user_sign_hongbao_list = Db::name('user_sign_hongbao')
- ->where('status', -1)
- ->where('order_id', $online['order_id'])
- ->where('type', 1)
- ->where('order_type', $order_type)
- ->select()
- ->toArray();
- if($user_sign_hongbao_list){
- foreach ($user_sign_hongbao_list as $user_sign_hongbao) {
- // 修改红包
- Db::name('user')
- ->where('uid', $user_sign_hongbao['uid'])
- ->inc('hongbao', floatval($user_sign_hongbao['number']))
- ->update();
- Db::name('user_sign_hongbao')
- ->where('id', $user_sign_hongbao['id'])
- ->update([
- 'status' => 1,
- 'settlement_time' => date('Y-m-d H:i:s')
- ]);
- }
- }
- // 结算京豆
- $user_sign_jingdou_list = Db::name('user_sign_jingdou')
- ->where('status', -1)
- ->where('order_id', $online['order_id'])
- ->where('type', 1)
- ->where('order_type', $order_type)
- ->select()
- ->toArray();
- if($user_sign_jingdou_list){
- foreach ($user_sign_jingdou_list as $user_sign_jingdou) {
- // 修改京豆
- Db::name('user')
- ->where('uid', $user_sign_jingdou['uid'])
- ->inc('jingdou', floatval($user_sign_jingdou['number']))
- ->update();
- Db::name('user_sign_jingdou')
- ->where('id', $user_sign_jingdou['id'])
- ->update([
- 'status' => 1,
- 'settlement_time' => date('Y-m-d H:i:s')
- ]);
- }
- }
- // 结算复购金
- $user_sign_fugou_list = Db::name('user_sign_fugou')
- ->where('status', -1)
- ->where('order_id', $online['order_id'])
- ->where('type', 1)
- ->where('order_type', $order_type)
- ->select()
- ->toArray();
- if($user_sign_fugou_list){
- foreach ($user_sign_fugou_list as $user_sign_fugou) {
- // 修改复购金
- Db::name('user')
- ->where('uid', $user_sign_fugou['uid'])
- ->inc('fugou', floatval($user_sign_fugou['number']))
- ->update();
- Db::name('user_sign_fugou')
- ->where('id', $user_sign_fugou['id'])
- ->update([
- 'status' => 1,
- 'settlement_time' => date('Y-m-d H:i:s')
- ]);
- }
- }
- // 结算贡献值
- $user_sign_gongxian_list = Db::name('user_sign_gongxian')
- ->where('status', -1)
- ->where('order_id', $online['order_id'])
- ->where('type', 1)
- ->where('order_type', $order_type)
- ->select()
- ->toArray();
- if($user_sign_gongxian_list){
- foreach ($user_sign_gongxian_list as $user_sign_gongxian) {
- // 修改贡献值
- Db::name('user')
- ->where('uid', $user_sign_gongxian['uid'])
- ->inc('contribute', floatval($user_sign_gongxian['number']))
- ->update();
- Db::name('user_sign_gongxian')
- ->where('id', $user_sign_gongxian['id'])
- ->update([
- 'status' => 1,
- 'settlement_time' => date('Y-m-d H:i:s')
- ]);
- /** @var UserRepository $userRepository */
- $userRepository = app()->make(UserRepository::class);
- $userRepository->setUserIdentity($user_sign_gongxian['uid']);
- }
- }
- // 结算PV值
- $user_pv_list = Db::name('user_pv_log')
- ->where('status', -1)
- ->where('order_id', $online['order_id'])
- ->where('order_type', $order_type)
- ->select()
- ->toArray();
- if($user_pv_list) {
- foreach ($user_pv_list as $user_pv) {
- // 修改pv
- Db::name('user')
- ->where('uid', $user_pv['uid'])
- ->inc('pv', floatval($user_pv['pv']))
- ->update();
- Db::name('user_pv_log')
- ->where('id', $user_pv['id'])
- ->update([
- 'status' => 1,
- 'settlement_time' => date('Y-m-d H:i:s')
- ]);
- }
- }
- // 结算佣金养老金
- $user_bill_list = Db::name('user_bill')
- ->where('status', 0)
- ->where([ 'link_id' => $online['order_id']])
- ->where('type_shop', $order_type)
- ->where([ 'pm' => 1])
- ->select()
- ->toArray();
- if($user_bill_list){
- foreach ($user_bill_list as $user_bill) {
- if($user_bill['commission_type'] == 5){
- Db::name('user')
- ->where('uid', $user_bill['uid'])
- ->inc('annuity', floatval($user_bill['number']))
- ->update();
- }else{
- Db::name('user')
- ->where('uid', $user_bill['uid'])
- ->inc('brokerage_price', floatval($user_bill['number']))
- ->update();
- }
- Db::name('user_bill')
- ->where('bill_id', $user_bill['bill_id'])
- ->update([
- 'status' => 1,
- 'take_time' => date('Y-m-d H:i:s')
- ]);
- }
- }
- //按角色结算
- // $StoreOrderRepository->close_order($online['order_id']);
- }
- }
|