2020-07-05 14:47:44 +08:00

68 lines
2.6 KiB
PHP
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace wstmart\common\model;
use think\Db;
/**
* ============================================================================
* 系统数据
*/
class SysSummary extends Base{
public function addToPayFast($orderId,$payFastNum,$fastScale,$sm=''){
$noticeData['orderId'] = $orderId;
$noticeData['toPayFast'] = $payFastNum;
$noticeData['fastScale'] = $fastScale;
$noticeData['createTime'] = time();
Db::name('sys_notice')->insert($noticeData);
// 原当购户“预获优惠券”、“预获产品券”的值同时≤15元时所获“已获优惠券”、“已获产品券”转入代快付值
// 改为当购户“预获优惠券”、“预获产品券”的值同时≤15元时所获“已获优惠券”、“已获产品券”转入代慢付值
$this->addSysSummary($payFastNum, 0, 1,$sm);
}
/**
* 添加系统数据
* @param integer $payFastNum [代快付值]
* @param integer $payFastSlow [代慢付值]
* @param integer $isAdd [1加2减]
*/
public function addSysSummary($payFastNum=0,$payFastSlow=0,$isAdd=1,$sm=''){
if($payFastNum){
$this->addSysLog($payFastNum,1,$isAdd,$sm);
if(1 == $isAdd){
$this->where(['id'=>1])->setInc('toPayFast',$payFastNum);
}else{
$this->where(['id'=>1])->setDec('toPayFast',$payFastNum);
}
}
if($payFastSlow){
$this->addSysLog($payFastSlow,2,$isAdd,$sm);
if(1 == $isAdd){
$this->where(['id'=>1])->setInc('toPaySlow',$payFastSlow);
}else{
$this->where(['id'=>1])->setDec('toPaySlow',$payFastSlow);
}
}
}
/**
* 加入系统记录
* @param [type] $num [数量]
* @param [type] $type [1代快付值 2代慢付值]
* @param [type] $changeType [1加 2减]
* @param integer $adminId [操作人员ID0为系统]
*/
public function addSysLog($num,$type,$changeType=1,$sm='',$adminId=0){
$data['num'] = $num;
$data['type'] = $type;
$data['changeType'] = $changeType;
$data['adminId'] = $adminId;
$data['remark'] = $sm;
$data['createTime'] = time();
Db::name('log_sys_data')->insert($data);
}
/**
* 获取系统数据,代快付,代慢付
* @param string $field [description]
* @return [type] [description]
*/
public function getInfo($field='toPayFast'){
return $this->where(['id'=>1])->field($field)->find();
}
}