增加提货数量+领取时间和提货时间
This commit is contained in:
@@ -56,6 +56,9 @@ class CodeController extends AdminController
|
||||
});
|
||||
$grid->column('area.title', '地区名称');
|
||||
$grid->column('status', '状态')->using(AreaCode::STATUS);
|
||||
$grid->column('get_at', '领取时间');
|
||||
$grid->column('pick_at', '提货时间');
|
||||
$grid->column('created_at', '创建时间');
|
||||
$grid->column('created_at', '创建时间');
|
||||
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Api\Controllers\Controller;
|
||||
use App\Api\Resources\Area\AreaCodeCollection;
|
||||
use App\Api\Resources\Area\AreaResource;
|
||||
use App\Models\Area;
|
||||
use App\Models\AreaCode;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Jason\Api\Api;
|
||||
@@ -90,7 +91,15 @@ class IndexController extends Controller
|
||||
})
|
||||
->paginate();
|
||||
|
||||
return $this->success(new AreaCodeCollection($codes));
|
||||
$data = [
|
||||
'count' => [
|
||||
'all' => $area->areaCodes()->count(),
|
||||
'get' => $area->areaCodes()->where('status', AreaCode::STATUS_USED)->count(),
|
||||
'pick' => $area->areaCodes()->where('status', AreaCode::STATUS_SIGN)->count(),
|
||||
],
|
||||
'lists' => new AreaCodeCollection($codes),
|
||||
];
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,6 +20,8 @@ class AreaCodeCollection extends BaseCollection
|
||||
'status' => $info->status,
|
||||
'text' => $info->status_text,
|
||||
],
|
||||
'get_at' => (string) $info->get_at,
|
||||
'pick_at' => (string) $info->pick_at,
|
||||
];
|
||||
}),
|
||||
'page' => $this->page(),
|
||||
|
||||
@@ -23,6 +23,10 @@ class AreaCode extends Model
|
||||
self::STATUS_SIGN => '已核销',
|
||||
];
|
||||
|
||||
public $dates=[
|
||||
'get_at','pick_at'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 生成人-管理人
|
||||
@@ -58,7 +62,8 @@ class AreaCode extends Model
|
||||
{
|
||||
$this->order->state = Order::STATUS_SIGNED;
|
||||
$this->order->save();
|
||||
$this->status = self::STATUS_SIGN;
|
||||
$this->status = self::STATUS_SIGN;
|
||||
$this->pick_at = now();
|
||||
$this->save();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ class CreateAreaCodesTable extends Migration
|
||||
$table->unsignedBigInteger('area_id')->index();
|
||||
$table->string('code');
|
||||
$table->boolean('status')->default(0);
|
||||
$table->timestamp('get_at')->nullable()->comment('领取时间');
|
||||
$table->timestamp('pick_at')->nullable()->comment('提货时间');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
@@ -77,9 +77,6 @@ class OrderBuyController extends Controller
|
||||
|
||||
|
||||
$type = OrderModel::TYPE_NORMAL;
|
||||
info($goods_sku->goods->channel);
|
||||
info($goods_sku->goods->id);
|
||||
info($goods_sku->id);
|
||||
|
||||
if ($goods_sku->goods->channel == Goods::CHANNEL_FREE) {
|
||||
$type = OrderModel::TYPE_SAMPLE;
|
||||
@@ -89,13 +86,10 @@ class OrderBuyController extends Controller
|
||||
$type = OrderModel::TYPE_SCORE;
|
||||
}
|
||||
|
||||
$areaCode = $user->info->areaCode;
|
||||
if ($type == OrderModel::TYPE_SAMPLE) {
|
||||
if (! $user->info->areaCode) {
|
||||
return $this->failed('您没有提货码不可参与此活动');
|
||||
}
|
||||
$areaCode = AreaCode::where('code', $user->info->areaCode)->first();
|
||||
if (! $areaCode) {
|
||||
return $this->failed('您绑定的提货码不正确');
|
||||
return $this->failed('您没有提货码不可参与此活动');
|
||||
}
|
||||
|
||||
if ($areaCode->status != AreaCode::STATUS_INIT) {
|
||||
@@ -190,13 +184,10 @@ class OrderBuyController extends Controller
|
||||
$type = OrderModel::TYPE_SCORE;
|
||||
}
|
||||
|
||||
$areaCode = $user->info->areaCode;
|
||||
if ($type == OrderModel::TYPE_SAMPLE) {
|
||||
if (! $user->info->areaCode) {
|
||||
return $this->failed('您没有提货码不可参与此活动');
|
||||
}
|
||||
$areaCode = AreaCode::where('code', $user->info->areaCode)->first();
|
||||
if (! $areaCode) {
|
||||
return $this->failed('您绑定的提货码不正确');
|
||||
return $this->failed('您没有提货码不可参与此活动');
|
||||
}
|
||||
|
||||
if ($areaCode->status != AreaCode::STATUS_INIT) {
|
||||
@@ -204,6 +195,7 @@ class OrderBuyController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$address = Address::where('user_id', $user->id)->where('id', $address_id)->first();
|
||||
|
||||
if (in_array($type, [OrderModel::TYPE_SCORE, OrderModel::TYPE_NORMAL]) && ! $address) {
|
||||
|
||||
@@ -480,7 +480,8 @@ class WeChatController extends Controller
|
||||
'delivery_code' => $delivery_code
|
||||
]);
|
||||
$areaCode->update([
|
||||
'user_id' => $user->id
|
||||
'user_id' => $user->id,
|
||||
'get_at' => now()
|
||||
]);
|
||||
} else {
|
||||
if ($user->info->delivery_code && $user->info->delivery_code != $delivery_code) {
|
||||
|
||||
Reference in New Issue
Block a user