First commit
This commit is contained in:
161
app/massage/model/CouponService.php
Executable file
161
app/massage/model/CouponService.php
Executable file
@@ -0,0 +1,161 @@
|
||||
<?php
|
||||
namespace app\massage\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use think\facade\Db;
|
||||
|
||||
class CouponService extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'massage_service_coupon_goods';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:04
|
||||
* @功能说明:添加
|
||||
*/
|
||||
public function dataAdd($data){
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:05
|
||||
* @功能说明:编辑
|
||||
*/
|
||||
public function goodsUpdate($dis,$data){
|
||||
|
||||
$spe = $data['spe'];
|
||||
|
||||
unset($data['spe']);
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
$this->updateSome($dis['id'],$data['uniacid'],$spe);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @param $uniacid
|
||||
* @param $spe
|
||||
* @功能说明:
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-23 13:35
|
||||
*/
|
||||
public function updateSome($id,$uniacid,$coach){
|
||||
|
||||
$spe_model = new GoodsSpe();
|
||||
|
||||
$spe_model->where(['goods_id'=>$id])->delete();
|
||||
|
||||
if(!empty($spe)){
|
||||
|
||||
foreach ($spe as $value){
|
||||
|
||||
$value['uniacid'] = $uniacid;
|
||||
|
||||
$value['goods_id'] = $id;
|
||||
|
||||
$spe_model->dataAdd($value);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:05
|
||||
* @功能说明:编辑
|
||||
*/
|
||||
public function dataUpdate($dis,$data){
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:06
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function dataList($dis,$page){
|
||||
|
||||
$data = $this->where($dis)->order('top desc,id desc')->paginate($page)->toArray();
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:43
|
||||
* @功能说明:
|
||||
*/
|
||||
public function dataInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-11-01 15:43
|
||||
* @功能说明:优惠券
|
||||
*/
|
||||
public function eventCoupon($id,$data){
|
||||
|
||||
if(!empty($data['service'])){
|
||||
|
||||
foreach ($data['service'] as $value){
|
||||
|
||||
$insert['uniacid'] = $data['uniacid'];
|
||||
|
||||
$insert['coupon_id'] = $id;
|
||||
|
||||
$insert['goods_id'] = $value;
|
||||
|
||||
$this->dataAdd($insert);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user