feat: 修改用户签到逻辑和支付通知逻辑
This commit is contained in:
parent
78a44016e5
commit
0b3fc8a7b6
@ -3,6 +3,8 @@
|
||||
namespace app\api\controller\user;
|
||||
|
||||
use app\api\controller\BaseApiController;
|
||||
use app\api\lists\user_sign\UserSignLists;
|
||||
use app\api\lists\user_sign_log\UserSignLogLists;
|
||||
use app\api\logic\user\UserLogic;
|
||||
use app\api\service\UserTokenService;
|
||||
use app\api\validate\UserValidate;
|
||||
@ -246,18 +248,19 @@ class UserController extends BaseApiController
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 礼品券/冻结券
|
||||
*/
|
||||
public function userSing()
|
||||
{
|
||||
(new UserValidate())->get()->goCheck('fund');
|
||||
$page_no = (int)$this->request->get('page_no', 1);
|
||||
$page_size = (int)$this->request->get('page_size', 15);
|
||||
$params = $this->request->get();
|
||||
$params['page_no'] = $page_no > 0 ? $page_no : 1;
|
||||
$params['page_size'] = $page_size > 0 ? $page_size : 15;
|
||||
$res = UserLogic::userSingList($params,$this->userId);
|
||||
$res['page_no'] = $params['page_no'];
|
||||
$res['page_size'] = $params['page_size'];
|
||||
return $this->success('ok', $res);
|
||||
$type = (int)$this->request->get('type', 1);
|
||||
if($type==1){
|
||||
return $this->dataLists(new UserSignLists());
|
||||
}else{
|
||||
return $this->dataLists(new UserSignLogLists());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
79
app/api/lists/user_sign/UserSignLists.php
Normal file
79
app/api/lists/user_sign/UserSignLists.php
Normal file
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\lists\user_sign;
|
||||
|
||||
|
||||
use app\api\lists\BaseApiDataLists;
|
||||
use app\common\model\user_label\UserLabel;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\logic\UserSignLogic;
|
||||
use app\common\model\user_ship\UserShip;
|
||||
use app\common\model\user_sign\UserSign;
|
||||
|
||||
/**
|
||||
* 积分列表
|
||||
* Class UserSignLists
|
||||
* @package app\api\user_sign
|
||||
*/
|
||||
class UserSignLists extends BaseApiDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author admin
|
||||
* @date 2024/06/17 17:02
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取用户标签列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author admin
|
||||
* @date 2024/06/17 17:02
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$type=$this->request->get('type',1);
|
||||
$mark=$this->request->get('mark','');
|
||||
if($type==1){
|
||||
$this->searchWhere[]=['type','in',[4,9,8,2]];
|
||||
$this->searchWhere[]=['status','=',1];
|
||||
}
|
||||
if($mark==1){
|
||||
$this->searchWhere[]=['financial_pm','=',1];
|
||||
}elseif($mark==2){
|
||||
$this->searchWhere[]=['financial_pm','=',0];
|
||||
}
|
||||
$list=UserSign::where($this->searchWhere)->order('id desc')
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->select()->each(function ($item){
|
||||
$item['title']=UserSignLogic::getTitle($item['type'],$item['number']);
|
||||
return $item;
|
||||
});
|
||||
return $list?->toArray();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取用户标签数量
|
||||
* @return int
|
||||
* @author admin
|
||||
* @date 2024/06/17 17:02
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return UserLabel::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
78
app/api/lists/user_sign_log/UserSignLogLists.php
Normal file
78
app/api/lists/user_sign_log/UserSignLogLists.php
Normal file
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\lists\user_sign_log;
|
||||
|
||||
|
||||
use app\api\lists\BaseApiDataLists;
|
||||
use app\common\model\user_label\UserLabel;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\logic\UserSignLogic;
|
||||
use app\common\model\user_ship\UserShip;
|
||||
use app\common\model\user_sign_log\UserSignLog;
|
||||
|
||||
/**
|
||||
* 积分记录列表
|
||||
* Class UserSignLogLists
|
||||
* @package app\api\user_sign_log
|
||||
*/
|
||||
class UserSignLogLists extends BaseApiDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author admin
|
||||
* @date 2024/06/17 17:02
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取用户标签列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author admin
|
||||
* @date 2024/06/17 17:02
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$type=$this->request->get('type',1);
|
||||
$mark=$this->request->get('mark','');
|
||||
if($type==1){
|
||||
$this->searchWhere[]=['type','in',[1,7,3]];
|
||||
$this->searchWhere[]=['status','=',1];
|
||||
}
|
||||
if($mark==1){
|
||||
$this->searchWhere[]=['financial_pm','=',1];
|
||||
}elseif($mark==2){
|
||||
$this->searchWhere[]=['financial_pm','=',0];
|
||||
}
|
||||
$list=UserSignLog::where($this->searchWhere)->order('id desc')
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->select()->each(function ($item){
|
||||
$item['title']=UserSignLogic::getTitle($item['type'],$item['number']);
|
||||
return $item;
|
||||
});
|
||||
return $list?->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取用户标签数量
|
||||
* @return int
|
||||
* @author admin
|
||||
* @date 2024/06/17 17:02
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return UserLabel::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
@ -21,6 +21,7 @@ use app\common\{logic\BaseLogic,
|
||||
model\vip_flow\VipFlow,
|
||||
service\SmsService,
|
||||
service\wechat\WeChatMnpService};
|
||||
use app\common\logic\UserSignLogic;
|
||||
use app\common\model\user_label\UserLabel;
|
||||
use support\Cache;
|
||||
use think\facade\Db;
|
||||
@ -287,7 +288,7 @@ class UserLogic extends BaseLogic
|
||||
}
|
||||
foreach ($data as &$value){
|
||||
if(!preg_match('/[\x{4e00}-\x{9fa5}]/u', $value['title'])){
|
||||
$value['title'] = PayNotifyLogic::getTitle($value['title'],$value['number']);
|
||||
$value['title'] = UserSignLogic::getTitle($value['title'],$value['number']);
|
||||
}
|
||||
}
|
||||
return [
|
||||
|
@ -1130,37 +1130,4 @@ class PayNotifyLogic extends BaseLogic
|
||||
return 0.1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//礼品券相关对应文本
|
||||
public static function getTitle($category, $amount)
|
||||
{
|
||||
switch ($category) {
|
||||
/**冻结券**/
|
||||
//收入
|
||||
case 1:
|
||||
return "购买商品{$amount}元获得冻结卷";
|
||||
case 7:
|
||||
return "充值{$amount}元获得冻结卷";
|
||||
//支出
|
||||
case 2:
|
||||
return "核销商品{$amount}元解冻冻结卷";
|
||||
case 3:
|
||||
return "退款{$amount}元扣除冻结卷";
|
||||
/**礼品券**/
|
||||
//收入
|
||||
case 4:
|
||||
return "核销金额{$amount}元获得礼品卷";
|
||||
//支出
|
||||
case 5:
|
||||
return "兑换{$amount}元商品扣除礼品卷";
|
||||
case 6:
|
||||
return "退款{$amount}元扣除礼品卷";
|
||||
case 8:
|
||||
return "收银台支付{$amount}元增加礼品卷";
|
||||
default:
|
||||
return "订单支付{$amount}元";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,12 +23,13 @@ class UserSignLogic extends BaseLogic
|
||||
$total_vip = bcmul($order['price'], 0.1, 2);
|
||||
$count = UserSign::where('uid', $order->uid)->count();
|
||||
if ($count == 0 && in_array($user_ship, [1, 2, 3, 5, 6, 7, 8])) {
|
||||
$write = self::write($order, $total_vip, 0, 1);
|
||||
self::write_log($write, $total_vip, 0);
|
||||
//首充
|
||||
$write = self::write($order, $total_vip, 0, 1,9);
|
||||
self::write_log($write, $total_vip, 0,9);
|
||||
User::where('id', $order->uid)->inc('integral', $total_vip)->update();
|
||||
} else {
|
||||
$write = self::write($order, $total_vip, 0, 0);
|
||||
self::write_log($write, $total_vip, 0);
|
||||
$write = self::write($order, $total_vip, 0, 0,7);
|
||||
self::write_log($write, $total_vip, 0,7);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -40,12 +41,12 @@ class UserSignLogic extends BaseLogic
|
||||
{
|
||||
$total_vip = bcmul($order['pay_price'], 0.1, 2);
|
||||
|
||||
//非收银台订单冻结里礼品卷
|
||||
if ($order['source'] == 0) {
|
||||
$write = self::write($order, $total_vip, 1, 0);
|
||||
//非收银台订单冻结礼品卷
|
||||
self::write($order, $total_vip, 1, 0,1);
|
||||
} else {
|
||||
$write = self::write($order, $total_vip, 1, 1);
|
||||
self::write_log($write, $total_vip, 1);
|
||||
$write = self::write($order, $total_vip, 1, 1,4);
|
||||
self::write_log($write, $total_vip, 1,4);
|
||||
User::where('id', $order->uid)->inc('integral', $total_vip)->update();
|
||||
}
|
||||
}
|
||||
@ -53,22 +54,23 @@ class UserSignLogic extends BaseLogic
|
||||
/**
|
||||
* 核销
|
||||
*/
|
||||
public static function WriteOff($order){
|
||||
$find=UserSign::where(['order_id'=>$order['order_id'],'status'=>0,'financial_pm'=>1,'order_type'=>1])->find();
|
||||
if($find){
|
||||
$find->status=1;
|
||||
public static function WriteOff($order)
|
||||
{
|
||||
$find = UserSign::where(['order_id' => $order['order_id'], 'status' => 0, 'financial_pm' => 1, 'order_type' => 1])->find();
|
||||
if ($find) {
|
||||
$find->status = 1;
|
||||
$find->save();
|
||||
User::where('id', $order->uid)->inc('integral', $find['number'])->update();
|
||||
self::write_log($find,$find['number'], 1);
|
||||
|
||||
self::write_log($find, $find['number'], 1,4);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 储存商品积分结算
|
||||
*/
|
||||
public static function storage($order){
|
||||
$find=UserSign::where(['order_id'=>$order['order_id'],'status'=>0,'financial_pm'=>1,'order_type'=>1])->find();
|
||||
if($find){
|
||||
public static function storage($order)
|
||||
{
|
||||
$find = UserSign::where(['order_id' => $order['order_id'], 'status' => 0, 'financial_pm' => 1, 'order_type' => 1])->find();
|
||||
if ($find) {
|
||||
// if($or)
|
||||
// $find->status=1;
|
||||
// $find->save();
|
||||
@ -78,14 +80,24 @@ class UserSignLogic extends BaseLogic
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function write($order, $total_vip, $order_type = 0, $status = 0, $title = 4, $pm = 1)
|
||||
/**
|
||||
* @param type 1:购买商品冻结
|
||||
* @param type 2:核销商品解冻
|
||||
* @param type 3:退款扣除冻结
|
||||
* @param type 4:核销金额获得
|
||||
* @param type 5:兑换商品扣除
|
||||
* @param type 6:退款扣除礼品
|
||||
* @param type 7:充值冻结
|
||||
* @param type 8:收银台支付增加
|
||||
* @param type 9:首充获得
|
||||
*/
|
||||
public static function write($order, $total_vip, $order_type = 0, $status = 0, $type = 4, $pm = 1)
|
||||
{
|
||||
//礼品券得
|
||||
$sing = [
|
||||
'uid' => $order['uid'],
|
||||
'order_id' => $order['order_id'],
|
||||
'title' => $title,
|
||||
'type' => $type,
|
||||
'financial_pm' => $pm,
|
||||
'store_id' => $order['store_id'],
|
||||
'status' => $status,
|
||||
@ -96,14 +108,25 @@ class UserSignLogic extends BaseLogic
|
||||
];
|
||||
return UserSign::create($sing);
|
||||
}
|
||||
public static function write_log($write, $total_vip, $order_type = 0, $title = 4, $pm = 1)
|
||||
/**
|
||||
* @param type 1:购买商品冻结
|
||||
* @param type 2:核销商品解冻
|
||||
* @param type 3:退款扣除冻结
|
||||
* @param type 4:核销金额获得
|
||||
* @param type 5:兑换商品扣除
|
||||
* @param type 6:退款扣除礼品
|
||||
* @param type 7:充值冻结
|
||||
* @param type 8:收银台支付增加
|
||||
* @param type 9:首充获得
|
||||
*/
|
||||
public static function write_log($write, $total_vip, $order_type = 0, $type = 4, $pm = 1)
|
||||
{
|
||||
//礼品券日志记录
|
||||
$sing = [
|
||||
'uid' => $write['uid'],
|
||||
'sid' => $write['id'],
|
||||
'order_id' => $write['order_id'],
|
||||
'title' => $title,
|
||||
'type' => $type,
|
||||
'financial_pm' => $pm,
|
||||
'order_type' => $order_type,
|
||||
'status' => 1,
|
||||
@ -111,5 +134,37 @@ class UserSignLogic extends BaseLogic
|
||||
];
|
||||
UserSignLog::create($sing);
|
||||
}
|
||||
|
||||
|
||||
//礼品券相关对应文本
|
||||
public static function getTitle($type, $amount)
|
||||
{
|
||||
switch ($type) {
|
||||
/**冻结券**/
|
||||
//收入
|
||||
case 1:
|
||||
return "购买商品{$amount}元获得冻结券";
|
||||
case 7:
|
||||
return "充值{$amount}元获得冻结券";
|
||||
//支出
|
||||
case 2:
|
||||
return "核销商品{$amount}元解冻冻结券";
|
||||
case 3:
|
||||
return "退款{$amount}元扣除冻结券";
|
||||
/**礼品券**/
|
||||
//收入
|
||||
case 4:
|
||||
return "核销金额{$amount}元获得礼品券";
|
||||
//支出
|
||||
case 5:
|
||||
return "兑换{$amount}元商品扣除礼品券";
|
||||
case 6:
|
||||
return "退款{$amount}元扣除礼品券";
|
||||
case 8:
|
||||
return "收银台支付{$amount}元增加礼品券";
|
||||
case 9:
|
||||
return "首充{$amount}元获得礼品券";
|
||||
default:
|
||||
return "订单支付{$amount}元";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user