This commit is contained in:
mkm 2024-06-29 13:52:52 +08:00
commit 085ad190fc
4 changed files with 218 additions and 24 deletions

View File

@ -245,6 +245,20 @@ 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);
}
/**
* 用户信息
*/

View File

@ -444,7 +444,12 @@ class OrderLogic extends BaseLogic
if($order['uid'] && $order['pay_price'] >= 500){
$user_number = bcmul($order['pay_price'], '0.10', 2);
User::where('id', $order['uid'])->inc('integral', $user_number)->update();
UserSign::where(['uid' => $order['uid'],'order_id' => $order['order_id']])->update(['status'=>1]);
// 核销加冻结礼品券 解冻礼品券
self::addUserSing($order,2,$user_number);//冻结
self::addUserSing($order,4,$user_number,1,1);//解冻
UserSign::where(['uid' => $order['uid'],'order_id' => $order['order_id'],'title'=>1])->update(['status'=>1]);
}
if ($order['spread_uid'] > 0) {
$spread_find=$financeFlow->where(['order_id'=>$order['id'],'financial_pm'=>1,'financial_type'=>12,'other_uid'=>$order['spread_uid']])->find();
@ -464,6 +469,39 @@ class OrderLogic extends BaseLogic
}
}
/**
* 处理冻结和解冻 礼品券得记录
* @param $order // 订单
* @param $category // 分类
* @param $number // 金额
* @param int $pm //收支 0支出 1获得
* @type $type //类型 0冻结 1解冻
* @return true
*/
public static function addUserSing($order, $category, $number, int $pm=0, $type=0)
{
$user_sing = new UserSign();
$sing = [
'uid' => $order['uid'],
'order_id' => $order['order_id'],
// 'title' => '购买商品获得兑换券',
// 'title' => PayNotifyLogic::getTitle($category,$number),
'title' => $category,
'financial_pm' => $pm,
'store_id' => $order['store_id'],
'number' => $number,
'type' => $type,
'status' => 1,
];
$user_sing->save($sing);
return true;
}
//不走二次分钱的核销
public static function lessWriteOff($params): bool
{

View File

@ -5,6 +5,7 @@ namespace app\api\logic\user;
use app\api\service\UserTokenService;
use app\common\{logic\BaseLogic,
logic\PayNotifyLogic,
model\dict\DictData,
model\finance\CapitalFlow,
model\store_finance_flow\StoreFinanceFlow,
@ -253,6 +254,48 @@ class UserLogic extends BaseLogic
}
public static function userSingList($params,$uid)
{
switch ($params['type']){
case 1:
$query = UserSign::where(['uid'=>$uid,'type'=>1]);
if($params['mark'] == 1){
$query->where('financial_pm',1);//获得
}
if($params['mark'] == 2){
$query->where('financial_pm',0);
}
$count = $query->count();
$data =$query
->page($params['page_no'],$params['page_size'])
->order('id','desc')
->select()?->toArray();
break;
default:
$query = UserSign::where(['uid'=>$uid,'type'=>0]);
if($params['mark'] == 1){
$query->where('financial_pm',1);//获得
}
if($params['mark'] == 2){
$query->where('financial_pm',0);
}
$count = $query->count();
$data =$query
->page($params['page_no'],$params['page_size'])
->order('id','desc')
->select()?->toArray();
}
foreach ($data as &$value){
if(!preg_match('/[\x{4e00}-\x{9fa5}]/u', $value['title'])){
$value['title'] = PayNotifyLogic::getTitle($value['title'],$value['number']);
}
}
return [
'lists' => $data,
'count' => $count
];
}
public static function dealDetails($params,$uid)
{
@ -306,12 +349,13 @@ class UserLogic extends BaseLogic
//礼品券明细
$query = UserSign::where(['uid'=>$uid]);
if($params['mark'] == 1){
$query->where('financial_pm',1);
$query->where('financial_pm',1);//获得
}
if($params['mark'] == 2){
$query->where('financial_pm',0);
}
$count = $query->count();
//todo 有就拿有得 没得就去获取对应得文本内容
$data =$query
->page($params['page_no'],$params['page_size'])
->order('id','desc')

View File

@ -142,10 +142,12 @@ class PayNotifyLogic extends BaseLogic
$sing[] = [
'uid' => $order['uid'],
'order_id' => $order['order_id'],
'title' => '订单扣除兑换券',
// 'title' => '订单扣除兑换券',
'title' => 5,
'financial_pm' => 0,
'store_id' => $order['store_id'],
'number' => $order['pay_price'],
'financial_pm' => 0,
'type' => 1,
'user_ship' => $user['user_ship'],
];
(new UserSign())->saveAll($sing);
@ -435,6 +437,10 @@ class PayNotifyLogic extends BaseLogic
User::where('id',$orderRe['uid'])->dec('purchase_funds',$purchase_funds)->update();
$capitalFlowDao->userExpense('user_order_purchase_pay', 'order', $orderRe['id'], $purchase_funds, '', 1, $orderRe['store_id']);
}
//退还 充值得兑换券
self::addNewUserSing($orderRe,3,$orderRe->refund_price);//冻结
self::addNewUserSing($orderRe,6,$orderRe->refund_price,0,1);//解冻
self::descUserSing($orderRe);
// d($purchase_funds,$orderRe['refund_price'],$orderRe);
return true;
@ -469,12 +475,17 @@ class PayNotifyLogic extends BaseLogic
$capitalFlowDao->userIncome('system_purchase_back', 'system_back', $order['id'], $deal_money);
}
if ($check_user_sing) {
//退还 兑换券
self::addNewUserSing($order,3,$order->refund_price);//冻结
self::addNewUserSing($order,6,$order->refund_price,0,1);//解冻
self::descUserSing($order);
}
return true;
}
//积分
if ($check_user_sing) {
self::addNewUserSing($order,3,$order->refund_price);//冻结
self::addNewUserSing($order,6,$order->refund_price,0,1);//解冻
self::descUserSing($order);
}
//微信日志 user_order_refund
@ -485,28 +496,59 @@ class PayNotifyLogic extends BaseLogic
return true;
// self::afterPay($order,$extra['transaction_id']);
}
//冻结券和礼品券得操作
/**
* 处理冻结和解冻 礼品券得记录
* @param $order // 订单
* @param $category // 分类
* @param $number // 金额
* @param int $pm //收支 0支出 1获得
* @type $type //类型 0冻结 1解冻
* @return true
*/
public static function addNewUserSing($order, $category, $number, int $pm=0, $type=0)
{
$user_sing = new UserSign();
$sing = [
'uid' => $order['uid'],
'order_id' => $order['order_id'],
// 'title' => '购买商品获得兑换券',
// 'title' => PayNotifyLogic::getTitle($category,$number),
'title' => $category,
'financial_pm' => $pm,
'store_id' => $order['store_id'],
'number' => $number,
'type' => $type,
'status' => 1,
];
$user_sing->save($sing);
return true;
}
//退积分-->订单
public static function descUserSing($order)
{
$user_sing = new UserSign();
// $user_sing = new UserSign();
if ($order['uid'] > 0) {
$user_number = bcmul($order['refund_price'], '0.10', 2);
$sing = [
'uid' => $order['uid'],
'order_id' => $order['order_id'],
'title' => '退款扣除兑换券',
'financial_pm' => 0,
'store_id' => $order['store_id'],
'number' => $user_number,
];
$user_sing->save($sing);
//删除之前获得的兑换券
UserSign::where([
'order_id' => $order['order_id'],
'financial_pm' => 1,
])->update(['delete_time' => time()]);
// $sing = [
// 'uid' => $order['uid'],
// 'order_id' => $order['order_id'],
// 'title' => '退款扣除兑换券',
// 'financial_pm' => 0,
// 'store_id' => $order['store_id'],
// 'number' => $user_number,
// ];
// $user_sing->save($sing);
// //删除之前获得的兑换券
// UserSign::where([
// 'order_id' => $order['order_id'],
// 'financial_pm' => 1,
// ])->update(['delete_time' => time()]);
$now_int = User::where('id', $order['uid'])->withTrashed()->find();
if ($now_int) {
if ($now_int['integral'] > $user_number) {
@ -600,10 +642,27 @@ class PayNotifyLogic extends BaseLogic
{
$total_vip = bcmul($order['price'], 0.1, 2);
$user_sing = new UserSign();
$sing = [
//冻结
$sing[] = [
'uid' => $order['uid'],
'order_id' => $order['order_id'],
'title' => '充值获得冻结兑换券',
// 'title' => '充值获得冻结兑换券',
// 'title' => self::getTitle(7,$total_vip),
'title' =>7,
'financial_pm' => 1,
'store_id' => $order['store_id'],
// 'type' => 1,
'status' => 1,
'number' => $total_vip,
'back_num' => $total_vip,
];
//礼品券得
$sing[] = [
'uid' => $order['uid'],
'order_id' => $order['order_id'],
// 'title' => '充值获得冻结兑换券',
// 'title' => self::getTitle(4,$total_vip),
'title' => 4,
'financial_pm' => 1,
'store_id' => $order['store_id'],
'type' => 1,
@ -611,7 +670,9 @@ class PayNotifyLogic extends BaseLogic
'number' => $total_vip,
'back_num' => $total_vip,
];
$user_sing->save($sing);
$user_sing->saveAll($sing);
User::where('id', $order->uid)->inc('integral', $total_vip)->update();
return true;
@ -770,10 +831,13 @@ class PayNotifyLogic extends BaseLogic
$sing = [
'uid' => $order['uid'],
'order_id' => $order['order_id'],
'title' => '购买商品获得兑换券',
// 'title' => '购买商品获得兑换券',
// 'title' => self::getTitle(1,$user_number),
'title' => 1,
'financial_pm' => 1,
'store_id' => $order['store_id'],
'number' => $user_number,
'status' => 0,
];
$user_sing->save($sing);
}
@ -796,7 +860,9 @@ class PayNotifyLogic extends BaseLogic
$sing = [
'uid' => $order['uid'],
'order_id' => $order['order_id'],
'title' => '购买商品获得兑换券',
// 'title' => '购买商品获得兑换券',
// 'title' => self::getTitle(1,$user_number),
'title' => 1,
'financial_pm' => 1,
'store_id' => $order['store_id'],
'number' => $user_number,
@ -1034,4 +1100,36 @@ class PayNotifyLogic extends BaseLogic
(new StoreBranchProduct())->saveAll($updateData);
}
//礼品券相关对应文本
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}元扣除礼品卷";
default:
return "订单支付{$amount}";
}
}
}