修改:权重值客服端相关接口
This commit is contained in:
parent
4b23b90fe9
commit
1cd0371198
|
|
@ -27,6 +27,8 @@ class WeightValueLog extends BaseModel{
|
|||
'remark',
|
||||
'created_at',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* Common: 获取列表
|
||||
* Author: wu-hui
|
||||
|
|
@ -41,7 +43,7 @@ class WeightValueLog extends BaseModel{
|
|||
$where = [];
|
||||
if($search['member_id'] > 0) $where[] = ['member_id','=',$search['member_id']];
|
||||
// if($search['type'] >= 0 && !is_null($search['type'])) $where[] = ['type','=',$search['type']];
|
||||
// if($search['change_type'] >= 0 && !is_null($search['type'])) $where[] = ['change_type','=',$search['change_type']];
|
||||
if($search['change_type'] >= 0 && !is_null($search['change_type'])) $where[] = ['change_type','=',$search['change_type']];
|
||||
// 列表获取
|
||||
$list = self::uniacid()
|
||||
->select($field)
|
||||
|
|
@ -55,6 +57,61 @@ class WeightValueLog extends BaseModel{
|
|||
|
||||
return $list ? $list->toArray() : [];
|
||||
}
|
||||
/**
|
||||
* Common: 获取总数
|
||||
* Author: wu-hui
|
||||
* Time: 2023/09/27 17:49
|
||||
* @param $uid
|
||||
* @param int $changeType
|
||||
* @return string
|
||||
*/
|
||||
public function getChangeTypeSum($uid,$changeType = -1){
|
||||
$where = [];
|
||||
if($changeType == 0) $where[] = ['change_type','=',0];
|
||||
if($changeType == 1) $where[] = ['change_type','=',1];
|
||||
|
||||
$sum = (float)self::uniacid()->where('member_id',$uid)->where($where)->sum('change_quantity');
|
||||
|
||||
return sprintf("%.2f",$sum);
|
||||
}
|
||||
/**
|
||||
* Common: 权重值增加|减少操作
|
||||
* Author: wu-hui
|
||||
* Time: 2023/09/27 17:12
|
||||
* @param int $uid
|
||||
* @param float $money
|
||||
* @param int $changeType
|
||||
* @param string $remark
|
||||
* @param int $type
|
||||
*/
|
||||
public function weightValueOperate(int $uid,float $money,int $changeType = 1,string $remark = '',int $type = 0){
|
||||
// 获取当前用户持有数量
|
||||
$changeFront = (float)Member::uniacid()->where('uid',$uid)->value('weight_value');
|
||||
// 变更后的数量
|
||||
$changeAfter = $changeType == 1 ? $changeFront + $money : $changeFront - $money;
|
||||
// 变更记录
|
||||
$data = [
|
||||
'uniacid' => \YunShop::app()->uniacid,
|
||||
'member_id' => $uid,// 用户id
|
||||
'type' => $type,// 权重值类型:0=经纪人(经销商)权重值
|
||||
'goods_id' => 0,// 商品id
|
||||
'order_id' => 0,// 订单id
|
||||
'order_goods_id' => 0,// 订单商品id
|
||||
'change_type' => $changeType,// 变更类型:0=减少,1=增加
|
||||
'change_quantity' => $money,// 变更数量
|
||||
'change_front' => (float)$changeFront,// 变更前拥有的数量
|
||||
'change_after' => sprintf("%.2f",$changeAfter),// 变更后拥有的数量
|
||||
'remark' => $remark,// 备注
|
||||
'created_at' => time(),// 变更时间
|
||||
];
|
||||
$this->insert($data);
|
||||
// 修改用户持有
|
||||
Member::uniacid()->where('uid',$uid)->update([
|
||||
'weight_value' => $changeAfter
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Common: 一对一关联 用户信息
|
||||
* Author: wu-hui
|
||||
|
|
@ -65,19 +122,4 @@ class WeightValueLog extends BaseModel{
|
|||
return $this->hasOne(Member::class, 'uid', 'member_id');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -266,7 +266,6 @@ class MemberCenterService extends BaseMemberCenterService
|
|||
];
|
||||
|
||||
}
|
||||
|
||||
if (app('MemberCenter')->isDiy()) {
|
||||
$data[] = [
|
||||
'key' => 'extension',
|
||||
|
|
@ -286,6 +285,20 @@ class MemberCenterService extends BaseMemberCenterService
|
|||
'weight' => 110
|
||||
];
|
||||
}
|
||||
// 权重值
|
||||
$data[] = [
|
||||
'key' => 'weight_value',
|
||||
'name' => '权重值',
|
||||
'value' => Member::current()['weight_value'],
|
||||
'unit' => '',
|
||||
'url' => 'weight_value',
|
||||
'min_url' => '',
|
||||
'diy_key' => 'weight_value',
|
||||
'weight' => 60
|
||||
];
|
||||
|
||||
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,111 @@
|
|||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* Author:
|
||||
* Date: 2017/4/2
|
||||
* Time: 下午5:37
|
||||
*/
|
||||
|
||||
namespace app\frontend\modules\finance\controllers;
|
||||
|
||||
use app\common\models\weightValue\WeightValueLog;
|
||||
use app\common\components\ApiController;
|
||||
use app\common\models\Member;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Yunshop\TeamDividend\models\TeamDividendAgencyModel;
|
||||
|
||||
class WeightValueController extends ApiController{
|
||||
/**
|
||||
* Common: 获取权重值首页信息
|
||||
* Author: wu-hui
|
||||
* Time: 2023/09/27 16:00
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function index(){
|
||||
$uid = \YunShop::app()->getMemberId();
|
||||
$data = [
|
||||
'weight_value' => sprintf("%.2f",Member::where('uid', $uid)->value('weight_value')),
|
||||
'list' => WeightValueLog::uniacid()->where('member_id',$uid)->limit(10)->get(['type','change_type','change_quantity','change_after','remark','created_at']),
|
||||
];
|
||||
|
||||
return $this->successJson('成功', $data);
|
||||
}
|
||||
/**
|
||||
* Common: 获取用户权重值信息
|
||||
* Author: wu-hui
|
||||
* Time: 2023/09/27 16:31
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function memberWeightValue(){
|
||||
if ($memberInfo = Member::where('uid', \YunShop::app()->getMemberId())->first()) {
|
||||
$data['weight_value'] = $memberInfo->weight_value;
|
||||
$data['has_password'] = $memberInfo->yzMember->hasPayPassword();
|
||||
$data['need_password'] = false;//(new PasswordService())->isNeed('balance', 'transfer');
|
||||
|
||||
return $this->successJson('获取数据成功', $data);
|
||||
}
|
||||
return $this->errorJson('未获取到会员数据');
|
||||
}
|
||||
/**
|
||||
* Common: 权重值转账
|
||||
* Author: wu-hui
|
||||
* Time: 2023/09/27 17:17
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function transfer(){
|
||||
// 参数获取
|
||||
$uid = \YunShop::app()->getMemberId();
|
||||
$transferId = (int)request()->input('transfer_id');
|
||||
$transferMoney = abs((float)request()->input('transfer_money'));
|
||||
if($transferId <= 0 || $transferMoney <= 0) return $this->errorJson('无受让人或者转赠数量为0!');
|
||||
// 判断:双方必须都是经销商
|
||||
$currentMemberIs = (int)TeamDividendAgencyModel::uniacid()->where('uid',$uid)->value('id');
|
||||
$transferMemberIs = (int)TeamDividendAgencyModel::uniacid()->where('uid',$transferId)->value('id');
|
||||
if($currentMemberIs <= 0 || $transferMemberIs <= 0) return $this->errorJson('身份非法,双方都必须为经纪人才能进行当前操作!');
|
||||
DB::beginTransaction();
|
||||
try{
|
||||
// 获取用户信息
|
||||
$currentMemberName = Member::uniacid()->where('uid',$uid)->value('nickname');
|
||||
$transferMemberName = Member::uniacid()->where('uid',$transferId)->value('nickname');
|
||||
// 减少当前用户持有权重值
|
||||
(new WeightValueLog())->weightValueOperate($uid,$transferMoney,0,"赠送给【{$transferMemberName}】");
|
||||
// 增加受让人持有权重值
|
||||
(new WeightValueLog())->weightValueOperate($transferId,$transferMoney,1,"来自【{$currentMemberName}】的赠送");
|
||||
|
||||
DB::commit();
|
||||
|
||||
return $this->successJson('操作成功');
|
||||
}catch(\Exception $e){
|
||||
DB::rollBack();
|
||||
return $this->errorJson($e->getMessage());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Common: 获取权重值变更记录列表
|
||||
* Author: wu-hui
|
||||
* Time: 2023/09/27 17:40
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function record(){
|
||||
//参数获取
|
||||
$pageSize = request()->input('page_size',10);
|
||||
$search = request()->input('search');
|
||||
$search['member_id'] = \YunShop::app()->getMemberId();
|
||||
// 列表获取
|
||||
$field = ['id','member_id','type','change_type','change_quantity','change_front','change_after','remark','created_at'];
|
||||
$result = WeightValueLog::getList($pageSize,$search,$field);
|
||||
$data = [
|
||||
'current_page' => $result['current_page'],
|
||||
'last_page' => $result['last_page'],
|
||||
'list' => $result['data'],
|
||||
'income' => WeightValueLog::getChangeTypeSum($search['member_id'],1),
|
||||
'expenditure' => WeightValueLog::getChangeTypeSum($search['member_id'],0),
|
||||
];
|
||||
|
||||
|
||||
return $this->successJson('成功', $data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -58,7 +58,7 @@ class TimedTaskService
|
|||
Setting::$uniqueAccountId = \YunShop::app()->uniacid = $u->uniacid;
|
||||
$this->set = Setting::get('plugin.shareholder');
|
||||
$this->setLog = Setting::get('plugin.shareholder_log');
|
||||
$is_execute = true;//$this->isExecute();
|
||||
$is_execute = $this->isExecute();
|
||||
if ($is_execute) {
|
||||
\Log::info('========股东分红UNIACID:' . $u->uniacid . '执行========');
|
||||
$this->setLog['current_d'] = date('d');
|
||||
|
|
|
|||
Loading…
Reference in New Issue