123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <?php
- /**
- * Created by: PhpStorm
- * User: lytian
- * Date: 2019/9/19
- * Time: 17:47
- */
- namespace app\main\service;
- use app\common\model\SpecialRechargeUrl;
- class SpecialPayService extends BaseService
- {
- /**
- * 定义属性
- *
- * @var SpecialPayService
- */
- protected static $self = null;
- /**
- * 返回实例
- *
- * @return SpecialPayService
- */
- public static function instance()
- {
- if (self::$self == null) {
- self::$self = new self();
- }
- return self::$self;
- }
- /**
- * @return SpecialRechargeUrl
- */
- public function getUrlModel()
- {
- return model("SpecialRechargeUrl");
- }
- /**
- * 我能下单吗
- * @param $id
- * @param $user_id
- * @return array
- * @throws \think\exception\DbException
- */
- public function canPay($id, $user_id)
- {
- $result = ['code' => 200, 'msg' => ''];
- $row = $this->getUrlModel()->get($id);
- if ($row['status'] == 'hidden') {
- $result['code'] = 201;
- $result['msg'] = '链接不存在';
- } else {
- if ($row['order_status'] == '1') {
- $result['code'] = 202;
- $result['msg'] = '链接已支付';
- } else {
- if ($row['user_id']) {
- if ($row['user_id'] != $user_id) {
- $result['code'] = 202;
- $result['msg'] = '该链接为专属福利链接,请您联系私人助理获取';
- }
- }
- }
- }
- return $result;
- }
- /**
- * 更新
- * @param $id
- * @param $params
- * @return false|int
- * @throws \think\exception\DbException
- */
- public function updateUrl($id, $params)
- {
- $row = $this->getUrlModel()->get($id);
- return $row->save($params);
- }
- }
|