初始版本
This commit is contained in:
94
server/app/common/model/accountLog/ShopAccountLog.php
Executable file
94
server/app/common/model/accountLog/ShopAccountLog.php
Executable file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\model\accountLog;
|
||||
|
||||
use app\common\enum\accountLog\AccountLogEnum;
|
||||
use app\common\enum\accountLog\CoachAccountLogEnum;
|
||||
use app\common\enum\accountLog\ShopAccountLogEnum;
|
||||
use app\common\model\BaseModel;
|
||||
use app\common\model\coach\Coach;
|
||||
use app\common\model\shop\Shop;
|
||||
use app\common\model\user\User;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
|
||||
class ShopAccountLog extends BaseModel
|
||||
{
|
||||
use SoftDelete;
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @notes 变动类型
|
||||
* @param $value
|
||||
* @param $data
|
||||
* @return string|string[]
|
||||
* @author ljj
|
||||
* @date 2022/5/31 4:45 下午
|
||||
*/
|
||||
public function getChangeTypeDescAttr($value,$data)
|
||||
{
|
||||
return ShopAccountLogEnum::getChangeTypeDesc($data['change_type']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $shopId (店铺ID
|
||||
* @param $changeType (变动类型
|
||||
* @param $action (操作动作: [1=新增, 2=扣减])
|
||||
* @param $changeAmount (变动的值
|
||||
* @param string $sourceSn (来源编号)
|
||||
* @param string $remark (备注信息)
|
||||
* @param array $extra (扩展信息)
|
||||
* @param int $adminId (管理员ID)
|
||||
* @param array $flowUsage (token信息组)
|
||||
* @return CoachAccountLog|false|Model
|
||||
*/
|
||||
public static function add($shopId, $changeObject,$changeType, $action, $changeAmount, string $sourceSn = '', int $adminId = 0, string $remark = '', array $extra = []): bool|Model|ShopAccountLog
|
||||
{
|
||||
|
||||
// 取用户信息
|
||||
$shop = (new Shop())->findOrEmpty($shopId);
|
||||
if ($shop->isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
$leftAmount = $shop->money;
|
||||
if(ShopAccountLogEnum::DEPOSIT == $changeObject){
|
||||
$leftAmount = $shop->deposit;
|
||||
}
|
||||
$data = [
|
||||
'sn' => generate_sn((new ShopAccountLog()), 'sn', 20),
|
||||
'shop_id' => $shopId,
|
||||
'change_object' => $changeObject,
|
||||
'change_type' => $changeType,
|
||||
'action' => $action,
|
||||
'left_amount' => $leftAmount,
|
||||
'change_amount' => $changeAmount,
|
||||
'source_sn' => $sourceSn,
|
||||
'remark' => $remark,
|
||||
'extra' => $extra ? json_encode($extra, JSON_UNESCAPED_UNICODE) : '',
|
||||
'admin_id' => $adminId
|
||||
];
|
||||
|
||||
return ShopAccountLog::create($data);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user