ShopCashOutService.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Niucloud-admin 企业快速开发的saas管理平台
  4. // +----------------------------------------------------------------------
  5. // | 官方网址:https://www.niucloud.com
  6. // +----------------------------------------------------------------------
  7. // | niucloud团队 版权所有 开源版本可自由商用
  8. // +----------------------------------------------------------------------
  9. // | Author: Niucloud Team
  10. // +----------------------------------------------------------------------
  11. namespace app\service\api\shop;
  12. use app\model\shop\ShopCashOut;
  13. use app\service\core\shop\CoreShopCashOutService;
  14. use core\base\BaseApiService;
  15. use core\exception\ApiException;
  16. use think\facade\Cache;
  17. /**
  18. * 店铺提现服务层
  19. */
  20. class ShopCashOutService extends BaseApiService
  21. {
  22. public function __construct()
  23. {
  24. parent::__construct();
  25. $this->model = new ShopCashOut();
  26. }
  27. /**
  28. * 店铺提现详情
  29. * @param int $id
  30. * @return array
  31. */
  32. public function getInfo(int $id)
  33. {
  34. $field = 'id,site_id,cash_out_no,transfer_type,transfer_realname,transfer_mobile,transfer_bank,transfer_account,transfer_fail_reason,transfer_time,apply_money,rate,service_money,money,audit_time,status,remark,create_time,refuse_reason, transfer_no, transfer_payee, transfer_payment_code';
  35. return $this->model->field($field)->where([ [ 'id', '=', $id ] ])->with(['siteInfo', 'transfer'])->append([ 'account_type_name', 'transfer_type_name', 'status_name', 'transfer_status_name' ])->findOrEmpty()->toArray();
  36. }
  37. /**
  38. * 提现转账(微信零钱)
  39. * @param int $id
  40. * @return void
  41. */
  42. public function transfer(int $id, array $data){
  43. $data['channel'] = $this->channel;
  44. $result = (new CoreShopCashOutService())->transfer($id, $data);
  45. return $result;
  46. }
  47. /**
  48. * 转账检测
  49. * @param string $code
  50. * @return bool|int
  51. */
  52. public function checkTransfer(string $code)
  53. {
  54. if (empty($code)) throw new ApiException('TRANSFER_CODE_EXPIRED');//转账二维码已过期
  55. $id = Cache::get($code);
  56. if (empty($id)) throw new ApiException('TRANSFER_CODE_EXPIRED');//转账二维码已过期
  57. return $id;
  58. }
  59. }