Coin.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. namespace app\service;
  3. use app\service\ConfServiceFacade;
  4. use app\service\api\UserServiceFacade;
  5. use laytp\traits\Error;
  6. use think\facade\Cache;
  7. use think\facade\Config;
  8. use think\facade\Request;
  9. use EasyWeChat\Factory;
  10. use think\facade\Db;
  11. class Coin{
  12. use Error;
  13. /**
  14. * 初始化
  15. * @param $token
  16. * @return bool
  17. * @throws \think\db\exception\DataNotFoundException
  18. * @throws \think\db\exception\DbException
  19. * @throws \think\db\exception\ModelNotFoundException
  20. */
  21. public function cash($post)
  22. {
  23. // $model = new \app\model\Extract();
  24. // $payPrice = 0; //扣除手续费后的实际到账金额
  25. // $conf = ConfServiceFacade::groupGet('system.config');
  26. // $loginUserInfo = UserServiceFacade::getUserInfo();
  27. // $post['uid'] = $loginUserInfo['id'];
  28. // $money = $loginUserInfo['now_money'];
  29. // if($conf['userExtractRate'] > 0){
  30. // $payPrice = $post['extract_price'] * (100- $conf['userExtractRate'])/100;
  31. // } else {
  32. // $payPrice = $post['extract_price'];
  33. // }
  34. // $post['rate'] = $conf['userExtractRate'];//服务手续费率
  35. // $post['real_price'] = $payPrice;//实际到账金额
  36. // $post['service_price'] = bcsub($post['extract_price'],$payPrice,2) ?? 0;;//服务费
  37. // // 更新用户余额
  38. // $balance = bcsub($money,$post['extract_price'],2) ?? 0;
  39. // $post['balance'] = $balance;//用户余额
  40. // // print_r($payPrice);
  41. // //可提现余额
  42. //
  43. // if($payPrice > $money){
  44. // $this->setError('可提现金额不足,此次提现金额超出可提现余额');
  45. // return false;
  46. // }
  47. // if($post['extract_price'] < $conf['userExtractMinPrice']){
  48. // $this->setError('提现金额不能小于' . $conf['userExtractMinPrice'] . '元');
  49. // return false;
  50. // }
  51. // if($payPrice <= 0){
  52. // $this->setError('提现金额不能小于或等于0元');
  53. // return false;
  54. // }
  55. // Db::startTrans();
  56. // try{
  57. // $saveRes = $model->save($post);
  58. // if (!$saveRes) throw new \Exception('保存基础信息失败');
  59. // $post['id'] = $model->id;
  60. // $balanceRes = \app\model\User::where(['id'=>$loginUserInfo['id']])->update(['now_money' => $balance]);
  61. // if(!$balanceRes){
  62. // $this->setError('提现金额不能小于或等于0元');
  63. // return false;
  64. // }
  65. // Db::commit();
  66. // return true;
  67. // }catch (\Exception $e) {
  68. // Db::rollback();
  69. // $this->setError('数据库异常,操作失败');
  70. // return false;
  71. // }
  72. }
  73. }