Unlockorder.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\Db;
  5. /**
  6. * 解锁微信号和私密视频
  7. */
  8. class Unlockorder extends Api
  9. {
  10. protected $noNeedLogin = [];
  11. protected $noNeedRight = ['*'];
  12. //解锁微信订单
  13. public function wechataccount(){
  14. $to_user_id = input('to_user_id','');
  15. if(empty($to_user_id)){
  16. $this->error();
  17. }
  18. $to_user_info = Db::name('user')->find($to_user_id);
  19. if(empty($to_user_info)){
  20. $this->error('不存在的用户');
  21. }
  22. $price = config('site.unlock_wechataccount');
  23. $price = bcadd(intval($price),0,0);
  24. $data = [
  25. 'user_id' => $this->auth->id,
  26. 'to_user_id' => $to_user_id,
  27. 'createtime' => time(),
  28. 'endtime' => time() + 604800,
  29. 'price' => $price,
  30. ];
  31. Db::startTrans();
  32. $order_id = Db::name('order_wechataccount')->insertGetId($data);
  33. if(!$order_id){
  34. Db::rollback();
  35. $this->error('解锁失败');
  36. }
  37. if($price > 0){
  38. $wallet_rs = model('wallet')->lockChangeAccountRemain($this->auth->id,'gold',$price,71,'解锁:'.$to_user_id,'order_wechataccount',$order_id);
  39. if($wallet_rs['status'] === false){
  40. Db::rollback();
  41. $this->error($wallet_rs['msg']);
  42. }
  43. }
  44. Db::commit();
  45. $this->success('解锁成功');
  46. }
  47. //解锁私密视频订单
  48. public function secretvideo(){
  49. $to_user_id = input('to_user_id','');
  50. if(empty($to_user_id)){
  51. $this->error();
  52. }
  53. $to_user_info = Db::name('user')->find($to_user_id);
  54. if(empty($to_user_info)){
  55. $this->error('不存在的用户');
  56. }
  57. $price = config('site.unlock_secretvideo');
  58. $price = bcadd(intval($price),0,0);
  59. $data = [
  60. 'user_id' => $this->auth->id,
  61. 'to_user_id' => $to_user_id,
  62. 'createtime' => time(),
  63. 'endtime' => time() + 604800,
  64. 'price' => $price,
  65. ];
  66. Db::startTrans();
  67. $order_id = Db::name('order_secretvideo')->insertGetId($data);
  68. if(!$order_id){
  69. Db::rollback();
  70. $this->error('解锁失败');
  71. }
  72. if($price > 0){
  73. $wallet_rs = model('wallet')->lockChangeAccountRemain($this->auth->id,'gold',$price,71,'解锁:'.$to_user_id,'order_secretvideo',$order_id);
  74. if($wallet_rs['status'] === false){
  75. Db::rollback();
  76. $this->error($wallet_rs['msg']);
  77. }
  78. }
  79. Db::commit();
  80. $this->success('解锁成功');
  81. }
  82. }