From a4b3ee325c7354579d495bc74a777e494e5ec38c Mon Sep 17 00:00:00 2001
From: quanwei <419654421@qq.com>
Date: Fri, 06 Feb 2026 18:18:44 +0800
Subject: [PATCH] 商品可以价格面议 选择走访时显示输入走访企业名 分会添加活动时要总会审核 分类添加人数限制,添加活动选择了填写人数限制的分类时活动名额下显示该分类人数限制为15 同一个企业30天内只能走访一次,在30天内走访同一个企业时提示该企业已被走访xx天后才可以从新走访
---
admin/app/common/model/order/Order.php | 44 +++++++++++++++++++++++++++++++++++++++++---
1 files changed, 41 insertions(+), 3 deletions(-)
diff --git a/admin/app/common/model/order/Order.php b/admin/app/common/model/order/Order.php
index a4266cf..d2a6eb4 100644
--- a/admin/app/common/model/order/Order.php
+++ b/admin/app/common/model/order/Order.php
@@ -3,6 +3,7 @@
namespace app\common\model\order;
use app\common\enum\order\OrderSourceEnum;
+use app\common\enum\supplier\SupplierType;
use app\common\exception\BaseException;
use app\common\library\easywechat\AppWx;
use app\common\library\easywechat\wx\WxOrder;
@@ -48,7 +49,6 @@
'order_source_text',
'pay_end_time_text',
];
-
/**
* 关联预售定金订单
* @return \think\model\relation\HasOne
@@ -128,7 +128,7 @@
*/
public function supplier()
{
- return $this->belongsTo('app\\common\\model\\supplier\\Supplier', 'shop_supplier_id', 'shop_supplier_id')->field(['shop_supplier_id', 'name', 'user_id']);
+ return $this->belongsTo('app\\common\\model\\supplier\\Supplier', 'shop_supplier_id', 'shop_supplier_id')->field(['shop_supplier_id', 'name', 'user_id', 'referee_id','supplier_type','gift_type']);
}
/**
@@ -590,6 +590,8 @@
}
$this['advance']->save(['order_status' => 20]);
}
+ // 减少用户购买商品次数
+ UserModel::decreasePurchaseCount($this['user_id'], $this['product'], $this['app_id']);
// 更新订单状态
return $this->save(['order_status' => 20,'is_refund' => 1,'refund_money' => $this['pay_price'], 'cancel_remark' => $data['cancel_remark']]);
});
@@ -619,7 +621,7 @@
// 回退用户积分
$user = UserModel::detail($this['user_id']);
$describe = "订单取消:{$this['order_no']}";
- $this['points_num'] > 0 && $user->setIncPoints($this['points_num'], $describe);
+ $this['points_num'] > 0 && $user->setIncPoints($this['points_num'], $describe,0,true,($this['supplier']['supplier_type'] == SupplierType::GROUPBUYING?1:0));
//预售订单
if ($this['order_source'] == OrderSourceEnum::ADVANCE) {
if ($this['advance']['money_return'] == 1) {//预售订单退定金
@@ -634,6 +636,8 @@
$this['advance']->save(['order_status' => 20]);
}
}
+ // 减少用户购买商品次数
+ UserModel::decreasePurchaseCount($this['user_id'], $this['product'], $this['app_id']);
// 更新订单状态
//return $this->save(['order_status' => $data['is_cancel'] ? 20 : 10]);
return $this->save([
@@ -880,6 +884,7 @@
return $count;
}
+
public function sendWxExpress($express_id, $express_no)
{
//判断后台是否设置了微信发货 by yj 2024.4.10
@@ -1032,4 +1037,37 @@
return $num;
}
+
+ /**
+ * 获取用户是否购买过指定商品
+ * @param int $user_id 用户ID
+ * @param array $product_ids 商品ID数组
+ * @param bool $is_complete 是否只查询已完成的订单
+ * @return array|bool
+ */
+ public static function getOrderProductIds($user_id, $product_ids = [], $is_complete = false)
+ {
+ // 构建查询条件
+ $model = (new static())->alias('o')
+ ->join('order_product op', 'o.order_id = op.order_id')
+ ->where('o.user_id', '=', $user_id)
+ ->where('o.order_source', '=', OrderSourceEnum::MASTER)
+ ->where('o.is_delete', '=', 0);
+ // 如果指定了商品ID,则只查询这些商品
+ if (!empty($product_ids)) {
+ $model->where('op.product_id', 'in', $product_ids);
+ }
+
+ // 如果只查询已完成的订单
+ if ($is_complete) {
+ $model->where('o.order_status', '=', 30); // 已完成状态
+ } else {
+ // 排除已取消的订单
+ $model->where('o.order_status', '<>', 20);
+ }
+
+ // 查询用户购买过的商品ID
+ $result = $model->group('op.product_id')->column('op.product_id');
+ return $result ?true:false;
+ }
}
\ No newline at end of file
--
Gitblit v1.9.2