parent
f2700ff5a0
commit
8d2e9e8814
|
|
@ -14,6 +14,7 @@ use app\common\model\user\User;
|
|||
use app\common\repositories\store\order\StoreOrderStatusRepository;
|
||||
use app\common\repositories\store\product\ProductAssistSetRepository;
|
||||
use app\common\repositories\store\product\ProductGroupBuyingRepository;
|
||||
use app\common\repositories\system\merchant\MerchantRepository;
|
||||
use think\db\BaseQuery;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
|
|
@ -57,15 +58,35 @@ class StoreOrderDao extends BaseDao
|
|||
* @author xaboyCRMEB
|
||||
* @day 2020/6/16
|
||||
*/
|
||||
public function search(array $where, $sysDel = 0)
|
||||
{
|
||||
public function search(array $where, $sysDel = 0){
|
||||
$query = StoreOrder::hasWhere('merchant', function ($query) use ($where) {
|
||||
if (isset($where['is_trader']) && $where['is_trader'] !== '') {
|
||||
$query->where('is_trader', $where['is_trader']);
|
||||
}
|
||||
$query->where('is_del',0);
|
||||
});
|
||||
$query->whereNotIn('StoreOrder.activity_type',[20,30]);
|
||||
// 存在商户id是否 判断商户id类型,显示对应的订单
|
||||
if(isset($where['mer_id']) && $where['mer_id'] !== ''){
|
||||
$merchantType = app()->make(MerchantRepository::class)
|
||||
->getSearch([])
|
||||
->where('mer_id', $where['mer_id'])
|
||||
->value('merchant_type');
|
||||
// 供应商 仅显示酒道馆进货订单
|
||||
if($merchantType == 2) $where['activity_type'] = 35;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$isWithGoods = $where['is_with_goods'] ?? 0;
|
||||
$activityType = $where['activity_type'] ?? 0;
|
||||
if($isWithGoods == 1 || $activityType == 35){
|
||||
$query->whereNotIn('StoreOrder.activity_type',[20,30]);
|
||||
}else{
|
||||
$query->whereNotIn('StoreOrder.activity_type',[20,30,35]);
|
||||
}
|
||||
|
||||
$query->when(($sysDel !== null), function ($query) use ($sysDel) {
|
||||
$query->where('is_system_del', $sysDel);
|
||||
});
|
||||
|
|
@ -100,12 +121,9 @@ class StoreOrderDao extends BaseDao
|
|||
->when(isset($where['uid']) && $where['uid'] !== '', function ($query) use ($where) {
|
||||
$query->where('uid', $where['uid']);
|
||||
})
|
||||
->when(isset($where['with_goods_mer_id']) && $where['with_goods_mer_id'] !== '', function ($query) use ($where) {
|
||||
if($where['with_goods_mer_id'] > 0) $query->where('with_goods_mer_id', $where['with_goods_mer_id']);
|
||||
},function($query){
|
||||
$query->where(function($orQuery){
|
||||
$orQuery->where('with_goods_mer_id', null)->whereOr('with_goods_mer_id','<=', 0);
|
||||
});
|
||||
->when(isset($where['with_goods_mer_id']) && $where['with_goods_mer_id'] !== '' && $where['with_goods_mer_id'] > 0, function ($query) use ($where) {
|
||||
// 酒道馆查看自己进货订单
|
||||
$query->where('with_goods_mer_id', $where['with_goods_mer_id']);
|
||||
})
|
||||
->when(isset($where['is_spread']) && $where['is_spread'] !== '', function ($query) use ($where) {
|
||||
if ($where['is_spread']) {
|
||||
|
|
|
|||
|
|
@ -615,15 +615,15 @@ class StoreOrderRepository extends BaseRepository
|
|||
|
||||
public function merOrderNumber(int $merId)
|
||||
{
|
||||
$noPay =app()->make(StoreGroupOrderRepository::class)->search(['with_goods_mer_id' => $merId,'is_del' => 0,'paid' => 0],0)->count();
|
||||
$noPostage = $this->dao->search(['with_goods_mer_id' => $merId, 'status' => 0, 'paid' => 1,'is_user' => 1])->where('StoreOrder.is_del', 0)->count();
|
||||
$all = $this->dao->search(['with_goods_mer_id' => $merId, 'status' => -2,'is_user' => 1])->where('StoreOrder.is_del', 0)->count();
|
||||
$noDeliver = $this->dao->search(['with_goods_mer_id' => $merId, 'status' => 1, 'paid' => 1])->where('StoreOrder.is_del', 0)->count();
|
||||
$noComment = $this->dao->search(['with_goods_mer_id' => $merId, 'status' => 2, 'paid' => 1,'is_user' => 1])->where('StoreOrder.is_del', 0)->count();
|
||||
$done = $this->dao->search(['with_goods_mer_id' => $merId, 'status' => 3, 'paid' => 1,'is_user' => 1])->where('StoreOrder.is_del', 0)->count();
|
||||
$noPay =app()->make(StoreGroupOrderRepository::class)->search(['with_goods_mer_id' => $merId,'activity_type' => 35,'is_del' => 0,'paid' => 0],0)->count();
|
||||
$noPostage = $this->dao->search(['with_goods_mer_id' => $merId,'activity_type' => 35, 'status' => 0, 'paid' => 1,'is_user' => 1])->where('StoreOrder.is_del', 0)->count();
|
||||
$all = $this->dao->search(['with_goods_mer_id' => $merId,'activity_type' => 35, 'status' => -2,'is_user' => 1])->where('StoreOrder.is_del', 0)->count();
|
||||
$noDeliver = $this->dao->search(['with_goods_mer_id' => $merId,'activity_type' => 35, 'status' => 1, 'paid' => 1])->where('StoreOrder.is_del', 0)->count();
|
||||
$noComment = $this->dao->search(['with_goods_mer_id' => $merId,'activity_type' => 35, 'status' => 2, 'paid' => 1,'is_user' => 1])->where('StoreOrder.is_del', 0)->count();
|
||||
$done = $this->dao->search(['with_goods_mer_id' => $merId,'activity_type' => 35, 'status' => 3, 'paid' => 1,'is_user' => 1])->where('StoreOrder.is_del', 0)->count();
|
||||
$refund = 0;//app()->make(StoreRefundOrderRepository::class)->getWhereCount(['with_goods_mer_id' => $merId, 'status' => [0, 1, 2]]);
|
||||
$orderPrice = $this->dao->search(['with_goods_mer_id' => $merId, 'paid' => 1])->sum('pay_price');
|
||||
$orderCount = $this->dao->search(['with_goods_mer_id' => $merId, 'paid' => 1,'is_user' => 1])->count();
|
||||
$orderPrice = $this->dao->search(['with_goods_mer_id' => $merId,'activity_type' => 35, 'paid' => 1])->sum('pay_price');
|
||||
$orderCount = $this->dao->search(['with_goods_mer_id' => $merId,'activity_type' => 35, 'paid' => 1,'is_user' => 1])->count();
|
||||
return compact('orderPrice','noComment', 'done', 'refund', 'noDeliver', 'noPay', 'noPostage', 'orderCount', 'all');
|
||||
}
|
||||
|
||||
|
|
@ -657,7 +657,18 @@ class StoreOrderRepository extends BaseRepository
|
|||
return $query->field('uid,nickname');
|
||||
};
|
||||
}
|
||||
$order = $this->dao->search($where)->where('order_id', $id)->where('StoreOrder.is_del', 0)->with($with)->append(['refund_status','open_receipt'])->find();
|
||||
$order =
|
||||
// $this->dao->search($where)
|
||||
$this->dao->getSearch([])
|
||||
->hasWhere('merchant',function($query) use ($where){
|
||||
$query->where('is_del',0);
|
||||
})
|
||||
->where('order_id',$id)
|
||||
->where('StoreOrder.is_del',0)
|
||||
->with($with)
|
||||
->append(['refund_status','open_receipt'])
|
||||
->find();
|
||||
|
||||
if (!$order) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ class ProductRepository extends BaseRepository
|
|||
const CREATE_PARAMS = [
|
||||
"is_copy", "image", "slider_image", "store_name", "store_info", "keyword", "bar_code", "guarantee_template_id", "cate_id", "unit_name", "sort" , "is_show", "is_good", 'is_gift_bag', 'integral_rate', "video_link", "temp_id", "content", "spec_type", "extension_type", "attr", 'mer_labels', 'delivery_way', 'delivery_free','param_temp_id','extend',
|
||||
["mer_cate_id",[]],
|
||||
['refund_switch',1],
|
||||
['refund_switch',0],
|
||||
["brand_id",0],
|
||||
['once_max_count',0],
|
||||
['once_min_count',0],
|
||||
|
|
@ -2441,6 +2441,10 @@ class ProductRepository extends BaseRepository
|
|||
if (!$count) throw new ValidateException('平台分类不存在或不可用');
|
||||
app()->make(StoreProductValidate::class)->check($data);
|
||||
$data['extend'] = $extend ?? [];
|
||||
// 判断:如果当前为供应商商品 则强制禁止退款
|
||||
$merchantType = app()->make(MerchantRepository::class)->getSearch([])->where('mer_id', $merId)->value('merchant_type');
|
||||
if($merchantType == 2) $data['refund_switch'] = 0;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,27 +16,42 @@ class OrderTakeEvent{
|
|||
public function handle($data){
|
||||
try{
|
||||
$order = $data['order'];
|
||||
// Log::info('订单进入待评价 - 酒卡额度相关处理 - 开始: '.var_export(['order_id' => $order->order_id,'uid' => $order->uid],1));
|
||||
# 获取变更记录 条件:order_id=当前订单id、变更类型=增加
|
||||
$sum = (float)app()->make(ExchangeQuotaRecordRepository::class)
|
||||
->searchModel([
|
||||
'order_id' => $order->order_id,
|
||||
'change_type' => 1,
|
||||
'source' => 0,// 仅查询购买赠送 进行解冻
|
||||
])->sum('change_quantity');
|
||||
$refundSum = (float)app()->make(ExchangeQuotaRecordRepository::class)
|
||||
->searchModel([
|
||||
'order_id' => $order->order_id,
|
||||
'change_type' => 0,
|
||||
'source' => 1,// 仅查询订单退款 减少内容
|
||||
])->sum('change_quantity');
|
||||
// 剩余数量 解冻
|
||||
$surplusQuota = (float)sprintf("%.2f",$sum - $refundSum);
|
||||
if($surplusQuota > 0){
|
||||
$hold = app()->make(ExchangeQuotaRepository::class)->searchModel(['uid'=>$order->uid])->findOrEmpty();
|
||||
$freezeQuota = sprintf("%.2f",$hold->freeze_quota - $surplusQuota);
|
||||
$hold->freeze_quota = $freezeQuota < 0 ? 0 : $freezeQuota;
|
||||
$hold->save();
|
||||
Log::info('订单进入待评价 - 酒卡额度相关处理 - 开始: '.var_export([
|
||||
'order_id' => $order->order_id,
|
||||
'uid' => $order->uid,
|
||||
'activity_type' => $order->activity_type
|
||||
],1));
|
||||
|
||||
if($order->activity_type == 35){
|
||||
// 酒道馆进货商品确认收货 复制商品||增加库存
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
// 其他商品
|
||||
# 获取变更记录 条件:order_id=当前订单id、变更类型=增加
|
||||
$sum = (float)app()->make(ExchangeQuotaRecordRepository::class)
|
||||
->searchModel([
|
||||
'order_id' => $order->order_id,
|
||||
'change_type' => 1,
|
||||
'source' => 0,// 仅查询购买赠送 进行解冻
|
||||
])->sum('change_quantity');
|
||||
$refundSum = (float)app()->make(ExchangeQuotaRecordRepository::class)
|
||||
->searchModel([
|
||||
'order_id' => $order->order_id,
|
||||
'change_type' => 0,
|
||||
'source' => 1,// 仅查询订单退款 减少内容
|
||||
])->sum('change_quantity');
|
||||
// 剩余数量 解冻
|
||||
$surplusQuota = (float)sprintf("%.2f",$sum - $refundSum);
|
||||
if($surplusQuota > 0){
|
||||
$hold = app()->make(ExchangeQuotaRepository::class)->searchModel(['uid'=>$order->uid])->findOrEmpty();
|
||||
$freezeQuota = sprintf("%.2f",$hold->freeze_quota - $surplusQuota);
|
||||
$hold->freeze_quota = $freezeQuota < 0 ? 0 : $freezeQuota;
|
||||
$hold->save();
|
||||
}
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
Log::info('订单进入待评价 - 酒卡额度相关处理 - 错误: '.$e->getMessage());
|
||||
|
|
|
|||
Loading…
Reference in New Issue