|
@@ -10,6 +10,8 @@ use app\model\CouponDetail;
|
|
use app\model\CouponGoods;
|
|
use app\model\CouponGoods;
|
|
use app\model\CouponPacket;
|
|
use app\model\CouponPacket;
|
|
use app\model\CouponPacketSequence;
|
|
use app\model\CouponPacketSequence;
|
|
|
|
+use app\model\SysCategory;
|
|
|
|
+use app\model\SysDept;
|
|
use support\Request;
|
|
use support\Request;
|
|
use support\Response;
|
|
use support\Response;
|
|
|
|
|
|
@@ -47,8 +49,8 @@ class CouponPacketSequenceController extends Curd
|
|
protected function doSelect(array $where, string $field = null, string $order = 'desc')
|
|
protected function doSelect(array $where, string $field = null, string $order = 'desc')
|
|
{
|
|
{
|
|
$model = $this->model->with([
|
|
$model = $this->model->with([
|
|
- 'packet'=>function($query){
|
|
|
|
- $query->select('coupon_packet_id','coupon_packet_name');
|
|
|
|
|
|
+ 'packet' => function ($query) {
|
|
|
|
+ $query->select('coupon_packet_id', 'coupon_packet_name');
|
|
},
|
|
},
|
|
'member' => function ($query) {
|
|
'member' => function ($query) {
|
|
$query->select('member_id', 'member_mobile');
|
|
$query->select('member_id', 'member_mobile');
|
|
@@ -157,22 +159,37 @@ class CouponPacketSequenceController extends Curd
|
|
*/
|
|
*/
|
|
public function info(Request $request): Response
|
|
public function info(Request $request): Response
|
|
{
|
|
{
|
|
- $detailId = $request->get('detail_id', '');
|
|
|
|
- if (empty($detailId)) {
|
|
|
|
|
|
+ $packetSequenceId = $request->get('coupon_packet_sequence_id', '');
|
|
|
|
+ if (empty($packetSequenceId)) {
|
|
return json_fail('参数异常');
|
|
return json_fail('参数异常');
|
|
}
|
|
}
|
|
|
|
|
|
- $detail = CouponDetail::where('coupon_detail_id', $detailId)
|
|
|
|
- ->select('coupon_detail_id', 'coupon_detail_extend_json')
|
|
|
|
|
|
+ $sequence = CouponPacketSequence::with([
|
|
|
|
+ 'packet' => function ($query) {
|
|
|
|
+ $query->select('coupon_packet_id', 'coupon_packet_name', 'join_coupon_packet_category_id', 'join_coupon_packet_dept_id', 'coupon_packet_status', 'coupon_packet_issue_num', 'coupon_packet_issue_datetime');
|
|
|
|
+ }
|
|
|
|
+ ])->where('coupon_packet_sequence_id', $packetSequenceId)
|
|
->first();
|
|
->first();
|
|
- if (!empty($detail->coupon_detail_extend_json)) {
|
|
|
|
- $couponDetailExtendJson = json_decode($detail->coupon_detail_extend_json, true);
|
|
|
|
- if (isset($couponDetailExtendJson['from'])) {
|
|
|
|
- $detail['from'] = MemberService::getMemberNameByMemberId($couponDetailExtendJson['from']);
|
|
|
|
|
|
+ if(!empty($sequence->packet)){
|
|
|
|
+ if ($sequence->packet->join_coupon_packet_dept_id == 0){
|
|
|
|
+ $sequence->packet->dept_name = '所有门店';
|
|
|
|
+ }else{
|
|
|
|
+ $sequence->packet->dept_nam = '';
|
|
|
|
+ $dept = SysDept::where('dept_id',$sequence->packet->join_coupon_packet_dept_id)->select('dept_id','dept_name')->first();
|
|
|
|
+ if (!empty($dept)){
|
|
|
|
+ $sequence->packet->dept_name = $dept->dept_name;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (!empty($sequence->packet->join_coupon_packet_category_id)){
|
|
|
|
+ $category = SysCategory::where('category_id',$sequence->packet->join_coupon_packet_category_id)
|
|
|
|
+ ->first();
|
|
|
|
+ if (!empty($category->category_name)){
|
|
|
|
+ $sequence->packet->category_name = $category->category_name;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- return json_success('', $detail);
|
|
|
|
|
|
+ return json_success('', $sequence);
|
|
}
|
|
}
|
|
|
|
|
|
public function myCouponGrouping(Request $request)
|
|
public function myCouponGrouping(Request $request)
|
|
@@ -201,12 +218,12 @@ class CouponPacketSequenceController extends Curd
|
|
}
|
|
}
|
|
])->whereIn('join_detail_coupon_id', $couponIds)
|
|
])->whereIn('join_detail_coupon_id', $couponIds)
|
|
->where('join_coupon_detail_member_id', $memberId);
|
|
->where('join_coupon_detail_member_id', $memberId);
|
|
- if ($settlementNow == 'Y') {
|
|
|
|
- $details = $details->whereIn('coupon_detail.coupon_detail_status', ['ACTIVED', 'WAITING']);
|
|
|
|
- } else {
|
|
|
|
- $details = $details->where('coupon_detail.coupon_detail_status', 'ACTIVED');
|
|
|
|
- }
|
|
|
|
- $details = $details->selectRaw('join_detail_coupon_id,join_coupon_detail_member_id,COUNT(*) as count')
|
|
|
|
|
|
+ if ($settlementNow == 'Y') {
|
|
|
|
+ $details = $details->whereIn('coupon_detail.coupon_detail_status', ['ACTIVED', 'WAITING']);
|
|
|
|
+ } else {
|
|
|
|
+ $details = $details->where('coupon_detail.coupon_detail_status', 'ACTIVED');
|
|
|
|
+ }
|
|
|
|
+ $details = $details->selectRaw('join_detail_coupon_id,join_coupon_detail_member_id,COUNT(*) as count')
|
|
->groupBy('join_detail_coupon_id', 'join_coupon_detail_member_id')
|
|
->groupBy('join_detail_coupon_id', 'join_coupon_detail_member_id')
|
|
->get()
|
|
->get()
|
|
->toArray();
|
|
->toArray();
|