wangmingchuan321@qq.com 12 months ago
commit 4d53641a10
  1. 34
      app/api/controller/Identity.php
  2. 8
      app/api/controller/Server.php
  3. 52
      app/api/model/user/IdentityOrder.php
  4. 15
      app/api/service/Identity.php
  5. 7
      app/api/service/passport/Login.php
  6. 8
      app/common/model/User.php

@ -3,6 +3,8 @@ declare (strict_types=1);
namespace app\api\controller; namespace app\api\controller;
use app\api\model\user\IdentityOrder;
use app\common\enum\user\IdentityEnum;
use cores\exception\BaseException; use cores\exception\BaseException;
use think\db\exception\DataNotFoundException; use think\db\exception\DataNotFoundException;
use think\db\exception\DbException; use think\db\exception\DbException;
@ -30,6 +32,38 @@ class Identity extends Controller
return $this->renderSuccess(compact('list')); return $this->renderSuccess(compact('list'));
} }
/**
* @notes:会员开卡记录
* @return Json
* @throws BaseException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author: wanghousheng
*/
public function userOpenCardLog(): Json
{
$model = new IdentityOrder();
$list = $model->cardList(['order_type' => IdentityEnum::MEMBER]);
return $this->renderSuccess($list);
}
/**
* @notes:分销商开卡记录
* @return Json
* @throws BaseException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author: wanghousheng
*/
public function dealerOpenCardLog(): Json
{
$model = new IdentityOrder();
$list = $model->cardList(['order_type' => IdentityEnum::DEALER]);
return $this->renderSuccess($list);
}
/** /**
* @notes:分销身份价格列表 * @notes:分销身份价格列表
* @return Json * @return Json

@ -47,8 +47,8 @@ class Server extends Controller
{ {
$server_name = $this->request->post('server_name'); $server_name = $this->request->post('server_name');
$category_id = intval($this->request->post('category_id')); $category_id = intval($this->request->post('category_id'));
$order_field = $this->request->post('order_field'); $order_field = (string)$this->request->post('order_field');
$order_sort = $this->request->post('order_sort', 'desc'); $order_sort = (string)$this->request->post('order_sort', 'desc');
$where = []; $where = [];
if ($server_name) { if ($server_name) {
$where[] = ['server.server_name', 'like', "%$server_name%"]; $where[] = ['server.server_name', 'like', "%$server_name%"];
@ -58,7 +58,7 @@ class Server extends Controller
} }
$where[] = ['server.status', '=', 1]; $where[] = ['server.status', '=', 1];
$model = new \app\api\model\Server(); $model = new \app\api\model\Server();
$list = $model->getList($where, $order_field, $order_sort); $list = $model->getList($where, 15, $order_field, $order_sort);
$data['list'] = $list->items(); $data['list'] = $list->items();
$data['total'] = $list->total(); $data['total'] = $list->total();
if (!$list->isEmpty()) { if (!$list->isEmpty()) {
@ -175,6 +175,8 @@ class Server extends Controller
'server_time' => $server_time, 'server_time' => $server_time,
'server_address' => $server_address, 'server_address' => $server_address,
'buyer_remark' => $remake, 'buyer_remark' => $remake,
'username' => $username,
'mobile' => $mobile,
]; ];
$result = $orderService->createOrder($data, $couponId); $result = $orderService->createOrder($data, $couponId);
if ($result) { if ($result) {

@ -3,9 +3,14 @@
namespace app\api\model\user; namespace app\api\model\user;
use app\api\service\User as UserService; use app\api\service\User as UserService;
use app\common\enum\order\PayStatus;
use app\common\model\user\IdentityOrder as BaseIdentityOrder; use app\common\model\user\IdentityOrder as BaseIdentityOrder;
use app\common\service\Order as OrderService; use app\common\service\Order as OrderService;
use cores\exception\BaseException; use cores\exception\BaseException;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\model\relation\HasOne;
use function getPlatform; use function getPlatform;
class IdentityOrder extends BaseIdentityOrder class IdentityOrder extends BaseIdentityOrder
@ -63,4 +68,51 @@ class IdentityOrder extends BaseIdentityOrder
{ {
return $this->save($data) !== false; return $this->save($data) !== false;
} }
public function identity(): HasOne
{
return $this->hasOne(Identity::class, 'identity_id', 'identity_id')
->bind(['identity_name' => 'name']);
}
/**
* @notes:开卡记录
* @param array $where
* @return array
* @throws BaseException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author: wanghousheng
*/
public function cardList(array $where = []): array
{
$userId = UserService::getCurrentLoginUserId();
$params['user_id'] = $userId;
$params['pay_status'] = PayStatus::SUCCESS;
$where = array_merge($where, $params);
$list = $this->where($where)
->with(['identity'])
->order('pay_time', 'desc')
->limit(20)
->select();
$data = [];
if (!empty($list)) {
foreach ($list as $value) {
$end_time = date("Y-m-d", strtotime("+{$value['month']} months", $value['pay_time']));
$is_valid = false;
if (strtotime(date("Y-m-d")) < strtotime($end_time)) {
$is_valid = true;
}
$data[] = [
'start_time' => date("Y-m-d", $value['pay_time']),
'end_time' => $end_time,
'name' => $value['identity_name'],
'month' => $value['month'],
'is_valid' => $is_valid
];
}
}
return $data;
}
} }

