|
@@ -9,10 +9,12 @@
|
|
|
|
|
|
namespace app\admin\service\card;
|
|
|
|
|
|
+use app\model\CardBatch;
|
|
|
use support\Db;
|
|
|
use support\exception\BusinessException;
|
|
|
use app\model\Card;
|
|
|
use support\Request;
|
|
|
+use support\Response;
|
|
|
|
|
|
class CardService
|
|
|
{
|
|
@@ -46,7 +48,6 @@ class CardService
|
|
|
$info['card_suffix'] = $card_info['card_batch_suffix'];
|
|
|
$info['card_pass'] = mt_rand(10000000, 99999999);// 卡密
|
|
|
$info['card_amount'] = $card_info['card_batch_amount'];
|
|
|
- $info['card_added'] = $card_info['card_batch_added'];
|
|
|
$info['card_validtimes'] = $card_info['card_batch_validtimes']; // 卡批次有效期 0=永久 天
|
|
|
$info['card_json'] = "{}";
|
|
|
$info['card_assign_json'] = "{}";
|
|
@@ -180,12 +181,18 @@ class CardService
|
|
|
->count();
|
|
|
if (!empty($rows)) {
|
|
|
foreach ($rows as $key => &$value) {
|
|
|
- $value['card_status_value'] = $value['card_status'];
|
|
|
- $value['card_status'] = Card::CARD_STATUS[$value['card_status']];
|
|
|
+ $value['card_status_value'] = Card::CARD_STATUS[$value['card_status']];
|
|
|
!empty($value['card_json']) && $value['card_json'] = json_decode($value['card_json'], true);
|
|
|
!empty($value['card_assign_json']) && $value['card_assign_json'] = json_decode($value['card_assign_json'], true);
|
|
|
!empty($value['card_process_json']) && $value['card_process_json'] = json_decode($value['card_process_json'], true);
|
|
|
!empty($value['card_extend_json']) && $value['card_extend_json'] = json_decode($value['card_extend_json'], true);
|
|
|
+ $value['card_no'] = $value['card_prefix'] . $value['card_sort'] . $value['card_suffix'];
|
|
|
+ if ($value['card_validtimes'] == 0) {
|
|
|
+ $value['card_validtimes'] = "永久";
|
|
|
+ } else {
|
|
|
+ $value['card_validtimes'] = date("Y-m-d H:i:s", $value['card_validtimes']);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -223,9 +230,34 @@ class CardService
|
|
|
*/
|
|
|
public static function exportCard(Request $request)
|
|
|
{
|
|
|
- $card_ids = $request->get('card_id', '');
|
|
|
+ $params = $request->get();
|
|
|
+
|
|
|
+ $join_card_batch_id = $params['join_card_batch_id'] ?? "";
|
|
|
+ $join_card_category_id = $params['join_card_category_id'] ?? "";
|
|
|
+ $join_card_member_id = $params['join_card_member_id'] ?? "";
|
|
|
+ $card_status = !empty($params['card_status']) ? $params['card_status'] : "";
|
|
|
+ $card_category = $params['card_category'] ?? "";
|
|
|
+ $card_name = $params['card_name'] ?? "";
|
|
|
+ $card_ids = $params['card_id'] ?? "";
|
|
|
+
|
|
|
$cardModel = new Card();
|
|
|
- $list = $cardModel::select('*')->whereIn('card_id', $card_ids)->get()->toArray();
|
|
|
+ $list = $cardModel::select('*')
|
|
|
+ ->when(!empty($card_name) && $card_name != '', function ($query) use ($card_name) {
|
|
|
+ $query->where('card_name', 'like', '%' . $card_name . '%');
|
|
|
+ })->when(!empty($card_status), function ($query) use ($card_status) {
|
|
|
+ $query->where('card_status', $card_status);
|
|
|
+ })->when(!empty($join_card_batch_id), function ($query) use ($join_card_batch_id) {
|
|
|
+ $query->where('join_card_batch_id', $join_card_batch_id);
|
|
|
+ })->when(!empty($join_card_category_id), function ($query) use ($join_card_category_id) {
|
|
|
+ $query->where('join_card_category_id', $join_card_category_id);
|
|
|
+ })->when(!empty($join_card_member_id), function ($query) use ($join_card_member_id) {
|
|
|
+ $query->where('join_card_member_id', $join_card_member_id);
|
|
|
+ })->when(!empty($card_category), function ($query) use ($card_category) {
|
|
|
+ $query->where('card_category', $card_category);
|
|
|
+ })
|
|
|
+ ->whereIn('card_id', $card_ids)
|
|
|
+ ->get()
|
|
|
+ ->toArray();
|
|
|
$exportData = [];
|
|
|
// 增加签名
|
|
|
if (!empty($list)) {
|
|
@@ -235,14 +267,18 @@ class CardService
|
|
|
$info['card_prefix'] = $value['card_prefix'];
|
|
|
$info['card_suffix'] = $value['card_suffix'];
|
|
|
$info['card_sort'] = $value['card_sort'];
|
|
|
- $info['card_validtimes'] = $value['card_validtimes'];
|
|
|
+ if ($value['card_validtimes'] == 0) {
|
|
|
+ $info['card_validtimes'] = "永久";
|
|
|
+ } else {
|
|
|
+ $info['card_validtimes'] = date("Y-m-d H:i:s", $value['card_validtimes']);
|
|
|
+ }
|
|
|
// 生成签名
|
|
|
$card_no = $value['card_prefix'] . $value['card_sort'] . $value['card_suffix'];
|
|
|
$card_sign = self::generateSignature($info, $info['card_pass']);
|
|
|
$card_extend_json['action'] = "bind-card";
|
|
|
$card_extend_json['data'] = ["card_id" => $card_no, "card_sign" => $card_sign];
|
|
|
$info['card_no'] = $card_no;
|
|
|
- $info['card_extend_json'] = $card_extend_json;
|
|
|
+ $info['card_extend_json'] = json_encode($card_extend_json);
|
|
|
$exportData[] = $info;
|
|
|
}
|
|
|
}
|
|
@@ -365,5 +401,24 @@ class CardService
|
|
|
return json_success('success');
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Notes: 卡状态下拉列表
|
|
|
+ * User: ZhouBenXu
|
|
|
+ * DateTime: 2024/7/1 上午9:27
|
|
|
+ * @return Response
|
|
|
+ */
|
|
|
+ public static function getStatusList()
|
|
|
+ {
|
|
|
+ $data = [];
|
|
|
+ $statusList = Card::CARD_STATUS;
|
|
|
+ foreach ($statusList as $key => $value) {
|
|
|
+ $info = [];
|
|
|
+ $info['status'] = $key;
|
|
|
+ $info['status_value'] = $value;
|
|
|
+ $data[] = $info;
|
|
|
+ }
|
|
|
+ return json_success('', $data);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|