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; } } }