setName('testtask') ->setDescription('the testtask command'); } /** * 商户批量取现 */ public function take() { $key_list = [ 1 => 'api_live_b23537ed-64b8-45d6-832e-fb228aa9e0a9', 2 => 'api_live_90ef02e4-54ac-41ee-adf1-e4927d23d58f', 3 => 'api_live_b0a687ec-5450-4ada-a0e4-65bac0f46871' ]; $appid_list = [ 1 => 'app_44108546-d27a-48ee-88c1-84b45b75114f', 2 => 'app_0827b960-b932-45ec-b800-4e850091b419', 3 => 'app_383a75dd-c03d-44ab-8f58-92c60fe9b9d0' ]; $merchant_member_list = Db::name('merchant_member') ->where('member_id', 'jsdk_member_wx21700447226310') ->where('settle_account_id', '0544998840384192') ->column('mer_id,type,member_id,settle_account_id'); foreach ($merchant_member_list as $merchant_member) { $mer_id = $merchant_member['mer_id']; if (empty($mer_id)) continue; if (empty($merchant_member['settle_account_id'])) continue; $params = [ 'app_id' => $appid_list[$merchant_member['type']], 'member_id' => $merchant_member['member_id'], 'settle_account_id' => $merchant_member['settle_account_id'], 'api_key' => $key_list[$merchant_member['type']] ]; $merber = new SettleAccount(); $merber->balance($params); $merber->result; if (isset($merber->result[1])) { $result = json_decode($merber->result[1], true); $result = json_decode($result['data'], true); $result['avl_balance'] = $result['avl_balance'] ?? 0; if ($result['avl_balance'] > 0) { $payment_id = ShouxinyiApiRequest::getOrderNumber('split'); $params = [ 'order_no' => $payment_id, 'app_id' => $appid_list[$merchant_member['type']], 'cash_type' => 'T1', 'cash_amt' => sprintf("%01.2f", $result['avl_balance']), 'member_id' => $merchant_member['member_id'], 'api_key' => $key_list[$merchant_member['type']] ]; Db::name("log")->insert(array('data' => '汇付取现参数-----' . json_encode($params)));//日志记录 $merber = new Drawcash(); $merber->create($params); # 返回查询结果 $merber->isError(); $res = $merber->result; Db::name("log")->insert(array('data' => '汇付延时分账-----' . json_encode($res))); //日志记录 Db::name("log")->insert(array('data' => "mer_id {$mer_id} 请求分账{$result['avl_balance']}元-----"));//日志记录 var_dump("mer_id {$mer_id} 请求分账{$result['avl_balance']}元-----"); return; } } } } public function add_bill_gongfu($title, $number, $uid, $mark, $commission_type, $order_sn, $order_id = 0, $mer_id = 0, $source = 0, $status = 0, $create_time = 0, $type = 'commission', $month = '', $is_mer = false) { if ($number == 0) { return; } $currency = ($type == 'commission' ? 'brokerage_price' : 'score'); $number = decimal2($number); $data = [ 'link_id' => $order_id,//关联订单id "uid" => $uid, "pm" => 1, "title" => $title, "category" => "now_money", "type" => $type,//明细类型 commission佣金 integral积分 "number" => $number, "mark" => $mark, "status" => $status,//0 = 待确定 1 = 有效 -1 = 无效 "commission_type" => $commission_type,//佣金类型 1代理费 2 消费佣金 3直推奖√ 4辖区佣金\r\n5 养老金√ 6 广告费 7 跨店奖励√ 8平台奖励 9渠道商\r\n10 推荐创客收益√ 11分红奖金√ 12代理区域收益√ 13消费循环佣金 14-推荐代理收益√ 15邀请小区团长升级√ 16大V经理分享奖√ 17创客合伙人√ 18积分奖励√ 19创客补贴√', "order_sn" => $order_sn,//订单号 "mer_id" => $mer_id,//商户id "source" => $source,//积分 "month" => $month,//奖励月份 "type_shop" => 0,//0平台1多多进宝2唯品会3苏宁易购4网易考拉5淘宝客6京东联盟7饿了么8线上 'create_time'=>$create_time ]; if ($status == 1) { $data['take_time'] = time(); //商户佣金类型处理 if (in_array($commission_type, [7,12,19])) { $balance = Db::name('merchant')->where('mer_id', $mer_id)->value($currency); $data['balance'] = decimal2($balance); Db::name("merchant")->where("mer_id", $mer_id)->inc($currency, $number)->update(); } else { $balance = Db::name('user')->where('uid', $uid)->value($currency); $data['balance'] = decimal2($balance); Db::name("user")->where("uid", $uid)->inc($currency, $number)->update(); } Db::name('log')->insert(['data' => "{$title}佣金增加{$number}," . json_encode($data)]); } Db::name("user_bill")->insert($data); } protected function execute(Input $input, Output $output) { $userRepository = app()->make(UserRepository::class);//先走一遍注册 try { $zhitui_rate_setting = systemConfig('zhitui_rate'); $zhitui_rate = $zhitui_rate_setting['zhitui_rate'] ?? 0; $zhitui_user_rate = $zhitui_rate_setting['zhitui_user_rate'] ?? 0; $chuangke_user_list = Db::name('user')->field('uid,user_group,phone')->where('user_group', 4)->select()->toArray(); foreach ($chuangke_user_list as $chuangke_user) { $child_uids = Db::name('user')->where('spread_uid', $chuangke_user['uid'])->column('uid'); if (!$child_uids) continue; $store_order_list = Db::name('store_order')->where('paid', 1) ->where('is_settlement', 1) ->whereIn('status', [0, 1, 2, 3]) ->whereIn('uid', $child_uids) ->select() ->toArray(); foreach ($store_order_list as $store_order) { $zhitui_rate1 = $store_order['total_price'] >= 19800 ? $zhitui_rate : $zhitui_user_rate; $total_price = $store_order['total_price'] + $store_order['youhui_price'];; $zhitui_money = round($total_price* $zhitui_rate1 * 0.01, 1); $user_bill = Db::name('user_bill') ->where('commission_type', 3) ->where('link_id', $store_order['order_id']) ->where('order_sn', $store_order['order_sn']) ->find(); if (empty($user_bill)) { echo "{$chuangke_user['phone']}应获得佣金{$zhitui_money} 订单号{$store_order['order_sn']} 实际获得0\r\n"; } else if ($zhitui_money != $user_bill['number']) { echo "{$chuangke_user['phone']}应获得佣金{$zhitui_money} 订单号{$store_order['order_sn']} 实际获得{$user_bill['number']}\r\n"; } $user_bill = Db::name('user_bill') ->where('commission_type', 3) ->where('link_id', $store_order['order_id']) ->where('order_sn', $store_order['order_sn']) ->find(); if (empty($user_bill)) { echo "{$chuangke_user['phone']}应获得佣金{$zhitui_money} 订单号{$store_order['order_sn']} 实际获得0\r\n"; } else if ($zhitui_money != $user_bill['number']) { echo "{$chuangke_user['phone']}应获得佣金{$zhitui_money} 订单号{$store_order['order_sn']} 实际获得{$user_bill['number']}\r\n"; $zhitui_money = $zhitui_money-$user_bill['number']; } $user_nick_name = $user['nickname'] ?? ''; $mark = $user_nick_name.'购买商品'; $title = "直推奖".date('m.d'); $commission_type = 3; $this->add_bill_gongfu($title, $zhitui_money, $chuangke_user['uid'], $mark, $commission_type, $store_order['order_sn'], $store_order['order_id'], $store_order['mer_id'], 0, 0,$store_order['pay_time']); } } return; $list = Db::connect('chuxubao')->query("select uid,phone,spread_uid from rrx_user where is_del=0 and is_show=2"); $is_run_mobile_list = []; foreach ($list as $chuxubao_user) { $childSpreadUidList = Db::connect('chuxubao')->query("select chuxubao.getUserSpreadId({$chuxubao_user['uid']}) as uids"); $count[0]['uids'] = trim($childSpreadUidList[0]['uids'], '$,'); $resultArray = explode(",", $count[0]['uids']); foreach ($resultArray as $reg_uid) { //查询储蓄保和上级 $reg_user = Db::connect('chuxubao')->query("select * from chuxubao.rrx_user where uid={$reg_uid} and is_del=0")[0] ?? []; if (!$reg_user) { continue; } $reg_spread_user = Db::connect('chuxubao')->query("select * from chuxubao.rrx_user where uid={$reg_user['spread_uid']} and is_del=0")[0] ?? [];; if (!$reg_spread_user) { continue; } if (in_array($reg_user['phone'], $is_run_mobile_list)) { continue; } $is_run_mobile_list[] = $reg_user['phone']; //储蓄宝在一壶茶上级 $yihucha_spread_user = Db::name('user')->where('phone', $reg_spread_user['phone'])->where('is_del', 0)->find(); //查询一壶茶 $yihucha_user = Db::name('user')->where('phone', $reg_user['phone'])->where('is_del', 0)->find(); //一壶茶用户原上级 $yihucha_puser = Db::name('user')->where('uid', $yihucha_user['spread_uid'])->where('is_del', 0)->find(); if (!$yihucha_user) { $userRepository->registr($reg_user['phone'], $yihucha_spread_user['uid'], 'h5', 0); // echo "{$reg_user['phone']}需要注册注册 邀请人{$chuxubao_user['phone']}\r\n"; } else { if (empty($yihucha_user['spread_uid'])) { //一壶茶上级为空 直接绑定上级 Db::name('user')->where('uid', $yihucha_user['uid'])->update(['spread_uid' => $yihucha_spread_user['uid']]); } else if ($yihucha_user['spread_uid'] != $yihucha_spread_user['uid']) { //暂时不作操作 echo "{$reg_user['phone']}已注册,有邀请人并且邀请人不是储蓄保上级 需要注意 储蓄保邀请人{$reg_spread_user['phone']} 一壶茶邀请人{$yihucha_puser['phone']}\r\n"; } } } } } catch (Exception $e) { var_dump($e->getFile() . ':' . $e->getLine() . '【' . $e->getMessage()); } return; $list = Db::connect('chuxubao')->query("select u.uid,u.phone,u.spread_uid,su.phone spread_phone from rrx_user u left join rrx_user su on su.uid=u.spread_uid where u.uid in ( select uid from rrx_enterprise_user ) and u.is_del=0"); var_dump($list); $userRepository = app()->make(UserRepository::class); //先走一遍注册 foreach ($list as $reg_user) { $user = Db::name('user')->where('phone', $reg_user['phone'])->find(); if (!$user) { $userRepository->registr($reg_user['phone'], null, 'h5', 0); echo "{$reg_user['phone']}注册成功\r\n"; } } // 再走一遍绑定关系 foreach ($list as $reg_user) { $user = Db::name('user')->where('phone', $reg_user['phone'])->find(); $spread_user = Db::name('user')->where('phone', $reg_user['spread_phone'])->find(); if ($spread_user && $user['spread_uid'] != $spread_user['uid']) { Db::name('user')->where('uid', $user['uid'])->update(['spread_uid' => $spread_user['uid']]); echo "{$reg_user['phone']}上级绑定成功{$reg_user['spread_phone']}\r\n"; } } return; $this->take(); return; $OrderGzcRepository = app()->make(OrderGzcRepository::class); // $uid = $OrderGzcRepository->register(15210999641); $uid = $OrderGzcRepository->gzc(1,0.01); var_dump($uid); return ; $order_list = Db::name('store_order') ->where('paid', 1) ->where('is_settlement', 1) ->select() ->toArray(); $storeOrderRepository = app()->make(StoreOrderRepository::class); foreach ($order_list as $order) { $storeOrderRepository->close_order($order['order_id']); } return; $data = [ 'a' => 21, 'b' => 22 ]; ksort($data); $params = ''; foreach ($data as $key => $value) { $params .= '&' . $key . '=' . $value; } $params = ltrim($params, '&'); $sign = strtoupper(md5($params . '&key=' . self::$thirdKey . '&signKey=' . self::$thirdsignKey . '×tamp=' . time())); var_dump($params . '&key=' . self::$thirdKey . '&signKey=' . self::$thirdsignKey . '×tamp=' . time()); var_dump($sign); $checkSign = Signature::thirdCheckSign($data, ['sign' => $sign,]); var_dump($checkSign); return; $list = Db::table('sheet1')->select()->toArray(); // foreach ($list as $val){ // if(empty($val['id'])) // continue; // $merchant_member = Db::name('merchant_member')->where('member_id', $val['member_id'])->find(); // // if ($merchant_member) { // Db::name('merchant_member')->where('member_id', $val['member_id'])->update([ // 'settle_account_id' => '0' . $val['id'] // ]); // } // } // return $list; $merchant_list = Db::name('merchant') ->select() ->toArray(); $key_list = [ 1 => 'api_live_b23537ed-64b8-45d6-832e-fb228aa9e0a9', 2 => 'api_live_90ef02e4-54ac-41ee-adf1-e4927d23d58f', 3 => 'api_live_b0a687ec-5450-4ada-a0e4-65bac0f46871' ]; $appid_list = [ 1 => 'app_44108546-d27a-48ee-88c1-84b45b75114f', 2 => 'app_0827b960-b932-45ec-b800-4e850091b419', 3 => 'app_383a75dd-c03d-44ab-8f58-92c60fe9b9d0' ]; $merber = new SettleAccount(); // $params = [ //// 'member_id' => 'jsdk_member_wx21689732717371', //'member_id' => '0', //'api_key' => $key_list[3] // ]; $mer_id = 592; // $merchant_intention = Db::name('merchant_intention') // ->where('mer_id', $mer_id) // ->find(); // $params = [ // 'app_id' => $appid_list[3], // 'member_id' => 'jsdk_member_wx21710727780769', // 'channel' => 'bank_account', // 'account_info' => [ // 'card_id' => $merchant_intention['bank_account'],//银行卡号 // 'card_name' => $merchant_intention['name'],//银行卡对应的户名 // 'cert_id' => $merchant_intention['idcard_no'],//证件号,银行账户类型为对私时,必填 // 'cert_type' => '00',//证件类型,仅支持:00-身份证,银行账户类型为对私时,必填 // 'tel_no' => $merchant_intention['phone'],//手机号 // 'bank_acct_type' => 2//银行账户类型:1-对公;2-对私 // ], // ]; // var_dump($params); // $merber->create($params, $key_list[3]); // $res = $merber->result; // var_dump($res); // $params = [ // 'app_id' => $appid_list[3], // 'member_id' => 'jsdk_member_1712631889320', // 'settle_account_id' => '0594907212710080', // 'api_key' => $key_list[3], // 'acct_type' => '03', // ]; // var_dump($params); // $merber = new SettleAccount(); // $merber->query($params); // $res = $merber->result; // var_dump($res); // return; $merchant_member_list = Db::name('merchant_member') ->column('mer_id,type,member_id,settle_account_id'); foreach ($merchant_member_list as $merchant_member) { $mer_id = $merchant_member['mer_id']; if (empty($mer_id)) continue; if (empty($merchant_member['settle_account_id'])) continue; $params = [ 'app_id' => $appid_list[$merchant_member['type']], 'member_id' => $merchant_member['member_id'], 'settle_account_id' => $merchant_member['settle_account_id'], 'api_key' => $key_list[$merchant_member['type']] ]; $merber = new SettleAccount(); $merber->balance($params); $merber->result; if (isset($merber->result[1])) { $result = json_decode($merber->result[1], true); $result = json_decode($result['data'], true); $result['avl_balance'] = $result['avl_balance'] ?? 0; if ($result['avl_balance'] > 0) { $payment_id = ShouxinyiApiRequest::getOrderNumber('split'); $params = [ 'order_no' => $payment_id, 'app_id' => $appid_list[$merchant_member['type']], 'cash_type' => 'T1', 'cash_amt' => sprintf("%01.2f", $result['avl_balance']), 'member_id' => $merchant_member['member_id'], 'api_key' => $key_list[$merchant_member['type']] ]; Db::name("log")->insert(array('data' => '汇付取现参数-----' . json_encode($params)));//日志记录 $merber = new Drawcash(); $merber->create($params); # 返回查询结果 $merber->isError(); $res = $merber->result; Db::name("log")->insert(array('data' => '汇付延时分账-----' . json_encode($res))); //日志记录 Db::name("log")->insert(array('data' => "mer_id {$mer_id} 请求分账{$result['avl_balance']}元-----"));//日志记录 var_dump("mer_id {$mer_id} 请求分账{$result['avl_balance']}元-----"); return; } } } // var_dump($merchant_member_list); // return; return; $refundMake = app()->make(StoreRefundOrderRepository::class); $storeOrderRepository = app()->make(StoreOrderRepository::class); $key = 'api_live_b0a687ec-5450-4ada-a0e4-65bac0f46871'; $member_id = 'jsdk_member_wx21710232183139'; $app_id = 'app_383a75dd-c03d-44ab-8f58-92c60fe9b9d0'; // //split_171250769195432933 // //split_171250766710946855 // //split_171250756308518692 // //split_171250756308518692 //split_171250824291283553 $params = [ 'order_no' => 'split_171250857280339363', 'api_key' => $key ]; $merber = new Drawcash(); $merber->query($params); # 返回查询结果 $merber->isError(); var_dump($merber); $res = $merber->result; return null; $payment_id = ShouxinyiApiRequest::getOrderNumber('split'); $params = [ 'order_no' => $payment_id, 'app_id' => $app_id, 'cash_type' => 'T1', 'cash_amt' => '0.50', 'member_id' => $member_id, 'remark' => '养老金', 'api_key' => $key ]; Db::name("log")->insert(array('data' => '汇付取现参数-----' . json_encode($params)));//日志记录 $merber = new Drawcash(); $merber->create($params); # 返回查询结果 $merber->isError(); $res = $merber->result; Db::name("log")->insert(array('data' => '汇付延时分账-----' . json_encode($res)));//日志记录 var_dump($merber); return $merber->result; // 创建取现对象 var_dump(date('H:i')); return; //公证处 //2 jsdk_member_wx1710231128628 //3 jsdk_member_wx21710232183139 //1 jsdk_member_ali1710232187326 //WX171205067143565297 002212024040217375110621169693733044224 //WX171205073720275677 002212024040217385710621169969109147648 //WX171205077431982682 002212024040217393410621170124857163776 $payment_id = ShouxinyiApiRequest::getOrderNumber('split'); $insertData = [ [ 'mid' => 0, 'requestId' => $payment_id, 'group_order_id' => 'WX171205067143565292', 'splitAmount' => 0.25, 'status' => 0 ], ]; $div_members[] = [ 'member_id' => $member_id, 'amount' => '0.25', 'fee_flag' => 'Y' ]; //////分账表 Db::name("store_split_order")->insertAll($insertData); /// 分账表end $params = [ 'payment_id' => '002212024040218261010621181853790355456', 'order_no' => $payment_id, 'confirm_amt' => '0.25', 'div_members' => $div_members ]; $params['api_key'] = $key; var_dump($params); Db::name("log")->insert(array('data' => '汇付延时分账参数-----' . json_encode($params)));//日志记录 $res = $storeOrderRepository->payment_confirm_create_traits($params); Db::name("log")->insert(array('data' => '汇付延时分账-----' . json_encode($res)));//日志记录 var_dump($res); // 分账 return; $storeOrderRepository = app()->make(StoreOrderRepository::class); $storeOrderRepository->douhuomall_delivery(); // var_dump( GongApiRequest::order_details('W202404061500443232427')); return; // $depositInfo = [ // 'conName' => '刘建',//消费者姓名 // 'conTel' => '15210999641',//消费者电话 // 'conCertType' => 1,//消费者证件类型 // 'conCertNo' => '130433199808212911',//消费者证件号 // 'conIsAuth' => 1,//消费者在平台是否已实名 // 'amount' => bcmul('0.25', '100'),//消费者存入的消费养老金额 // 'depositDt' => '2024-04-03 18:01:18',//入账时间 // ]; // $depositInfo['bankName'] = '中国民生银行'; // $depositInfo['branchName'] = '中国民生银行股份有限公司北京劲松支行'; // $depositInfo['bankAccount'] = '629966688'; // $depositInfo['bankPaymentFlow'] = '313002023122702917666735446EB285'; // $depositInfo['accountType'] = 1; $depositInfo = [ 'conName' => '何海强', //消费者姓名 'conTel' => '19931699683', //消费者电话 'conCertType' => 1, //消费者证件类型 'conCertNo' => '130433199808212911', //消费者证件号 'conIsAuth' => 1, //消费者在平台是否已实名 'amount' => bcmul('0.01', '100'), //消费者存入的消费养老金额 'depositDt' => '2024-04-03 18:01:19',//入账时间 ]; $depositInfo['bankName'] = '中国民生银行'; $depositInfo['branchName'] = '中国民生银行股份有限公司北京劲松支行'; $depositInfo['bankAccount'] = '629966688'; $depositInfo['bankPaymentFlow'] = '313002023122702917666735446EB285'; $depositInfo['accountType'] = 1; $applys[] = $depositInfo; $OrderMerchantRepository = app()->make(OrderMerchantRepository::class); $orderId = $OrderMerchantRepository->getNewOrderId('IN10'); $OrderGzcRepository = app()->make(OrderGzcRepository::class); $q = $OrderGzcRepository->doInGzc(['platform_no' => $orderId], $applys); var_dump($q); return; $spuIds = '10029352697750'; $res = GongApiRequest::goods_status($spuIds); $res1 = GongApiRequest::get_goods_info($spuIds); // var_dump($res); // var_dump($res1); $product_data = Db::name('store_product') ->where("spu_id != '' or spu_id is not null") ->where('product_id', 12622) ->order('product_id asc') ->limit(0, 50) ->select() ->toArray(); foreach ($product_data as $item) { $spuIds = $item['spu_id']; $goods_status = GongApiRequest::goods_status($spuIds); var_dump($goods_status); $status = $goods_status[0]['status'] ?? 1; $goods_info = GongApiRequest::get_goods_info($spuIds); var_dump($goods_info); if ($status == 0 || (isset($goods_info['error_msg']) && $goods_info['error_msg'] == '没有查询到商品信息')) { var_dump('下架'); } } return; return; // 退款 $refund_traits = [ 'id' => '002212024040218261010621181853790355456', 'refund_order_no' => $refundMake->getNewOrderId(), 'refund_amt' => '1.00', ]; $hf_refund_res = $refundMake->Payment_refund_traits($refund_traits, $key, 3); var_dump($hf_refund_res); Db::name('log')->insert(['data' => '汇付退款返回结果:' . json_encode($hf_refund_res)]); return; // $data = []; // $re=app()->make(UserRepository::class)->daoruUser($data); // var_dump($re); // return; $where = [ 'is_used' => 1, 'mer_status' => 1, // 'type' => 5, // 'is_show' => 1, 'is_hide' => 0, // 'is_del' => 0 ]; $product_data = Db::name('store_product') ->where($where) ->where("spu_id != '' or spu_id is not null") ->where('product_id', '>', 12630) ->order('product_id asc') ->fetchSql(true) ->limit(0, 50) ->select(); var_dump($product_data); $spuIds = '9ed876a65570'; $res = GongApiRequest::goods_status($spuIds); $res1 = GongApiRequest::get_goods_info($spuIds); var_dump($res); var_dump($res1); return $this->appid = '4100076550';; $this->key = '5ce3da55dc739b6e7d9021d59618c5faa3b4030f41c5699658c7ca30cfd19f09b4046d606d196f1d'; $this->appKey = 'a2ad5078501e928b991cd8aaeb0446dc'; $this->secretKey = 'fd8aab59e9b94d9e889cb22838c03f2a'; $this->userThird = app()->make(UserThirdRepository::class); $this->url = 'https://api.jd.com/routerjson'; // 指令输出 $output->writeln('pensiontask'); // (new Access())->test1111(); $this->get_jd_goods_list(); // app()->make(Jd::class)->get_jd_goods_list(); // $product_share_ids = Db::name('product_share') // ->where("`url` is null or `url` ='' ") // ->group('product_id') // ->column('product_id'); // // $list = Db::name('store_product') // ->whereNotIn('product_id',$product_share_ids) // ->where('is_show',1) // ->order('create_time desc') // ->select() // ->toArray(); // // // $header = [ // 'X-Token: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJhcHAuYmp0ZGJhLmNvbSIsImF1ZCI6ImFwcC5ianRkYmEuY29tIiwiaWF0IjoxNjk2Mzg5MzM2LCJuYmYiOjE2OTYzODkzMzYsImV4cCI6MTcwNzE4OTMzNiwianRpIjpbMTA1NzQsInVzZXIiXX0.15FqgSFYfy-9OKtgeIPV7M5Pj6lHHr83c7GPt5lZik4' // ]; // foreach ($list as $store_product) { // $res1 = Common::sendCurl("https://app.bjtdba.com/api/product_share?pid={$store_product['product_id']}&type=1", null, 'get', $header); // $res2 = Common::sendCurl("https://app.bjtdba.com/api/product_share?pid={$store_product['product_id']}&type=2", null, 'get', $header); // var_dump($res1, $res2); // } } public function get_jd_goods_list() { $eliteIdList = [ '1', //好券商品 // '2', //精选卖场 // '10', //9.9包邮 // '15', //京东配送 // '22', //实时热销榜 //// '23', //为你推荐 // '24', //数码家电 // '25', //超市 // '26', //母婴玩具 // '27', //家具日用 // '28', //美妆穿搭 // '30', //图书文具 // '31', //今日必推 // '32', //京东好物 // '33', //京东秒杀 // '34', //拼购商品 // '40', //高收益榜 // '41', //自营热卖榜 //// '108', //秒杀进行中 // '109', //新品首发 // '110', //自营 // '112', //京东爆品 // '125', //首购商品 // '129', //高佣榜单 //// '130', //视频商品 // '153', //历史最低价商品榜 //// '238', //新人价商品 //// '315', //秒杀未开始 // '341', //3C新品 // '342', //智能新品 // '343', //3C长尾商品 // '345', //时尚新品 // '346', //时尚爆品 // '1001', //选品库 //// '515', //订单接龙商品 // '519', //官方活动 // '12254', //超级补贴 // '12318', //便宜包邮 // '12339', //超市卡 ]; set_time_limit(0); // $eliteIdList = [1]; foreach ($eliteIdList as $eliteId) { for ($page = 1; $page <= 10000; $page++) { $apiName = 'jd.union.open.goods.jingfen.query'; $params = [ 'goodsReq' => [ 'eliteId' => $eliteId, 'pageIndex' => $page ?? 1, 'pageSize' => 1, ] ]; $result = $this->getUrlResult($apiName, $params); $result = json_decode($result, true); $result = json_decode($result['jd_union_open_goods_jingfen_query_responce']['queryResult'], true); $result = $result['data'] ?? []; if (empty($result)) break; $this->formatGoodsList($result ?? []); } } } //格式化从京东联盟获取到的商品列表 public function formatGoodsList($goodsList) { $insertList = []; foreach ($goodsList as $goods) { $commissionMoney = $goods['commissionInfo']['commission'] ?? 0; //养老金 $oldMoney = app()->make(ProductRepository::class)->yanglaojin(0, $commissionMoney); // var_dump($goods); // return; if ($oldMoney < 0.1) continue; if (!isset($goods['couponInfo']['couponList'][0])) continue; foreach ($goods['couponInfo']['couponList'] as $coupon) { } $goods['couponInfo']['couponList'][0]['getStartTime'] = date('Y-m-d', intval($goods['couponInfo']['couponList'][0]['getStartTime'] / 1000)); $goods['couponInfo']['couponList'][0]['getEndTime'] = date('Y-m-d', intval($goods['couponInfo']['couponList'][0]['getEndTime'] / 1000)); $formatList = [ 'type' => 6, //京东商品 'skuId' => $goods['skuId'], //skuid 'id' => $goods['brandCode'] ?? '', //id 'thumb' => $goods['imageInfo']['imageList'][0]['url'] ?? '', //商品缩略图 'name' => $goods['skuName'], //名称 'commission' => $oldMoney, //佣金 'commission_rate' => $goods['commissionInfo']['commissionShare'] ?? '',//佣金比例 'sales' => "", 'coupon_money' => $goods['couponInfo']['couponList'] ?? [], 'lowestCouponPrice' => decimal2($goods['priceInfo']['lowestCouponPrice']), //券后价lowestCouponPrice 'price' => $goods['priceInfo']['price'], //价格 'imageList' => array_column($goods['imageInfo']['imageList'], 'url'), //图片合集 ]; $insertList[] = ['json' => json_encode($formatList, JSON_UNESCAPED_UNICODE), 'pension' => $oldMoney, 'type' => 2]; // break; } if ($insertList) { Db::name("third_party_goods")->insertAll($insertList); } // return $formatList; } //返回请求参数链接 public function getUrlResult($apiName = "", $params = []) { if (empty($apiName)) { return false; } //公共请求参数 $requestParams = [ 'method' => $apiName, 'format' => 'json', 'app_key' => $this->appKey, 'timestamp' => date('Y-m-d H:i:s'), 'v' => '1.0', 'sign_method' => 'md5', '360buy_param_json' => json_encode($params) ]; $orderData = $this->paramOrder($requestParams); $sign = $this->paramSign($orderData); $requestParams['sign'] = $sign; $res = $this->apiSign($requestParams); return $res; } //为空检查 protected function checkEmpty($value) { if (!isset($value)) return true; if ($value === null) return true; if (trim($value) === "") return true; return false; } //编码设置 public function characet($data, $targetCharset) { if (!empty($data)) { $fileType = 'utf-8'; if (strcasecmp($fileType, $targetCharset) != 0) { $data = mb_convert_encoding($data, $targetCharset, $fileType); } } return $data; } //签名 public function paramSign($params) { $str = $this->secretKey . $params . $this->secretKey; $sign = md5($str); return strtoupper($sign); } public function apiSign($param) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $this->url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $param); curl_setopt($ch, CURLOPT_TIMEOUT, 60); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); $data = curl_exec($ch); curl_close($ch); return $data; } //排序ksort public function paramOrder($params) { ksort($params); $stringToBeSigned = ""; $i = 0; foreach ($params as $k => $v) { if (false === $this->checkEmpty($v)) { $v = $this->characet($v, 'utf-8'); if ($i == 0) { $stringToBeSigned .= "$k" . "$v"; } else { $stringToBeSigned .= "$k" . "$v"; } $i++; } } unset ($k, $v); return $stringToBeSigned; } }