TestTask.php 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910
  1. <?php
  2. declare (strict_types=1);
  3. namespace app\command;
  4. use AdaPaySdk\Drawcash;
  5. use AdaPaySdk\PaymentConfirm;
  6. use AdaPaySdk\SettleAccount;
  7. use app\common\model\merchant\order\OrderMerchant;
  8. use app\common\model\store\order\StoreOrder;
  9. use app\common\model\user\User;
  10. use app\common\model\user\UserCertification;
  11. use app\common\repositories\merchant\order\OrderGzcRepository;
  12. use app\common\repositories\merchant\order\OrderMerchantRepository;
  13. use app\common\repositories\store\order\StoreOrderStatusRepository;
  14. use app\common\repositories\store\order\StoreRefundOrderRepository;
  15. use app\common\repositories\store\product\ProductRepository;
  16. use app\common\repositories\user\UserBillRepository;
  17. use app\common\repositories\user\UserRepository;
  18. use app\common\repositories\user\UserThirdRepository;
  19. use app\controller\api\Common;
  20. use app\controller\api\merchant\sxy\Access;
  21. use app\controller\api\store\product\Jd;
  22. use app\controller\api\util\Signature;
  23. use app\traits\GongApiRequest;
  24. use app\traits\GzcApiRequest;
  25. use app\traits\ShouxinyiApiRequest;
  26. use Carbon\Carbon;
  27. use think\App;
  28. use think\console\Command;
  29. use think\console\Input;
  30. use think\console\Output;
  31. use think\db\exception\DataNotFoundException;
  32. use think\db\exception\DbException;
  33. use think\db\exception\ModelNotFoundException;
  34. use think\Exception;
  35. use think\facade\Db;
  36. use think\facade\Log;
  37. use app\common\repositories\store\order\StoreOrderRepository;
  38. use think\facade\Request;
  39. /**
  40. * Class PensionTasks
  41. * @package app\command
  42. * @author: php迷途小书童
  43. * @created: 2021/3/19 9:14
  44. */
  45. class TestTask extends Command
  46. {
  47. /**
  48. * @var string
  49. */
  50. private $appid;
  51. /**
  52. * @var string
  53. */
  54. private $appKey;
  55. /**
  56. * @var string
  57. */
  58. private $secretKey;
  59. /**
  60. * @var string
  61. */
  62. private $url;
  63. private static $thirdKey = 'mtizndu2c3nzywe';
  64. private static $thirdsignKey = '93b8004c63cb098c7c7cf5ca98d9898bc00107b073906df132b140f8fa1ee160e206d8ab';
  65. protected function configure()
  66. {
  67. // 指令配置
  68. $this->setName('testtask')
  69. ->setDescription('the testtask command');
  70. }
  71. /**
  72. * 商户批量取现
  73. */
  74. public function take()
  75. {
  76. $key_list = [
  77. 1 => 'api_live_b23537ed-64b8-45d6-832e-fb228aa9e0a9',
  78. 2 => 'api_live_90ef02e4-54ac-41ee-adf1-e4927d23d58f',
  79. 3 => 'api_live_b0a687ec-5450-4ada-a0e4-65bac0f46871'
  80. ];
  81. $appid_list = [
  82. 1 => 'app_44108546-d27a-48ee-88c1-84b45b75114f',
  83. 2 => 'app_0827b960-b932-45ec-b800-4e850091b419',
  84. 3 => 'app_383a75dd-c03d-44ab-8f58-92c60fe9b9d0'
  85. ];
  86. $merchant_member_list = Db::name('merchant_member')
  87. ->where('member_id', 'jsdk_member_wx21700447226310')
  88. ->where('settle_account_id', '0544998840384192')
  89. ->column('mer_id,type,member_id,settle_account_id');
  90. foreach ($merchant_member_list as $merchant_member) {
  91. $mer_id = $merchant_member['mer_id'];
  92. if (empty($mer_id))
  93. continue;
  94. if (empty($merchant_member['settle_account_id']))
  95. continue;
  96. $params = [
  97. 'app_id' => $appid_list[$merchant_member['type']],
  98. 'member_id' => $merchant_member['member_id'],
  99. 'settle_account_id' => $merchant_member['settle_account_id'],
  100. 'api_key' => $key_list[$merchant_member['type']]
  101. ];
  102. $merber = new SettleAccount();
  103. $merber->balance($params);
  104. $merber->result;
  105. if (isset($merber->result[1])) {
  106. $result = json_decode($merber->result[1], true);
  107. $result = json_decode($result['data'], true);
  108. $result['avl_balance'] = $result['avl_balance'] ?? 0;
  109. if ($result['avl_balance'] > 0) {
  110. $payment_id = ShouxinyiApiRequest::getOrderNumber('split');
  111. $params = [
  112. 'order_no' => $payment_id,
  113. 'app_id' => $appid_list[$merchant_member['type']],
  114. 'cash_type' => 'T1',
  115. 'cash_amt' => sprintf("%01.2f", $result['avl_balance']),
  116. 'member_id' => $merchant_member['member_id'],
  117. 'api_key' => $key_list[$merchant_member['type']]
  118. ];
  119. Db::name("log")->insert(array('data' => '汇付取现参数-----' . json_encode($params)));//日志记录
  120. $merber = new Drawcash();
  121. $merber->create($params);
  122. # 返回查询结果
  123. $merber->isError();
  124. $res = $merber->result;
  125. Db::name("log")->insert(array('data' => '汇付延时分账-----' . json_encode($res))); //日志记录
  126. Db::name("log")->insert(array('data' => "mer_id {$mer_id} 请求分账{$result['avl_balance']}元-----"));//日志记录
  127. var_dump("mer_id {$mer_id} 请求分账{$result['avl_balance']}元-----");
  128. return;
  129. }
  130. }
  131. }
  132. }
  133. 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)
  134. {
  135. if ($number == 0) {
  136. return;
  137. }
  138. $currency = ($type == 'commission' ? 'brokerage_price' : 'score');
  139. $number = decimal2($number);
  140. $data = [
  141. 'link_id' => $order_id,//关联订单id
  142. "uid" => $uid,
  143. "pm" => 1,
  144. "title" => $title,
  145. "category" => "now_money",
  146. "type" => $type,//明细类型 commission佣金 integral积分
  147. "number" => $number,
  148. "mark" => $mark,
  149. "status" => $status,//0 = 待确定 1 = 有效 -1 = 无效
  150. "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创客补贴√',
  151. "order_sn" => $order_sn,//订单号
  152. "mer_id" => $mer_id,//商户id
  153. "source" => $source,//积分
  154. "month" => $month,//奖励月份
  155. "type_shop" => 0,//0平台1多多进宝2唯品会3苏宁易购4网易考拉5淘宝客6京东联盟7饿了么8线上
  156. 'create_time'=>$create_time
  157. ];
  158. if ($status == 1) {
  159. $data['take_time'] = time();
  160. //商户佣金类型处理
  161. if (in_array($commission_type, [7,12,19])) {
  162. $balance = Db::name('merchant')->where('mer_id', $mer_id)->value($currency);
  163. $data['balance'] = decimal2($balance);
  164. Db::name("merchant")->where("mer_id", $mer_id)->inc($currency, $number)->update();
  165. } else {
  166. $balance = Db::name('user')->where('uid', $uid)->value($currency);
  167. $data['balance'] = decimal2($balance);
  168. Db::name("user")->where("uid", $uid)->inc($currency, $number)->update();
  169. }
  170. Db::name('log')->insert(['data' => "{$title}佣金增加{$number}," . json_encode($data)]);
  171. }
  172. Db::name("user_bill")->insert($data);
  173. }
  174. protected function execute(Input $input, Output $output)
  175. {
  176. $userRepository = app()->make(UserRepository::class);//先走一遍注册
  177. try {
  178. $zhitui_rate_setting = systemConfig('zhitui_rate');
  179. $zhitui_rate = $zhitui_rate_setting['zhitui_rate'] ?? 0;
  180. $zhitui_user_rate = $zhitui_rate_setting['zhitui_user_rate'] ?? 0;
  181. $chuangke_user_list = Db::name('user')->field('uid,user_group,phone')->where('user_group', 4)->select()->toArray();
  182. foreach ($chuangke_user_list as $chuangke_user) {
  183. $child_uids = Db::name('user')->where('spread_uid', $chuangke_user['uid'])->column('uid');
  184. if (!$child_uids)
  185. continue;
  186. $store_order_list = Db::name('store_order')->where('paid', 1)
  187. ->where('is_settlement', 1)
  188. ->whereIn('status', [0, 1, 2, 3])
  189. ->whereIn('uid', $child_uids)
  190. ->select()
  191. ->toArray();
  192. foreach ($store_order_list as $store_order) {
  193. $zhitui_rate1 = $store_order['total_price'] >= 19800 ? $zhitui_rate : $zhitui_user_rate;
  194. $total_price = $store_order['total_price'] + $store_order['youhui_price'];;
  195. $zhitui_money = round($total_price* $zhitui_rate1 * 0.01, 1);
  196. $user_bill = Db::name('user_bill')
  197. ->where('commission_type', 3)
  198. ->where('link_id', $store_order['order_id'])
  199. ->where('order_sn', $store_order['order_sn'])
  200. ->find();
  201. if (empty($user_bill)) {
  202. echo "{$chuangke_user['phone']}应获得佣金{$zhitui_money} 订单号{$store_order['order_sn']} 实际获得0\r\n";
  203. } else if ($zhitui_money != $user_bill['number']) {
  204. echo "{$chuangke_user['phone']}应获得佣金{$zhitui_money} 订单号{$store_order['order_sn']} 实际获得{$user_bill['number']}\r\n";
  205. }
  206. $user_bill = Db::name('user_bill')
  207. ->where('commission_type', 3)
  208. ->where('link_id', $store_order['order_id'])
  209. ->where('order_sn', $store_order['order_sn'])
  210. ->find();
  211. if (empty($user_bill)) {
  212. echo "{$chuangke_user['phone']}应获得佣金{$zhitui_money} 订单号{$store_order['order_sn']} 实际获得0\r\n";
  213. } else if ($zhitui_money != $user_bill['number']) {
  214. echo "{$chuangke_user['phone']}应获得佣金{$zhitui_money} 订单号{$store_order['order_sn']} 实际获得{$user_bill['number']}\r\n";
  215. $zhitui_money = $zhitui_money-$user_bill['number'];
  216. }
  217. $user_nick_name = $user['nickname'] ?? '';
  218. $mark = $user_nick_name.'购买商品';
  219. $title = "直推奖".date('m.d');
  220. $commission_type = 3;
  221. $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']);
  222. }
  223. }
  224. return;
  225. $list = Db::connect('chuxubao')->query("select uid,phone,spread_uid from rrx_user where is_del=0 and is_show=2");
  226. $is_run_mobile_list = [];
  227. foreach ($list as $chuxubao_user) {
  228. $childSpreadUidList = Db::connect('chuxubao')->query("select chuxubao.getUserSpreadId({$chuxubao_user['uid']}) as uids");
  229. $count[0]['uids'] = trim($childSpreadUidList[0]['uids'], '$,');
  230. $resultArray = explode(",", $count[0]['uids']);
  231. foreach ($resultArray as $reg_uid) {
  232. //查询幸福宝和上级
  233. $reg_user = Db::connect('chuxubao')->query("select * from chuxubao.rrx_user where uid={$reg_uid} and is_del=0")[0] ?? [];
  234. if (!$reg_user) {
  235. continue;
  236. }
  237. $reg_spread_user = Db::connect('chuxubao')->query("select * from chuxubao.rrx_user where uid={$reg_user['spread_uid']} and is_del=0")[0] ?? [];;
  238. if (!$reg_spread_user) {
  239. continue;
  240. }
  241. if (in_array($reg_user['phone'], $is_run_mobile_list)) {
  242. continue;
  243. }
  244. $is_run_mobile_list[] = $reg_user['phone'];
  245. //储蓄宝在一壶茶上级
  246. $yihucha_spread_user = Db::name('user')->where('phone', $reg_spread_user['phone'])->where('is_del', 0)->find();
  247. //查询一壶茶
  248. $yihucha_user = Db::name('user')->where('phone', $reg_user['phone'])->where('is_del', 0)->find();
  249. //一壶茶用户原上级
  250. $yihucha_puser = Db::name('user')->where('uid', $yihucha_user['spread_uid'])->where('is_del', 0)->find();
  251. if (!$yihucha_user) {
  252. $userRepository->registr($reg_user['phone'], $yihucha_spread_user['uid'], 'h5', 0);
  253. // echo "{$reg_user['phone']}需要注册注册 邀请人{$chuxubao_user['phone']}\r\n";
  254. } else {
  255. if (empty($yihucha_user['spread_uid'])) {
  256. //一壶茶上级为空 直接绑定上级
  257. Db::name('user')->where('uid', $yihucha_user['uid'])->update(['spread_uid' => $yihucha_spread_user['uid']]);
  258. } else if ($yihucha_user['spread_uid'] != $yihucha_spread_user['uid']) {
  259. //暂时不作操作
  260. echo "{$reg_user['phone']}已注册,有邀请人并且邀请人不是幸福宝上级 需要注意 幸福宝邀请人{$reg_spread_user['phone']} 一壶茶邀请人{$yihucha_puser['phone']}\r\n";
  261. }
  262. }
  263. }
  264. }
  265. } catch (Exception $e) {
  266. var_dump($e->getFile() . ':' . $e->getLine() . '【' . $e->getMessage());
  267. }
  268. return;
  269. $list = Db::connect('chuxubao')->query("select u.uid,u.phone,u.spread_uid,su.phone spread_phone from rrx_user u
  270. left join rrx_user su on su.uid=u.spread_uid
  271. where u.uid in (
  272. select uid from rrx_enterprise_user
  273. ) and u.is_del=0");
  274. var_dump($list);
  275. $userRepository = app()->make(UserRepository::class);
  276. //先走一遍注册
  277. foreach ($list as $reg_user) {
  278. $user = Db::name('user')->where('phone', $reg_user['phone'])->find();
  279. if (!$user) {
  280. $userRepository->registr($reg_user['phone'], null, 'h5', 0);
  281. echo "{$reg_user['phone']}注册成功\r\n";
  282. }
  283. }
  284. // 再走一遍绑定关系
  285. foreach ($list as $reg_user) {
  286. $user = Db::name('user')->where('phone', $reg_user['phone'])->find();
  287. $spread_user = Db::name('user')->where('phone', $reg_user['spread_phone'])->find();
  288. if ($spread_user && $user['spread_uid'] != $spread_user['uid']) {
  289. Db::name('user')->where('uid', $user['uid'])->update(['spread_uid' => $spread_user['uid']]);
  290. echo "{$reg_user['phone']}上级绑定成功{$reg_user['spread_phone']}\r\n";
  291. }
  292. }
  293. return;
  294. $this->take();
  295. return;
  296. $OrderGzcRepository = app()->make(OrderGzcRepository::class);
  297. // $uid = $OrderGzcRepository->register(15210999641);
  298. $uid = $OrderGzcRepository->gzc(1,0.01);
  299. var_dump($uid);
  300. return ;
  301. $order_list = Db::name('store_order')
  302. ->where('paid', 1)
  303. ->where('is_settlement', 1)
  304. ->select()
  305. ->toArray();
  306. $storeOrderRepository = app()->make(StoreOrderRepository::class);
  307. foreach ($order_list as $order) {
  308. $storeOrderRepository->close_order($order['order_id']);
  309. }
  310. return;
  311. $data = [
  312. 'a' => 21,
  313. 'b' => 22
  314. ];
  315. ksort($data);
  316. $params = '';
  317. foreach ($data as $key => $value) {
  318. $params .= '&' . $key . '=' . $value;
  319. }
  320. $params = ltrim($params, '&');
  321. $sign = strtoupper(md5($params . '&key=' . self::$thirdKey . '&signKey=' . self::$thirdsignKey . '&timestamp=' . time()));
  322. var_dump($params . '&key=' . self::$thirdKey . '&signKey=' . self::$thirdsignKey . '&timestamp=' . time());
  323. var_dump($sign);
  324. $checkSign = Signature::thirdCheckSign($data, ['sign' => $sign,]);
  325. var_dump($checkSign);
  326. return;
  327. $list = Db::table('sheet1')->select()->toArray();
  328. // foreach ($list as $val){
  329. // if(empty($val['id']))
  330. // continue;
  331. // $merchant_member = Db::name('merchant_member')->where('member_id', $val['member_id'])->find();
  332. //
  333. // if ($merchant_member) {
  334. // Db::name('merchant_member')->where('member_id', $val['member_id'])->update([
  335. // 'settle_account_id' => '0' . $val['id']
  336. // ]);
  337. // }
  338. // }
  339. // return $list;
  340. $merchant_list = Db::name('merchant')
  341. ->select()
  342. ->toArray();
  343. $key_list = [
  344. 1 => 'api_live_b23537ed-64b8-45d6-832e-fb228aa9e0a9',
  345. 2 => 'api_live_90ef02e4-54ac-41ee-adf1-e4927d23d58f',
  346. 3 => 'api_live_b0a687ec-5450-4ada-a0e4-65bac0f46871'
  347. ];
  348. $appid_list = [
  349. 1 => 'app_44108546-d27a-48ee-88c1-84b45b75114f',
  350. 2 => 'app_0827b960-b932-45ec-b800-4e850091b419',
  351. 3 => 'app_383a75dd-c03d-44ab-8f58-92c60fe9b9d0'
  352. ];
  353. $merber = new SettleAccount();
  354. // $params = [
  355. //// 'member_id' => 'jsdk_member_wx21689732717371',
  356. //'member_id' => '0',
  357. //'api_key' => $key_list[3]
  358. // ];
  359. $mer_id = 592;
  360. // $merchant_intention = Db::name('merchant_intention')
  361. // ->where('mer_id', $mer_id)
  362. // ->find();
  363. // $params = [
  364. // 'app_id' => $appid_list[3],
  365. // 'member_id' => 'jsdk_member_wx21710727780769',
  366. // 'channel' => 'bank_account',
  367. // 'account_info' => [
  368. // 'card_id' => $merchant_intention['bank_account'],//银行卡号
  369. // 'card_name' => $merchant_intention['name'],//银行卡对应的户名
  370. // 'cert_id' => $merchant_intention['idcard_no'],//证件号,银行账户类型为对私时,必填
  371. // 'cert_type' => '00',//证件类型,仅支持:00-身份证,银行账户类型为对私时,必填
  372. // 'tel_no' => $merchant_intention['phone'],//手机号
  373. // 'bank_acct_type' => 2//银行账户类型:1-对公;2-对私
  374. // ],
  375. // ];
  376. // var_dump($params);
  377. // $merber->create($params, $key_list[3]);
  378. // $res = $merber->result;
  379. // var_dump($res);
  380. // $params = [
  381. // 'app_id' => $appid_list[3],
  382. // 'member_id' => 'jsdk_member_1712631889320',
  383. // 'settle_account_id' => '0594907212710080',
  384. // 'api_key' => $key_list[3],
  385. // 'acct_type' => '03',
  386. // ];
  387. // var_dump($params);
  388. // $merber = new SettleAccount();
  389. // $merber->query($params);
  390. // $res = $merber->result;
  391. // var_dump($res);
  392. // return;
  393. $merchant_member_list = Db::name('merchant_member')
  394. ->column('mer_id,type,member_id,settle_account_id');
  395. foreach ($merchant_member_list as $merchant_member) {
  396. $mer_id = $merchant_member['mer_id'];
  397. if (empty($mer_id))
  398. continue;
  399. if (empty($merchant_member['settle_account_id']))
  400. continue;
  401. $params = [
  402. 'app_id' => $appid_list[$merchant_member['type']],
  403. 'member_id' => $merchant_member['member_id'],
  404. 'settle_account_id' => $merchant_member['settle_account_id'],
  405. 'api_key' => $key_list[$merchant_member['type']]
  406. ];
  407. $merber = new SettleAccount();
  408. $merber->balance($params);
  409. $merber->result;
  410. if (isset($merber->result[1])) {
  411. $result = json_decode($merber->result[1], true);
  412. $result = json_decode($result['data'], true);
  413. $result['avl_balance'] = $result['avl_balance'] ?? 0;
  414. if ($result['avl_balance'] > 0) {
  415. $payment_id = ShouxinyiApiRequest::getOrderNumber('split');
  416. $params = [
  417. 'order_no' => $payment_id,
  418. 'app_id' => $appid_list[$merchant_member['type']],
  419. 'cash_type' => 'T1',
  420. 'cash_amt' => sprintf("%01.2f", $result['avl_balance']),
  421. 'member_id' => $merchant_member['member_id'],
  422. 'api_key' => $key_list[$merchant_member['type']]
  423. ];
  424. Db::name("log")->insert(array('data' => '汇付取现参数-----' . json_encode($params)));//日志记录
  425. $merber = new Drawcash();
  426. $merber->create($params);
  427. # 返回查询结果
  428. $merber->isError();
  429. $res = $merber->result;
  430. Db::name("log")->insert(array('data' => '汇付延时分账-----' . json_encode($res))); //日志记录
  431. Db::name("log")->insert(array('data' => "mer_id {$mer_id} 请求分账{$result['avl_balance']}元-----"));//日志记录
  432. var_dump("mer_id {$mer_id} 请求分账{$result['avl_balance']}元-----");
  433. return;
  434. }
  435. }
  436. }
  437. // var_dump($merchant_member_list);
  438. // return;
  439. return;
  440. $refundMake = app()->make(StoreRefundOrderRepository::class);
  441. $storeOrderRepository = app()->make(StoreOrderRepository::class);
  442. $key = 'api_live_b0a687ec-5450-4ada-a0e4-65bac0f46871';
  443. $member_id = 'jsdk_member_wx21710232183139';
  444. $app_id = 'app_383a75dd-c03d-44ab-8f58-92c60fe9b9d0';
  445. // //split_171250769195432933
  446. // //split_171250766710946855
  447. // //split_171250756308518692
  448. // //split_171250756308518692
  449. //split_171250824291283553
  450. $params = [
  451. 'order_no' => 'split_171250857280339363',
  452. 'api_key' => $key
  453. ];
  454. $merber = new Drawcash();
  455. $merber->query($params);
  456. # 返回查询结果
  457. $merber->isError();
  458. var_dump($merber);
  459. $res = $merber->result;
  460. return null;
  461. $payment_id = ShouxinyiApiRequest::getOrderNumber('split');
  462. $params = [
  463. 'order_no' => $payment_id,
  464. 'app_id' => $app_id,
  465. 'cash_type' => 'T1',
  466. 'cash_amt' => '0.50',
  467. 'member_id' => $member_id,
  468. 'remark' => '养老金',
  469. 'api_key' => $key
  470. ];
  471. Db::name("log")->insert(array('data' => '汇付取现参数-----' . json_encode($params)));//日志记录
  472. $merber = new Drawcash();
  473. $merber->create($params);
  474. # 返回查询结果
  475. $merber->isError();
  476. $res = $merber->result;
  477. Db::name("log")->insert(array('data' => '汇付延时分账-----' . json_encode($res)));//日志记录
  478. var_dump($merber);
  479. return $merber->result;
  480. // 创建取现对象
  481. var_dump(date('H:i'));
  482. return;
  483. //公证处
  484. //2 jsdk_member_wx1710231128628
  485. //3 jsdk_member_wx21710232183139
  486. //1 jsdk_member_ali1710232187326
  487. //WX171205067143565297 002212024040217375110621169693733044224
  488. //WX171205073720275677 002212024040217385710621169969109147648
  489. //WX171205077431982682 002212024040217393410621170124857163776
  490. $payment_id = ShouxinyiApiRequest::getOrderNumber('split');
  491. $insertData = [
  492. [
  493. 'mid' => 0,
  494. 'requestId' => $payment_id,
  495. 'group_order_id' => 'WX171205067143565292',
  496. 'splitAmount' => 0.25,
  497. 'status' => 0
  498. ],
  499. ];
  500. $div_members[] = [
  501. 'member_id' => $member_id,
  502. 'amount' => '0.25',
  503. 'fee_flag' => 'Y'
  504. ];
  505. //////分账表
  506. Db::name("store_split_order")->insertAll($insertData);
  507. /// 分账表end
  508. $params = [
  509. 'payment_id' => '002212024040218261010621181853790355456',
  510. 'order_no' => $payment_id,
  511. 'confirm_amt' => '0.25',
  512. 'div_members' => $div_members
  513. ];
  514. $params['api_key'] = $key;
  515. var_dump($params);
  516. Db::name("log")->insert(array('data' => '汇付延时分账参数-----' . json_encode($params)));//日志记录
  517. $res = $storeOrderRepository->payment_confirm_create_traits($params);
  518. Db::name("log")->insert(array('data' => '汇付延时分账-----' . json_encode($res)));//日志记录
  519. var_dump($res);
  520. // 分账
  521. return;
  522. $storeOrderRepository = app()->make(StoreOrderRepository::class);
  523. $storeOrderRepository->douhuomall_delivery();
  524. // var_dump( GongApiRequest::order_details('W202404061500443232427'));
  525. return;
  526. // $depositInfo = [
  527. // 'conName' => '刘建',//消费者姓名
  528. // 'conTel' => '15210999641',//消费者电话
  529. // 'conCertType' => 1,//消费者证件类型
  530. // 'conCertNo' => '130433199808212911',//消费者证件号
  531. // 'conIsAuth' => 1,//消费者在平台是否已实名
  532. // 'amount' => bcmul('0.25', '100'),//消费者存入的消费养老金额
  533. // 'depositDt' => '2024-04-03 18:01:18',//入账时间
  534. // ];
  535. // $depositInfo['bankName'] = '中国民生银行';
  536. // $depositInfo['branchName'] = '中国民生银行股份有限公司北京劲松支行';
  537. // $depositInfo['bankAccount'] = '629966688';
  538. // $depositInfo['bankPaymentFlow'] = '313002023122702917666735446EB285';
  539. // $depositInfo['accountType'] = 1;
  540. $depositInfo = [
  541. 'conName' => '何海强', //消费者姓名
  542. 'conTel' => '19931699683', //消费者电话
  543. 'conCertType' => 1, //消费者证件类型
  544. 'conCertNo' => '130433199808212911', //消费者证件号
  545. 'conIsAuth' => 1, //消费者在平台是否已实名
  546. 'amount' => bcmul('0.01', '100'), //消费者存入的消费养老金额
  547. 'depositDt' => '2024-04-03 18:01:19',//入账时间
  548. ];
  549. $depositInfo['bankName'] = '中国民生银行';
  550. $depositInfo['branchName'] = '中国民生银行股份有限公司北京劲松支行';
  551. $depositInfo['bankAccount'] = '629966688';
  552. $depositInfo['bankPaymentFlow'] = '313002023122702917666735446EB285';
  553. $depositInfo['accountType'] = 1;
  554. $applys[] = $depositInfo;
  555. $OrderMerchantRepository = app()->make(OrderMerchantRepository::class);
  556. $orderId = $OrderMerchantRepository->getNewOrderId('IN10');
  557. $OrderGzcRepository = app()->make(OrderGzcRepository::class);
  558. $q = $OrderGzcRepository->doInGzc(['platform_no' => $orderId], $applys);
  559. var_dump($q);
  560. return;
  561. $spuIds = '10029352697750';
  562. $res = GongApiRequest::goods_status($spuIds);
  563. $res1 = GongApiRequest::get_goods_info($spuIds);
  564. // var_dump($res);
  565. // var_dump($res1);
  566. $product_data = Db::name('store_product')
  567. ->where("spu_id != '' or spu_id is not null")
  568. ->where('product_id', 12622)
  569. ->order('product_id asc')
  570. ->limit(0, 50)
  571. ->select()
  572. ->toArray();
  573. foreach ($product_data as $item) {
  574. $spuIds = $item['spu_id'];
  575. $goods_status = GongApiRequest::goods_status($spuIds);
  576. var_dump($goods_status);
  577. $status = $goods_status[0]['status'] ?? 1;
  578. $goods_info = GongApiRequest::get_goods_info($spuIds);
  579. var_dump($goods_info);
  580. if ($status == 0 || (isset($goods_info['error_msg']) && $goods_info['error_msg'] == '没有查询到商品信息')) {
  581. var_dump('下架');
  582. }
  583. }
  584. return;
  585. return;
  586. // 退款
  587. $refund_traits = [
  588. 'id' => '002212024040218261010621181853790355456',
  589. 'refund_order_no' => $refundMake->getNewOrderId(),
  590. 'refund_amt' => '1.00',
  591. ];
  592. $hf_refund_res = $refundMake->Payment_refund_traits($refund_traits, $key, 3);
  593. var_dump($hf_refund_res);
  594. Db::name('log')->insert(['data' => '汇付退款返回结果:' . json_encode($hf_refund_res)]);
  595. return;
  596. // $data = [];
  597. // $re=app()->make(UserRepository::class)->daoruUser($data);
  598. // var_dump($re);
  599. // return;
  600. $where = [
  601. 'is_used' => 1,
  602. 'mer_status' => 1,
  603. // 'type' => 5,
  604. // 'is_show' => 1,
  605. 'is_hide' => 0,
  606. // 'is_del' => 0
  607. ];
  608. $product_data = Db::name('store_product')
  609. ->where($where)
  610. ->where("spu_id != '' or spu_id is not null")
  611. ->where('product_id', '>', 12630)
  612. ->order('product_id asc')
  613. ->fetchSql(true)
  614. ->limit(0, 50)
  615. ->select();
  616. var_dump($product_data);
  617. $spuIds = '9ed876a65570';
  618. $res = GongApiRequest::goods_status($spuIds);
  619. $res1 = GongApiRequest::get_goods_info($spuIds);
  620. var_dump($res);
  621. var_dump($res1);
  622. return
  623. $this->appid = '4100076550';;
  624. $this->key = '5ce3da55dc739b6e7d9021d59618c5faa3b4030f41c5699658c7ca30cfd19f09b4046d606d196f1d';
  625. $this->appKey = 'a2ad5078501e928b991cd8aaeb0446dc';
  626. $this->secretKey = 'fd8aab59e9b94d9e889cb22838c03f2a';
  627. $this->userThird = app()->make(UserThirdRepository::class);
  628. $this->url = 'https://api.jd.com/routerjson';
  629. // 指令输出
  630. $output->writeln('pensiontask');
  631. // (new Access())->test1111();
  632. $this->get_jd_goods_list();
  633. // app()->make(Jd::class)->get_jd_goods_list();
  634. // $product_share_ids = Db::name('product_share')
  635. // ->where("`url` is null or `url` ='' ")
  636. // ->group('product_id')
  637. // ->column('product_id');
  638. //
  639. // $list = Db::name('store_product')
  640. // ->whereNotIn('product_id',$product_share_ids)
  641. // ->where('is_show',1)
  642. // ->order('create_time desc')
  643. // ->select()
  644. // ->toArray();
  645. //
  646. //
  647. // $header = [
  648. // 'X-Token: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJhcHAuYmp0ZGJhLmNvbSIsImF1ZCI6ImFwcC5ianRkYmEuY29tIiwiaWF0IjoxNjk2Mzg5MzM2LCJuYmYiOjE2OTYzODkzMzYsImV4cCI6MTcwNzE4OTMzNiwianRpIjpbMTA1NzQsInVzZXIiXX0.15FqgSFYfy-9OKtgeIPV7M5Pj6lHHr83c7GPt5lZik4'
  649. // ];
  650. // foreach ($list as $store_product) {
  651. // $res1 = Common::sendCurl("https://app.bjtdba.com/api/product_share?pid={$store_product['product_id']}&type=1", null, 'get', $header);
  652. // $res2 = Common::sendCurl("https://app.bjtdba.com/api/product_share?pid={$store_product['product_id']}&type=2", null, 'get', $header);
  653. // var_dump($res1, $res2);
  654. // }
  655. }
  656. public function get_jd_goods_list()
  657. {
  658. $eliteIdList = [
  659. '1', //好券商品
  660. // '2', //精选卖场
  661. // '10', //9.9包邮
  662. // '15', //京东配送
  663. // '22', //实时热销榜
  664. //// '23', //为你推荐
  665. // '24', //数码家电
  666. // '25', //超市
  667. // '26', //母婴玩具
  668. // '27', //家具日用
  669. // '28', //美妆穿搭
  670. // '30', //图书文具
  671. // '31', //今日必推
  672. // '32', //京东好物
  673. // '33', //京东秒杀
  674. // '34', //拼购商品
  675. // '40', //高收益榜
  676. // '41', //自营热卖榜
  677. //// '108', //秒杀进行中
  678. // '109', //新品首发
  679. // '110', //自营
  680. // '112', //京东爆品
  681. // '125', //首购商品
  682. // '129', //高佣榜单
  683. //// '130', //视频商品
  684. // '153', //历史最低价商品榜
  685. //// '238', //新人价商品
  686. //// '315', //秒杀未开始
  687. // '341', //3C新品
  688. // '342', //智能新品
  689. // '343', //3C长尾商品
  690. // '345', //时尚新品
  691. // '346', //时尚爆品
  692. // '1001', //选品库
  693. //// '515', //订单接龙商品
  694. // '519', //官方活动
  695. // '12254', //超级补贴
  696. // '12318', //便宜包邮
  697. // '12339', //超市卡
  698. ];
  699. set_time_limit(0);
  700. // $eliteIdList = [1];
  701. foreach ($eliteIdList as $eliteId) {
  702. for ($page = 1; $page <= 10000; $page++) {
  703. $apiName = 'jd.union.open.goods.jingfen.query';
  704. $params = [
  705. 'goodsReq' => [
  706. 'eliteId' => $eliteId,
  707. 'pageIndex' => $page ?? 1,
  708. 'pageSize' => 1,
  709. ]
  710. ];
  711. $result = $this->getUrlResult($apiName, $params);
  712. $result = json_decode($result, true);
  713. $result = json_decode($result['jd_union_open_goods_jingfen_query_responce']['queryResult'], true);
  714. $result = $result['data'] ?? [];
  715. if (empty($result)) break;
  716. $this->formatGoodsList($result ?? []);
  717. }
  718. }
  719. }
  720. //格式化从京东联盟获取到的商品列表
  721. public function formatGoodsList($goodsList)
  722. {
  723. $insertList = [];
  724. foreach ($goodsList as $goods) {
  725. $commissionMoney = $goods['commissionInfo']['commission'] ?? 0;
  726. //养老金
  727. $oldMoney = app()->make(ProductRepository::class)->yanglaojin(0, $commissionMoney);
  728. // var_dump($goods);
  729. // return;
  730. if ($oldMoney < 0.1) continue;
  731. if (!isset($goods['couponInfo']['couponList'][0])) continue;
  732. foreach ($goods['couponInfo']['couponList'] as $coupon) {
  733. }
  734. $goods['couponInfo']['couponList'][0]['getStartTime'] = date('Y-m-d', intval($goods['couponInfo']['couponList'][0]['getStartTime'] / 1000));
  735. $goods['couponInfo']['couponList'][0]['getEndTime'] = date('Y-m-d', intval($goods['couponInfo']['couponList'][0]['getEndTime'] / 1000));
  736. $formatList = [
  737. 'type' => 6, //京东商品
  738. 'skuId' => $goods['skuId'], //skuid
  739. 'id' => $goods['brandCode'] ?? '', //id
  740. 'thumb' => $goods['imageInfo']['imageList'][0]['url'] ?? '', //商品缩略图
  741. 'name' => $goods['skuName'], //名称
  742. 'commission' => $oldMoney, //佣金
  743. 'commission_rate' => $goods['commissionInfo']['commissionShare'] ?? '',//佣金比例
  744. 'sales' => "",
  745. 'coupon_money' => $goods['couponInfo']['couponList'] ?? [],
  746. 'lowestCouponPrice' => decimal2($goods['priceInfo']['lowestCouponPrice']), //券后价lowestCouponPrice
  747. 'price' => $goods['priceInfo']['price'], //价格
  748. 'imageList' => array_column($goods['imageInfo']['imageList'], 'url'), //图片合集
  749. ];
  750. $insertList[] = ['json' => json_encode($formatList, JSON_UNESCAPED_UNICODE), 'pension' => $oldMoney, 'type' => 2];
  751. // break;
  752. }
  753. if ($insertList) {
  754. Db::name("third_party_goods")->insertAll($insertList);
  755. }
  756. // return $formatList;
  757. }
  758. //返回请求参数链接
  759. public function getUrlResult($apiName = "", $params = [])
  760. {
  761. if (empty($apiName)) {
  762. return false;
  763. }
  764. //公共请求参数
  765. $requestParams = [
  766. 'method' => $apiName,
  767. 'format' => 'json',
  768. 'app_key' => $this->appKey,
  769. 'timestamp' => date('Y-m-d H:i:s'),
  770. 'v' => '1.0',
  771. 'sign_method' => 'md5',
  772. '360buy_param_json' => json_encode($params)
  773. ];
  774. $orderData = $this->paramOrder($requestParams);
  775. $sign = $this->paramSign($orderData);
  776. $requestParams['sign'] = $sign;
  777. $res = $this->apiSign($requestParams);
  778. return $res;
  779. }
  780. //为空检查
  781. protected function checkEmpty($value)
  782. {
  783. if (!isset($value))
  784. return true;
  785. if ($value === null)
  786. return true;
  787. if (trim($value) === "")
  788. return true;
  789. return false;
  790. }
  791. //编码设置
  792. public function characet($data, $targetCharset)
  793. {
  794. if (!empty($data)) {
  795. $fileType = 'utf-8';
  796. if (strcasecmp($fileType, $targetCharset) != 0) {
  797. $data = mb_convert_encoding($data, $targetCharset, $fileType);
  798. }
  799. }
  800. return $data;
  801. }
  802. //签名
  803. public function paramSign($params)
  804. {
  805. $str = $this->secretKey . $params . $this->secretKey;
  806. $sign = md5($str);
  807. return strtoupper($sign);
  808. }
  809. public function apiSign($param)
  810. {
  811. $ch = curl_init();
  812. curl_setopt($ch, CURLOPT_URL, $this->url);
  813. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  814. curl_setopt($ch, CURLOPT_POST, 1);
  815. curl_setopt($ch, CURLOPT_POSTFIELDS, $param);
  816. curl_setopt($ch, CURLOPT_TIMEOUT, 60);
  817. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  818. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  819. $data = curl_exec($ch);
  820. curl_close($ch);
  821. return $data;
  822. }
  823. //排序ksort
  824. public function paramOrder($params)
  825. {
  826. ksort($params);
  827. $stringToBeSigned = "";
  828. $i = 0;
  829. foreach ($params as $k => $v) {
  830. if (false === $this->checkEmpty($v)) {
  831. $v = $this->characet($v, 'utf-8');
  832. if ($i == 0) {
  833. $stringToBeSigned .= "$k" . "$v";
  834. } else {
  835. $stringToBeSigned .= "$k" . "$v";
  836. }
  837. $i++;
  838. }
  839. }
  840. unset ($k, $v);
  841. return $stringToBeSigned;
  842. }
  843. }