147 lines
2.9 KiB
PHP
Executable File
147 lines
2.9 KiB
PHP
Executable File
<?php
|
|
|
|
namespace wstmart\admin\model;
|
|
|
|
/**
|
|
|
|
* ============================================================================
|
|
|
|
* 商城配置业务处理
|
|
|
|
*/
|
|
|
|
use think\Db;
|
|
|
|
class SysConfigs extends Base{
|
|
|
|
/**
|
|
|
|
* 获取商城配置
|
|
|
|
*/
|
|
|
|
public function getSysConfigs(){
|
|
|
|
$rs = $this->field('fieldCode,fieldValue')->select();
|
|
|
|
$rv = [];
|
|
|
|
$split = [
|
|
|
|
'submitOrderTipUsers','payOrderTipUsers','cancelOrderTipUsers','rejectOrderTipUsers','refundOrderTipUsers','complaintOrderTipUsers','cashDrawsTipUsers'
|
|
|
|
];
|
|
|
|
foreach ($rs as $v){
|
|
|
|
if(in_array($v['fieldCode'],$split)){
|
|
|
|
$rv[$v['fieldCode']] = ($v['fieldValue']=='')?[]:explode(',',$v['fieldValue']);
|
|
|
|
}else{
|
|
|
|
$rv[$v['fieldCode']] = $v['fieldValue'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$signScore = explode(",",$rv['signScore']);
|
|
|
|
for($i=0;$i<31;++$i){
|
|
|
|
$rv['signScore'.$i] = ($signScore[0]==0)?0:$signScore[$i];
|
|
|
|
}
|
|
|
|
return $rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 编辑
|
|
|
|
*/
|
|
|
|
public function edit($fieldType = 0){
|
|
\think\Cache::clear();
|
|
if(1 == input('isDataConfigs')){
|
|
$data = input('post.');
|
|
unset($data['isDataConfigs']);
|
|
$m = Model('Table');
|
|
$m->setTable('data_configs');
|
|
Db::startTrans();
|
|
try{
|
|
foreach ($data as $k=>$v) {
|
|
$m->updateInfo(['configId'=>$k],['fieldValue'=>$v]);
|
|
}
|
|
if (isset($data['jiri_jiyan'])) {
|
|
$this->update(['fieldValue'=>$data['jiri_jiyan']],['fieldCode'=>'jiri_jiyan']);
|
|
}
|
|
if (isset($data['jiri_get_percent'])) {
|
|
$this->update(['fieldValue'=>floatval($data['jiri_get_percent'])],['fieldCode'=>'jiri_get_percent']);
|
|
}
|
|
if (isset($data['jiri'])) {
|
|
$time = strtotime($data['jiri']);
|
|
if (empty($time)) {return WSTReturn("操作失败;吉日日期格式不对", 1);}
|
|
$this->update(['fieldValue'=>date('Y/m/d', $time)],['fieldCode'=>'jiri']);
|
|
}
|
|
Db::commit();
|
|
return WSTReturn("操作成功", 1);
|
|
}catch (\Exception $e) {
|
|
Db::rollback();errLog($e);
|
|
}
|
|
}else{
|
|
$list = $this->where('fieldType',$fieldType)->field('configId,fieldCode,fieldValue')->select();
|
|
Db::startTrans();
|
|
|
|
try{
|
|
|
|
foreach ($list as $key =>$v){
|
|
|
|
$code = trim($v['fieldCode']);
|
|
|
|
if(in_array($code,['wstVersion','wstMd5','wstMobileImgSuffix','mallLicense']))continue;
|
|
|
|
$val = Input('post.'.trim($v['fieldCode']));
|
|
|
|
//启用图片
|
|
|
|
if(substr($val,0,7)=='upload/' && strpos($val,'.')!==false){
|
|
|
|
WSTUseImages(1, $v['configId'],$val, 'sys_configs','fieldValue');
|
|
|
|
}
|
|
|
|
$this->update(['fieldValue'=>$val],['fieldCode'=>$code]);
|
|
|
|
}
|
|
|
|
Db::commit();
|
|
|
|
cache('WST_CONF',null);
|
|
|
|
return WSTReturn("操作成功", 1);
|
|
|
|
}catch (\Exception $e) {
|
|
|
|
Db::rollback();errLog($e);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
return WSTReturn("操作失败", 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|