初始化项目

This commit is contained in:
2026-09-01 22:15:50 +08:00
commit b5a26a8848
11217 changed files with 1710987 additions and 0 deletions
+124
View File
@@ -0,0 +1,124 @@
<?php
declare (strict_types=1);
namespace app\store\model;
use app\common\model\Bank as BankModel;
use think\Db;
/**
* 银行账户模型
* Class Goods
* @package app\store\model
*/
class Bank extends BankModel
{
/**
* 添加银行账户
* @param array $data
* @return bool
*/
public function add(array $data)
{
/*if (!isset($data['images']) || empty($data['images'])) {
$this->error = '请上传商品图片';
return false;
}*/
$data['wxapp_id'] = $data['sku']['wxapp_id'] = self::$wxapp_id;
// 开启事务
Db::startTrans();
try {
// 添加商品
$this->allowField(true)->save($data);
// 商品图片
//$this->addSupplierImages($data['images']);
Db::commit();
return $this->bank_id;
} catch (\Exception $e) {
$this->error = $e->getMessage();
Db::rollback();
}
return false;
}
/**
* 添加供货商图片
* @param $images
* @return int
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
private function addSupplierImages($images)
{
$this->image()->delete();
$data = array_map(function ($image_id) {
return [
'image_id' => $image_id,
'wxapp_id' => self::$wxapp_id
];
}, $images);
return $this->image()->saveAll($data);
}
/**
* 编辑银行账户
* @param $data
* @return bool
*/
public function edit($data)
{
/*if (!isset($data['images']) || empty($data['images'])) {
$this->error = '请上传商品图片';
return false;
}*/
$data['wxapp_id'] = $data['sku']['wxapp_id'] = self::$wxapp_id;
// 开启事务
Db::startTrans();
try {
// 保存商品
$this->allowField(true)->save($data);
// 商品图片
//$this->addSupplierImages($data['images']);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
$this->error = $e->getMessage();
return false;
}
}
/**
* 修改银行账户状态
* @param $status
* @return false|int
*/
public function setStatus($status)
{
return $this->save(['status' => $status]) !== false;
}
/**
* 修改银行其他账户状态为非默认,只能有一个默认
* @param $bank_id
* @param $store_user_id
* @return false|int
*/
public function setOtherStatus($bank_id,$store_user_id)
{
$where = array(
'bank_id' => array('neq', $bank_id),
'store_user_id' => array('eq', $store_user_id),
);
return $this->save(['status' => 2],$where) !== false;
}
/**
* 删除
* @param $bank_id
* @return false|int
*/
public function setDelete($bank_id)
{
return $this->where(['bank_id' => $bank_id])->delete();
}
}