`a`.`deleted_at` IS NULL AND `c`.`deleted_at` IS NULL AND `a`.`store_id` = #{storeId} AND ( `c`.`code` LIKE CONCAT('%', #{keyword}, '%') OR `c`.`name` LIKE CONCAT('%', #{keyword}, '%') OR `c`.`telephone` LIKE CONCAT('%', #{keyword}, '%') OR `c`.`name_pinyin_full` LIKE CONCAT(#{keyword}, '%') OR `c`.`name_pinyin_initial` LIKE CONCAT(#{keyword}, '%') OR `c`.`name_pinyin_mixed` LIKE CONCAT(#{keyword}, '%') ) INSERT INTO `gao_point_account` ( `id`, `store_id`, `customer_id`, `balance`, `total_earned`, `total_consumed`, `total_revoked`, `total_adjusted`, `version`, `created_at`, `updated_at`, `deleted_at` ) VALUES ( #{account.id}, #{account.storeId}, #{account.customerId}, #{account.balance}, #{account.totalEarned}, #{account.totalConsumed}, #{account.totalRevoked}, #{account.totalAdjusted}, #{account.version}, #{account.createdAt}, #{account.updatedAt}, #{account.deletedAt} ) ON DUPLICATE KEY UPDATE `id` = `id` UPDATE `gao_point_account` SET `balance` = `balance` + #{delta}, `total_earned` = `total_earned` + #{totalEarnedDelta}, `total_consumed` = `total_consumed` + #{totalConsumedDelta}, `total_revoked` = `total_revoked` + #{totalRevokedDelta}, `total_adjusted` = `total_adjusted` + #{totalAdjustedDelta}, `version` = `version` + 1, `updated_at` = #{updatedAt} WHERE `id` = #{id} AND `balance` + #{delta} >= 0 AND `deleted_at` IS NULL