1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- <?php
- /*
- * @Author: wang jun
- * @Date: 2021-10-29 16:16:29
- * @Last Modified by: wang jun
- * @Last Modified time: 2021-11-09 16:21:40
- */
- namespace app\index\logic;
- use app\index\logic\businesslogic;
- use app\index\model\userinfomodel;
- use app\index\model\usersharelogmodel;
- use think\Log;
- class usershareloglogic
- {
- /**
- * 日志新增
- * 20211029
- * wj
- */
- public function newinfo($info)
- {
- $m_ual = new usersharelogmodel();
- if (!isset($info['sharetime']) || empty($info['sharetime'])) {
- $info['sharetime'] = date('Y-m-d H:i:s');
- }
- $userid = 0;
- if (isset($info['shareopenid']) && !empty($info['shareopenid'])) {
- $openid = $info['shareopenid'];
- $m_u = new userinfomodel();
- $uwhere = ['openid' => $openid];
- $uinfo = $m_u->getInfo($uwhere, 'id');
- if (!empty($uinfo)) {
- $userid = $uinfo['id'];
- }
- }
- $info['userid'] = $userid;
- $id = $m_ual->insertData($info);
- if (!$id) {
- return backarr(0, "操作失败");
- }
- //积分处理
- $data = [
- 'openid' => $info['shareopenid'],
- 'type' => 'share',
- 'typeid' => 2,
- ];
- $l_bl = new businesslogic();
- $result = $l_bl->handlescorebusinessforopenid($data);
- log::info($result);
- if (1 != $result['status']) {
- return backarr(0, $result['msg']);
- }
- return backarr(1, "操作成功", ['id' => $id]);
- }
- /**
- * 日志新增
- * 20220121
- * wj
- */
- public function newinfobyuserid($info)
- {
- $m_ual = new usersharelogmodel();
- if (!isset($info['sharetime']) || empty($info['sharetime'])) {
- $info['sharetime'] = date('Y-m-d H:i:s');
- }
- if (isset($info['userid'])) {
- $userid = $info['userid'];
- $m_u = new userinfomodel();
- $uwhere = ['id' => $userid];
- $uinfo = $m_u->getInfo($uwhere, 'id');
- if (empty($uinfo)) {
- return backarr(0, "无用户信息");
- }
- $info['userid'] = $uinfo['id'];
- }
- $id = $m_ual->insertData($info);
- if (!$id) {
- return backarr(0, "操作失败");
- }
- if (isset($info['userid'])) {
- //积分处理
- $data = [
- 'userid' => $info['userid'],
- 'type' => 'share',
- 'typeid' => 2,
- ];
- $l_bl = new businesslogic();
- $result = $l_bl->handlescorebusinessforuserid($data);
- log::info($result);
- }
- return backarr(1, "操作成功", ['id' => $id]);
- }
- }
|