@ -82,23 +82,12 @@ class Identity extends BaseService
private function cheapPrice($data) private function cheapPrice($data)
{ {
$one_data = []; $one_data = $data[0];
foreach ($data as $value) {
if ($value['month'] == 1) {
$one_data = $value;
break;
}
}
foreach ($data as $key => $value) { foreach ($data as $key => $value) {
$data[$key]['cheap_price'] = 0; $data[$key]['cheap_price'] = 0;
if (!empty($one_data)) { if (!empty($one_data)) {
if ($value['month'] > 1) {
$price = $value['month'] * $one_data['price'];
$data[$key]['cheap_price'] = $price - $value['price'];
}
} else {
if ($key > 0) { if ($key > 0) {
$price = $value['month'] * $data[$key - 1]['price']; $price = $value['month'] * $one_data['price'];
$data[$key]['cheap_price'] = $price - $value['price']; $data[$key]['cheap_price'] = $price - $value['price'];
} }
} }

@ -191,11 +191,14 @@ class Login extends BaseService
// 解密encryptedData -> 拿到手机号 // 解密encryptedData -> 拿到手机号
$plainData = OauthService::wxDecryptData($form['encryptedData'], $form['iv'], $wxSession['session_key']); $plainData = OauthService::wxDecryptData($form['encryptedData'], $form['iv'], $wxSession['session_key']);
// 整理登录注册数据 // 整理登录注册数据
if (empty($form['partyData']['oauth'])) {
$form['partyData']['oauth'] = 'MP-WEIXIN';
}
$loginData = [ $loginData = [
'mobile' => $plainData['purePhoneNumber'], 'mobile' => $plainData['purePhoneNumber'],
'isParty' => $form['isParty'], 'isParty' => $form['isParty'],
'partyData' => !empty($form['partyData']) ?: [], 'partyData' => $form['partyData'],
'refereeId' => $form['refereeId'] ?? null 'refereeId' => $form['refereeId'] ?? null,
]; ];
// 自动登录注册 // 自动登录注册
$this->register($loginData); $this->register($loginData);

@ -52,9 +52,11 @@ class User extends BaseModel
public function getUserTypeTextAttr($value, $data): string public function getUserTypeTextAttr($value, $data): string
{ {
// 身份 // 身份
$result = UserTypeEnum::data(); if (!empty($data['user_type'])) {
if (!empty($result[$data['user_type']]['name'])) { $result = UserTypeEnum::data();
return $result[$data['user_type']]['name']; if (!empty($result[$data['user_type']]['name'])) {
return $result[$data['user_type']]['name'];
}
} }
return '未知'; return '未知';
} }

Loading…
Cancel
Save