| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- <?php
- namespace App\Models\Api\Process;
- use Illuminate\Database\Eloquent\Factories\HasFactory;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Support\Facades\DB;
- /**
- * 违规处理-低价商品处理人员关系模型
- * @author: 唐远望
- * @version: 1.0
- * @date: 2025-12-10
- */
- class LowPriceGoodsMember extends Model
- {
- use HasFactory;
- // 与模型关联的表名
- protected $table = 'process_lowprice_product_member';
- // 是否主动维护时间戳
- public $timestamps = false;
- // 定义时间戳字段名
- // const CREATED_AT = 'insert_time';
- // const UPDATED_AT = 'update_time';
- /**
- * 添加
- * @author 唐远望
- * @version 1.0
- * @date 2025-12-10
- */
- public function addLowPriceGoodsMember_content($data)
- {
- $insert_data = [
- 'lowprice_product_logid' => $data['lowprice_product_logid'],
- 'employee_id' => $data['employee_id'],
- 'duty_type' => $data['duty_type'],
- ];
- $LowPriceGoodsMember_id = $this->insertGetId($insert_data);
- return $LowPriceGoodsMember_id;
- }
- /**
- * 写入数据
- * @author 唐远望
- * @version 1.0
- * @date 2025-12-10
- * @param $data
- * @return bool
- */
- public function addLowPriceGoodsMember($data)
- {
- DB::beginTransaction();
- try {
- $this->addLowPriceGoodsMember_content($data);
- DB::commit();
- return true;
- // 成功处理...
- } catch (\Exception $e) {
- DB::rollBack();
- // 错误处理...
- return false;
- }
- }
- /**
- * 编辑内容
- * @author 唐远望
- * @version 1.0
- * @date 2025-12-10
- * @param $data
- * @return bool
- */
- public function editLowPriceGoodsMember_content($where, $data)
- {
- $LowPriceGoodsMember = $this->where($where)->first();
- if (!$LowPriceGoodsMember) {
- return false;
- }
- $LowPriceGoodsMember->lowprice_product_logid = $data['lowprice_product_logid'];
- $LowPriceGoodsMember->employee_id = $data['employee_id'];
- $LowPriceGoodsMember->duty_type = $data['duty_type'];
- $LowPriceGoodsMember->save();
- return true;
- }
- /**
- * 更新数据
- * @author 唐远望
- * @version 1.0
- * @date 2025-12-10
- * @param $data
- * @return bool
- */
- public function updateLowPriceGoodsMember($where, $data)
- {
- DB::beginTransaction();
- try {
- $this->editLowPriceGoodsMember_content($where, $data);
- DB::commit();
- return true;
- // 成功处理...
- } catch (\Exception $e) {
- DB::rollBack();
- // 错误处理...
- return false;
- }
- }
- /**
- * 删除数据
- * @author 唐远望
- * @version 1.0
- * @date 2025-12-10
- * @param $id
- * @return bool
- */
- public function deleteLowPriceGoodsMember($where)
- {
- $LowPriceGoodsMember = $this->where($where)->first();
- if (!$LowPriceGoodsMember) {
- return false;
- }
- $LowPriceGoodsMember->delete();
- return true;
- }
- }
|