feat(shopro): 中羿体育活动报名费处理

- 新增报名费商品类别和商品创建逻辑
- 实现报名费价格动态更新
- 添加活动报名功能
- 优化 SkuPrice trait 中的 sku 处理逻辑
- 修复活动列表和详情页面的一些小问题
This commit is contained in:
2025-05-30 14:39:30 +08:00
parent 94a540ac96
commit 6e655c6121
4 changed files with 109 additions and 29 deletions

View File

@@ -40,7 +40,13 @@ trait SkuPrice
protected function editSimSku($goods, $type = 'add')
{
$params = $this->request->only([
'stock', 'stock_warning', 'sn', 'weight', 'cost_price', 'original_price', 'price'
'stock',
'stock_warning',
'sn',
'weight',
'cost_price',
'original_price',
'price'
]);
$data = [
@@ -83,7 +89,36 @@ trait SkuPrice
// 检测库存预警
$this->checkStockWarning($skuPrice, $type);
}
}
// 中羿体育项目报名费sku处理
private function zySku($goods, $type)
{
$data = [
'goods_id' => $goods->id,
'stock' => 999,
'cost_price' => 0,
'original_price' => 0,
'price' => $goods['price'][0] ?? 0,
'original_price' => $goods['price'][0] ?? 0,
'stock_warning' => null
];
if ($type == 'edit') {
$skuPrice = SkuPriceModel::where('goods_id', $goods->id)->order('id', 'asc')->find();
if ($skuPrice) {
SkuPriceModel::where('goods_id', $goods->id)->where('id', '<>', $skuPrice->id)->delete();
SkuModel::where('goods_id', $goods->id)->delete();
}
unset($data['stock']);
}
if (!isset($skuPrice) || !$skuPrice) {
$skuPrice = new SkuPriceModel();
}
$skuPrice->save($data);
if ($type == 'add') {
$this->addStockLog($skuPrice, 0, $data['stock'], $type);
$this->checkStockWarning($skuPrice, $type);
}
}
@@ -97,7 +132,8 @@ trait SkuPrice
protected function editMultSku($goods, $type = 'add')
{
$params = $this->request->only([
'skus', 'sku_prices'
'skus',
'sku_prices'
]);
$skus = $params['skus'] ?? [];
$skuPrices = $params['sku_prices'] ?? [];
@@ -176,7 +212,7 @@ trait SkuPrice
* @param array $skuPrices
* @return void
*/
private function checkMultSku($skus, $skuPrices)
private function checkMultSku($skus, $skuPrices)
{
if (count($skus) < 1) {
error_stop('请填写规格列表');
@@ -300,4 +336,4 @@ trait SkuPrice
return $allChildrenSku;
}
}
}

View File

@@ -8,14 +8,14 @@ use think\Model;
class Activity extends Model
{
// 表名
protected $table = 'zy_activity';
public static $tableName = 'zy_activity';
// 自动写入时间戳字段
protected $autoWriteTimestamp = false;
@@ -25,15 +25,14 @@ class Activity extends Model
protected $deleteTime = false;
// 追加属性
protected $append = [
];
protected $append = [];
public $costKey = ['man' => '男报名费', 'woman' => '女报名费', 'extra' => '附加费', 'server' => '服务费'];
public function stadium()
{