1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <?php
- namespace app\service;
- use app\service\ConfServiceFacade;
- use app\service\api\UserServiceFacade;
- use laytp\traits\Error;
- use think\facade\Cache;
- use think\facade\Config;
- use think\facade\Request;
- use EasyWeChat\Factory;
- use think\facade\Db;
- class Bill
- {
- use Error;
- /**
- * phpmailer对象
- */
- protected $client;
- /**
- * 构造函数
- */
- public function __construct()
- {
- // $conf = ConfServiceFacade::groupGet('system.ai');
- // $this->client = new \AipOcr($conf['app_id'],$conf['api_key'],$conf['secret_key']);
- }
- /**
- * 初始化
- * @param $token
- * @return bool
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function record($pm=0,$coin=0,$type = '',$mark = '',$uid = '',$uniacid = '',$direct=false,$balance=0,$isTime=0)
- {
- $model = new \app\model\Bill();
- $payPrice = 0;
- $post['pm'] = $pm ;
- $post['coin'] = $coin;
- $post['type'] = $type;
- $post['mark'] = $mark;
- $post['uid'] = $uid;
- $post['uniacid'] = $uniacid;
- $post['is_time'] = $isTime;
- if($direct){
- $balance = $balance;
- }else{
- $loginUserInfo = \app\model\User::where('id','=',$uid)->find();
- $money = $loginUserInfo['coin'];
- // 更新用户余额
- if($pm == 0){
- $balance = $money-$coin;
- }else{
- $balance = $money+$coin;
- }
- }
- $post['balance'] = $balance;
- Db::startTrans();
- try{
- $saveRes = $model->save($post);
- if (!$saveRes) throw new \Exception('保存基础信息失败');
- Db::commit();
- return true;
- }catch (\Exception $e) {
- Db::rollback();
- $this->setError('数据库异常,操作失败');
- return false;
- }
- }
- }
|