| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672 |
- <?php
- namespace app\business;
- use Illuminate\Support\Arr;
- use support\Db;
- use support\Redis;
- use Throwable;
- use yzh52521\EasyHttp\Http;
- class PayorderBusiness
- {
- static private $url = "https://xswg.bbbzf.xyz/api/pay/create_order";
- static private $apikey = 'NAIE3F8W6AQFMMCUTWQ5TZJU2XAPZT3QW0USC274FHMYM61BUTUBC6KLMSKKNEYA623NWI1V29INBKC4NHMRTJXM4VTVDVCQK6ZXCKIXUYL6TFNCTWIHJKAYFHM3D4ZB';
- static private $memberid = 20000214;
- /**
- * @param array $param [
- * order_no
- * ]
- * @return array
- */
- static public function payment($order_no, $pay_bankcode, $money, $url = '')
- {
- if (empty($url)) {
- $url = getenv('WEB_HOST');
- }
- $arr = [
- 'mchId' => self::$memberid,
- 'productId' => $pay_bankcode,
- 'mchOrderNo' => $order_no,
- 'amount' => (int)bcmul($money, 100),
- 'notifyUrl' => getenv('API_HOST') . '/api/pay/payment_callback.html',//异步通知地址,支付成功后将支付成功消息以POST请求发送给这个网址
- 'subject' => '商品',
- 'body' => '商品描述',
- 'extra' => 'abcd',
- ];
- $arr['sign'] = self::payMd5sign($arr);
- $data = Http::post(self::$url, $arr)->array();
- return ['data' => $data, 'arr' => $arr];
- }
- static public function payMd5sign(array $param)
- {
- /* @对数组键进行ASCII码排序*/
- ksort($param);
- $arr = [];
- //将数组进行重组装
- foreach ($param as $k => $v) {
- if (!empty($v)) {
- $arr[] = $k . '=' . $v;
- }
- }
- //转换成字符串并且拼接上密钥
- $sign = implode('&', $arr) . '&key=' . self::$apikey;
- return strtoupper(md5($sign));
- }
- /** 生成订单号
- * @param array $param
- * @return int
- * @throws \Exception
- */
- static public function orderAdd(array $param)
- {
- try {
- $goods = Db::table('wa_goods')->where('id', $param['id'])->first();
- if (empty($goods)) {
- throw new \Exception('产品不存在!');
- }
- $payAisleData = Db::table('wa_pay_aisle')->where('characteristic', $param['pay_characteristic'])->first();
- if (empty($payAisleData)) {
- throw new \Exception('支付类型不存在!');
- }
- $characteristic = $payAisleData->characteristic;
- $pay_type = $payAisleData->type;
- $order_no = date('YmdHis') . mt_rand(1000, 9999);
- $payorderId = Db::table('wa_payorder')->insertGetId([
- 'goods_id' => $goods->id,
- 'goods_type' => $goods->type,
- 'user_id' => $param['user_data']['id'],
- 'order_no' => $order_no,
- 'pay_characteristic' => $characteristic,
- 'pay_type' => $pay_type,
- 'money' => bcmul($goods->pay_price, $param['num'], 2),
- 'num' => $param['num'],
- 'name' => Arr::get($param, 'name', null),
- 'mobile' => Arr::get($param, 'mobile', null),
- 'number' => Arr::get($param, 'number', null),
- 'address' => Arr::get($param, 'address', null),
- 'affiliated_bank' => Arr::get($param, 'affiliated_bank', null),
- 'card_number' => Arr::get($param, 'card_number', null),
- 'created_at' => date('Y-m-d H:i:s'),
- 'updated_at' => date('Y-m-d H:i:s'),
- ]);
- } catch (\Throwable $exception) {
- throw new \Exception($exception->getMessage());
- }
- return $payorderId;
- }
- /** 开通银行卡生成订单号
- * @param array $param
- * @return int
- * @throws \Exception
- */
- static public function CardorderAdd(array $param)
- {
- try {
- $goods = Db::table('wa_goods')->where('id', $param['id'])->first();
- if (empty($goods)) {
- throw new \Exception('产品不存在!');
- }
- $price_money = bcmul($goods->pay_price, $param['num']);
- if ($param['user_data']['money_one'] < $price_money) {
- throw new \Exception('华润财富余额不足!');
- }
- $payorderId = Db::table('wa_payorder')->insertGetId([
- 'goods_id' => $goods->id,
- 'goods_type' => $goods->type,
- 'user_id' => $param['user_data']['id'],
- 'order_no' => date('YmdHis') . mt_rand(1000, 9999),
- 'pay_characteristic' => 0,
- 'pay_type' => 0,
- 'is_pay' => 2,
- 'money' => $price_money,
- 'num' => 1,
- 'created_at' => date('Y-m-d H:i:s'),
- 'updated_at' => date('Y-m-d H:i:s'),
- ]);
- } catch (\Throwable $exception) {
- throw new \Exception($exception->getMessage());
- }
- return $payorderId;
- }
- /**提现
- * @return void
- */
- static public function tx_withdraw($param, $service_charge = '')
- {
- try {
- $payAisleData = Db::table('wa_pay_aisle')->where('characteristic', $param['pay_characteristic'])->first();
- if (empty($payAisleData)) {
- throw new \Exception('支付类型不存在!');
- }
- $payorderId = Db::table('wa_payorder')->insertGetId([
- 'goods_type' => 1001,
- 'user_id' => $param['user_data']['id'],
- 'order_no' => date('YmdHis') . mt_rand(1000, 9999),
- 'pay_characteristic' => $payAisleData->characteristic,
- 'pay_type' => $payAisleData->type,
- 'money' => bcmul($param['money'], $service_charge, 2),
- 'withdraw_money' => $param['money'],
- 'mold_type' => $param['mold'],
- 'created_at' => date('Y-m-d H:i:s'),
- 'updated_at' => date('Y-m-d H:i:s'),
- ]);
- } catch (\Throwable $exception) {
- throw new \Exception($exception->getMessage());
- }
- return $payorderId;
- }
- /** 购买原始股
- * @param $num
- * @param $user_id
- * @param $pay_characteristic
- * @return int
- * @throws \Exception
- */
- static public function orderAddInitialShare($num, $user_id, $pay_characteristic)
- {
- try {
- $wa_system = Db::table('wa_system')->first();
- $payAisleData = Db::table('wa_pay_aisle')->where('characteristic', $pay_characteristic)->first();
- if (empty($payAisleData)) {
- throw new \Exception('支付类型不存在!');
- }
- $payorderId = Db::table('wa_payorder')->insertGetId([
- 'goods_id' => 0,
- 'goods_type' => 10,
- 'user_id' => $user_id,
- 'order_no' => date('YmdHis') . mt_rand(1000, 9999),
- 'pay_characteristic' => $payAisleData->characteristic,
- 'pay_type' => $payAisleData->type,
- 'money' => bcmul($wa_system->money_five_value, $num, 2),
- 'num' => $num,
- 'created_at' => date('Y-m-d H:i:s'),
- 'updated_at' => date('Y-m-d H:i:s'),
- ]);
- } catch (\Throwable $exception) {
- throw new \Exception($exception->getMessage());
- }
- return $payorderId;
- }
- /** 提现回调
- * @param $data
- * @return void
- * @throws \Exception
- */
- static public function payorderJkjtx($data)
- {
- try {
- /** @var $bankCard 银行卡 */
- $bankCard = Db::table('wa_bank_card')->where('uid', $data['user_id'])->first();
- $withdrawId = Db::table('wa_withdraw')->insertGetId([
- 'order_no' => date('YmdHis') . mt_rand(10000, 99999),
- 'user_id' => $data['user_id'],
- 'money' => $data['withdraw_money'],
- 'type' => $data['mold_type'],
- 'affiliated_bank' => $bankCard->affiliated_bank,
- 'account_holder' => $bankCard->account_holder,
- 'card_number' => $bankCard->card_number,
- 'created_at' => date('Y-m-d H:i:s'),
- 'updated_at' => date('Y-m-d H:i:s'),
- ]);
- StreamBusiness::delStream($data['user_id'], $data['withdraw_money'], streamType4, $data['mold_type'], moldTypefild($data['mold_type']), $withdrawId);
- } catch (Throwable $exception) {
- throw new \Exception($exception->getMessage());
- }
- }
- /** 支付回调
- * @param $orderNo
- * @return void
- */
- static public function paymentCallback($orderNo)
- {
- try {
- $payorder = Db::table('wa_payorder')->where('order_no', $orderNo)->first();
- if ($payorder->is_pay != 1) {
- throw new \Exception('订单已处理!');
- }
- self::payorderSave(collect($payorder)->toArray());
- } catch (\Throwable $exception) {
- throw new \Exception($exception->getMessage());
- }
- return true;
- }
- /** 购买原始股权回调
- * @param $data
- * @return void
- */
- // static public function goodsStockRights($data)
- // {
- // try {
- // $goodsData=Db::table('wa_goods')->where('id',$data['goods_id'])->first();
- // $thisDay=date('Y-m-d H:i:s');
- // /** @var $futureDay 未来时间*/
- // $futureDay=futureDay(1095);
- //
- // $myGoodsId=Db::table('wa_my_goods')->insertGetId([
- // 'user_id' => $data['user_id'],
- // 'goods_id' => $goodsData->id,
- // 'money' => $data['money'],
- // 'on' => date('YmdHis').mt_rand(1000,9999),
- // 'type' => $goodsData->type,
- // 'pay_id' => $data['id'],
- // 'stock_rights' => $goodsData->stock_rights,
- // 'unit_price' => $goodsData->unit_price,
- // 'refund_amount' => $data['money'],
- // 'expiretime' => strtotime($futureDay),
- // 'expiredate' => $futureDay,
- // 'created_at' => $thisDay,
- // 'updated_at' => $thisDay
- // ]);
- //
- //
- //// StreamBusiness::addStream($data['user_id'],bcmul($goodsData->stock_rights,$goodsData->unit_price,2),streamType5,moldType4,moldTypefild(moldType4),$data['id']);
- //
- // $usersData=Db::table('wa_users')->where('id',$data['user_id'])->first();
- // $system=Db::table('wa_system')->first();
- // if(!empty($usersData->pid) && !empty($system->rebate)){
- // StreamBusiness::addStream($usersData->pid,$system->rebate,streamType10,moldType4,moldTypefild4,$data['id']);
- // }
- // if(!empty($usersData->ppid) && !empty($system->rebate_one)){
- // StreamBusiness::addStream($usersData->ppid,$system->rebate_one,streamType10,moldType4,moldTypefild4,$data['id']);
- // }
- //
- // if(!empty($usersData->toppid) && !empty($system->rebate_two)){
- // StreamBusiness::addStream($usersData->toppid,$system->rebate_two,streamType10,moldType4,moldTypefild4,$data['id']);
- // }
- //
- // /** 新增消费数据 */
- // Db::table('wa_users')->where('id',$data['user_id'])->increment('invest_money',$data['money']);
- //
- // Db::table('wa_goods')->where('id',$goodsData->id)->decrement('num',1);
- //
- // }catch (\Throwable $exception){
- // throw new \Exception($exception->getMessage());
- // }
- // }
- /** 订单回调处理
- * @param $data 订单信息
- * @return void
- */
- static public function payorderSave($data)
- {
- try {
- self::payorderGoods($data);
- Db::table('wa_payorder')->where('id', $data['id'])->update([
- 'is_pay' => 2,
- 'updated_at' => date('Y-m-d H:i:s'),
- ]);
- } catch (\Throwable $exception) {
- throw new \Exception($exception->getMessage());
- }
- return true;
- }
- /** 商品回调
- * @param $data
- * @return void
- * @throws \Exception
- */
- static public function payorderGoods($data)
- {
- try {
- $goodsData = Db::table('wa_goods')->where('id', $data['goods_id'])->first();
- $thisDay = date('Y-m-d H:i:s');
- /** @var $futureDay 未来时间 */
- $futureDay = futureDay(1095);
- if ($goodsData->type == 10) {
- $mygoodslist = Db::table('wa_my_goods')
- ->where('user_id', $data['user_id'])
- ->where('goods_id', $goodsData->id)
- ->first();
- if ($mygoodslist) {
- Db::table('wa_my_goods')->where('id', $mygoodslist->id)->increment('balance', $goodsData->balance);
- } else {
- $myGoodsId = Db::table('wa_my_goods')->insertGetId([
- 'user_id' => $data['user_id'],
- 'goods_id' => $goodsData->id,
- 'money' => $data['money'],
- 'num' => $data['num'],
- 'on' => date('YmdHis') . mt_rand(1000, 9999),
- 'type' => $goodsData->type,
- 'pay_id' => $data['id'],
- 'bonus' => $goodsData->bonus,
- 'balance' => $goodsData->balance,
- 'usd_quota' => $goodsData->usd_quota,
- 'refund_amount' => $data['money'],
- 'name' => Arr::get($data, 'name', null),
- 'mobile' => Arr::get($data, 'mobile', null),
- 'number' => Arr::get($data, 'number', null),
- 'address' => Arr::get($data, 'address', null),
- 'affiliated_bank' => Arr::get($data, 'affiliated_bank', null),
- 'card_number' => Arr::get($data, 'card_number', null),
- 'expiretime' => strtotime($futureDay),
- 'expiredate' => $futureDay,
- 'created_at' => $thisDay,
- 'updated_at' => $thisDay,
- ]);
- }
- } else {
- $myGoodsId = Db::table('wa_my_goods')->insertGetId([
- 'user_id' => $data['user_id'],
- 'goods_id' => $goodsData->id,
- 'money' => $data['money'],
- 'num' => $data['num'],
- 'on' => date('YmdHis') . mt_rand(1000, 9999),
- 'type' => $goodsData->type,
- 'pay_id' => $data['id'],
- 'bonus' => $goodsData->bonus,
- 'balance' => $goodsData->balance,
- 'usd_quota' => $goodsData->usd_quota,
- 'refund_amount' => $data['money'],
- 'name' => Arr::get($data, 'name', null),
- 'mobile' => Arr::get($data, 'mobile', null),
- 'number' => Arr::get($data, 'number', null),
- 'address' => Arr::get($data, 'address', null),
- 'expiretime' => strtotime($futureDay),
- 'expiredate' => $futureDay,
- 'created_at' => $thisDay,
- 'updated_at' => $thisDay,
- ]);
- }
- $userlist = Db::table('wa_users')->where('id', $data['user_id'])->first();
- if ($goodsData->type == 1) {
- if (!empty($goodsData->bonus)) {
- Db::table('wa_cron_task')->insert([
- 'user_id' => $data['user_id'],
- 'goods_id' => $goodsData->id,
- 'order_id' => $data['id'],
- 'money' => $data['money'],
- 'bonus' => $goodsData->bonus,
- 'rebate' => $goodsData->rebate,
- 'rebate_one' => $goodsData->rebate_one,
- 'rebate_two' => $goodsData->rebate_two,
- 'goods_type' => $goodsData->type,
- 'day_dividend_time' => strtotime(date('Y-m-d', strtotime('+1 days')) . ' 00:10:00'),
- 'dividend_time' => strtotime($futureDay),
- 'created_at' => $thisDay,
- 'updated_at' => $thisDay,
- 'my_good_id' => $myGoodsId,
- ]);
- StreamBusiness::addStream($data['user_id'], $goodsData->bonus, streamType9, moldType7, moldTypefild7, $data['id']);
- if (!empty($userlist->pid) && !empty($goodsData->rebate)) {
- StreamBusiness::addStream($userlist->pid, $goodsData->rebate, streamType9, moldType9, moldTypefild9, $data['id']);
- }
- if (!empty($userlist->ppid) && !empty($goodsData->rebate_one)) {
- StreamBusiness::addStream($userlist->ppid, $goodsData->rebate_one, streamType9, moldType9, moldTypefild9, $data['id']);
- }
- if (!empty($userlist->toppid) && !empty($goodsData->rebate_two)) {
- StreamBusiness::addStream($userlist->toppid, $goodsData->rebate_two, streamType9, moldType9, moldTypefild9, $data['id']);
- }
- }
- if (!empty($goodsData->trial_bonus)) {
- $carkdatalist = Db::table('wa_user_social_cark')
- ->where('user_id', $data['user_id'])
- ->where('status', 3)->first();
- if (!empty($carkdatalist)) {
- StreamBusiness::addStream($data['user_id'], $goodsData->trial_bonus, streamType9, moldType6, moldTypefild6, $data['id']);
- }
- }
- if (!empty($goodsData->balance)) {
- StreamBusiness::addStream($data['user_id'], $goodsData->balance, streamType9, moldType10, moldTypefild10, $data['id']);
- StreamBusiness::delStream($data['user_id'], $goodsData->balance, streamType25, moldType3, moldTypefild3, $data['id']);
- }
- StreamBusiness::delStream($data['user_id'], $goodsData->payment_usd, streamType21, moldType3, moldTypefild3, $data['id']);
- /** 分佣 */
- $system = Db::table('wa_system')->first();
- if (!empty($userlist->pid) && !empty($system->rebate)) {
- StreamBusiness::addStream($userlist->pid, bcmul($goodsData->pay_price, bcdiv($system->rebate, 100, 2), 2), streamType10, moldType8, moldTypefild8, $data['id']);
- }
- if (!empty($userlist->ppid) && !empty($system->rebate_one)) {
- StreamBusiness::addStream($userlist->ppid, bcmul($goodsData->pay_price, bcdiv($system->rebate_one, 100, 2), 2), streamType10, moldType8, moldTypefild8, $data['id']);
- }
- if (!empty($userlist->toppid) && !empty($system->rebate_two)) {
- StreamBusiness::addStream($userlist->toppid, bcmul($goodsData->pay_price, bcdiv($system->rebate_two, 100, 2), 2), streamType10, moldType8, moldTypefild8, $data['id']);
- }
- } elseif ($goodsData->type == 2) {
- if (!empty($goodsData->bonus)) {
- Db::table('wa_cron_task')->insert([
- 'user_id' => $data['user_id'],
- 'goods_id' => $goodsData->id,
- 'order_id' => $data['id'],
- 'money' => $data['money'],
- 'bonus' => $goodsData->bonus,
- 'balance' => $goodsData->balance,
- 'rebate' => $goodsData->rebate,
- 'rebate_one' => $goodsData->rebate_one,
- 'rebate_two' => $goodsData->rebate_two,
- 'goods_type' => $goodsData->type,
- 'day_dividend_time' => strtotime(date('Y-m-d', strtotime('+1 days')) . ' 00:10:00'),
- 'dividend_time' => strtotime($futureDay),
- 'created_at' => $thisDay,
- 'updated_at' => $thisDay,
- 'my_good_id' => $myGoodsId,
- 'event_time' => 0,
- 'is_activity' => 0,
- ]);
- StreamBusiness::addStream($data['user_id'], $goodsData->bonus, streamType26, moldType11, moldTypefild11, $data['id']);
- }
- if (!empty($goodsData->balance)) {
- StreamBusiness::addStream($data['user_id'], $goodsData->balance, streamType30, moldType10, moldTypefild10, $data['id']);
- StreamBusiness::delStream($data['user_id'], $goodsData->balance, streamType27, moldType3, moldTypefild3, $data['id']);
- }
- StreamBusiness::delStream($data['user_id'], $goodsData->payment_usd, streamType28, moldType3, moldTypefild3, $data['id']);
- /** 分佣 */
- $system = Db::table('wa_system')->first();
- if (!empty($userlist->pid) && !empty($system->rebate)) {
- StreamBusiness::addStream($userlist->pid, bcmul($goodsData->pay_price, bcdiv($system->rebate, 100, 2), 2), streamType10, moldType8, moldTypefild8, $data['id']);
- }
- if (!empty($userlist->ppid) && !empty($system->rebate_one)) {
- StreamBusiness::addStream($userlist->ppid, bcmul($goodsData->pay_price, bcdiv($system->rebate_one, 100, 2), 2), streamType10, moldType8, moldTypefild8, $data['id']);
- }
- if (!empty($userlist->toppid) && !empty($system->rebate_two)) {
- StreamBusiness::addStream($userlist->toppid, bcmul($goodsData->pay_price, bcdiv($system->rebate_two, 100, 2), 2), streamType10, moldType8, moldTypefild8, $data['id']);
- }
- } elseif ($goodsData->type == 3) {
- Db::table('wa_user_social_cark')->where('user_id', $data['user_id'])->update(['is_buy' => 2, 'buy_time' => date('Y-m-d H:i:s')]);
- } elseif ($goodsData->type == 4) {
- if (!empty($goodsData->bonus)) {
- Db::table('wa_cron_task_four')->insert([
- 'user_id' => $data['user_id'],
- 'goods_id' => $goodsData->id,
- 'order_id' => $data['id'],
- 'money' => $data['money'],
- 'bonus' => $goodsData->bonus,
- 'goods_type' => $goodsData->type,
- 'day_dividend_time' => strtotime(date('Y-m-d', strtotime('+1 days')) . ' 00:00:00'),
- 'dividend_time' => strtotime($futureDay),
- 'created_at' => $thisDay,
- 'updated_at' => $thisDay,
- 'my_good_id' => $myGoodsId,
- 'event_time' => 0,
- 'is_activity' => 0,
- ]);
- StreamBusiness::addStream($data['user_id'], $goodsData->bonus, streamType37, moldType12, moldTypefild12, $data['id']);
- }
- if (!empty($goodsData->balance)) {
- StreamBusiness::addStream($data['user_id'], $goodsData->balance, streamType36, moldType13, moldTypefild13, $data['id']);
- Db::table('wa_users')->where('id', $data['user_id'])->increment('accumulate_thirteen', $goodsData->balance);
- }
- if (!empty($goodsData->usd_quota)) {
- StreamBusiness::addStream($data['user_id'], $goodsData->usd_quota, streamType36, moldType14, moldTypefild14, $data['id']);
- Db::table('wa_users')->where('id', $data['user_id'])->increment('accumulate_fourteen', $goodsData->usd_quota);
- }
- if (!empty($goodsData->ranking)) {
- $cardlist = Db::table('wa_user_social_cark')->where('user_id', $data['user_id'])->first();
- if (!empty($cardlist)) {
- if ($cardlist->ranking > $goodsData->ranking) {
- Db::table('wa_user_social_cark')->where('id', $cardlist->id)->decrement('ranking', $goodsData->ranking);
- Db::table('wa_my_goods')->where('id', $myGoodsId)->update([
- 'ranking' => $goodsData->ranking,
- ]);
- $new_ranking = bcsub($cardlist->ranking, $goodsData->ranking);
- Db::table('wa_users')->where('id', $data['user_id'])->increment('increase_ranking', $goodsData->ranking);
- } else {
- $new_ranking = $cardlist->ranking;
- }
- Db::table('wa_users')->where('id', $data['user_id'])->update(['new_ranking' => $new_ranking]);
- }
- }
- /** 分佣 */
- $system = Db::table('wa_system')->first();
- if (!empty($userlist->pid) && !empty($system->rebate)) {
- StreamBusiness::addStream($userlist->pid, bcmul($goodsData->pay_price, bcdiv($system->rebate, 100, 2), 2), streamType10, moldType8, moldTypefild8, $data['id']);
- }
- if (!empty($userlist->ppid) && !empty($system->rebate_one)) {
- StreamBusiness::addStream($userlist->ppid, bcmul($goodsData->pay_price, bcdiv($system->rebate_one, 100, 2), 2), streamType10, moldType8, moldTypefild8, $data['id']);
- }
- if (!empty($userlist->toppid) && !empty($system->rebate_two)) {
- StreamBusiness::addStream($userlist->toppid, bcmul($goodsData->pay_price, bcdiv($system->rebate_two, 100, 2), 2), streamType10, moldType8, moldTypefild8, $data['id']);
- }
- } elseif ($goodsData->type == 5) {
- $futureDay = futureDay($goodsData->day);
- $myGoodsId_two = Db::table('wa_my_goods')->insertGetId([
- 'user_id' => $data['user_id'],
- 'goods_id' => $goodsData->id,
- 'money' => $data['money'],
- 'num' => $data['num'],
- 'on' => date('YmdHis') . mt_rand(1000, 9999),
- 'type' => $goodsData->type,
- 'pay_id' => $data['id'],
- 'bonus' => $goodsData->bonus,
- 'balance' => $goodsData->balance,
- 'usd_quota' => $goodsData->usd_quota,
- 'refund_amount' => $data['money'],
- 'name' => Arr::get($data, 'name', null),
- 'mobile' => Arr::get($data, 'mobile', null),
- 'number' => Arr::get($data, 'number', null),
- 'address' => Arr::get($data, 'address', null),
- 'expiretime' => strtotime($futureDay),
- 'expiredate' => $futureDay,
- 'created_at' => $thisDay,
- 'updated_at' => $thisDay,
- ]);
- if (!empty($goodsData->bonus)) {
- Db::table('wa_cron_task')->insert([
- 'user_id' => $data['user_id'],
- 'goods_id' => $goodsData->id,
- 'order_id' => $data['id'],
- 'money' => $data['money'],
- 'bonus' => $goodsData->bonus,
- 'balance' => $goodsData->balance,
- 'rebate' => $goodsData->rebate,
- 'rebate_one' => $goodsData->rebate_one,
- 'rebate_two' => $goodsData->rebate_two,
- 'goods_type' => $goodsData->type,
- 'day_dividend_time' => strtotime(date('Y-m-d', strtotime('+1 days')) . ' 00:10:00'),
- 'dividend_time' => strtotime($futureDay),
- 'created_at' => $thisDay,
- 'updated_at' => $thisDay,
- 'my_good_id' => $myGoodsId_two,
- 'event_time' => 0,
- 'is_activity' => 0,
- ]);
- StreamBusiness::addStream($data['user_id'], $goodsData->bonus, streamType43, moldType15, moldTypefild15, $data['id']);
- }
- if (!empty($goodsData->balance)) {
- StreamBusiness::addStream($data['user_id'], $goodsData->balance, streamType43, moldType3, moldTypefild3, $data['id']);
- }
- if (!empty($goodsData->bonus)) {
- Db::table('wa_cron_task')->insert([
- 'user_id' => $data['user_id'],
- 'goods_id' => $goodsData->id,
- 'order_id' => $data['id'],
- 'money' => $data['money'],
- 'bonus' => $goodsData->bonus,
- 'balance' => $goodsData->balance,
- 'rebate' => $goodsData->rebate,
- 'rebate_one' => $goodsData->rebate_one,
- 'rebate_two' => $goodsData->rebate_two,
- 'goods_type' => $goodsData->type,
- 'day_dividend_time' => strtotime(date('Y-m-d', strtotime('+1 days')) . ' 00:10:00'),
- 'dividend_time' => strtotime($futureDay),
- 'created_at' => $thisDay,
- 'updated_at' => $thisDay,
- 'my_good_id' => $myGoodsId,
- 'event_time' => 0,
- 'is_activity' => 0,
- ]);
- StreamBusiness::addStream($data['user_id'], $goodsData->bonus, streamType43, moldType15, moldTypefild15, $data['id']);
- }
- if (!empty($goodsData->balance)) {
- StreamBusiness::addStream($data['user_id'], $goodsData->balance, streamType43, moldType3, moldTypefild3, $data['id']);
- }
- Db::table('wa_users')->where('id', $data['user_id'])->update(['mailing_date' => strtotime(futureDay($goodsData->mailing_date))]);
- /** 分佣 */
- $system = Db::table('wa_system')->first();
- if (!empty($userlist->pid) && !empty($system->rebate)) {
- StreamBusiness::addStream($userlist->pid, bcmul($goodsData->pay_price, bcdiv($system->rebate, 100, 2), 2), streamType42, moldType16, moldTypefild16, $data['id']);
- }
- if (!empty($userlist->ppid) && !empty($system->rebate_one)) {
- StreamBusiness::addStream($userlist->ppid, bcmul($goodsData->pay_price, bcdiv($system->rebate_one, 100, 2), 2), streamType42, moldType16, moldTypefild16, $data['id']);
- }
- if (!empty($userlist->toppid) && !empty($system->rebate_two)) {
- StreamBusiness::addStream($userlist->toppid, bcmul($goodsData->pay_price, bcdiv($system->rebate_two, 100, 2), 2), streamType42, moldType16, moldTypefild16, $data['id']);
- }
- } elseif ($goodsData->type == 6) {
- StreamBusiness::addStream($data['user_id'], $goodsData->pay_price, streamType45, moldType17, moldTypefild17, $data['id']);
- } elseif ($goodsData->type == 7) {
- StreamBusiness::addStream($data['user_id'], $goodsData->pay_price, streamType45, moldType17, moldTypefild17, $data['id']);
- } elseif ($goodsData->type == 8) {
- Db::table('wa_users')->where('id', $data['user_id'])->update(['is_protocol' => 1, 'protocol_time' => date('Y-m-d H:i:s')]);
- StreamBusiness::addStream($data['user_id'], $goodsData->pay_price, streamType45, moldType17, moldTypefild17, $data['id']);
- } elseif ($goodsData->type == 9) {
- } elseif ($goodsData->type == 10) {
- }
- /** 新增消费数据 */
- Db::table('wa_users')->where('id', $data['user_id'])->increment('invest_money', $data['money']);
- Db::table('wa_goods')->where('id', $goodsData->id)->decrement('num', $data['num']);
- } catch (\Throwable $exception) {
- throw new \Exception($exception->getMessage());
- }
- }
- }
|